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)24
-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)21
-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--bitflags/.gitignore4
-rw-r--r--bitflags/.travis.yml39
-rw-r--r--bitflags/CHANGELOG.md149
-rw-r--r--bitflags/CODE_OF_CONDUCT.md73
-rw-r--r--bitflags/Cargo.toml37
-rw-r--r--bitflags/LICENSE-APACHE201
-rw-r--r--bitflags/LICENSE-MIT25
-rw-r--r--bitflags/README.md34
-rw-r--r--bitflags/bors.toml3
-rw-r--r--bitflags/build.rs44
-rw-r--r--bitflags/src/example_generated.rs14
-rw-r--r--bitflags/src/lib.rs1430
-rw-r--r--bitflags/test_suite/Cargo.toml13
-rw-r--r--bitflags/test_suite/tests/compile-fail/private_flags.rs20
-rw-r--r--bitflags/test_suite/tests/compiletest.rs33
-rw-r--r--bitflags/test_suite/tests/conflicting_trait_impls.rs17
-rw-r--r--bitflags/test_suite/tests/external.rs19
-rw-r--r--bitflags/test_suite/tests/external_no_std.rs21
-rw-r--r--bitflags/test_suite/tests/i128_bitflags.rs30
-rw-r--r--bitflags/test_suite/tests/serde.rs35
-rw-r--r--cc/.github/workflows/main.yml124
-rw-r--r--cc/.gitignore4
-rw-r--r--cc/Cargo.toml28
-rw-r--r--cc/LICENSE-APACHE201
-rw-r--r--cc/LICENSE-MIT25
-rw-r--r--cc/README.md194
-rw-r--r--cc/cc-test/Cargo.toml16
-rw-r--r--cc/cc-test/build.rs88
-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.rs58
-rw-r--r--cc/src/bin/gcc-shim.rs48
-rw-r--r--cc/src/com.rs155
-rw-r--r--cc/src/lib.rs2666
-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.rs754
-rw-r--r--cc/tests/cc_env.rs118
-rw-r--r--cc/tests/cflags.rs15
-rw-r--r--cc/tests/cxxflags.rs15
-rw-r--r--cc/tests/support/mod.rs161
-rw-r--r--cc/tests/test.rs377
-rw-r--r--cfg-if/.github/workflows/main.yml53
-rw-r--r--cfg-if/.gitignore2
-rw-r--r--cfg-if/Cargo.toml25
-rw-r--r--cfg-if/LICENSE-APACHE201
-rw-r--r--cfg-if/LICENSE-MIT25
-rw-r--r--cfg-if/README.md47
-rw-r--r--cfg-if/src/lib.rs176
-rw-r--r--cfg-if/tests/xcrate.rs14
-rw-r--r--ci/gitlab-ci.yml (renamed from nitrocli/ci/gitlab-ci.yml)14
-rw-r--r--clap/.appveyor.yml17
-rw-r--r--clap/.clog.toml14
-rw-r--r--clap/.github/CONTRIBUTING.md115
-rw-r--r--clap/.github/ISSUE_TEMPLATE.md46
-rw-r--r--clap/.gitignore27
-rw-r--r--clap/.mention-bot9
-rw-r--r--clap/.travis.yml59
-rw-r--r--clap/CHANGELOG.md2855
-rw-r--r--clap/CONTRIBUTORS.md91
-rw-r--r--clap/Cargo.toml91
-rw-r--r--clap/LICENSE-MIT21
-rw-r--r--clap/README.md542
-rw-r--r--clap/SPONSORS.md17
-rw-r--r--clap/benches/01_default.rs18
-rw-r--r--clap/benches/02_simple.rs114
-rw-r--r--clap/benches/03_complex.rs230
-rw-r--r--clap/benches/04_new_help.rs198
-rw-r--r--clap/benches/05_ripgrep.rs777
-rw-r--r--clap/benches/06_rustup.rs458
-rw-r--r--clap/clap-perf/clap_perf.dat8
-rw-r--r--clap/clap-perf/clap_perf.pngbin9702 -> 0 bytes
-rwxr-xr-xclap/clap-perf/plot_perf.gp26
-rw-r--r--clap/clap-test.rs86
-rw-r--r--clap/clap_dep_graph.dot41
-rw-r--r--clap/clap_dep_graph.pngbin96195 -> 0 bytes
-rw-r--r--clap/examples/01a_quick_example.rs79
-rw-r--r--clap/examples/01b_quick_example.rs93
-rw-r--r--clap/examples/01c_quick_example.rs75
-rw-r--r--clap/examples/02_apps.rs30
-rw-r--r--clap/examples/03_args.rs84
-rw-r--r--clap/examples/04_using_matches.rs54
-rw-r--r--clap/examples/05_flag_args.rs56
-rw-r--r--clap/examples/06_positional_args.rs56
-rw-r--r--clap/examples/07_option_args.rs71
-rw-r--r--clap/examples/08_subcommands.rs57
-rw-r--r--clap/examples/09_auto_version.rs29
-rw-r--r--clap/examples/10_default_values.rs40
-rw-r--r--clap/examples/11_only_specific_values.rs33
-rw-r--r--clap/examples/12_typed_values.rs50
-rw-r--r--clap/examples/13a_enum_values_automatic.rs68
-rw-r--r--clap/examples/13b_enum_values_manual.rs54
-rw-r--r--clap/examples/14_groups.rs87
-rw-r--r--clap/examples/15_custom_validator.rs37
-rw-r--r--clap/examples/16_app_settings.rs41
-rw-r--r--clap/examples/17_yaml.rs53
-rw-r--r--clap/examples/17_yaml.yml97
-rw-r--r--clap/examples/18_builder_macro.rs84
-rw-r--r--clap/examples/19_auto_authors.rs15
-rw-r--r--clap/examples/20_subcommands.rs143
-rw-r--r--clap/examples/21_aliases.rs39
-rw-r--r--clap/examples/22_stop_parsing_with_--.rs25
-rw-r--r--clap/justfile39
-rw-r--r--clap/rustfmt.toml4
-rw-r--r--clap/src/app/help.rs1028
-rw-r--r--clap/src/app/meta.rs33
-rw-r--r--clap/src/app/mod.rs1839
-rw-r--r--clap/src/app/parser.rs2167
-rw-r--r--clap/src/app/settings.rs1174
-rw-r--r--clap/src/app/usage.rs479
-rw-r--r--clap/src/app/validator.rs573
-rw-r--r--clap/src/args/any_arg.rs74
-rw-r--r--clap/src/args/arg.rs3954
-rw-r--r--clap/src/args/arg_builder/base.rs38
-rw-r--r--clap/src/args/arg_builder/flag.rs159
-rw-r--r--clap/src/args/arg_builder/mod.rs13
-rw-r--r--clap/src/args/arg_builder/option.rs244
-rw-r--r--clap/src/args/arg_builder/positional.rs229
-rw-r--r--clap/src/args/arg_builder/switched.rs38
-rw-r--r--clap/src/args/arg_builder/valued.rs67
-rw-r--r--clap/src/args/arg_matcher.rs218
-rw-r--r--clap/src/args/arg_matches.rs963
-rw-r--r--clap/src/args/group.rs635
-rw-r--r--clap/src/args/macros.rs109
-rw-r--r--clap/src/args/matched_arg.rs24
-rw-r--r--clap/src/args/mod.rs21
-rw-r--r--clap/src/args/settings.rs231
-rw-r--r--clap/src/args/subcommand.rs66
-rw-r--r--clap/src/completions/bash.rs219
-rw-r--r--clap/src/completions/elvish.rs126
-rw-r--r--clap/src/completions/fish.rs99
-rw-r--r--clap/src/completions/macros.rs28
-rw-r--r--clap/src/completions/mod.rs179
-rw-r--r--clap/src/completions/powershell.rs139
-rw-r--r--clap/src/completions/shell.rs52
-rw-r--r--clap/src/completions/zsh.rs472
-rw-r--r--clap/src/errors.rs912
-rw-r--r--clap/src/fmt.rs189
-rw-r--r--clap/src/lib.rs629
-rw-r--r--clap/src/macros.rs1108
-rw-r--r--clap/src/map.rs74
-rw-r--r--clap/src/osstringext.rs119
-rw-r--r--clap/src/strext.rs16
-rw-r--r--clap/src/suggestions.rs147
-rw-r--r--clap/src/usage_parser.rs1347
-rw-r--r--clap/tests/app.yml121
-rw-r--r--clap/tests/app_settings.rs965
-rw-r--r--clap/tests/arg_aliases.rs200
-rw-r--r--clap/tests/borrowed.rs19
-rw-r--r--clap/tests/completions.rs883
-rw-r--r--clap/tests/conflicts.rs102
-rw-r--r--clap/tests/default_vals.rs498
-rw-r--r--clap/tests/delimiters.rs139
-rw-r--r--clap/tests/derive_order.rs245
-rw-r--r--clap/tests/env.rs263
-rw-r--r--clap/tests/example1_tmpl_full.txt15
-rw-r--r--clap/tests/example1_tmpl_simple.txt8
-rw-r--r--clap/tests/flags.rs147
-rw-r--r--clap/tests/global_args.rs37
-rw-r--r--clap/tests/groups.rs207
-rw-r--r--clap/tests/help.rs1205
-rw-r--r--clap/tests/hidden_args.rs178
-rw-r--r--clap/tests/indices.rs175
-rwxr-xr-xclap/tests/macros.rs391
-rw-r--r--clap/tests/multiple_occurrences.rs75
-rw-r--r--clap/tests/multiple_values.rs1122
-rw-r--r--clap/tests/opts.rs461
-rw-r--r--clap/tests/positionals.rs274
-rw-r--r--clap/tests/posix_compatible.rs292
-rw-r--r--clap/tests/possible_values.rs266
-rw-r--r--clap/tests/propagate_globals.rs148
-rw-r--r--clap/tests/require.rs688
-rw-r--r--clap/tests/subcommands.rs216
-rw-r--r--clap/tests/template_help.rs117
-rw-r--r--clap/tests/tests.rs435
-rw-r--r--clap/tests/unique_args.rs22
-rw-r--r--clap/tests/utf8.rs223
-rw-r--r--clap/tests/version-numbers.rs12
-rw-r--r--clap/tests/version.rs58
-rw-r--r--clap/tests/yaml.rs40
-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)0
-rw-r--r--doc/nitrocli.1.pdf (renamed from nitrocli/doc/nitrocli.1.pdf)bin38453 -> 38453 bytes
-rw-r--r--doc/packaging.md (renamed from nitrocli/doc/packaging.md)0
-rw-r--r--getrandom/.cargo/config5
-rw-r--r--getrandom/.gitignore6
-rw-r--r--getrandom/.travis.yml221
-rw-r--r--getrandom/CHANGELOG.md158
-rw-r--r--getrandom/Cargo.toml45
-rw-r--r--getrandom/LICENSE-APACHE201
-rw-r--r--getrandom/LICENSE-MIT26
-rw-r--r--getrandom/README.md78
-rw-r--r--getrandom/appveyor.yml52
-rw-r--r--getrandom/benches/mod.rs23
-rw-r--r--getrandom/build.rs19
-rw-r--r--getrandom/src/bsd_arandom.rs49
-rw-r--r--getrandom/src/cloudabi.rs25
-rw-r--r--getrandom/src/dummy.rs14
-rw-r--r--getrandom/src/error.rs178
-rw-r--r--getrandom/src/error_impls.rs35
-rw-r--r--getrandom/src/fuchsia.rs20
-rw-r--r--getrandom/src/ios.rs31
-rw-r--r--getrandom/src/lib.rs282
-rw-r--r--getrandom/src/linux_android.rs44
-rw-r--r--getrandom/src/macos.rs34
-rw-r--r--getrandom/src/openbsd.rs23
-rw-r--r--getrandom/src/rdrand.rs90
-rw-r--r--getrandom/src/solaris_illumos.rs44
-rw-r--r--getrandom/src/use_file.rs73
-rw-r--r--getrandom/src/util.rs96
-rw-r--r--getrandom/src/util_libc.rs143
-rw-r--r--getrandom/src/vxworks.rs35
-rw-r--r--getrandom/src/wasi.rs19
-rw-r--r--getrandom/src/wasm32_bindgen.rs113
-rw-r--r--getrandom/src/wasm32_stdweb.rs114
-rw-r--r--getrandom/src/windows.rs26
-rw-r--r--getrandom/src/windows_uwp.rs59
-rw-r--r--getrandom/tests/common.rs68
-rw-r--r--getrandom/utils/ci/install.sh49
-rw-r--r--getrandom/utils/ci/script.sh13
-rw-r--r--heck/.gitignore2
-rw-r--r--heck/Cargo.toml14
-rw-r--r--heck/LICENSE-APACHE201
-rw-r--r--heck/LICENSE-MIT25
-rw-r--r--heck/README.md56
-rw-r--r--heck/no_step_on_snek.pngbin43512 -> 0 bytes
-rw-r--r--heck/src/camel.rs52
-rw-r--r--heck/src/kebab.rs51
-rw-r--r--heck/src/lib.rs165
-rw-r--r--heck/src/mixed.rs56
-rw-r--r--heck/src/shouty_snake.rs67
-rw-r--r--heck/src/snake.rs79
-rw-r--r--heck/src/title.rs52
-rw-r--r--lazy-static/.gitignore4
-rw-r--r--lazy-static/.travis.yml34
-rw-r--r--lazy-static/Cargo.toml34
-rw-r--r--lazy-static/LICENSE-APACHE201
-rw-r--r--lazy-static/LICENSE-MIT25
-rw-r--r--lazy-static/README.md79
-rw-r--r--lazy-static/appveyor.yml61
-rw-r--r--lazy-static/compiletest/Cargo.toml11
-rw-r--r--lazy-static/compiletest/src/lib.rs11
-rw-r--r--lazy-static/compiletest/tests/compile-fail/README.md22
-rw-r--r--lazy-static/compiletest/tests/compile-fail/incorrect_visibility_restriction.rs10
-rw-r--r--lazy-static/compiletest/tests/compile-fail/static_is_private.rs14
-rw-r--r--lazy-static/compiletest/tests/compile-fail/static_is_sized.rs11
-rw-r--r--lazy-static/compiletest/tests/compile_tests.rs19
-rw-r--r--lazy-static/src/core_lazy.rs31
-rw-r--r--lazy-static/src/inline_lazy.rs57
-rw-r--r--lazy-static/src/lib.rs215
-rw-r--r--lazy-static/tests/no_std.rs20
-rw-r--r--lazy-static/tests/test.rs164
-rw-r--r--libc/.cirrus.yml43
-rw-r--r--libc/.github/issue_template.md24
-rw-r--r--libc/.gitignore4
-rw-r--r--libc/CONTRIBUTING.md66
-rw-r--r--libc/Cargo.toml36
-rw-r--r--libc/LICENSE-APACHE201
-rw-r--r--libc/LICENSE-MIT25
-rw-r--r--libc/README.md106
-rw-r--r--libc/build.rs144
-rw-r--r--libc/ci/README.md236
-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/azure-install-rust.yml82
-rw-r--r--libc/ci/azure-master.yml22
-rw-r--r--libc/ci/azure.yml228
-rw-r--r--libc/ci/build.sh272
-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/Dockerfile21
-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/Dockerfile24
-rw-r--r--libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile11
-rw-r--r--libc/ci/docker/mips64-unknown-linux-muslabi64/Dockerfile15
-rw-r--r--libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile11
-rw-r--r--libc/ci/docker/mips64el-unknown-linux-muslabi64/Dockerfile15
-rw-r--r--libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile24
-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/Dockerfile28
-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.sh74
-rwxr-xr-xlibc/ci/emscripten-entry.sh20
-rw-r--r--libc/ci/emscripten.sh52
-rw-r--r--libc/ci/install-musl.sh83
-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.sh46
-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.sh77
-rw-r--r--libc/ci/style.rs208
-rw-r--r--libc/ci/style.sh19
-rw-r--r--libc/ci/switch.json37
-rw-r--r--libc/ci/sysinfo_guard.patch10
-rwxr-xr-xlibc/ci/test-runner-linux25
-rw-r--r--libc/libc-test/Cargo.toml54
-rw-r--r--libc/libc-test/build.rs2658
-rw-r--r--libc/libc-test/src/cmsg.c28
-rw-r--r--libc/libc-test/test/cmsg.rs100
-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.rs374
-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.rs20
-rw-r--r--libc/src/fuchsia/aarch64.rs66
-rw-r--r--libc/src/fuchsia/align.rs142
-rw-r--r--libc/src/fuchsia/mod.rs4571
-rw-r--r--libc/src/fuchsia/no_align.rs129
-rw-r--r--libc/src/fuchsia/x86_64.rs152
-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.rs157
-rw-r--r--libc/src/macros.rs275
-rw-r--r--libc/src/sgx.rs47
-rw-r--r--libc/src/switch.rs49
-rw-r--r--libc/src/unix/align.rs6
-rw-r--r--libc/src/unix/bsd/apple/b32/align.rs7
-rw-r--r--libc/src/unix/bsd/apple/b32/mod.rs115
-rw-r--r--libc/src/unix/bsd/apple/b64/align.rs7
-rw-r--r--libc/src/unix/bsd/apple/b64/mod.rs120
-rw-r--r--libc/src/unix/bsd/apple/mod.rs3543
-rw-r--r--libc/src/unix/bsd/freebsdlike/dragonfly/errno.rs12
-rw-r--r--libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs1096
-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.rs224
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs32
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs224
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs34
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/mod.rs1486
-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/align.rs7
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs24
-rw-r--r--libc/src/unix/bsd/freebsdlike/mod.rs1466
-rw-r--r--libc/src/unix/bsd/mod.rs794
-rw-r--r--libc/src/unix/bsd/netbsdlike/mod.rs765
-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.rs1965
-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.rs16
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/mod.rs1509
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs8
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/x86.rs16
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs24
-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.rs1531
-rw-r--r--libc/src/unix/hermit/aarch64.rs2
-rw-r--r--libc/src/unix/hermit/mod.rs1049
-rw-r--r--libc/src/unix/hermit/x86_64.rs2
-rw-r--r--libc/src/unix/linux_like/android/b32/arm.rs357
-rw-r--r--libc/src/unix/linux_like/android/b32/mod.rs221
-rw-r--r--libc/src/unix/linux_like/android/b32/x86/align.rs7
-rw-r--r--libc/src/unix/linux_like/android/b32/x86/mod.rs422
-rw-r--r--libc/src/unix/linux_like/android/b64/aarch64/align.rs7
-rw-r--r--libc/src/unix/linux_like/android/b64/aarch64/mod.rs332
-rw-r--r--libc/src/unix/linux_like/android/b64/mod.rs281
-rw-r--r--libc/src/unix/linux_like/android/b64/x86_64/align.rs7
-rw-r--r--libc/src/unix/linux_like/android/b64/x86_64/mod.rs427
-rw-r--r--libc/src/unix/linux_like/android/mod.rs2409
-rw-r--r--libc/src/unix/linux_like/emscripten/align.rs74
-rw-r--r--libc/src/unix/linux_like/emscripten/mod.rs1917
-rw-r--r--libc/src/unix/linux_like/emscripten/no_align.rs63
-rw-r--r--libc/src/unix/linux_like/linux/align.rs106
-rw-r--r--libc/src/unix/linux_like/linux/gnu/align.rs13
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs876
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/mips/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs901
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/mod.rs271
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs873
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/sparc/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs978
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/x86/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs1164
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs954
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/mips64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs1017
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/mod.rs87
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs1052
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs861
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/s390x.rs1029
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs988
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs929
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs423
-rw-r--r--libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs375
-rw-r--r--libc/src/unix/linux_like/linux/gnu/mod.rs1057
-rw-r--r--libc/src/unix/linux_like/linux/gnu/no_align.rs10
-rw-r--r--libc/src/unix/linux_like/linux/mod.rs3194
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/arm/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs845
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/hexagon.rs797
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/mips/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs849
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/mod.rs65
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/powerpc.rs863
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/x86/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs954
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/aarch64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs655
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/mips64.rs754
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/mod.rs169
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs739
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/x86_64/align.rs7
-rw-r--r--libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs961
-rw-r--r--libc/src/unix/linux_like/linux/musl/mod.rs436
-rw-r--r--libc/src/unix/linux_like/linux/no_align.rs84
-rw-r--r--libc/src/unix/linux_like/mod.rs1569
-rw-r--r--libc/src/unix/mod.rs1552
-rw-r--r--libc/src/unix/newlib/aarch64/mod.rs33
-rw-r--r--libc/src/unix/newlib/align.rs61
-rw-r--r--libc/src/unix/newlib/arm/mod.rs35
-rw-r--r--libc/src/unix/newlib/mod.rs725
-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/redox/mod.rs1114
-rw-r--r--libc/src/unix/solarish/compat.rs32
-rw-r--r--libc/src/unix/solarish/mod.rs2499
-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.rs1049
-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.rs633
-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.rs7
-rw-r--r--libc/src/unix/uclibc/mips/mod.rs479
-rw-r--r--libc/src/unix/uclibc/mod.rs2295
-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/vxworks/aarch64.rs4
-rw-r--r--libc/src/vxworks/arm.rs4
-rwxr-xr-xlibc/src/vxworks/mod.rs2086
-rw-r--r--libc/src/vxworks/powerpc.rs4
-rw-r--r--libc/src/vxworks/powerpc64.rs4
-rw-r--r--libc/src/vxworks/x86.rs4
-rw-r--r--libc/src/vxworks/x86_64.rs4
-rw-r--r--libc/src/wasi.rs743
-rw-r--r--libc/src/windows/gnu/align.rs19
-rw-r--r--libc/src/windows/gnu/mod.rs23
-rw-r--r--libc/src/windows/mod.rs604
-rw-r--r--libc/src/windows/msvc.rs17
-rw-r--r--libc/tests/const_fn.rs5
-rw-r--r--nitrocli/Cargo.lock255
-rw-r--r--nitrokey-sys/.gitignore4
-rw-r--r--nitrokey-sys/CHANGELOG.md76
-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.5/DeviceCommunicationExceptions.cpp24
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/LICENSE166
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/NK_C_API.cc910
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/NK_C_API.h1014
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/NitrokeyManager.cc1199
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/README.md291
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/command_id.cc188
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/device.cc345
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/CommandFailedException.h76
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/DeviceCommunicationExceptions.h73
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/LibraryException.h118
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/LongOperationInProgressException.h45
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/NitrokeyManager.h308
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/command.h112
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/command_id.h156
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/cxx_semantics.h44
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/deprecated.h35
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/device.h224
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/device_proto.h491
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/dissect.h145
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/hidapi/hidapi.h391
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/log.h109
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/misc.h121
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick10_commands.h929
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick10_commands_0.8.h348
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick20_commands.h394
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/libnitrokey/version.h33
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/log.cc103
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/misc.cc123
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/version.cc37
-rw-r--r--nitrokey-sys/libnitrokey-v3.5/version.cc.in37
-rw-r--r--nitrokey-sys/src/ffi.rs1481
-rw-r--r--nitrokey-sys/src/lib.rs31
-rw-r--r--nitrokey/.builds/archlinux-msrv.yml22
-rw-r--r--nitrokey/.builds/archlinux-use-system-lib.yml25
-rw-r--r--nitrokey/.builds/archlinux.yml16
-rw-r--r--nitrokey/.builds/lint.yml16
-rw-r--r--nitrokey/.gitignore7
-rw-r--r--nitrokey/CHANGELOG.md158
-rw-r--r--nitrokey/Cargo.toml27
-rw-r--r--nitrokey/LICENSES/CC0-1.0.txt121
-rw-r--r--nitrokey/LICENSES/MIT.txt24
-rw-r--r--nitrokey/README.md114
-rw-r--r--nitrokey/TODO.md10
-rw-r--r--nitrokey/examples/list-devices.rs26
-rw-r--r--nitrokey/examples/otp.rs43
-rw-r--r--nitrokey/src/auth.rs437
-rw-r--r--nitrokey/src/config.rs106
-rw-r--r--nitrokey/src/device/mod.rs668
-rw-r--r--nitrokey/src/device/pro.rs95
-rw-r--r--nitrokey/src/device/storage.rs884
-rw-r--r--nitrokey/src/device/wrapper.rs141
-rw-r--r--nitrokey/src/error.rs273
-rw-r--r--nitrokey/src/lib.rs597
-rw-r--r--nitrokey/src/otp.rs423
-rw-r--r--nitrokey/src/pws.rs391
-rw-r--r--nitrokey/src/util.rs99
-rw-r--r--nitrokey/tests/device.rs711
-rw-r--r--nitrokey/tests/lib.rs28
-rw-r--r--nitrokey/tests/otp.rs287
-rw-r--r--nitrokey/tests/pws.rs159
-rw-r--r--nitrokey/tests/util/mod.rs113
-rw-r--r--proc-macro-error/.gitignore4
-rw-r--r--proc-macro-error/.gitlab-ci.yml54
-rw-r--r--proc-macro-error/.travis.yml19
-rw-r--r--proc-macro-error/CHANGELOG.md86
-rw-r--r--proc-macro-error/Cargo.toml7
-rw-r--r--proc-macro-error/LICENSE-APACHE201
-rw-r--r--proc-macro-error/LICENSE-MIT21
-rw-r--r--proc-macro-error/README.md206
-rw-r--r--proc-macro-error/proc-macro-error-attr/Cargo.toml18
-rw-r--r--proc-macro-error/proc-macro-error-attr/src/lib.rs162
-rw-r--r--proc-macro-error/proc-macro-error/Cargo.toml26
-rw-r--r--proc-macro-error/proc-macro-error/build.rs11
-rw-r--r--proc-macro-error/proc-macro-error/src/dummy.rs136
-rw-r--r--proc-macro-error/proc-macro-error/src/lib.rs514
-rw-r--r--proc-macro-error/proc-macro-error/src/macros.rs257
-rw-r--r--proc-macro-error/proc-macro-error/src/nightly.rs49
-rw-r--r--proc-macro-error/proc-macro-error/src/stable.rs26
-rw-r--r--proc-macro-error/test-crate/Cargo.toml20
-rw-r--r--proc-macro-error/test-crate/src/lib.rs123
-rw-r--r--proc-macro-error/test-crate/tests/macro-errors.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ok.rs9
-rw-r--r--proc-macro-error/test-crate/tests/ui/abort.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/abort.stderr8
-rw-r--r--proc-macro-error/test-crate/tests/ui/call_site.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/call_site.stderr8
-rw-r--r--proc-macro-error/test-crate/tests/ui/direct_abort.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/direct_abort.stderr5
-rw-r--r--proc-macro-error/test-crate/tests/ui/dummy.rs16
-rw-r--r--proc-macro-error/test-crate/tests/ui/dummy.stderr5
-rw-r--r--proc-macro-error/test-crate/tests/ui/multi-error.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/multi-error.stderr32
-rw-r--r--proc-macro-error/test-crate/tests/ui/not_proc_macro.rs4
-rw-r--r--proc-macro-error/test-crate/tests/ui/not_proc_macro.stderr8
-rw-r--r--proc-macro-error/test-crate/tests/ui/option_expect.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/option_expect.stderr5
-rw-r--r--proc-macro-error/test-crate/tests/ui/result_expect.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/result_expect.stderr5
-rw-r--r--proc-macro-error/test-crate/tests/ui/result_unwrap.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/result_unwrap.stderr5
-rw-r--r--proc-macro-error/test-crate/tests/ui/unknown_setting.rs4
-rw-r--r--proc-macro-error/test-crate/tests/ui/unknown_setting.stderr5
-rw-r--r--proc-macro-error/test-crate/tests/ui/unrelated_panic.rs6
-rw-r--r--proc-macro-error/test-crate/tests/ui/unrelated_panic.stderr7
-rw-r--r--proc-macro2/.gitignore3
-rw-r--r--proc-macro2/.travis.yml36
-rw-r--r--proc-macro2/Cargo.toml57
-rw-r--r--proc-macro2/LICENSE-APACHE201
-rw-r--r--proc-macro2/LICENSE-MIT25
-rw-r--r--proc-macro2/README.md93
-rw-r--r--proc-macro2/benches/bench-libproc-macro/Cargo.toml13
-rw-r--r--proc-macro2/benches/bench-libproc-macro/README.md10
-rw-r--r--proc-macro2/benches/bench-libproc-macro/lib.rs49
-rw-r--r--proc-macro2/benches/bench-libproc-macro/main.rs3
-rw-r--r--proc-macro2/build.rs129
-rw-r--r--proc-macro2/src/fallback.rs1458
-rw-r--r--proc-macro2/src/lib.rs1199
-rw-r--r--proc-macro2/src/strnom.rs391
-rw-r--r--proc-macro2/src/wrapper.rs927
-rw-r--r--proc-macro2/tests/features.rs8
-rw-r--r--proc-macro2/tests/marker.rs59
-rw-r--r--proc-macro2/tests/test.rs466
-rw-r--r--quote/.gitignore2
-rw-r--r--quote/.travis.yml18
-rw-r--r--quote/Cargo.toml32
-rw-r--r--quote/LICENSE-APACHE201
-rw-r--r--quote/LICENSE-MIT25
-rw-r--r--quote/README.md237
-rw-r--r--quote/benches/bench.rs193
-rw-r--r--quote/src/ext.rs112
-rw-r--r--quote/src/format.rs164
-rw-r--r--quote/src/ident_fragment.rs72
-rw-r--r--quote/src/lib.rs948
-rw-r--r--quote/src/runtime.rs373
-rw-r--r--quote/src/spanned.rs42
-rw-r--r--quote/src/to_tokens.rs209
-rw-r--r--quote/tests/compiletest.rs6
-rw-r--r--quote/tests/test.rs429
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated-dup.rs9
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated-dup.stderr11
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated.rs9
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated.stderr11
-rw-r--r--quote/tests/ui/does-not-have-iter-separated.rs5
-rw-r--r--quote/tests/ui/does-not-have-iter-separated.stderr11
-rw-r--r--quote/tests/ui/does-not-have-iter.rs5
-rw-r--r--quote/tests/ui/does-not-have-iter.stderr11
-rw-r--r--quote/tests/ui/not-quotable.rs7
-rw-r--r--quote/tests/ui/not-quotable.stderr10
-rw-r--r--quote/tests/ui/not-repeatable.rs7
-rw-r--r--quote/tests/ui/not-repeatable.stderr14
-rw-r--r--quote/tests/ui/wrong-type-span.rs7
-rw-r--r--quote/tests/ui/wrong-type-span.stderr10
-rw-r--r--rand/.github/ISSUE_TEMPLATE/compile-issue.md16
-rw-r--r--rand/.github/ISSUE_TEMPLATE/feature_request.md18
-rw-r--r--rand/.github/ISSUE_TEMPLATE/other.md10
-rw-r--r--rand/.gitignore4
-rw-r--r--rand/.travis.yml315
-rw-r--r--rand/CHANGELOG.md568
-rw-r--r--rand/COPYRIGHT12
-rw-r--r--rand/Cargo.toml90
-rw-r--r--rand/LICENSE-APACHE201
-rw-r--r--rand/LICENSE-MIT26
-rw-r--r--rand/README.md118
-rw-r--r--rand/appveyor.yml49
-rw-r--r--rand/benches/generators.rs220
-rw-r--r--rand/benches/misc.rs140
-rw-r--r--rand/benches/seq.rs177
-rw-r--r--rand/benches/weighted.rs36
-rw-r--r--rand/examples/monte-carlo.rs48
-rw-r--r--rand/examples/monty-hall.rs112
-rw-r--r--rand/rand_chacha/CHANGELOG.md18
-rw-r--r--rand/rand_chacha/COPYRIGHT12
-rw-r--r--rand/rand_chacha/Cargo.toml28
-rw-r--r--rand/rand_chacha/LICENSE-APACHE201
-rw-r--r--rand/rand_chacha/LICENSE-MIT26
-rw-r--r--rand/rand_chacha/README.md49
-rw-r--r--rand/rand_chacha/src/chacha.rs452
-rw-r--r--rand/rand_chacha/src/lib.rs30
-rw-r--r--rand/rand_core/CHANGELOG.md58
-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.md82
-rw-r--r--rand/rand_core/src/block.rs437
-rw-r--r--rand/rand_core/src/error.rs190
-rw-r--r--rand/rand_core/src/impls.rs158
-rw-r--r--rand/rand_core/src/le.rs68
-rw-r--r--rand/rand_core/src/lib.rs492
-rw-r--r--rand/rand_core/src/os.rs85
-rw-r--r--rand/rand_distr/CHANGELOG.md21
-rw-r--r--rand/rand_distr/COPYRIGHT12
-rw-r--r--rand/rand_distr/Cargo.toml27
-rw-r--r--rand/rand_distr/LICENSE-APACHE201
-rw-r--r--rand/rand_distr/LICENSE-MIT25
-rw-r--r--rand/rand_distr/README.md42
-rw-r--r--rand/rand_distr/benches/distributions.rs316
-rw-r--r--rand/rand_distr/src/binomial.rs329
-rw-r--r--rand/rand_distr/src/cauchy.rs120
-rw-r--r--rand/rand_distr/src/dirichlet.rs154
-rw-r--r--rand/rand_distr/src/exponential.rs145
-rw-r--r--rand/rand_distr/src/gamma.rs485
-rw-r--r--rand/rand_distr/src/lib.rs134
-rw-r--r--rand/rand_distr/src/normal.rs219
-rw-r--r--rand/rand_distr/src/pareto.rs89
-rw-r--r--rand/rand_distr/src/pert.rs132
-rw-r--r--rand/rand_distr/src/poisson.rs233
-rw-r--r--rand/rand_distr/src/triangular.rs125
-rw-r--r--rand/rand_distr/src/unit_ball.rs69
-rw-r--r--rand/rand_distr/src/unit_circle.rs99
-rw-r--r--rand/rand_distr/src/unit_disc.rs66
-rw-r--r--rand/rand_distr/src/unit_sphere.rs94
-rw-r--r--rand/rand_distr/src/utils.rs234
-rw-r--r--rand/rand_distr/src/weibull.rs86
-rw-r--r--rand/rand_distr/src/ziggurat_tables.rs279
-rw-r--r--rand/rand_distr/tests/uniformity.rs59
-rw-r--r--rand/rand_hc/CHANGELOG.md16
-rw-r--r--rand/rand_hc/COPYRIGHT12
-rw-r--r--rand/rand_hc/Cargo.toml22
-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.rs464
-rw-r--r--rand/rand_hc/src/lib.rs23
-rw-r--r--rand/rand_isaac/CHANGELOG.md21
-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.rs476
-rw-r--r--rand/rand_isaac/src/isaac64.rs466
-rw-r--r--rand/rand_isaac/src/isaac_array.rs136
-rw-r--r--rand/rand_isaac/src/lib.rs27
-rw-r--r--rand/rand_jitter/CHANGELOG.md32
-rw-r--r--rand/rand_jitter/COPYRIGHT12
-rw-r--r--rand/rand_jitter/Cargo.toml30
-rw-r--r--rand/rand_jitter/LICENSE-APACHE201
-rw-r--r--rand/rand_jitter/LICENSE-MIT26
-rw-r--r--rand/rand_jitter/README.md119
-rw-r--r--rand/rand_jitter/benches/mod.rs17
-rw-r--r--rand/rand_jitter/src/error.rs77
-rw-r--r--rand/rand_jitter/src/lib.rs750
-rw-r--r--rand/rand_jitter/src/platform.rs44
-rw-r--r--rand/rand_jitter/tests/mod.rs28
-rw-r--r--rand/rand_os/CHANGELOG.md35
-rw-r--r--rand/rand_os/COPYRIGHT12
-rw-r--r--rand/rand_os/Cargo.toml26
-rw-r--r--rand/rand_os/LICENSE-APACHE201
-rw-r--r--rand/rand_os/LICENSE-MIT26
-rw-r--r--rand/rand_os/README.md35
-rw-r--r--rand/rand_os/src/lib.rs106
-rw-r--r--rand/rand_pcg/CHANGELOG.md24
-rw-r--r--rand/rand_pcg/COPYRIGHT12
-rw-r--r--rand/rand_pcg/Cargo.toml32
-rw-r--r--rand/rand_pcg/LICENSE-APACHE201
-rw-r--r--rand/rand_pcg/LICENSE-MIT26
-rw-r--r--rand/rand_pcg/README.md43
-rw-r--r--rand/rand_pcg/src/lib.rs49
-rw-r--r--rand/rand_pcg/src/pcg128.rs225
-rw-r--r--rand/rand_pcg/src/pcg64.rs127
-rw-r--r--rand/rand_pcg/tests/lcg128xsl64.rs55
-rw-r--r--rand/rand_pcg/tests/lcg64xsh32.rs54
-rw-r--r--rand/rand_pcg/tests/mcg128xsl64.rs54
-rw-r--r--rand/rand_xorshift/CHANGELOG.md19
-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.rs117
-rw-r--r--rand/rand_xorshift/tests/mod.rs89
-rw-r--r--rand/rand_xoshiro/CHANGELOG.md24
-rw-r--r--rand/rand_xoshiro/COPYRIGHT12
-rw-r--r--rand/rand_xoshiro/Cargo.toml25
-rw-r--r--rand/rand_xoshiro/LICENSE-APACHE201
-rw-r--r--rand/rand_xoshiro/LICENSE-MIT25
-rw-r--r--rand/rand_xoshiro/README.md34
-rw-r--r--rand/rand_xoshiro/src/common.rs243
-rw-r--r--rand/rand_xoshiro/src/lib.rs94
-rw-r--r--rand/rand_xoshiro/src/splitmix64.rs149
-rw-r--r--rand/rand_xoshiro/src/xoroshiro128plus.rs130
-rw-r--r--rand/rand_xoshiro/src/xoroshiro128starstar.rs127
-rw-r--r--rand/rand_xoshiro/src/xoroshiro64star.rs102
-rw-r--r--rand/rand_xoshiro/src/xoroshiro64starstar.rs101
-rw-r--r--rand/rand_xoshiro/src/xoshiro128plus.rs112
-rw-r--r--rand/rand_xoshiro/src/xoshiro128starstar.rs111
-rw-r--r--rand/rand_xoshiro/src/xoshiro256plus.rs131
-rw-r--r--rand/rand_xoshiro/src/xoshiro256starstar.rs128
-rw-r--r--rand/rand_xoshiro/src/xoshiro512plus.rs122
-rw-r--r--rand/rand_xoshiro/src/xoshiro512starstar.rs122
-rw-r--r--rand/rand_xoshiro/tests/serde.rs83
-rw-r--r--rand/rustfmt.toml30
-rw-r--r--rand/src/distributions/bernoulli.rs166
-rw-r--r--rand/src/distributions/binomial.rs313
-rw-r--r--rand/src/distributions/cauchy.rs103
-rw-r--r--rand/src/distributions/dirichlet.rs128
-rw-r--r--rand/src/distributions/exponential.rs108
-rw-r--r--rand/src/distributions/float.rs259
-rw-r--r--rand/src/distributions/gamma.rs371
-rw-r--r--rand/src/distributions/integer.rs184
-rw-r--r--rand/src/distributions/mod.rs381
-rw-r--r--rand/src/distributions/normal.rs170
-rw-r--r--rand/src/distributions/other.rs220
-rw-r--r--rand/src/distributions/pareto.rs67
-rw-r--r--rand/src/distributions/poisson.rs151
-rw-r--r--rand/src/distributions/triangular.rs79
-rw-r--r--rand/src/distributions/uniform.rs1270
-rw-r--r--rand/src/distributions/unit_circle.rs101
-rw-r--r--rand/src/distributions/unit_sphere.rs96
-rw-r--r--rand/src/distributions/utils.rs488
-rw-r--r--rand/src/distributions/weibull.rs64
-rw-r--r--rand/src/distributions/weighted/alias_method.rs499
-rw-r--r--rand/src/distributions/weighted/mod.rs363
-rw-r--r--rand/src/distributions/ziggurat_tables.rs279
-rw-r--r--rand/src/lib.rs720
-rw-r--r--rand/src/prelude.rs28
-rw-r--r--rand/src/rngs/adapter/mod.rs15
-rw-r--r--rand/src/rngs/adapter/read.rs148
-rw-r--r--rand/src/rngs/adapter/reseeding.rs357
-rw-r--r--rand/src/rngs/entropy.rs76
-rw-r--r--rand/src/rngs/mock.rs64
-rw-r--r--rand/src/rngs/mod.rs119
-rw-r--r--rand/src/rngs/small.rs115
-rw-r--r--rand/src/rngs/std.rs100
-rw-r--r--rand/src/rngs/thread.rs124
-rw-r--r--rand/src/seq/index.rs409
-rw-r--r--rand/src/seq/mod.rs791
-rw-r--r--rand/tests/wasm_bindgen/Cargo.toml16
-rw-r--r--rand/tests/wasm_bindgen/js/index.js7
-rw-r--r--rand/tests/wasm_bindgen/src/lib.rs49
-rw-r--r--rand/utils/ci/install.sh49
-rwxr-xr-xrand/utils/ci/install_cargo_web.sh15
-rw-r--r--rand/utils/ci/miri.sh23
-rw-r--r--rand/utils/ci/script.sh27
-rwxr-xr-xrand/utils/ziggurat_tables.py125
-rw-r--r--rustfmt.toml (renamed from nitrocli/rustfmt.toml)0
-rw-r--r--rustversion/.gitignore3
-rw-r--r--rustversion/.travis.yml17
-rw-r--r--rustversion/Cargo.toml21
-rw-r--r--rustversion/LICENSE-APACHE201
-rw-r--r--rustversion/LICENSE-MIT23
-rw-r--r--rustversion/README.md138
-rw-r--r--rustversion/src/attr.rs35
-rw-r--r--rustversion/src/bound.rs84
-rw-r--r--rustversion/src/date.rs77
-rw-r--r--rustversion/src/expr.rs177
-rw-r--r--rustversion/src/lib.rs254
-rw-r--r--rustversion/src/rustc.rs195
-rw-r--r--rustversion/src/time.rs44
-rw-r--r--rustversion/src/version.rs16
-rw-r--r--src/arg_util.rs (renamed from nitrocli/src/arg_util.rs)14
-rw-r--r--src/args.rs (renamed from nitrocli/src/args.rs)367
-rw-r--r--src/commands.rs (renamed from nitrocli/src/commands.rs)198
-rw-r--r--src/error.rs (renamed from nitrocli/src/error.rs)6
-rw-r--r--src/main.rs (renamed from nitrocli/src/main.rs)85
-rw-r--r--src/pinentry.rs (renamed from nitrocli/src/pinentry.rs)41
-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)0
-rw-r--r--src/tests/encrypted.rs (renamed from nitrocli/src/tests/encrypted.rs)0
-rw-r--r--src/tests/hidden.rs (renamed from nitrocli/src/tests/hidden.rs)0
-rw-r--r--src/tests/list.rs (renamed from nitrocli/src/tests/list.rs)0
-rw-r--r--src/tests/lock.rs (renamed from nitrocli/src/tests/lock.rs)0
-rw-r--r--src/tests/mod.rs (renamed from nitrocli/src/tests/mod.rs)2
-rw-r--r--src/tests/otp.rs (renamed from nitrocli/src/tests/otp.rs)2
-rw-r--r--src/tests/pin.rs (renamed from nitrocli/src/tests/pin.rs)0
-rw-r--r--src/tests/pws.rs (renamed from nitrocli/src/tests/pws.rs)0
-rw-r--r--src/tests/reset.rs (renamed from nitrocli/src/tests/reset.rs)0
-rw-r--r--src/tests/run.rs (renamed from nitrocli/src/tests/run.rs)0
-rw-r--r--src/tests/status.rs (renamed from nitrocli/src/tests/status.rs)0
-rw-r--r--src/tests/unencrypted.rs (renamed from nitrocli/src/tests/unencrypted.rs)0
-rw-r--r--structopt/.gitignore6
-rw-r--r--structopt/.travis.yml24
-rw-r--r--structopt/CHANGELOG.md444
-rw-r--r--structopt/Cargo.toml35
-rw-r--r--structopt/LICENSE-APACHE201
-rw-r--r--structopt/LICENSE-MIT21
-rw-r--r--structopt/README.md148
-rw-r--r--structopt/examples/README.md82
-rw-r--r--structopt/examples/after_help.rs19
-rw-r--r--structopt/examples/at_least_two.rs15
-rw-r--r--structopt/examples/basic.rs48
-rw-r--r--structopt/examples/deny_missing_docs.rs51
-rw-r--r--structopt/examples/doc_comments.rs74
-rw-r--r--structopt/examples/enum_in_args.rs25
-rw-r--r--structopt/examples/enum_tuple.rs26
-rw-r--r--structopt/examples/env.rs26
-rw-r--r--structopt/examples/example.rs54
-rw-r--r--structopt/examples/flatten.rs29
-rw-r--r--structopt/examples/gen_completions.rs26
-rw-r--r--structopt/examples/git.rs35
-rw-r--r--structopt/examples/group.rs31
-rw-r--r--structopt/examples/keyvalue.rs36
-rw-r--r--structopt/examples/negative_flag.rs15
-rw-r--r--structopt/examples/no_version.rs17
-rw-r--r--structopt/examples/rename_all.rs74
-rw-r--r--structopt/examples/skip.rs47
-rw-r--r--structopt/examples/subcommand_aliases.rs21
-rw-r--r--structopt/examples/true_or_false.rs41
-rw-r--r--structopt/link-check-headers.json14
-rw-r--r--structopt/src/lib.rs1015
-rw-r--r--structopt/structopt-derive/Cargo.toml27
-rw-r--r--structopt/structopt-derive/LICENSE-APACHE201
-rw-r--r--structopt/structopt-derive/LICENSE-MIT21
-rw-r--r--structopt/structopt-derive/src/attrs.rs620
-rw-r--r--structopt/structopt-derive/src/doc_comments.rs103
-rw-r--r--structopt/structopt-derive/src/lib.rs667
-rw-r--r--structopt/structopt-derive/src/parse.rs304
-rw-r--r--structopt/structopt-derive/src/spanned.rs101
-rw-r--r--structopt/structopt-derive/src/ty.rs108
-rw-r--r--structopt/tests/argument_naming.rs311
-rw-r--r--structopt/tests/arguments.rs86
-rw-r--r--structopt/tests/author_version_about.rs46
-rw-r--r--structopt/tests/custom-string-parsers.rs306
-rw-r--r--structopt/tests/deny-warnings.rs47
-rw-r--r--structopt/tests/doc-comments-help.rs162
-rw-r--r--structopt/tests/explicit_name_no_renaming.rs32
-rw-r--r--structopt/tests/flags.rs162
-rw-r--r--structopt/tests/flatten.rs95
-rw-r--r--structopt/tests/issues.rs67
-rw-r--r--structopt/tests/macro-errors.rs13
-rw-r--r--structopt/tests/nested-subcommands.rs193
-rw-r--r--structopt/tests/non_literal_attributes.rs147
-rw-r--r--structopt/tests/options.rs336
-rw-r--r--structopt/tests/privacy.rs32
-rw-r--r--structopt/tests/raw_bool_literal.rs29
-rw-r--r--structopt/tests/raw_idents.rs17
-rw-r--r--structopt/tests/rename_all_env.rs46
-rw-r--r--structopt/tests/skip.rs148
-rw-r--r--structopt/tests/special_types.rs73
-rw-r--r--structopt/tests/subcommands.rs213
-rw-r--r--structopt/tests/ui/bool_default_value.rs21
-rw-r--r--structopt/tests/ui/bool_default_value.stderr5
-rw-r--r--structopt/tests/ui/bool_required.rs21
-rw-r--r--structopt/tests/ui/bool_required.stderr5
-rw-r--r--structopt/tests/ui/flatten_and_doc.rs30
-rw-r--r--structopt/tests/ui/flatten_and_doc.stderr5
-rw-r--r--structopt/tests/ui/flatten_and_methods.rs29
-rw-r--r--structopt/tests/ui/flatten_and_methods.stderr5
-rw-r--r--structopt/tests/ui/flatten_and_parse.rs29
-rw-r--r--structopt/tests/ui/flatten_and_parse.stderr5
-rw-r--r--structopt/tests/ui/non_existent_attr.rs21
-rw-r--r--structopt/tests/ui/non_existent_attr.stderr5
-rw-r--r--structopt/tests/ui/opt_opt_nonpositional.rs20
-rw-r--r--structopt/tests/ui/opt_opt_nonpositional.stderr5
-rw-r--r--structopt/tests/ui/opt_vec_nonpositional.rs20
-rw-r--r--structopt/tests/ui/opt_vec_nonpositional.stderr5
-rw-r--r--structopt/tests/ui/option_default_value.rs21
-rw-r--r--structopt/tests/ui/option_default_value.stderr5
-rw-r--r--structopt/tests/ui/option_required.rs21
-rw-r--r--structopt/tests/ui/option_required.stderr5
-rw-r--r--structopt/tests/ui/parse_empty_try_from_os.rs21
-rw-r--r--structopt/tests/ui/parse_empty_try_from_os.stderr5
-rw-r--r--structopt/tests/ui/parse_function_is_not_path.rs21
-rw-r--r--structopt/tests/ui/parse_function_is_not_path.stderr5
-rw-r--r--structopt/tests/ui/parse_literal_spec.rs21
-rw-r--r--structopt/tests/ui/parse_literal_spec.stderr5
-rw-r--r--structopt/tests/ui/parse_not_zero_args.rs21
-rw-r--r--structopt/tests/ui/parse_not_zero_args.stderr5
-rw-r--r--structopt/tests/ui/positional_bool.rs10
-rw-r--r--structopt/tests/ui/positional_bool.stderr10
-rw-r--r--structopt/tests/ui/raw.rs25
-rw-r--r--structopt/tests/ui/raw.stderr19
-rw-r--r--structopt/tests/ui/rename_all_wrong_casing.rs21
-rw-r--r--structopt/tests/ui/rename_all_wrong_casing.stderr5
-rw-r--r--structopt/tests/ui/skip_flatten.rs42
-rw-r--r--structopt/tests/ui/skip_flatten.stderr5
-rw-r--r--structopt/tests/ui/skip_subcommand.rs42
-rw-r--r--structopt/tests/ui/skip_subcommand.stderr5
-rw-r--r--structopt/tests/ui/skip_with_other_options.rs15
-rw-r--r--structopt/tests/ui/skip_with_other_options.stderr5
-rw-r--r--structopt/tests/ui/skip_without_default.rs29
-rw-r--r--structopt/tests/ui/skip_without_default.stderr9
-rw-r--r--structopt/tests/ui/struct_flatten.rs21
-rw-r--r--structopt/tests/ui/struct_flatten.stderr5
-rw-r--r--structopt/tests/ui/struct_parse.rs21
-rw-r--r--structopt/tests/ui/struct_parse.stderr5
-rw-r--r--structopt/tests/ui/struct_subcommand.rs21
-rw-r--r--structopt/tests/ui/struct_subcommand.stderr5
-rw-r--r--structopt/tests/ui/structopt_empty_attr.rs22
-rw-r--r--structopt/tests/ui/structopt_empty_attr.stderr5
-rw-r--r--structopt/tests/ui/structopt_name_value_attr.rs22
-rw-r--r--structopt/tests/ui/structopt_name_value_attr.stderr5
-rw-r--r--structopt/tests/ui/subcommand_and_flatten.rs36
-rw-r--r--structopt/tests/ui/subcommand_and_flatten.stderr5
-rw-r--r--structopt/tests/ui/subcommand_and_methods.rs36
-rw-r--r--structopt/tests/ui/subcommand_and_methods.stderr5
-rw-r--r--structopt/tests/ui/subcommand_and_parse.rs36
-rw-r--r--structopt/tests/ui/subcommand_and_parse.stderr5
-rw-r--r--structopt/tests/ui/subcommand_opt_opt.rs36
-rw-r--r--structopt/tests/ui/subcommand_opt_opt.stderr5
-rw-r--r--structopt/tests/ui/subcommand_opt_vec.rs36
-rw-r--r--structopt/tests/ui/subcommand_opt_vec.stderr5
-rw-r--r--structopt/tests/ui/tuple_struct.rs18
-rw-r--r--structopt/tests/ui/tuple_struct.stderr5
-rw-r--r--structopt/tests/utils.rs45
-rw-r--r--syn-mid/.editorconfig22
-rw-r--r--syn-mid/.gitignore6
-rw-r--r--syn-mid/.rustfmt.toml4
-rw-r--r--syn-mid/CHANGELOG.md33
-rw-r--r--syn-mid/Cargo.toml23
-rw-r--r--syn-mid/LICENSE-APACHE202
-rw-r--r--syn-mid/LICENSE-MIT23
-rw-r--r--syn-mid/README.md72
-rw-r--r--syn-mid/azure-pipelines.yml49
-rw-r--r--syn-mid/bors.toml1
-rw-r--r--syn-mid/ci/azure-clippy.yml31
-rw-r--r--syn-mid/ci/azure-install-rust.yml33
-rw-r--r--syn-mid/ci/azure-rustdoc.yml13
-rw-r--r--syn-mid/ci/azure-rustfmt.yml18
-rw-r--r--syn-mid/ci/azure-test.yml34
-rw-r--r--syn-mid/examples/const_fn/Cargo.toml16
-rw-r--r--syn-mid/examples/const_fn/lib.rs31
-rw-r--r--syn-mid/examples/const_fn_test/Cargo.toml9
-rw-r--r--syn-mid/examples/const_fn_test/build.rs16
-rw-r--r--syn-mid/examples/const_fn_test/tests/test.rs25
-rw-r--r--syn-mid/src/arg.rs99
-rw-r--r--syn-mid/src/lib.rs190
-rw-r--r--syn-mid/src/macros.rs107
-rw-r--r--syn-mid/src/pat.rs413
-rw-r--r--syn-mid/src/path.rs50
-rw-r--r--syn/.gitignore3
-rw-r--r--syn/.travis.yml76
-rw-r--r--syn/Cargo.toml72
-rw-r--r--syn/LICENSE-APACHE201
-rw-r--r--syn/LICENSE-MIT23
-rw-r--r--syn/README.md291
-rw-r--r--syn/appveyor.yml16
-rw-r--r--syn/benches/file.rs30
-rw-r--r--syn/benches/rust.rs158
-rw-r--r--syn/build.rs63
-rw-r--r--syn/codegen/Cargo.toml31
-rw-r--r--syn/codegen/README.md12
-rw-r--r--syn/codegen/src/debug.rs308
-rw-r--r--syn/codegen/src/file.rs32
-rw-r--r--syn/codegen/src/fold.rs284
-rw-r--r--syn/codegen/src/full.rs20
-rw-r--r--syn/codegen/src/gen.rs45
-rw-r--r--syn/codegen/src/json.rs18
-rw-r--r--syn/codegen/src/main.rs36
-rw-r--r--syn/codegen/src/operand.rs38
-rw-r--r--syn/codegen/src/parse.rs657
-rw-r--r--syn/codegen/src/version.rs24
-rw-r--r--syn/codegen/src/visit.rs265
-rw-r--r--syn/codegen/src/visit_mut.rs262
-rw-r--r--syn/dev/Cargo.toml22
-rw-r--r--syn/dev/README.md6
-rw-r--r--syn/dev/main.rs4
-rw-r--r--syn/dev/parse.rs18
-rw-r--r--syn/examples/README.md19
-rw-r--r--syn/examples/dump-syntax/Cargo.toml17
-rw-r--r--syn/examples/dump-syntax/README.md28
-rw-r--r--syn/examples/dump-syntax/src/main.rs149
-rw-r--r--syn/examples/heapsize/Cargo.toml2
-rw-r--r--syn/examples/heapsize/README.md72
-rw-r--r--syn/examples/heapsize/example/Cargo.toml9
-rw-r--r--syn/examples/heapsize/example/src/main.rs28
-rw-r--r--syn/examples/heapsize/heapsize/Cargo.toml9
-rw-r--r--syn/examples/heapsize/heapsize/src/lib.rs64
-rw-r--r--syn/examples/heapsize/heapsize_derive/Cargo.toml14
-rw-r--r--syn/examples/heapsize/heapsize_derive/src/lib.rs96
-rw-r--r--syn/examples/lazy-static/Cargo.toml2
-rw-r--r--syn/examples/lazy-static/README.md42
-rw-r--r--syn/examples/lazy-static/example/Cargo.toml10
-rw-r--r--syn/examples/lazy-static/example/src/main.rs20
-rw-r--r--syn/examples/lazy-static/lazy-static/Cargo.toml14
-rw-r--r--syn/examples/lazy-static/lazy-static/src/lib.rs143
-rw-r--r--syn/examples/trace-var/Cargo.toml2
-rw-r--r--syn/examples/trace-var/README.md61
-rw-r--r--syn/examples/trace-var/example/Cargo.toml9
-rw-r--r--syn/examples/trace-var/example/src/main.rs15
-rw-r--r--syn/examples/trace-var/trace-var/Cargo.toml14
-rw-r--r--syn/examples/trace-var/trace-var/src/lib.rs180
-rw-r--r--syn/json/Cargo.toml18
-rw-r--r--syn/json/src/lib.rs214
-rw-r--r--syn/src/attr.rs682
-rw-r--r--syn/src/await.rs2
-rw-r--r--syn/src/bigint.rs66
-rw-r--r--syn/src/buffer.rs382
-rw-r--r--syn/src/custom_keyword.rs252
-rw-r--r--syn/src/custom_punctuation.rs309
-rw-r--r--syn/src/data.rs456
-rw-r--r--syn/src/derive.rs273
-rw-r--r--syn/src/discouraged.rs195
-rw-r--r--syn/src/error.rs357
-rw-r--r--syn/src/export.rs35
-rw-r--r--syn/src/expr.rs3236
-rw-r--r--syn/src/ext.rs135
-rw-r--r--syn/src/file.rs113
-rw-r--r--syn/src/gen/fold.rs3236
-rw-r--r--syn/src/gen/visit.rs3792
-rw-r--r--syn/src/gen/visit_mut.rs3798
-rw-r--r--syn/src/gen_helper.rs154
-rw-r--r--syn/src/generics.rs1152
-rw-r--r--syn/src/group.rs280
-rw-r--r--syn/src/ident.rs101
-rw-r--r--syn/src/item.rs3104
-rw-r--r--syn/src/keyword.rs0
-rw-r--r--syn/src/lib.rs947
-rw-r--r--syn/src/lifetime.rs140
-rw-r--r--syn/src/lit.rs1382
-rw-r--r--syn/src/lookahead.rs168
-rw-r--r--syn/src/mac.rs239
-rw-r--r--syn/src/macros.rs191
-rw-r--r--syn/src/op.rs231
-rw-r--r--syn/src/parse.rs1222
-rw-r--r--syn/src/parse_macro_input.rs110
-rw-r--r--syn/src/parse_quote.rs131
-rw-r--r--syn/src/pat.rs903
-rw-r--r--syn/src/path.rs744
-rw-r--r--syn/src/print.rs16
-rw-r--r--syn/src/punctuated.rs918
-rw-r--r--syn/src/sealed.rs4
-rw-r--r--syn/src/span.rs67
-rw-r--r--syn/src/spanned.rs114
-rw-r--r--syn/src/stmt.rs333
-rw-r--r--syn/src/thread.rs41
-rw-r--r--syn/src/token.rs956
-rw-r--r--syn/src/tt.rs108
-rw-r--r--syn/src/ty.rs1178
-rw-r--r--syn/syn.json5616
-rw-r--r--syn/tests/common/eq.rs459
-rw-r--r--syn/tests/common/mod.rs19
-rw-r--r--syn/tests/common/parse.rs49
-rw-r--r--syn/tests/debug/gen.rs5633
-rw-r--r--syn/tests/debug/mod.rs110
-rw-r--r--syn/tests/features/error.rs1
-rw-r--r--syn/tests/features/mod.rs22
-rw-r--r--syn/tests/macros/mod.rs76
-rw-r--r--syn/tests/repo/mod.rs109
-rw-r--r--syn/tests/repo/progress.rs37
-rw-r--r--syn/tests/test_asyncness.rs39
-rw-r--r--syn/tests/test_attribute.rs296
-rw-r--r--syn/tests/test_derive_input.rs894
-rw-r--r--syn/tests/test_expr.rs37
-rw-r--r--syn/tests/test_generics.rs285
-rw-r--r--syn/tests/test_grouping.rs55
-rw-r--r--syn/tests/test_ident.rs87
-rw-r--r--syn/tests/test_iterators.rs51
-rw-r--r--syn/tests/test_lit.rs184
-rw-r--r--syn/tests/test_meta.rs341
-rw-r--r--syn/tests/test_parse_buffer.rs53
-rw-r--r--syn/tests/test_pat.rs20
-rw-r--r--syn/tests/test_precedence.rs394
-rw-r--r--syn/tests/test_receiver.rs109
-rw-r--r--syn/tests/test_round_trip.rs151
-rw-r--r--syn/tests/test_should_parse.rs47
-rw-r--r--syn/tests/test_size.rs31
-rw-r--r--syn/tests/test_token_trees.rs28
-rw-r--r--syn/tests/test_visibility.rs99
-rw-r--r--syn/tests/zzz_stable.rs33
-rw-r--r--textwrap/.appveyor.yml23
-rw-r--r--textwrap/.circleci/config.yml13
-rw-r--r--textwrap/.codecov.yml13
-rw-r--r--textwrap/.dir-locals.el3
-rw-r--r--textwrap/.gitignore5
-rw-r--r--textwrap/.travis.yml17
-rw-r--r--textwrap/Cargo.toml38
-rw-r--r--textwrap/LICENSE21
-rw-r--r--textwrap/README.md337
-rw-r--r--textwrap/benches/linear.rs122
-rw-r--r--textwrap/examples/layout.rs38
-rw-r--r--textwrap/examples/termwidth.rs41
-rw-r--r--textwrap/src/indentation.rs294
-rw-r--r--textwrap/src/lib.rs987
-rw-r--r--textwrap/src/splitting.rs139
-rw-r--r--textwrap/tests/version-numbers.rs17
-rw-r--r--unicode-segmentation/.gitignore5
-rw-r--r--unicode-segmentation/.travis.yml24
-rw-r--r--unicode-segmentation/COPYRIGHT7
-rw-r--r--unicode-segmentation/Cargo.toml25
-rw-r--r--unicode-segmentation/LICENSE-APACHE201
-rw-r--r--unicode-segmentation/LICENSE-MIT25
-rw-r--r--unicode-segmentation/README.md89
-rwxr-xr-xunicode-segmentation/scripts/unicode.py375
-rwxr-xr-xunicode-segmentation/scripts/unicode_gen_breaktests.py212
-rw-r--r--unicode-segmentation/src/grapheme.rs708
-rw-r--r--unicode-segmentation/src/lib.rs242
-rw-r--r--unicode-segmentation/src/sentence.rs373
-rw-r--r--unicode-segmentation/src/tables.rs2523
-rw-r--r--unicode-segmentation/src/test.rs197
-rw-r--r--unicode-segmentation/src/testdata.rs2122
-rw-r--r--unicode-segmentation/src/word.rs664
-rw-r--r--unicode-width/.gitignore3
-rw-r--r--unicode-width/.travis.yml28
-rw-r--r--unicode-width/COPYRIGHT7
-rw-r--r--unicode-width/Cargo.toml29
-rw-r--r--unicode-width/LICENSE-APACHE201
-rw-r--r--unicode-width/LICENSE-MIT25
-rw-r--r--unicode-width/README.md58
-rwxr-xr-xunicode-width/scripts/unicode.py321
-rw-r--r--unicode-width/src/lib.rs131
-rw-r--r--unicode-width/src/tables.rs284
-rw-r--r--unicode-width/src/tests.rs175
-rw-r--r--unicode-xid/.gitignore3
-rw-r--r--unicode-xid/.travis.yml25
-rw-r--r--unicode-xid/COPYRIGHT7
-rw-r--r--unicode-xid/Cargo.toml28
-rw-r--r--unicode-xid/LICENSE-APACHE201
-rw-r--r--unicode-xid/LICENSE-MIT25
-rw-r--r--unicode-xid/README.md44
-rwxr-xr-xunicode-xid/scripts/unicode.py187
-rw-r--r--unicode-xid/src/lib.rs87
-rw-r--r--unicode-xid/src/tables.rs451
-rw-r--r--unicode-xid/src/tests.rs111
-rwxr-xr-xvar/binary-size.py (renamed from nitrocli/var/binary-size.py)7
-rw-r--r--var/shell-complete.rs167
1234 files changed, 853 insertions, 257188 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 02812e0..152eff1 100644
--- a/nitrocli/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,12 +1,26 @@
-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 the `argparse` dependency
- - Made the --verbose and --model options global
-- Bumped `nitrokey` dependency to `0.5.1`
+ - 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
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 b69a2bb..18d8968 100644
--- a/nitrocli/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,7 @@
[package]
name = "nitrocli"
-version = "0.3.1"
+version = "0.3.3"
edition = "2018"
authors = ["Daniel Mueller <deso@posteo.net>"]
license = "GPL-3.0-or-later"
@@ -36,6 +36,10 @@ 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
@@ -49,7 +53,7 @@ version = "0.4.0"
version = "0.2"
[dependencies.nitrokey]
-version = "0.5.1"
+version = "0.6"
[dependencies.structopt]
version = "0.3.7"
@@ -63,30 +67,3 @@ version = "0.1"
[dev-dependencies.regex]
version = "1"
-
-[patch.crates-io]
-base32 = { path = "../base32" }
-bitflags = { path = "../bitflags" }
-cc = { path = "../cc" }
-cfg-if = { path = "../cfg-if" }
-clap = { path = "../clap" }
-getrandom = { path = "../getrandom" }
-heck = { path = "../heck" }
-lazy_static = { path = "../lazy-static" }
-libc = { path = "../libc" }
-nitrokey = { path = "../nitrokey" }
-nitrokey-sys = { path = "../nitrokey-sys" }
-proc-macro-error = { path = "../proc-macro-error/proc-macro-error" }
-proc-macro-error-attr = { path = "../proc-macro-error/proc-macro-error-attr" }
-proc-macro2 = { path = "../proc-macro2" }
-quote = { path = "../quote" }
-rand_core = { path = "../rand/rand_core" }
-rustversion = { path = "../rustversion" }
-structopt = { path = "../structopt" }
-structopt-derive = { path = "../structopt/structopt-derive" }
-syn = { path = "../syn" }
-syn-mid = { path = "../syn-mid" }
-textwrap = { path = "../textwrap" }
-unicode-segmentation = { path = "../unicode-segmentation" }
-unicode-width = { path = "../unicode-width" }
-unicode-xid = { path = "../unicode-xid" }
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 a1833ac..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.35+-blue.svg)](https://blog.rust-lang.org/2019/05/23/Rust-1.35.0.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
========
@@ -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
--------------
@@ -157,7 +170,7 @@ 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/stable/nitrocli
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/bitflags/.gitignore b/bitflags/.gitignore
deleted file mode 100644
index fbd9642..0000000
--- a/bitflags/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-target
-Cargo.lock
-
-/.idea/
diff --git a/bitflags/.travis.yml b/bitflags/.travis.yml
deleted file mode 100644
index 9dd45c4..0000000
--- a/bitflags/.travis.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-branches:
- except:
- - /.*(.tmp)$/
-
-language: rust
-matrix:
- include:
- # This version is tested to avoid unintentional bumping of the minimum supported Rust version
- - rust: 1.20.0
- env:
- - LABEL="msrv"
- script:
- - cargo test
- - rust: stable
- env:
- - LABEL="no-std"
- script:
- - rustup target add thumbv6m-none-eabi
- - cargo build --features example_generated --target thumbv6m-none-eabi
- - rust: nightly
- env:
- - LABEL="compiletest"
- script:
- - cargo test
- - cargo test -p test_suite --features unstable
- - rust: stable
- - rust: stable
- os: osx
- - rust: beta
- allow_failures:
- - rust: nightly
-
-sudo: false
-script:
- - cargo test --all
-
-notifications:
- email:
- on_success: never
diff --git a/bitflags/CHANGELOG.md b/bitflags/CHANGELOG.md
deleted file mode 100644
index 0d49101..0000000
--- a/bitflags/CHANGELOG.md
+++ /dev/null
@@ -1,149 +0,0 @@
-# 1.2.1
-
-- Remove extraneous `#[inline]` attributes ([#194])
-
-[#194]: https://github.com/bitflags/bitflags/pull/194
-
-# 1.2.0
-
-- Fix typo: {Lower, Upper}Exp - {Lower, Upper}Hex ([#183])
-
-- Add support for "unknown" bits ([#188])
-
-[#183]: https://github.com/rust-lang-nursery/bitflags/pull/183
-[#188]: https://github.com/rust-lang-nursery/bitflags/pull/188
-
-# 1.1.0
-
-This is a re-release of `1.0.5`, which was yanked due to a bug in the RLS.
-
-# 1.0.5
-
-- Use compiletest_rs flags supported by stable toolchain ([#171])
-
-- Put the user provided attributes first ([#173])
-
-- Make bitflags methods `const` on newer compilers ([#175])
-
-[#171]: https://github.com/rust-lang-nursery/bitflags/pull/171
-[#173]: https://github.com/rust-lang-nursery/bitflags/pull/173
-[#175]: https://github.com/rust-lang-nursery/bitflags/pull/175
-
-# 1.0.4
-
-- Support Rust 2018 style macro imports ([#165])
-
- ```rust
- use bitflags::bitflags;
- ```
-
-[#165]: https://github.com/rust-lang-nursery/bitflags/pull/165
-
-# 1.0.3
-
-- Improve zero value flag handling and documentation ([#157])
-
-[#157]: https://github.com/rust-lang-nursery/bitflags/pull/157
-
-# 1.0.2
-
-- 30% improvement in compile time of bitflags crate ([#156])
-
-- Documentation improvements ([#153])
-
-- Implementation cleanup ([#149])
-
-[#156]: https://github.com/rust-lang-nursery/bitflags/pull/156
-[#153]: https://github.com/rust-lang-nursery/bitflags/pull/153
-[#149]: https://github.com/rust-lang-nursery/bitflags/pull/149
-
-# 1.0.1
-- Add support for `pub(restricted)` specifier on the bitflags struct ([#135])
-- Optimize performance of `all()` when called from a separate crate ([#136])
-
-[#135]: https://github.com/rust-lang-nursery/bitflags/pull/135
-[#136]: https://github.com/rust-lang-nursery/bitflags/pull/136
-
-# 1.0.0
-- **[breaking change]** Macro now generates [associated constants](https://doc.rust-lang.org/reference/items.html#associated-constants) ([#24])
-
-- **[breaking change]** Minimum supported version is Rust **1.20**, due to usage of associated constants
-
-- After being broken in 0.9, the `#[deprecated]` attribute is now supported again ([#112])
-
-- Other improvements to unit tests and documentation ([#106] and [#115])
-
-[#24]: https://github.com/rust-lang-nursery/bitflags/pull/24
-[#106]: https://github.com/rust-lang-nursery/bitflags/pull/106
-[#112]: https://github.com/rust-lang-nursery/bitflags/pull/112
-[#115]: https://github.com/rust-lang-nursery/bitflags/pull/115
-
-## How to update your code to use associated constants
-Assuming the following structure definition:
-```rust
-bitflags! {
- struct Something: u8 {
- const FOO = 0b01,
- const BAR = 0b10
- }
-}
-```
-In 0.9 and older you could do:
-```rust
-let x = FOO.bits | BAR.bits;
-```
-Now you must use:
-```rust
-let x = Something::FOO.bits | Something::BAR.bits;
-```
-
-# 0.9.1
-- Fix the implementation of `Formatting` traits when other formatting traits were present in scope ([#105])
-
-[#105]: https://github.com/rust-lang-nursery/bitflags/pull/105
-
-# 0.9.0
-- **[breaking change]** Use struct keyword instead of flags to define bitflag types ([#84])
-
-- **[breaking change]** Terminate const items with semicolons instead of commas ([#87])
-
-- Implement the `Hex`, `Octal`, and `Binary` formatting traits ([#86])
-
-- Printing an empty flag value with the `Debug` trait now prints "(empty)" instead of nothing ([#85])
-
-- The `bitflags!` macro can now be used inside of a fn body, to define a type local to that function ([#74])
-
-[#74]: https://github.com/rust-lang-nursery/bitflags/pull/74
-[#84]: https://github.com/rust-lang-nursery/bitflags/pull/84
-[#85]: https://github.com/rust-lang-nursery/bitflags/pull/85
-[#86]: https://github.com/rust-lang-nursery/bitflags/pull/86
-[#87]: https://github.com/rust-lang-nursery/bitflags/pull/87
-
-# 0.8.2
-- Update feature flag used when building bitflags as a dependency of the Rust toolchain
-
-# 0.8.1
-- Allow bitflags to be used as a dependency of the Rust toolchain
-
-# 0.8.0
-- Add support for the experimental `i128` and `u128` integer types ([#57])
-- Add set method: `flags.set(SOME_FLAG, true)` or `flags.set(SOME_FLAG, false)` ([#55])
- This may break code that defines its own set method
-
-[#55]: https://github.com/rust-lang-nursery/bitflags/pull/55
-[#57]: https://github.com/rust-lang-nursery/bitflags/pull/57
-
-# 0.7.1
-*(yanked)*
-
-# 0.7.0
-- Implement the Extend trait ([#49])
-- Allow definitions inside the `bitflags!` macro to refer to items imported from other modules ([#51])
-
-[#49]: https://github.com/rust-lang-nursery/bitflags/pull/49
-[#51]: https://github.com/rust-lang-nursery/bitflags/pull/51
-
-# 0.6.0
-- The `no_std` feature was removed as it is now the default
-- The `assignment_operators` feature was remove as it is now enabled by default
-- Some clippy suggestions have been applied
diff --git a/bitflags/CODE_OF_CONDUCT.md b/bitflags/CODE_OF_CONDUCT.md
deleted file mode 100644
index f7add90..0000000
--- a/bitflags/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-In the interest of fostering an open and welcoming environment, we as
-contributors and maintainers pledge to making participation in our project and
-our community a harassment-free experience for everyone, regardless of age, body
-size, disability, ethnicity, gender identity and expression, level of experience,
-education, socio-economic status, nationality, personal appearance, race,
-religion, or sexual identity and orientation.
-
-## Our Standards
-
-Examples of behavior that contributes to creating a positive environment
-include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or
- advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable
-behavior and are expected to take appropriate and fair corrective action in
-response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community. Examples of
-representing a project or community include using an official project e-mail
-address, posting via an official social media account, or acting as an appointed
-representative at an online or offline event. Representation of a project may be
-further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the project team at coc@senaite.org. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. The project team is
-obligated to maintain confidentiality with regard to the reporter of an incident.
-Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good
-faith may face temporary or permanent repercussions as determined by other
-members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
-
-[homepage]: https://www.contributor-covenant.org \ No newline at end of file
diff --git a/bitflags/Cargo.toml b/bitflags/Cargo.toml
deleted file mode 100644
index afbe066..0000000
--- a/bitflags/Cargo.toml
+++ /dev/null
@@ -1,37 +0,0 @@
-[package]
-
-name = "bitflags"
-# NB: When modifying, also modify:
-# 1. html_root_url in lib.rs
-# 2. number in readme (for breaking changes)
-version = "1.2.1"
-authors = ["The Rust Project Developers"]
-license = "MIT/Apache-2.0"
-keywords = ["bit", "bitmask", "bitflags", "flags"]
-readme = "README.md"
-repository = "https://github.com/bitflags/bitflags"
-homepage = "https://github.com/bitflags/bitflags"
-documentation = "https://docs.rs/bitflags"
-categories = ["no-std"]
-description = """
-A macro to generate structures which behave like bitflags.
-"""
-exclude = [
- ".travis.yml",
- "appveyor.yml",
- "bors.toml"
-]
-build = "build.rs"
-
-[badges]
-travis-ci = { repository = "bitflags/bitflags" }
-
-[features]
-default = []
-example_generated = []
-
-[package.metadata.docs.rs]
-features = [ "example_generated" ]
-
-[workspace]
-members = ["test_suite"]
diff --git a/bitflags/LICENSE-APACHE b/bitflags/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/bitflags/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/bitflags/LICENSE-MIT b/bitflags/LICENSE-MIT
deleted file mode 100644
index 39d4bdb..0000000
--- a/bitflags/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/bitflags/README.md b/bitflags/README.md
deleted file mode 100644
index df12934..0000000
--- a/bitflags/README.md
+++ /dev/null
@@ -1,34 +0,0 @@
-bitflags
-========
-
-[![Build Status](https://travis-ci.com/bitflags/bitflags.svg?branch=master)](https://travis-ci.com/bitflags/bitflags)
-[![Join the chat at https://gitter.im/bitflags/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bitflags/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge)
-[![Latest version](https://img.shields.io/crates/v/bitflags.svg)](https://crates.io/crates/bitflags)
-[![Documentation](https://docs.rs/bitflags/badge.svg)](https://docs.rs/bitflags)
-![Minimum rustc version](https://img.shields.io/badge/rustc-1.20+-yellow.svg)
-![License](https://img.shields.io/crates/l/bitflags.svg)
-
-A Rust macro to generate structures which behave like a set of bitflags
-
-- [Documentation](https://docs.rs/bitflags)
-- [Release notes](https://github.com/bitflags/bitflags/releases)
-
-## Usage
-
-Add this to your `Cargo.toml`:
-
-```toml
-[dependencies]
-bitflags = "1.0"
-```
-
-and this to your crate root:
-
-```rust
-#[macro_use]
-extern crate bitflags;
-```
-
-## Rust Version Support
-
-The minimum supported Rust version is 1.20 due to use of associated constants.
diff --git a/bitflags/bors.toml b/bitflags/bors.toml
deleted file mode 100644
index 713ea9b..0000000
--- a/bitflags/bors.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-status = [
- "continuous-integration/travis-ci/push",
-]
diff --git a/bitflags/build.rs b/bitflags/build.rs
deleted file mode 100644
index 985757a..0000000
--- a/bitflags/build.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use std::env;
-use std::process::Command;
-use std::str::{self, FromStr};
-
-fn main(){
- let minor = match rustc_minor_version() {
- Some(minor) => minor,
- None => return,
- };
-
- // const fn stabilized in Rust 1.31:
- if minor >= 31 {
- println!("cargo:rustc-cfg=bitflags_const_fn");
- }
-}
-
-fn rustc_minor_version() -> Option<u32> {
- let rustc = match env::var_os("RUSTC") {
- Some(rustc) => rustc,
- None => return None,
- };
-
- let output = match Command::new(rustc).arg("--version").output() {
- Ok(output) => output,
- Err(_) => return None,
- };
-
- let version = match str::from_utf8(&output.stdout) {
- Ok(version) => version,
- Err(_) => return None,
- };
-
- let mut pieces = version.split('.');
- if pieces.next() != Some("rustc 1") {
- return None;
- }
-
- let next = match pieces.next() {
- Some(next) => next,
- None => return None,
- };
-
- u32::from_str(next).ok()
-} \ No newline at end of file
diff --git a/bitflags/src/example_generated.rs b/bitflags/src/example_generated.rs
deleted file mode 100644
index cf188d9..0000000
--- a/bitflags/src/example_generated.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-//! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS
-//! CRATE**.
-
-bitflags! {
- /// This is the same `Flags` struct defined in the [crate level example](../index.html#example).
- /// Note that this struct is just for documentation purposes only, it must not be used outside
- /// this crate.
- pub struct Flags: u32 {
- const A = 0b00000001;
- const B = 0b00000010;
- const C = 0b00000100;
- const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
- }
-}
diff --git a/bitflags/src/lib.rs b/bitflags/src/lib.rs
deleted file mode 100644
index 3929b02..0000000
--- a/bitflags/src/lib.rs
+++ /dev/null
@@ -1,1430 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A typesafe bitmask flag generator useful for sets of C-style bitmask flags.
-//! It can be used for creating typesafe wrappers around C APIs.
-//!
-//! The `bitflags!` macro generates a `struct` that manages a set of flags. The
-//! flags should only be defined for integer types, otherwise unexpected type
-//! errors may occur at compile time.
-//!
-//! # Example
-//!
-//! ```
-//! #[macro_use]
-//! extern crate bitflags;
-//!
-//! bitflags! {
-//! struct Flags: u32 {
-//! const A = 0b00000001;
-//! const B = 0b00000010;
-//! const C = 0b00000100;
-//! const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
-//! }
-//! }
-//!
-//! fn main() {
-//! let e1 = Flags::A | Flags::C;
-//! let e2 = Flags::B | Flags::C;
-//! assert_eq!((e1 | e2), Flags::ABC); // union
-//! assert_eq!((e1 & e2), Flags::C); // intersection
-//! assert_eq!((e1 - e2), Flags::A); // set difference
-//! assert_eq!(!e2, Flags::A); // set complement
-//! }
-//! ```
-//!
-//! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code
-//! generated by the above `bitflags!` expansion.
-//!
-//! The generated `struct`s can also be extended with type and trait
-//! implementations:
-//!
-//! ```
-//! #[macro_use]
-//! extern crate bitflags;
-//!
-//! use std::fmt;
-//!
-//! bitflags! {
-//! struct Flags: u32 {
-//! const A = 0b00000001;
-//! const B = 0b00000010;
-//! }
-//! }
-//!
-//! impl Flags {
-//! pub fn clear(&mut self) {
-//! self.bits = 0; // The `bits` field can be accessed from within the
-//! // same module where the `bitflags!` macro was invoked.
-//! }
-//! }
-//!
-//! impl fmt::Display for Flags {
-//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-//! write!(f, "hi!")
-//! }
-//! }
-//!
-//! fn main() {
-//! let mut flags = Flags::A | Flags::B;
-//! flags.clear();
-//! assert!(flags.is_empty());
-//! assert_eq!(format!("{}", flags), "hi!");
-//! assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B");
-//! assert_eq!(format!("{:?}", Flags::B), "B");
-//! }
-//! ```
-//!
-//! # Visibility
-//!
-//! The generated struct and its associated flag constants are not exported
-//! out of the current module by default. A definition can be exported out of
-//! the current module by adding `pub` before `flags`:
-//!
-//! ```
-//! #[macro_use]
-//! extern crate bitflags;
-//!
-//! mod example {
-//! bitflags! {
-//! pub struct Flags1: u32 {
-//! const A = 0b00000001;
-//! }
-//! }
-//! bitflags! {
-//! # pub
-//! struct Flags2: u32 {
-//! const B = 0b00000010;
-//! }
-//! }
-//! }
-//!
-//! fn main() {
-//! let flag1 = example::Flags1::A;
-//! let flag2 = example::Flags2::B; // error: const `B` is private
-//! }
-//! ```
-//!
-//! # Attributes
-//!
-//! Attributes can be attached to the generated `struct` by placing them
-//! before the `flags` keyword.
-//!
-//! # Trait implementations
-//!
-//! The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash`
-//! traits automatically derived for the `struct` using the `derive` attribute.
-//! Additional traits can be derived by providing an explicit `derive`
-//! attribute on `flags`.
-//!
-//! The `Extend` and `FromIterator` traits are implemented for the `struct`,
-//! too: `Extend` adds the union of the instances of the `struct` iterated over,
-//! while `FromIterator` calculates the union.
-//!
-//! The `Binary`, `Debug`, `LowerHex`, `Octal` and `UpperHex` trait is also
-//! implemented by displaying the bits value of the internal struct.
-//!
-//! ## Operators
-//!
-//! The following operator traits are implemented for the generated `struct`:
-//!
-//! - `BitOr` and `BitOrAssign`: union
-//! - `BitAnd` and `BitAndAssign`: intersection
-//! - `BitXor` and `BitXorAssign`: toggle
-//! - `Sub` and `SubAssign`: set difference
-//! - `Not`: set complement
-//!
-//! # Methods
-//!
-//! The following methods are defined for the generated `struct`:
-//!
-//! - `empty`: an empty set of flags
-//! - `all`: the set of all defined flags
-//! - `bits`: the raw value of the flags currently stored
-//! - `from_bits`: convert from underlying bit representation, unless that
-//! representation contains bits that do not correspond to a
-//! defined flag
-//! - `from_bits_truncate`: convert from underlying bit representation, dropping
-//! any bits that do not correspond to defined flags
-//! - `from_bits_unchecked`: convert from underlying bit representation, keeping
-//! all bits (even those not corresponding to defined
-//! flags)
-//! - `is_empty`: `true` if no flags are currently stored
-//! - `is_all`: `true` if currently set flags exactly equal all defined flags
-//! - `intersects`: `true` if there are flags common to both `self` and `other`
-//! - `contains`: `true` all of the flags in `other` are contained within `self`
-//! - `insert`: inserts the specified flags in-place
-//! - `remove`: removes the specified flags in-place
-//! - `toggle`: the specified flags will be inserted if not present, and removed
-//! if they are.
-//! - `set`: inserts or removes the specified flags depending on the passed value
-//!
-//! ## Default
-//!
-//! The `Default` trait is not automatically implemented for the generated struct.
-//!
-//! If your default value is equal to `0` (which is the same value as calling `empty()`
-//! on the generated struct), you can simply derive `Default`:
-//!
-//! ```
-//! #[macro_use]
-//! extern crate bitflags;
-//!
-//! bitflags! {
-//! // Results in default value with bits: 0
-//! #[derive(Default)]
-//! struct Flags: u32 {
-//! const A = 0b00000001;
-//! const B = 0b00000010;
-//! const C = 0b00000100;
-//! }
-//! }
-//!
-//! fn main() {
-//! let derived_default: Flags = Default::default();
-//! assert_eq!(derived_default.bits(), 0);
-//! }
-//! ```
-//!
-//! If your default value is not equal to `0` you need to implement `Default` yourself:
-//!
-//! ```
-//! #[macro_use]
-//! extern crate bitflags;
-//!
-//! bitflags! {
-//! struct Flags: u32 {
-//! const A = 0b00000001;
-//! const B = 0b00000010;
-//! const C = 0b00000100;
-//! }
-//! }
-//!
-//! // explicit `Default` implementation
-//! impl Default for Flags {
-//! fn default() -> Flags {
-//! Flags::A | Flags::C
-//! }
-//! }
-//!
-//! fn main() {
-//! let implemented_default: Flags = Default::default();
-//! assert_eq!(implemented_default, (Flags::A | Flags::C));
-//! }
-//! ```
-//!
-//! # Zero Flags
-//!
-//! Flags with a value equal to zero will have some strange behavior that one should be aware of.
-//!
-//! ```
-//! #[macro_use]
-//! extern crate bitflags;
-//!
-//! bitflags! {
-//! struct Flags: u32 {
-//! const NONE = 0b00000000;
-//! const SOME = 0b00000001;
-//! }
-//! }
-//!
-//! fn main() {
-//! let empty = Flags::empty();
-//! let none = Flags::NONE;
-//! let some = Flags::SOME;
-//!
-//! // Zero flags are treated as always present
-//! assert!(empty.contains(Flags::NONE));
-//! assert!(none.contains(Flags::NONE));
-//! assert!(some.contains(Flags::NONE));
-//!
-//! // Zero flags will be ignored when testing for emptiness
-//! assert!(none.is_empty());
-//! }
-//! ```
-
-#![no_std]
-#![doc(html_root_url = "https://docs.rs/bitflags/1.2.1")]
-
-#[cfg(test)]
-#[macro_use]
-extern crate std;
-
-// Re-export libcore using an alias so that the macros can work without
-// requiring `extern crate core` downstream.
-#[doc(hidden)]
-pub extern crate core as _core;
-
-/// The macro used to generate the flag structure.
-///
-/// See the [crate level docs](../bitflags/index.html) for complete documentation.
-///
-/// # Example
-///
-/// ```
-/// #[macro_use]
-/// extern crate bitflags;
-///
-/// bitflags! {
-/// struct Flags: u32 {
-/// const A = 0b00000001;
-/// const B = 0b00000010;
-/// const C = 0b00000100;
-/// const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
-/// }
-/// }
-///
-/// fn main() {
-/// let e1 = Flags::A | Flags::C;
-/// let e2 = Flags::B | Flags::C;
-/// assert_eq!((e1 | e2), Flags::ABC); // union
-/// assert_eq!((e1 & e2), Flags::C); // intersection
-/// assert_eq!((e1 - e2), Flags::A); // set difference
-/// assert_eq!(!e2, Flags::A); // set complement
-/// }
-/// ```
-///
-/// The generated `struct`s can also be extended with type and trait
-/// implementations:
-///
-/// ```
-/// #[macro_use]
-/// extern crate bitflags;
-///
-/// use std::fmt;
-///
-/// bitflags! {
-/// struct Flags: u32 {
-/// const A = 0b00000001;
-/// const B = 0b00000010;
-/// }
-/// }
-///
-/// impl Flags {
-/// pub fn clear(&mut self) {
-/// self.bits = 0; // The `bits` field can be accessed from within the
-/// // same module where the `bitflags!` macro was invoked.
-/// }
-/// }
-///
-/// impl fmt::Display for Flags {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-/// write!(f, "hi!")
-/// }
-/// }
-///
-/// fn main() {
-/// let mut flags = Flags::A | Flags::B;
-/// flags.clear();
-/// assert!(flags.is_empty());
-/// assert_eq!(format!("{}", flags), "hi!");
-/// assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B");
-/// assert_eq!(format!("{:?}", Flags::B), "B");
-/// }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! bitflags {
- (
- $(#[$outer:meta])*
- pub struct $BitFlags:ident: $T:ty {
- $(
- $(#[$inner:ident $($args:tt)*])*
- const $Flag:ident = $value:expr;
- )+
- }
- ) => {
- __bitflags! {
- $(#[$outer])*
- (pub) $BitFlags: $T {
- $(
- $(#[$inner $($args)*])*
- $Flag = $value;
- )+
- }
- }
- };
- (
- $(#[$outer:meta])*
- struct $BitFlags:ident: $T:ty {
- $(
- $(#[$inner:ident $($args:tt)*])*
- const $Flag:ident = $value:expr;
- )+
- }
- ) => {
- __bitflags! {
- $(#[$outer])*
- () $BitFlags: $T {
- $(
- $(#[$inner $($args)*])*
- $Flag = $value;
- )+
- }
- }
- };
- (
- $(#[$outer:meta])*
- pub ($($vis:tt)+) struct $BitFlags:ident: $T:ty {
- $(
- $(#[$inner:ident $($args:tt)*])*
- const $Flag:ident = $value:expr;
- )+
- }
- ) => {
- __bitflags! {
- $(#[$outer])*
- (pub ($($vis)+)) $BitFlags: $T {
- $(
- $(#[$inner $($args)*])*
- $Flag = $value;
- )+
- }
- }
- };
-}
-
-#[macro_export(local_inner_macros)]
-#[doc(hidden)]
-macro_rules! __bitflags {
- (
- $(#[$outer:meta])*
- ($($vis:tt)*) $BitFlags:ident: $T:ty {
- $(
- $(#[$inner:ident $($args:tt)*])*
- $Flag:ident = $value:expr;
- )+
- }
- ) => {
- $(#[$outer])*
- #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
- $($vis)* struct $BitFlags {
- bits: $T,
- }
-
- __impl_bitflags! {
- $BitFlags: $T {
- $(
- $(#[$inner $($args)*])*
- $Flag = $value;
- )+
- }
- }
- };
-}
-
-#[macro_export(local_inner_macros)]
-#[doc(hidden)]
-#[cfg(bitflags_const_fn)]
-macro_rules! __fn_bitflags {
- (
- $(# $attr_args:tt)*
- const fn $($item:tt)*
- ) => {
- $(# $attr_args)*
- const fn $($item)*
- };
- (
- $(# $attr_args:tt)*
- pub const fn $($item:tt)*
- ) => {
- $(# $attr_args)*
- pub const fn $($item)*
- };
- (
- $(# $attr_args:tt)*
- pub const unsafe fn $($item:tt)*
- ) => {
- $(# $attr_args)*
- pub const unsafe fn $($item)*
- };
-}
-
-#[macro_export(local_inner_macros)]
-#[doc(hidden)]
-#[cfg(not(bitflags_const_fn))]
-macro_rules! __fn_bitflags {
- (
- $(# $attr_args:tt)*
- const fn $($item:tt)*
- ) => {
- $(# $attr_args)*
- fn $($item)*
- };
- (
- $(# $attr_args:tt)*
- pub const fn $($item:tt)*
- ) => {
- $(# $attr_args)*
- pub fn $($item)*
- };
- (
- $(# $attr_args:tt)*
- pub const unsafe fn $($item:tt)*
- ) => {
- $(# $attr_args)*
- pub unsafe fn $($item)*
- };
-}
-
-#[macro_export(local_inner_macros)]
-#[doc(hidden)]
-macro_rules! __impl_bitflags {
- (
- $BitFlags:ident: $T:ty {
- $(
- $(#[$attr:ident $($args:tt)*])*
- $Flag:ident = $value:expr;
- )+
- }
- ) => {
- impl $crate::_core::fmt::Debug for $BitFlags {
- fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
- // This convoluted approach is to handle #[cfg]-based flag
- // omission correctly. For example it needs to support:
- //
- // #[cfg(unix)] const A: Flag = /* ... */;
- // #[cfg(windows)] const B: Flag = /* ... */;
-
- // Unconditionally define a check for every flag, even disabled
- // ones.
- #[allow(non_snake_case)]
- trait __BitFlags {
- $(
- #[inline]
- fn $Flag(&self) -> bool { false }
- )+
- }
-
- // Conditionally override the check for just those flags that
- // are not #[cfg]ed away.
- impl __BitFlags for $BitFlags {
- $(
- __impl_bitflags! {
- #[allow(deprecated)]
- #[inline]
- $(? #[$attr $($args)*])*
- fn $Flag(&self) -> bool {
- if Self::$Flag.bits == 0 && self.bits != 0 {
- false
- } else {
- self.bits & Self::$Flag.bits == Self::$Flag.bits
- }
- }
- }
- )+
- }
-
- let mut first = true;
- $(
- if <$BitFlags as __BitFlags>::$Flag(self) {
- if !first {
- f.write_str(" | ")?;
- }
- first = false;
- f.write_str(__bitflags_stringify!($Flag))?;
- }
- )+
- let extra_bits = self.bits & !$BitFlags::all().bits();
- if extra_bits != 0 {
- if !first {
- f.write_str(" | ")?;
- }
- first = false;
- f.write_str("0x")?;
- $crate::_core::fmt::LowerHex::fmt(&extra_bits, f)?;
- }
- if first {
- f.write_str("(empty)")?;
- }
- Ok(())
- }
- }
- impl $crate::_core::fmt::Binary for $BitFlags {
- fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
- $crate::_core::fmt::Binary::fmt(&self.bits, f)
- }
- }
- impl $crate::_core::fmt::Octal for $BitFlags {
- fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
- $crate::_core::fmt::Octal::fmt(&self.bits, f)
- }
- }
- impl $crate::_core::fmt::LowerHex for $BitFlags {
- fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
- $crate::_core::fmt::LowerHex::fmt(&self.bits, f)
- }
- }
- impl $crate::_core::fmt::UpperHex for $BitFlags {
- fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result {
- $crate::_core::fmt::UpperHex::fmt(&self.bits, f)
- }
- }
-
- #[allow(dead_code)]
- impl $BitFlags {
- $(
- $(#[$attr $($args)*])*
- pub const $Flag: $BitFlags = $BitFlags { bits: $value };
- )+
-
- __fn_bitflags! {
- /// Returns an empty set of flags
- #[inline]
- pub const fn empty() -> $BitFlags {
- $BitFlags { bits: 0 }
- }
- }
-
- __fn_bitflags! {
- /// Returns the set containing all flags.
- #[inline]
- pub const fn all() -> $BitFlags {
- // See `Debug::fmt` for why this approach is taken.
- #[allow(non_snake_case)]
- trait __BitFlags {
- $(
- const $Flag: $T = 0;
- )+
- }
- impl __BitFlags for $BitFlags {
- $(
- __impl_bitflags! {
- #[allow(deprecated)]
- $(? #[$attr $($args)*])*
- const $Flag: $T = Self::$Flag.bits;
- }
- )+
- }
- $BitFlags { bits: $(<$BitFlags as __BitFlags>::$Flag)|+ }
- }
- }
-
- __fn_bitflags! {
- /// Returns the raw value of the flags currently stored.
- #[inline]
- pub const fn bits(&self) -> $T {
- self.bits
- }
- }
-
- /// Convert from underlying bit representation, unless that
- /// representation contains bits that do not correspond to a flag.
- #[inline]
- pub fn from_bits(bits: $T) -> $crate::_core::option::Option<$BitFlags> {
- if (bits & !$BitFlags::all().bits()) == 0 {
- $crate::_core::option::Option::Some($BitFlags { bits })
- } else {
- $crate::_core::option::Option::None
- }
- }
-
- __fn_bitflags! {
- /// Convert from underlying bit representation, dropping any bits
- /// that do not correspond to flags.
- #[inline]
- pub const fn from_bits_truncate(bits: $T) -> $BitFlags {
- $BitFlags { bits: bits & $BitFlags::all().bits }
- }
- }
-
- __fn_bitflags! {
- /// Convert from underlying bit representation, preserving all
- /// bits (even those not corresponding to a defined flag).
- #[inline]
- pub const unsafe fn from_bits_unchecked(bits: $T) -> $BitFlags {
- $BitFlags { bits }
- }
- }
-
- __fn_bitflags! {
- /// Returns `true` if no flags are currently stored.
- #[inline]
- pub const fn is_empty(&self) -> bool {
- self.bits() == $BitFlags::empty().bits()
- }
- }
-
- __fn_bitflags! {
- /// Returns `true` if all flags are currently set.
- #[inline]
- pub const fn is_all(&self) -> bool {
- self.bits == $BitFlags::all().bits
- }
- }
-
- __fn_bitflags! {
- /// Returns `true` if there are flags common to both `self` and `other`.
- #[inline]
- pub const fn intersects(&self, other: $BitFlags) -> bool {
- !$BitFlags{ bits: self.bits & other.bits}.is_empty()
- }
- }
-
- __fn_bitflags! {
- /// Returns `true` all of the flags in `other` are contained within `self`.
- #[inline]
- pub const fn contains(&self, other: $BitFlags) -> bool {
- (self.bits & other.bits) == other.bits
- }
- }
-
- /// Inserts the specified flags in-place.
- #[inline]
- pub fn insert(&mut self, other: $BitFlags) {
- self.bits |= other.bits;
- }
-
- /// Removes the specified flags in-place.
- #[inline]
- pub fn remove(&mut self, other: $BitFlags) {
- self.bits &= !other.bits;
- }
-
- /// Toggles the specified flags in-place.
- #[inline]
- pub fn toggle(&mut self, other: $BitFlags) {
- self.bits ^= other.bits;
- }
-
- /// Inserts or removes the specified flags depending on the passed value.
- #[inline]
- pub fn set(&mut self, other: $BitFlags, value: bool) {
- if value {
- self.insert(other);
- } else {
- self.remove(other);
- }
- }
- }
-
- impl $crate::_core::ops::BitOr for $BitFlags {
- type Output = $BitFlags;
-
- /// Returns the union of the two sets of flags.
- #[inline]
- fn bitor(self, other: $BitFlags) -> $BitFlags {
- $BitFlags { bits: self.bits | other.bits }
- }
- }
-
- impl $crate::_core::ops::BitOrAssign for $BitFlags {
-
- /// Adds the set of flags.
- #[inline]
- fn bitor_assign(&mut self, other: $BitFlags) {
- self.bits |= other.bits;
- }
- }
-
- impl $crate::_core::ops::BitXor for $BitFlags {
- type Output = $BitFlags;
-
- /// Returns the left flags, but with all the right flags toggled.
- #[inline]
- fn bitxor(self, other: $BitFlags) -> $BitFlags {
- $BitFlags { bits: self.bits ^ other.bits }
- }
- }
-
- impl $crate::_core::ops::BitXorAssign for $BitFlags {
-
- /// Toggles the set of flags.
- #[inline]
- fn bitxor_assign(&mut self, other: $BitFlags) {
- self.bits ^= other.bits;
- }
- }
-
- impl $crate::_core::ops::BitAnd for $BitFlags {
- type Output = $BitFlags;
-
- /// Returns the intersection between the two sets of flags.
- #[inline]
- fn bitand(self, other: $BitFlags) -> $BitFlags {
- $BitFlags { bits: self.bits & other.bits }
- }
- }
-
- impl $crate::_core::ops::BitAndAssign for $BitFlags {
-
- /// Disables all flags disabled in the set.
- #[inline]
- fn bitand_assign(&mut self, other: $BitFlags) {
- self.bits &= other.bits;
- }
- }
-
- impl $crate::_core::ops::Sub for $BitFlags {
- type Output = $BitFlags;
-
- /// Returns the set difference of the two sets of flags.
- #[inline]
- fn sub(self, other: $BitFlags) -> $BitFlags {
- $BitFlags { bits: self.bits & !other.bits }
- }
- }
-
- impl $crate::_core::ops::SubAssign for $BitFlags {
-
- /// Disables all flags enabled in the set.
- #[inline]
- fn sub_assign(&mut self, other: $BitFlags) {
- self.bits &= !other.bits;
- }
- }
-
- impl $crate::_core::ops::Not for $BitFlags {
- type Output = $BitFlags;
-
- /// Returns the complement of this set of flags.
- #[inline]
- fn not(self) -> $BitFlags {
- $BitFlags { bits: !self.bits } & $BitFlags::all()
- }
- }
-
- impl $crate::_core::iter::Extend<$BitFlags> for $BitFlags {
- fn extend<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(&mut self, iterator: T) {
- for item in iterator {
- self.insert(item)
- }
- }
- }
-
- impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags {
- fn from_iter<T: $crate::_core::iter::IntoIterator<Item=$BitFlags>>(iterator: T) -> $BitFlags {
- let mut result = Self::empty();
- result.extend(iterator);
- result
- }
- }
- };
-
- // Every attribute that the user writes on a const is applied to the
- // corresponding const that we generate, but within the implementation of
- // Debug and all() we want to ignore everything but #[cfg] attributes. In
- // particular, including a #[deprecated] attribute on those items would fail
- // to compile.
- // https://github.com/bitflags/bitflags/issues/109
- //
- // Input:
- //
- // ? #[cfg(feature = "advanced")]
- // ? #[deprecated(note = "Use somthing else.")]
- // ? #[doc = r"High quality documentation."]
- // fn f() -> i32 { /* ... */ }
- //
- // Output:
- //
- // #[cfg(feature = "advanced")]
- // fn f() -> i32 { /* ... */ }
- (
- $(#[$filtered:meta])*
- ? #[cfg $($cfgargs:tt)*]
- $(? #[$rest:ident $($restargs:tt)*])*
- fn $($item:tt)*
- ) => {
- __impl_bitflags! {
- $(#[$filtered])*
- #[cfg $($cfgargs)*]
- $(? #[$rest $($restargs)*])*
- fn $($item)*
- }
- };
- (
- $(#[$filtered:meta])*
- // $next != `cfg`
- ? #[$next:ident $($nextargs:tt)*]
- $(? #[$rest:ident $($restargs:tt)*])*
- fn $($item:tt)*
- ) => {
- __impl_bitflags! {
- $(#[$filtered])*
- // $next filtered out
- $(? #[$rest $($restargs)*])*
- fn $($item)*
- }
- };
- (
- $(#[$filtered:meta])*
- fn $($item:tt)*
- ) => {
- $(#[$filtered])*
- fn $($item)*
- };
-
- // Every attribute that the user writes on a const is applied to the
- // corresponding const that we generate, but within the implementation of
- // Debug and all() we want to ignore everything but #[cfg] attributes. In
- // particular, including a #[deprecated] attribute on those items would fail
- // to compile.
- // https://github.com/bitflags/bitflags/issues/109
- //
- // const version
- //
- // Input:
- //
- // ? #[cfg(feature = "advanced")]
- // ? #[deprecated(note = "Use somthing else.")]
- // ? #[doc = r"High quality documentation."]
- // const f: i32 { /* ... */ }
- //
- // Output:
- //
- // #[cfg(feature = "advanced")]
- // const f: i32 { /* ... */ }
- (
- $(#[$filtered:meta])*
- ? #[cfg $($cfgargs:tt)*]
- $(? #[$rest:ident $($restargs:tt)*])*
- const $($item:tt)*
- ) => {
- __impl_bitflags! {
- $(#[$filtered])*
- #[cfg $($cfgargs)*]
- $(? #[$rest $($restargs)*])*
- const $($item)*
- }
- };
- (
- $(#[$filtered:meta])*
- // $next != `cfg`
- ? #[$next:ident $($nextargs:tt)*]
- $(? #[$rest:ident $($restargs:tt)*])*
- const $($item:tt)*
- ) => {
- __impl_bitflags! {
- $(#[$filtered])*
- // $next filtered out
- $(? #[$rest $($restargs)*])*
- const $($item)*
- }
- };
- (
- $(#[$filtered:meta])*
- const $($item:tt)*
- ) => {
- $(#[$filtered])*
- const $($item)*
- };
-}
-
-// Same as std::stringify but callable from __impl_bitflags, which needs to use
-// local_inner_macros so can only directly call macros from this crate.
-#[macro_export]
-#[doc(hidden)]
-macro_rules! __bitflags_stringify {
- ($s:ident) => {
- stringify!($s)
- };
-}
-
-#[cfg(feature = "example_generated")]
-pub mod example_generated;
-
-#[cfg(test)]
-mod tests {
- use std::collections::hash_map::DefaultHasher;
- use std::hash::{Hash, Hasher};
-
- bitflags! {
- #[doc = "> The first principle is that you must not fool yourself — and"]
- #[doc = "> you are the easiest person to fool."]
- #[doc = "> "]
- #[doc = "> - Richard Feynman"]
- struct Flags: u32 {
- const A = 0b00000001;
- #[doc = "<pcwalton> macros are way better at generating code than trans is"]
- const B = 0b00000010;
- const C = 0b00000100;
- #[doc = "* cmr bed"]
- #[doc = "* strcat table"]
- #[doc = "<strcat> wait what?"]
- const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
- }
- }
-
- bitflags! {
- struct _CfgFlags: u32 {
- #[cfg(unix)]
- const _CFG_A = 0b01;
- #[cfg(windows)]
- const _CFG_B = 0b01;
- #[cfg(unix)]
- const _CFG_C = Self::_CFG_A.bits | 0b10;
- }
- }
-
- bitflags! {
- struct AnotherSetOfFlags: i8 {
- const ANOTHER_FLAG = -1_i8;
- }
- }
-
- bitflags! {
- struct LongFlags: u32 {
- const LONG_A = 0b1111111111111111;
- }
- }
-
- #[test]
- fn test_bits() {
- assert_eq!(Flags::empty().bits(), 0b00000000);
- assert_eq!(Flags::A.bits(), 0b00000001);
- assert_eq!(Flags::ABC.bits(), 0b00000111);
-
- assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
- assert_eq!(AnotherSetOfFlags::ANOTHER_FLAG.bits(), !0_i8);
- }
-
- #[test]
- fn test_from_bits() {
- assert_eq!(Flags::from_bits(0), Some(Flags::empty()));
- assert_eq!(Flags::from_bits(0b1), Some(Flags::A));
- assert_eq!(Flags::from_bits(0b10), Some(Flags::B));
- assert_eq!(Flags::from_bits(0b11), Some(Flags::A | Flags::B));
- assert_eq!(Flags::from_bits(0b1000), None);
-
- assert_eq!(
- AnotherSetOfFlags::from_bits(!0_i8),
- Some(AnotherSetOfFlags::ANOTHER_FLAG)
- );
- }
-
- #[test]
- fn test_from_bits_truncate() {
- assert_eq!(Flags::from_bits_truncate(0), Flags::empty());
- assert_eq!(Flags::from_bits_truncate(0b1), Flags::A);
- assert_eq!(Flags::from_bits_truncate(0b10), Flags::B);
- assert_eq!(Flags::from_bits_truncate(0b11), (Flags::A | Flags::B));
- assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty());
- assert_eq!(Flags::from_bits_truncate(0b1001), Flags::A);
-
- assert_eq!(
- AnotherSetOfFlags::from_bits_truncate(0_i8),
- AnotherSetOfFlags::empty()
- );
- }
-
- #[test]
- fn test_from_bits_unchecked() {
- let extra = unsafe { Flags::from_bits_unchecked(0b1000) };
- assert_eq!(unsafe { Flags::from_bits_unchecked(0) }, Flags::empty());
- assert_eq!(unsafe { Flags::from_bits_unchecked(0b1) }, Flags::A);
- assert_eq!(unsafe { Flags::from_bits_unchecked(0b10) }, Flags::B);
- assert_eq!(unsafe { Flags::from_bits_unchecked(0b11) }, (Flags::A | Flags::B));
- assert_eq!(unsafe { Flags::from_bits_unchecked(0b1000) }, (extra | Flags::empty()));
- assert_eq!(unsafe { Flags::from_bits_unchecked(0b1001) }, (extra | Flags::A));
- }
-
- #[test]
- fn test_is_empty() {
- assert!(Flags::empty().is_empty());
- assert!(!Flags::A.is_empty());
- assert!(!Flags::ABC.is_empty());
-
- assert!(!AnotherSetOfFlags::ANOTHER_FLAG.is_empty());
- }
-
- #[test]
- fn test_is_all() {
- assert!(Flags::all().is_all());
- assert!(!Flags::A.is_all());
- assert!(Flags::ABC.is_all());
-
- assert!(AnotherSetOfFlags::ANOTHER_FLAG.is_all());
- }
-
- #[test]
- fn test_two_empties_do_not_intersect() {
- let e1 = Flags::empty();
- let e2 = Flags::empty();
- assert!(!e1.intersects(e2));
-
- assert!(AnotherSetOfFlags::ANOTHER_FLAG.intersects(AnotherSetOfFlags::ANOTHER_FLAG));
- }
-
- #[test]
- fn test_empty_does_not_intersect_with_full() {
- let e1 = Flags::empty();
- let e2 = Flags::ABC;
- assert!(!e1.intersects(e2));
- }
-
- #[test]
- fn test_disjoint_intersects() {
- let e1 = Flags::A;
- let e2 = Flags::B;
- assert!(!e1.intersects(e2));
- }
-
- #[test]
- fn test_overlapping_intersects() {
- let e1 = Flags::A;
- let e2 = Flags::A | Flags::B;
- assert!(e1.intersects(e2));
- }
-
- #[test]
- fn test_contains() {
- let e1 = Flags::A;
- let e2 = Flags::A | Flags::B;
- assert!(!e1.contains(e2));
- assert!(e2.contains(e1));
- assert!(Flags::ABC.contains(e2));
-
- assert!(AnotherSetOfFlags::ANOTHER_FLAG.contains(AnotherSetOfFlags::ANOTHER_FLAG));
- }
-
- #[test]
- fn test_insert() {
- let mut e1 = Flags::A;
- let e2 = Flags::A | Flags::B;
- e1.insert(e2);
- assert_eq!(e1, e2);
-
- let mut e3 = AnotherSetOfFlags::empty();
- e3.insert(AnotherSetOfFlags::ANOTHER_FLAG);
- assert_eq!(e3, AnotherSetOfFlags::ANOTHER_FLAG);
- }
-
- #[test]
- fn test_remove() {
- let mut e1 = Flags::A | Flags::B;
- let e2 = Flags::A | Flags::C;
- e1.remove(e2);
- assert_eq!(e1, Flags::B);
-
- let mut e3 = AnotherSetOfFlags::ANOTHER_FLAG;
- e3.remove(AnotherSetOfFlags::ANOTHER_FLAG);
- assert_eq!(e3, AnotherSetOfFlags::empty());
- }
-
- #[test]
- fn test_operators() {
- let e1 = Flags::A | Flags::C;
- let e2 = Flags::B | Flags::C;
- assert_eq!((e1 | e2), Flags::ABC); // union
- assert_eq!((e1 & e2), Flags::C); // intersection
- assert_eq!((e1 - e2), Flags::A); // set difference
- assert_eq!(!e2, Flags::A); // set complement
- assert_eq!(e1 ^ e2, Flags::A | Flags::B); // toggle
- let mut e3 = e1;
- e3.toggle(e2);
- assert_eq!(e3, Flags::A | Flags::B);
-
- let mut m4 = AnotherSetOfFlags::empty();
- m4.toggle(AnotherSetOfFlags::empty());
- assert_eq!(m4, AnotherSetOfFlags::empty());
- }
-
- #[test]
- fn test_operators_unchecked() {
- let extra = unsafe { Flags::from_bits_unchecked(0b1000) };
- let e1 = Flags::A | Flags::C | extra;
- let e2 = Flags::B | Flags::C;
- assert_eq!((e1 | e2), (Flags::ABC | extra)); // union
- assert_eq!((e1 & e2), Flags::C); // intersection
- assert_eq!((e1 - e2), (Flags::A | extra)); // set difference
- assert_eq!(!e2, Flags::A); // set complement
- assert_eq!(!e1, Flags::B); // set complement
- assert_eq!(e1 ^ e2, Flags::A | Flags::B | extra); // toggle
- let mut e3 = e1;
- e3.toggle(e2);
- assert_eq!(e3, Flags::A | Flags::B | extra);
- }
-
- #[test]
- fn test_set() {
- let mut e1 = Flags::A | Flags::C;
- e1.set(Flags::B, true);
- e1.set(Flags::C, false);
-
- assert_eq!(e1, Flags::A | Flags::B);
- }
-
- #[test]
- fn test_assignment_operators() {
- let mut m1 = Flags::empty();
- let e1 = Flags::A | Flags::C;
- // union
- m1 |= Flags::A;
- assert_eq!(m1, Flags::A);
- // intersection
- m1 &= e1;
- assert_eq!(m1, Flags::A);
- // set difference
- m1 -= m1;
- assert_eq!(m1, Flags::empty());
- // toggle
- m1 ^= e1;
- assert_eq!(m1, e1);
- }
-
-
- #[cfg(bitflags_const_fn)]
- #[test]
- fn test_const_fn() {
- const _M1: Flags = Flags::empty();
-
- const M2: Flags = Flags::A;
- assert_eq!(M2, Flags::A);
-
- const M3: Flags = Flags::C;
- assert_eq!(M3, Flags::C);
- }
-
- #[test]
- fn test_extend() {
- let mut flags;
-
- flags = Flags::empty();
- flags.extend([].iter().cloned());
- assert_eq!(flags, Flags::empty());
-
- flags = Flags::empty();
- flags.extend([Flags::A, Flags::B].iter().cloned());
- assert_eq!(flags, Flags::A | Flags::B);
-
- flags = Flags::A;
- flags.extend([Flags::A, Flags::B].iter().cloned());
- assert_eq!(flags, Flags::A | Flags::B);
-
- flags = Flags::B;
- flags.extend([Flags::A, Flags::ABC].iter().cloned());
- assert_eq!(flags, Flags::ABC);
- }
-
- #[test]
- fn test_from_iterator() {
- assert_eq!([].iter().cloned().collect::<Flags>(), Flags::empty());
- assert_eq!(
- [Flags::A, Flags::B].iter().cloned().collect::<Flags>(),
- Flags::A | Flags::B
- );
- assert_eq!(
- [Flags::A, Flags::ABC].iter().cloned().collect::<Flags>(),
- Flags::ABC
- );
- }
-
- #[test]
- fn test_lt() {
- let mut a = Flags::empty();
- let mut b = Flags::empty();
-
- assert!(!(a < b) && !(b < a));
- b = Flags::B;
- assert!(a < b);
- a = Flags::C;
- assert!(!(a < b) && b < a);
- b = Flags::C | Flags::B;
- assert!(a < b);
- }
-
- #[test]
- fn test_ord() {
- let mut a = Flags::empty();
- let mut b = Flags::empty();
-
- assert!(a <= b && a >= b);
- a = Flags::A;
- assert!(a > b && a >= b);
- assert!(b < a && b <= a);
- b = Flags::B;
- assert!(b > a && b >= a);
- assert!(a < b && a <= b);
- }
-
- fn hash<T: Hash>(t: &T) -> u64 {
- let mut s = DefaultHasher::new();
- t.hash(&mut s);
- s.finish()
- }
-
- #[test]
- fn test_hash() {
- let mut x = Flags::empty();
- let mut y = Flags::empty();
- assert_eq!(hash(&x), hash(&y));
- x = Flags::all();
- y = Flags::ABC;
- assert_eq!(hash(&x), hash(&y));
- }
-
- #[test]
- fn test_debug() {
- assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B");
- assert_eq!(format!("{:?}", Flags::empty()), "(empty)");
- assert_eq!(format!("{:?}", Flags::ABC), "A | B | C | ABC");
- let extra = unsafe { Flags::from_bits_unchecked(0xb8) };
- assert_eq!(format!("{:?}", extra), "0xb8");
- assert_eq!(format!("{:?}", Flags::A | extra), "A | 0xb8");
- assert_eq!(format!("{:?}", Flags::ABC | extra), "A | B | C | ABC | 0xb8");
- }
-
- #[test]
- fn test_binary() {
- assert_eq!(format!("{:b}", Flags::ABC), "111");
- assert_eq!(format!("{:#b}", Flags::ABC), "0b111");
- let extra = unsafe { Flags::from_bits_unchecked(0b1010000) };
- assert_eq!(format!("{:b}", Flags::ABC | extra), "1010111");
- assert_eq!(format!("{:#b}", Flags::ABC | extra), "0b1010111");
- }
-
- #[test]
- fn test_octal() {
- assert_eq!(format!("{:o}", LongFlags::LONG_A), "177777");
- assert_eq!(format!("{:#o}", LongFlags::LONG_A), "0o177777");
- let extra = unsafe { LongFlags::from_bits_unchecked(0o5000000) };
- assert_eq!(format!("{:o}", LongFlags::LONG_A | extra), "5177777");
- assert_eq!(format!("{:#o}", LongFlags::LONG_A | extra), "0o5177777");
- }
-
- #[test]
- fn test_lowerhex() {
- assert_eq!(format!("{:x}", LongFlags::LONG_A), "ffff");
- assert_eq!(format!("{:#x}", LongFlags::LONG_A), "0xffff");
- let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) };
- assert_eq!(format!("{:x}", LongFlags::LONG_A | extra), "e0ffff");
- assert_eq!(format!("{:#x}", LongFlags::LONG_A | extra), "0xe0ffff");
- }
-
- #[test]
- fn test_upperhex() {
- assert_eq!(format!("{:X}", LongFlags::LONG_A), "FFFF");
- assert_eq!(format!("{:#X}", LongFlags::LONG_A), "0xFFFF");
- let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) };
- assert_eq!(format!("{:X}", LongFlags::LONG_A | extra), "E0FFFF");
- assert_eq!(format!("{:#X}", LongFlags::LONG_A | extra), "0xE0FFFF");
- }
-
- mod submodule {
- bitflags! {
- pub struct PublicFlags: i8 {
- const X = 0;
- }
- }
- bitflags! {
- struct PrivateFlags: i8 {
- const Y = 0;
- }
- }
-
- #[test]
- fn test_private() {
- let _ = PrivateFlags::Y;
- }
- }
-
- #[test]
- fn test_public() {
- let _ = submodule::PublicFlags::X;
- }
-
- mod t1 {
- mod foo {
- pub type Bar = i32;
- }
-
- bitflags! {
- /// baz
- struct Flags: foo::Bar {
- const A = 0b00000001;
- #[cfg(foo)]
- const B = 0b00000010;
- #[cfg(foo)]
- const C = 0b00000010;
- }
- }
- }
-
- #[test]
- fn test_in_function() {
- bitflags! {
- struct Flags: u8 {
- const A = 1;
- #[cfg(any())] // false
- const B = 2;
- }
- }
- assert_eq!(Flags::all(), Flags::A);
- assert_eq!(format!("{:?}", Flags::A), "A");
- }
-
- #[test]
- fn test_deprecated() {
- bitflags! {
- pub struct TestFlags: u32 {
- #[deprecated(note = "Use something else.")]
- const ONE = 1;
- }
- }
- }
-
- #[test]
- fn test_pub_crate() {
- mod module {
- bitflags! {
- pub (crate) struct Test: u8 {
- const FOO = 1;
- }
- }
- }
-
- assert_eq!(module::Test::FOO.bits(), 1);
- }
-
- #[test]
- fn test_pub_in_module() {
- mod module {
- mod submodule {
- bitflags! {
- // `pub (in super)` means only the module `module` will
- // be able to access this.
- pub (in super) struct Test: u8 {
- const FOO = 1;
- }
- }
- }
-
- mod test {
- // Note: due to `pub (in super)`,
- // this cannot be accessed directly by the testing code.
- pub(super) fn value() -> u8 {
- super::submodule::Test::FOO.bits()
- }
- }
-
- pub fn value() -> u8 {
- test::value()
- }
- }
-
- assert_eq!(module::value(), 1)
- }
-
- #[test]
- fn test_zero_value_flags() {
- bitflags! {
- struct Flags: u32 {
- const NONE = 0b0;
- const SOME = 0b1;
- }
- }
-
- assert!(Flags::empty().contains(Flags::NONE));
- assert!(Flags::SOME.contains(Flags::NONE));
- assert!(Flags::NONE.is_empty());
-
- assert_eq!(format!("{:?}", Flags::empty()), "NONE");
- assert_eq!(format!("{:?}", Flags::SOME), "SOME");
- }
-}
diff --git a/bitflags/test_suite/Cargo.toml b/bitflags/test_suite/Cargo.toml
deleted file mode 100644
index 2a02d80..0000000
--- a/bitflags/test_suite/Cargo.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[project]
-name = "test_suite"
-version = "0.0.0"
-
-[features]
-unstable = ["compiletest_rs"]
-
-[dependencies]
-bitflags = { path = "../" }
-compiletest_rs = { version = "0.3.18", optional = true, features=["stable"] }
-serde = "1.0"
-serde_derive = "1.0"
-serde_json = "1.0"
diff --git a/bitflags/test_suite/tests/compile-fail/private_flags.rs b/bitflags/test_suite/tests/compile-fail/private_flags.rs
deleted file mode 100644
index d31c28d..0000000
--- a/bitflags/test_suite/tests/compile-fail/private_flags.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-#[macro_use]
-extern crate bitflags;
-
-mod example {
- bitflags! {
- pub struct Flags1: u32 {
- const FLAG_A = 0b00000001;
- }
- }
- bitflags! {
- struct Flags2: u32 {
- const FLAG_B = 0b00000010;
- }
- }
-}
-
-fn main() {
- let flag1 = example::Flags1::FLAG_A;
- let flag2 = example::Flags2::FLAG_B; //~ ERROR struct `Flags2` is private
-}
diff --git a/bitflags/test_suite/tests/compiletest.rs b/bitflags/test_suite/tests/compiletest.rs
deleted file mode 100644
index 2beeae0..0000000
--- a/bitflags/test_suite/tests/compiletest.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-#![cfg(feature = "unstable")]
-
-extern crate compiletest_rs as compiletest;
-
-use std::fs;
-use std::result::Result;
-
-use compiletest::common::Mode;
-
-fn run_mode(mode: Mode) {
- let config = compiletest::Config {
- mode: mode,
- src_base: format!("tests/{}", mode).into(),
- target_rustcflags: fs::read_dir("../target/debug/deps")
- .unwrap()
- .map(Result::unwrap)
- .filter(|entry| {
- let file_name = entry.file_name();
- let file_name = file_name.to_string_lossy();
- file_name.starts_with("libbitflags-") && file_name.ends_with(".rlib")
- })
- .max_by_key(|entry| entry.metadata().unwrap().modified().unwrap())
- .map(|entry| format!("--extern bitflags={}", entry.path().to_string_lossy())),
- ..Default::default()
- };
-
- compiletest::run_tests(&config);
-}
-
-#[test]
-fn compile_test() {
- run_mode(Mode::CompileFail);
-}
diff --git a/bitflags/test_suite/tests/conflicting_trait_impls.rs b/bitflags/test_suite/tests/conflicting_trait_impls.rs
deleted file mode 100644
index eb7a325..0000000
--- a/bitflags/test_suite/tests/conflicting_trait_impls.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-#![no_std]
-
-#[macro_use]
-extern crate bitflags;
-
-#[allow(unused_imports)]
-use core::fmt::Display;
-
-bitflags! {
- /// baz
- struct Flags: u32 {
- const A = 0b00000001;
- }
-}
-
-#[test]
-fn main() {}
diff --git a/bitflags/test_suite/tests/external.rs b/bitflags/test_suite/tests/external.rs
deleted file mode 100644
index 4c88387..0000000
--- a/bitflags/test_suite/tests/external.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#[macro_use]
-extern crate bitflags;
-
-bitflags! {
- /// baz
- struct Flags: u32 {
- const A = 0b00000001;
- #[doc = "bar"]
- const B = 0b00000010;
- const C = 0b00000100;
- #[doc = "foo"]
- const ABC = Flags::A.bits | Flags::B.bits | Flags::C.bits;
- }
-}
-
-#[test]
-fn smoke() {
- assert_eq!(Flags::ABC, Flags::A | Flags::B | Flags::C);
-}
diff --git a/bitflags/test_suite/tests/external_no_std.rs b/bitflags/test_suite/tests/external_no_std.rs
deleted file mode 100644
index 31f87e4..0000000
--- a/bitflags/test_suite/tests/external_no_std.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-#![no_std]
-
-#[macro_use]
-extern crate bitflags;
-
-bitflags! {
- /// baz
- struct Flags: u32 {
- const A = 0b00000001;
- #[doc = "bar"]
- const B = 0b00000010;
- const C = 0b00000100;
- #[doc = "foo"]
- const ABC = Flags::A.bits | Flags::B.bits | Flags::C.bits;
- }
-}
-
-#[test]
-fn smoke() {
- assert_eq!(Flags::ABC, Flags::A | Flags::B | Flags::C);
-}
diff --git a/bitflags/test_suite/tests/i128_bitflags.rs b/bitflags/test_suite/tests/i128_bitflags.rs
deleted file mode 100644
index 1b6f7c5..0000000
--- a/bitflags/test_suite/tests/i128_bitflags.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-#![cfg(feature = "unstable")]
-
-#[macro_use]
-extern crate bitflags;
-
-bitflags! {
- /// baz
- struct Flags128: u128 {
- const A = 0x0000_0000_0000_0000_0000_0000_0000_0001;
- const B = 0x0000_0000_0000_1000_0000_0000_0000_0000;
- const C = 0x8000_0000_0000_0000_0000_0000_0000_0000;
- const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
- }
-}
-
-#[test]
-fn test_i128_bitflags() {
- assert_eq!(Flags128::ABC, Flags128::A | Flags128::B | Flags128::C);
- assert_eq!(Flags128::A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
- assert_eq!(Flags128::B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
- assert_eq!(Flags128::C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
- assert_eq!(
- Flags128::ABC.bits,
- 0x8000_0000_0000_1000_0000_0000_0000_0001
- );
- assert_eq!(format!("{:?}", Flags128::A), "A");
- assert_eq!(format!("{:?}", Flags128::B), "B");
- assert_eq!(format!("{:?}", Flags128::C), "C");
- assert_eq!(format!("{:?}", Flags128::ABC), "A | B | C | ABC");
-}
diff --git a/bitflags/test_suite/tests/serde.rs b/bitflags/test_suite/tests/serde.rs
deleted file mode 100644
index 0424af5..0000000
--- a/bitflags/test_suite/tests/serde.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-#[macro_use]
-extern crate bitflags;
-
-#[macro_use]
-extern crate serde_derive;
-extern crate serde;
-extern crate serde_json;
-
-bitflags! {
- #[derive(Serialize, Deserialize)]
- struct Flags: u32 {
- const A = 1;
- const B = 2;
- const C = 4;
- const D = 8;
- }
-}
-
-#[test]
-fn serialize() {
- let flags = Flags::A | Flags::B;
-
- let serialized = serde_json::to_string(&flags).unwrap();
-
- assert_eq!(serialized, r#"{"bits":3}"#);
-}
-
-#[test]
-fn deserialize() {
- let deserialized: Flags = serde_json::from_str(r#"{"bits":12}"#).unwrap();
-
- let expected = Flags::C | Flags::D;
-
- assert_eq!(deserialized.bits, expected.bits);
-}
diff --git a/cc/.github/workflows/main.yml b/cc/.github/workflows/main.yml
deleted file mode 100644
index 9c35a41..0000000
--- a/cc/.github/workflows/main.yml
+++ /dev/null
@@ -1,124 +0,0 @@
-name: CI
-on: [push, pull_request]
-
-jobs:
- test:
- name: Test
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- build: [stable, beta, nightly, linux32, macos, aarch64-ios, win32, win64, mingw32, mingw64, windows-2016]
- include:
- - build: stable
- os: ubuntu-latest
- rust: stable
- target: x86_64-unknown-linux-gnu
- - build: beta
- os: ubuntu-latest
- rust: beta
- target: x86_64-unknown-linux-gnu
- - build: nightly
- os: ubuntu-latest
- rust: nightly
- target: x86_64-unknown-linux-gnu
- - build: linux32
- os: ubuntu-latest
- rust: stable
- target: i686-unknown-linux-gnu
- - build: macos
- os: macos-latest
- rust: stable
- target: x86_64-apple-darwin
- - build: aarch64-ios
- os: macos-latest
- rust: stable
- target: aarch64-apple-ios
- no_run: --no-run
- - build: win32
- os: windows-2016
- rust: stable-i686-msvc
- target: i686-pc-windows-msvc
- - build: win64
- os: windows-latest
- rust: stable
- target: x86_64-pc-windows-msvc
- - build: mingw32
- os: windows-latest
- rust: stable-i686-gnu
- target: i686-pc-windows-gnu
- - build: mingw64
- os: windows-latest
- rust: stable-x86_64-gnu
- target: x86_64-pc-windows-gnu
- - build: windows-2016
- os: windows-2016
- rust: stable-x86_64
- target: x86_64-pc-windows-msvc
- steps:
- - uses: actions/checkout@master
- - name: Install Rust (rustup)
- run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
- if: matrix.os != 'macos-latest'
- shell: bash
- - name: Install Rust (macos)
- run: |
- curl https://sh.rustup.rs | sh -s -- -y
- echo "##[add-path]$HOME/.cargo/bin"
- if: matrix.os == 'macos-latest'
- - run: rustup target add ${{ matrix.target }}
- - name: Install g++-multilib
- run: |
- set -e
- # Remove the ubuntu-toolchain-r/test PPA, which is added by default.
- # Some packages were removed, and this is causing the g++multilib
- # install to fail. Similar issue:
- # https://github.com/scikit-learn/scikit-learn/issues/13928.
- sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test
- sudo apt-get install g++-multilib
- if: matrix.build == 'linux32'
- - run: cargo build
- - run: cargo test ${{ matrix.no_run }}
- - run: cargo test ${{ matrix.no_run }} --features parallel
- - run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }}
- - run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --features parallel
- - run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --release
-
- msrv:
- name: MSRV
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest, windows-latest]
- steps:
- - uses: actions/checkout@master
- - name: Install Rust
- run: rustup update 1.31.0 --no-self-update && rustup default 1.31.0
- shell: bash
- - run: cargo build
-
- rustfmt:
- name: Rustfmt
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@master
- - name: Install Rust
- run: rustup update stable && rustup default stable && rustup component add rustfmt
- - run: cargo fmt -- --check
-
- publish_docs:
- name: Publish Documentation
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@master
- - name: Install Rust
- run: rustup update stable && rustup default stable
- - name: Build documentation
- run: cargo doc --no-deps --all-features
- - name: Publish documentation
- run: |
- cd target/doc
- git init
- git add .
- git -c user.name='ci' -c user.email='ci' commit -m init
- git push -f -q https://git:${{ secrets.github_token }}@github.com/${{ github.repository }} HEAD:gh-pages
- if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
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 88f44eb..0000000
--- a/cc/Cargo.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-[package]
-name = "cc"
-version = "1.0.48"
-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"]
-edition = "2018"
-
-[dependencies]
-num_cpus = { version = "1.10", optional = true }
-jobserver = { version = "0.1.16", optional = true }
-
-[features]
-parallel = ["num_cpus", "jobserver"]
-
-[dev-dependencies]
-tempfile = "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 68448ac..0000000
--- a/cc/README.md
+++ /dev/null
@@ -1,194 +0,0 @@
-# cc-rs
-
-A library to compile C/C++/assembly into a Rust library/application.
-
-[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
-
-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
-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
-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/cc-test/Cargo.toml b/cc/cc-test/Cargo.toml
deleted file mode 100644
index c25854c..0000000
--- a/cc/cc-test/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "cc-test"
-version = "0.1.0"
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-edition = "2018"
-
-[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 3065861..0000000
--- a/cc/cc-test/build.rs
+++ /dev/null
@@ -1,88 +0,0 @@
-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 a457c72..0000000
--- a/cc/cc-test/tests/all.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-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/src/bin/gcc-shim.rs b/cc/src/bin/gcc-shim.rs
deleted file mode 100644
index 1731df8..0000000
--- a/cc/src/bin/gcc-shim.rs
+++ /dev/null
@@ -1,48 +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 mut args = env::args();
- let program = args.next().expect("Unexpected empty args");
-
- let out_dir = PathBuf::from(
- env::var_os("GCCTEST_OUT_DIR").expect(&format!("{}: GCCTEST_OUT_DIR not found", program)),
- );
-
- // Find the first nonexistent candidate file to which the program's args can be written.
- for i in 0.. {
- let candidate = &out_dir.join(format!("out{}", i));
-
- // If the file exists, commands have already run. Try again.
- if candidate.exists() {
- continue;
- }
-
- // Create a file and record the args passed to the command.
- let mut f = File::create(candidate).expect(&format!(
- "{}: can't create candidate: {}",
- program,
- candidate.to_string_lossy()
- ));
- for arg in args {
- writeln!(f, "{}", arg).expect(&format!(
- "{}: can't write to candidate: {}",
- program,
- candidate.to_string_lossy()
- ));
- }
- break;
- }
-
- // Create a file used by some tests.
- let path = &out_dir.join("libfoo.a");
- File::create(path).expect(&format!(
- "{}: can't create libfoo.a: {}",
- program,
- path.to_string_lossy()
- ));
-}
diff --git a/cc/src/com.rs b/cc/src/com.rs
deleted file mode 100644
index a5f2afe..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 crate::winapi::CoInitializeEx;
-use crate::winapi::IUnknown;
-use crate::winapi::Interface;
-use crate::winapi::BSTR;
-use crate::winapi::COINIT_MULTITHREADED;
-use crate::winapi::{SysFreeString, SysStringLen};
-use crate::winapi::{HRESULT, S_FALSE, S_OK};
-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;
-
-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 d795e5a..0000000
--- a/cc/src/lib.rs
+++ /dev/null
@@ -1,2666 +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 parallelism.
-//!
-//! # Examples
-//!
-//! Use the `Build` struct to compile `src/foo.c`:
-//!
-//! ```no_run
-//! 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)]
-
-use std::collections::HashMap;
-use std::env;
-use std::ffi::{OsStr, OsString};
-use std::fmt::{self, Display};
-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>>>,
- ar_flags: Vec<String>,
- no_default_flags: 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>,
- force_frame_pointer: 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))
- }
-}
-
-impl Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}: {}", self.kind, self.message)
- }
-}
-
-/// 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());
- }
- }
- }
-
- /// What the flag to force frame pointers.
- fn add_force_frame_pointer(&self, cmd: &mut Tool) {
- match *self {
- ToolFamily::Gnu | ToolFamily::Clang => {
- cmd.push_cc_arg("-fno-omit-frame-pointer".into());
- }
- _ => (),
- }
- }
-
- /// 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",
- }
- }
-
- 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())),
- ar_flags: Vec::new(),
- no_default_flags: false,
- 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,
- force_frame_pointer: 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
- }
-
- /// Add an arbitrary flag to the invocation of the compiler
- ///
- /// # Example
- ///
- /// ```no_run
- /// cc::Build::new()
- /// .file("src/foo.c")
- /// .file("src/bar.c")
- /// .ar_flag("/NODEFAULTLIB:libc.dll")
- /// .compile("foo");
- /// ```
-
- pub fn ar_flag(&mut self, flag: &str) -> &mut Build {
- self.ar_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,
- self.cuda,
- 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") && !self.cuda {
- 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
- }
-
- /// Disables the generation of default compiler flags. The default compiler
- /// flags may cause conflicts in some cross compiling scenarios.
- ///
- /// Setting the `CRATE_CC_NO_DEFAULTS` environment variable has the same
- /// effect as setting this to `true`. The presence of the environment
- /// variable and the value of `no_default_flags` will be OR'd together.
- pub fn no_default_flags(&mut self, no_default_flags: bool) -> &mut Build {
- self.no_default_flags = no_default_flags;
- 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 `DEBUG` environment
- /// variable by build scripts, so it's not required to call this function.
- pub fn debug(&mut self, debug: bool) -> &mut Build {
- self.debug = Some(debug);
- self
- }
-
- /// Configures whether the compiler will emit instructions to store
- /// frame pointers during codegen.
- ///
- /// This option is automatically enabled when debug information is emitted.
- /// Otherwise the target platform compiler's default will be used.
- /// You can use this option to force a specific setting.
- pub fn force_frame_pointer(&mut self, force: bool) -> &mut Build {
- self.force_frame_pointer = Some(force);
- 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` and `riscv` 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<'me>(&'me self, objs: &[Object]) -> Result<(), Error> {
- use std::sync::atomic::{AtomicBool, Ordering::SeqCst};
- use std::sync::Once;
-
- // Limit our parallelism globally with a jobserver. Start off by
- // releasing our own token for this process so we can have a bit of an
- // easier to write loop below. If this fails, though, then we're likely
- // on Windows with the main implicit token, so we just have a bit extra
- // parallelism for a bit and don't reacquire later.
- let server = jobserver();
- let reacquire = server.release_raw().is_ok();
-
- // When compiling objects in parallel we do a few dirty tricks to speed
- // things up:
- //
- // * First is that we use the `jobserver` crate to limit the parallelism
- // of this build script. The `jobserver` crate will use a jobserver
- // configured by Cargo for build scripts to ensure that parallelism is
- // coordinated across C compilations and Rust compilations. Before we
- // compile anything we make sure to wait until we acquire a token.
- //
- // Note that this jobserver is cached globally so we only used one per
- // process and only worry about creating it once.
- //
- // * Next we use a raw `thread::spawn` per thread to actually compile
- // objects in parallel. We only actually spawn a thread after we've
- // acquired a token to perform some work
- //
- // * Finally though we want to keep the dependencies of this crate
- // pretty light, so we avoid using a safe abstraction like `rayon` and
- // instead rely on some bits of `unsafe` code. We know that this stack
- // frame persists while everything is compiling so we use all the
- // stack-allocated objects without cloning/reallocating. We use a
- // transmute to `State` with a `'static` lifetime to persist
- // everything we need across the boundary, and the join-on-drop
- // semantics of `JoinOnDrop` should ensure that our stack frame is
- // alive while threads are alive.
- //
- // With all that in mind we compile all objects in a loop here, after we
- // acquire the appropriate tokens, Once all objects have been compiled
- // we join on all the threads and propagate the results of compilation.
- //
- // Note that as a slight optimization we try to break out as soon as
- // possible as soon as any compilation fails to ensure that errors get
- // out to the user as fast as possible.
- let error = AtomicBool::new(false);
- let mut threads = Vec::new();
- for obj in objs {
- if error.load(SeqCst) {
- break;
- }
- let token = server.acquire()?;
- let state = State {
- build: self,
- obj,
- error: &error,
- };
- let state = unsafe { std::mem::transmute::<State, State<'static>>(state) };
- let thread = thread::spawn(|| {
- let state: State<'me> = state; // erase the `'static` lifetime
- let result = state.build.compile_object(state.obj);
- if result.is_err() {
- state.error.store(true, SeqCst);
- }
- drop(token); // make sure our jobserver token is released after the compile
- return result;
- });
- threads.push(JoinOnDrop(Some(thread)));
- }
-
- for mut thread in threads {
- if let Some(thread) = thread.0.take() {
- thread.join().expect("thread should not panic")?;
- }
- }
-
- // Reacquire our process's token before we proceed, which we released
- // before entering the loop above.
- if reacquire {
- server.acquire_raw()?;
- }
-
- return Ok(());
-
- /// Shared state from the parent thread to the child thread. This
- /// package of pointers is temporarily transmuted to a `'static`
- /// lifetime to cross the thread boundary and then once the thread is
- /// running we erase the `'static` to go back to an anonymous lifetime.
- struct State<'a> {
- build: &'a Build,
- obj: &'a Object,
- error: &'a AtomicBool,
- }
-
- /// Returns a suitable `jobserver::Client` used to coordinate
- /// parallelism between build scripts.
- fn jobserver() -> &'static jobserver::Client {
- static INIT: Once = Once::new();
- static mut JOBSERVER: Option<jobserver::Client> = None;
-
- fn _assert_sync<T: Sync>() {}
- _assert_sync::<jobserver::Client>();
-
- unsafe {
- INIT.call_once(|| {
- let server = default_jobserver();
- JOBSERVER = Some(server);
- });
- JOBSERVER.as_ref().unwrap()
- }
- }
-
- unsafe fn default_jobserver() -> jobserver::Client {
- // Try to use the environmental jobserver which Cargo typically
- // initializes for us...
- if let Some(client) = jobserver::Client::from_env() {
- return client;
- }
-
- // ... but if that fails for whatever reason fall back to the number
- // of cpus on the system or the `NUM_JOBS` env var.
- let mut parallelism = num_cpus::get();
- if let Ok(amt) = env::var("NUM_JOBS") {
- if let Ok(amt) = amt.parse() {
- parallelism = amt;
- }
- }
-
- // If we create our own jobserver then be sure to reserve one token
- // for ourselves.
- let client = jobserver::Client::new(parallelism).expect("failed to create jobserver");
- client.acquire_raw().expect("failed to acquire initial");
- return client;
- }
-
- struct JoinOnDrop(Option<thread::JoinHandle<Result<(), Error>>>);
-
- impl Drop for JoinOnDrop {
- fn drop(&mut self) {
- if let Some(thread) = self.0.take() {
- drop(thread.join());
- }
- }
- }
- }
-
- #[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, self.cuda, msvc, is_asm, is_arm);
- // armasm and armasm64 don't requrie -c option
- if !msvc || !is_asm || !is_arm {
- cmd.arg("-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("-E");
-
- 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 `no_default_flags` or environment variable
- let no_defaults = self.no_default_flags || self.getenv("CRATE_CC_NO_DEFAULTS").is_some();
-
- if !no_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("-I".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() {
- if let Some(ref value) = *value {
- cmd.args.push(format!("-D{}={}", key, value).into());
- } else {
- cmd.args.push(format!("-D{}", 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 { .. } => {
- cmd.push_cc_arg("-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.push_cc_arg(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());
- }
- // Disable generation of PIC on RISC-V for now: rust-lld doesn't support this yet
- if self
- .pic
- .unwrap_or(!target.contains("windows-gnu") && !target.contains("riscv"))
- {
- 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 {
- // NVCC debug flag
- cmd.args.push("-G".into());
- }
- let family = cmd.family;
- family.add_debug_flags(cmd);
- }
-
- if self.get_force_frame_pointer() {
- let family = cmd.family;
- family.add_force_frame_pointer(cmd);
- }
-
- // Target flags
- match cmd.family {
- ToolFamily::Clang => {
- cmd.args.push(format!("--target={}", target).into());
- }
- ToolFamily::Msvc { clang_cl } => {
- // This is an undocumented flag from MSVC but helps with making
- // builds more reproducible by avoiding putting timestamps into
- // files.
- cmd.args.push("-Brepro".into());
-
- if clang_cl {
- if target.contains("x86_64") {
- cmd.args.push("-m64".into());
- } else if target.contains("86") {
- cmd.args.push("-m32".into());
- cmd.push_cc_arg("-arch:IA32".into());
- } else {
- cmd.push_cc_arg(format!("--target={}", target).into());
- }
- } else {
- if target.contains("i586") {
- cmd.push_cc_arg("-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.starts_with("riscv32") || target.starts_with("riscv64") {
- // get the 32i/32imac/32imc/64gc/64imac/... part
- let mut parts = target.split('-');
- if let Some(arch) = parts.next() {
- let arch = &arch[5..];
- cmd.args.push(("-march=rv".to_owned() + arch).into());
- if target.contains("linux") && arch.starts_with("64") {
- cmd.args.push("-mabi=lp64d".into());
- } else if target.contains("linux") && arch.starts_with("32") {
- cmd.args.push("-mabi=ilp32d".into());
- } else if arch.starts_with("64") {
- cmd.args.push("-mabi=lp64".into());
- } else {
- cmd.args.push("-mabi=ilp32".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");
- for flag in self.ar_flags.iter() {
- cmd.arg(flag);
- }
-
- // 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()?;
-
- // Set an environment variable to tell the OSX archiver to ensure
- // that all dates listed in the archive are zero, improving
- // determinism of builds. AFAIK there's not really official
- // documentation of this but there's a lot of references to it if
- // you search google.
- //
- // You can reproduce this locally on a mac with:
- //
- // $ touch foo.c
- // $ cc -c foo.c -o foo.o
- //
- // # Notice that these two checksums are different
- // $ ar crus libfoo1.a foo.o && sleep 2 && ar crus libfoo2.a foo.o
- // $ md5sum libfoo*.a
- //
- // # Notice that these two checksums are the same
- // $ export ZERO_AR_DATE=1
- // $ ar crus libfoo1.a foo.o && sleep 2 && touch foo.o && ar crus libfoo2.a foo.o
- // $ md5sum libfoo*.a
- //
- // In any case if this doesn't end up getting read, it shouldn't
- // cause that many issues!
- ar.env("ZERO_AR_DATE", "1");
- for flag in self.ar_flags.iter() {
- ar.arg(flag);
- }
- 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 min_version =
- std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "7.0".into());
-
- let sdk = match arch {
- ArchSpec::Device(arch) => {
- cmd.args.push("-arch".into());
- cmd.args.push(arch.into());
- cmd.args
- .push(format!("-miphoneos-version-min={}", min_version).into());
- "iphoneos"
- }
- ArchSpec::Simulator(arch) => {
- cmd.args.push(arch.into());
- cmd.args
- .push(format!("-mios-simulator-version-min={}", min_version).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, wrapper, args)| {
- // find the driver mode, if any
- const DRIVER_MODE: &str = "--driver-mode=";
- let driver_mode = args
- .iter()
- .find(|a| a.starts_with(DRIVER_MODE))
- .map(|a| &a[DRIVER_MODE.len()..]);
- // 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::with_clang_driver(PathBuf::from(tool.trim()), driver_mode);
- if let Some(cc) = wrapper {
- 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 target.contains("vxworks") {
- "wr-c++".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-uwp-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"),
- "riscv32i-unknown-none-elf" => Some("riscv32-unknown-elf"),
- "riscv32imac-unknown-none-elf" => Some("riscv32-unknown-elf"),
- "riscv32imc-unknown-none-elf" => Some("riscv32-unknown-elf"),
- "riscv64gc-unknown-none-elf" => Some("riscv64-unknown-elf"),
- "riscv64imac-unknown-none-elf" => Some("riscv64-unknown-elf"),
- "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-uwp-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), None, self.cuda);
- nvcc_tool
- .args
- .push(format!("-ccbin={}", tool.path.display()).into());
- nvcc_tool.family = tool.family;
- 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_force_frame_pointer(&self) -> bool {
- self.force_frame_pointer.unwrap_or_else(|| self.get_debug())
- }
-
- 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) -> Self {
- Tool::with_features(path, None, false)
- }
-
- fn with_clang_driver(path: PathBuf, clang_driver: Option<&str>) -> Self {
- Self::with_features(path, clang_driver, false)
- }
-
- fn with_features(path: PathBuf, clang_driver: Option<&str>, cuda: bool) -> Self {
- // 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") {
- match clang_driver {
- Some("cl") => ToolFamily::Msvc { clang_cl: true },
- _ => 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("-Xcompiler".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,
- cuda: bool,
- msvc: bool,
- is_asm: bool,
- is_arm: bool,
-) {
- if msvc && !cuda && !(is_asm && is_arm) {
- 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 bc2b1c2..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 crate::winapi::Interface;
-use crate::winapi::BSTR;
-use crate::winapi::LPCOLESTR;
-use crate::winapi::LPSAFEARRAY;
-use crate::winapi::S_FALSE;
-use crate::winapi::{CoCreateInstance, CLSCTX_ALL};
-use crate::winapi::{IUnknown, IUnknownVtbl};
-use crate::winapi::{HRESULT, LCID, LPCWSTR, PULONGLONG};
-use crate::winapi::{LPFILETIME, ULONG};
-use std::ffi::OsString;
-use std::ptr::null_mut;
-
-use crate::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 = 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 = 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 5af3ff7..0000000
--- a/cc/src/windows_registry.rs
+++ /dev/null
@@ -1,754 +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 crate::Tool;
-
-/// 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 crate::com;
- use crate::registry::{RegistryKey, LOCAL_MACHINE};
- use crate::setup_config::{EnumSetupInstances, SetupConfiguration, SetupInstance};
- use std::env;
- use std::ffi::OsString;
- use std::fs::File;
- use std::io::Read;
- use std::iter;
- use std::mem;
- use std::path::{Path, PathBuf};
-
- use crate::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
- }
- }
-
- #[allow(bare_trait_objects)]
- 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 = instance.ok()?;
- let installation_name = instance.installation_name().ok()?;
- if installation_name.to_str()?.starts_with("VisualStudio/16.") {
- Some(PathBuf::from(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> {
- com::initialize().ok()?;
-
- let config = SetupConfiguration::new().ok()?;
- config.enum_all_instances().ok()
- }
-
- pub fn find_msvc_15(tool: &str, target: &str) -> Option<Tool> {
- let iter = vs15_instances()?;
- for instance in iter {
- let instance = 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) = 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);
- }
-
- 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 = instance.installation_path().ok()?.into();
- let version_path =
- instance_path.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt");
- let mut version_file = File::open(version_path).ok()?;
- let mut version = String::new();
- 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 = 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 = 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 = get_vc_dir("14.0")?;
- let mut tool = get_tool(tool, &vcdir, target)?;
- add_sdks(&mut tool, target)?;
- Some(tool.into_tool())
- }
-
- fn add_sdks(tool: &mut MsvcTool, target: &str) -> Option<()> {
- let sub = lib_subdir(target)?;
- let (ucrt, ucrt_version) = 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 = get_vc_dir("12.0")?;
- let mut tool = get_tool(tool, &vcdir, target)?;
- let sub = lib_subdir(target)?;
- let sdk81 = 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 = get_vc_dir("11.0")?;
- let mut tool = get_tool(tool, &vcdir, target)?;
- let sub = lib_subdir(target)?;
- let sdk8 = 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 = 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 = LOCAL_MACHINE.open(key.as_ref()).ok()?;
- let path = 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 = LOCAL_MACHINE.open(key.as_ref()).ok()?;
- let root = key.query_str("KitsRoot10").ok()?;
- let readdir = Path::new(&root).join("lib").read_dir().ok()?;
- let max_libdir = 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 = LOCAL_MACHINE.open(key.as_ref()).ok()?;
- let root = key.query_str("InstallationFolder").ok()?;
- let readdir = 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 = 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 = LOCAL_MACHINE.open(key.as_ref()).ok()?;
- let root = 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 = LOCAL_MACHINE.open(key.as_ref()).ok()?;
- let root = 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_vs16(target) {
- return Some(r);
- } else 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 43eb689..0000000
--- a/cc/tests/cc_env.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-use std::env;
-use std::ffi::OsString;
-use std::path::Path;
-
-mod support;
-use crate::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/cflags.rs b/cc/tests/cflags.rs
deleted file mode 100644
index caec6ea..0000000
--- a/cc/tests/cflags.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-mod support;
-
-use crate::support::Test;
-use std::env;
-
-/// This test is in its own module because it modifies the environment and would affect other tests
-/// when run in parallel with them.
-#[test]
-fn gnu_no_warnings_if_cflags() {
- env::set_var("CFLAGS", "-arbitrary");
- let test = Test::gnu();
- test.gcc().file("foo.c").compile("foo");
-
- test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra");
-}
diff --git a/cc/tests/cxxflags.rs b/cc/tests/cxxflags.rs
deleted file mode 100644
index c524c7d..0000000
--- a/cc/tests/cxxflags.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-mod support;
-
-use crate::support::Test;
-use std::env;
-
-/// This test is in its own module because it modifies the environment and would affect other tests
-/// when run in parallel with them.
-#[test]
-fn gnu_no_warnings_if_cxxflags() {
- env::set_var("CXXFLAGS", "-arbitrary");
- let test = Test::gnu();
- test.gcc().file("foo.cpp").cpp(true).compile("foo");
-
- test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra");
-}
diff --git a/cc/tests/support/mod.rs b/cc/tests/support/mod.rs
deleted file mode 100644
index fe8acde..0000000
--- a/cc/tests/support/mod.rs
+++ /dev/null
@@ -1,161 +0,0 @@
-#![allow(dead_code)]
-
-use std::env;
-use std::ffi::{OsStr, OsString};
-use std::fs::{self, File};
-use std::io;
-use std::io::prelude::*;
-use std::path::{Path, PathBuf};
-
-use cc;
-use tempfile::{Builder, 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();
- }
- let td = Builder::new().prefix("gcc-test").tempdir_in(&gcc).unwrap();
- gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX));
- Test {
- td: td,
- 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 {
- link_or_copy(
- &self.gcc,
- self.td
- .path()
- .join(&format!("{}{}", name, env::consts::EXE_SUFFIX)),
- )
- .unwrap();
- self
- }
-
- pub fn gcc(&self) -> cc::Build {
- let mut cfg = cc::Build::new();
- 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", self.path())
- .__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
- }
-
- fn path(&self) -> OsString {
- let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
- path.insert(0, self.td.path().to_owned());
- env::join_paths(path).unwrap()
- }
-
- 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
- }
-}
-
-/// Hard link an executable or copy it if that fails.
-///
-/// We first try to hard link an executable to save space. If that fails (as on Windows with
-/// different mount points, issue #60), we copy.
-#[cfg(not(target_os = "macos"))]
-fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
- let from = from.as_ref();
- let to = to.as_ref();
- fs::hard_link(from, to).or_else(|_| fs::copy(from, to).map(|_| ()))
-}
-
-/// Copy an executable.
-///
-/// On macOS, hard linking the executable leads to strange failures (issue #419), so we just copy.
-#[cfg(target_os = "macos")]
-fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
- fs::copy(from, to).map(|_| ())
-}
diff --git a/cc/tests/test.rs b/cc/tests/test.rs
deleted file mode 100644
index def11f0..0000000
--- a/cc/tests/test.rs
+++ /dev/null
@@ -1,377 +0,0 @@
-use crate::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_fp_auto() {
- let test = Test::gnu();
- test.gcc().debug(true).file("foo.c").compile("foo");
- test.cmd(0).must_have("-g");
- test.cmd(0).must_have("-fno-omit-frame-pointer");
-}
-
-#[test]
-fn gnu_debug_fp() {
- let test = Test::gnu();
- test.gcc().debug(true).file("foo.c").compile("foo");
- test.cmd(0).must_have("-g");
- test.cmd(0).must_have("-fno-omit-frame-pointer");
-}
-
-#[test]
-fn gnu_debug_nofp() {
- let test = Test::gnu();
- test.gcc()
- .debug(true)
- .force_frame_pointer(false)
- .file("foo.c")
- .compile("foo");
- test.cmd(0).must_have("-g");
- test.cmd(0).must_not_have("-fno-omit-frame-pointer");
-
- let test = Test::gnu();
- test.gcc()
- .force_frame_pointer(false)
- .debug(true)
- .file("foo.c")
- .compile("foo");
- test.cmd(0).must_have("-g");
- test.cmd(0).must_not_have("-fno-omit-frame-pointer");
-}
-
-#[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_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/cfg-if/.github/workflows/main.yml b/cfg-if/.github/workflows/main.yml
deleted file mode 100644
index 411ffe7..0000000
--- a/cfg-if/.github/workflows/main.yml
+++ /dev/null
@@ -1,53 +0,0 @@
-name: CI
-on: [push, pull_request]
-
-jobs:
- test:
- name: Test
- runs-on: ubuntu-latest
- strategy:
- matrix:
- rust: [stable, beta, nightly]
- steps:
- - uses: actions/checkout@master
- - name: Install Rust Stable
- run: |
- rustup self update
- rustup update ${{ matrix.rust }}
- rustup default ${{ matrix.rust }}
- rustc -vV
- - name: Run tests
- run: cargo test
-
- rustfmt:
- name: Rustfmt
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@master
- - name: Install Rust Stable
- run: |
- rustup update stable
- rustup default stable
- rustup component add rustfmt
- - name: Run rustfmt
- run: cargo fmt -- --check
-
- publish_docs:
- name: Publish Documentation
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@master
- - name: Install Rust Stable
- run: |
- rustup update stable
- rustup default stable
- - name: Build documentation
- run: cargo doc --no-deps
- - name: Publish documentation
- run: |
- cd target/doc
- git init
- git add .
- git -c user.name='ci' -c user.email='ci' commit -m init
- git push -f -q https://git:${{ secrets.github_token }}@github.com/${{ github.repository }} HEAD:gh-pages
- if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
diff --git a/cfg-if/.gitignore b/cfg-if/.gitignore
deleted file mode 100644
index a9d37c5..0000000
--- a/cfg-if/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-target
-Cargo.lock
diff --git a/cfg-if/Cargo.toml b/cfg-if/Cargo.toml
deleted file mode 100644
index 01bd1a7..0000000
--- a/cfg-if/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-[package]
-name = "cfg-if"
-version = "0.1.10"
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-license = "MIT/Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/alexcrichton/cfg-if"
-homepage = "https://github.com/alexcrichton/cfg-if"
-documentation = "https://docs.rs/cfg-if"
-description = """
-A macro to ergonomically define an item depending on a large number of #[cfg]
-parameters. Structured like an if-else chain, the first matching branch is the
-item that gets emitted.
-"""
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "alexcrichton/cfg-if" }
-
-[dependencies]
-core = { version = "1.0.0", optional = true, package = 'rustc-std-workspace-core' }
-compiler_builtins = { version = '0.1.2', optional = true }
-
-[features]
-rustc-dep-of-std = ['core', 'compiler_builtins']
diff --git a/cfg-if/LICENSE-APACHE b/cfg-if/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/cfg-if/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/cfg-if/LICENSE-MIT b/cfg-if/LICENSE-MIT
deleted file mode 100644
index 39e0ed6..0000000
--- a/cfg-if/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/cfg-if/README.md b/cfg-if/README.md
deleted file mode 100644
index 50b5e3b..0000000
--- a/cfg-if/README.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# cfg-if
-
-[Documentation](https://docs.rs/cfg-if)
-
-A macro to ergonomically define an item depending on a large number of #[cfg]
-parameters. Structured like an if-else chain, the first matching branch is the
-item that gets emitted.
-
-```toml
-[dependencies]
-cfg-if = "0.1"
-```
-
-## Example
-
-```rust
-cfg_if::cfg_if! {
- if #[cfg(unix)] {
- fn foo() { /* unix specific functionality */ }
- } else if #[cfg(target_pointer_width = "32")] {
- fn foo() { /* non-unix, 32-bit functionality */ }
- } else {
- fn foo() { /* fallback implementation */ }
- }
-}
-
-fn main() {
- foo();
-}
-```
-
-# 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 `cfg-if` 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/cfg-if/src/lib.rs b/cfg-if/src/lib.rs
deleted file mode 100644
index 6c5058d..0000000
--- a/cfg-if/src/lib.rs
+++ /dev/null
@@ -1,176 +0,0 @@
-//! A macro for defining `#[cfg]` if-else statements.
-//!
-//! The macro provided by this crate, `cfg_if`, 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.
-//!
-//! # Example
-//!
-//! ```
-//! cfg_if::cfg_if! {
-//! if #[cfg(unix)] {
-//! fn foo() { /* unix specific functionality */ }
-//! } else if #[cfg(target_pointer_width = "32")] {
-//! fn foo() { /* non-unix, 32-bit functionality */ }
-//! } else {
-//! fn foo() { /* fallback implementation */ }
-//! }
-//! }
-//!
-//! # fn main() {}
-//! ```
-
-#![no_std]
-#![doc(html_root_url = "https://docs.rs/cfg-if")]
-#![deny(missing_docs)]
-#![cfg_attr(test, deny(warnings))]
-
-/// The main macro provided by this crate. See crate documentation for more
-/// information.
-#[macro_export]
-macro_rules! cfg_if {
- // match if/else chains with a final `else`
- ($(
- if #[cfg($($meta:meta),*)] { $($tokens:tt)* }
- ) else * else {
- $($tokens2:tt)*
- }) => {
- $crate::cfg_if! {
- @__items
- () ;
- $( ( ($($meta),*) ($($tokens)*) ), )*
- ( () ($($tokens2)*) ),
- }
- };
-
- // match if/else chains lacking a final `else`
- (
- if #[cfg($($i_met:meta),*)] { $($i_tokens:tt)* }
- $(
- else if #[cfg($($e_met:meta),*)] { $($e_tokens:tt)* }
- )*
- ) => {
- $crate::cfg_if! {
- @__items
- () ;
- ( ($($i_met),*) ($($i_tokens)*) ),
- $( ( ($($e_met),*) ($($e_tokens)*) ), )*
- ( () () ),
- }
- };
-
- // 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),*) ($($tokens:tt)*) ), $($rest:tt)*) => {
- // Emit all items within one block, applying an appropriate #[cfg]. The
- // #[cfg] will require all `$m` matchers specified and must also negate
- // all previous matchers.
- #[cfg(all($($m,)* not(any($($not),*))))] $crate::cfg_if! { @__identity $($tokens)* }
-
- // 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.
- $crate::cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* }
- };
-
- // Internal macro to make __apply work out right for different match types,
- // because of how macros matching/expand stuff.
- (@__identity $($tokens:tt)*) => {
- $($tokens)*
- };
-}
-
-#[cfg(test)]
-mod tests {
- cfg_if! {
- if #[cfg(test)] {
- use core::option::Option as Option2;
- fn works1() -> Option2<u32> { Some(1) }
- } else {
- fn works1() -> Option<u32> { None }
- }
- }
-
- cfg_if! {
- if #[cfg(foo)] {
- fn works2() -> bool { false }
- } else if #[cfg(test)] {
- fn works2() -> bool { true }
- } else {
- fn works2() -> bool { false }
- }
- }
-
- cfg_if! {
- if #[cfg(foo)] {
- fn works3() -> bool { false }
- } else {
- fn works3() -> bool { true }
- }
- }
-
- cfg_if! {
- if #[cfg(test)] {
- use core::option::Option as Option3;
- fn works4() -> Option3<u32> { Some(1) }
- }
- }
-
- cfg_if! {
- if #[cfg(foo)] {
- fn works5() -> bool { false }
- } else if #[cfg(test)] {
- fn works5() -> bool { true }
- }
- }
-
- #[test]
- fn it_works() {
- assert!(works1().is_some());
- assert!(works2());
- assert!(works3());
- assert!(works4().is_some());
- assert!(works5());
- }
-
- #[test]
- #[allow(clippy::assertions_on_constants)]
- fn test_usage_within_a_function() {
- cfg_if! {if #[cfg(debug_assertions)] {
- // we want to put more than one thing here to make sure that they
- // all get configured properly.
- assert!(cfg!(debug_assertions));
- assert_eq!(4, 2+2);
- } else {
- assert!(works1().is_some());
- assert_eq!(10, 5+5);
- }}
- }
-
- trait Trait {
- fn blah(&self);
- }
-
- #[allow(dead_code)]
- struct Struct;
-
- impl Trait for Struct {
- cfg_if! {
- if #[cfg(feature = "blah")] {
- fn blah(&self) {
- unimplemented!();
- }
- } else {
- fn blah(&self) {
- unimplemented!();
- }
- }
- }
- }
-}
diff --git a/cfg-if/tests/xcrate.rs b/cfg-if/tests/xcrate.rs
deleted file mode 100644
index e7b4a36..0000000
--- a/cfg-if/tests/xcrate.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-cfg_if::cfg_if! {
- if #[cfg(foo)] {
- fn works() -> bool { false }
- } else if #[cfg(test)] {
- fn works() -> bool { true }
- } else {
- fn works() -> bool { false }
- }
-}
-
-#[test]
-fn smoke() {
- assert!(works());
-}
diff --git a/nitrocli/ci/gitlab-ci.yml b/ci/gitlab-ci.yml
index 29bf59d..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/29bf41a2cc4fb8d3f588cf51eb6a8ba883808c4b/1.35.0/stretch/Dockerfile
-image: "rust:1.35.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/clap/.appveyor.yml b/clap/.appveyor.yml
deleted file mode 100644
index 247a550..0000000
--- a/clap/.appveyor.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-environment:
- matrix:
- - TARGET: x86_64-pc-windows-msvc
- - TARGET: i686-pc-windows-msvc
- - TARGET: x86_64-pc-windows-gnu
- - TARGET: i686-pc-windows-gnu
- RUST_BACKTRACE: full
-install:
- - curl -sSf -o rustup-init.exe https://win.rustup.rs/
- - rustup-init.exe -y --default-host %TARGET%
- - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- - rustc -vV
- - cargo -vV
-build: false
-test_script:
- - cargo build --verbose --features yaml
- - cargo test --verbose --features yaml
diff --git a/clap/.clog.toml b/clap/.clog.toml
deleted file mode 100644
index 301dd92..0000000
--- a/clap/.clog.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[clog]
-repository = "https://github.com/kbknapp/clap-rs"
-outfile = "CHANGELOG.md"
-from-latest-tag = true
-
-[sections]
-Performance = ["perf"]
-Improvements = ["impr", "im", "imp"]
-Documentation = ["docs"]
-Deprecations = ["depr"]
-Examples = ["examples"]
-"New Settings" = ["setting", "settings"]
-"API Additions" = ["add", "api"]
-"New Sponsor" = ["sponsor"]
diff --git a/clap/.github/CONTRIBUTING.md b/clap/.github/CONTRIBUTING.md
deleted file mode 100644
index 2c6f752..0000000
--- a/clap/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# How to Contribute
-
-Contributions are always welcome! And there is a multitude of ways in which you can help depending on what you like to do, or are good at. Anything from documentation, code cleanup, issue completion, new features, you name it, even filing issues is contributing and greatly appreciated!
-
-Another really great way to help is if you find an interesting, or helpful way in which to use `clap`. You can either add it to the [examples/](examples) directory, or file an issue and tell me. I'm all about giving credit where credit is due :)
-
-### Testing Code
-
-To test with all features both enabled and disabled, you can run these commands:
-
-```sh
-$ cargo test --no-default-features
-$ cargo test --features "yaml unstable"
-```
-
-Alternatively, if you have [`just`](https://github.com/casey/just) installed you can run the prebuilt recipes. *Not* using `just` is perfectly fine as well, it simply bundles commands automatically.
-
-For example, to test the code, as above simply run:
-
-```sh
-$ just run-tests
-```
-
-From here on, I will list the appropriate `cargo` command as well as the `just` command.
-
-Sometimes it's helpful to only run a subset of the tests, which can be done via:
-
-```sh
-$ cargo test --test <test_name>
-
-# Or
-
-$ just run-test <test_name>
-```
-
-### Linting Code
-
-During the CI process `clap` runs against many different lints using [`clippy`](https://github.com/rust-lang-nursery/rust-clippy). In order to check if these lints pass on your own computer prior to submitting a PR you'll need a nightly compiler.
-
-In order to check the code for lints run either:
-
-```sh
-$ rustup override add nightly
-$ cargo build --features lints
-$ rustup override remove
-
-# Or
-
-$ just lint
-```
-
-### Debugging Code
-
-Another helpful technique is to see the `clap` debug output while developing features. In order to see the debug output while running the full test suite or individual tests, run:
-
-```sh
-$ cargo test --features debug
-
-# Or for individual tests
-$ cargo test --test <test_name> --features debug
-
-# The corresponding just command for individual debugging tests is:
-$ just debug <test_name>
-```
-
-### Commit Messages
-
-I use a [conventional](https://github.com/ajoslin/conventional-changelog/blob/a5505865ff3dd710cf757f50530e73ef0ca641da/conventions/angular.md) changelog format so I can update my changelog automatically using [clog](https://github.com/clog-tool/clog-cli)
-
- * Please format your commit subject line using the following format: `TYPE(COMPONENT): MESSAGE` where `TYPE` is one of the following:
- - `api` - An addition to the API
- - `setting` - A new `AppSettings` variant
- - `feat` - A new feature of an existing API
- - `imp` - An improvement to an existing feature/API
- - `perf` - A performance improvement
- - `docs` - Changes to documentation only
- - `tests` - Changes to the testing framework or tests only
- - `fix` - A bug fix
- - `refactor` - Code functionality doesn't change, but underlying structure may
- - `style` - Stylistic changes only, no functionality changes
- - `wip` - A work in progress commit (Should typically be `git rebase`'ed away)
- - `chore` - Catch all or things that have to do with the build system, etc
- - `examples` - Changes to existing example, or a new example
- * The `COMPONENT` is optional, and may be a single file, directory, or logical component. Parenthesis can be omitted if you are opting not to use the `COMPONENT`.
-
-### Tests and Documentation
-
-1. Create tests for your changes
-2. **Ensure the tests are passing.** Run the tests (`cargo test --features "yaml unstable"`), alternatively `just run-tests` if you have `just` installed.
-3. **Optional** Run the lints (`cargo build --features lints`) (requires a nightly compiler), alternatively `just lint`
-4. Ensure your changes contain documentation if adding new APIs or features.
-
-### Preparing the PR
-
-1. `git rebase` into concise commits and remove `--fixup`s or `wip` commits (`git rebase -i HEAD~NUM` where `NUM` is number of commits back to start the rebase)
-2. Push your changes back to your fork (`git push origin $your-branch`)
-3. Create a pull request against `master`! (You can also create the pull request first, and we'll merge when ready. This a good way to discuss proposed changes.)
-
-### Other ways to contribute
-
-Another really great way to help is if you find an interesting, or helpful way in which to use `clap`. You can either add it to the [examples/](../examples) directory, or file an issue and tell me. I'm all about giving credit where credit is due :)
-
-### Goals
-
-There are a few goals of `clap` that I'd like to maintain throughout contributions. If your proposed changes break, or go against any of these goals we'll discuss the changes further before merging (but will *not* be ignored, all contributes are welcome!). These are by no means hard-and-fast rules, as I'm no expert and break them myself from time to time (even if by mistake or ignorance :P).
-
-* Remain backwards compatible when possible
- - If backwards compatibility *must* be broken, use deprecation warnings if at all possible before removing legacy code
- - This does not apply for security concerns
-* Parse arguments quickly
- - Parsing of arguments shouldn't slow down usage of the main program
- - This is also true of generating help and usage information (although *slightly* less stringent, as the program is about to exit)
-* Try to be cognizant of memory usage
- - Once parsing is complete, the memory footprint of `clap` should be low since the main program is the star of the show
-* `panic!` on *developer* error, exit gracefully on *end-user* error
diff --git a/clap/.github/ISSUE_TEMPLATE.md b/clap/.github/ISSUE_TEMPLATE.md
deleted file mode 100644
index 5f94a2c..0000000
--- a/clap/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,46 +0,0 @@
-<!--
-Please use the following template to assist with creating an issue and to ensure a speedy resolution. If an area is not applicable, feel free to delete the area or mark with `N/A`
--->
-
-### Rust Version
-
-* Use the output of `rustc -V`
-
-### Affected Version of clap
-
-* Can be found in Cargo.lock of your project (i.e. `grep clap Cargo.lock`)
-
-### Bug or Feature Request Summary
-
-
-### Expected Behavior Summary
-
-
-### Actual Behavior Summary
-
-
-### Steps to Reproduce the issue
-
-
-### Sample Code or Link to Sample Code
-
-
-### Debug output
-
-Compile clap with cargo features `"debug"` such as:
-
-```toml
-[dependencies]
-clap = { version = "2", features = ["debug"] }
-```
-
-<details>
-<summary> Debug Output </summary>
-<pre>
-<code>
-
-Paste Debug Output Here
-
-</code>
-</pre>
-</details>
diff --git a/clap/.gitignore b/clap/.gitignore
deleted file mode 100644
index 34253e9..0000000
--- a/clap/.gitignore
+++ /dev/null
@@ -1,27 +0,0 @@
-# Compiled files
-*.o
-*.so
-*.rlib
-*.dll
-
-# Executables
-*.exe
-
-# Generated by Cargo
-/target/
-/clap-test/target/
-
-# Cargo files
-Cargo.lock
-
-# Temp files
-.*~
-
-# Backup files
-*.bak
-*.bk
-*.orig
-
-# Project files
-.vscode/*
-.idea/*
diff --git a/clap/.mention-bot b/clap/.mention-bot
deleted file mode 100644
index f339f59..0000000
--- a/clap/.mention-bot
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "findPotentialReviewers": false,
- "alwaysNotifyForPaths": [
- {
- "name": "kbknapp",
- "files": ["**/*.rs", "**/*.md", "*"]
- }
- ]
-}
diff --git a/clap/.travis.yml b/clap/.travis.yml
deleted file mode 100644
index 9eb4044..0000000
--- a/clap/.travis.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-sudo: true
-language: rust
-cache: cargo
-rust:
- - nightly
- - beta
- - stable
- - 1.31.0
-matrix:
- allow_failures:
- - rust: nightly
-before_script:
- - |
- pip install git+git://github.com/kbknapp/travis-cargo.git --user &&
- export PATH=$HOME/.local/bin:$PATH
- - |
- if [[ "$TRAVIS_RUST_VERSION" == "1.13.0" ]]; then
- echo "Old Rust detected, removing version-sync dependency"
- sed -i "/^version-sync =/d" Cargo.toml
- rm "tests/version-numbers.rs"
- fi
-script:
- - |
- travis-cargo --only stable test -- --verbose --no-default-features &&
- travis-cargo --skip nightly test -- --verbose --features "yaml unstable" &&
- travis-cargo --only nightly test -- --verbose --features "yaml unstable nightly" &&
- travis-cargo --only nightly bench -- --no-run
-addons:
- apt:
- packages:
- - binutils-dev
- - libcurl4-openssl-dev
- - libelf-dev
- - libdw-dev
- - libiberty-dev
- - cmake
- - gcc
- - zlib1g-dev
-after_success:
- - |
- wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
- tar xzf master.tar.gz &&
- cd kcov-master &&
- mkdir build &&
- cd build &&
- cmake .. &&
- make &&
- sudo make install &&
- cd ../.. &&
- rm -rf kcov-master &&
- cargo clean &&
- cargo test --no-run --features "yaml unstable" &&
- for file in target/debug/*-*; do mkdir -p "target/cov/$(basename $file)"; kcov --exclude-pattern=/.cargo --verify "target/cov/$(basename $file)" "$file"; done &&
- kcov --coveralls-id=$TRAVIS_JOB_ID --merge target/cov target/cov/* &&
- echo "Uploaded code coverage"
-env:
- global:
- - TRAVIS_CARGO_NIGHTLY_FEATURE=lints
- - secure: JLBlgHY6OEmhJ8woewNJHmuBokTNUv7/WvLkJGV8xk0t6bXBwSU0jNloXwlH7FiQTc4TccX0PumPDD4MrMgxIAVFPmmmlQOCmdpYP4tqZJ8xo189E5zk8lKF5OyaVYCs5SMmFC3cxCsKjfwGIexNu3ck5Uhwe9jI0tqgkgM3URA=
diff --git a/clap/CHANGELOG.md b/clap/CHANGELOG.md
deleted file mode 100644
index d1fdd40..0000000
--- a/clap/CHANGELOG.md
+++ /dev/null
@@ -1,2855 +0,0 @@
-<a name="v2.33.0"></a>
-## v2.33.0 (2019-04-06)
-
-#### New Sponsor
-
-* Stephen Oats is now a sponsor \o/ ([823457c0](https://github.com/kbknapp/clap-rs/commit/823457c0ef5e994ed7080cf62addbfe1aa3b1833))
-* **SPONSORS.md:** fixes Josh Triplett's info in the sponsor document ([24cb5740](https://github.com/kbknapp/clap-rs/commit/24cb574090a11159b48bba105d5ec2dfb0a20e4e))
-
-#### Features
-
-* **Completions:** adds completion support for Elvish. ([e9d0562a](https://github.com/kbknapp/clap-rs/commit/e9d0562a1dc5dfe731ed7c767e6cee0af08f0cf9))
-* There is a new setting to disable automatic building of `--help` and `-h` flags (`AppSettings::DisableAutoHelp`)
-
-#### Improvements
-
-* **arg_matches.rs:** add Debug implementations ([47192b7a](https://github.com/kbknapp/clap-rs/commit/47192b7a2d84ec716b81ae4af621e008a8762dc9))
-* **macros:** Support shorthand syntax for ArgGroups ([df9095e7](https://github.com/kbknapp/clap-rs/commit/df9095e75bb1e7896415251d0d4ffd8a0ebcd559))
-
-#### Documentation
-
-* Refer to macOS rather than OSX. ([ab0d767f](https://github.com/kbknapp/clap-rs/commit/ab0d767f3a5a57e2bbb97d0183c2ef63c8c77a6c))
-* **README.md:** use https for all links ([96a7639a](https://github.com/kbknapp/clap-rs/commit/96a7639a36bcb184c3f45348986883115ef1ab3a))
-
-#### Bug Fixes
-
-* add debug assertion for missing args in subcommand ArgGroup ([2699d9e5](https://github.com/kbknapp/clap-rs/commit/2699d9e51e7eadc258ba64c4e347c5d1fef61343))
-* Restore compat with Rust 1.21 ([6b263de1](https://github.com/kbknapp/clap-rs/commit/6b263de1d42ede692ec5ee55019ad2fc6386f92e))
-* Dont mention unused subcommands ([ef92e2b6](https://github.com/kbknapp/clap-rs/commit/ef92e2b639ed305bdade4741f60fa85cb0101c5a))
-* **OsValues:** Add `ExactSizeIterator` implementation ([356c69e5](https://github.com/kbknapp/clap-rs/commit/356c69e508fd25a9f0ea2d27bf80ae1d9a8d88f4))
-* **arg_enum!:**
- * Fix comma position for valid values. ([1f1f9ff3](https://github.com/kbknapp/clap-rs/commit/1f1f9ff3fa38a43231ef8be9cfea89a32e53f518))
- * Invalid expansions of some trailing-comma patterns ([7023184f](https://github.com/kbknapp/clap-rs/commit/7023184fca04e852c270341548d6a16207d13862))
-* **completions:** improve correctness of completions when whitespace is involved ([5a08ff29](https://github.com/kbknapp/clap-rs/commit/5a08ff295b2aa6ce29420df6252a0e3ff4441bdc))
-* **help message:** Unconditionally uses long description for subcommands ([6acc8b6a](https://github.com/kbknapp/clap-rs/commit/6acc8b6a621a765cbf513450188000d943676a30), closes [#897](https://github.com/kbknapp/clap-rs/issues/897))
-* **macros:** fixes broken pattern which prevented calling multi-argument Arg methods ([9e7a352e](https://github.com/kbknapp/clap-rs/commit/9e7a352e13aaf8025d80f2bac5c47fb32528672b))
-* **parser:** Better interaction between AllowExternalSubcommands and SubcommandRequired ([9601c95a](https://github.com/kbknapp/clap-rs/commit/9601c95a03d2b82bf265c328b4769238f1b79002))
-
-#### Minimum Required Rust
-
-* As of this release, `clap` requires `rustc 1.31.0` or greater.
-
-<a name="v2.32.0"></a>
-## v2.32.0 (2018-06-26)
-
-#### Minimum Required Rust
-
-* As of this release, `clap` requires `rustc 1.21.0` or greater.
-
-
-#### Features
-
-* **Completions:** adds completion support for Elvish. ([e9d0562a](https://github.com/kbknapp/clap-rs/commit/e9d0562a1dc5dfe731ed7c767e6cee0af08f0cf9))
-
-#### Improvements
-
-* **macros:** Support shorthand syntax for ArgGroups ([df9095e7](https://github.com/kbknapp/clap-rs/commit/df9095e75bb1e7896415251d0d4ffd8a0ebcd559))
-
-#### Bug Fixes
-
-* **OsValues:** Add `ExactSizeIterator` implementation ([356c69e5](https://github.com/kbknapp/clap-rs/commit/356c69e508fd25a9f0ea2d27bf80ae1d9a8d88f4))
-* **arg_enum!:** Invalid expansions of some trailing-comma patterns ([7023184f](https://github.com/kbknapp/clap-rs/commit/7023184fca04e852c270341548d6a16207d13862))
-* **help message:** Unconditionally uses long description for subcommands ([6acc8b6a](https://github.com/kbknapp/clap-rs/commit/6acc8b6a621a765cbf513450188000d943676a30), closes [#897](https://github.com/kbknapp/clap-rs/issues/897))
-
-#### Documentation
-
-* Refer to macOS rather than OSX. ([ab0d767f](https://github.com/kbknapp/clap-rs/commit/ab0d767f3a5a57e2bbb97d0183c2ef63c8c77a6c))
-
-
-
-<a name="v2.31.2"></a>
-### v2.31.2 (2018-03-19)
-
-#### Bug Fixes
-
-* **Fish Completions:** fixes a bug that only allowed a single completion in in Fish Shell ([e8774a8](https://github.com/kbknapp/clap-rs/pull/1214/commits/e8774a84ee4a319c888036e7c595ab46451d8e48), closes [#1212](https://github.com/kbknapp/clap-rs/issues/1212))
-* **AllowExternalSubcommands**: fixes a bug where external subcommands would be blocked by a similarly named subcommand (suggestions were getting in the way). ([a410e85](https://github.com/kbknapp/clap-rs/pull/1215/commits/a410e855bcd82b05f9efa73fa8b9774dc8842c6b))
-
-#### Documentation
-
-* Fixes some typos in the `README.md` ([c8e685d7](https://github.com/kbknapp/clap-rs/commit/c8e685d76adee2a3cc06cac6952ffcf6f9548089))
-
-<a name="v2.31.1"></a>
-### v2.31.1 (2018-03-06)
-
-
-#### Improvements
-
-* **AllowMissingPositional:** improves the ability of AllowMissingPositional to allow 'skipping' to the last positional arg with '--' ([df20e6e2](https://github.com/kbknapp/clap-rs/commit/df20e6e24b4e782be0b423b484b9798e3e2efe2f))
-
-
-<a name="v2.31.0"></a>
-## v2.31.0 (2018-03-04)
-
-
-#### Features
-
-* **Arg Indices:** adds the ability to query argument value indices ([f58d0576](https://github.com/kbknapp/clap-rs/commit/f58d05767ec8133c8eb2de117cb642b9ae29ccbc))
-* **Indices:** implements an Indices<Item=&usize> iterator ([1e67be44](https://github.com/kbknapp/clap-rs/commit/1e67be44f0ccf161cc84c4e6082382072e89c302))
-* **Raw Args** adds a convenience function to `Arg` that allows implying all of `Arg::last` `Arg::allow_hyphen_values` and `Arg::multiple(true)` ([66a78f29](https://github.com/kbknapp/clap-rs/commit/66a78f2972786f5fe7c07937a1ac23da2542afd2))
-
-#### Documentation
-
-* Fix some typos and markdown issues. ([935ba0dd](https://github.com/kbknapp/clap-rs/commit/935ba0dd547a69c3f636c5486795012019408794))
-* **Arg Indices:** adds the documentation for the arg index querying methods ([50bc0047](https://github.com/kbknapp/clap-rs/commit/50bc00477afa64dc6cdc5de161d3de3ba1d105a7))
-* **CONTRIBUTING.md:** fix url to clippy upstream repo to point to https://github.com/rust-lang-nursery/rust-clippy instead of https://github.com/Manishearth/rust-clippy ([42407d7f](https://github.com/kbknapp/clap-rs/commit/42407d7f21d794103cda61f49d2615aae0a4bcd9))
-* **Values:** improves the docs example of the Values iterator ([74075d65](https://github.com/kbknapp/clap-rs/commit/74075d65e8db1ddb5e2a4558009a5729d749d1b6))
-* Updates readme to hint that the `wrap_help` feature is a thing ([fc7ab227](https://github.com/kbknapp/clap-rs/commit/66a78f2972786f5fe7c07937a1ac23da2542afd2))
-
-### Improvements
-
-* Cargo.toml: use codegen-units = 1 in release and bench profiles ([19f425ea](https://github.com/kbknapp/clap-rs/commit/66a78f2972786f5fe7c07937a1ac23da2542afd2))
-* Adds WASM support (clap now compiles on WASM!) ([689949e5](https://github.com/kbknapp/clap-rs/commit/689949e57d390bb61bc69f3ed91f60a2105738d0))
-* Uses the short help tool-tip for PowerShell completion scripts ([ecda22ce](https://github.com/kbknapp/clap-rs/commit/ecda22ce7210ce56d7b2d1a5445dd1b8a2959656))
-
-
-<a name="v2.30.0"></a>
-## v2.30.0 (2018-02-13)
-
-#### Bug Fixes
-
-* **YAML:** Adds a missing conversion from `Arg::last` when instantiating from a YAML file ([aab77c81a5](https://github.com/kbknapp/clap-rs/pull/1175/commits/aab77c81a519b045f95946ae0dd3e850f9b93070), closes [#1160](https://github.com/kbknapp/clap-rs/issues/1173))
-
-#### Improvements
-
-* **Bash Completions:** instead of completing a generic option name, all bash completions fall back to file completions UNLESS `Arg::possible_values` was used ([872f02ae](https://github.com/kbknapp/clap-rs/commit/872f02aea900ffa376850a279eb164645e1234fa))
-* **Deps:** No longer needlessly compiles `ansi_term` on Windows since its not used ([b57ee946](https://github.com/kbknapp/clap-rs/commit/b57ee94609da3ddc897286cfba968f26ff961491), closes [#1155](https://github.com/kbknapp/clap-rs/issues/1155))
-* **Help Message:** changes the `[values: foo bar baz]` array to `[possible values: foo bar baz]` for consistency with the API ([414707e4e97](https://github.com/kbknapp/clap-rs/pull/1176/commits/414707e4e979d07bfe555247e5d130c546673708), closes [#1160](https://github.com/kbknapp/clap-rs/issues/1160))
-
-
-<a name="v2.29.4"></a>
-### v2.29.4 (2018-02-06)
-
-
-#### Bug Fixes
-
-* **Overrides Self:** fixes a bug where options with multiple values couldnt ever have multiple values ([d95907cf](https://github.com/kbknapp/clap-rs/commit/d95907cff6d011a901fe35fa00b0f4e18547a1fb))
-
-
-
-<a name="v2.29.3"></a>
-### v2.29.3 (2018-02-05)
-
-
-#### Improvements
-
-* **Overrides:** clap now supports arguments which override with themselves ([6c7a0010](https://github.com/kbknapp/clap-rs/commit/6c7a001023ca1eac1cc6ffe6c936b4c4a2aa3c45), closes [#976](https://github.com/kbknapp/clap-rs/issues/976))
-
-#### Bug Fixes
-
-* **Requirements:** fixes an issue where conflicting args would still show up as required ([e06cefac](https://github.com/kbknapp/clap-rs/commit/e06cefac97083838c0a4e1444dcad02a5c3f911e), closes [#1158](https://github.com/kbknapp/clap-rs/issues/1158))
-* Fixes a bug which disallows proper nesting of `--` ([73993fe](https://github.com/kbknapp/clap-rs/commit/73993fe30d135f682e763ec93dcb0814ed518011), closes [#1161](https://github.com/kbknapp/clap-rs/issues/1161))
-
-#### New Settings
-
-* **AllArgsOverrideSelf:** adds a new convenience setting to allow all args to override themselves ([4670325d](https://github.com/kbknapp/clap-rs/commit/4670325d1bf0369addec2ae2bcb56f1be054c924))
-
-
-
-<a name="v2.29.2"></a>
-### v2.29.2 (2018-01-16)
-
-
-#### Features
-
-* **completions/zsh.rs:**
- * Escape possible values for options ([25561dec](https://github.com/kbknapp/clap-rs/commit/25561decf147d329b64634a14d9695673c2fc78f))
- * Implement postional argument possible values completion ([f3b0afd2](https://github.com/kbknapp/clap-rs/commit/f3b0afd2bef8b7be97162f8a7802ddf7603dff36))
- * Complete positional arguments properly ([e39aeab8](https://github.com/kbknapp/clap-rs/commit/e39aeab8487596046fbdbc6a226e5c8820585245))
-
-#### Bug Fixes
-
-* **completions/zsh.rs:**
- * Add missing autoload for is-at-least ([a6522607](https://github.com/kbknapp/clap-rs/commit/a652260795d1519f6ec2a7a09ccc1258499cad7b))
- * Don't pass -S to _arguments if Zsh is too old ([16b4f143](https://github.com/kbknapp/clap-rs/commit/16b4f143ff466b7ef18a267bc44ade0f9639109b))
- * Maybe fix completions with mixed positionals and subcommands ([1146f0da](https://github.com/kbknapp/clap-rs/commit/1146f0da154d6796fbfcb09db8efa3593cb0d898))
-* **completions/zsh.zsh:** Remove redundant code from output ([0e185b92](https://github.com/kbknapp/clap-rs/commit/0e185b922ed1e0fd653de00b4cd8d567d72ff68e), closes [#1142](https://github.com/kbknapp/clap-rs/issues/1142))
-
-
-
-<a name="2.29.1"></a>
-### 2.29.1 (2018-01-09)
-
-
-#### Documentation
-
-* fixes broken links. ([56e734b8](https://github.com/kbknapp/clap-rs/commit/56e734b839303d733d2e5baf7dac39bd7b97b8e4))
-* updates contributors list ([e1313a5a](https://github.com/kbknapp/clap-rs/commit/e1313a5a0f69d8f4016f73b860a63af8318a6676))
-
-#### Performance
-
-* further debloating by removing generics from error cases ([eb8d919e](https://github.com/kbknapp/clap-rs/commit/eb8d919e6f3443db279ba0c902f15d76676c02dc))
-* debloats clap by deduplicating logic and refactors ([03e413d7](https://github.com/kbknapp/clap-rs/commit/03e413d7175d35827cd7d8908d47dbae15a849a3))
-
-#### Bug Fixes
-
-* fixes the ripgrep benchmark by adding a value to a flag that expects it ([d26ab2b9](https://github.com/kbknapp/clap-rs/commit/d26ab2b97cf9c0ea675b440b7b0eaf6ac3ad01f4))
-* **bash completion:** Change the bash completion script code generation to support hyphens. ([ba7f1d18](https://github.com/kbknapp/clap-rs/commit/ba7f1d18eba7a07ce7f57e0981986f66c994b639))
-* **completions/zsh.rs:** Fix completion of long option values ([46365cf8](https://github.com/kbknapp/clap-rs/commit/46365cf8be5331ba04c895eb183e2f230b5aad51))
-
-
-<a name="2.29.0"></a>
-## 2.29.0 (2017-12-02)
-
-
-#### API Additions
-
-* **Arg:** adds Arg::hide_env_values(bool) which allows one to hide any current env values and display only the key in help messages ([fb41d062](https://github.com/kbknapp/clap-rs/commit/fb41d062eedf37cb4f805c90adca29909bd197d7))
-
-
-
-<a name="2.28.0"></a>
-## 2.28.0 (2017-11-28)
-
-The minimum required Rust is now 1.20. This was done to start using bitflags 1.0 and having >1.0 deps is a *very good* thing!
-
-#### Documentation
-
-* changes the demo version to 2.28 to stay in sync ([ce6ca492](https://github.com/kbknapp/clap-rs/commit/ce6ca492c7510ab6474075806360b96081b021a9))
-* Fix URL path to github hosted files ([ce72aada](https://github.com/kbknapp/clap-rs/commit/ce72aada56a9581d4a6cb4bf9bdb861c3906f8df), closes [#1106](https://github.com/kbknapp/clap-rs/issues/1106))
-* fix typo ([002b07fc](https://github.com/kbknapp/clap-rs/commit/002b07fc98a1c85acb66296b1eec0b2aba906125))
-* **README.md:** updates the readme and pulls out some redundant sections ([db6caf86](https://github.com/kbknapp/clap-rs/commit/db6caf8663747e679d2f4ed3bd127f33476754aa))
-
-#### Improvements
-
-* adds '[SUBCOMMAND]' to usage strings with only AppSettings::AllowExternalSubcommands is used with no other subcommands ([e78bb757](https://github.com/kbknapp/clap-rs/commit/e78bb757a3df16e82d539e450c06767a6bfcf859), closes [#1093](https://github.com/kbknapp/clap-rs/issues/1093))
-
-#### API Additions
-
-* Adds Arg::case_insensitive(bool) which allows matching Arg::possible_values without worrying about ASCII case ([1fec268e](https://github.com/kbknapp/clap-rs/commit/1fec268e51736602e38e67c76266f439e2e0ef12), closes [#1118](https://github.com/kbknapp/clap-rs/issues/1118))
-* Adds the traits to be used with the clap-derive crate to be able to use Custom Derive ([6f4c3412](https://github.com/kbknapp/clap-rs/commit/6f4c3412415e882f5ca2cc3fbd6d4dce79440828))
-
-#### Bug Fixes
-
-* Fixes a regression where --help couldn't be overridden ([a283d69f](https://github.com/kbknapp/clap-rs/commit/a283d69fc08aa016ae1bf9ba010012abecc7ba69), closes [#1112](https://github.com/kbknapp/clap-rs/issues/1112))
-* fixes a bug that allowed options to pass parsing when no value was provided ([2fb75821](https://github.com/kbknapp/clap-rs/commit/2fb758219c7a60d639da67692e100b855a8165ac), closes [#1105](https://github.com/kbknapp/clap-rs/issues/1105))
-* ignore PropagateGlobalValuesDown deprecation warning ([f61ce3f5](https://github.com/kbknapp/clap-rs/commit/f61ce3f55fe65e16b3db0bd4facdc4575de22767), closes [#1086](https://github.com/kbknapp/clap-rs/issues/1086))
-
-#### Deps
-
-* Updates `bitflags` to 1.0
-
-
-
-<a name="v2.27.1"></a>
-## v2.27.1 (2017-10-24)
-
-
-#### Bug Fixes
-
-* Adds `term_size` as an optional dependency (with feature `wrap_help`) to fix compile bug
-
-<a name="v2.27.0"></a>
-## v2.27.0 (2017-10-24)
-
-** This release raises the minimum required version of Rust to 1.18 **
-
-** This release also contains a very minor breaking change to fix a bug **
-
-The only CLIs affected will be those using unrestrained multiple values and subcommands where the
-subcommand name can coincide with one of the multiple values.
-
-See the commit [0c223f54](https://github.com/kbknapp/clap-rs/commit/0c223f54ed46da406bc8b43a5806e0b227863b31) for full details.
-
-
-#### Bug Fixes
-
-* Values from global args are now propagated UP and DOWN!
-* fixes a bug where using AppSettings::AllowHyphenValues would allow invalid arguments even when there is no way for them to be valid ([77ed4684](https://github.com/kbknapp/clap-rs/commit/77ed46841fc0263d7aa32fcc5cc49ef703b37c04), closes [#1066](https://github.com/kbknapp/clap-rs/issues/1066))
-* when an argument requires a value and that value happens to match a subcommand name, its parsed as a value ([0c223f54](https://github.com/kbknapp/clap-rs/commit/0c223f54ed46da406bc8b43a5806e0b227863b31), closes [#1031](https://github.com/kbknapp/clap-rs/issues/1031), breaks [#](https://github.com/kbknapp/clap-rs/issues/), [#](https://github.com/kbknapp/clap-rs/issues/))
-* fixes a bug that prevented number_of_values and default_values to be used together ([5eb342a9](https://github.com/kbknapp/clap-rs/commit/5eb342a99dde07b0f011048efde3e283bc1110fc), closes [#1050](https://github.com/kbknapp/clap-rs/issues/1050), [#1056](https://github.com/kbknapp/clap-rs/issues/1056))
-* fixes a bug that didn't allow args with default values to have conflicts ([58b5b4be](https://github.com/kbknapp/clap-rs/commit/58b5b4be315280888d50d9b15119b91a9028f050), closes [#1071](https://github.com/kbknapp/clap-rs/issues/1071))
-* fixes a panic when using global args and calling App::get_matches_from_safe_borrow multiple times ([d86ec797](https://github.com/kbknapp/clap-rs/commit/d86ec79742c77eb3f663fb30e225954515cf25bb), closes [#1076](https://github.com/kbknapp/clap-rs/issues/1076))
-* fixes issues and potential regressions with global args values not being propagated properly or at all ([a43f9dd4](https://github.com/kbknapp/clap-rs/commit/a43f9dd4aaf1864dd14a3c28dec89ccdd70c61e5), closes [#1010](https://github.com/kbknapp/clap-rs/issues/1010), [#1061](https://github.com/kbknapp/clap-rs/issues/1061), [#978](https://github.com/kbknapp/clap-rs/issues/978))
-* fixes a bug where default values are not applied if the option supports zero values ([9c248cbf](https://github.com/kbknapp/clap-rs/commit/9c248cbf7d8a825119bc387c23e9a1d1989682b0), closes [#1047](https://github.com/kbknapp/clap-rs/issues/1047))
-
-#### Documentation
-
-* adds addtional blurbs about using multiples with subcommands ([03455b77](https://github.com/kbknapp/clap-rs/commit/03455b7751a757e7b2f6ffaf2d16168539c99661))
-* updates the docs to reflect changes to global args and that global args values can now be propagated back up the stack ([ead076f0](https://github.com/kbknapp/clap-rs/commit/ead076f03ada4c322bf3e34203925561ec496d87))
-* add html_root_url attribute ([e67a061b](https://github.com/kbknapp/clap-rs/commit/e67a061bcf567c6518d6c2f58852e01f02764b22))
-* sync README version numbers with crate version ([5536361b](https://github.com/kbknapp/clap-rs/commit/5536361bcda29887ed86bb68e43d0b603cbc423f))
-
-#### Improvements
-
-* args that have require_delimiter(true) is now reflected in help and usage strings ([dce61699](https://github.com/kbknapp/clap-rs/commit/dce616998ed9bd95e8ed3bec1f09a4883da47b85), closes [#1052](https://github.com/kbknapp/clap-rs/issues/1052))
-* if all subcommands are hidden, the subcommands section of the help message is no longer displayed ([4ae7b046](https://github.com/kbknapp/clap-rs/commit/4ae7b0464750bc07ec80ece38e43f003fdd1b8ae), closes [#1046](https://github.com/kbknapp/clap-rs/issues/1046))
-
-#### Breaking Changes
-
-* when an argument requires a value and that value happens to match a subcommand name, its parsed as a value ([0c223f54](https://github.com/kbknapp/clap-rs/commit/0c223f54ed46da406bc8b43a5806e0b227863b31), closes [#1031](https://github.com/kbknapp/clap-rs/issues/1031), breaks [#](https://github.com/kbknapp/clap-rs/issues/), [#](https://github.com/kbknapp/clap-rs/issues/))
-
-#### Deprecations
-
-* **AppSettings::PropagateGlobalValuesDown:** this setting is no longer required to propagate values down or up ([2bb5ddce](https://github.com/kbknapp/clap-rs/commit/2bb5ddcee61c791ca1aaca494fbeb4bd5e277488))
-
-
-
-<a name="v2.26.2"></a>
-### v2.26.2 (2017-09-14)
-
-
-#### Improvements
-
-* if all subcommands are hidden, the subcommands section of the help message is no longer displayed ([4ae7b046](https://github.com/kbknapp/clap-rs/commit/4ae7b0464750bc07ec80ece38e43f003fdd1b8ae), closes [#1046](https://github.com/kbknapp/clap-rs/issues/1046))
-
-#### Bug Fixes
-
-* fixes a bug where default values are not applied if the option supports zero values ([9c248cbf](https://github.com/kbknapp/clap-rs/commit/9c248cbf7d8a825119bc387c23e9a1d1989682b0), closes [#1047](https://github.com/kbknapp/clap-rs/issues/1047))
-
-
-
-<a name="v2.26.1"></a>
-### v2.26.1 (2017-09-14)
-
-
-#### Bug Fixes
-
-* fixes using require_equals(true) and min_values(0) together ([10ae208f](https://github.com/kbknapp/clap-rs/commit/10ae208f68518eff6e98166724065745f4083174), closes [#1044](https://github.com/kbknapp/clap-rs/issues/1044))
-* escape special characters in zsh and fish completions ([87e019fc](https://github.com/kbknapp/clap-rs/commit/87e019fc84ba6193a8c4ddc26c61eb99efffcd25))
-* avoid panic generating default help msg if term width set to 0 due to bug in textwrap 0.7.0 ([b3eadb0d](https://github.com/kbknapp/clap-rs/commit/b3eadb0de516106db4e08f078ad32e8f6d6e7a57))
-* Change `who's` -> `whose` ([53c1ffe8](https://github.com/kbknapp/clap-rs/commit/53c1ffe87f38b05d8804a0f7832412a952845349))
-* adds a debug assertion to ensure all args added to groups actually exist ([7ad123e2](https://github.com/kbknapp/clap-rs/commit/7ad123e2c02577e3ca30f7e205181e896b157d11), closes [#917](https://github.com/kbknapp/clap-rs/issues/917))
-* fixes a bug where args that allow values to start with a hyphen couldnt contain a double hyphen -- as a value ([ab2f4c9e](https://github.com/kbknapp/clap-rs/commit/ab2f4c9e563e36ec739a4b55d5a5b76fdb9e9fa4), closes [#960](https://github.com/kbknapp/clap-rs/issues/960))
-* fixes a bug where positional argument help text is misaligned ([54c16836](https://github.com/kbknapp/clap-rs/commit/54c16836dea4651806a2cfad53146a83fa3abf21))
-* **Help Message:** fixes long_about not being usable ([a8257ea0](https://github.com/kbknapp/clap-rs/commit/a8257ea0ffb812e552aca256c4a3d2aebfd8065b), closes [#1043](https://github.com/kbknapp/clap-rs/issues/1043))
-* **Suggestions:** output for flag after subcommand ([434ea5ba](https://github.com/kbknapp/clap-rs/commit/434ea5ba71395d8c1afcf88e69f0b0d8339b01a1))
-
-
-
-<a name="v2.26.0"></a>
-## v2.26.0 (2017-07-29)
-
-Minimum version of Rust is now v1.13.0 (Stable)
-
-
-#### Improvements
-
-* bumps unicode-segmentation to v1.2 ([cd7b40a2](https://github.com/kbknapp/clap-rs/commit/cd7b40a21c77bae17ba453c5512cb82b7d1ce474))
-
-
-#### Performance
-
-* update textwrap to version 0.7.0 ([c2d4e637](https://github.com/kbknapp/clap-rs/commit/c2d4e63756a6f070e38c16dff846e9b0a53d6f93))
-
-
-
-
-<a name="v2.25.1"></a>
-### v2.25.1 (2017-07-21)
-
-#### Improvements
-
-* impl Default for Values + OsValues for any lifetime. ([fb7d6231f1](https://github.com/kbknapp/clap-rs/commit/fb7d6231f13a2f79f411e62dca210b7dc9994c18))
-
-#### Documentation
-
-* Various documentation typos and grammar fixes
-
-<a name="v2.25.0"></a>
-### v2.25.0 (2017-06-20)
-
-
-#### Features
-
-* use textwrap crate for wrapping help texts ([b93870c1](https://github.com/kbknapp/clap-rs/commit/b93870c10ae3bd90d233c586a33e086803117285))
-
-#### Improvements
-
-* **Suggestions:** suggests to use flag after subcommand when applicable ([2671ca72](https://github.com/kbknapp/clap-rs/commit/2671ca7260119d4311d21c4075466aafdd9da734))
-* Bumps bitflags crate to v0.9
-
-#### Documentation
-
-* Change `who's` -> `whose` ([53c1ffe8](https://github.com/kbknapp/clap-rs/commit/53c1ffe87f38b05d8804a0f7832412a952845349))
-
-#### Documentation
-
-* **App::template:** adds details about the necessity to use AppSettings::UnifiedHelpMessage when using {unified} tags in the help template ([cbea3d5a](https://github.com/kbknapp/clap-rs/commit/cbea3d5acf3271a7a734498c4d99c709941c331e), closes [#949](https://github.com/kbknapp/clap-rs/issues/949))
-* **Arg::allow_hyphen_values:** updates the docs to include warnings for allow_hyphen_values and multiple(true) used together ([f9b0d657](https://github.com/kbknapp/clap-rs/commit/f9b0d657835d3f517f313d70962177dc30acf4a7))
-* **README.md:**
- * added a warning about using ~ deps ([821929b5](https://github.com/kbknapp/clap-rs/commit/821929b51bd60213955705900a436c9a64fcb79f), closes [#964](https://github.com/kbknapp/clap-rs/issues/964))
-* **clap_app!:** adds using the @group specifier to the macro docs ([826048cb](https://github.com/kbknapp/clap-rs/commit/826048cb3cbc0280169303f1498ff0a2b7395883), closes [#932](https://github.com/kbknapp/clap-rs/issues/932))
-
-
-
-<a name="v2.24.2"></a>
-### v2.24.2 (2017-05-15)
-
-
-#### Bug Fixes
-
-* adds a debug assertion to ensure all args added to groups actually exist ([14f6b8f3](https://github.com/kbknapp/clap-rs/commit/14f6b8f3a2f6df73aeeec9c54a54909b1acfc158), closes [#917](https://github.com/kbknapp/clap-rs/issues/917))
-* fixes a bug where args that allow values to start with a hyphen couldnt contain a double hyphen -- as a value ([ebf73a09](https://github.com/kbknapp/clap-rs/commit/ebf73a09db6f3c03c19cdd76b1ba6113930e1643), closes [#960](https://github.com/kbknapp/clap-rs/issues/960))
-* fixes a bug where positional argument help text is misaligned ([54c16836](https://github.com/kbknapp/clap-rs/commit/54c16836dea4651806a2cfad53146a83fa3abf21))
-
-#### Documentation
-
-* **App::template:** adds details about the necessity to use AppSettings::UnifiedHelpMessage when using {unified} tags in the help template ([cf569438](https://github.com/kbknapp/clap-rs/commit/cf569438f309c199800bb8e46c9f140187de69d7), closes [#949](https://github.com/kbknapp/clap-rs/issues/949))
-* **Arg::allow_hyphen_values:** updates the docs to include warnings for allow_hyphen_values and multiple(true) used together ([ded5a2f1](https://github.com/kbknapp/clap-rs/commit/ded5a2f15474d4a5bd46a67b130ccb8b6781bd01))
-* **clap_app!:** adds using the @group specifier to the macro docs ([fe85fcb1](https://github.com/kbknapp/clap-rs/commit/fe85fcb1772b61f13b20b7ea5290e2437a76190c), closes [#932](https://github.com/kbknapp/clap-rs/issues/932))
-
-
-
-<a name="v2.24.0"></a>
-### v2.24.0 (2017-05-07)
-
-
-#### Bug Fixes
-
-* fixes a bug where args with last(true) and required(true) set were not being printed in the usage string ([3ac533fe](https://github.com/kbknapp/clap-rs/commit/3ac533fedabf713943eedf006f830a5a486bbe80), closes [#944](https://github.com/kbknapp/clap-rs/issues/944))
-* fixes a bug that was printing the arg name, instead of value name when Arg::last(true) was used ([e1fe8ac3](https://github.com/kbknapp/clap-rs/commit/e1fe8ac3bc1f9cf4e36df0d881f8419755f1787b), closes [#940](https://github.com/kbknapp/clap-rs/issues/940))
-* fixes a bug where flags were parsed as flags AND positional values when specific combinations of settings were used ([20f83292](https://github.com/kbknapp/clap-rs/commit/20f83292d070038b8cee2a6b47e91f6b0a2f7871), closes [#946](https://github.com/kbknapp/clap-rs/issues/946))
-
-
-
-<a name="v2.24.0"></a>
-## v2.24.0 (2017-05-05)
-
-
-#### Documentation
-
-* **README.md:** fix some typos ([fa34deac](https://github.com/kbknapp/clap-rs/commit/fa34deac079f334c3af97bb7fb151880ba8887f8))
-
-#### API Additions
-
-* **Arg:** add `default_value_os` ([d5ef8955](https://github.com/kbknapp/clap-rs/commit/d5ef8955414b1587060f7218385256105b639c88))
-* **arg_matches.rs:** Added a Default implementation for Values and OsValues iterators. ([0a4384e3](https://github.com/kbknapp/clap-rs/commit/0a4384e350eed74c2a4dc8964c203f21ac64897f))
-
-
-<a name="v2.23.2"></a>
-### v2.23.2 (2017-04-19)
-
-
-#### Bug Fixes
-
-* **PowerShell Completions:** fixes a bug where powershells completions cant be used if no subcommands are defined ([a8bce558](https://github.com/kbknapp/clap-rs/commit/a8bce55837dc4e0fb187dc93180884a40ae09c6f), closes [#931](https://github.com/kbknapp/clap-rs/issues/931))
-
-#### Improvements
-
-* bumps term_size to take advantage of better terminal dimension handling ([e05100b7](https://github.com/kbknapp/clap-rs/commit/e05100b73d74066a90876bf38f952adf5e8ee422))
-* **PowerShell Completions:** massively dedups subcommand names in the generate script to make smaller scripts that are still functionally equiv ([85b0e1cc](https://github.com/kbknapp/clap-rs/commit/85b0e1cc4b9755dda75a93d898d79bc38631552b))
-
-#### Documentation
-
-* Fix a typo the minimum rust version required ([71dabba3](https://github.com/kbknapp/clap-rs/commit/71dabba3ea0a17c88b0e2199c9d99f0acbf3bc17))
-
-<a name="v2.23.1"></a>
-### v2.23.1 (2017-04-05)
-
-
-#### Bug Fixes
-
-* fixes a missing newline character in the autogenerated help and version messages in some instances ([5ae9007d](https://github.com/kbknapp/clap-rs/commit/5ae9007d984ae94ae2752df51bcbaeb0ec89bc15))
-
-
-<a name="v2.23.0"></a>
-## v2.23.0 (2017-04-05)
-
-
-#### API Additions
-
-* `App::long_about`
-* `App::long_version`
-* `App::print_long_help`
-* `App::write_long_help`
-* `App::print_long_version`
-* `App::write_long_version`
-* `Arg::long_help`
-
-#### Features
-
-* allows distinguishing between short and long version messages (-V/short or --version/long) ([59272b06](https://github.com/kbknapp/clap-rs/commit/59272b06cc213289dc604dbc694cb95d383a5d68))
-* allows distinguishing between short and long help with subcommands in the same manner as args ([6b371891](https://github.com/kbknapp/clap-rs/commit/6b371891a1702173a849d1e95f9fecb168bf6fc4))
-* allows specifying a short help vs a long help (i.e. varying levels of detail depending on if -h or --help was used) ([ef1b24c3](https://github.com/kbknapp/clap-rs/commit/ef1b24c3a0dff2f58c5e2e90880fbc2b69df20ee))
-* **clap_app!:** adds support for arg names with hyphens similar to longs with hyphens ([f7a88779](https://github.com/kbknapp/clap-rs/commit/f7a8877978c8f90e6543d4f0d9600c086cf92cd7), closes [#869](https://github.com/kbknapp/clap-rs/issues/869))
-
-#### Bug Fixes
-
-* fixes a bug that wasn't allowing help and version to be properly overridden ([8b2ceb83](https://github.com/kbknapp/clap-rs/commit/8b2ceb8368bcb70689fadf1c7f4b9549184926c1), closes [#922](https://github.com/kbknapp/clap-rs/issues/922))
-
-#### Documentation
-
-* **clap_app!:** documents the `--("some-arg")` method for using args with hyphens inside them ([bc08ef3e](https://github.com/kbknapp/clap-rs/commit/bc08ef3e185393073d969d301989b6319c616c1f), closes [#919](https://github.com/kbknapp/clap-rs/issues/919))
-
-
-
-<a name="v2.22.2"></a>
-### v2.22.2 (2017-03-30)
-
-
-#### Bug Fixes
-
-* **Custom Usage Strings:** fixes the usage string regression when using help templates ([0e4fd96d](https://github.com/kbknapp/clap-rs/commit/0e4fd96d74280d306d09e60ac44f938a82321769))
-
-
-
-<a name="v2.22.1"></a>
-### v2.22.1 (2017-03-24)
-
-
-#### Bug Fixes
-
-* **usage:** fixes a big regression with custom usage strings ([2c41caba](https://github.com/kbknapp/clap-rs/commit/2c41caba3c7d723a2894e315d04da796b0e97759))
-
-<a name="v2.22.0"></a>
-## v2.22.0 (2017-03-23)
-
-#### API Additions
-
-* **App::name:** adds the ability to change the name of the App instance after creation ([d49e8292](https://github.com/kbknapp/clap-rs/commit/d49e8292b026b06e2b70447cd9f08299f4fcba76), closes [#908](https://github.com/kbknapp/clap-rs/issues/908))
-* **Arg::hide_default_value:** adds ability to hide the default value of an argument from the help string ([89e6ea86](https://github.com/kbknapp/clap-rs/commit/89e6ea861e16a1ad56757ca12f6b32d02253e44a), closes [#902](https://github.com/kbknapp/clap-rs/issues/902))
-
-
-<a name="v2.21.3"></a>
-### v2.21.3 (2017-03-23)
-
-#### Bug Fixes
-
-* **yaml:** adds support for loading author info from yaml ([e04c390c](https://github.com/kbknapp/clap-rs/commit/e04c390c597a55fa27e724050342f16c42f1c5c9))
-
-
-<a name="v2.21.2"></a>
-### v2.21.2 (2017-03-17)
-
-
-#### Improvements
-
-* add fish subcommand help support ([f8f68cf8](https://github.com/kbknapp/clap-rs/commit/f8f68cf8251669aef4539a25a7c1166f0ac81ea6))
-* options that use `require_equals(true)` now display the equals sign in help messages, usage strings, and errors" ([c8eb0384](https://github.com/kbknapp/clap-rs/commit/c8eb0384d394d2900ccdc1593099c97808a3fa05), closes [#903](https://github.com/kbknapp/clap-rs/issues/903))
-
-
-#### Bug Fixes
-
-* setting the max term width now correctly propagates down through child subcommands
-
-
-
-<a name="v2.21.1"></a>
-### v2.21.1 (2017-03-12)
-
-
-#### Bug Fixes
-
-* **ArgRequiredElseHelp:** fixes the precedence of this error to prioritize over other error messages ([74b751ff](https://github.com/kbknapp/clap-rs/commit/74b751ff2e3631e337b7946347c1119829a41c53), closes [#895](https://github.com/kbknapp/clap-rs/issues/895))
-* **Positionals:** fixes some regression bugs resulting from old asserts in debug mode. ([9a3bc98e](https://github.com/kbknapp/clap-rs/commit/9a3bc98e9b55e7514b74b73374c5ac8b6e5e0508), closes [#896](https://github.com/kbknapp/clap-rs/issues/896))
-
-
-
-<a name="v2.21.0"></a>
-## v2.21.0 (2017-03-09)
-
-#### Performance
-
-* doesn't run `arg_post_processing` on multiple values anymore ([ec516182](https://github.com/kbknapp/clap-rs/commit/ec5161828729f6a53f0fccec8648f71697f01f78))
-* changes internal use of `VecMap` to `Vec` for matched values of `Arg`s ([22bf137a](https://github.com/kbknapp/clap-rs/commit/22bf137ac581684c6ed460d2c3c640c503d62621))
-* vastly reduces the amount of cloning when adding non-global args minus when they're added from `App::args` which is forced to clone ([8da0303b](https://github.com/kbknapp/clap-rs/commit/8da0303bc02db5fe047cfc0631a9da41d9dc60f7))
-* refactor to remove unneeded vectors and allocations and checks for significant performance increases ([0efa4119](https://github.com/kbknapp/clap-rs/commit/0efa4119632f134fc5b8b9695b007dd94b76735d))
-
-#### Documentation
-
-* Fix examples link in CONTRIBUTING.md ([60cf875d](https://github.com/kbknapp/clap-rs/commit/60cf875d67a252e19bb85054be57696fac2c57a1))
-
-#### Improvements
-
-* when `AppSettings::SubcommandsNegateReqs` and `ArgsNegateSubcommands` are used, a new more accurate double line usage string is shown ([50f02300](https://github.com/kbknapp/clap-rs/commit/50f02300d81788817acefef0697e157e01b6ca32), closes [#871](https://github.com/kbknapp/clap-rs/issues/871))
-
-#### API Additions
-
-* **Arg::last:** adds the ability to mark a positional argument as 'last' which means it should be used with `--` syntax and can be accessed early ([6a7aea90](https://github.com/kbknapp/clap-rs/commit/6a7aea9043b83badd9ab038b4ecc4c787716147e), closes [#888](https://github.com/kbknapp/clap-rs/issues/888))
-* provides `default_value_os` and `default_value_if[s]_os` ([0f2a3782](https://github.com/kbknapp/clap-rs/commit/0f2a378219a6930748d178ba350fe5925be5dad5), closes [#849](https://github.com/kbknapp/clap-rs/issues/849))
-* provides `App::help_message` and `App::version_message` which allows one to override the auto-generated help/version flag associated help ([389c413](https://github.com/kbknapp/clap-rs/commit/389c413b7023dccab8c76aa00577ea1d048e7a99), closes [#889](https://github.com/kbknapp/clap-rs/issues/889))
-
-#### New Settings
-
-* **InferSubcommands:** adds a setting to allow one to infer shortened subcommands or aliases (i.e. for subcommmand "test", "t", "te", or "tes" would be allowed assuming no other ambiguities) ([11602032](https://github.com/kbknapp/clap-rs/commit/11602032f6ff05881e3adf130356e37d5e66e8f9), closes [#863](https://github.com/kbknapp/clap-rs/issues/863))
-
-#### Bug Fixes
-
-* doesn't print the argument sections in the help message if all args in that section are hidden ([ce5ee5f5](https://github.com/kbknapp/clap-rs/commit/ce5ee5f5a76f838104aeddd01c8ec956dd347f50))
-* doesn't include the various [ARGS] [FLAGS] or [OPTIONS] if the only ones available are hidden ([7b4000af](https://github.com/kbknapp/clap-rs/commit/7b4000af97637703645c5fb2ac8bb65bd546b95b), closes [#882](https://github.com/kbknapp/clap-rs/issues/882))
-* now correctly shows subcommand as required in the usage string when AppSettings::SubcommandRequiredElseHelp is used ([8f0884c1](https://github.com/kbknapp/clap-rs/commit/8f0884c1764983a49b45de52a1eddf8d721564d8))
-* fixes some memory leaks when an error is detected and clap exits ([8c2dd287](https://github.com/kbknapp/clap-rs/commit/8c2dd28718262ace4ae0db98563809548e02a86b))
-* fixes a trait that's marked private accidentlly, but should be crate internal public ([1ae21108](https://github.com/kbknapp/clap-rs/commit/1ae21108015cea87e5360402e1747025116c7878))
-* **Completions:** fixes a bug that tried to propogate global args multiple times when generating multiple completion scripts ([5e9b9cf4](https://github.com/kbknapp/clap-rs/commit/5e9b9cf4dd80fa66a624374fd04e6545635c1f94), closes [#846](https://github.com/kbknapp/clap-rs/issues/846))
-
-#### Features
-
-* **Options:** adds the ability to require the equals syntax with options --opt=val ([f002693d](https://github.com/kbknapp/clap-rs/commit/f002693dec6a6959c4e9590cb7b7bfffd6d6e5bc), closes [#833](https://github.com/kbknapp/clap-rs/issues/833))
-
-
-
-<a name="v2.20.5"></a>
-### v2.20.5 (2017-02-18)
-
-
-#### Bug Fixes
-
-* **clap_app!:** fixes a critical bug of a missing fragment specifier when using `!property` style tags. ([5635c1f94](https://github.com/kbknapp/clap-rs/commit/5e9b9cf4dd80fa66a624374fd04e6545635c1f94))
-
-
-<a name="v2.20.4"></a>
-### v2.20.4 (2017-02-15)
-
-
-#### Bug Fixes
-
-* **Completions:** fixes a bug that tried to propogate global args multiple times when generating multiple completion scripts ([5e9b9cf4](https://github.com/kbknapp/clap-rs/commit/5e9b9cf4dd80fa66a624374fd04e6545635c1f94), closes [#846](https://github.com/kbknapp/clap-rs/issues/846))
-
-#### Documentation
-
-* Fix examples link in CONTRIBUTING.md ([60cf875d](https://github.com/kbknapp/clap-rs/commit/60cf875d67a252e19bb85054be57696fac2c57a1))
-
-
-<a name="v2.20.3"></a>
-### v2.20.3 (2017-02-03)
-
-
-#### Documentation
-
-* **Macros:** adds a warning about changing values in Cargo.toml not triggering a rebuild automatically ([112aea3e](https://github.com/kbknapp/clap-rs/commit/112aea3e42ae9e0c0a2d33ebad89496dbdd95e5d), closes [#838](https://github.com/kbknapp/clap-rs/issues/838))
-
-#### Bug Fixes
-
-* fixes a println->debugln typo ([279aa62e](https://github.com/kbknapp/clap-rs/commit/279aa62eaf08f56ce090ba16b937bc763cbb45be))
-* fixes bash completions for commands that have an underscore in the name ([7f5cfa72](https://github.com/kbknapp/clap-rs/commit/7f5cfa724f0ac4e098f5fe466c903febddb2d994), closes [#581](https://github.com/kbknapp/clap-rs/issues/581))
-* fixes a bug where ZSH completions would panic if the binary name had an underscore in it ([891a2a00](https://github.com/kbknapp/clap-rs/commit/891a2a006f775e92c556dda48bb32fac9807c4fb), closes [#581](https://github.com/kbknapp/clap-rs/issues/581))
-* allow final word to be wrapped in wrap_help ([564c5f0f](https://github.com/kbknapp/clap-rs/commit/564c5f0f1730f4a2c1cdd128664f1a981c31dcd4), closes [#828](https://github.com/kbknapp/clap-rs/issues/828))
-* fixes a bug where global args weren't included in the generated completion scripts ([9a1e006e](https://github.com/kbknapp/clap-rs/commit/9a1e006eb75ad5a6057ebd119aa90f7e06c0ace8), closes [#841](https://github.com/kbknapp/clap-rs/issues/841))
-
-
-
-<a name="v2.20.2"></a>
-### v2.20.2 (2017-02-03)
-
-#### Bug Fixes
-
-* fixes a critical bug where subcommand settings were being propogated too far ([74648c94](https://github.com/kbknapp/clap-rs/commit/74648c94b893df542bfa5bb595e68c7bb8167e36), closes [#832](https://github.com/kbknapp/clap-rs/issues/832))
-
-
-#### Improvements
-
-* adds ArgGroup::multiple to the supported YAML fields for building ArgGroups from YAML ([d8590037](https://github.com/kbknapp/clap-rs/commit/d8590037ce07dafd8cd5b26928aa4a9fd3018288), closes [#840](https://github.com/kbknapp/clap-rs/issues/840))
-
-<a name="v2.20.1"></a>
-### v2.20.1 (2017-01-31)
-
-#### Bug Fixes
-
-* allow final word to be wrapped in wrap_help ([564c5f0f](https://github.com/kbknapp/clap-rs/commit/564c5f0f1730f4a2c1cdd128664f1a981c31dcd4), closes [#828](https://github.com/kbknapp/clap-rs/issues/828))
-* actually show character in debug output ([84d8c547](https://github.com/kbknapp/clap-rs/commit/84d8c5476de95b7f37d61888bc4f13688b712434))
-* include final character in line lenght ([aff4ba18](https://github.com/kbknapp/clap-rs/commit/aff4ba18da8147e1259b04b0bfbc1fcb5c78a3c0))
-
-#### Improvements
-
-* updates libc and term_size deps for the libc version conflict ([6802ac4a](https://github.com/kbknapp/clap-rs/commit/6802ac4a59c142cda9ec55ca0c45ae5cb9a6ab55))
-
-#### Documentation
-
-* fix link from app_from_crate! to crate_authors! (#822) ([5b29be9b](https://github.com/kbknapp/clap-rs/commit/5b29be9b073330ab1f7227cdd19fe4aab39d5dcb))
-* fix spelling of "guaranteed" ([4f30a65b](https://github.com/kbknapp/clap-rs/commit/4f30a65b9c03eb09607eb91a929a6396637dc105))
-
-<a name="v2.20.0"></a>
-
-#### New Settings
-
-* **ArgsNegateSubcommands:** disables args being allowed between subcommands ([5e2af8c9](https://github.com/kbknapp/clap-rs/commit/5e2af8c96adb5ab75fa2d1536237ebcb41869494), closes [#793](https://github.com/kbknapp/clap-rs/issues/793))
-* **DontCollapseArgsInUsage:** disables the collapsing of positional args into `[ARGS]` in the usage string ([c2978afc](https://github.com/kbknapp/clap-rs/commit/c2978afc61fb46d5263ab3b2d87ecde1c9ce1553), closes [#769](https://github.com/kbknapp/clap-rs/issues/769))
-* **DisableHelpSubcommand:** disables building the `help` subcommand ([a10fc859](https://github.com/kbknapp/clap-rs/commit/a10fc859ee20159fbd9ff4337be59b76467a64f2))
-* **AllowMissingPositional:** allows one to implement `$ prog [optional] <required>` style CLIs where the second postional argument is required, but the first is optional ([1110fdc7](https://github.com/kbknapp/clap-rs/commit/1110fdc7a345c108820dc45783a9bf893fa4c214), closes [#636](https://github.com/kbknapp/clap-rs/issues/636))
-* **PropagateGlobalValuesDown:** automatically propagats global arg's values down through *used* subcommands ([985536c8](https://github.com/kbknapp/clap-rs/commit/985536c8ebcc09af98aac835f42a8072ad58c262), closes [#694](https://github.com/kbknapp/clap-rs/issues/694))
-
-#### API Additions
-
-##### Arg
-
-* **Arg::value_terminator:** adds the ability to terminate multiple values with a given string or char ([be64ce0c](https://github.com/kbknapp/clap-rs/commit/be64ce0c373efc106384baca3f487ea99fe7b8cf), closes [#782](https://github.com/kbknapp/clap-rs/issues/782))
-* **Arg::default_value_if[s]:** adds new methods for *conditional* default values (such as a particular value from another argument was used) ([eb4010e7](https://github.com/kbknapp/clap-rs/commit/eb4010e7b21724447ef837db11ac441915728f22))
-* **Arg::requires_if[s]:** adds the ability to *conditionally* require additional args (such as if a particular value was used) ([198449d6](https://github.com/kbknapp/clap-rs/commit/198449d64393c265f0bc327aaeac23ec4bb97226))
-* **Arg::required_if[s]:** adds the ability for an arg to be *conditionally* required (i.e. "arg X is only required if arg Y was used with value Z") ([ee9cfddf](https://github.com/kbknapp/clap-rs/commit/ee9cfddf345a6b5ae2af42ba72aa5c89e2ca7f59))
-* **Arg::validator_os:** adds ability to validate values which may contain invalid UTF-8 ([47232498](https://github.com/kbknapp/clap-rs/commit/47232498a813db4f3366ccd3e9faf0bff56433a4))
-
-##### Macros
-
-* **crate_description!:** Uses the `Cargo.toml` description field to fill in the `App::about` method at compile time ([4d9a82db](https://github.com/kbknapp/clap-rs/commit/4d9a82db8e875e9b64a9c2a5c6e22c25afc1279d), closes [#778](https://github.com/kbknapp/clap-rs/issues/778))
-* **crate_name!:** Uses the `Cargo.toml` name field to fill in the `App::new` method at compile time ([4d9a82db](https://github.com/kbknapp/clap-rs/commit/4d9a82db8e875e9b64a9c2a5c6e22c25afc1279d), closes [#778](https://github.com/kbknapp/clap-rs/issues/778))
-* **app_from_crate!:** Combines `crate_version!`, `crate_name!`, `crate_description!`, and `crate_authors!` into a single macro call to build a default `App` instance from the `Cargo.toml` fields ([4d9a82db](https://github.com/kbknapp/clap-rs/commit/4d9a82db8e875e9b64a9c2a5c6e22c25afc1279d), closes [#778](https://github.com/kbknapp/clap-rs/issues/778))
-
-
-#### Features
-
-* **no_cargo:** adds a `no_cargo` feature to disable Cargo-env-var-dependent macros for those *not* using `cargo` to build their crates (#786) ([6fdd2f9d](https://github.com/kbknapp/clap-rs/commit/6fdd2f9d693aaf1118fc61bd362273950703f43d))
-
-#### Bug Fixes
-
-* **Options:** fixes a critical bug where options weren't forced to have a value ([5a5f2b1e](https://github.com/kbknapp/clap-rs/commit/5a5f2b1e9f598a0d0280ef3e98abbbba2bc41132), closes [#665](https://github.com/kbknapp/clap-rs/issues/665))
-* fixes a bug where calling the help of a subcommand wasn't ignoring required args of parent commands ([d3d34a2b](https://github.com/kbknapp/clap-rs/commit/d3d34a2b51ef31004055b0ab574f766d801c3adf), closes [#789](https://github.com/kbknapp/clap-rs/issues/789))
-* **Help Subcommand:** fixes a bug where the help subcommand couldn't be overriden ([d34ec3e0](https://github.com/kbknapp/clap-rs/commit/d34ec3e032d03e402d8e87af9b2942fe2819b2da), closes [#787](https://github.com/kbknapp/clap-rs/issues/787))
-* **Low Index Multiples:** fixes a bug which caused combinations of LowIndexMultiples and `Arg::allow_hyphen_values` to fail parsing ([26c670ca](https://github.com/kbknapp/clap-rs/commit/26c670ca16d2c80dc26d5c1ce83380ace6357318))
-
-#### Improvements
-
-* **Default Values:** improves the error message when default values are involved ([1f33de54](https://github.com/kbknapp/clap-rs/commit/1f33de545036e7fd2f80faba251fca009bd519b8), closes [#774](https://github.com/kbknapp/clap-rs/issues/774))
-* **YAML:** adds conditional requirements and conditional default values to YAML ([9a4df327](https://github.com/kbknapp/clap-rs/commit/9a4df327893486adb5558ffefba790c634ccdc6e), closes [#764](https://github.com/kbknapp/clap-rs/issues/764))
-* Support `--("some-arg-name")` syntax for defining long arg names when using `clap_app!` macro ([f41ec962](https://github.com/kbknapp/clap-rs/commit/f41ec962c243a5ffff8b1be1ae2ad63970d3d1d4))
-* Support `("some app name")` syntax for defining app names when using `clap_app!` macro ([9895b671](https://github.com/kbknapp/clap-rs/commit/9895b671cff784f35cf56abcd8270f7c2ba09699), closes [#759](https://github.com/kbknapp/clap-rs/issues/759))
-* **Help Wrapping:** long app names (with spaces), authors, and descriptions are now wrapped appropriately ([ad4691b7](https://github.com/kbknapp/clap-rs/commit/ad4691b71a63e951ace346318238d8834e04ad8a), closes [#777](https://github.com/kbknapp/clap-rs/issues/777))
-
-
-#### Documentation
-
-* **Conditional Default Values:** fixes the failing doc tests of Arg::default_value_ifs ([4ef09101](https://github.com/kbknapp/clap-rs/commit/4ef091019c083b4db1a0c13f1c1e95ac363259f2))
-* **Conditional Requirements:** adds docs for Arg::requires_ifs ([7f296e29](https://github.com/kbknapp/clap-rs/commit/7f296e29db7d9036e76e5dbcc9c8b20dfe7b25bd))
-* **README.md:** fix some typos ([f22c21b4](https://github.com/kbknapp/clap-rs/commit/f22c21b422d5b287d1a1ac183a379ee02eebf54f))
-* **src/app/mod.rs:** fix some typos ([5c9b0d47](https://github.com/kbknapp/clap-rs/commit/5c9b0d47ca78dea285c5b9dec79063d24c3e451a))
-
-<a name="v2.19.3"></a>
-### v2.19.3 (2016-12-28)
-
-
-#### Bug Fixes
-
-* fixes a bug where calling the help of a subcommand wasn't ignoring required args of parent commands ([a0ee4993](https://github.com/kbknapp/clap-rs/commit/a0ee4993015ea97b06b5bc9f378d8bcb18f1c51c), closes [#789](https://github.com/kbknapp/clap-rs/issues/789))
-
-
-
-<a name="v2.19.2"></a>
-### v2.19.2 (2016-12-08)
-
-#### Bug Fixes
-
-* **ZSH Completions:** escapes square brackets in ZSH completions ([7e17d5a3](https://github.com/kbknapp/clap-rs/commit/7e17d5a36b2cc2cc77e7b15796b14d639ed3cbf7), closes [#771](https://github.com/kbknapp/clap-rs/issues/771))
-
-#### Documentation
-
-* **Examples:** adds subcommand examples ([0e0f3354](https://github.com/kbknapp/clap-rs/commit/0e0f33547a6901425afc1d9fbe19f7ae3832d9a4), closes [#766](https://github.com/kbknapp/clap-rs/issues/766))
-* **README.md:** adds guidance on when to use ~ in version pinning, and clarifies breaking change policy ([591eaefc](https://github.com/kbknapp/clap-rs/commit/591eaefc7319142ba921130e502bb0729feed907), closes [#765](https://github.com/kbknapp/clap-rs/issues/765))
-
-
-
-<a name="v2.19.1"></a>
-### v2.19.1 (2016-12-01)
-
-
-#### Bug Fixes
-
-* **Help Messages:** fixes help message alignment when specific settings are used on options ([cd94b318](https://github.com/kbknapp/clap-rs/commit/cd94b3188d63b63295a319e90e826bca46befcd2), closes [#760](https://github.com/kbknapp/clap-rs/issues/760))
-
-#### Improvements
-
-* **Bash Completion:** allows bash completion to fall back to traidtional bash completion upon no matching completing function ([b1b16d56](https://github.com/kbknapp/clap-rs/commit/b1b16d56d8fddf819bdbe24b3724bb6a9f3fa613)))
-
-
-<a name="v2.19.0"></a>
-## v2.19.0 (2016-11-21)
-
-#### Features
-
-* allows specifying AllowLeadingHyphen style values, but only for specific args vice command wide ([c0d70feb](https://github.com/kbknapp/clap-rs/commit/c0d70febad9996a77a54107054daf1914c50d4ef), closes [#742](https://github.com/kbknapp/clap-rs/issues/742))
-
-#### Bug Fixes
-
-* **Required Unless:** fixes a bug where having required_unless set doesn't work when conflicts are also set ([d20331b6](https://github.com/kbknapp/clap-rs/commit/d20331b6f7940ac3a4e919999f8bb4780875125d), closes [#753](https://github.com/kbknapp/clap-rs/issues/753))
-* **ZSH Completions:** fixes an issue where zsh completions caused panics if there were no subcommands ([49e7cdab](https://github.com/kbknapp/clap-rs/commit/49e7cdab76dd1ccc07221e360f07808ec62648aa), closes [#754](https://github.com/kbknapp/clap-rs/issues/754))
-
-#### Improvements
-
-* **Validators:** improves the error messages for validators ([65eb3385](https://github.com/kbknapp/clap-rs/commit/65eb33859d3ff53e7d3277f02a9d3fd9038a9dfb), closes [#744](https://github.com/kbknapp/clap-rs/issues/744))
-
-#### Documentation
-
-* updates the docs landing page ([01e1e33f](https://github.com/kbknapp/clap-rs/commit/01e1e33f377934099a4a725fab5cd6c5ff50eaa2))
-* adds the macro version back to the readme ([45eb9bf1](https://github.com/kbknapp/clap-rs/commit/45eb9bf130329c3f3853aba0342c2fe3c64ff80f))
-* fix broken docs links ([808e7cee](https://github.com/kbknapp/clap-rs/commit/808e7ceeb86d4a319bdc270f51c23a64621dbfb3))
-* **Compatibility Policy:** adds an official compatibility policy to ([760d66dc](https://github.com/kbknapp/clap-rs/commit/760d66dc17310b357f257776624151da933cd25d), closes [#740](https://github.com/kbknapp/clap-rs/issues/740))
-* **Contributing:** updates the readme to improve the readability and contributing sections ([eb51316c](https://github.com/kbknapp/clap-rs/commit/eb51316cdfdc7258d287ba13b67ef2f42bd2b8f6))
-
-<a name="v2.18.0"></a>
-## v2.18.0 (2016-11-05)
-
-
-#### Features
-
-* **Completions:** adds completion support for PowerShell. ([cff82c88](https://github.com/kbknapp/clap-rs/commit/cff82c880e21064fca63351507b80350df6caadf), closes [#729](https://github.com/kbknapp/clap-rs/issues/729))
-
-
-
-<a name="v2.17.1"></a>
-### v2.17.1 (2016-11-02)
-
-
-#### Bug Fixes
-
-* **Low Index Multiples:** fixes a bug where using low index multiples was propagated to subcommands ([33924e88](https://github.com/kbknapp/clap-rs/commit/33924e884461983c4e6b5ea1330fecc769a4ade7), closes [#725](https://github.com/kbknapp/clap-rs/issues/725))
-
-
-
-<a name="v2.17.0"></a>
-## v2.17.0 (2016-11-01)
-
-
-#### Features
-
-* **Positional Args:** allows specifying the second to last positional argument as multiple(true) ([1ced2a74](https://github.com/kbknapp/clap-rs/commit/1ced2a7433ea8937a1b260ea65d708f32ca7c95e), closes [#725](https://github.com/kbknapp/clap-rs/issues/725))
-
-
-
-<a name="v2.16.4"></a>
-### v2.16.4 (2016-10-31)
-
-
-#### Improvements
-
-* **Error Output:** conflicting errors are now symetrical, meaning more consistent and less confusing ([3d37001d](https://github.com/kbknapp/clap-rs/commit/3d37001d1dc647d73cc597ff172f1072d4beb80d), closes [#718](https://github.com/kbknapp/clap-rs/issues/718))
-
-#### Documentation
-
-* Fix typo in example `13a_enum_values_automatic` ([c22fbc07](https://github.com/kbknapp/clap-rs/commit/c22fbc07356e556ffb5d1a79ec04597d149b915e))
-* **README.md:** fixes failing yaml example (#715) ([21fba9e6](https://github.com/kbknapp/clap-rs/commit/21fba9e6cd8c163012999cd0ce271ec8780c5695))
-
-#### Bug Fixes
-
-* **ZSH Completions:** fixes bug that caused panic on subcommands with aliases ([5c70e1a0](https://github.com/kbknapp/clap-rs/commit/5c70e1a01bc977e44c10015d18bb8e215c32dfc8), closes [#714](https://github.com/kbknapp/clap-rs/issues/714))
-* **debug:** fixes the debug feature (#716) ([6c11ccf4](https://github.com/kbknapp/clap-rs/commit/6c11ccf443d46258d51f7cda33fbcc81e7fe8e90))
-
-
-
-<a name="v2.16.3"></a>
-### v2.16.3 (2016-10-28)
-
-
-#### Bug Fixes
-
-* Derive display order after propagation ([9cb6facf](https://github.com/kbknapp/clap-rs/commit/9cb6facf507aff7cddd124b8c29714d2b0e7bd13), closes [#706](https://github.com/kbknapp/clap-rs/issues/706))
-* **yaml-example:** inconsistent args ([847f7199](https://github.com/kbknapp/clap-rs/commit/847f7199219ead5065561d91d64780d99ae4b587))
-
-
-
-<a name="v2.15.1"></a>
-### v2.16.2 (2016-10-25)
-
-
-#### Bug Fixes
-
-* **Fish Completions:** fixes a bug where single quotes are not escaped ([780b4a18](https://github.com/kbknapp/clap-rs/commit/780b4a18281b6f7f7071e1b9db2290fae653c406), closes [#704](https://github.com/kbknapp/clap-rs/issues/704))
-
-
-<a name="v2.16.1"></a>
-### v2.16.1 (2016-10-24)
-
-
-#### Bug Fixes
-
-* **Help Message:** fixes a regression bug where args with multiple(true) threw off alignment ([ebddac79](https://github.com/kbknapp/clap-rs/commit/ebddac791f3ceac193d5ad833b4b734b9643a7af), closes [#702](https://github.com/kbknapp/clap-rs/issues/702))
-
-
-
-<a name="v2.16.0"></a>
-## v2.16.0 (2016-10-23)
-
-
-#### Features
-
-* **Completions:** adds ZSH completion support ([3e36b0ba](https://github.com/kbknapp/clap-rs/commit/3e36b0bac491d3f6194aee14604caf7be26b3d56), closes [#699](https://github.com/kbknapp/clap-rs/issues/699))
-
-
-
-<a name="v2.15.0"></a>
-## v2.15.0 (2016-10-21)
-
-
-#### Features
-
-* **AppSettings:** adds new setting `AppSettings::AllowNegativeNumbers` ([ab064546](https://github.com/kbknapp/clap-rs/commit/ab06454677fb6aa9b9f804644fcca2168b1eaee3), closes [#696](https://github.com/kbknapp/clap-rs/issues/696))
-
-#### Documentation
-
-* **app/settings.rs:** moves variants to roughly alphabetical order ([9ed4d4d7](https://github.com/kbknapp/clap-rs/commit/9ed4d4d7957a23357aef60081e45639ab9e3905f))
-
-
-<a name="v2.14.1"></a>
-### v2.14.1 (2016-10-20)
-
-
-#### Documentation
-
-* Improve documentation around features ([4ee85b95](https://github.com/kbknapp/clap-rs/commit/4ee85b95d2d16708a016a3ba4e6e2c93b89b7fad))
-* reword docs for ErrorKind and app::Settings ([3ccde7a4](https://github.com/kbknapp/clap-rs/commit/3ccde7a4b8f7a2ea8b916a5415c04a8ff4b5cb7a))
-* fix tests that fail when the "suggestions" feature is disabled ([996fc381](https://github.com/kbknapp/clap-rs/commit/996fc381763a48d125c7ea8a58fed057fd0b4ac6))
-* fix the OsString-using doc-tests ([af9e1a39](https://github.com/kbknapp/clap-rs/commit/af9e1a393ce6cdda46a03c8a4f48df222b015a24))
-* tag non-rust code blocks as such instead of ignoring them ([0ba9f4b1](https://github.com/kbknapp/clap-rs/commit/0ba9f4b123f281952581b6dec948f7e51dd22890))
-* **ErrorKind:** improve some errors about subcommands ([9f6217a4](https://github.com/kbknapp/clap-rs/commit/9f6217a424da823343d7b801b9c350dee3cd1906))
-* **yaml:** make sure the doc-tests don't fail before "missing file" ([8c0f5551](https://github.com/kbknapp/clap-rs/commit/8c0f55516f4910c78c9f8a2bdbd822729574f95b))
-
-#### Improvements
-
-* Stabilize clap_app! ([cd516006](https://github.com/kbknapp/clap-rs/commit/cd516006e35c37b005f329338560a0a53d1f3e00))
-* **with_defaults:** Deprecate App::with_defaults() ([26085409](https://github.com/kbknapp/clap-rs/commit/2608540940c8bb66e517b65706bc7dea55510682), closes [#638](https://github.com/kbknapp/clap-rs/issues/638))
-
-#### Bug Fixes
-
-* fixes a bug that made determining when to auto-wrap long help messages inconsistent ([468baadb](https://github.com/kbknapp/clap-rs/commit/468baadb8398fc1d37897b0c49374aef4cf97dca), closes [#688](https://github.com/kbknapp/clap-rs/issues/688))
-* **Completions:** fish completions for nested subcommands ([a61eaf8a](https://github.com/kbknapp/clap-rs/commit/a61eaf8aade76cfe90ccc0f7125751ebf60e3254))
-* **features:** Make lints not enable other nightly-requiring features ([835f75e3](https://github.com/kbknapp/clap-rs/commit/835f75e3ba20999117363ed9f916464d777f36ef))
-
-
-
-<a name="v2.14.0"></a>
-## v2.14.0 (2016-10-05)
-
-
-#### Features
-
-* **arg_aliases:** Ability to alias arguments ([33b5f6ef](https://github.com/kbknapp/clap-rs/commit/33b5f6ef2c9612ecabb31f96b824793e46bfd3dd), closes [#669](https://github.com/kbknapp/clap-rs/issues/669))
-* **flag_aliases:** Ability to alias flags ([40d6dac9](https://github.com/kbknapp/clap-rs/commit/40d6dac973927dded6ab423481634ef47ee7bfd7))
-
-#### Bug Fixes
-
-* **UsageParser:** Handle non-ascii names / options. ([1d6a7c6e](https://github.com/kbknapp/clap-rs/commit/1d6a7c6e7e6aadc527346aa822f19d8587f714f3), closes [#664](https://github.com/kbknapp/clap-rs/issues/664))
-
-#### Documentation
-
-* typo ([bac417fa](https://github.com/kbknapp/clap-rs/commit/bac417fa1cea3d32308334c7cccfcf54546cd9d8))
-
-
-<a name="v2.13.0"></a>
-## v2.13.0 (2016-09-18)
-
-
-#### Documentation
-
-* updates README.md with new website information and updated video tutorials info ([0c19c580](https://github.com/kbknapp/clap-rs/commit/0c19c580cf50f1b82ff32f70b36708ae2bcac132))
-* updates the docs about removing implicit value_delimiter(true) ([c81bc722](https://github.com/kbknapp/clap-rs/commit/c81bc722ebb8a86d22be89b5aec98df9fe222a08))
-* **Default Values:** adds better examples on using default values ([57a8d9ab](https://github.com/kbknapp/clap-rs/commit/57a8d9abb2f973c235a8a14f8fc031673d7a7460), closes [#418](https://github.com/kbknapp/clap-rs/issues/418))
-
-#### Bug Fixes
-
-* **Value Delimiters:** fixes the confusion around implicitly setting value delimiters. (default is now `false`) ([09d4d0a9](https://github.com/kbknapp/clap-rs/commit/09d4d0a9038d7ce2df55c2aec95e16f36189fcee), closes [#666](https://github.com/kbknapp/clap-rs/issues/666))
-
-
-
-<a name="v2.12.1"></a>
-### v2.12.1 (2016-09-13)
-
-
-#### Bug Fixes
-
-* **Help Wrapping:** fixes a regression-bug where the old {n} newline char stopped working ([92ac353b](https://github.com/kbknapp/clap-rs/commit/92ac353b48b7caa2511ad2a046d94da93c236cf6), closes [#661](https://github.com/kbknapp/clap-rs/issues/661))
-
-
-
-<a name="v2.12.0"></a>
-## v2.12.0 (2016-09-13)
-
-
-#### Features
-
-* **Help:** adds ability to hide the possible values on a per argument basis ([9151ef73](https://github.com/kbknapp/clap-rs/commit/9151ef739871f2e74910c342299c0de196b95dec), closes [#640](https://github.com/kbknapp/clap-rs/issues/640))
-* **help:** allow for limiting detected terminal width ([a43e28af](https://github.com/kbknapp/clap-rs/commit/a43e28af85c9a9deaedd5ef735f4f13008daab29), closes [#653](https://github.com/kbknapp/clap-rs/issues/653))
-
-#### Documentation
-
-* **Help Wrapping:** removes the verbiage about using `'{n}'` to insert newlines in help text ([c5a2b352](https://github.com/kbknapp/clap-rs/commit/c5a2b352ca600f5b802290ad945731066cd53611))
-* **Value Delimiters:** updates the docs for the Arg::multiple method WRT value delimiters and default settings ([f9d17a06](https://github.com/kbknapp/clap-rs/commit/f9d17a060aa53f10d0a6e1a7eed5d989d1a59533))
-* **appsettings:** Document AppSetting::DisableVersion ([94501965](https://github.com/kbknapp/clap-rs/commit/945019654d2ca67eb2b1d6014fdf80b84d528d30), closes [#589](https://github.com/kbknapp/clap-rs/issues/589))
-
-#### Bug Fixes
-
-* **AllowLeadingHyphen:** fixes a bug where valid args aren't recognized with this setting ([a9699e4d](https://github.com/kbknapp/clap-rs/commit/a9699e4d7cdc9a06e73b845933ff1fe6d76f016a), closes [#588](https://github.com/kbknapp/clap-rs/issues/588))
-
-#### Improvements
-
-* **Help Wrapping:**
- * clap now ignores hard newlines in help messages and properly re-aligns text, but still wraps if the term width is too small ([c7678523](https://github.com/kbknapp/clap-rs/commit/c76785239fd42adc8ca04f9202b6fec615aa9f14), closes [#617](https://github.com/kbknapp/clap-rs/issues/617))
- * makes some minor changes to when next line help is automatically used ([01cae799](https://github.com/kbknapp/clap-rs/commit/01cae7990a33167ac35103fb36c811b4fe6eb98f))
-* **Value Delimiters:** changes the default value delimiter rules ([f9e69254](https://github.com/kbknapp/clap-rs/commit/f9e692548e8c94de15f909432de301407d6bb834), closes [#655](https://github.com/kbknapp/clap-rs/issues/655))
-* **YAML:** supports setting Arg::require_delimiter from YAML ([b9b55a39](https://github.com/kbknapp/clap-rs/commit/b9b55a39dfebcdbdc05dca2692927e503db50816))
-
-#### Performance
-
-* **help:** fix redundant contains() checks ([a8afed74](https://github.com/kbknapp/clap-rs/commit/a8afed7428bf0733f8e93bb11ad6c00d9e970fcc))
-
-
-
-<a name="v2.11.3"></a>
-### v2.11.3 (2016-09-07)
-
-
-#### Documentation
-
-* **Help Wrapping:** removes the verbiage about using `'{n}'` to insert newlines in help text ([c5a2b352](https://github.com/kbknapp/clap-rs/commit/c5a2b352ca600f5b802290ad945731066cd53611))
-
-#### Improvements
-
-* **Help Wrapping:**
- * clap now ignores hard newlines in help messages and properly re-aligns text, but still wraps if the term width is too small ([c7678523](https://github.com/kbknapp/clap-rs/commit/c76785239fd42adc8ca04f9202b6fec615aa9f14), closes [#617](https://github.com/kbknapp/clap-rs/issues/617))
- * makes some minor changes to when next line help is automatically used ([01cae799](https://github.com/kbknapp/clap-rs/commit/01cae7990a33167ac35103fb36c811b4fe6eb98f))
-* **YAML:** supports setting Arg::require_delimiter from YAML ([b9b55a39](https://github.com/kbknapp/clap-rs/commit/b9b55a39dfebcdbdc05dca2692927e503db50816))
-
-
-
-
-<a name="v2.11.2"></a>
-### v2.11.2 (2016-09-06)
-
-#### Improvements
-
-* **Help Wrapping:** makes some minor changes to when next line help is automatically used ([5658b117](https://github.com/kbknapp/clap-rs/commit/5658b117aec3e03adff9c8c52a4c4bc1fcb4e1ff))
-
-
-<a name="v2.11.1"></a>
-### v2.11.1 (2016-09-05)
-
-
-#### Bug Fixes
-
-* **Settings:** fixes an issue where settings weren't propogated down through grand-child subcommands ([b3efc107](https://github.com/kbknapp/clap-rs/commit/b3efc107515d78517b20798ff3890b8a2b04498e), closes [#638](https://github.com/kbknapp/clap-rs/issues/638))
-
-#### Features
-
-* **Errors:** Errors with custom description ([58512f2f](https://github.com/kbknapp/clap-rs/commit/58512f2fcb430745f1ee6ee8f1c67f62dc216c73))
-
-#### Improvements
-
-* **help:** use term_size instead of home-grown solution ([fc7327e9](https://github.com/kbknapp/clap-rs/commit/fc7327e9dcf4258ef2baebf0a8714d9c0622855b))
-
-
-
-<a name="v2.11.0"></a>
-### v2.11.0 (2016-08-28)
-
-
-#### Bug Fixes
-
-* **Groups:** fixes some usage strings that contain both args in groups and ones that conflict with each other ([3d782def](https://github.com/kbknapp/clap-rs/commit/3d782def57725e2de26ca5a5bc5cc2e40ddebefb), closes [#616](https://github.com/kbknapp/clap-rs/issues/616))
-
-#### Documentation
-
-* moves docs to docs.rs ([03209d5e](https://github.com/kbknapp/clap-rs/commit/03209d5e1300906f00bafec1869c2047a92e5071), closes [#634](https://github.com/kbknapp/clap-rs/issues/634))
-
-#### Improvements
-
-* **Completions:** uses standard conventions for bash completion files, namely '{bin}.bash-completion' ([27f5bbfb](https://github.com/kbknapp/clap-rs/commit/27f5bbfbcc9474c2f57c2b92b1feb898ae46ee70), closes [#567](https://github.com/kbknapp/clap-rs/issues/567))
-* **Help:** automatically moves help text to the next line and wraps when term width is determined to be too small, or help text is too long ([150964c4](https://github.com/kbknapp/clap-rs/commit/150964c4e7124d54476c9d9b4b3f2406f0fd00e5), closes [#597](https://github.com/kbknapp/clap-rs/issues/597))
-* **YAML Errors:** vastly improves error messages when using YAML ([f43b7c65](https://github.com/kbknapp/clap-rs/commit/f43b7c65941c53adc0616b8646a21dc255862eb2), closes [#574](https://github.com/kbknapp/clap-rs/issues/574))
-
-#### Features
-
-* adds App::with_defaults to automatically use crate_authors! and crate_version! macros ([5520bb01](https://github.com/kbknapp/clap-rs/commit/5520bb012c127dfd299fd55699443c744d8dcd5b), closes [#600](https://github.com/kbknapp/clap-rs/issues/600))
-
-
-
-<a name="v2.10.4"></a>
-### v2.10.4 (2016-08-25)
-
-
-#### Bug Fixes
-
-* **Help Wrapping:** fixes a bug where help is wrapped incorrectly and causing a panic with some non-English characters ([d0b442c7](https://github.com/kbknapp/clap-rs/commit/d0b442c7beeecac9764406bc3bd171ced0b8825e), closes [#626](https://github.com/kbknapp/clap-rs/issues/626))
-
-
-
-<a name="v2.10.3"></a>
-### v2.10.3 (2016-08-25)
-
-#### Features
-
-* **Help:** adds new short hand way to use source formatting and ignore term width in help messages ([7dfdaf20](https://github.com/kbknapp/clap-rs/commit/7dfdaf200ebb5c431351a045b48f5e0f0d3f31db), closes [#625](https://github.com/kbknapp/clap-rs/issues/625))
-
-#### Documentation
-
-* **Term Width:** adds details about set_term_width(0) ([00b8205d](https://github.com/kbknapp/clap-rs/commit/00b8205d22639d1b54b9c453c55c785aace52cb2))
-
-#### Bug Fixes
-
-* **Unicode:** fixes two bugs where non-English characters were stripped or caused a panic with help wrapping ([763a5c92](https://github.com/kbknapp/clap-rs/commit/763a5c920e23efc74d190af0cb8b5dd714b2d67a), closes [#626](https://github.com/kbknapp/clap-rs/issues/626))
-
-
-
-<a name="v2.10.2"></a>
-### v2.10.2 (2016-08-22)
-
-
-#### Bug Fixes
-
-* fixes a bug where the help is printed twice ([a643fb28](https://github.com/kbknapp/clap-rs/commit/a643fb283acd9905dc727c4579c5c9fa2ceaa7e7), closes [#623](https://github.com/kbknapp/clap-rs/issues/623))
-
-
-
-<a name="v2.10.1"></a>
-### v2.10.1 (2016-08-21)
-
-
-#### Bug Fixes
-
-* **Help Subcommand:** fixes misleading usage string when using multi-level subcommmands ([e203515e](https://github.com/kbknapp/clap-rs/commit/e203515e3ac495b405dbba4f78fb6af148fd282e), closes [#618](https://github.com/kbknapp/clap-rs/issues/618))
-
-#### Features
-
-* **YAML:** allows using lists or single values with arg declarations ([9ade2cd4](https://github.com/kbknapp/clap-rs/commit/9ade2cd4b268d6d7fe828319ce6a523c641b9c38), closes [#614](https://github.com/kbknapp/clap-rs/issues/614), [#613](https://github.com/kbknapp/clap-rs/issues/613))
-
-
-
-<a name="v2.10.0"></a>
-## v2.10.0 (2016-07-29)
-
-
-#### Features
-
-* **Completions:** one can generate a basic fish completions script at compile time ([1979d2f2](https://github.com/kbknapp/clap-rs/commit/1979d2f2f3216e57d02a97e624a8a8f6cf867ed9))
-
-#### Bug Fixes
-
-* **parser:** preserve external subcommand name ([875df243](https://github.com/kbknapp/clap-rs/commit/875df24316c266920a073c13bbefbf546bc1f635))
-
-#### Breaking Changes
-
-* **parser:** preserve external subcommand name ([875df243](https://github.com/kbknapp/clap-rs/commit/875df24316c266920a073c13bbefbf546bc1f635))
-
-#### Documentation
-
-* **YAML:** fixes example 17's incorrect reference to arg_groups instead of groups ([b6c99e13](https://github.com/kbknapp/clap-rs/commit/b6c99e1377f918e78c16c8faced70a71607da931), closes [#601](https://github.com/kbknapp/clap-rs/issues/601))
-
-
-
-<a name="2.9.3"></a>
-### 2.9.3 (2016-07-24)
-
-
-#### Bug Fixes
-
-* fixes bug where only first arg in list of required_unless_one is recognized ([1fc3b55b](https://github.com/kbknapp/clap-rs/commit/1fc3b55bd6c8653b02e7c4253749c6b77737d2ac), closes [#575](https://github.com/kbknapp/clap-rs/issues/575))
-* **Settings:** fixes typo subcommandsrequired->subcommandrequired ([fc72cdf5](https://github.com/kbknapp/clap-rs/commit/fc72cdf591d30f5d9375d0b5cc2a2ff3e812f9f6), closes [#593](https://github.com/kbknapp/clap-rs/issues/593))
-
-#### Features
-
-* **Completions:** adds the ability to generate completions to io::Write object ([9f62cf73](https://github.com/kbknapp/clap-rs/commit/9f62cf7378ba5acb5ce8c5bac89b4aa60c30755f))
-* **Settings:** Add unset_setting and unset_settings fns to App (#598) ([0ceba231](https://github.com/kbknapp/clap-rs/commit/0ceba231c6767cd6d88fdb1feeeea41deadf77ff), closes [#590](https://github.com/kbknapp/clap-rs/issues/590))
-
-
-<a name="2.9.2"></a>
-### 2.9.2 (2016-07-03)
-
-
-#### Documentation
-
-* **Completions:** fixes the formatting of the Cargo.toml excerpt in the completions example ([722f2607](https://github.com/kbknapp/clap-rs/commit/722f2607beaef56b6a0e433db5fd09492d9f028c))
-
-#### Bug Fixes
-
-* **Completions:** fixes bug where --help and --version short weren't added to the completion list ([e9f2438e](https://github.com/kbknapp/clap-rs/commit/e9f2438e2ce99af0ae570a2eaf541fc7f55b771b), closes [#536](https://github.com/kbknapp/clap-rs/issues/536))
-
-
-
-<a name="2.9.1"></a>
-### 2.9.1 (2016-07-02)
-
-
-#### Improvements
-
-* **Completions:** allows multiple completions to be built by namespacing with bin name ([57484b2d](https://github.com/kbknapp/clap-rs/commit/57484b2daeaac01c1026e8c84efc8bf099e0eb31))
-
-
-<a name="v2.9.0"></a>
-## v2.9.0 (2016-07-01)
-
-
-#### Documentation
-
-* **Completions:**
- * fixes some errors in the completion docs ([9b359bf0](https://github.com/kbknapp/clap-rs/commit/9b359bf06255d3dad8f489308044b60a9d1e6a87))
- * adds documentation for completion scripts ([c6c519e4](https://github.com/kbknapp/clap-rs/commit/c6c519e40efd6c4533a9ef5efe8e74fd150391b7))
-
-#### Features
-
-* **Completions:**
- * one can now generate a bash completions script at compile time! ([e75b6c7b](https://github.com/kbknapp/clap-rs/commit/e75b6c7b75f729afb9eb1d2a2faf61dca7674634), closes [#376](https://github.com/kbknapp/clap-rs/issues/376))
- * completions now include aliases to subcommands, including all subcommand options ([0ab9f840](https://github.com/kbknapp/clap-rs/commit/0ab9f84052a8cf65b5551657f46c0c270841e634), closes [#556](https://github.com/kbknapp/clap-rs/issues/556))
- * completions now continue completing even after first completion ([18fc2e5b](https://github.com/kbknapp/clap-rs/commit/18fc2e5b5af63bf54a94b72cec5e1223d49f4806))
- * allows matching on possible values in options ([89cc2026](https://github.com/kbknapp/clap-rs/commit/89cc2026ba9ac69cf44c5254360bbf99236d4f89), closes [#557](https://github.com/kbknapp/clap-rs/issues/557))
-
-#### Bug Fixes
-
-* **AllowLeadingHyphen:** fixes an issue where isn't ignored like it should be with this setting ([96c24c9a](https://github.com/kbknapp/clap-rs/commit/96c24c9a8fa1f85e06138d3cdd133e51659e19d2), closes [#558](https://github.com/kbknapp/clap-rs/issues/558))
-
-<a name="v2.8.0"></a>
-## v2.8.0 (2016-06-30)
-
-
-#### Features
-
-* **Arg:** adds new setting `Arg::require_delimiter` which requires val delimiter to parse multiple values ([920b5595](https://github.com/kbknapp/clap-rs/commit/920b5595ed72abfb501ce054ab536067d8df2a66))
-
-#### Bug Fixes
-
-* Declare term::Winsize as repr(C) ([5d663d90](https://github.com/kbknapp/clap-rs/commit/5d663d905c9829ce6e7a164f1f0896cdd70236dd))
-
-#### Documentation
-
-* **Arg:** adds docs for ([49af4e38](https://github.com/kbknapp/clap-rs/commit/49af4e38a5dae2ab0a7fc3b4147e2c053d532484))
-
-
-
-<a name="v2.7.1"></a>
-### v2.7.1 (2016-06-29)
-
-
-#### Bug Fixes
-
-* **Options:**
- * options with multiple values and using delimiters no longer parse additional values after a trailing space ([cdc500bd](https://github.com/kbknapp/clap-rs/commit/cdc500bdde6abe238c36ade406ddafc2bafff583))
- * using options with multiple values and with an = no longer parse args after the trailing space as values ([290f61d0](https://github.com/kbknapp/clap-rs/commit/290f61d07177413cf082ada55526d83405f6d011))
-
-
-
-<a name="v2.7.0"></a>
-## v2.7.0 (2016-06-28)
-
-
-#### Documentation
-
-* fix typos ([43b3d40b](https://github.com/kbknapp/clap-rs/commit/43b3d40b8c38b1571da75af86b5088be96cccec2))
-* **ArgGroup:** vastly improves ArgGroup docs by adding better examples ([9e5f4f5d](https://github.com/kbknapp/clap-rs/commit/9e5f4f5d734d630bca5535c3a0aa4fd4f9db3e39), closes [#534](https://github.com/kbknapp/clap-rs/issues/534))
-
-#### Features
-
-* **ArgGroup:** one can now specify groups which require AT LEAST one of the args ([33689acc](https://github.com/kbknapp/clap-rs/commit/33689acc689b217a8c0ee439f1b1225590c38355), closes [#533](https://github.com/kbknapp/clap-rs/issues/533))
-
-#### Bug Fixes
-
-* **App:** using `App::print_help` now prints the same as would have been printed by `--help` or the like ([e84cc018](https://github.com/kbknapp/clap-rs/commit/e84cc01836bbe0527e97de6db9889bd9e0fd6ba1), closes [#536](https://github.com/kbknapp/clap-rs/issues/536))
-* **Help:**
- * prevents invoking <cmd> help help and displaying incorrect help message ([e3d2893f](https://github.com/kbknapp/clap-rs/commit/e3d2893f377942a2d4cf3c6ff04524d0346e6fdb), closes [#538](https://github.com/kbknapp/clap-rs/issues/538))
- * subcommand help messages requested via <cmd> help <sub> now correctly match <cmd> <sub> --help ([08ad1cff](https://github.com/kbknapp/clap-rs/commit/08ad1cff4fec57224ea957a2891a057b323c01bc), closes [#539](https://github.com/kbknapp/clap-rs/issues/539))
-
-#### Improvements
-
-* **ArgGroup:** Add multiple ArgGroups per Arg ([902e182f](https://github.com/kbknapp/clap-rs/commit/902e182f7a58aff11ff01e0a452abcdbdb2262aa), closes [#426](https://github.com/kbknapp/clap-rs/issues/426))
-* **Usage Strings:** `[FLAGS]` and `[ARGS]` are no longer blindly added to usage strings ([9b2e45b1](https://github.com/kbknapp/clap-rs/commit/9b2e45b170aff567b038d8b3368880b6046c10c6), closes [#537](https://github.com/kbknapp/clap-rs/issues/537))
-* **arg_enum!:** allows using meta items like repr(C) with arg_enum!s ([edf9b233](https://github.com/kbknapp/clap-rs/commit/edf9b2331c17a2cbcc13f961add4c55c2778e773), closes [#543](https://github.com/kbknapp/clap-rs/issues/543))
-
-
-
-<a name="v2.6.0"></a>
-## v2.6.0 (2016-06-14)
-
-
-#### Improvements
-
-* removes extra newline from help output ([86e61d19](https://github.com/kbknapp/clap-rs/commit/86e61d19a748fb9870fcf1175308984e51ca1115))
-* allows printing version to any io::Write object ([921f5f79](https://github.com/kbknapp/clap-rs/commit/921f5f7916597f1d028cd4a65bfe76a01c801724))
-* removes extra newline when printing version ([7e2e2cbb](https://github.com/kbknapp/clap-rs/commit/7e2e2cbb4a8a0f050bb8072a376f742fc54b8589))
-* **Aliases:** improves readability of asliases in help messages ([ca511de7](https://github.com/kbknapp/clap-rs/commit/ca511de71f5b8c2ac419f1b188658e8c63b67846), closes [#526](https://github.com/kbknapp/clap-rs/issues/526), [#529](https://github.com/kbknapp/clap-rs/issues/529))
-* **Usage Strings:** improves the default usage string when only a single positional arg is present ([ec86f2da](https://github.com/kbknapp/clap-rs/commit/ec86f2dada1545a63fc72355e22fcdc4c466c215), closes [#518](https://github.com/kbknapp/clap-rs/issues/518))
-
-#### Features
-
-* **Help:** allows wrapping at specified term width (Even on Windows!) ([1761dc0d](https://github.com/kbknapp/clap-rs/commit/1761dc0d27d0d621229d792be40c36fbf65c3014), closes [#451](https://github.com/kbknapp/clap-rs/issues/451))
-* **Settings:**
- * adds new setting to stop delimiting values with -- or TrailingVarArg ([fc3e0f5a](https://github.com/kbknapp/clap-rs/commit/fc3e0f5afda6d24cdb3c4676614beebe13e1e870), closes [#511](https://github.com/kbknapp/clap-rs/issues/511))
- * one can now set an AppSetting which is propogated down through child subcommands ([e2341835](https://github.com/kbknapp/clap-rs/commit/e23418351a3b98bf08dfd7744bc14377c70d59ee), closes [#519](https://github.com/kbknapp/clap-rs/issues/519))
-* **Subcommands:** adds support for visible aliases ([7b10e7f8](https://github.com/kbknapp/clap-rs/commit/7b10e7f8937a07fdb8d16a6d8df79ce78d080cd3), closes [#522](https://github.com/kbknapp/clap-rs/issues/522))
-
-#### Bug Fixes
-
-* fixes bug where args are printed out of order with templates ([05abb534](https://github.com/kbknapp/clap-rs/commit/05abb534864764102031a0d402e64ac65867aa87))
-* fixes bug where one can't override version or help flags ([90d7d6a2](https://github.com/kbknapp/clap-rs/commit/90d7d6a2ea8240122dd9bf8d82d3c4f5ebb5c703), closes [#514](https://github.com/kbknapp/clap-rs/issues/514))
-* fixes issue where before_help wasn't printed ([b3faff60](https://github.com/kbknapp/clap-rs/commit/b3faff6030f76a23f26afcfa6a90169002ed7106))
-* **Help:** `App::before_help` and `App::after_help` now correctly wrap ([1f4da767](https://github.com/kbknapp/clap-rs/commit/1f4da7676e6e71aa8dda799f3eeefad105a47819), closes [#516](https://github.com/kbknapp/clap-rs/issues/516))
-* **Settings:** fixes bug where new color settings couldn't be converted from strs ([706a7c11](https://github.com/kbknapp/clap-rs/commit/706a7c11b0900be594de6d5a3121938eff197602))
-* **Subcommands:** subcommands with aliases now display help of the aliased subcommand ([5354d14b](https://github.com/kbknapp/clap-rs/commit/5354d14b51f189885ba110e01e6b76cca3752992), closes [#521](https://github.com/kbknapp/clap-rs/issues/521))
-* **Windows:** fixes a failing windows build ([01e7dfd6](https://github.com/kbknapp/clap-rs/commit/01e7dfd6c07228c0be6695b3c7bf9370d82860d4))
-* **YAML:** adds missing YAML methods for App and Arg ([e468faf3](https://github.com/kbknapp/clap-rs/commit/e468faf3f05950fd9f72d84b69aa2061e91c6c64), closes [#528](https://github.com/kbknapp/clap-rs/issues/528))
-
-
-
-<a name="v2.5.2"></a>
-### v2.5.2 (2016-05-31)
-
-
-#### Improvements
-
-* removes extra newline from help output ([86e61d19](https://github.com/kbknapp/clap-rs/commit/86e61d19a748fb9870fcf1175308984e51ca1115))
-* allows printing version to any io::Write object ([921f5f79](https://github.com/kbknapp/clap-rs/commit/921f5f7916597f1d028cd4a65bfe76a01c801724))
-* removes extra newline when printing version ([7e2e2cbb](https://github.com/kbknapp/clap-rs/commit/7e2e2cbb4a8a0f050bb8072a376f742fc54b8589))
-
-#### Bug Fixes
-
-* fixes bug where args are printed out of order with templates ([3935431d](https://github.com/kbknapp/clap-rs/commit/3935431d5633f577c0826ae2142794b301f4b8ca))
-* fixes bug where one can't override version or help flags ([90d7d6a2](https://github.com/kbknapp/clap-rs/commit/90d7d6a2ea8240122dd9bf8d82d3c4f5ebb5c703), closes [#514](https://github.com/kbknapp/clap-rs/issues/514))
-* fixes issue where before_help wasn't printed ([b3faff60](https://github.com/kbknapp/clap-rs/commit/b3faff6030f76a23f26afcfa6a90169002ed7106))
-
-#### Documentation
-
-* inter-links all types and pages ([3312893d](https://github.com/kbknapp/clap-rs/commit/3312893ddaef3f44d68d8d26ed3d08010be50d97), closes [#505](https://github.com/kbknapp/clap-rs/issues/505))
-* makes all publicly available types viewable in docs ([52ca6505](https://github.com/kbknapp/clap-rs/commit/52ca6505b4fec7b5c2d53d160c072d395eb21da6))
-
-<a name="v2.5.1"></a>
-### v2.5.1 (2016-05-11)
-
-
-#### Bug Fixes
-
-* **Subcommand Aliases**: fixes lifetime issue when setting multiple aliases at once ([ac42f6cf0](https://github.com/kbknapp/clap-rs/commit/ac42f6cf0de6c4920f703807d63061803930b18d))
-
-<a name="v2.5.0"></a>
-## v2.5.0 (2016-05-10)
-
-
-#### Improvements
-
-* **SubCommand Aliases:** adds feature to yaml configs too ([69592195](https://github.com/kbknapp/clap-rs/commit/695921954dde46dfd483399dcdef482c9dd7f34a))
-
-#### Features
-
-* **SubCommands:** adds support for subcommand aliases ([66b4dea6](https://github.com/kbknapp/clap-rs/commit/66b4dea65c44d8f77ff522238a9237aed1bcab6d), closes [#469](https://github.com/kbknapp/clap-rs/issues/469))
-
-
-<a name="v2.4.3"></a>
-### v2.4.3 (2016-05-10)
-
-
-#### Bug Fixes
-
-* **Usage Strings:**
- * now properly dedups args that are also in groups ([3ca0947c](https://github.com/kbknapp/clap-rs/commit/3ca0947c166b4f8525752255e3a4fa6565eb9689), closes [#498](https://github.com/kbknapp/clap-rs/issues/498))
- * removes duplicate groups from usage strings ([f574fb8a](https://github.com/kbknapp/clap-rs/commit/f574fb8a7cde4d4a2fa4c4481d59be2d0f135427))
-
-#### Improvements
-
-* **Groups:** formats positional args in groups in a better way ([fef11154](https://github.com/kbknapp/clap-rs/commit/fef11154fb7430d1cbf04a672aabb366e456a368))
-* **Help:**
- * moves positionals to standard <> formatting ([03dfe5ce](https://github.com/kbknapp/clap-rs/commit/03dfe5ceff1d63f172788ff688567ddad9fe119b))
- * default help subcommand string has been shortened ([5b7fe8e4](https://github.com/kbknapp/clap-rs/commit/5b7fe8e4161e43ab19e2e5fcf55fbe46791134e9), closes [#494](https://github.com/kbknapp/clap-rs/issues/494))
-
-<a name="v2.4.2"></a>
-### v2.4.3 (2016-05-10)
-
-* Ghost Release
-
-<a name="v2.4.1"></a>
-### v2.4.3 (2016-05-10)
-
-* Ghost Release
-
-<a name="v2.4.0"></a>
-## v2.4.0 (2016-05-02)
-
-
-#### Features
-
-* **Help:** adds support for displaying info before help message ([29fbfa3b](https://github.com/kbknapp/clap-rs/commit/29fbfa3b963f2f3ca7704bf5d3e1201531baa373))
-* **Required:** adds allowing args that are required unless certain args are present ([af1f7916](https://github.com/kbknapp/clap-rs/commit/af1f79168390ea7da4074d0d9777de458ea64971))
-
-#### Documentation
-
-* hides formatting from docs ([cb708093](https://github.com/kbknapp/clap-rs/commit/cb708093a7cd057f08c98b7bd1ed54c2db86ae7e))
-* **required_unless:** adds docs and examples for required_unless ([ca727b52](https://github.com/kbknapp/clap-rs/commit/ca727b52423b9883acd88b2f227b2711bc144573))
-
-#### Bug Fixes
-
-* **Required Args:** fixes issue where missing required args are sometimes duplicatd in error messages ([3beebd81](https://github.com/kbknapp/clap-rs/commit/3beebd81e7bc2faa4115ac109cf570e512c5477f), closes [#492](https://github.com/kbknapp/clap-rs/issues/492))
-
-
-<a name="v2.3.0"></a>
-## v2.3.0 (2016-04-18)
-
-
-#### Improvements
-
-* **macros.rs:** Added write_nspaces macro (a new version of write_spaces) ([9d757e86](https://github.com/kbknapp/clap-rs/commit/9d757e8678e334e5a740ac750c76a9ed4e785cba))
-* **parser.rs:**
- * Provide a way to create a usage string without the USAGE: title ([a91d378b](https://github.com/kbknapp/clap-rs/commit/a91d378ba0c91b5796457f8c6e881b13226ab735))
- * Make Parser's create_usage public allowing to have function outside the parser to generate the help ([d51945f8](https://github.com/kbknapp/clap-rs/commit/d51945f8b82ebb0963f4f40b384a9e8335783091))
- * Expose Parser's flags, opts and positionals argument as iterators ([9b23e7ee](https://github.com/kbknapp/clap-rs/commit/9b23e7ee40e51f7a823644c4496be955dc6c9d3a))
-* **src/args:** Exposes argument display order by introducing a new Trait ([1321630e](https://github.com/kbknapp/clap-rs/commit/1321630ef56955f152c73376d4d85cceb0bb4a12))
-* **srs/args:** Added longest_filter to AnyArg trait ([65b3f667](https://github.com/kbknapp/clap-rs/commit/65b3f667532685f854c699ddd264d326599cf7e5))
-
-#### Features
-
-* **Authors Macro:** adds a crate_authors macro ([38fb59ab](https://github.com/kbknapp/clap-rs/commit/38fb59abf480eb2b6feca269097412f8b00b5b54), closes [#447](https://github.com/kbknapp/clap-rs/issues/447))
-* **HELP:**
- * implements optional colored help messages ([abc8f669](https://github.com/kbknapp/clap-rs/commit/abc8f669c3c8193ffc3a3b0ac6c3ac2198794d4f), closes [#483](https://github.com/kbknapp/clap-rs/issues/483))
- * Add a Templated Help system. ([81e121ed](https://github.com/kbknapp/clap-rs/commit/81e121edd616f7285593f11120c63bcccae0d23e))
-
-#### Bug Fixes
-
-* **HELP:** Adjust Help to semantic changes introduced in 6933b84 ([8d23806b](https://github.com/kbknapp/clap-rs/commit/8d23806bd67530ad412c34a1dcdcb1435555573d))
-
-<a name="v2.2.6"></a>
-### v2.2.6 (2016-04-11)
-
-#### Bug Fixes
-
-* **Arg Groups**: fixes bug where arg name isn't printed properly ([3019a685](https://github.com/kbknapp/clap-rs/commit/3019a685eee747ccbe6be09ad5dddce0b1d1d4db), closes [#476](https://github.com/kbknapp/clap-rs/issues/476))
-
-
-<a name="v2.2.5"></a>
-### v2.2.5 (2016-04-03)
-
-
-#### Bug Fixes
-
-* **Empty Values:** fixes bug where empty values weren't stored ([885d166f](https://github.com/kbknapp/clap-rs/commit/885d166f04eb3fb581898ae5818c6c8032e5a686), closes [#470](https://github.com/kbknapp/clap-rs/issues/470))
-* **Help Message:** fixes bug where arg name is printed twice ([71acf1d5](https://github.com/kbknapp/clap-rs/commit/71acf1d576946658b8bbdb5ae79e6716c43a030f), closes [#472](https://github.com/kbknapp/clap-rs/issues/472))
-
-
-<a name="v2.2.4"></a>
-### v2.2.4 (2016-03-30)
-
-
-#### Bug Fixes
-
-* fixes compiling with debug cargo feature ([d4b55450](https://github.com/kbknapp/clap-rs/commit/d4b554509928031ac0808076178075bb21f8c1da))
-* **Empty Values:** fixes bug where empty values weren't stored ([885d166f](https://github.com/kbknapp/clap-rs/commit/885d166f04eb3fb581898ae5818c6c8032e5a686), closes [#470](https://github.com/kbknapp/clap-rs/issues/470))
-
-
-
-<a name="v2.2.3"></a>
-### v2.2.3 (2016-03-28)
-
-
-#### Bug Fixes
-
-* **Help Subcommand:** fixes issue where help and version flags weren't properly displayed ([205b07bf](https://github.com/kbknapp/clap-rs/commit/205b07bf2e6547851f1290f8cd6b169145e144f1), closes [#466](https://github.com/kbknapp/clap-rs/issues/466))
-
-<a name="v2.2.2"></a>
-### v2.2.2 (2016-03-27)
-
-
-#### Bug Fixes
-
-* **Help Message:** fixes bug with wrapping in the middle of a unicode sequence ([05365ddc](https://github.com/kbknapp/clap-rs/commit/05365ddcc252e4b49e7a75e199d6001a430bd84d), closes [#456](https://github.com/kbknapp/clap-rs/issues/456))
-* **Usage Strings:** fixes small bug where -- would appear needlessly in usage strings ([6933b849](https://github.com/kbknapp/clap-rs/commit/6933b8491c2a7e28cdb61b47dcf10caf33c2f78a), closes [#461](https://github.com/kbknapp/clap-rs/issues/461))
-
-
-<a name="2.2.1"></a>
-### 2.2.1 (2016-03-16)
-
-
-#### Features
-
-* **Help Message:** wraps and aligns the help message of subcommands ([813d75d0](https://github.com/kbknapp/clap-rs/commit/813d75d06fbf077c65762608c0fa5e941cfc393c), closes [#452](https://github.com/kbknapp/clap-rs/issues/452))
-
-#### Bug Fixes
-
-* **Help Message:** fixes a bug where small terminal sizes causing a loop ([1d73b035](https://github.com/kbknapp/clap-rs/commit/1d73b0355236923aeaf6799abc759762ded7e1d0), closes [#453](https://github.com/kbknapp/clap-rs/issues/453))
-
-
-<a name="v2.2.0"></a>
-## v2.2.0 (2016-03-15)
-
-
-#### Features
-
-* **Help Message:** can auto wrap and aligning help text to term width ([e36af026](https://github.com/kbknapp/clap-rs/commit/e36af0266635f23e85e951b9088d561e9a5d1bf6), closes [#428](https://github.com/kbknapp/clap-rs/issues/428))
-* **Help Subcommand:** adds support passing additional subcommands to help subcommand ([2c12757b](https://github.com/kbknapp/clap-rs/commit/2c12757bbdf34ce481f3446c074e24c09c2e60fd), closes [#416](https://github.com/kbknapp/clap-rs/issues/416))
-* **Opts and Flags:** adds support for custom ordering in help messages ([9803b51e](https://github.com/kbknapp/clap-rs/commit/9803b51e799904c0befaac457418ee766ccc1ab9))
-* **Settings:** adds support for automatically deriving custom display order of args ([ad86e433](https://github.com/kbknapp/clap-rs/commit/ad86e43334c4f70e86909689a088fb87e26ff95a), closes [#444](https://github.com/kbknapp/clap-rs/issues/444))
-* **Subcommands:** adds support for custom ordering in help messages ([7d2a2ed4](https://github.com/kbknapp/clap-rs/commit/7d2a2ed413f5517d45988eef0765cdcd663b6372), closes [#442](https://github.com/kbknapp/clap-rs/issues/442))
-
-#### Bug Fixes
-
-* **From Usage:** fixes a bug where adding empty lines werent ignored ([c5c58c86](https://github.com/kbknapp/clap-rs/commit/c5c58c86b9c503d8de19da356a5a5cffb59fbe84))
-
-#### Documentation
-
-* **Groups:** explains required ArgGroups better ([4ff0205b](https://github.com/kbknapp/clap-rs/commit/4ff0205b85a45151b59bbaf090a89df13438380f), closes [#439](https://github.com/kbknapp/clap-rs/issues/439))
-
-<a name="v2.1.2"></a>
-### v2.1.2 (2016-02-24)
-
-#### Bug Fixes
-
-* **Nightly:** fixes failing nightly build ([d752c170](https://github.com/kbknapp/clap-rs/commit/d752c17029598b19037710f204b7943f0830ae75), closes [#434](https://github.com/kbknapp/clap-rs/issues/434))
-
-
-<a name="v2.1.1"></a>
-### v2.1.1 (2016-02-19)
-
-
-#### Documentation
-
-* **AppSettings:** clarifies that AppSettings do not propagate ([3c8db0e9](https://github.com/kbknapp/clap-rs/commit/3c8db0e9be1d24edaad364359513cbb02abb4186), closes [#429](https://github.com/kbknapp/clap-rs/issues/429))
-* **Arg Examples:** adds better examples ([1e79cccc](https://github.com/kbknapp/clap-rs/commit/1e79cccc12937bc0e7cd2aad8e404410798e9fff))
-
-#### Improvements
-
-* **Help:** adds setting for next line help by arg ([066df748](https://github.com/kbknapp/clap-rs/commit/066df7486e684cf50a8479a356a12ba972c34ce1), closes [#427](https://github.com/kbknapp/clap-rs/issues/427))
-
-
-<a name="v2.1.0"></a>
-## v2.1.0 (2016-02-10)
-
-
-#### Features
-
-* **Defult Values:** adds support for default values in args ([73211952](https://github.com/kbknapp/clap-rs/commit/73211952964a79d97b434dd567e6d7d34be7feb5), closes [#418](https://github.com/kbknapp/clap-rs/issues/418))
-
-#### Documentation
-
-* **Default Values:** adds better examples and notes for default values ([9facd74f](https://github.com/kbknapp/clap-rs/commit/9facd74f843ef3807c5d35259558a344e6c25905))
-
-
-<a name="v2.0.6"></a>
-### v2.0.6 (2016-02-09)
-
-
-#### Improvements
-
-* **Positional Arguments:** now displays value name if appropriate ([f0a99916](https://github.com/kbknapp/clap-rs/commit/f0a99916c59ce675515c6dcdfe9a40b130510908), closes [#420](https://github.com/kbknapp/clap-rs/issues/420))
-
-
-<a name="v2.0.5"></a>
-### v2.0.5 (2016-02-05)
-
-
-#### Bug Fixes
-
-* **Multiple Values:** fixes bug where number_of_values wasnt respected ([72c387da](https://github.com/kbknapp/clap-rs/commit/72c387da0bb8a6f526f863770f08bb8ca0d3de03))
-
-
-<a name="v2.0.4"></a>
-### v2.0.4 (2016-02-04)
-
-
-#### Bug Fixes
-
-* adds support for building ArgGroups from standalone YAML ([fcbc7e12](https://github.com/kbknapp/clap-rs/commit/fcbc7e12f5d7b023b8f30cba8cad28a01cf6cd26))
-* Stop lonely hyphens from causing panic ([85b11468](https://github.com/kbknapp/clap-rs/commit/85b11468b0189d5cc15f1cfac5db40d17a0077dc), closes [#410](https://github.com/kbknapp/clap-rs/issues/410))
-* **AppSettings:** fixes bug where subcmds didn't receive parent ver ([a62e4527](https://github.com/kbknapp/clap-rs/commit/a62e452754b3b0e3ac9a15aa8b5330636229ead1))
-
-<a name="v2.0.3"></a>
-### v2.0.3 (2016-02-02)
-
-
-#### Improvements
-
-* **values:** adds support for up to u64::max values per arg ([c7abf7d7](https://github.com/kbknapp/clap-rs/commit/c7abf7d7611e317b0d31d97632e3d2e13570947c))
-* **occurrences:** Allow for more than 256 occurrences of an argument. ([3731ddb3](https://github.com/kbknapp/clap-rs/commit/3731ddb361163f3d6b86844362871e48c80fa530))
-
-#### Features
-
-* **AppSettings:** adds HidePossibleValuesInHelp to skip writing those values ([cdee7a0e](https://github.com/kbknapp/clap-rs/commit/cdee7a0eb2beeec723cb98acfacf03bf629c1da3))
-
-#### Bug Fixes
-
-* **value_t_or_exit:** fixes typo which causes value_t_or_exit to return a Result ([ee96baff](https://github.com/kbknapp/clap-rs/commit/ee96baffd306cb8d20ddc5575cf739bb1a6354e8))
-
-
-<a name="v2.0.2"></a>
-### v2.0.2 (2016-01-31)
-
-
-#### Improvements
-
-* **arg_enum:** enum declared with arg_enum returns [&'static str; #] instead of Vec ([9c4b8a1a](https://github.com/kbknapp/clap-rs/commit/9c4b8a1a6b12949222f17d1074578ad7676b9c0d))
-
-#### Bug Fixes
-
-* clap_app! should be gated by unstable, not nightly feature ([0c8b84af](https://github.com/kbknapp/clap-rs/commit/0c8b84af6161d5baf683688eafc00874846f83fa))
-* **SubCommands:** fixed where subcmds weren't recognized after mult args ([c19c17a8](https://github.com/kbknapp/clap-rs/commit/c19c17a8850602990e24347aeb4427cf43316223), closes [#405](https://github.com/kbknapp/clap-rs/issues/405))
-* **Usage Parser:** fixes a bug where literal single quotes weren't allowed in help strings ([0bcc7120](https://github.com/kbknapp/clap-rs/commit/0bcc71206478074769e311479b34a9f74fe80f5c), closes [#406](https://github.com/kbknapp/clap-rs/issues/406))
-
-
-<a name="v2.0.1"></a>
-### v2.0.1 (2016-01-30)
-
-
-#### Bug Fixes
-
-* fixes cargo features to NOT require nightly with unstable features ([dcbcc60c](https://github.com/kbknapp/clap-rs/commit/dcbcc60c9ba17894be636472ea4b07a82d86a9db), closes [#402](https://github.com/kbknapp/clap-rs/issues/402))
-
-
-<a name="v2.0.0"></a>
-## v2.0.0 (2016-01-28)
-
-
-#### Improvements
-
-* **From Usage:** vastly improves the usage parser ([fa3a2f86](https://github.com/kbknapp/clap-rs/commit/fa3a2f86bd674c5eb07128c95098fab7d1437247), closes [#350](https://github.com/kbknapp/clap-rs/issues/350))
-
-#### Features
-
-* adds support for external subcommands ([177fe5cc](https://github.com/kbknapp/clap-rs/commit/177fe5cce745c2164a8e38c23be4c4460d2d7211), closes [#372](https://github.com/kbknapp/clap-rs/issues/372))
-* adds support values with a leading hyphen ([e4d429b9](https://github.com/kbknapp/clap-rs/commit/e4d429b9d52e95197bd0b572d59efacecf305a59), closes [#385](https://github.com/kbknapp/clap-rs/issues/385))
-* adds support for turning off the value delimiter ([508db850](https://github.com/kbknapp/clap-rs/commit/508db850a87c2e251cf6b6ddead9ad56b29f9e57), closes [#352](https://github.com/kbknapp/clap-rs/issues/352))
-* adds support changing the value delimiter ([dafeae8a](https://github.com/kbknapp/clap-rs/commit/dafeae8a526162640f6a68da434370c64d190889), closes [#353](https://github.com/kbknapp/clap-rs/issues/353))
-* adds support for comma separated values ([e69da6af](https://github.com/kbknapp/clap-rs/commit/e69da6afcd2fe48a3c458ca031db40997f860eda), closes [#348](https://github.com/kbknapp/clap-rs/issues/348))
-* adds support with options with optional values ([4555736c](https://github.com/kbknapp/clap-rs/commit/4555736cad01441dcde4ea84a285227e0844c16e), closes [#367](https://github.com/kbknapp/clap-rs/issues/367))
-* **UTF-8:** adds support for invalid utf8 in values ([c5c59dec](https://github.com/kbknapp/clap-rs/commit/c5c59dec0bc33b86b2e99d30741336f17ec84282), closes [#269](https://github.com/kbknapp/clap-rs/issues/269))
-* **v2:** implementing the base of 2.x ([a3536054](https://github.com/kbknapp/clap-rs/commit/a3536054512ba833533dc56615ce3663d884381c))
-
-#### Bug Fixes
-
-* fixes nightly build with new lints ([17599195](https://github.com/kbknapp/clap-rs/commit/175991956c37dc83ba9c49396e927a1cb65c5b11))
-* fixes Windows build for 2x release ([674c9b48](https://github.com/kbknapp/clap-rs/commit/674c9b48c7c92079cb180cc650a9e39f34781c32), closes [#392](https://github.com/kbknapp/clap-rs/issues/392))
-* fixes yaml build for 2x base ([adceae64](https://github.com/kbknapp/clap-rs/commit/adceae64c8556d00ab715677377b216f9f468ad7))
-
-#### Documentation
-
-* updates examples for 2x release ([1303b360](https://github.com/kbknapp/clap-rs/commit/1303b3607468f362ab1b452d5614c1a064dc69b4), closes [#394](https://github.com/kbknapp/clap-rs/issues/394))
-* updates examples for 2x release ([0a011f31](https://github.com/kbknapp/clap-rs/commit/0a011f3142aec338d388a6c8bfe22fa7036021bb), closes [#394](https://github.com/kbknapp/clap-rs/issues/394))
-* updates documentation for v2 release ([8d51724e](https://github.com/kbknapp/clap-rs/commit/8d51724ef73dfde5bb94fb9466bc5463a1cc1502))
-* updating docs for 2x release ([576d0e0e](https://github.com/kbknapp/clap-rs/commit/576d0e0e2c7b8f386589179bbf7419b93abacf1c))
-* **README.md:**
- * updates readme for v2 release ([acaba01a](https://github.com/kbknapp/clap-rs/commit/acaba01a353c12144b9cd9a3ce447400691849b0), closes [#393](https://github.com/kbknapp/clap-rs/issues/393))
- * fix typo and make documentation conspicuous ([07b9f614](https://github.com/kbknapp/clap-rs/commit/07b9f61495d927f69f7abe6c0d85253f0f4e6107))
-
-#### BREAKING CHANGES
-
-* **Fewer liftimes! Yay!**
- * `App<'a, 'b, 'c, 'd, 'e, 'f>` => `App<'a, 'b>`
- * `Arg<'a, 'b, 'c, 'd, 'e, 'f>` => `Arg<'a, 'b>`
- * `ArgMatches<'a, 'b>` => `ArgMatches<'a>`
-* **Simply Renamed**
- * `App::arg_group` => `App::group`
- * `App::arg_groups` => `App::groups`
- * `ArgGroup::add` => `ArgGroup::arg`
- * `ArgGroup::add_all` => `ArgGroup::args`
- * `ClapError` => `Error`
- * struct field `ClapError::error_type` => `Error::kind`
- * `ClapResult` => `Result`
- * `ClapErrorType` => `ErrorKind`
-* **Removed Deprecated Functions and Methods**
- * `App::subcommands_negate_reqs`
- * `App::subcommand_required`
- * `App::arg_required_else_help`
- * `App::global_version(bool)`
- * `App::versionless_subcommands`
- * `App::unified_help_messages`
- * `App::wait_on_error`
- * `App::subcommand_required_else_help`
- * `SubCommand::new`
- * `App::error_on_no_subcommand`
- * `Arg::new`
- * `Arg::mutually_excludes`
- * `Arg::mutually_excludes_all`
- * `Arg::mutually_overrides_with`
- * `simple_enum!`
-* **Renamed Error Variants**
- * `InvalidUnicode` => `InvalidUtf8`
- * `InvalidArgument` => `UnknownArgument`
-* **Usage Parser**
- * Value names can now be specified inline, i.e. `-o, --option <FILE> <FILE2> 'some option which takes two files'`
- * **There is now a priority of order to determine the name** - This is perhaps the biggest breaking change. See the documentation for full details. Prior to this change, the value name took precedence. **Ensure your args are using the proper names (i.e. typically the long or short and NOT the value name) throughout the code**
-* `ArgMatches::values_of` returns an `Values` now which implements `Iterator` (should not break any code)
-* `crate_version!` returns `&'static str` instead of `String`
-* Using the `clap_app!` macro requires compiling with the `unstable` feature because the syntax could change slightly in the future
-
-
-<a name="v1.5.5"></a>
-### v1.5.5 (2016-01-04)
-
-
-#### Bug Fixes
-
-* fixes an issue where invalid short args didn't cause an error ([c9bf7e44](https://github.com/kbknapp/clap-rs/commit/c9bf7e4440bd2f9b524ea955311d433c40a7d1e0))
-* prints the name in version and help instead of binary name ([8f3817f6](https://github.com/kbknapp/clap-rs/commit/8f3817f665c0cab6726bc16c56a53b6a61e44448), closes [#368](https://github.com/kbknapp/clap-rs/issues/368))
-* fixes an intentional panic issue discovered via clippy ([ea83a3d4](https://github.com/kbknapp/clap-rs/commit/ea83a3d421ea8856d4cac763942834d108b71406))
-
-
-<a name="v1.5.4"></a>
-### v1.5.4 (2015-12-18)
-
-
-#### Examples
-
-* **17_yaml:** conditinonally compile 17_yaml example ([575de089](https://github.com/kbknapp/clap-rs/commit/575de089a3e240c398cb10e6cf5a5c6b68662c01))
-
-#### Improvements
-
-* clippy improvements ([99cdebc2](https://github.com/kbknapp/clap-rs/commit/99cdebc23da3a45a165f14b27bebeb2ed828a2ce))
-
-#### Bug Fixes
-
-
-* **errors:** return correct error type in WrongNumValues error builder ([5ba8ba9d](https://github.com/kbknapp/clap-rs/commit/5ba8ba9dcccdfa74dd1c44260e64b359bbb36be6))
-* ArgRequiredElseHelp setting now takes precedence over missing required args ([faad83fb](https://github.com/kbknapp/clap-rs/commit/faad83fbef6752f3093b6e98fca09a9449b830f4), closes [#362](https://github.com/kbknapp/clap-rs/issues/362))
-
-
-<a name="v1.5.3"></a>
-### v1.5.3 (2015-11-20)
-
-
-#### Bug Fixes
-
-* **Errors:** fixes some instances when errors are missing a final newline ([c4d2b171](https://github.com/kbknapp/clap-rs/commit/c4d2b1711994479ad64ee52b6b49d2ceccbf2118))
-
-
-
-
-<a name="v1.5.2"></a>
-### v1.5.2 (2015-11-14)
-
-
-#### Bug Fixes
-
-* **Errors:** fixes a compiling bug when built on Windows or without the color feature ([a35f7634](https://github.com/kbknapp/clap-rs/commit/a35f76346fe6ecc88dda6a1eb13627186e7ce185))
-
-
-
-<a name="v1.5.1"></a>
-### v1.5.1 (2015-11-13)
-
-
-#### Bug Fixes
-
-* **Required Args:** fixes a bug where required args are not correctly accounted for ([f03b88a9](https://github.com/kbknapp/clap-rs/commit/f03b88a9766b331a63879bcd747687f2e5a2661b), closes [#343](https://github.com/kbknapp/clap-rs/issues/343))
-
-
-
-<a name="v1.5.0"></a>
-## v1.5.0 (2015-11-13)
-
-
-#### Bug Fixes
-
-* fixes a bug with required positional args in usage strings ([c6858f78](https://github.com/kbknapp/clap-rs/commit/c6858f78755f8e860204323c828c8355a066dc83))
-
-#### Documentation
-
-* **FAQ:** updates readme with slight changes to FAQ ([a4ef0fab](https://github.com/kbknapp/clap-rs/commit/a4ef0fab73c8dc68f1b138965d1340459c113398))
-
-#### Improvements
-
-* massive errors overhaul ([cdc29175](https://github.com/kbknapp/clap-rs/commit/cdc29175bc9c53e5b4aec86cbc04c1743154dae6))
-* **ArgMatcher:** huge refactor and deduplication of code ([8988853f](https://github.com/kbknapp/clap-rs/commit/8988853fb8825e8f841fde349834cc12cdbad081))
-* **Errors:** errors have been vastly improved ([e59bc0c1](https://github.com/kbknapp/clap-rs/commit/e59bc0c16046db156a88ba71a037db05028e995c))
-* **Traits:** refactoring some configuration into traits ([5800cdec](https://github.com/kbknapp/clap-rs/commit/5800cdec6dce3def4242b9f7bd136308afb19685))
-
-#### Performance
-
-* **App:**
- * more BTreeMap->Vec, Opts and SubCmds ([bc4495b3](https://github.com/kbknapp/clap-rs/commit/bc4495b32ec752b6c4b29719e831c043ef2a26ce))
- * changes flags BTreeMap->Vec ([d357640f](https://github.com/kbknapp/clap-rs/commit/d357640fab55e5964fe83efc3c771e53aa3222fd))
- * removed unneeded BTreeMap ([78971fd6](https://github.com/kbknapp/clap-rs/commit/78971fd68d7dc5c8e6811b4520cdc54e4188f733))
- * changes BTreeMap to VecMap in some instances ([64b921d0](https://github.com/kbknapp/clap-rs/commit/64b921d087fdd03775c95ba0bcf65d3f5d36f812))
- * removed excess clones ([ec0089d4](https://github.com/kbknapp/clap-rs/commit/ec0089d42ed715d293fb668d3a90b0db0aa3ec39))
-
-
-
-<a name="v1.4.7"></a>
-### v1.4.7 (2015-11-03)
-
-
-#### Documentation
-
-* Clarify behavior of Arg::multiple with options. ([434f497a](https://github.com/kbknapp/clap-rs/commit/434f497ab6d831f8145cf09278c97ca6ee6c6fe7))
-* Fix typos and improve grammar. ([c1f66b5d](https://github.com/kbknapp/clap-rs/commit/c1f66b5de7b5269fbf8760a005ef8c645edd3229))
-
-#### Bug Fixes
-
-* **Error Status:** fixes bug where --help and --version return non-zero exit code ([89b51fdf](https://github.com/kbknapp/clap-rs/commit/89b51fdf8b1ab67607567344e2317ff1a757cb12))
-
-
-
-<a name="v1.4.6"></a>
-### v1.4.6 (2015-10-29)
-
-
-#### Features
-
-* allows parsing without a binary name for daemons and interactive CLIs ([aff89d57](https://github.com/kbknapp/clap-rs/commit/aff89d579b5b85c3dc81b64f16d5865299ec39a2), closes [#318](https://github.com/kbknapp/clap-rs/issues/318))
-
-#### Bug Fixes
-
-* **Errors:** tones down quoting in some error messages ([34ce59ed](https://github.com/kbknapp/clap-rs/commit/34ce59ede53bfa2eef722c74881cdba7419fd9c7), closes [#309](https://github.com/kbknapp/clap-rs/issues/309))
-* **Help and Version:** only builds help and version once ([e3be87cf](https://github.com/kbknapp/clap-rs/commit/e3be87cfc095fc41c9811adcdc6d2b079f237d5e))
-* **Option Args:** fixes bug with args and multiple values ([c9a9548a](https://github.com/kbknapp/clap-rs/commit/c9a9548a8f96cef8a3dd9a980948325fbbc1b91b), closes [#323](https://github.com/kbknapp/clap-rs/issues/323))
-* **POSIX Overrides:** fixes bug where required args are overridden ([40ed2b50](https://github.com/kbknapp/clap-rs/commit/40ed2b50c3a9fe88bfdbaa43cef9fd6493ecaa8e))
-* **Safe Matches:** using 'safe' forms of the get_matches family no longer exit the process ([c47025dc](https://github.com/kbknapp/clap-rs/commit/c47025dca2b3305dea0a0acfdd741b09af0c0d05), closes [#256](https://github.com/kbknapp/clap-rs/issues/256))
-* **Versionless SubCommands:** fixes a bug where the -V flag was needlessly built ([27df8b9d](https://github.com/kbknapp/clap-rs/commit/27df8b9d98d13709dad3929a009f40ebff089a1a), closes [#329](https://github.com/kbknapp/clap-rs/issues/329))
-
-#### Documentation
-
-* adds comparison in readme ([1a8bf31e](https://github.com/kbknapp/clap-rs/commit/1a8bf31e7a6b87ce48a66af2cde1645b2dd5bc95), closes [#325](https://github.com/kbknapp/clap-rs/issues/325))
-
-
-
-<a name="v1.4.5"></a>
-### v1.4.5 (2015-10-06)
-
-
-#### Bug Fixes
-
-* fixes crash on invalid arg error ([c78ce128](https://github.com/kbknapp/clap-rs/commit/c78ce128ebbe7b8f730815f8176c29d76f4ade8c))
-
-
-
-<a name="v1.4.4"></a>
-### v1.4.4 (2015-10-06)
-
-
-#### Documentation
-
-* clean up some formatting ([b7df92d7](https://github.com/kbknapp/clap-rs/commit/b7df92d7ea25835701dd22ddff984b9749f48a00))
-* move the crate-level docs to top of the lib.rs file ([d7233bf1](https://github.com/kbknapp/clap-rs/commit/d7233bf122dbf80ba8fc79e5641be2df8af10e7a))
-* changes doc comments to rustdoc comments ([34b601be](https://github.com/kbknapp/clap-rs/commit/34b601be5fdde76c1a0859385b359b96d66b8732))
-* fixes panic in 14_groups example ([945b00a0](https://github.com/kbknapp/clap-rs/commit/945b00a0c27714b63bdca48d003fe205fcfdc578), closes [#295](https://github.com/kbknapp/clap-rs/issues/295))
-* avoid suggesting star dependencies. ([d33228f4](https://github.com/kbknapp/clap-rs/commit/d33228f40b5fefb84cf3dd51546bfb340dcd9f5a))
-* **Rustdoc:** adds portions of the readme to main rustdoc page ([6f9ee181](https://github.com/kbknapp/clap-rs/commit/6f9ee181e69d90bd4206290e59d6f3f1e8f0cbb2), closes [#293](https://github.com/kbknapp/clap-rs/issues/293))
-
-#### Bug Fixes
-
-* grammar error in some conflicting option errors ([e73b07e1](https://github.com/kbknapp/clap-rs/commit/e73b07e19474323ad2260da66abbf6a6d4ecbd4f))
-* **Unified Help:** sorts both flags and options as a unified category ([2a223dad](https://github.com/kbknapp/clap-rs/commit/2a223dad82901fa2e74baad3bfc4c7b94509300f))
-* **Usage:** fixes a bug where required args aren't filtered properly ([72b453dc](https://github.com/kbknapp/clap-rs/commit/72b453dc170af3050bb123d35364f6da77fc06d7), closes [#277](https://github.com/kbknapp/clap-rs/issues/277))
-* **Usage Strings:** fixes a bug ordering of elements in usage strings ([aaf0d6fe](https://github.com/kbknapp/clap-rs/commit/aaf0d6fe7aa2403e76096c16204d254a9ee61ee2), closes [#298](https://github.com/kbknapp/clap-rs/issues/298))
-
-#### Features
-
-* supports -aValue style options ([0e3733e4](https://github.com/kbknapp/clap-rs/commit/0e3733e4fec2015c2d566a51432dcd92cb69cad3))
-* **Trailing VarArg:** adds opt-in setting for final arg being vararg ([27018b18](https://github.com/kbknapp/clap-rs/commit/27018b1821a4bcd5235cfe92abe71b3c99efc24d), closes [#278](https://github.com/kbknapp/clap-rs/issues/278))
-
-
-
-<a name="v1.4.3"></a>
-### v1.4.3 (2015-09-30)
-
-
-#### Features
-
-* allows accessing arg values by group name ([c92a4b9e](https://github.com/kbknapp/clap-rs/commit/c92a4b9eff2d679957f61c0c41ff404b40d38a91))
-
-#### Documentation
-
-* use links to examples instead of plain text ([bb4fe237](https://github.com/kbknapp/clap-rs/commit/bb4fe237858535627271465147add537e4556b43))
-
-#### Bug Fixes
-
-* **Help Message:** required args no longer double list in usage ([1412e639](https://github.com/kbknapp/clap-rs/commit/1412e639e0a79df84936d1101a837f90077d1c83), closes [#277](https://github.com/kbknapp/clap-rs/issues/277))
-* **Possible Values:** possible value validation is restored ([f121ae74](https://github.com/kbknapp/clap-rs/commit/f121ae749f8f4bfe754ef2e8a6dfc286504b5b75), closes [#287](https://github.com/kbknapp/clap-rs/issues/287))
-
-
-
-<a name="v1.4.2"></a>
-### v1.4.2 (2015-09-23)
-
-
-#### Bug Fixes
-
-* **Conflicts:** fixes bug with conflicts not removing required args ([e17fcec5](https://github.com/kbknapp/clap-rs/commit/e17fcec53b3216ad047a13dddc6f740473fad1a1), closes [#271](https://github.com/kbknapp/clap-rs/issues/271))
-
-
-
-<a name="v1.4.1"></a>
-### v1.4.1 (2015-09-22)
-
-
-#### Examples
-
-* add clap_app quick example ([4ba6249c](https://github.com/kbknapp/clap-rs/commit/4ba6249c3cf4d2e083370d1fe4dcc7025282c28a))
-
-#### Features
-
-* **Unicode:** allows non-panicing on invalid unicode characters ([c5bf7ddc](https://github.com/kbknapp/clap-rs/commit/c5bf7ddc8cfb876ec928a5aaf5591232bbb32e5d))
-
-#### Documentation
-
-* properly names Examples section for rustdoc ([87ba5445](https://github.com/kbknapp/clap-rs/commit/87ba54451d7ec7b1c9b9ef134f90bbe39e6fac69))
-* fixes various typos and spelling ([f85640f9](https://github.com/kbknapp/clap-rs/commit/f85640f9f6d8fd3821a40e9b8b7a34fabb789d02))
-* **Arg:** unhides fields of the Arg struct ([931aea88](https://github.com/kbknapp/clap-rs/commit/931aea88427edf43a3da90d5a500c1ff2b2c3614))
-
-#### Bug Fixes
-
-* flush the buffer in App::print_version() ([cbc42a37](https://github.com/kbknapp/clap-rs/commit/cbc42a37d212d84d22b1777d08e584ff191934e7))
-* Macro benchmarks ([13712da1](https://github.com/kbknapp/clap-rs/commit/13712da1d36dc7614eec3a10ad488257ba615751))
-
-
-
-<a name="v1.4.0"></a>
-## v1.4.0 (2015-09-09)
-
-
-#### Features
-
-* allows printing help message by library consumers ([56b95f32](https://github.com/kbknapp/clap-rs/commit/56b95f320875c62dda82cb91b29059671e120ed1))
-* allows defining hidden args and subcmds ([2cab4d03](https://github.com/kbknapp/clap-rs/commit/2cab4d0334ea3c2439a1d4bfca5bf9905c7ea9ac), closes [#231](https://github.com/kbknapp/clap-rs/issues/231))
-* Builder macro to assist with App/Arg/Group/SubCommand building ([443841b0](https://github.com/kbknapp/clap-rs/commit/443841b012a8d795cd5c2bd69ae6e23ef9b16477))
-* **Errors:** allows consumers to write to stderr and exit on error ([1e6403b6](https://github.com/kbknapp/clap-rs/commit/1e6403b6a863574fa3cb6946b1fb58f034e8664c))
-
-
-
-<a name="v1.3.2"></a>
-### v1.3.2 (2015-09-08)
-
-
-#### Documentation
-
-* fixed ErrorKind docs ([dd057843](https://github.com/kbknapp/clap-rs/commit/dd05784327fa070eb6ce5ce89a8507e011d8db94))
-* **ErrorKind:** changed examples content ([b9ca2616](https://github.com/kbknapp/clap-rs/commit/b9ca261634b89613bbf3d98fd74d55cefbb31a8c))
-
-#### Bug Fixes
-
-* fixes a bug where the help subcommand wasn't overridable ([94003db4](https://github.com/kbknapp/clap-rs/commit/94003db4b5eebe552ca337521c1c001295822745))
-
-#### Features
-
-* adds abiltiy not consume self when parsing matches and/or exit on help ([94003db4](https://github.com/kbknapp/clap-rs/commit/94003db4b5eebe552ca337521c1c001295822745))
-* **App:** Added ability for users to handle errors themselves ([934e6fbb](https://github.com/kbknapp/clap-rs/commit/934e6fbb643b2385efc23444fe6fce31494dc288))
-
-
-
-<a name="v1.3.1"></a>
-### v1.3.1 (2015-09-04)
-
-
-#### Examples
-
-* **17_yaml:** fixed example ([9b848622](https://github.com/kbknapp/clap-rs/commit/9b848622296c8c5c7b9a39b93ddd41f51df790b5))
-
-#### Performance
-
-* changes ArgGroup HashSets to Vec ([3cb4a48e](https://github.com/kbknapp/clap-rs/commit/3cb4a48ebd15c20692f4f3a2a924284dc7fd5e10))
-* changes BTreeSet for Vec in some instances ([baab2e3f](https://github.com/kbknapp/clap-rs/commit/baab2e3f4060e811abee14b1654cbcd5cf3b5fea))
-
-
-
-<a name="v1.3.0"></a>
-## v1.3.0 (2015-09-01)
-
-
-#### Features
-
-* **YAML:** allows building a CLI from YAML files ([86cf4c45](https://github.com/kbknapp/clap-rs/commit/86cf4c45626a36b8115446952f9069f73c1debc3))
-* **ArgGroups:** adds support for building ArgGroups from yaml ([ecf88665](https://github.com/kbknapp/clap-rs/commit/ecf88665cbff367018b29161a1b75d44a212707d))
-* **Subcommands:** adds support for subcommands from yaml ([e415cf78](https://github.com/kbknapp/clap-rs/commit/e415cf78ba916052d118a8648deba2b9c16b1530))
-
-#### Documentation
-
-* **YAML:** adds examples for using YAML to build a CLI ([ab41d7f3](https://github.com/kbknapp/clap-rs/commit/ab41d7f38219544750e6e1426076dc498073191b))
-* **Args from YAML:** fixes doc examples ([19b348a1](https://github.com/kbknapp/clap-rs/commit/19b348a10050404cd93888dbbbe4f396681b67d0))
-* **Examples:** adds better usage examples instead of having unused variables ([8cbacd88](https://github.com/kbknapp/clap-rs/commit/8cbacd8883004fe71a8ea036ec4391c7dd8efe94))
-
-#### Examples
-
-* Add AppSettings example ([12705079](https://github.com/kbknapp/clap-rs/commit/12705079ca96a709b4dd94f7ddd20a833b26838c))
-
-#### Bug Fixes
-
-* **Unified Help Messages:** fixes a crash from this setting and no opts ([169ffec1](https://github.com/kbknapp/clap-rs/commit/169ffec1003d58d105d7ef2585b3425e57980000), closes [#210](https://github.com/kbknapp/clap-rs/issues/210))
-
-
-
-<a name="v1.2.5"></a>
-### v1.2.5 (2015-08-27)
-
-
-#### Examples
-
-* add custom validator example ([b9997d1f](https://github.com/kbknapp/clap-rs/commit/b9997d1fca74d4d8f93971f2a01bdf9798f913d5))
-* fix indentation ([d4f1b740](https://github.com/kbknapp/clap-rs/commit/d4f1b740ede410fd2528b9ecd89592c2fd8b1e20))
-
-#### Features
-
-* **Args:** allows opts and args to define a name for help and usage msgs ([ad962ec4](https://github.com/kbknapp/clap-rs/commit/ad962ec478da999c7dba0afdb84c266f4d09b1bd))
-
-
-
-<a name="v1.2.4"></a>
-### v1.2.4 (2015-08-26)
-
-
-#### Bug Fixes
-
-* **Possible Values:** fixes a bug where suggestions arent made when using --long=value format ([3d5e9a6c](https://github.com/kbknapp/clap-rs/commit/3d5e9a6cedb26668839b481c9978e2fbbab8be6f), closes [#192](https://github.com/kbknapp/clap-rs/issues/192))
-
-
-
-<a name="v1.2.3"></a>
-### v1.2.3 (2015-08-24)
-
-
-#### Bug Fixes
-
-* **App, Args:** fixed subcommand reqs negation ([b41afa8c](https://github.com/kbknapp/clap-rs/commit/b41afa8c3ded3d1be12f7a2f8ea06cc44afc9458), closes [#188](https://github.com/kbknapp/clap-rs/issues/188))
-
-
-
-<a name="v1.2.2"></a>
-### v1.2.2 (2015-08-23)
-
-
-#### Bug Fixes
-
-* fixed confusing error message, also added test for it ([fc7a31a7](https://github.com/kbknapp/clap-rs/commit/fc7a31a745efbf1768ee2c62cd3bb72bfe30c708))
-* **App:** fixed requirmets overriding ([9c135eb7](https://github.com/kbknapp/clap-rs/commit/9c135eb790fa16183e5bdb2009ddc3cf9e25f99f))
-
-
-
-<a name="v1.2.1"></a>
-### v1.2.1 (2015-08-20)
-
-
-#### Documentation
-
-* **README.md:** updates for new features ([16cf9245](https://github.com/kbknapp/clap-rs/commit/16cf9245fb5fc4cf6face898e358368bf9961cbb))
-
-#### Features
-
-* implements posix compatible conflicts for long args ([8c2d48ac](https://github.com/kbknapp/clap-rs/commit/8c2d48acf5473feebd721a9049a9c9b7051e70f9))
-* added overrides to support conflicts in POSIX compatible manner ([0b916a00](https://github.com/kbknapp/clap-rs/commit/0b916a00de26f6941538f6bc5f3365fa302083c1))
-* **Args:** allows defining POSIX compatible argument conflicts ([d715646e](https://github.com/kbknapp/clap-rs/commit/d715646e69759ccd95e01f49b04f489827ecf502))
-
-#### Bug Fixes
-
-* fixed links in cargo and license buttons ([6d9837ad](https://github.com/kbknapp/clap-rs/commit/6d9837ad9a9e006117cd7372fdc60f9a3889c7e2))
-
-#### Performance
-
-* **Args and Apps:** changes HashSet->Vec in some instances for increased performance ([d0c3b379](https://github.com/kbknapp/clap-rs/commit/d0c3b379700757e0a9b0c40af709f8af1f5b4949))
-
-
-
-<a name="v1.2.0"></a>
-### v1.2.0 (2015-08-15)
-
-
-#### Bug Fixes
-
-* fixed misspell and enum name ([7df170d7](https://github.com/kbknapp/clap-rs/commit/7df170d7f4ecff06608317655d1e0c4298f62076))
-* fixed use for clap crate ([dc3ada73](https://github.com/kbknapp/clap-rs/commit/dc3ada738667d4b689678f79d14251ee82004ece))
-
-#### Documentation
-
-* updates docs for new features ([03496547](https://github.com/kbknapp/clap-rs/commit/034965471782d872ca495045b58d34b31807c5b1))
-* fixed docs for previous changes ([ade36778](https://github.com/kbknapp/clap-rs/commit/ade367780c366425de462506d256e0f554ed3b9c))
-
-#### Improvements
-
-* **AppSettings:** adds ability to add multiple settings at once ([4a00e251](https://github.com/kbknapp/clap-rs/commit/4a00e2510d0ca8d095d5257d51691ba3b61c1374))
-
-#### Features
-
-* Replace application level settings with enum variants ([618dc4e2](https://github.com/kbknapp/clap-rs/commit/618dc4e2c205bf26bc43146164e65eb1f6b920ed))
-* **Args:** allows for custom argument value validations to be defined ([84ae2ddb](https://github.com/kbknapp/clap-rs/commit/84ae2ddbceda34b5cbda98a6959edaa52fde2e1a), closes [#170](https://github.com/kbknapp/clap-rs/issues/170))
-
-
-
-<a name="v1.1.6"></a>
-### v1.1.6 (2015-08-01)
-
-
-#### Bug Fixes
-
-* fixes two bugs in App when printing newlines in help and subcommands required error ([d63c0136](https://github.com/kbknapp/clap-rs/commit/d63c0136310db9dd2b1c7b4745938311601d8938))
-
-
-
-<a name="v1.1.5"></a>
-### v1.1.5 (2015-07-29)
-
-#### Performance
-
-* removes some unneeded allocations ([93e915df](https://github.com/kbknapp/clap-rs/commit/93e915dfe300f7b7d6209ca93323c6a46f89a8c1))
-
-<a name="v1.1.4"></a>
-### v1.1.4 (2015-07-20)
-
-
-#### Improvements
-
-* **Usage Strings** displays a [--] when it may be helpful ([86c3be85](https://github.com/kbknapp/clap-rs/commit/86c3be85fb6f77f83b5a6d2df40ae60937486984))
-
-#### Bug Fixes
-
-* **Macros** fixes a typo in a macro generated error message ([c9195c5f](https://github.com/kbknapp/clap-rs/commit/c9195c5f92abb8cd6a37b4f4fbb2f1fee2a8e368))
-* **Type Errors** fixes formatting of error output when failed type parsing ([fe5d95c6](https://github.com/kbknapp/clap-rs/commit/fe5d95c64f3296e6eddcbec0cb8b86659800145f))
-
-
-
-<a name="v1.1.3"></a>
-### v1.1.3 (2015-07-18)
-
-
-#### Documentation
-
-* updates README.md to include lack of color support on Windows ([52f81e17](https://github.com/kbknapp/clap-rs/commit/52f81e17377b18d2bd0f34693b642b7f358998ee))
-
-#### Bug Fixes
-
-* fixes formatting bug which prevented compiling on windows ([9cb5dceb](https://github.com/kbknapp/clap-rs/commit/9cb5dceb3e5fe5e0e7b24619ff77e5040672b723), closes [#163](https://github.com/kbknapp/clap-rs/issues/163))
-
-
-
-<a name="v1.1.2"></a>
-### v1.1.2 (2015-07-17)
-
-
-#### Bug Fixes
-
-* fixes a bug when parsing multiple {n} newlines inside help strings ([6d214b54](https://github.com/kbknapp/clap-rs/commit/6d214b549a9b7e189a94e5fa2b7c92cc333ca637))
-
-
-
-<a name="v1.1.1"></a>
-## v1.1.1 (2015-07-17)
-
-
-#### Bug Fixes
-
-* fixes a logic bug and allows setting Arg::number_of_values() < 2 ([42b6d1fc](https://github.com/kbknapp/clap-rs/commit/42b6d1fc3c519c92dfb3af15276e7d3b635e6cfe), closes [#161](https://github.com/kbknapp/clap-rs/issues/161))
-
-
-
-<a name="v1.1.0"></a>
-## v1.1.0 (2015-07-16)
-
-
-#### Features
-
-* allows creating unified help messages, a la docopt or getopts ([52bcd892](https://github.com/kbknapp/clap-rs/commit/52bcd892ea51564ce463bc5865acd64f8fe91cb1), closes [#158](https://github.com/kbknapp/clap-rs/issues/158))
-* allows stating all subcommands should *not* have --version flags ([336c476f](https://github.com/kbknapp/clap-rs/commit/336c476f631d512b54ac56fdca6f29ebdc2c00c5), closes [#156](https://github.com/kbknapp/clap-rs/issues/156))
-* allows setting version number to auto-propagate through subcommands ([bc66d3c6](https://github.com/kbknapp/clap-rs/commit/bc66d3c6deedeca62463fff95369ab1cfcdd366b), closes [#157](https://github.com/kbknapp/clap-rs/issues/157))
-
-#### Improvements
-
-* **Help Strings** properly aligns and handles newlines in long help strings ([f9800a29](https://github.com/kbknapp/clap-rs/commit/f9800a29696dd2cc0b0284bf693b3011831e556f), closes [#145](https://github.com/kbknapp/clap-rs/issues/145))
-
-
-#### Performance
-
-* **Help Messages** big performance improvements when printing help messages ([52bcd892](https://github.com/kbknapp/clap-rs/commit/52bcd892ea51564ce463bc5865acd64f8fe91cb1))
-
-#### Documentation
-
-* updates readme with new features ([8232f7bb](https://github.com/kbknapp/clap-rs/commit/8232f7bb52e88862bc13c3d4f99ee4f56cfe4bc0))
-* fix incorrect code example for `App::subcommand_required` ([8889689d](https://github.com/kbknapp/clap-rs/commit/8889689dc6336ccc45b2c9f2cf8e2e483a639e93))
-
-
-<a name="v1.0.3"></a>
-### v1.0.3 (2015-07-11)
-
-
-#### Improvements
-
-* **Errors** writes errors to stderr ([cc76ab8c](https://github.com/kbknapp/clap-rs/commit/cc76ab8c2b77c67b42f4717ded530df7806142cf), closes [#154](https://github.com/kbknapp/clap-rs/issues/154))
-
-#### Documentation
-
-* **README.md** updates example help message to new format ([0aca29bd](https://github.com/kbknapp/clap-rs/commit/0aca29bd5d6d1a4e9971bdc88d946ffa58606efa))
-
-
-
-<a name="v1.0.2"></a>
-### v1.0.2 (2015-07-09)
-
-
-#### Improvements
-
-* **Usage** re-orders optional arguments and required to natural standard ([dc7e1fce](https://github.com/kbknapp/clap-rs/commit/dc7e1fcea5c85d317018fb201d2a9262249131b4), closes [#147](https://github.com/kbknapp/clap-rs/issues/147))
-
-
-
-<a name="v1.0.1"></a>
-### v1.0.1 (2015-07-08)
-
-
-#### Bug Fixes
-
-* allows empty values when using --long='' syntax ([083f82d3](https://github.com/kbknapp/clap-rs/commit/083f82d333b69720a6ef30074875310921d964d1), closes [#151](https://github.com/kbknapp/clap-rs/issues/151))
-
-
-
-<a name="v1.0.0"></a>
-## v1.0.0 (2015-07-08)
-
-
-#### Documentation
-
-* **README.md** adds new features to what's new list ([938f7f01](https://github.com/kbknapp/clap-rs/commit/938f7f01340f521969376cf4e2e3d9436bca21f7))
-* **README.md** use with_name for subcommands ([28b7e316](https://github.com/kbknapp/clap-rs/commit/28b7e3161fb772e5309042648fe8c3a420645bac))
-
-#### Features
-
-* args can now be parsed from arbitrary locations, not just std::env::args() ([75312528](https://github.com/kbknapp/clap-rs/commit/753125282b1b9bfff875f1557ce27610edcc59e1))
-
-
-
-<a name="v1.0.0"></a>
-## v1.0.0-beta (2015-06-30)
-
-
-#### Features
-
-* allows waiting for user input on error ([d0da3bdd](https://github.com/kbknapp/clap-rs/commit/d0da3bdd9d1871541907ea9c645322a74d260e07), closes [#140](https://github.com/kbknapp/clap-rs/issues/140))
-* **Help** allows one to fully override the auto-generated help message ([26d5ae3e](https://github.com/kbknapp/clap-rs/commit/26d5ae3e330d1e150811d5b60b2b01a8f8df854e), closes [#141](https://github.com/kbknapp/clap-rs/issues/141))
-
-#### Documentation
-
-* adds "whats new" section to readme ([ff149a29](https://github.com/kbknapp/clap-rs/commit/ff149a29dd9e179865e6d577cd7dc87c54f8f95c))
-
-#### Improvements
-
-* removes deprecated functions in prep for 1.0 ([274484df](https://github.com/kbknapp/clap-rs/commit/274484dfd08fff4859cefd7e9bef3b73d3a9cb5f))
-
-
-
-<a name="v0.11.0"></a>
-## v0.11.0 (2015-06-17) - BREAKING CHANGE
-
-
-#### Documentation
-
-* updates docs to new version flag defaults ([ebf442eb](https://github.com/kbknapp/clap-rs/commit/ebf442ebebbcd2ec6bfe2c06566c9d362bccb112))
-
-#### Features
-
-* **Help and Version** default short for version is now `-V` but can be overridden (only breaks manual documentation) (**BREAKING CHANGE** [eb1d9320](https://github.com/kbknapp/clap-rs/commit/eb1d9320c509c1e4e57d7c7959da82bcfe06ada0))
-
-
-
-<a name="v0.10.5"></a>
-### v0.10.5 (2015-06-06)
-
-
-#### Bug Fixes
-
-* **Global Args** global arguments propogate fully now ([1f377960](https://github.com/kbknapp/clap-rs/commit/1f377960a48c82f54ca5f39eb56bcb393140b046), closes [#137](https://github.com/kbknapp/clap-rs/issues/137))
-
-
-
-<a name="v0.10.4"></a>
-### v0.10.4 (2015-06-06)
-
-
-#### Bug Fixes
-
-* **Global Args** global arguments propogate fully now ([8f2c0160](https://github.com/kbknapp/clap-rs/commit/8f2c0160c8d844daef375a33dbaec7d89de00a00), closes [#137](https://github.com/kbknapp/clap-rs/issues/137))
-
-
-
-<a name="v0.10.3"></a>
-### v0.10.3 (2015-05-31)
-
-
-#### Bug Fixes
-
-* **Global Args** fixes a bug where globals only transfer to one subcommand ([a37842ee](https://github.com/kbknapp/clap-rs/commit/a37842eec1ee3162b86fdbda23420b221cdb1e3b), closes [#135](https://github.com/kbknapp/clap-rs/issues/135))
-
-
-
-<a name="v0.10.2"></a>
-### v0.10.2 (2015-05-30)
-
-
-#### Improvements
-
-* **Binary Names** allows users to override the system determined bin name ([2191fe94](https://github.com/kbknapp/clap-rs/commit/2191fe94bda35771383b52872fb7f5421b178be1), closes [#134](https://github.com/kbknapp/clap-rs/issues/134))
-
-#### Documentation
-
-* adds contributing guidelines ([6f76bd0a](https://github.com/kbknapp/clap-rs/commit/6f76bd0a07e8b7419b391243ab2d6687cd8a9c5f))
-
-
-
-<a name="v0.10.1"></a>
-### v0.10.1 (2015-05-26)
-
-
-#### Features
-
-* can now specify that an app or subcommand should display help on no args or subcommands ([29ca7b2f](https://github.com/kbknapp/clap-rs/commit/29ca7b2f74376ca0cdb9d8ee3bfa99f7640cc404), closes [#133](https://github.com/kbknapp/clap-rs/issues/133))
-
-
-
-<a name="v0.10.0"></a>
-## v0.10.0 (2015-05-23)
-
-
-#### Features
-
-* **Global Args** allows args that propagate down to child commands ([2bcc6137](https://github.com/kbknapp/clap-rs/commit/2bcc6137a83cb07757771a0afea953e68e692f0b), closes [#131](https://github.com/kbknapp/clap-rs/issues/131))
-
-#### Improvements
-
-* **Colors** implements more structured colored output ([d6c3ed54](https://github.com/kbknapp/clap-rs/commit/d6c3ed54d21cf7b40d9f130d4280ff5448522fc5), closes [#129](https://github.com/kbknapp/clap-rs/issues/129))
-
-#### Deprecations
-
-* **SubCommand/App** several methods and functions for stable release ([28b73855](https://github.com/kbknapp/clap-rs/commit/28b73855523ad170544afdb20665db98702fbe70))
-
-#### Documentation
-
-* updates for deprecations and new features ([743eefe8](https://github.com/kbknapp/clap-rs/commit/743eefe8dd40c1260065ce086d572e9e9358bc4c))
-
-
-
-<a name="v0.9.2"></a>
-## v0.9.2 (2015-05-20)
-
-
-#### Bug Fixes
-
-* **help** allows parent requirements to be ignored with help and version ([52218cc1](https://github.com/kbknapp/clap-rs/commit/52218cc1fdb06a42456c964d98cc2c7ac3432412), closes [#124](https://github.com/kbknapp/clap-rs/issues/124))
-
-
-
-<a name="v0.9.1"></a>
-## v0.9.1 (2015-05-18)
-
-
-#### Bug Fixes
-
-* **help** fixes a bug where requirements are included as program name in help and version ([08ba3f25](https://github.com/kbknapp/clap-rs/commit/08ba3f25cf38b149229ba8b9cb37a5804fe6b789))
-
-
-
-<a name="v0.9.0"></a>
-## v0.9.0 (2015-05-17)
-
-
-#### Improvements
-
-* **usage** usage strings now include parent command requirements ([dd8f21c7](https://github.com/kbknapp/clap-rs/commit/dd8f21c7c15cde348fdcf44fa7c205f0e98d2e4a), closes [#125](https://github.com/kbknapp/clap-rs/issues/125))
-* **args** allows consumer of clap to decide if empty values are allowed or not ([ab4ec609](https://github.com/kbknapp/clap-rs/commit/ab4ec609ccf692b9b72cccef5c9f74f5577e360d), closes [#122](https://github.com/kbknapp/clap-rs/issues/122))
-
-#### Features
-
-* **subcommands**
- * allows optionally specifying that no subcommand is an error ([7554f238](https://github.com/kbknapp/clap-rs/commit/7554f238fd3afdd60b7e4dcf00ff4a9eccf842c1), closes [#126](https://github.com/kbknapp/clap-rs/issues/126))
- * subcommands can optionally negate parent requirements ([4a4229f5](https://github.com/kbknapp/clap-rs/commit/4a4229f500e21c350e1ef78dd09ef27559653288), closes [#123](https://github.com/kbknapp/clap-rs/issues/123))
-
-
-
-<a name="v0.8.6"></a>
-## v0.8.6 (2015-05-17)
-
-
-#### Bug Fixes
-
-* **args** `-` can now be parsed as a value for an argument ([bc12e78e](https://github.com/kbknapp/clap-rs/commit/bc12e78eadd7eaf9d008a8469fdd2dfd7990cb5d), closes [#121](https://github.com/kbknapp/clap-rs/issues/121))
-
-
-
-<a name="v0.8.5"></a>
-## v0.8.5 (2015-05-15)
-
-
-#### Bug Fixes
-
-* **macros** makes macro errors consistent with others ([0c264a8c](https://github.com/kbknapp/clap-rs/commit/0c264a8ca57ec1cfdcb74dae79145d766cdc9b97), closes [#118](https://github.com/kbknapp/clap-rs/issues/118))
-
-#### Features
-
-* **macros**
- * arg_enum! and simple_enum! provide a Vec<&str> of variant names ([30fa87ba](https://github.com/kbknapp/clap-rs/commit/30fa87ba4e0f3189351d8f4f78b72e616a30d0bd), closes [#119](https://github.com/kbknapp/clap-rs/issues/119))
- * arg_enum! and simple_enum! auto-implement Display ([d1219f0d](https://github.com/kbknapp/clap-rs/commit/d1219f0d1371d872061bd0718057eca4ef47b739), closes [#120](https://github.com/kbknapp/clap-rs/issues/120))
-
-
-
-<a name="v0.8.4"></a>
-## v0.8.4 (2015-05-12)
-
-
-#### Bug Fixes
-
-* **suggestions** --help and --version now get suggestions ([d2b3b1fa](https://github.com/kbknapp/clap-rs/commit/d2b3b1faa0bdc1c5d2350cc4635aba81e02e9d96), closes [#116](https://github.com/kbknapp/clap-rs/issues/116))
-
-
-
-<a name="v0.8.3"></a>
-## v0.8.3 (2015-05-10)
-
-
-#### Bug Fixes
-
-* **usage** groups unfold their members in usage strings ([55d15582](https://github.com/kbknapp/clap-rs/commit/55d155827ea4a6b077a83669701e797ce1ad68f4), closes [#114](https://github.com/kbknapp/clap-rs/issues/114))
-
-#### Performance
-
-* **usage** removes unneeded allocations ([fd53cd18](https://github.com/kbknapp/clap-rs/commit/fd53cd188555f5c3dc8bc341c5d7eb04b761a70f))
-
-
-
-<a name="v0.8.2"></a>
-## v0.8.2 (2015-05-08)
-
-
-#### Bug Fixes
-
-* **usage strings** positional arguments are presented in index order ([eb0e374e](https://github.com/kbknapp/clap-rs/commit/eb0e374ecf952f1eefbc73113f21e0705936e40b), closes [#112](https://github.com/kbknapp/clap-rs/issues/112))
-
-
-
-<a name="v0.8.1"></a>
-## v0.8.1 (2015-05-06)
-
-
-#### Bug Fixes
-
-* **subcommands** stops parsing multiple values when subcommands are found ([fc79017e](https://github.com/kbknapp/clap-rs/commit/fc79017eced04fd41cc1801331e5054df41fac17), closes [#109](https://github.com/kbknapp/clap-rs/issues/109))
-
-#### Improvements
-
-* **color** reduces color in error messages ([aab44cca](https://github.com/kbknapp/clap-rs/commit/aab44cca6352f47e280c296e50c535f5d752dd46), closes [#110](https://github.com/kbknapp/clap-rs/issues/110))
-* **suggestions** adds suggested arguments to usage strings ([99447414](https://github.com/kbknapp/clap-rs/commit/994474146e9fb8b701af773a52da71553d74d4b7))
-
-
-
-<a name="v0.8.0"></a>
-## v0.8.0 (2015-05-06)
-
-
-#### Bug Fixes
-
-* **did-you-mean** for review ([0535cfb0](https://github.com/kbknapp/clap-rs/commit/0535cfb0c711331568b4de8080eeef80bd254b68))
-* **Positional** positionals were ignored if they matched a subcmd, even after '--' ([90e7b081](https://github.com/kbknapp/clap-rs/commit/90e7b0818741668b47cbe3becd029bab588e3553))
-* **help** fixes bug where space between arg and help is too long ([632fb115](https://github.com/kbknapp/clap-rs/commit/632fb11514c504999ea86bdce47cdd34f8ebf646))
-
-#### Features
-
-* **from_usage** adds ability to add value names or num of vals in usage string ([3d581976](https://github.com/kbknapp/clap-rs/commit/3d58197674ed7886ca315efb76e411608a327501), closes [#98](https://github.com/kbknapp/clap-rs/issues/98))
-* **did-you-mean**
- * gate it behind 'suggestions' ([c0e38351](https://github.com/kbknapp/clap-rs/commit/c0e383515d01bdd5ca459af9c2f7e2cf49e2488b))
- * for possible values ([1cc2deb2](https://github.com/kbknapp/clap-rs/commit/1cc2deb29158e0e4e8b434e4ce26b3d819301a7d))
- * for long flags (i.e. --long) ([52a0b850](https://github.com/kbknapp/clap-rs/commit/52a0b8505c99354bdf5fd1cd256cf41197ac2d81))
- * for subcommands ([06e869b5](https://github.com/kbknapp/clap-rs/commit/06e869b5180258047ed3c60ba099de818dd25fff))
-* **Flags** adds sugestions functionality ([8745071c](https://github.com/kbknapp/clap-rs/commit/8745071c3257dd327c497013516f12a823df9530))
-* **errors** colorizes output red on error ([f8b26b13](https://github.com/kbknapp/clap-rs/commit/f8b26b13da82ba3ba9a932d3d1ab4ea45d1ab036))
-
-#### Improvements
-
-* **arg_enum** allows ascii case insensitivity for enum variants ([b249f965](https://github.com/kbknapp/clap-rs/commit/b249f9657c6921c004764bd80d13ebca81585eec), closes [#104](https://github.com/kbknapp/clap-rs/issues/104))
-* **clap-test** simplified `make test` invocation ([d17dcb29](https://github.com/kbknapp/clap-rs/commit/d17dcb2920637a1f58c61c596b7bd362fd53047c))
-
-#### Documentation
-
-* **README** adds details about optional and new features ([960389de](https://github.com/kbknapp/clap-rs/commit/960389de02c9872aaee9adabe86987f71f986e39))
-* **clap** fix typos caught by codespell ([8891d929](https://github.com/kbknapp/clap-rs/commit/8891d92917aa1a069cca67272be41b99e548356e))
-* **from_usage** explains new usage strings with multiple values ([05476fc6](https://github.com/kbknapp/clap-rs/commit/05476fc61cd1e5f4a4e750d258c878732a3a9c64))
-
-
-
-<a name="v0.7.6"></a>
-## v0.7.6 (2015-05-05)
-
-
-#### Improvements
-
-* **Options** adds number of values to options in help/usage ([c1c993c4](https://github.com/kbknapp/clap-rs/commit/c1c993c419d18e35c443785053d8de9a2ef88073))
-
-#### Features
-
-* **from_usage** adds ability to add value names or num of vals in usage string ([ad55748c](https://github.com/kbknapp/clap-rs/commit/ad55748c265cf27935c7b210307d2040b6a09125), closes [#98](https://github.com/kbknapp/clap-rs/issues/98))
-
-#### Bug Fixes
-
-* **MultipleValues** properly distinguishes between multiple values and multiple occurrences ([dd2a7564](https://github.com/kbknapp/clap-rs/commit/dd2a75640ca68a91b973faad15f04df891356cef), closes [#99](https://github.com/kbknapp/clap-rs/issues/99))
-* **help** fixes tab alignment with multiple values ([847001ff](https://github.com/kbknapp/clap-rs/commit/847001ff6d8f4d9518e810fefb8edf746dd0f31e))
-
-#### Documentation
-
-* **from_usage** explains new usage strings with multiple values ([5a3a42df](https://github.com/kbknapp/clap-rs/commit/5a3a42dfa3a783537f88dedc0fd5f0edcb8ea372))
-
-
-
-<a name="v0.7.5"></a>
-## v0.7.5 (2015-05-04)
-
-
-#### Bug Fixes
-
-* **Options** fixes bug where options with no value don't error out ([a1fb94be](https://github.com/kbknapp/clap-rs/commit/a1fb94be53141572ffd97aad037295d4ffec82d0))
-
-
-
-<a name="v0.7.4"></a>
-## v0.7.4 (2015-05-03)
-
-
-#### Bug Fixes
-
-* **Options** fixes a bug where option arguments in succession get their values skipped ([f66334d0](https://github.com/kbknapp/clap-rs/commit/f66334d0ce984e2b56e5c19abb1dd536fae9342a))
-
-
-
-<a name="v0.7.3"></a>
-## v0.7.3 (2015-05-03)
-
-
-#### Bug Fixes
-
-* **RequiredValues** fixes a bug where missing values are parsed as missing arguments ([93c4a723](https://github.com/kbknapp/clap-rs/commit/93c4a7231ba1a08152648598f7aa4503ea82e4de))
-
-#### Improvements
-
-* **ErrorMessages** improves error messages and corrections ([a29c3983](https://github.com/kbknapp/clap-rs/commit/a29c3983c4229906655a29146ec15a0e46dd942d))
-* **ArgGroups** improves requirement and confliction support for groups ([c236dc5f](https://github.com/kbknapp/clap-rs/commit/c236dc5ff475110d2a1b80e62903f80296163ad3))
-
-
-
-<a name="v0.7.2"></a>
-## v0.7.2 (2015-05-03)
-
-
-#### Bug Fixes
-
-* **RequiredArgs** fixes bug where required-by-default arguments are not listed in usage ([12aea961](https://github.com/kbknapp/clap-rs/commit/12aea9612d290845ba86515c240aeeb0a21198db), closes [#96](https://github.com/kbknapp/clap-rs/issues/96))
-
-
-
-<a name="v0.7.1"></a>
-## v0.7.1 (2015-05-01)
-
-
-#### Bug Fixes
-
-* **MultipleValues** stops evaluating values if the max or exact number of values was reached ([86d92c9f](https://github.com/kbknapp/clap-rs/commit/86d92c9fdbf9f422442e9562977bbaf268dbbae1))
-
-
-
-<a name="v0.7.0"></a>
-## v0.7.0 (2015-04-30) - BREAKING CHANGE
-
-
-#### Bug Fixes
-
-* **from_usage** removes bug where usage strings have no help text ([ad4e5451](https://github.com/kbknapp/clap-rs/commit/ad4e54510739aeabf75f0da3278fb0952db531b3), closes [#83](https://github.com/kbknapp/clap-rs/issues/83))
-
-#### Features
-
-* **MultipleValues**
- * add support for minimum and maximum number of values ([53f6b8c9](https://github.com/kbknapp/clap-rs/commit/53f6b8c9d8dc408b4fa9f833fc3a63683873c42f))
- * adds support limited number and named values ([ae09f05e](https://github.com/kbknapp/clap-rs/commit/ae09f05e92251c1b39a83d372736fcc7b504e432))
- * implement shorthand for options with multiple values ([6669f0a9](https://github.com/kbknapp/clap-rs/commit/6669f0a9687d4f668523145d7bd5c007d1eb59a8))
-* **arg** allow other types besides Vec for multiple value settings (**BREAKING CHANGE** [0cc2f698](https://github.com/kbknapp/clap-rs/commit/0cc2f69839b9b1db5d06330771b494783049a88e), closes [#87](https://github.com/kbknapp/clap-rs/issues/87))
-* **usage** implement smart usage strings on errors ([d77048ef](https://github.com/kbknapp/clap-rs/commit/d77048efb1e595ffe831f1a2bea2f2700db53b9f), closes [#88](https://github.com/kbknapp/clap-rs/issues/88))
-
-
-
-<a name="v0.6.9"></a>
-## v0.6.9 (2015-04-29)
-
-
-#### Bug Fixes
-
-* **from_usage** removes bug where usage strings have no help text ([ad4e5451](https://github.com/kbknapp/clap-rs/commit/ad4e54510739aeabf75f0da3278fb0952db531b3), closes [#83](https://github.com/kbknapp/clap-rs/issues/83))
-
-
-
-<a name="0.6.8"></a>
-## 0.6.8 (2015-04-27)
-
-
-#### Bug Fixes
-
-* **help** change long help --long=long -> --long <long> ([1e25abfc](https://github.com/kbknapp/clap-rs/commit/1e25abfc36679ab89eae71bf98ced4de81992d00))
-* **RequiredArgs** required by default args should no longer be required when their exclusions are present ([4bb4c3cc](https://github.com/kbknapp/clap-rs/commit/4bb4c3cc076b49e86720e882bf8c489877199f2d))
-
-#### Features
-
-* **ArgGroups** add ability to create arg groups ([09eb4d98](https://github.com/kbknapp/clap-rs/commit/09eb4d9893af40c347e50e2b717e1adef552357d))
-
-
-
-<a name="v0.6.7"></a>
-## v0.6.7 (2015-04-22)
-
-
-#### Bug Fixes
-
-* **from_usage** fix bug causing args to not be required ([b76129e9](https://github.com/kbknapp/clap-rs/commit/b76129e9b71a63365d5c77a7f57b58dbd1e94d49))
-
-#### Features
-
-* **apps** add ability to display additional help info after auto-gen'ed help msg ([65cc259e](https://github.com/kbknapp/clap-rs/commit/65cc259e4559cbe3653c865ec0c4b1e42a389b07))
-
-
-
-<a name="v0.6.6"></a>
-## v0.6.6 (2015-04-19)
-
-
-#### Bug Fixes
-
-* **from_usage** tabs and spaces should be treated equally ([4fd44181](https://github.com/kbknapp/clap-rs/commit/4fd44181d55d8eb88caab1e625231cfa3129e347))
-
-#### Features
-
-* **macros.rs** add macro to get version from Cargo.toml ([c630969a](https://github.com/kbknapp/clap-rs/commit/c630969aa3bbd386379219cae27ba1305b117f3e))
-
-
-
-<a name="v0.6.5"></a>
-## v0.6.5 (2015-04-19)
-
-
-#### Bug Fixes
-
-* **macros.rs** fix use statements for trait impls ([86e4075e](https://github.com/kbknapp/clap-rs/commit/86e4075eb111937c8a7bdb344e866e350429f042))
-
-
-
-<a name="v0.6.4"></a>
-## v0.6.4 (2015-04-17)
-
-
-#### Features
-
-* **macros** add ability to create enums pub or priv with derives ([2c499f80](https://github.com/kbknapp/clap-rs/commit/2c499f8015a199827cdf1fa3ec4f6f171722f8c7))
-
-
-
-<a name="v0.6.3"></a>
-## v0.6.3 (2015-04-16)
-
-
-#### Features
-
-* **macros** add macro to create custom enums to use as types ([fb672aff](https://github.com/kbknapp/clap-rs/commit/fb672aff561c29db2e343d6c607138f141aca8b6))
-
-
-
-<a name="v0.6.2"></a>
-## v0.6.2 (2015-04-14)
-
-
-#### Features
-
-* **macros**
- * add ability to get multiple typed values or exit ([0b87251f](https://github.com/kbknapp/clap-rs/commit/0b87251fc088234bee51c323c2b652d7254f7a59))
- * add ability to get a typed multiple values ([e243fe38](https://github.com/kbknapp/clap-rs/commit/e243fe38ddbbf845a46c0b9baebaac3778c80927))
- * add convenience macro to get a typed value or exit ([4b7cd3ea](https://github.com/kbknapp/clap-rs/commit/4b7cd3ea4947780d9daa39f3e1ddab53ad4c7fef))
- * add convenience macro to get a typed value ([8752700f](https://github.com/kbknapp/clap-rs/commit/8752700fbb30e89ee68adbce24489ae9a24d33a9))
-
-
-
-<a name="v0.6.1"></a>
-## v0.6.1 (2015-04-13)
-
-
-#### Bug Fixes
-
-* **from_usage** trim all whitespace before parsing ([91d29045](https://github.com/kbknapp/clap-rs/commit/91d2904599bd602deef2e515dfc65dc2863bdea0))
-
-
-
-<a name="v0.6.0"></a>
-## v0.6.0 (2015-04-13)
-
-
-#### Bug Fixes
-
-* **tests** fix failing doc tests ([3710cd69](https://github.com/kbknapp/clap-rs/commit/3710cd69162f87221a62464f63437c1ce843ad3c))
-
-#### Features
-
-* **app** add support for building args from usage strings ([d5d48bcf](https://github.com/kbknapp/clap-rs/commit/d5d48bcf463a4e494ef758836bd69a4c220bbbb5))
-* **args** add ability to create basic arguments from a usage string ([ab409a8f](https://github.com/kbknapp/clap-rs/commit/ab409a8f1db9e37cc70200f6f4a84a162692e618))
-
-
-
-<a name="v0.5.14"></a>
-## v0.5.14 (2015-04-10)
-
-
-#### Bug Fixes
-
-* **usage**
- * remove unneeded space ([51372789](https://github.com/kbknapp/clap-rs/commit/5137278942121bc2593ce6e5dc224ec2682549e6))
- * remove warning about unused variables ([ba817b9d](https://github.com/kbknapp/clap-rs/commit/ba817b9d815e37320650973f1bea0e7af3030fd7))
-
-#### Features
-
-* **usage** add ability to get usage string for subcommands too ([3636afc4](https://github.com/kbknapp/clap-rs/commit/3636afc401c2caa966efb5b1869ef4f1ed3384aa))
-
-
-
-<a name="v0.5.13"></a>
-## v0.5.13 (2015-04-09)
-
-
-#### Features
-
-* **SubCommands** add method to get name and subcommand matches together ([64e53928](https://github.com/kbknapp/clap-rs/commit/64e539280e23e567cf5de393b346eb0ca20e7eb5))
-* **ArgMatches** add method to get default usage string ([02462150](https://github.com/kbknapp/clap-rs/commit/02462150ca750bdc7012627d7e8d96379d494d7f))
-
-
-
-<a name="v0.5.12"></a>
-## v0.5.12 (2015-04-08)
-
-
-#### Features
-
-* **help** sort arguments by name so as to not display a random order ([f4b2bf57](https://github.com/kbknapp/clap-rs/commit/f4b2bf5767386013069fb74862e6e938dacf44d2))
-
-
-
-<a name="v0.5.11"></a>
-## v0.5.11 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **flags** fix bug not allowing users to specify -v or -h ([90e72cff](https://github.com/kbknapp/clap-rs/commit/90e72cffdee321b79eea7a2207119533540062b4))
-
-
-
-<a name="v0.5.10"></a>
-## v0.5.10 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **help** fix spacing when option argument has not long version ([ca17fa49](https://github.com/kbknapp/clap-rs/commit/ca17fa494b68e92da83ee364bf64b0687006824b))
-
-
-
-<a name="v0.5.9"></a>
-## v0.5.9 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **positional args** all previous positional args become required when a latter one is required ([c14c3f31](https://github.com/kbknapp/clap-rs/commit/c14c3f31fd557c165570b60911d8ee483d89d6eb), closes [#50](https://github.com/kbknapp/clap-rs/issues/50))
-* **clap** remove unstable features for Rust 1.0 ([9abdb438](https://github.com/kbknapp/clap-rs/commit/9abdb438e36e364d41550e7f5d44ebcaa8ee6b10))
-* **args** improve error messages for arguments with mutual exclusions ([18dbcf37](https://github.com/kbknapp/clap-rs/commit/18dbcf37024daf2b76ca099a6f118b53827aa339), closes [#51](https://github.com/kbknapp/clap-rs/issues/51))
-
-
-
-<a name="v0.5.8"></a>
-## v0.5.8 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **option args** fix bug in getting the wrong number of occurrences for options ([82ad6ad7](https://github.com/kbknapp/clap-rs/commit/82ad6ad77539cf9f9a03b78db466f575ebd972cc))
-* **help** fix formatting for option arguments with no long ([e8691004](https://github.com/kbknapp/clap-rs/commit/e869100423d93fa3acff03c4620cbcc0d0e790a1))
-* **flags** add assertion to catch flags with specific value sets ([a0a2a40f](https://github.com/kbknapp/clap-rs/commit/a0a2a40fed57f7c5ad9d68970d090e9856306c7d), closes [#52](https://github.com/kbknapp/clap-rs/issues/52))
-* **args** improve error messages for arguments with mutual exclusions ([bff945fc](https://github.com/kbknapp/clap-rs/commit/bff945fc5d03bba4266533340adcffb002508d1b), closes [#51](https://github.com/kbknapp/clap-rs/issues/51))
-* **tests** add missing .takes_value(true) to option2 ([bdb0e88f](https://github.com/kbknapp/clap-rs/commit/bdb0e88f696c8595c3def3bfb0e52d538c7be085))
-* **positional args** all previous positional args become required when a latter one is required ([343d47dc](https://github.com/kbknapp/clap-rs/commit/343d47dcbf83786a45c0d0f01b27fd9dd76725de), closes [#50](https://github.com/kbknapp/clap-rs/issues/50))
-
-
-
-<a name="v0.5.7"></a>
-## v0.5.7 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **args** fix bug in arguments who are required and mutually exclusive ([6ceb88a5](https://github.com/kbknapp/clap-rs/commit/6ceb88a594caae825605abc1cdad95204996bf29))
-
-
-
-<a name="v0.5.6"></a>
-## v0.5.6 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **help** fix formatting of help and usage ([28691b52](https://github.com/kbknapp/clap-rs/commit/28691b52f67e65c599e10e4ea2a0f6f9765a06b8))
-
-
-
-<a name="v0.5.5"></a>
-## v0.5.5 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **help** fix formatting of help for flags and options ([6ec10115](https://github.com/kbknapp/clap-rs/commit/6ec1011563a746f0578a93b76d45e63878e0f9a8))
-
-
-
-<a name="v0.5.4"></a>
-## v0.5.4 (2015-04-08)
-
-
-#### Features
-
-* **help** add '...' to indicate multiple values supported ([297ddba7](https://github.com/kbknapp/clap-rs/commit/297ddba77000e2228762ab0eca50b480f7467386))
-
-
-
-<a name="v0.5.3"></a>
-## v0.5.3 (2015-04-08)
-
-
-#### Features
-
-* **positionals**
- * add assertions for positional args with multiple vals ([b7fa72d4](https://github.com/kbknapp/clap-rs/commit/b7fa72d40f18806ec2042dd67a518401c2cf5681))
- * add support for multiple values ([80784009](https://github.com/kbknapp/clap-rs/commit/807840094109fbf90b348039ae22669ef27889ba))
-
-
-
-<a name="v0.5.2"></a>
-## v0.5.2 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **apps** allow use of hyphens in application and subcommand names ([da549dcb](https://github.com/kbknapp/clap-rs/commit/da549dcb6c7e0d773044ab17829744483a8b0f7f))
-
-
-
-<a name="v0.5.1"></a>
-## v0.5.1 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **args** determine if the only arguments allowed are also required ([0a09eb36](https://github.com/kbknapp/clap-rs/commit/0a09eb365ced9a03faf8ed24f083ef730acc90e8))
-
-
-
-<a name="v0.5.0"></a>
-## v0.5.0 (2015-04-08)
-
-
-#### Features
-
-* **args** add support for a specific set of allowed values on options or positional arguments ([270eb889](https://github.com/kbknapp/clap-rs/commit/270eb88925b6dc2881bff1f31ee344f085d31809))
-
-
-
-<a name="v0.4.18"></a>
-## v0.4.18 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **usage** display required args in usage, even if only required by others ([1b7316d4](https://github.com/kbknapp/clap-rs/commit/1b7316d4a8df70b0aa584ccbfd33f68966ad2a54))
-
-#### Features
-
-* **subcommands** properly list subcommands in help and usage ([4ee02344](https://github.com/kbknapp/clap-rs/commit/4ee023442abc3dba54b68138006a52b714adf331))
-
-
-
-<a name="v0.4.17"></a>
-## v0.4.17 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **tests** remove cargo test from claptests makefile ([1cf73817](https://github.com/kbknapp/clap-rs/commit/1cf73817d6fb1dccb5b6a23b46c2efa8b567ad62))
-
-
-
-<a name="v0.4.16"></a>
-## v0.4.16 (2015-04-08)
-
-
-#### Bug Fixes
-
-* **option** fix bug with option occurrence values ([9af52e93](https://github.com/kbknapp/clap-rs/commit/9af52e93cef9e17ac9974963f132013d0b97b946))
-* **tests** fix testing script bug and formatting ([d8f03a55](https://github.com/kbknapp/clap-rs/commit/d8f03a55c4f74d126710ee06aad5a667246a8001))
-
-#### Features
-
-* **arg** allow lifetimes other than 'static in arguments ([9e8c1fb9](https://github.com/kbknapp/clap-rs/commit/9e8c1fb9406f8448873ca58bab07fe905f1551e5))
diff --git a/clap/CONTRIBUTORS.md b/clap/CONTRIBUTORS.md
deleted file mode 100644
index f0fd777..0000000
--- a/clap/CONTRIBUTORS.md
+++ /dev/null
@@ -1,91 +0,0 @@
-the following is a list of contributors:
-
-
-[<img alt="kbknapp" src="https://avatars1.githubusercontent.com/u/6942134?v=4&s=117" width="117">](https://github.com/kbknapp) |[<img alt="homu" src="https://avatars1.githubusercontent.com/u/10212162?v=4&s=117" width="117">](https://github.com/homu) |[<img alt="Vinatorul" src="https://avatars1.githubusercontent.com/u/6770624?v=4&s=117" width="117">](https://github.com/Vinatorul) |[<img alt="tormol" src="https://avatars3.githubusercontent.com/u/10460821?v=4&s=117" width="117">](https://github.com/tormol) |[<img alt="willmurphyscode" src="https://avatars3.githubusercontent.com/u/12529630?v=4&s=117" width="117">](https://github.com/willmurphyscode) |[<img alt="little-dude" src="https://avatars2.githubusercontent.com/u/6646324?v=4&s=117" width="117">](https://github.com/little-dude) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[kbknapp](https://github.com/kbknapp) |[homu](https://github.com/homu) |[Vinatorul](https://github.com/Vinatorul) |[tormol](https://github.com/tormol) |[willmurphyscode](https://github.com/willmurphyscode) |[little-dude](https://github.com/little-dude) |
-
-[<img alt="sru" src="https://avatars3.githubusercontent.com/u/2485892?v=4&s=117" width="117">](https://github.com/sru) |[<img alt="mgeisler" src="https://avatars0.githubusercontent.com/u/89623?v=4&s=117" width="117">](https://github.com/mgeisler) |[<img alt="nabijaczleweli" src="https://avatars3.githubusercontent.com/u/6709544?v=4&s=117" width="117">](https://github.com/nabijaczleweli) |[<img alt="Byron" src="https://avatars2.githubusercontent.com/u/63622?v=4&s=117" width="117">](https://github.com/Byron) |[<img alt="hgrecco" src="https://avatars0.githubusercontent.com/u/278566?v=4&s=117" width="117">](https://github.com/hgrecco) |[<img alt="bluejekyll" src="https://avatars3.githubusercontent.com/u/986845?v=4&s=117" width="117">](https://github.com/bluejekyll) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[sru](https://github.com/sru) |[mgeisler](https://github.com/mgeisler) |[nabijaczleweli](https://github.com/nabijaczleweli) |[Byron](https://github.com/Byron) |[hgrecco](https://github.com/hgrecco) |[bluejekyll](https://github.com/bluejekyll) |
-
-[<img alt="segevfiner" src="https://avatars0.githubusercontent.com/u/24731903?v=4&s=117" width="117">](https://github.com/segevfiner) |[<img alt="ignatenkobrain" src="https://avatars1.githubusercontent.com/u/2866862?v=4&s=117" width="117">](https://github.com/ignatenkobrain) |[<img alt="james-darkfox" src="https://avatars3.githubusercontent.com/u/637155?v=4&s=117" width="117">](https://github.com/james-darkfox) |[<img alt="H2CO3" src="https://avatars2.githubusercontent.com/u/742370?v=4&s=117" width="117">](https://github.com/H2CO3) |[<img alt="nateozem" src="https://avatars2.githubusercontent.com/u/22719441?v=4&s=117" width="117">](https://github.com/nateozem) |[<img alt="glowing-chemist" src="https://avatars0.githubusercontent.com/u/17074682?v=4&s=117" width="117">](https://github.com/glowing-chemist) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[segevfiner](https://github.com/segevfiner) |[ignatenkobrain](https://github.com/ignatenkobrain) |[james-darkfox](https://github.com/james-darkfox) |[H2CO3](https://github.com/H2CO3) |[nateozem](https://github.com/nateozem) |[glowing-chemist](https://github.com/glowing-chemist) |
-
-[<img alt="discosultan" src="https://avatars1.githubusercontent.com/u/2970736?v=4&s=117" width="117">](https://github.com/discosultan) |[<img alt="rtaycher" src="https://avatars0.githubusercontent.com/u/324733?v=4&s=117" width="117">](https://github.com/rtaycher) |[<img alt="Arnavion" src="https://avatars2.githubusercontent.com/u/1096010?v=4&s=117" width="117">](https://github.com/Arnavion) |[<img alt="japaric" src="https://avatars3.githubusercontent.com/u/5018213?v=4&s=117" width="117">](https://github.com/japaric) |[<img alt="untitaker" src="https://avatars0.githubusercontent.com/u/837573?v=4&s=117" width="117">](https://github.com/untitaker) |[<img alt="afiune" src="https://avatars0.githubusercontent.com/u/5712253?v=4&s=117" width="117">](https://github.com/afiune) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[discosultan](https://github.com/discosultan) |[rtaycher](https://github.com/rtaycher) |[Arnavion](https://github.com/Arnavion) |[japaric](https://github.com/japaric) |[untitaker](https://github.com/untitaker) |[afiune](https://github.com/afiune) |
-
-[<img alt="crazymerlyn" src="https://avatars1.githubusercontent.com/u/6919679?v=4&s=117" width="117">](https://github.com/crazymerlyn) |[<img alt="SuperFluffy" src="https://avatars0.githubusercontent.com/u/701177?v=4&s=117" width="117">](https://github.com/SuperFluffy) |[<img alt="matthiasbeyer" src="https://avatars0.githubusercontent.com/u/427866?v=4&s=117" width="117">](https://github.com/matthiasbeyer) |[<img alt="malbarbo" src="https://avatars3.githubusercontent.com/u/1678126?v=4&s=117" width="117">](https://github.com/malbarbo) |[<img alt="tshepang" src="https://avatars0.githubusercontent.com/u/588486?v=4&s=117" width="117">](https://github.com/tshepang) |[<img alt="golem131" src="https://avatars3.githubusercontent.com/u/2429587?v=4&s=117" width="117">](https://github.com/golem131) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[crazymerlyn](https://github.com/crazymerlyn) |[SuperFluffy](https://github.com/SuperFluffy) |[matthiasbeyer](https://github.com/matthiasbeyer) |[malbarbo](https://github.com/malbarbo) |[tshepang](https://github.com/tshepang) |[golem131](https://github.com/golem131) |
-
-[<img alt="jimmycuadra" src="https://avatars2.githubusercontent.com/u/122457?v=4&s=117" width="117">](https://github.com/jimmycuadra) |[<img alt="Nemo157" src="https://avatars1.githubusercontent.com/u/81079?v=4&s=117" width="117">](https://github.com/Nemo157) |[<img alt="severen" src="https://avatars1.githubusercontent.com/u/4061736?v=4&s=117" width="117">](https://github.com/severen) |[<img alt="Eijebong" src="https://avatars2.githubusercontent.com/u/3650385?v=4&s=117" width="117">](https://github.com/Eijebong) |[<img alt="cstorey" src="https://avatars3.githubusercontent.com/u/743059?v=4&s=117" width="117">](https://github.com/cstorey) |[<img alt="wdv4758h" src="https://avatars1.githubusercontent.com/u/2716047?v=4&s=117" width="117">](https://github.com/wdv4758h) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[jimmycuadra](https://github.com/jimmycuadra) |[Nemo157](https://github.com/Nemo157) |[severen](https://github.com/severen) |[Eijebong](https://github.com/Eijebong) |[cstorey](https://github.com/cstorey) |[wdv4758h](https://github.com/wdv4758h) |
-
-[<img alt="frewsxcv" src="https://avatars2.githubusercontent.com/u/416575?v=4&s=117" width="117">](https://github.com/frewsxcv) |[<img alt="hoodie" src="https://avatars1.githubusercontent.com/u/260370?v=4&s=117" width="117">](https://github.com/hoodie) |[<img alt="huonw" src="https://avatars1.githubusercontent.com/u/1203825?v=4&s=117" width="117">](https://github.com/huonw) |[<img alt="GrappigPanda" src="https://avatars0.githubusercontent.com/u/2055372?v=4&s=117" width="117">](https://github.com/GrappigPanda) |[<img alt="shepmaster" src="https://avatars0.githubusercontent.com/u/174509?v=4&s=117" width="117">](https://github.com/shepmaster) |[<img alt="starkat99" src="https://avatars1.githubusercontent.com/u/8295111?v=4&s=117" width="117">](https://github.com/starkat99) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[frewsxcv](https://github.com/frewsxcv) |[hoodie](https://github.com/hoodie) |[huonw](https://github.com/huonw) |[GrappigPanda](https://github.com/GrappigPanda) |[shepmaster](https://github.com/shepmaster) |[starkat99](https://github.com/starkat99) |
-
-[<img alt="porglezomp" src="https://avatars1.githubusercontent.com/u/1690225?v=4&s=117" width="117">](https://github.com/porglezomp) |[<img alt="kraai" src="https://avatars1.githubusercontent.com/u/552646?v=4&s=117" width="117">](https://github.com/kraai) |[<img alt="musoke" src="https://avatars0.githubusercontent.com/u/16665084?v=4&s=117" width="117">](https://github.com/musoke) |[<img alt="nelsonjchen" src="https://avatars1.githubusercontent.com/u/5363?v=4&s=117" width="117">](https://github.com/nelsonjchen) |[<img alt="pkgw" src="https://avatars0.githubusercontent.com/u/59598?v=4&s=117" width="117">](https://github.com/pkgw) |[<img alt="Deedasmi" src="https://avatars0.githubusercontent.com/u/5093293?v=4&s=117" width="117">](https://github.com/Deedasmi) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[porglezomp](https://github.com/porglezomp) |[kraai](https://github.com/kraai) |[musoke](https://github.com/musoke) |[nelsonjchen](https://github.com/nelsonjchen) |[pkgw](https://github.com/pkgw) |[Deedasmi](https://github.com/Deedasmi) |
-
-[<img alt="vmchale" src="https://avatars1.githubusercontent.com/u/13259982?v=4&s=117" width="117">](https://github.com/vmchale) |[<img alt="etopiei" src="https://avatars3.githubusercontent.com/u/17671663?v=4&s=117" width="117">](https://github.com/etopiei) |[<img alt="messense" src="https://avatars0.githubusercontent.com/u/1556054?v=4&s=117" width="117">](https://github.com/messense) |[<img alt="Keats" src="https://avatars2.githubusercontent.com/u/680355?v=4&s=117" width="117">](https://github.com/Keats) |[<img alt="kieraneglin" src="https://avatars0.githubusercontent.com/u/569917?v=4&s=117" width="117">](https://github.com/kieraneglin) |[<img alt="durka" src="https://avatars3.githubusercontent.com/u/47007?v=4&s=117" width="117">](https://github.com/durka) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[vmchale](https://github.com/vmchale) |[etopiei](https://github.com/etopiei) |[messense](https://github.com/messense) |[Keats](https://github.com/Keats) |[kieraneglin](https://github.com/kieraneglin) |[durka](https://github.com/durka) |
-
-[<img alt="alex-gulyas" src="https://avatars0.githubusercontent.com/u/8698329?v=4&s=117" width="117">](https://github.com/alex-gulyas) |[<img alt="cite-reader" src="https://avatars1.githubusercontent.com/u/4196987?v=4&s=117" width="117">](https://github.com/cite-reader) |[<img alt="alexbool" src="https://avatars3.githubusercontent.com/u/1283792?v=4&s=117" width="117">](https://github.com/alexbool) |[<img alt="AluisioASG" src="https://avatars2.githubusercontent.com/u/1904165?v=4&s=117" width="117">](https://github.com/AluisioASG) |[<img alt="BurntSushi" src="https://avatars3.githubusercontent.com/u/456674?v=4&s=117" width="117">](https://github.com/BurntSushi) |[<img alt="AndrewGaspar" src="https://avatars1.githubusercontent.com/u/2292643?v=4&s=117" width="117">](https://github.com/AndrewGaspar) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[alex-gulyas](https://github.com/alex-gulyas) |[cite-reader](https://github.com/cite-reader) |[alexbool](https://github.com/alexbool) |[AluisioASG](https://github.com/AluisioASG) |[BurntSushi](https://github.com/BurntSushi) |[AndrewGaspar](https://github.com/AndrewGaspar) |
-
-[<img alt="nox" src="https://avatars0.githubusercontent.com/u/123095?v=4&s=117" width="117">](https://github.com/nox) |[<img alt="mitsuhiko" src="https://avatars1.githubusercontent.com/u/7396?v=4&s=117" width="117">](https://github.com/mitsuhiko) |[<img alt="pixelistik" src="https://avatars1.githubusercontent.com/u/170929?v=4&s=117" width="117">](https://github.com/pixelistik) |[<img alt="ogham" src="https://avatars3.githubusercontent.com/u/503760?v=4&s=117" width="117">](https://github.com/ogham) |[<img alt="Bilalh" src="https://avatars0.githubusercontent.com/u/171602?v=4&s=117" width="117">](https://github.com/Bilalh) |[<img alt="dotdash" src="https://avatars1.githubusercontent.com/u/230962?v=4&s=117" width="117">](https://github.com/dotdash) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[nox](https://github.com/nox) |[mitsuhiko](https://github.com/mitsuhiko) |[pixelistik](https://github.com/pixelistik) |[ogham](https://github.com/ogham) |[Bilalh](https://github.com/Bilalh) |[dotdash](https://github.com/dotdash) |
-
-[<img alt="bradurani" src="https://avatars0.githubusercontent.com/u/4195952?v=4&s=117" width="117">](https://github.com/bradurani) |[<img alt="Seeker14491" src="https://avatars2.githubusercontent.com/u/6490497?v=4&s=117" width="117">](https://github.com/Seeker14491) |[<img alt="brianp" src="https://avatars1.githubusercontent.com/u/179134?v=4&s=117" width="117">](https://github.com/brianp) |[<img alt="cldershem" src="https://avatars3.githubusercontent.com/u/201608?v=4&s=117" width="117">](https://github.com/cldershem) |[<img alt="casey" src="https://avatars2.githubusercontent.com/u/1945?v=4&s=117" width="117">](https://github.com/casey) |[<img alt="volks73" src="https://avatars1.githubusercontent.com/u/1915469?v=4&s=117" width="117">](https://github.com/volks73) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[bradurani](https://github.com/bradurani) |[Seeker14491](https://github.com/Seeker14491) |[brianp](https://github.com/brianp) |[cldershem](https://github.com/cldershem) |[casey](https://github.com/casey) |[volks73](https://github.com/volks73) |
-
-[<img alt="daboross" src="https://avatars1.githubusercontent.com/u/1152146?v=4&s=117" width="117">](https://github.com/daboross) |[<img alt="da-x" src="https://avatars1.githubusercontent.com/u/321273?v=4&s=117" width="117">](https://github.com/da-x) |[<img alt="mernen" src="https://avatars0.githubusercontent.com/u/6412?v=4&s=117" width="117">](https://github.com/mernen) |[<img alt="dguo" src="https://avatars0.githubusercontent.com/u/2763135?v=4&s=117" width="117">](https://github.com/dguo) |[<img alt="davidszotten" src="https://avatars3.githubusercontent.com/u/412005?v=4&s=117" width="117">](https://github.com/davidszotten) |[<img alt="drusellers" src="https://avatars1.githubusercontent.com/u/63355?v=4&s=117" width="117">](https://github.com/drusellers) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[daboross](https://github.com/daboross) |[da-x](https://github.com/da-x) |[mernen](https://github.com/mernen) |[dguo](https://github.com/dguo) |[davidszotten](https://github.com/davidszotten) |[drusellers](https://github.com/drusellers) |
-
-[<img alt="eddyb" src="https://avatars2.githubusercontent.com/u/77424?v=4&s=117" width="117">](https://github.com/eddyb) |[<img alt="Enet4" src="https://avatars0.githubusercontent.com/u/4738426?v=4&s=117" width="117">](https://github.com/Enet4) |[<img alt="Fraser999" src="https://avatars3.githubusercontent.com/u/190532?v=4&s=117" width="117">](https://github.com/Fraser999) |[<img alt="birkenfeld" src="https://avatars0.githubusercontent.com/u/144359?v=4&s=117" width="117">](https://github.com/birkenfeld) |[<img alt="guanqun" src="https://avatars0.githubusercontent.com/u/53862?v=4&s=117" width="117">](https://github.com/guanqun) |[<img alt="tanakh" src="https://avatars2.githubusercontent.com/u/109069?v=4&s=117" width="117">](https://github.com/tanakh) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[eddyb](https://github.com/eddyb) |[Enet4](https://github.com/Enet4) |[Fraser999](https://github.com/Fraser999) |[birkenfeld](https://github.com/birkenfeld) |[guanqun](https://github.com/guanqun) |[tanakh](https://github.com/tanakh) |
-
-[<img alt="SirVer" src="https://avatars0.githubusercontent.com/u/140115?v=4&s=117" width="117">](https://github.com/SirVer) |[<img alt="idmit" src="https://avatars1.githubusercontent.com/u/2546728?v=4&s=117" width="117">](https://github.com/idmit) |[<img alt="archer884" src="https://avatars1.githubusercontent.com/u/679494?v=4&s=117" width="117">](https://github.com/archer884) |[<img alt="jacobmischka" src="https://avatars1.githubusercontent.com/u/3939997?v=4&s=117" width="117">](https://github.com/jacobmischka) |[<img alt="jespino" src="https://avatars0.githubusercontent.com/u/290303?v=4&s=117" width="117">](https://github.com/jespino) |[<img alt="jfrankenau" src="https://avatars3.githubusercontent.com/u/2736480?v=4&s=117" width="117">](https://github.com/jfrankenau) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[SirVer](https://github.com/SirVer) |[idmit](https://github.com/idmit) |[archer884](https://github.com/archer884) |[jacobmischka](https://github.com/jacobmischka) |[jespino](https://github.com/jespino) |[jfrankenau](https://github.com/jfrankenau) |
-
-[<img alt="jtdowney" src="https://avatars1.githubusercontent.com/u/44654?v=4&s=117" width="117">](https://github.com/jtdowney) |[<img alt="andete" src="https://avatars2.githubusercontent.com/u/689017?v=4&s=117" width="117">](https://github.com/andete) |[<img alt="joshtriplett" src="https://avatars2.githubusercontent.com/u/162737?v=4&s=117" width="117">](https://github.com/joshtriplett) |[<img alt="Kalwyn" src="https://avatars3.githubusercontent.com/u/22778640?v=4&s=117" width="117">](https://github.com/Kalwyn) |[<img alt="manuel-rhdt" src="https://avatars1.githubusercontent.com/u/3199013?v=4&s=117" width="117">](https://github.com/manuel-rhdt) |[<img alt="Marwes" src="https://avatars3.githubusercontent.com/u/957312?v=4&s=117" width="117">](https://github.com/Marwes) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[jtdowney](https://github.com/jtdowney) |[andete](https://github.com/andete) |[joshtriplett](https://github.com/joshtriplett) |[Kalwyn](https://github.com/Kalwyn) |[manuel-rhdt](https://github.com/manuel-rhdt) |[Marwes](https://github.com/Marwes) |
-
-[<img alt="mdaffin" src="https://avatars1.githubusercontent.com/u/171232?v=4&s=117" width="117">](https://github.com/mdaffin) |[<img alt="iliekturtles" src="https://avatars3.githubusercontent.com/u/5081378?v=4&s=117" width="117">](https://github.com/iliekturtles) |[<img alt="nicompte" src="https://avatars2.githubusercontent.com/u/439369?v=4&s=117" width="117">](https://github.com/nicompte) |[<img alt="NickeZ" src="https://avatars2.githubusercontent.com/u/492753?v=4&s=117" width="117">](https://github.com/NickeZ) |[<img alt="nvzqz" src="https://avatars0.githubusercontent.com/u/10367662?v=4&s=117" width="117">](https://github.com/nvzqz) |[<img alt="nuew" src="https://avatars2.githubusercontent.com/u/26099511?v=4&s=117" width="117">](https://github.com/nuew) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[mdaffin](https://github.com/mdaffin) |[iliekturtles](https://github.com/iliekturtles) |[nicompte](https://github.com/nicompte) |[NickeZ](https://github.com/NickeZ) |[nvzqz](https://github.com/nvzqz) |[nuew](https://github.com/nuew) |
-
-[<img alt="Geogi" src="https://avatars1.githubusercontent.com/u/1818316?v=4&s=117" width="117">](https://github.com/Geogi) |[<img alt="focusaurus" src="https://avatars1.githubusercontent.com/u/482377?v=4&s=117" width="117">](https://github.com/focusaurus) |[<img alt="flying-sheep" src="https://avatars0.githubusercontent.com/u/291575?v=4&s=117" width="117">](https://github.com/flying-sheep) |[<img alt="Phlosioneer" src="https://avatars2.githubusercontent.com/u/4657718?v=4&s=117" width="117">](https://github.com/Phlosioneer) |[<img alt="peppsac" src="https://avatars3.githubusercontent.com/u/2198295?v=4&s=117" width="117">](https://github.com/peppsac) |[<img alt="golddranks" src="https://avatars1.githubusercontent.com/u/2675542?v=4&s=117" width="117">](https://github.com/golddranks) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[Geogi](https://github.com/Geogi) |[focusaurus](https://github.com/focusaurus) |[flying-sheep](https://github.com/flying-sheep) |[Phlosioneer](https://github.com/Phlosioneer) |[peppsac](https://github.com/peppsac) |[golddranks](https://github.com/golddranks) |
-
-[<img alt="hexjelly" src="https://avatars0.githubusercontent.com/u/435283?v=4&s=117" width="117">](https://github.com/hexjelly) |[<img alt="rom1v" src="https://avatars1.githubusercontent.com/u/543275?v=4&s=117" width="117">](https://github.com/rom1v) |[<img alt="rnelson" src="https://avatars3.githubusercontent.com/u/118361?v=4&s=117" width="117">](https://github.com/rnelson) |[<img alt="swatteau" src="https://avatars3.githubusercontent.com/u/5521255?v=4&s=117" width="117">](https://github.com/swatteau) |[<img alt="tchajed" src="https://avatars3.githubusercontent.com/u/1255037?v=4&s=117" width="117">](https://github.com/tchajed) |[<img alt="tspiteri" src="https://avatars0.githubusercontent.com/u/18604588?v=4&s=117" width="117">](https://github.com/tspiteri) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[hexjelly](https://github.com/hexjelly) |[rom1v](https://github.com/rom1v) |[rnelson](https://github.com/rnelson) |[swatteau](https://github.com/swatteau) |[tchajed](https://github.com/tchajed) |[tspiteri](https://github.com/tspiteri) |
-
-[<img alt="siiptuo" src="https://avatars0.githubusercontent.com/u/10729330?v=4&s=117" width="117">](https://github.com/siiptuo) |[<img alt="vks" src="https://avatars2.githubusercontent.com/u/33460?v=4&s=117" width="117">](https://github.com/vks) |[<img alt="vsupalov" src="https://avatars2.githubusercontent.com/u/2801030?v=4&s=117" width="117">](https://github.com/vsupalov) |[<img alt="mineo" src="https://avatars1.githubusercontent.com/u/78236?v=4&s=117" width="117">](https://github.com/mineo) |[<img alt="wabain" src="https://avatars3.githubusercontent.com/u/7651435?v=4&s=117" width="117">](https://github.com/wabain) |[<img alt="grossws" src="https://avatars2.githubusercontent.com/u/171284?v=4&s=117" width="117">](https://github.com/grossws) |
-:---: |:---: |:---: |:---: |:---: |:---: |
-[siiptuo](https://github.com/siiptuo) |[vks](https://github.com/vks) |[vsupalov](https://github.com/vsupalov) |[mineo](https://github.com/mineo) |[wabain](https://github.com/wabain) |[grossws](https://github.com/grossws) |
-
-[<img alt="kennytm" src="https://avatars1.githubusercontent.com/u/103023?v=4&s=117" width="117">](https://github.com/kennytm) |[<img alt="king6cong" src="https://avatars3.githubusercontent.com/u/302560?v=4&s=117" width="117">](https://github.com/king6cong) |[<img alt="mvaude" src="https://avatars1.githubusercontent.com/u/9532611?v=4&s=117" width="117">](https://github.com/mvaude) |[<img alt="panicbit" src="https://avatars2.githubusercontent.com/u/628445?v=4&s=117" width="117">](https://github.com/panicbit) |[<img alt="brennie" src="https://avatars3.githubusercontent.com/u/156585?v=4&s=117" width="117">](https://github.com/brennie) |
-:---: |:---: |:---: |:---: |:---: |
-[kennytm](https://github.com/kennytm) |[king6cong](https://github.com/king6cong) |[mvaude](https://github.com/mvaude) |[panicbit](https://github.com/panicbit) |[brennie](https://github.com/brennie) |
-
-
-
-
-This list was generated by [mgechev/github-contributors-list](https://github.com/mgechev/github-contributors-list)
diff --git a/clap/Cargo.toml b/clap/Cargo.toml
deleted file mode 100644
index 47498c1..0000000
--- a/clap/Cargo.toml
+++ /dev/null
@@ -1,91 +0,0 @@
-[package]
-
-name = "clap"
-version = "2.33.0"
-authors = ["Kevin K. <kbknapp@gmail.com>"]
-exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"]
-repository = "https://github.com/clap-rs/clap"
-documentation = "https://docs.rs/clap/"
-homepage = "https://clap.rs/"
-readme = "README.md"
-license = "MIT"
-keywords = ["argument", "cli", "arg", "parser", "parse"]
-categories = ["command-line-interface"]
-description = """
-A simple to use, efficient, and full-featured Command Line Argument Parser
-"""
-
-[badges]
-travis-ci = { repository = "clap-rs/clap" }
-appveyor = { repository = "clap-rs/clap" }
-coveralls = { repository = "clap-rs/clap", branch = "master" }
-is-it-maintained-issue-resolution = { repository = "clap-rs/clap" }
-is-it-maintained-open-issues = { repository = "clap-rs/clap" }
-maintenance = {status = "actively-developed"}
-
-[dependencies]
-bitflags = "1.0"
-unicode-width = "0.1.4"
-textwrap = "0.11.0"
-strsim = { version = "0.8", optional = true }
-yaml-rust = { version = "0.3.5", optional = true }
-clippy = { version = "~0.0.166", optional = true }
-atty = { version = "0.2.2", optional = true }
-vec_map = { version = "0.8", optional = true }
-term_size = { version = "0.3.0", optional = true }
-
-[target.'cfg(not(windows))'.dependencies]
-ansi_term = { version = "0.11", optional = true }
-
-[dev-dependencies]
-regex = "1"
-lazy_static = "1.3"
-version-sync = "0.8"
-
-[features]
-default = ["suggestions", "color", "vec_map"]
-suggestions = ["strsim"]
-color = ["ansi_term", "atty"]
-wrap_help = ["term_size", "textwrap/term_size"]
-yaml = ["yaml-rust"]
-unstable = [] # for building with unstable clap features (doesn't require nightly Rust) (currently none)
-nightly = [] # for building with unstable Rust features (currently none)
-lints = ["clippy"] # Requires nightly Rust
-debug = [] # Enables debug messages
-no_cargo = [] # Enable if you're not using Cargo, disables Cargo-env-var-dependent macros
-doc = ["yaml"] # All the features which add to documentation
-
-[profile.release]
-opt-level = 3
-debug = false
-rpath = false
-lto = true
-debug-assertions = false
-codegen-units = 1
-
-[profile.dev]
-opt-level = 0
-debug = true
-rpath = false
-lto = false
-debug-assertions = true
-codegen-units = 4
-
-[profile.test]
-opt-level = 1
-debug = true
-rpath = false
-lto = false
-debug-assertions = true
-codegen-units = 4
-
-[profile.bench]
-opt-level = 3
-debug = false
-rpath = false
-lto = true
-debug-assertions = false
-codegen-units = 1
-
-[package.metadata.docs.rs]
-features = ["doc"]
diff --git a/clap/LICENSE-MIT b/clap/LICENSE-MIT
deleted file mode 100644
index 5acedf0..0000000
--- a/clap/LICENSE-MIT
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2015-2016 Kevin B. Knapp
-
-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/clap/README.md b/clap/README.md
deleted file mode 100644
index c95f494..0000000
--- a/clap/README.md
+++ /dev/null
@@ -1,542 +0,0 @@
-clap
-====
-
-[![Crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap) [![Crates.io](https://img.shields.io/crates/d/clap.svg)](https://crates.io/crates/clap) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/clap-rs/clap/blob/master/LICENSE-MIT) [![Coverage Status](https://coveralls.io/repos/kbknapp/clap-rs/badge.svg?branch=master&service=github)](https://coveralls.io/github/kbknapp/clap-rs?branch=master) [![Join the chat at https://gitter.im/kbknapp/clap-rs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbknapp/clap-rs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
-Linux: [![Build Status](https://travis-ci.org/clap-rs/clap.svg?branch=master)](https://travis-ci.org/clap-rs/clap)
-Windows: [![Build status](https://ci.appveyor.com/api/projects/status/ejg8c33dn31nhv36/branch/master?svg=true)](https://ci.appveyor.com/project/kbknapp/clap-rs/branch/master)
-
-Command Line Argument Parser for Rust
-
-It is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcommands when writing console/terminal applications.
-
-* [documentation](https://docs.rs/clap/)
-* [website](https://clap.rs/)
-* [video tutorials](https://www.youtube.com/playlist?list=PLza5oFLQGTl2Z5T8g1pRkIynR3E0_pc7U)
-
-Table of Contents
-=================
-
-* [About](#about)
-* [FAQ](#faq)
-* [Features](#features)
-* [Quick Example](#quick-example)
-* [Try it!](#try-it)
- * [Pre-Built Test](#pre-built-test)
- * [BYOB (Build Your Own Binary)](#byob-build-your-own-binary)
-* [Usage](#usage)
- * [Optional Dependencies / Features](#optional-dependencies--features)
- * [Dependencies Tree](#dependencies-tree)
- * [More Information](#more-information)
- * [Video Tutorials](#video-tutorials)
-* [How to Contribute](#how-to-contribute)
- * [Compatibility Policy](#compatibility-policy)
- * [Minimum Version of Rust](#minimum-version-of-rust)
-* [Related Crates](#related-crates)
-* [License](#license)
-* [Recent Breaking Changes](#recent-breaking-changes)
- * [Deprecations](#deprecations)
-
-Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
-
-## About
-
-`clap` is used to parse *and validate* the string of command line arguments provided by a user at runtime. You provide the list of valid possibilities, and `clap` handles the rest. This means you focus on your *applications* functionality, and less on the parsing and validating of arguments.
-
-`clap` provides many things 'for free' (with no configuration) including the traditional version and help switches (or flags) along with associated messages. If you are using subcommands, `clap` will also auto-generate a `help` subcommand and separate associated help messages.
-
-Once `clap` parses the user provided string of arguments, it returns the matches along with any applicable values. If the user made an error or typo, `clap` informs them with a friendly message and exits gracefully (or returns a `Result` type and allows you to perform any clean up prior to exit). Because of this, you can make reasonable assumptions in your code about the validity of the arguments prior to your applications main execution.
-
-## FAQ
-
-For a full FAQ and more in depth details, see [the wiki page](https://github.com/clap-rs/clap/wiki/FAQ)
-
-### Comparisons
-
-First, let me say that these comparisons are highly subjective, and not meant in a critical or harsh manner. All the argument parsing libraries out there (to include `clap`) have their own strengths and weaknesses. Sometimes it just comes down to personal taste when all other factors are equal. When in doubt, try them all and pick one that you enjoy :) There's plenty of room in the Rust community for multiple implementations!
-
-#### How does `clap` compare to [getopts](https://github.com/rust-lang-nursery/getopts)?
-
-`getopts` is a very basic, fairly minimalist argument parsing library. This isn't a bad thing, sometimes you don't need tons of features, you just want to parse some simple arguments, and have some help text generated for you based on valid arguments you specify. The downside to this approach is that you must manually implement most of the common features (such as checking to display help messages, usage strings, etc.). If you want a highly custom argument parser, and don't mind writing the majority of the functionality yourself, `getopts` is an excellent base.
-
-`getopts` also doesn't allocate much, or at all. This gives it a very small performance boost. Although, as you start implementing additional features, that boost quickly disappears.
-
-Personally, I find many, many uses of `getopts` are manually implementing features that `clap` provides by default. Using `clap` simplifies your codebase allowing you to focus on your application, and not argument parsing.
-
-#### How does `clap` compare to [docopt.rs](https://github.com/docopt/docopt.rs)?
-
-I first want to say I'm a big a fan of BurntSushi's work, the creator of `Docopt.rs`. I aspire to produce the quality of libraries that this man does! When it comes to comparing these two libraries they are very different. `docopt` tasks you with writing a help message, and then it parsers that message for you to determine all valid arguments and their use. Some people LOVE this approach, others do not. If you're willing to write a detailed help message, it's nice that you can stick that in your program and have `docopt` do the rest. On the downside, it's far less flexible.
-
-`docopt` is also excellent at translating arguments into Rust types automatically. There is even a syntax extension which will do all this for you, if you're willing to use a nightly compiler (use of a stable compiler requires you to somewhat manually translate from arguments to Rust types). To use BurntSushi's words, `docopt` is also a sort of black box. You get what you get, and it's hard to tweak implementation or customize the experience for your use case.
-
-Because `docopt` is doing a ton of work to parse your help messages and determine what you were trying to communicate as valid arguments, it's also one of the more heavy weight parsers performance-wise. For most applications this isn't a concern and this isn't to say `docopt` is slow, in fact far from it. This is just something to keep in mind while comparing.
-
-#### All else being equal, what are some reasons to use `clap`? (The Pitch)
-
-`clap` is as fast, and as lightweight as possible while still giving all the features you'd expect from a modern argument parser. In fact, for the amount and type of features `clap` offers it remains about as fast as `getopts`. If you use `clap` when just need some simple arguments parsed, you'll find it's a walk in the park. `clap` also makes it possible to represent extremely complex, and advanced requirements, without too much thought. `clap` aims to be intuitive, easy to use, and fully capable for wide variety use cases and needs.
-
-#### All else being equal, what are some reasons *not* to use `clap`? (The Anti Pitch)
-
-Depending on the style in which you choose to define the valid arguments, `clap` can be very verbose. `clap` also offers so many fine-tuning knobs and dials, that learning everything can seem overwhelming. I strive to keep the simple cases simple, but when turning all those custom dials it can get complex. `clap` is also opinionated about parsing. Even though so much can be tweaked and tuned with `clap` (and I'm adding more all the time), there are still certain features which `clap` implements in specific ways which may be contrary to some users use-cases. Finally, `clap` is "stringly typed" when referring to arguments which can cause typos in code. This particular paper-cut is being actively worked on, and should be gone in v3.x.
-
-## Features
-
-Below are a few of the features which `clap` supports, full descriptions and usage can be found in the [documentation](https://docs.rs/clap/) and [examples/](examples) directory
-
-* **Auto-generated Help, Version, and Usage information**
- - Can optionally be fully, or partially overridden if you want a custom help, version, or usage statements
-* **Auto-generated completion scripts at compile time (Bash, Zsh, Fish, and PowerShell)**
- - Even works through many multiple levels of subcommands
- - Works with options which only accept certain values
- - Works with subcommand aliases
-* **Flags / Switches** (i.e. bool fields)
- - Both short and long versions supported (i.e. `-f` and `--flag` respectively)
- - Supports combining short versions (i.e. `-fBgoZ` is the same as `-f -B -g -o -Z`)
- - Supports multiple occurrences (i.e. `-vvv` or `-v -v -v`)
-* **Positional Arguments** (i.e. those which are based off an index from the program name)
- - Supports multiple values (i.e. `myprog <file>...` such as `myprog file1.txt file2.txt` being two values for the same "file" argument)
- - Supports Specific Value Sets (See below)
- - Can set value parameters (such as the minimum number of values, the maximum number of values, or the exact number of values)
- - Can set custom validations on values to extend the argument parsing capability to truly custom domains
-* **Option Arguments** (i.e. those that take values)
- - Both short and long versions supported (i.e. `-o value`, `-ovalue`, `-o=value` and `--option value` or `--option=value` respectively)
- - Supports multiple values (i.e. `-o <val1> -o <val2>` or `-o <val1> <val2>`)
- - Supports delimited values (i.e. `-o=val1,val2,val3`, can also change the delimiter)
- - Supports Specific Value Sets (See below)
- - Supports named values so that the usage/help info appears as `-o <FILE> <INTERFACE>` etc. for when you require specific multiple values
- - Can set value parameters (such as the minimum number of values, the maximum number of values, or the exact number of values)
- - Can set custom validations on values to extend the argument parsing capability to truly custom domains
-* **Sub-Commands** (i.e. `git add <file>` where `add` is a sub-command of `git`)
- - Support their own sub-arguments, and sub-sub-commands independent of the parent
- - Get their own auto-generated Help, Version, and Usage independent of parent
-* **Support for building CLIs from YAML** - This keeps your Rust source nice and tidy and makes supporting localized translation very simple!
-* **Requirement Rules**: Arguments can define the following types of requirement rules
- - Can be required by default
- - Can be required only if certain arguments are present
- - Can require other arguments to be present
- - Can be required only if certain values of other arguments are used
-* **Confliction Rules**: Arguments can optionally define the following types of exclusion rules
- - Can be disallowed when certain arguments are present
- - Can disallow use of other arguments when present
-* **Groups**: Arguments can be made part of a group
- - Fully compatible with other relational rules (requirements, conflicts, and overrides) which allows things like requiring the use of any arg in a group, or denying the use of an entire group conditionally
-* **Specific Value Sets**: Positional or Option Arguments can define a specific set of allowed values (i.e. imagine a `--mode` option which may *only* have one of two values `fast` or `slow` such as `--mode fast` or `--mode slow`)
-* **Default Values**
- - Also supports conditional default values (i.e. a default which only applies if specific arguments are used, or specific values of those arguments)
-* **Automatic Version from Cargo.toml**: `clap` is fully compatible with Rust's `env!()` macro for automatically setting the version of your application to the version in your Cargo.toml. See [09_auto_version example](examples/09_auto_version.rs) for how to do this (Thanks to [jhelwig](https://github.com/jhelwig) for pointing this out)
-* **Typed Values**: You can use several convenience macros provided by `clap` to get typed values (i.e. `i32`, `u8`, etc.) from positional or option arguments so long as the type you request implements `std::str::FromStr` See the [12_typed_values example](examples/12_typed_values.rs). You can also use `clap`s `arg_enum!` macro to create an enum with variants that automatically implement `std::str::FromStr`. See [13a_enum_values_automatic example](examples/13a_enum_values_automatic.rs) for details
-* **Suggestions**: Suggests corrections when the user enters a typo. For example, if you defined a `--myoption` argument, and the user mistakenly typed `--moyption` (notice `y` and `o` transposed), they would receive a `Did you mean '--myoption'?` error and exit gracefully. This also works for subcommands and flags. (Thanks to [Byron](https://github.com/Byron) for the implementation) (This feature can optionally be disabled, see 'Optional Dependencies / Features')
-* **Colorized Errors (Non Windows OS only)**: Error message are printed in in colored text (this feature can optionally be disabled, see 'Optional Dependencies / Features').
-* **Global Arguments**: Arguments can optionally be defined once, and be available to all child subcommands. There values will also be propagated up/down throughout all subcommands.
-* **Custom Validations**: You can define a function to use as a validator of argument values. Imagine defining a function to validate IP addresses, or fail parsing upon error. This means your application logic can be solely focused on *using* values.
-* **POSIX Compatible Conflicts/Overrides** - In POSIX args can be conflicting, but not fail parsing because whichever arg comes *last* "wins" so to speak. This allows things such as aliases (i.e. `alias ls='ls -l'` but then using `ls -C` in your terminal which ends up passing `ls -l -C` as the final arguments. Since `-l` and `-C` aren't compatible, this effectively runs `ls -C` in `clap` if you choose...`clap` also supports hard conflicts that fail parsing). (Thanks to [Vinatorul](https://github.com/Vinatorul)!)
-* Supports the Unix `--` meaning, only positional arguments follow
-
-## Quick Example
-
-The following examples show a quick example of some of the very basic functionality of `clap`. For more advanced usage, such as requirements, conflicts, groups, multiple values and occurrences see the [documentation](https://docs.rs/clap/), [examples/](examples) directory of this repository or the [video tutorials](https://www.youtube.com/playlist?list=PLza5oFLQGTl2Z5T8g1pRkIynR3E0_pc7U).
-
- **NOTE:** All of these examples are functionally the same, but show different styles in which to use `clap`. These different styles are purely a matter of personal preference.
-
-The first example shows a method using the 'Builder Pattern' which allows more advanced configuration options (not shown in this small example), or even dynamically generating arguments when desired.
-
-```rust
-// (Full example with detailed comments in examples/01b_quick_example.rs)
-//
-// This example demonstrates clap's full 'builder pattern' style of creating arguments which is
-// more verbose, but allows easier editing, and at times more advanced options, or the possibility
-// to generate arguments dynamically.
-extern crate clap;
-use clap::{Arg, App, SubCommand};
-
-fn main() {
- let matches = App::new("My Super Program")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .arg(Arg::with_name("config")
- .short("c")
- .long("config")
- .value_name("FILE")
- .help("Sets a custom config file")
- .takes_value(true))
- .arg(Arg::with_name("INPUT")
- .help("Sets the input file to use")
- .required(true)
- .index(1))
- .arg(Arg::with_name("v")
- .short("v")
- .multiple(true)
- .help("Sets the level of verbosity"))
- .subcommand(SubCommand::with_name("test")
- .about("controls testing features")
- .version("1.3")
- .author("Someone E. <someone_else@other.com>")
- .arg(Arg::with_name("debug")
- .short("d")
- .help("print debug information verbosely")))
- .get_matches();
-
- // Gets a value for config if supplied by user, or defaults to "default.conf"
- let config = matches.value_of("config").unwrap_or("default.conf");
- println!("Value for config: {}", config);
-
- // Calling .unwrap() is safe here because "INPUT" is required (if "INPUT" wasn't
- // required we could have used an 'if let' to conditionally get the value)
- println!("Using input file: {}", matches.value_of("INPUT").unwrap());
-
- // Vary the output based on how many times the user used the "verbose" flag
- // (i.e. 'myprog -v -v -v' or 'myprog -vvv' vs 'myprog -v'
- match matches.occurrences_of("v") {
- 0 => println!("No verbose info"),
- 1 => println!("Some verbose info"),
- 2 => println!("Tons of verbose info"),
- 3 | _ => println!("Don't be crazy"),
- }
-
- // You can handle information about subcommands by requesting their matches by name
- // (as below), requesting just the name used, or both at the same time
- if let Some(matches) = matches.subcommand_matches("test") {
- if matches.is_present("debug") {
- println!("Printing debug info...");
- } else {
- println!("Printing normally...");
- }
- }
-
- // more program logic goes here...
-}
-```
-
-One could also optionally declare their CLI in YAML format and keep your Rust source tidy
-or support multiple localized translations by having different YAML files for each localization.
-
-First, create the `cli.yml` file to hold your CLI options, but it could be called anything we like:
-
-```yaml
-name: myapp
-version: "1.0"
-author: Kevin K. <kbknapp@gmail.com>
-about: Does awesome things
-args:
- - config:
- short: c
- long: config
- value_name: FILE
- help: Sets a custom config file
- takes_value: true
- - INPUT:
- help: Sets the input file to use
- required: true
- index: 1
- - verbose:
- short: v
- multiple: true
- help: Sets the level of verbosity
-subcommands:
- - test:
- about: controls testing features
- version: "1.3"
- author: Someone E. <someone_else@other.com>
- args:
- - debug:
- short: d
- help: print debug information
-```
-
-Since this feature requires additional dependencies that not everyone may want, it is *not* compiled in by default and we need to enable a feature flag in Cargo.toml:
-
-Simply change your `clap = "2.33"` to `clap = {version = "2.33", features = ["yaml"]}`.
-
-Finally we create our `main.rs` file just like we would have with the previous two examples:
-
-```rust
-// (Full example with detailed comments in examples/17_yaml.rs)
-//
-// This example demonstrates clap's building from YAML style of creating arguments which is far
-// more clean, but takes a very small performance hit compared to the other two methods.
-#[macro_use]
-extern crate clap;
-use clap::App;
-
-fn main() {
- // The YAML file is found relative to the current file, similar to how modules are found
- let yaml = load_yaml!("cli.yml");
- let matches = App::from_yaml(yaml).get_matches();
-
- // Same as previous examples...
-}
-```
-
-If you were to compile any of the above programs and run them with the flag `--help` or `-h` (or `help` subcommand, since we defined `test` as a subcommand) the following would be output
-
-```sh
-$ myprog --help
-My Super Program 1.0
-Kevin K. <kbknapp@gmail.com>
-Does awesome things
-
-USAGE:
- MyApp [FLAGS] [OPTIONS] <INPUT> [SUBCOMMAND]
-
-FLAGS:
- -h, --help Prints help information
- -v Sets the level of verbosity
- -V, --version Prints version information
-
-OPTIONS:
- -c, --config <FILE> Sets a custom config file
-
-ARGS:
- INPUT The input file to use
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test Controls testing features
-```
-
-**NOTE:** You could also run `myapp test --help` or `myapp help test` to see the help message for the `test` subcommand.
-
-There are also two other methods to create CLIs. Which style you choose is largely a matter of personal preference. The two other methods are:
-
-* Using [usage strings (examples/01a_quick_example.rs)](examples/01a_quick_example.rs) similar to (but not exact) docopt style usage statements. This is far less verbose than the above methods, but incurs a slight runtime penalty.
-* Using [a macro (examples/01c_quick_example.rs)](examples/01c_quick_example.rs) which is like a hybrid of the builder and usage string style. It's less verbose, but doesn't incur the runtime penalty of the usage string style. The downside is that it's harder to debug, and more opaque.
-
-Examples of each method can be found in the [examples/](examples) directory of this repository.
-
-## Try it!
-
-### Pre-Built Test
-
-To try out the pre-built examples, use the following steps:
-
-* Clone the repository `$ git clone https://github.com/clap-rs/clap && cd clap-rs/`
-* Compile the example `$ cargo build --example <EXAMPLE>`
-* Run the help info `$ ./target/debug/examples/<EXAMPLE> --help`
-* Play with the arguments!
-* You can also do a onetime run via `$ cargo run --example <EXAMPLE> -- [args to example]`
-
-### BYOB (Build Your Own Binary)
-
-To test out `clap`'s default auto-generated help/version follow these steps:
-* Create a new cargo project `$ cargo new fake --bin && cd fake`
-* Add `clap` to your `Cargo.toml`
-
-```toml
-[dependencies]
-clap = "2"
-```
-
-* Add the following to your `src/main.rs`
-
-```rust
-extern crate clap;
-use clap::App;
-
-fn main() {
- App::new("fake").version("v1.0-beta").get_matches();
-}
-```
-
-* Build your program `$ cargo build --release`
-* Run with help or version `$ ./target/release/fake --help` or `$ ./target/release/fake --version`
-
-## Usage
-
-For full usage, add `clap` as a dependency in your `Cargo.toml` () to use from crates.io:
-
-```toml
-[dependencies]
-clap = "~2.33"
-```
-
-(**note**: If you are concerned with supporting a minimum version of Rust that is *older* than the current stable Rust minus 2 stable releases, it's recommended to use the `~major.minor.patch` style versions in your `Cargo.toml` which will only update the patch version automatically. For more information see the [Compatibility Policy](#compatibility-policy))
-
-Then add `extern crate clap;` to your crate root.
-
-Define a list of valid arguments for your program (see the [documentation](https://docs.rs/clap/) or [examples/](examples) directory of this repo)
-
-Then run `cargo build` or `cargo update && cargo build` for your project.
-
-### Optional Dependencies / Features
-
-#### Features enabled by default
-
-* **"suggestions"**: Turns on the `Did you mean '--myoption'?` feature for when users make typos. (builds dependency `strsim`)
-* **"color"**: Turns on colored error messages. This feature only works on non-Windows OSs. (builds dependency `ansi-term` only on non-Windows targets)
-* **"vec_map"**: Use [`VecMap`](https://crates.io/crates/vec_map) internally instead of a [`BTreeMap`](https://doc.rust-lang.org/stable/std/collections/struct.BTreeMap.html). This feature provides a _slight_ performance improvement. (builds dependency `vec_map`)
-
-To disable these, add this to your `Cargo.toml`:
-
-```toml
-[dependencies.clap]
-version = "2.33"
-default-features = false
-```
-
-You can also selectively enable only the features you'd like to include, by adding:
-
-```toml
-[dependencies.clap]
-version = "2.33"
-default-features = false
-
-# Cherry-pick the features you'd like to use
-features = [ "suggestions", "color" ]
-```
-
-#### Opt-in features
-
-* **"yaml"**: Enables building CLIs from YAML documents. (builds dependency `yaml-rust`)
-* **"unstable"**: Enables unstable `clap` features that may change from release to release
-* **"wrap_help"**: Turns on the help text wrapping feature, based on the terminal size. (builds dependency `term-size`)
-
-### Dependencies Tree
-
-The following graphic depicts `clap`s dependency graph (generated using [cargo-graph](https://github.com/kbknapp/cargo-graph)).
-
- * **Dashed** Line: Optional dependency
- * **Red** Color: **NOT** included by default (must use cargo `features` to enable)
- * **Blue** Color: Dev dependency, only used while developing.
-
-![clap dependencies](clap_dep_graph.png)
-
-### More Information
-
-You can find complete documentation on the [docs.rs](https://docs.rs/clap/) for this project.
-
-You can also find usage examples in the [examples/](examples) directory of this repo.
-
-#### Video Tutorials
-
-There's also the video tutorial series [Argument Parsing with Rust v2](https://www.youtube.com/playlist?list=PLza5oFLQGTl2Z5T8g1pRkIynR3E0_pc7U).
-
-These videos slowly trickle out as I finish them and currently a work in progress.
-
-## How to Contribute
-
-Details on how to contribute can be found in the [CONTRIBUTING.md](.github/CONTRIBUTING.md) file.
-
-### Compatibility Policy
-
-Because `clap` takes SemVer and compatibility seriously, this is the official policy regarding breaking changes and minimum required versions of Rust.
-
-`clap` will pin the minimum required version of Rust to the CI builds. Bumping the minimum version of Rust is considered a minor breaking change, meaning *at a minimum* the minor version of `clap` will be bumped.
-
-In order to keep from being surprised of breaking changes, it is **highly** recommended to use the `~major.minor.patch` style in your `Cargo.toml` only if you wish to target a version of Rust that is *older* than current stable minus two releases:
-
-```toml
-[dependencies]
-clap = "~2.33"
-```
-
-This will cause *only* the patch version to be updated upon a `cargo update` call, and therefore cannot break due to new features, or bumped minimum versions of Rust.
-
-#### Warning about '~' Dependencies
-
-Using `~` can cause issues in certain circumstances.
-
-From @alexcrichton:
-
-Right now Cargo's version resolution is pretty naive, it's just a brute-force search of the solution space, returning the first resolvable graph. This also means that it currently won't terminate until it proves there is not possible resolvable graph. This leads to situations where workspaces with multiple binaries, for example, have two different dependencies such as:
-
-```toml,no_sync
-
-# In one Cargo.toml
-[dependencies]
-clap = "~2.33.0"
-
-# In another Cargo.toml
-[dependencies]
-clap = "2.33.0"
-```
-
-This is inherently an unresolvable crate graph in Cargo right now. Cargo requires there's only one major version of a crate, and being in the same workspace these two crates must share a version. This is impossible in this location, though, as these version constraints cannot be met.
-
-#### Minimum Version of Rust
-
-`clap` will officially support current stable Rust, minus two releases, but may work with prior releases as well. For example, current stable Rust at the time of this writing is 1.32.0, meaning `clap` is guaranteed to compile with 1.30.0 and beyond.
-
-At the 1.33.0 stable release, `clap` will be guaranteed to compile with 1.31.0 and beyond, etc.
-
-Upon bumping the minimum version of Rust (assuming it's within the stable-2 range), it *must* be clearly annotated in the `CHANGELOG.md`
-
-#### Breaking Changes
-
-`clap` takes a similar policy to Rust and will bump the major version number upon breaking changes with only the following exceptions:
-
- * The breaking change is to fix a security concern
- * The breaking change is to be fixing a bug (i.e. relying on a bug as a feature)
- * The breaking change is a feature isn't used in the wild, or all users of said feature have given approval *prior* to the change
-
-#### Compatibility with Wasm
-
-A best effort is made to ensure that `clap` will work on projects targeting `wasm32-unknown-unknown`. However there is no dedicated CI build
-covering this specific target.
-
-## License
-
-`clap` is licensed under the MIT license. Please read the [LICENSE-MIT](LICENSE-MIT) file in this repository for more information.
-
-## Related Crates
-
-There are several excellent crates which can be used with `clap`, I recommend checking them all out! If you've got a crate that would be a good fit to be used with `clap` open an issue and let me know, I'd love to add it!
-
-* [`structopt`](https://github.com/TeXitoi/structopt) - This crate allows you to define a struct, and build a CLI from it! No more "stringly typed" and it uses `clap` behind the scenes! (*Note*: There is work underway to pull this crate into mainline `clap`).
-* [`assert_cli`](https://github.com/assert-rs/assert_cli) - This crate allows you test your CLIs in a very intuitive and functional way!
-
-## Recent Breaking Changes
-
-`clap` follows semantic versioning, so breaking changes should only happen upon major version bumps. The only exception to this rule is breaking changes that happen due to implementation that was deemed to be a bug, security concerns, or it can be reasonably proved to affect no code. For the full details, see [CHANGELOG.md](./CHANGELOG.md).
-
-As of 2.27.0:
-
-* Argument values now take precedence over subcommand names. This only arises by using unrestrained multiple values and subcommands together where the subcommand name can coincide with one of the multiple values. Such as `$ prog <files>... <subcommand>`. The fix is to place restraints on number of values, or disallow the use of `$ prog <prog-args> <subcommand>` structure.
-
-As of 2.0.0 (From 1.x)
-
-* **Fewer lifetimes! Yay!**
- * `App<'a, 'b, 'c, 'd, 'e, 'f>` => `App<'a, 'b>`
- * `Arg<'a, 'b, 'c, 'd, 'e, 'f>` => `Arg<'a, 'b>`
- * `ArgMatches<'a, 'b>` => `ArgMatches<'a>`
-* **Simply Renamed**
- * `App::arg_group` => `App::group`
- * `App::arg_groups` => `App::groups`
- * `ArgGroup::add` => `ArgGroup::arg`
- * `ArgGroup::add_all` => `ArgGroup::args`
- * `ClapError` => `Error`
- * struct field `ClapError::error_type` => `Error::kind`
- * `ClapResult` => `Result`
- * `ClapErrorType` => `ErrorKind`
-* **Removed Deprecated Functions and Methods**
- * `App::subcommands_negate_reqs`
- * `App::subcommand_required`
- * `App::arg_required_else_help`
- * `App::global_version(bool)`
- * `App::versionless_subcommands`
- * `App::unified_help_messages`
- * `App::wait_on_error`
- * `App::subcommand_required_else_help`
- * `SubCommand::new`
- * `App::error_on_no_subcommand`
- * `Arg::new`
- * `Arg::mutually_excludes`
- * `Arg::mutually_excludes_all`
- * `Arg::mutually_overrides_with`
- * `simple_enum!`
-* **Renamed Error Variants**
- * `InvalidUnicode` => `InvalidUtf8`
- * `InvalidArgument` => `UnknownArgument`
-* **Usage Parser**
- * Value names can now be specified inline, i.e. `-o, --option <FILE> <FILE2> 'some option which takes two files'`
- * **There is now a priority of order to determine the name** - This is perhaps the biggest breaking change. See the documentation for full details. Prior to this change, the value name took precedence. **Ensure your args are using the proper names (i.e. typically the long or short and NOT the value name) throughout the code**
-* `ArgMatches::values_of` returns an `Values` now which implements `Iterator` (should not break any code)
-* `crate_version!` returns `&'static str` instead of `String`
-
-### Deprecations
-
-Old method names will be left around for several minor version bumps, or one major version bump.
-
-As of 2.27.0:
-
-* **AppSettings::PropagateGlobalValuesDown:** this setting deprecated and is no longer required to propagate values down or up
diff --git a/clap/SPONSORS.md b/clap/SPONSORS.md
deleted file mode 100644
index 67f5544..0000000
--- a/clap/SPONSORS.md
+++ /dev/null
@@ -1,17 +0,0 @@
-Below is a list of sponsors for the clap-rs project
-
-If you are interested in becoming a sponsor for this project please our [sponsorship page](https://clap.rs/sponsorship/).
-
-## Recurring Sponsors:
-
-| [<img alt="Noelia Seva-Gonzalez" src="https://clap.rs/wp-content/uploads/2017/10/noelia_sm-1.png" width="117">](https://noeliasg.com/about/) | [<img alt="messense" src="https://clap.rs/wp-content/uploads/2018/01/messense-400x400.png" width="117">](https://github.com/messense) | [<img alt="Josh" src="https://clap.rs/wp-content/uploads/2018/11/josh_t.jpg" width="117">](https://joshtriplett.org) | <img alt="Stephen Oats" src="https://clap.rs/wp-content/uploads/2019/03/stephenoats.png" width="117"> |
-|:-:|:-:|:-:|:-:|
-|Noelia Seva-Gonzalez | Messense | Josh Triplett | Stephen Oats |
-
-
-## Single-Donation and Former Sponsors:
-
-| [<img alt="Rob Tsuk" src="https://clap.rs/wp-content/uploads/2017/10/robtsuk_sm.png" width="117">](https://github.com/rtsuk)| | |
-|:-:|:-:|:-:|
-|Rob Tsuk| | |
-
diff --git a/clap/benches/01_default.rs b/clap/benches/01_default.rs
deleted file mode 100644
index 24e619e..0000000
--- a/clap/benches/01_default.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-#![feature(test)]
-
-extern crate clap;
-extern crate test;
-
-use clap::App;
-
-use test::Bencher;
-
-#[bench]
-fn build_app(b: &mut Bencher) {
- b.iter(|| App::new("claptests"));
-}
-
-#[bench]
-fn parse_clean(b: &mut Bencher) {
- b.iter(|| App::new("claptests").get_matches_from(vec![""]));
-}
diff --git a/clap/benches/02_simple.rs b/clap/benches/02_simple.rs
deleted file mode 100644
index 010fa86..0000000
--- a/clap/benches/02_simple.rs
+++ /dev/null
@@ -1,114 +0,0 @@
-#![feature(test)]
-
-extern crate clap;
-extern crate test;
-
-use clap::{App, Arg};
-
-use test::Bencher;
-
-macro_rules! create_app {
- () => ({
- App::new("claptests")
- .version("0.1")
- .about("tests clap library")
- .author("Kevin K. <kbknapp@gmail.com>")
- .args_from_usage("-f --flag 'tests flags'
- -o --option=[opt] 'tests options'
- [positional] 'tests positional'")
- })
-}
-
-#[bench]
-fn build_app(b: &mut Bencher) {
-
- b.iter(|| create_app!());
-}
-
-#[bench]
-fn add_flag(b: &mut Bencher) {
- fn build_app() -> App<'static, 'static> {
- App::new("claptests")
- }
-
- b.iter(|| build_app().arg(Arg::from_usage("-s, --some 'something'")));
-}
-
-#[bench]
-fn add_flag_ref(b: &mut Bencher) {
- fn build_app() -> App<'static, 'static> {
- App::new("claptests")
- }
-
- b.iter(|| {
- let arg = Arg::from_usage("-s, --some 'something'");
- build_app().arg(&arg)
- });
-}
-
-#[bench]
-fn add_opt(b: &mut Bencher) {
- fn build_app() -> App<'static, 'static> {
- App::new("claptests")
- }
-
- b.iter(|| build_app().arg(Arg::from_usage("-s, --some <FILE> 'something'")));
-}
-
-#[bench]
-fn add_opt_ref(b: &mut Bencher) {
- fn build_app() -> App<'static, 'static> {
- App::new("claptests")
- }
-
- b.iter(|| {
- let arg = Arg::from_usage("-s, --some <FILE> 'something'");
- build_app().arg(&arg)
- });
-}
-
-#[bench]
-fn add_pos(b: &mut Bencher) {
- fn build_app() -> App<'static, 'static> {
- App::new("claptests")
- }
-
- b.iter(|| build_app().arg(Arg::with_name("some")));
-}
-
-#[bench]
-fn add_pos_ref(b: &mut Bencher) {
- fn build_app() -> App<'static, 'static> {
- App::new("claptests")
- }
-
- b.iter(|| {
- let arg = Arg::with_name("some");
- build_app().arg(&arg)
- });
-}
-
-#[bench]
-fn parse_clean(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec![""]));
-}
-
-#[bench]
-fn parse_flag(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"]));
-}
-
-#[bench]
-fn parse_option(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1"]));
-}
-
-#[bench]
-fn parse_positional(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1"]));
-}
-
-#[bench]
-fn parse_complex(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1", "-f", "arg1"]));
-}
diff --git a/clap/benches/03_complex.rs b/clap/benches/03_complex.rs
deleted file mode 100644
index b00fc4e..0000000
--- a/clap/benches/03_complex.rs
+++ /dev/null
@@ -1,230 +0,0 @@
-#![feature(test)]
-
-#[macro_use]
-extern crate clap;
-extern crate test;
-
-use clap::{App, Arg, SubCommand, AppSettings};
-
-use test::Bencher;
-
-static ARGS: &'static str = "-o --option=[opt]... 'tests options'
- [positional] 'tests positionals'";
-static OPT3_VALS: [&'static str; 2] = ["fast", "slow"];
-static POS3_VALS: [&'static str; 2] = ["vi", "emacs"];
-
-macro_rules! create_app {
- () => ({
- App::new("claptests")
- .version("0.1")
- .about("tests clap library")
- .author("Kevin K. <kbknapp@gmail.com>")
- .args_from_usage(ARGS)
- .arg(Arg::from_usage("-f --flag... 'tests flags'")
- .global(true))
- .args(&[
- Arg::from_usage("[flag2] -F 'tests flags with exclusions'").conflicts_with("flag").requires("option2"),
- Arg::from_usage("--long-option-2 [option2] 'tests long options with exclusions'").conflicts_with("option").requires("positional2"),
- Arg::from_usage("[positional2] 'tests positionals with exclusions'"),
- Arg::from_usage("-O --Option [option3] 'tests options with specific value sets'").possible_values(&OPT3_VALS),
- Arg::from_usage("[positional3]... 'tests positionals with specific values'").possible_values(&POS3_VALS),
- Arg::from_usage("--multvals [one] [two] 'Tests multiple values, not mult occs'"),
- Arg::from_usage("--multvalsmo... [one] [two] 'Tests multiple values, not mult occs'"),
- Arg::from_usage("--minvals2 [minvals]... 'Tests 2 min vals'").min_values(2),
- Arg::from_usage("--maxvals3 [maxvals]... 'Tests 3 max vals'").max_values(3)
- ])
- .subcommand(SubCommand::with_name("subcmd")
- .about("tests subcommands")
- .version("0.1")
- .author("Kevin K. <kbknapp@gmail.com>")
- .arg_from_usage("-o --option [scoption]... 'tests options'")
- .arg_from_usage("[scpositional] 'tests positionals'"))
- })
-}
-
-#[bench]
-fn create_app_from_usage(b: &mut Bencher) {
-
- b.iter(|| create_app!());
-}
-
-#[bench]
-fn create_app_builder(b: &mut Bencher) {
- b.iter(|| {
- App::new("claptests")
- .version("0.1")
- .about("tests clap library")
- .author("Kevin K. <kbknapp@gmail.com>")
- .arg(Arg::with_name("opt")
- .help("tests options")
- .short("o")
- .long("option")
- .takes_value(true)
- .multiple(true))
- .arg(Arg::with_name("positional")
- .help("tests positionals")
- .index(1))
- .arg(Arg::with_name("flag")
- .short("f")
- .help("tests flags")
- .long("flag")
- .multiple(true)
- .global(true))
- .arg(Arg::with_name("flag2")
- .short("F")
- .help("tests flags with exclusions")
- .conflicts_with("flag")
- .requires("option2"))
- .arg(Arg::with_name("option2")
- .help("tests long options with exclusions")
- .conflicts_with("option")
- .requires("positional2")
- .takes_value(true)
- .long("long-option-2"))
- .arg(Arg::with_name("positional2")
- .index(3)
- .help("tests positionals with exclusions"))
- .arg(Arg::with_name("option3")
- .short("O")
- .long("Option")
- .takes_value(true)
- .help("tests options with specific value sets")
- .possible_values(&OPT3_VALS))
- .arg(Arg::with_name("positional3")
- .multiple(true)
- .help("tests positionals with specific values")
- .index(4)
- .possible_values(&POS3_VALS))
- .arg(Arg::with_name("multvals")
- .long("multvals")
- .takes_value(true)
- .help("Tests multiple values, not mult occs")
- .value_names(&["one", "two"]))
- .arg(Arg::with_name("multvalsmo")
- .long("multvalsmo")
- .takes_value(true)
- .multiple(true)
- .help("Tests multiple values, not mult occs")
- .value_names(&["one", "two"]))
- .arg(Arg::with_name("minvals")
- .long("minvals2")
- .multiple(true)
- .takes_value(true)
- .help("Tests 2 min vals")
- .min_values(2))
- .arg(Arg::with_name("maxvals")
- .long("maxvals3")
- .takes_value(true)
- .multiple(true)
- .help("Tests 3 max vals")
- .max_values(3))
- .subcommand(SubCommand::with_name("subcmd")
- .about("tests subcommands")
- .version("0.1")
- .author("Kevin K. <kbknapp@gmail.com>")
- .arg(Arg::with_name("scoption")
- .short("o")
- .long("option")
- .multiple(true)
- .takes_value(true)
- .help("tests options"))
- .arg(Arg::with_name("scpositional")
- .index(1)
- .help("tests positionals")));
- });
-}
-
-#[bench]
-fn create_app_macros(b: &mut Bencher) {
- b.iter(|| {
- clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg opt: -o --option +takes_value ... "tests options")
- (@arg positional: index(1) "tests positionals")
- (@arg flag: -f --flag ... +global "tests flags")
- (@arg flag2: -F conflicts_with[flag] requires[option2]
- "tests flags with exclusions")
- (@arg option2: --long_option_2 conflicts_with[option] requires[positional2]
- "tests long options with exclusions")
- (@arg positional2: index(2) "tests positionals with exclusions")
- (@arg option3: -O --Option +takes_value possible_value[fast slow]
- "tests options with specific value sets")
- (@arg positional3: index(3) ... possible_value[vi emacs]
- "tests positionals with specific values")
- (@arg multvals: --multvals +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg multvalsmo: --multvalsmo ... +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg minvals: --minvals2 min_values(1) ... +takes_value "Tests 2 min vals")
- (@arg maxvals: --maxvals3 ... +takes_value max_values(3) "Tests 3 max vals")
- (@subcommand subcmd =>
- (about: "tests subcommands")
- (version: "0.1")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg scoption: -o --option ... +takes_value "tests options")
- (@arg scpositional: index(1) "tests positionals"))
- );
- });
-}
-
-#[bench]
-fn parse_clean(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec![""]));
-}
-
-#[bench]
-fn parse_flag(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"]));
-}
-
-#[bench]
-fn parse_option(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "-o", "option1"]));
-}
-
-#[bench]
-fn parse_positional(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1"]));
-}
-
-#[bench]
-fn parse_sc_clean(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd"]));
-}
-
-#[bench]
-fn parse_sc_flag(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-f"]));
-}
-
-#[bench]
-fn parse_sc_option(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-o", "option1"]));
-}
-
-#[bench]
-fn parse_sc_positional(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "arg1"]));
-}
-
-#[bench]
-fn parse_complex1(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "-ff", "-o", "option1", "arg1", "-O", "fast", "arg2", "--multvals", "one", "two", "emacs"]));
-}
-
-#[bench]
-fn parse_complex2(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "arg1", "-f", "arg2", "--long-option-2", "some", "-O", "slow", "--multvalsmo", "one", "two", "--minvals2", "3", "2", "1"]));
-}
-
-#[bench]
-fn parse_complex2_with_args_negate_scs(b: &mut Bencher) {
- b.iter(|| create_app!().setting(AppSettings::ArgsNegateSubcommands).get_matches_from(vec!["myprog", "arg1", "-f", "arg2", "--long-option-2", "some", "-O", "slow", "--multvalsmo", "one", "two", "--minvals2", "3", "2", "1"]));
-}
-
-#[bench]
-fn parse_sc_complex(b: &mut Bencher) {
- b.iter(|| create_app!().get_matches_from(vec!["myprog", "subcmd", "-f", "-o", "option1", "arg1"]));
-}
diff --git a/clap/benches/04_new_help.rs b/clap/benches/04_new_help.rs
deleted file mode 100644
index f033efb..0000000
--- a/clap/benches/04_new_help.rs
+++ /dev/null
@@ -1,198 +0,0 @@
-#![feature(test)]
-
-extern crate clap;
-extern crate test;
-
-use test::Bencher;
-
-use std::io::Cursor;
-
-use clap::App;
-use clap::{Arg, SubCommand};
-
-fn build_help(app: &App) -> String {
- let mut buf = Cursor::new(Vec::with_capacity(50));
- app.write_help(&mut buf).unwrap();
- let content = buf.into_inner();
- String::from_utf8(content).unwrap()
-}
-
-fn app_example1<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .args_from_usage("-c, --config=[FILE] 'Sets a custom config file'
- <output> 'Sets an optional output file'
- -d... 'Turn debugging information on'")
- .subcommand(SubCommand::with_name("test")
- .about("does testing things")
- .arg_from_usage("-l, --list 'lists test values'"))
-}
-
-fn app_example2<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
-}
-
-fn app_example3<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .arg(Arg::with_name("debug")
- .help("turn on debugging information")
- .short("d"))
- .args(&[Arg::with_name("config")
- .help("sets the config file to use")
- .takes_value(true)
- .short("c")
- .long("config"),
- Arg::with_name("input")
- .help("the input file to use")
- .index(1)
- .required(true)])
- .arg_from_usage("--license 'display the license file'")
- .args_from_usage("[output] 'Supply an output file to use'
- -i, --int=[IFACE] 'Set an interface to use'")
-}
-
-fn app_example4<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .about("Parses an input file to do awesome things")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .arg(Arg::with_name("debug")
- .help("turn on debugging information")
- .short("d")
- .long("debug"))
- .arg(Arg::with_name("config")
- .help("sets the config file to use")
- .short("c")
- .long("config"))
- .arg(Arg::with_name("input")
- .help("the input file to use")
- .index(1)
- .required(true))
-}
-
-fn app_example5<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp").arg(Arg::with_name("awesome")
- .help("turns up the awesome")
- .short("a")
- .long("awesome")
- .multiple(true)
- .requires("config")
- .conflicts_with("output"))
-}
-
-fn app_example6<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .arg(Arg::with_name("input")
- .help("the input file to use")
- .index(1)
- .requires("config")
- .conflicts_with("output")
- .required(true))
- .arg(Arg::with_name("config")
- .help("the config file to use")
- .index(2))
-}
-
-fn app_example7<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .arg(Arg::with_name("config"))
- .arg(Arg::with_name("output"))
- .arg(Arg::with_name("input")
- .help("the input file to use")
- .takes_value(true)
- .short("i")
- .long("input")
- .multiple(true)
- .required(true)
- .requires("config")
- .conflicts_with("output"))
-}
-
-fn app_example8<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .arg(Arg::with_name("config"))
- .arg(Arg::with_name("output"))
- .arg(Arg::with_name("input")
- .help("the input file to use")
- .takes_value(true)
- .short("i")
- .long("input")
- .multiple(true)
- .required(true)
- .requires("config")
- .conflicts_with("output"))
-}
-
-fn app_example10<'b, 'c>() -> App<'b, 'c> {
- App::new("myapp")
- .about("does awesome things")
- .arg(Arg::with_name("CONFIG")
- .help("The config file to use (default is \"config.json\")")
- .short("c")
- .takes_value(true))
-}
-
-#[bench]
-fn example1(b: &mut Bencher) {
- let app = app_example1();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example2(b: &mut Bencher) {
- let app = app_example2();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example3(b: &mut Bencher) {
- let app = app_example3();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example4(b: &mut Bencher) {
- let app = app_example4();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example5(b: &mut Bencher) {
- let app = app_example5();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example6(b: &mut Bencher) {
- let app = app_example6();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example7(b: &mut Bencher) {
- let app = app_example7();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example8(b: &mut Bencher) {
- let app = app_example8();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example10(b: &mut Bencher) {
- let app = app_example10();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn example4_template(b: &mut Bencher) {
- let app = app_example4().template("{bin} {version}\n{author}\n{about}\n\nUSAGE:\n {usage}\n\nFLAGS:\n{flags}\n\nARGS:\n{args}\n");
- b.iter(|| build_help(&app));
-}
diff --git a/clap/benches/05_ripgrep.rs b/clap/benches/05_ripgrep.rs
deleted file mode 100644
index 7db1552..0000000
--- a/clap/benches/05_ripgrep.rs
+++ /dev/null
@@ -1,777 +0,0 @@
-// Used to simulate a fairly large number of options/flags and parsing with thousands of positional
-// args
-//
-// CLI used is adapted from ripgrep 48a8a3a691220f9e5b2b08f4051abe8655ea7e8a
-
-#![feature(test)]
-
-extern crate clap;
-extern crate test;
-#[macro_use]
-extern crate lazy_static;
-
-use clap::{App, AppSettings, Arg, ArgSettings};
-
-use test::Bencher;
-use std::collections::HashMap;
-use std::io::Cursor;
-
-#[bench]
-fn build_app_short(b: &mut Bencher) { b.iter(|| app_short()); }
-
-#[bench]
-fn build_app_long(b: &mut Bencher) { b.iter(|| app_long()); }
-
-#[bench]
-fn build_help_short(b: &mut Bencher) {
- let app = app_short();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn build_help_long(b: &mut Bencher) {
- let app = app_long();
- b.iter(|| build_help(&app));
-}
-
-#[bench]
-fn parse_clean(b: &mut Bencher) { b.iter(|| app_short().get_matches_from(vec!["rg", "pat"])); }
-
-#[bench]
-fn parse_complex(b: &mut Bencher) {
- b.iter(|| {
- app_short().get_matches_from(vec!["rg",
- "pat",
- "-cFlN",
- "-pqr=some",
- "--null",
- "--no-filename",
- "--no-messages",
- "-SH",
- "-C5",
- "--follow",
- "-e some"])
- });
-}
-
-#[bench]
-fn parse_lots(b: &mut Bencher) {
- b.iter(|| {
- app_short()
- .get_matches_from(vec!["rg", "pat", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some"])
- });
-}
-
-const ABOUT: &'static str = "
-ripgrep (rg) recursively searches your current directory for a regex pattern.
-
-ripgrep's regex engine uses finite automata and guarantees linear time
-searching. Because of this, features like backreferences and arbitrary
-lookaround are not supported.
-
-Project home page: https://github.com/BurntSushi/ripgrep
-
-Use -h for short descriptions and --help for more details.";
-
-const USAGE: &'static str = "
- rg [OPTIONS] <pattern> [<path> ...]
- rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
- rg [OPTIONS] --files [<path> ...]
- rg [OPTIONS] --type-list";
-
-const TEMPLATE: &'static str = "\
-{bin} {version}
-{author}
-{about}
-
-USAGE:{usage}
-
-ARGS:
-{positionals}
-
-OPTIONS:
-{unified}";
-
-/// Build a clap application with short help strings.
-pub fn app_short() -> App<'static, 'static> { app(false, |k| USAGES[k].short) }
-
-/// Build a clap application with long help strings.
-pub fn app_long() -> App<'static, 'static> { app(true, |k| USAGES[k].long) }
-
-
-/// Build the help text of an application.
-fn build_help(app: &App) -> String {
- let mut buf = Cursor::new(Vec::with_capacity(50));
- app.write_help(&mut buf).unwrap();
- let content = buf.into_inner();
- String::from_utf8(content).unwrap()
-}
-
-
-/// Build a clap application parameterized by usage strings.
-///
-/// The function given should take a clap argument name and return a help
-/// string. `app` will panic if a usage string is not defined.
-///
-/// This is an intentionally stand-alone module so that it can be used easily
-/// in a `build.rs` script to build shell completion files.
-fn app<F>(next_line_help: bool, doc: F) -> App<'static, 'static>
- where F: Fn(&'static str) -> &'static str
-{
- let arg = |name| Arg::with_name(name).help(doc(name)).next_line_help(next_line_help);
- let flag = |name| arg(name).long(name);
-
- App::new("ripgrep")
- .author("BurntSushi") // simulating since it's only a bench
- .version("0.4.0") // Simulating
- .about(ABOUT)
- .max_term_width(100)
- .setting(AppSettings::UnifiedHelpMessage)
- .usage(USAGE)
- .template(TEMPLATE)
- // Handle help/version manually to make their output formatting
- // consistent with short/long views.
- .arg(arg("help-short").short("h"))
- .arg(flag("help"))
- .arg(flag("version").short("V"))
- // First, set up primary positional/flag arguments.
- .arg(arg("pattern")
- .required_unless_one(&[
- "file", "files", "help-short", "help", "regexp", "type-list",
- "version",
- ]))
- .arg(arg("path").multiple(true))
- .arg(flag("regexp").short("e")
- .takes_value(true).multiple(true).number_of_values(1)
- .set(ArgSettings::AllowLeadingHyphen)
- .value_name("pattern"))
- .arg(flag("files")
- // This should also conflict with `pattern`, but the first file
- // path will actually be in `pattern`.
- .conflicts_with_all(&["file", "regexp", "type-list"]))
- .arg(flag("type-list")
- .conflicts_with_all(&["file", "files", "pattern", "regexp"]))
- // Second, set up common flags.
- .arg(flag("text").short("a"))
- .arg(flag("count").short("c"))
- .arg(flag("color")
- .value_name("WHEN")
- .takes_value(true)
- .hide_possible_values(true)
- .possible_values(&["never", "auto", "always", "ansi"]))
- .arg(flag("colors").value_name("SPEC")
- .takes_value(true).multiple(true).number_of_values(1))
- .arg(flag("fixed-strings").short("F"))
- .arg(flag("glob").short("g")
- .takes_value(true).multiple(true).number_of_values(1)
- .value_name("GLOB"))
- .arg(flag("ignore-case").short("i"))
- .arg(flag("line-number").short("n"))
- .arg(flag("no-line-number").short("N"))
- .arg(flag("quiet").short("q"))
- .arg(flag("type").short("t")
- .takes_value(true).multiple(true).number_of_values(1)
- .value_name("TYPE"))
- .arg(flag("type-not").short("T")
- .takes_value(true).multiple(true).number_of_values(1)
- .value_name("TYPE"))
- .arg(flag("unrestricted").short("u")
- .multiple(true))
- .arg(flag("invert-match").short("v"))
- .arg(flag("word-regexp").short("w"))
- // Third, set up less common flags.
- .arg(flag("after-context").short("A")
- .value_name("NUM").takes_value(true)
- .validator(validate_number))
- .arg(flag("before-context").short("B")
- .value_name("NUM").takes_value(true)
- .validator(validate_number))
- .arg(flag("context").short("C")
- .value_name("NUM").takes_value(true)
- .validator(validate_number))
- .arg(flag("column"))
- .arg(flag("context-separator")
- .value_name("SEPARATOR").takes_value(true))
- .arg(flag("debug"))
- .arg(flag("file").short("f")
- .value_name("FILE").takes_value(true)
- .multiple(true).number_of_values(1))
- .arg(flag("files-with-matches").short("l"))
- .arg(flag("files-without-match"))
- .arg(flag("with-filename").short("H"))
- .arg(flag("no-filename"))
- .arg(flag("heading").overrides_with("no-heading"))
- .arg(flag("no-heading").overrides_with("heading"))
- .arg(flag("hidden"))
- .arg(flag("ignore-file")
- .value_name("FILE").takes_value(true)
- .multiple(true).number_of_values(1))
- .arg(flag("follow").short("L"))
- .arg(flag("max-count")
- .short("m").value_name("NUM").takes_value(true)
- .validator(validate_number))
- .arg(flag("maxdepth")
- .value_name("NUM").takes_value(true)
- .validator(validate_number))
- .arg(flag("mmap"))
- .arg(flag("no-messages"))
- .arg(flag("no-mmap"))
- .arg(flag("no-ignore"))
- .arg(flag("no-ignore-parent"))
- .arg(flag("no-ignore-vcs"))
- .arg(flag("null"))
- .arg(flag("path-separator").value_name("SEPARATOR").takes_value(true))
- .arg(flag("pretty").short("p"))
- .arg(flag("replace").short("r").value_name("ARG").takes_value(true))
- .arg(flag("case-sensitive").short("s"))
- .arg(flag("smart-case").short("S"))
- .arg(flag("sort-files"))
- .arg(flag("threads")
- .short("j").value_name("ARG").takes_value(true)
- .validator(validate_number))
- .arg(flag("vimgrep"))
- .arg(flag("type-add")
- .value_name("TYPE").takes_value(true)
- .multiple(true).number_of_values(1))
- .arg(flag("type-clear")
- .value_name("TYPE").takes_value(true)
- .multiple(true).number_of_values(1))
-}
-
-struct Usage {
- short: &'static str,
- long: &'static str,
-}
-
-macro_rules! doc {
- ($map:expr, $name:expr, $short:expr) => {
- doc!($map, $name, $short, $short)
- };
- ($map:expr, $name:expr, $short:expr, $long:expr) => {
- $map.insert($name, Usage {
- short: $short,
- long: concat!($long, "\n "),
- });
- };
-}
-
-lazy_static! {
- static ref USAGES: HashMap<&'static str, Usage> = {
- let mut h = HashMap::new();
- doc!(h, "help-short",
- "Show short help output.",
- "Show short help output. Use --help to show more details.");
- doc!(h, "help",
- "Show verbose help output.",
- "When given, more details about flags are provided.");
- doc!(h, "version",
- "Prints version information.");
-
- doc!(h, "pattern",
- "A regular expression used for searching.",
- "A regular expression used for searching. Multiple patterns \
- may be given. To match a pattern beginning with a -, use [-].");
- doc!(h, "regexp",
- "A regular expression used for searching.",
- "A regular expression used for searching. Multiple patterns \
- may be given. To match a pattern beginning with a -, use [-].");
- doc!(h, "path",
- "A file or directory to search.",
- "A file or directory to search. Directories are searched \
- recursively.");
- doc!(h, "files",
- "Print each file that would be searched.",
- "Print each file that would be searched without actually \
- performing the search. This is useful to determine whether a \
- particular file is being searched or not.");
- doc!(h, "type-list",
- "Show all supported file types.",
- "Show all supported file types and their corresponding globs.");
-
- doc!(h, "text",
- "Search binary files as if they were text.");
- doc!(h, "count",
- "Only show count of matches for each file.");
- doc!(h, "color",
- "When to use color. [default: auto]",
- "When to use color in the output. The possible values are \
- never, auto, always or ansi. The default is auto. When always \
- is used, coloring is attempted based on your environment. When \
- ansi used, coloring is forcefully done using ANSI escape color \
- codes.");
- doc!(h, "colors",
- "Configure color settings and styles.",
- "This flag specifies color settings for use in the output. \
- This flag may be provided multiple times. Settings are applied \
- iteratively. Colors are limited to one of eight choices: \
- red, blue, green, cyan, magenta, yellow, white and black. \
- Styles are limited to nobold, bold, nointense or intense.\n\n\
- The format of the flag is {type}:{attribute}:{value}. {type} \
- should be one of path, line or match. {attribute} can be fg, bg \
- or style. {value} is either a color (for fg and bg) or a text \
- style. A special format, {type}:none, will clear all color \
- settings for {type}.\n\nFor example, the following command will \
- change the match color to magenta and the background color for \
- line numbers to yellow:\n\n\
- rg --colors 'match:fg:magenta' --colors 'line:bg:yellow' foo.");
- doc!(h, "fixed-strings",
- "Treat the pattern as a literal string.",
- "Treat the pattern as a literal string instead of a regular \
- expression. When this flag is used, special regular expression \
- meta characters such as (){}*+. do not need to be escaped.");
- doc!(h, "glob",
- "Include or exclude files/directories.",
- "Include or exclude files/directories for searching that \
- match the given glob. This always overrides any other \
- ignore logic. Multiple glob flags may be used. Globbing \
- rules match .gitignore globs. Precede a glob with a ! \
- to exclude it.");
- doc!(h, "ignore-case",
- "Case insensitive search.",
- "Case insensitive search. This is overridden by \
- --case-sensitive.");
- doc!(h, "line-number",
- "Show line numbers.",
- "Show line numbers (1-based). This is enabled by default when \
- searching in a tty.");
- doc!(h, "no-line-number",
- "Suppress line numbers.",
- "Suppress line numbers. This is enabled by default when NOT \
- searching in a tty.");
- doc!(h, "quiet",
- "Do not print anything to stdout.",
- "Do not print anything to stdout. If a match is found in a file, \
- stop searching. This is useful when ripgrep is used only for \
- its exit code.");
- doc!(h, "type",
- "Only search files matching TYPE.",
- "Only search files matching TYPE. Multiple type flags may be \
- provided. Use the --type-list flag to list all available \
- types.");
- doc!(h, "type-not",
- "Do not search files matching TYPE.",
- "Do not search files matching TYPE. Multiple type-not flags may \
- be provided. Use the --type-list flag to list all available \
- types.");
- doc!(h, "unrestricted",
- "Reduce the level of \"smart\" searching.",
- "Reduce the level of \"smart\" searching. A single -u \
- won't respect .gitignore (etc.) files. Two -u flags will \
- additionally search hidden files and directories. Three \
- -u flags will additionally search binary files. -uu is \
- roughly equivalent to grep -r and -uuu is roughly \
- equivalent to grep -a -r.");
- doc!(h, "invert-match",
- "Invert matching.",
- "Invert matching. Show lines that don't match given patterns.");
- doc!(h, "word-regexp",
- "Only show matches surrounded by word boundaries.",
- "Only show matches surrounded by word boundaries. This is \
- equivalent to putting \\b before and after all of the search \
- patterns.");
-
- doc!(h, "after-context",
- "Show NUM lines after each match.");
- doc!(h, "before-context",
- "Show NUM lines before each match.");
- doc!(h, "context",
- "Show NUM lines before and after each match.");
- doc!(h, "column",
- "Show column numbers",
- "Show column numbers (1-based). This only shows the column \
- numbers for the first match on each line. This does not try \
- to account for Unicode. One byte is equal to one column. This \
- implies --line-number.");
- doc!(h, "context-separator",
- "Set the context separator string. [default: --]",
- "The string used to separate non-contiguous context lines in the \
- output. Escape sequences like \\x7F or \\t may be used. The \
- default value is --.");
- doc!(h, "debug",
- "Show debug messages.",
- "Show debug messages. Please use this when filing a bug report.");
- doc!(h, "file",
- "Search for patterns from the given file.",
- "Search for patterns from the given file, with one pattern per \
- line. When this flag is used or multiple times or in \
- combination with the -e/--regexp flag, then all patterns \
- provided are searched. Empty pattern lines will match all input \
- lines, and the newline is not counted as part of the pattern.");
- doc!(h, "files-with-matches",
- "Only show the path of each file with at least one match.");
- doc!(h, "files-without-match",
- "Only show the path of each file that contains zero matches.");
- doc!(h, "with-filename",
- "Show file name for each match.",
- "Prefix each match with the file name that contains it. This is \
- the default when more than one file is searched.");
- doc!(h, "no-filename",
- "Never show the file name for a match.",
- "Never show the file name for a match. This is the default when \
- one file is searched.");
- doc!(h, "heading",
- "Show matches grouped by each file.",
- "This shows the file name above clusters of matches from each \
- file instead of showing the file name for every match. This is \
- the default mode at a tty.");
- doc!(h, "no-heading",
- "Don't group matches by each file.",
- "Don't group matches by each file. If -H/--with-filename is \
- enabled, then file names will be shown for every line matched. \
- This is the default mode when not at a tty.");
- doc!(h, "hidden",
- "Search hidden files and directories.",
- "Search hidden files and directories. By default, hidden files \
- and directories are skipped.");
- doc!(h, "ignore-file",
- "Specify additional ignore files.",
- "Specify additional ignore files for filtering file paths. \
- Ignore files should be in the gitignore format and are matched \
- relative to the current working directory. These ignore files \
- have lower precedence than all other ignore files. When \
- specifying multiple ignore files, earlier files have lower \
- precedence than later files.");
- doc!(h, "follow",
- "Follow symbolic links.");
- doc!(h, "max-count",
- "Limit the number of matches.",
- "Limit the number of matching lines per file searched to NUM.");
- doc!(h, "maxdepth",
- "Descend at most NUM directories.",
- "Limit the depth of directory traversal to NUM levels beyond \
- the paths given. A value of zero only searches the \
- starting-points themselves.\n\nFor example, \
- 'rg --maxdepth 0 dir/' is a no-op because dir/ will not be \
- descended into. 'rg --maxdepth 1 dir/' will search only the \
- direct children of dir/.");
- doc!(h, "mmap",
- "Searching using memory maps when possible.",
- "Search using memory maps when possible. This is enabled by \
- default when ripgrep thinks it will be faster. Note that memory \
- map searching doesn't currently support all options, so if an \
- incompatible option (e.g., --context) is given with --mmap, \
- then memory maps will not be used.");
- doc!(h, "no-messages",
- "Suppress all error messages.",
- "Suppress all error messages. This is equivalent to redirecting \
- stderr to /dev/null.");
- doc!(h, "no-mmap",
- "Never use memory maps.",
- "Never use memory maps, even when they might be faster.");
- doc!(h, "no-ignore",
- "Don't respect ignore files.",
- "Don't respect ignore files (.gitignore, .ignore, etc.). This \
- implies --no-ignore-parent and --no-ignore-vcs.");
- doc!(h, "no-ignore-parent",
- "Don't respect ignore files in parent directories.",
- "Don't respect ignore files (.gitignore, .ignore, etc.) in \
- parent directories.");
- doc!(h, "no-ignore-vcs",
- "Don't respect VCS ignore files",
- "Don't respect version control ignore files (.gitignore, etc.). \
- This implies --no-ignore-parent. Note that .ignore files will \
- continue to be respected.");
- doc!(h, "null",
- "Print NUL byte after file names",
- "Whenever a file name is printed, follow it with a NUL byte. \
- This includes printing file names before matches, and when \
- printing a list of matching files such as with --count, \
- --files-with-matches and --files. This option is useful for use \
- with xargs.");
- doc!(h, "path-separator",
- "Path separator to use when printing file paths.",
- "The path separator to use when printing file paths. This \
- defaults to your platform's path separator, which is / on Unix \
- and \\ on Windows. This flag is intended for overriding the \
- default when the environment demands it (e.g., cygwin). A path \
- separator is limited to a single byte.");
- doc!(h, "pretty",
- "Alias for --color always --heading -n.");
- doc!(h, "replace",
- "Replace matches with string given.",
- "Replace every match with the string given when printing \
- results. Neither this flag nor any other flag will modify your \
- files.\n\nCapture group indices (e.g., $5) and names \
- (e.g., $foo) are supported in the replacement string.\n\n\
- Note that the replacement by default replaces each match, and \
- NOT the entire line. To replace the entire line, you should \
- match the entire line.");
- doc!(h, "case-sensitive",
- "Search case sensitively.",
- "Search case sensitively. This overrides -i/--ignore-case and \
- -S/--smart-case.");
- doc!(h, "smart-case",
- "Smart case search.",
- "Searches case insensitively if the pattern is all lowercase. \
- Search case sensitively otherwise. This is overridden by \
- either -s/--case-sensitive or -i/--ignore-case.");
- doc!(h, "sort-files",
- "Sort results by file path. Implies --threads=1.",
- "Sort results by file path. Note that this currently \
- disables all parallelism and runs search in a single thread.");
- doc!(h, "threads",
- "The approximate number of threads to use.",
- "The approximate number of threads to use. A value of 0 (which \
- is the default) causes ripgrep to choose the thread count \
- using heuristics.");
- doc!(h, "vimgrep",
- "Show results in vim compatible format.",
- "Show results with every match on its own line, including \
- line numbers and column numbers. With this option, a line with \
- more than one match will be printed more than once.");
-
- doc!(h, "type-add",
- "Add a new glob for a file type.",
- "Add a new glob for a particular file type. Only one glob can be \
- added at a time. Multiple --type-add flags can be provided. \
- Unless --type-clear is used, globs are added to any existing \
- globs defined inside of ripgrep.\n\nNote that this MUST be \
- passed to every invocation of ripgrep. Type settings are NOT \
- persisted.\n\nExample: \
- rg --type-add 'foo:*.foo' -tfoo PATTERN.\n\n\
- --type-add can also be used to include rules from other types \
- with the special include directive. The include directive \
- permits specifying one or more other type names (separated by a \
- comma) that have been defined and its rules will automatically \
- be imported into the type specified. For example, to create a \
- type called src that matches C++, Python and Markdown files, one \
- can use:\n\n\
- --type-add 'src:include:cpp,py,md'\n\n\
- Additional glob rules can still be added to the src type by \
- using the --type-add flag again:\n\n\
- --type-add 'src:include:cpp,py,md' --type-add 'src:*.foo'\n\n\
- Note that type names must consist only of Unicode letters or \
- numbers. Punctuation characters are not allowed.");
- doc!(h, "type-clear",
- "Clear globs for given file type.",
- "Clear the file type globs previously defined for TYPE. This \
- only clears the default type definitions that are found inside \
- of ripgrep.\n\nNote that this MUST be passed to every \
- invocation of ripgrep. Type settings are NOT persisted.");
-
- h
- };
-}
-
-fn validate_number(s: String) -> Result<(), String> {
- s.parse::<usize>().map(|_| ()).map_err(|err| err.to_string())
-}
diff --git a/clap/benches/06_rustup.rs b/clap/benches/06_rustup.rs
deleted file mode 100644
index f9ba477..0000000
--- a/clap/benches/06_rustup.rs
+++ /dev/null
@@ -1,458 +0,0 @@
-// Used to simulate a fairly large number of subcommands
-//
-// CLI used is from rustup 408ed84f0e50511ed44a405dd91365e5da588790
-
-#![feature(test)]
-
-extern crate clap;
-extern crate test;
-
-use clap::{App, AppSettings, Arg, Shell, SubCommand, ArgGroup};
-
-use test::Bencher;
-
-#[bench]
-fn build_app(b: &mut Bencher) { b.iter(|| build_cli()); }
-
-#[bench]
-fn parse_clean(b: &mut Bencher) { b.iter(|| build_cli().get_matches_from(vec![""])); }
-
-#[bench]
-fn parse_subcommands(b: &mut Bencher) {
- b.iter(|| build_cli().get_matches_from(vec!["rustup override add stable"]));
-}
-
-pub fn build_cli() -> App<'static, 'static> {
- App::new("rustup")
- .version("0.9.0") // Simulating
- .about("The Rust toolchain installer")
- .after_help(RUSTUP_HELP)
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .arg(Arg::with_name("verbose")
- .help("Enable verbose output")
- .short("v")
- .long("verbose"))
- .subcommand(SubCommand::with_name("show")
- .about("Show the active and installed toolchains")
- .after_help(SHOW_HELP))
- .subcommand(SubCommand::with_name("install")
- .about("Update Rust toolchains")
- .after_help(TOOLCHAIN_INSTALL_HELP)
- .setting(AppSettings::Hidden) // synonym for 'toolchain install'
- .arg(Arg::with_name("toolchain")
- .required(true)))
- .subcommand(SubCommand::with_name("update")
- .about("Update Rust toolchains")
- .after_help(UPDATE_HELP)
- .arg(Arg::with_name("toolchain").required(false))
- .arg(Arg::with_name("no-self-update")
- .help("Don't perform self update when running the `rustup` command")
- .long("no-self-update")
- .takes_value(false)
- .hidden(true)))
- .subcommand(SubCommand::with_name("default")
- .about("Set the default toolchain")
- .after_help(DEFAULT_HELP)
- .arg(Arg::with_name("toolchain").required(true)))
- .subcommand(SubCommand::with_name("toolchain")
- .about("Modify or query the installed toolchains")
- .after_help(TOOLCHAIN_HELP)
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("list").about("List installed toolchains"))
- .subcommand(SubCommand::with_name("install")
- .about("Install or update a given toolchain")
- .arg(Arg::with_name("toolchain").required(true)))
- .subcommand(SubCommand::with_name("uninstall")
- .about("Uninstall a toolchain")
- .arg(Arg::with_name("toolchain").required(true)))
- .subcommand(SubCommand::with_name("link")
- .about("Create a custom toolchain by symlinking to a directory")
- .arg(Arg::with_name("toolchain").required(true))
- .arg(Arg::with_name("path").required(true)))
- .subcommand(SubCommand::with_name("update")
- .setting(AppSettings::Hidden) // synonym for 'install'
- .arg(Arg::with_name("toolchain")
- .required(true)))
- .subcommand(SubCommand::with_name("add")
- .setting(AppSettings::Hidden) // synonym for 'install'
- .arg(Arg::with_name("toolchain")
- .required(true)))
- .subcommand(SubCommand::with_name("remove")
- .setting(AppSettings::Hidden) // synonym for 'uninstall'
- .arg(Arg::with_name("toolchain")
- .required(true))))
- .subcommand(SubCommand::with_name("target")
- .about("Modify a toolchain's supported targets")
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("list")
- .about("List installed and available targets")
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("add")
- .about("Add a target to a Rust toolchain")
- .arg(Arg::with_name("target").required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("remove")
- .about("Remove a target from a Rust toolchain")
- .arg(Arg::with_name("target").required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("install")
- .setting(AppSettings::Hidden) // synonym for 'add'
- .arg(Arg::with_name("target")
- .required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("uninstall")
- .setting(AppSettings::Hidden) // synonym for 'remove'
- .arg(Arg::with_name("target")
- .required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true))))
- .subcommand(SubCommand::with_name("component")
- .about("Modify a toolchain's installed components")
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("list")
- .about("List installed and available components")
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("add")
- .about("Add a component to a Rust toolchain")
- .arg(Arg::with_name("component").required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true))
- .arg(Arg::with_name("target")
- .long("target")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("remove")
- .about("Remove a component from a Rust toolchain")
- .arg(Arg::with_name("component").required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true))
- .arg(Arg::with_name("target")
- .long("target")
- .takes_value(true))))
- .subcommand(SubCommand::with_name("override")
- .about("Modify directory toolchain overrides")
- .after_help(OVERRIDE_HELP)
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("list").about("List directory toolchain overrides"))
- .subcommand(SubCommand::with_name("set")
- .about("Set the override toolchain for a directory")
- .arg(Arg::with_name("toolchain").required(true)))
- .subcommand(SubCommand::with_name("unset")
- .about("Remove the override toolchain for a directory")
- .after_help(OVERRIDE_UNSET_HELP)
- .arg(Arg::with_name("path")
- .long("path")
- .takes_value(true)
- .help("Path to the directory"))
- .arg(Arg::with_name("nonexistent")
- .long("nonexistent")
- .takes_value(false)
- .help("Remove override toolchain for all nonexistent directories")))
- .subcommand(SubCommand::with_name("add")
- .setting(AppSettings::Hidden) // synonym for 'set'
- .arg(Arg::with_name("toolchain")
- .required(true)))
- .subcommand(SubCommand::with_name("remove")
- .setting(AppSettings::Hidden) // synonym for 'unset'
- .about("Remove the override toolchain for a directory")
- .arg(Arg::with_name("path")
- .long("path")
- .takes_value(true))
- .arg(Arg::with_name("nonexistent")
- .long("nonexistent")
- .takes_value(false)
- .help("Remove override toolchain for all nonexistent directories"))))
- .subcommand(SubCommand::with_name("run")
- .about("Run a command with an environment configured for a given toolchain")
- .after_help(RUN_HELP)
- .setting(AppSettings::TrailingVarArg)
- .arg(Arg::with_name("toolchain").required(true))
- .arg(Arg::with_name("command")
- .required(true)
- .multiple(true)
- .use_delimiter(false)))
- .subcommand(SubCommand::with_name("which")
- .about("Display which binary will be run for a given command")
- .arg(Arg::with_name("command").required(true)))
- .subcommand(SubCommand::with_name("doc")
- .about("Open the documentation for the current toolchain")
- .after_help(DOC_HELP)
- .arg(Arg::with_name("book")
- .long("book")
- .help("The Rust Programming Language book"))
- .arg(Arg::with_name("std")
- .long("std")
- .help("Standard library API documentation"))
- .group(ArgGroup::with_name("page").args(&["book", "std"])))
- .subcommand(SubCommand::with_name("man")
- .about("View the man page for a given command")
- .arg(Arg::with_name("command").required(true))
- .arg(Arg::with_name("toolchain")
- .long("toolchain")
- .takes_value(true)))
- .subcommand(SubCommand::with_name("self")
- .about("Modify the rustup installation")
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("update")
- .about("Download and install updates to rustup"))
- .subcommand(SubCommand::with_name("uninstall")
- .about("Uninstall rustup.")
- .arg(Arg::with_name("no-prompt").short("y")))
- .subcommand(SubCommand::with_name("upgrade-data")
- .about("Upgrade the internal data format.")))
- .subcommand(SubCommand::with_name("telemetry")
- .about("rustup telemetry commands")
- .setting(AppSettings::Hidden)
- .setting(AppSettings::VersionlessSubcommands)
- .setting(AppSettings::DeriveDisplayOrder)
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("enable").about("Enable rustup telemetry"))
- .subcommand(SubCommand::with_name("disable").about("Disable rustup telemetry"))
- .subcommand(SubCommand::with_name("analyze").about("Analyze stored telemetry")))
- .subcommand(SubCommand::with_name("set")
- .about("Alter rustup settings")
- // .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("default-host")
- .about("The triple used to identify toolchains when not specified")
- .arg(Arg::with_name("host_triple").required(true))))
- .subcommand(SubCommand::with_name("completions")
- .about("Generate completion scripts for your shell")
- .after_help(COMPLETIONS_HELP)
- .setting(AppSettings::ArgRequiredElseHelp)
- .arg(Arg::with_name("shell").possible_values(&Shell::variants())))
-}
-
-static RUSTUP_HELP: &'static str = r"
-rustup installs The Rust Programming Language from the official
-release channels, enabling you to easily switch between stable, beta,
-and nightly compilers and keep them updated. It makes cross-compiling
-simpler with binary builds of the standard library for common platforms.
-
-If you are new to Rust consider running `rustup doc --book`
-to learn Rust.";
-
-static SHOW_HELP: &'static str = r"
-Shows the name of the active toolchain and the version of `rustc`.
-
-If the active toolchain has installed support for additional
-compilation targets, then they are listed as well.
-
-If there are multiple toolchains installed then all installed
-toolchains are listed as well.";
-
-static UPDATE_HELP: &'static str = r"
-With no toolchain specified, the `update` command updates each of the
-installed toolchains from the official release channels, then updates
-rustup itself.
-
-If given a toolchain argument then `update` updates that toolchain,
-the same as `rustup toolchain install`.
-
-'toolchain' specifies a toolchain name, such as 'stable', 'nightly',
-or '1.8.0'. For more information see `rustup help toolchain`.";
-
-static TOOLCHAIN_INSTALL_HELP: &'static str = r"
-Installs a specific rust toolchain.
-
-The 'install' command is an alias for 'rustup update <toolchain>'.
-
-'toolchain' specifies a toolchain name, such as 'stable', 'nightly',
-or '1.8.0'. For more information see `rustup help toolchain`.";
-
-static DEFAULT_HELP: &'static str = r"
-Sets the default toolchain to the one specified. If the toolchain is
-not already installed then it is installed first.";
-
-static TOOLCHAIN_HELP: &'static str = r"
-Many `rustup` commands deal with *toolchains*, a single installation
-of the Rust compiler. `rustup` supports multiple types of
-toolchains. The most basic track the official release channels:
-'stable', 'beta' and 'nightly'; but `rustup` can also install
-toolchains from the official archives, for alternate host platforms,
-and from local builds.
-
-Standard release channel toolchain names have the following form:
-
- <channel>[-<date>][-<host>]
-
- <channel> = stable|beta|nightly|<version>
- <date> = YYYY-MM-DD
- <host> = <target-triple>
-
-'channel' is either a named release channel or an explicit version
-number, such as '1.8.0'. Channel names can be optionally appended with
-an archive date, as in 'nightly-2014-12-18', in which case the
-toolchain is downloaded from the archive for that date.
-
-Finally, the host may be specified as a target triple. This is most
-useful for installing a 32-bit compiler on a 64-bit platform, or for
-installing the [MSVC-based toolchain] on Windows. For example:
-
- rustup toolchain install stable-x86_64-pc-windows-msvc
-
-For convenience, elements of the target triple that are omitted will be
-inferred, so the above could be written:
-
- $ rustup default stable-msvc
-
-Toolchain names that don't name a channel instead can be used to name
-custom toolchains with the `rustup toolchain link` command.";
-
-static OVERRIDE_HELP: &'static str = r"
-Overrides configure rustup to use a specific toolchain when
-running in a specific directory.
-
-Directories can be assigned their own Rust toolchain with
-`rustup override`. When a directory has an override then
-any time `rustc` or `cargo` is run inside that directory,
-or one of its child directories, the override toolchain
-will be invoked.
-
-To pin to a specific nightly:
-
- rustup override set nightly-2014-12-18
-
-Or a specific stable release:
-
- rustup override set 1.0.0
-
-To see the active toolchain use `rustup show`. To remove the override
-and use the default toolchain again, `rustup override unset`.";
-
-static OVERRIDE_UNSET_HELP: &'static str = r"
-If `--path` argument is present, removes the override toolchain for
-the specified directory. If `--nonexistent` argument is present, removes
-the override toolchain for all nonexistent directories. Otherwise,
-removes the override toolchain for the current directory.";
-
-static RUN_HELP: &'static str = r"
-Configures an environment to use the given toolchain and then runs
-the specified program. The command may be any program, not just
-rustc or cargo. This can be used for testing arbitrary toolchains
-without setting an override.
-
-Commands explicitly proxied by `rustup` (such as `rustc` and `cargo`)
-also have a shorthand for this available. The toolchain can be set by
-using `+toolchain` as the first argument. These are equivalent:
-
- cargo +nightly build
-
- rustup run nightly cargo build";
-
-static DOC_HELP: &'static str = r"
-Opens the documentation for the currently active toolchain with the
-default browser.
-
-By default, it opens the documentation index. Use the various flags to
-open specific pieces of documentation.";
-
-static COMPLETIONS_HELP: &'static str = r"
-One can generate a completion script for `rustup` that is compatible with
-a given shell. The script is output on `stdout` allowing one to re-direct
-the output to the file of their choosing. Where you place the file will
-depend on which shell, and which operating system you are using. Your
-particular configuration may also determine where these scripts need
-to be placed.
-
-Here are some common set ups for the three supported shells under
-Unix and similar operating systems (such as GNU/Linux).
-
-BASH:
-
-Completion files are commonly stored in `/usr/share/bash-completion/completions`
-
-Run the command:
-
-`rustup completions bash > /usr/share/bash-completion/completions/rustup.bash`
-
-This installs the completion script. You may have to log out and log
-back in to your shell session for the changes to take affect.
-
-FISH:
-
-Fish completion files are commonly stored in
-`$HOME/.config/fish/completions`
-
-Run the command:
-`rustup completions fish > ~/.config/fish/completions/rustup.fish`
-
-This installs the completion script. You may have to log out and log
-back in to your shell session for the changes to take affect.
-
-ZSH:
-
-ZSH completions are commonly stored in any directory listed in your
-`$fpath` variable. To use these completions, you must either add the
-generated script to one of those directories, or add your own
-to this list.
-
-Adding a custom directory is often the safest best if you're unsure
-of which directory to use. First create the directory, for this
-example we'll create a hidden directory inside our `$HOME` directory
-
-`mkdir ~/.zfunc`
-
-Then add the following lines to your `.zshrc` just before `compinit`
-
-`fpath+=~/.zfunc`
-
-Now you can install the completions script using the following command
-
-`rustup completions zsh > ~/.zfunc/_rustup`
-
-You must then either log out and log back in, or simply run
-
-`exec zsh`
-
-For the new completions to take affect.
-
-CUSTOM LOCATIONS:
-
-Alternatively, you could save these files to the place of your choosing,
-such as a custom directory inside your $HOME. Doing so will require you
-to add the proper directives, such as `source`ing inside your login
-script. Consult your shells documentation for how to add such directives.
-
-POWERSHELL:
-
-The powershell completion scripts require PowerShell v5.0+ (which comes
-Windows 10, but can be downloaded separately for windows 7 or 8.1).
-
-First, check if a profile has already been set
-
-`PS C:\> Test-Path $profile`
-
-If the above command returns `False` run the following
-
-`PS C:\> New-Item -path $profile -type file --force`
-
-Now open the file provided by `$profile` (if you used the `New-Item` command
-it will be `%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`
-
-Next, we either save the completions file into our profile, or into a separate file
-and source it inside our profile. To save the completions into our profile simply
-use";
diff --git a/clap/clap-perf/clap_perf.dat b/clap/clap-perf/clap_perf.dat
deleted file mode 100644
index 6a8592c..0000000
--- a/clap/clap-perf/clap_perf.dat
+++ /dev/null
@@ -1,8 +0,0 @@
-#Version Date Builder Err Usage Err Parse1 Err Parse2 Err
-1.0 2015-07-07 12408 840 16830 229 21235 725 27387 910
-1.1 2015-07-16 11885 191 16670 595 20919 252 26868 457
-1.2 2015-08-14 12563 587 17190 311 22421 233 28232 624
-1.3 2015-09-01 10534 131 14648 874 18213 1070 24101 361
-1.4 2015-09-09 10223 852 13203 749 18924 1216 23492 944
-1.5 2015-11-12 5422 416 7974 680 9723 792 13389 1151
-2.0 2016-01-27 4783 376 5263 481 9651 1015 10577 191
diff --git a/clap/clap-perf/clap_perf.png b/clap/clap-perf/clap_perf.png
deleted file mode 100644
index caaefb0..0000000
--- a/clap/clap-perf/clap_perf.png
+++ /dev/null
Binary files differ
diff --git a/clap/clap-perf/plot_perf.gp b/clap/clap-perf/plot_perf.gp
deleted file mode 100755
index 4db6a87..0000000
--- a/clap/clap-perf/plot_perf.gp
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/gnuplot
-reset
-set terminal png
-set output "clap_perf.png"
-
-set xlabel "Version"
-set xrange [0.9:2.1]
-set ylabel "Time (ns)"
-set yrange [0:35000]
-
-set title "clap-rs Performance (Parse Time - Lower is Better) by Version"
-set key inside right top
-set grid
-set style line 1 lc rgb '#0060ad' lt 1 lw 1 pt 7 ps .5 # --- blue
-set style line 2 lc rgb '#dd181f' lt 1 lw 1 pt 5 ps .5 # --- red
-set style line 3 lc rgb '#18dd00' lt 1 lw 1 pt 7 ps .5 # --- green
-set style line 4 lc rgb '#000000' lt 1 lw 1 pt 5 ps .5 # --- black
-
-plot "clap_perf.dat" u 1:3:4 notitle w yerrorbars ls 1, \
- "" u 1:3 t "Create Parser Using Builder" w lines ls 1, \
- "" u 1:5:6 notitle w yerrorbars ls 2, \
- "" u 1:5 t "Create Parser Usage String" w lines ls 2, \
- "" u 1:7:8 notitle "Parse Complex Args" w yerrorbars ls 3, \
- "" u 1:7 t "Parse Complex Args" w lines ls 3, \
- "" u 1:9:10 notitle w yerrorbars ls 4, \
- "" u 1:9 t "Parse Very Complex Args" w lines ls 4
diff --git a/clap/clap-test.rs b/clap/clap-test.rs
deleted file mode 100644
index 7d57ac4..0000000
--- a/clap/clap-test.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-#[allow(unused_imports, dead_code)]
-mod test {
- use std::str;
- use std::io::{Cursor, Write};
-
- use regex::Regex;
-
- use clap::{App, Arg, SubCommand, ArgGroup};
-
- fn compare<S, S2>(l: S, r: S2) -> bool
- where S: AsRef<str>,
- S2: AsRef<str>
- {
- let re = Regex::new("\x1b[^m]*m").unwrap();
- // Strip out any mismatching \r character on windows that might sneak in on either side
- let ls = l.as_ref().trim().replace("\r", "");
- let rs = r.as_ref().trim().replace("\r", "");
- let left = re.replace_all(&*ls, "");
- let right = re.replace_all(&*rs, "");
- let b = left == right;
- if !b {
- println!();
- println!("--> left");
- println!("{}", left);
- println!("--> right");
- println!("{}", right);
- println!("--")
- }
- b
- }
-
- pub fn compare_output(l: App, args: &str, right: &str, stderr: bool) -> bool {
- let mut buf = Cursor::new(Vec::with_capacity(50));
- let res = l.get_matches_from_safe(args.split(' ').collect::<Vec<_>>());
- let err = res.unwrap_err();
- err.write_to(&mut buf).unwrap();
- let content = buf.into_inner();
- let left = String::from_utf8(content).unwrap();
- assert_eq!(stderr, err.use_stderr());
- compare(left, right)
- }
- pub fn compare_output2(l: App, args: &str, right1: &str, right2: &str, stderr: bool) -> bool {
- let mut buf = Cursor::new(Vec::with_capacity(50));
- let res = l.get_matches_from_safe(args.split(' ').collect::<Vec<_>>());
- let err = res.unwrap_err();
- err.write_to(&mut buf).unwrap();
- let content = buf.into_inner();
- let left = String::from_utf8(content).unwrap();
- assert_eq!(stderr, err.use_stderr());
- compare(&*left, right1) || compare(&*left, right2)
- }
-
- // Legacy tests from the Python script days
-
- pub fn complex_app() -> App<'static, 'static> {
- let args = "-o --option=[opt]... 'tests options'
- [positional] 'tests positionals'";
- let opt3_vals = ["fast", "slow"];
- let pos3_vals = ["vi", "emacs"];
- App::new("clap-test")
- .version("v1.4.8")
- .about("tests clap library")
- .author("Kevin K. <kbknapp@gmail.com>")
- .args_from_usage(args)
- .arg(Arg::from_usage("-f --flag... 'tests flags'")
- .global(true))
- .args(&[
- Arg::from_usage("[flag2] -F 'tests flags with exclusions'").conflicts_with("flag").requires("long-option-2"),
- Arg::from_usage("--long-option-2 [option2] 'tests long options with exclusions'").conflicts_with("option").requires("positional2"),
- Arg::from_usage("[positional2] 'tests positionals with exclusions'"),
- Arg::from_usage("-O --Option [option3] 'specific vals'").possible_values(&opt3_vals),
- Arg::from_usage("[positional3]... 'tests specific values'").possible_values(&pos3_vals),
- Arg::from_usage("--multvals [one] [two] 'Tests multiple values, not mult occs'"),
- Arg::from_usage("--multvalsmo... [one] [two] 'Tests multiple values, and mult occs'"),
- Arg::from_usage("--minvals2 [minvals]... 'Tests 2 min vals'").min_values(2),
- Arg::from_usage("--maxvals3 [maxvals]... 'Tests 3 max vals'").max_values(3)
- ])
- .subcommand(SubCommand::with_name("subcmd")
- .about("tests subcommands")
- .version("0.1")
- .author("Kevin K. <kbknapp@gmail.com>")
- .arg_from_usage("-o --option [scoption]... 'tests options'")
- .arg_from_usage("-s --subcmdarg [subcmdarg] 'tests other args'")
- .arg_from_usage("[scpositional] 'tests positionals'"))
- }
-}
diff --git a/clap/clap_dep_graph.dot b/clap/clap_dep_graph.dot
deleted file mode 100644
index 9d7e5c6..0000000
--- a/clap/clap_dep_graph.dot
+++ /dev/null
@@ -1,41 +0,0 @@
-digraph dependencies {
- N0[label="clap"];
- N1[label="ansi_term"];
- N2[label="bitflags"];
- N3[label="clippy",color=blue];
- N4[label="strsim"];
- N5[label="term_size"];
- N6[label="unicode-segmentation"];
- N7[label="unicode-width"];
- N8[label="vec_map"];
- N9[label="yaml-rust",color=red];
- N10[label="clippy_lints",color=blue];
- N11[label="matches",color=blue];
- N12[label="quine-mc_cluskey",color=blue];
- N13[label="regex-syntax",color=red];
- N14[label="rustc-serialize",color=blue];
- N15[label="semver",color=blue];
- N16[label="toml",color=blue];
- N17[label="unicode-normalization",color=blue];
- N0 -> N1[label="",style=dashed];
- N0 -> N2[label=""];
- N0 -> N3[label="",style=dashed,color=blue];
- N0 -> N4[label="",style=dashed];
- N0 -> N5[label="",style=dashed];
- N0 -> N6[label=""];
- N0 -> N7[label=""];
- N0 -> N8[label=""];
- N0 -> N9[label="",style=dashed,color=red];
- N3 -> N10[label="",style=dashed,color=blue];
- N5 -> N3[label="",style=dashed,color=blue];
- N9 -> N3[label="",style=dashed,color=blue];
- N9 -> N13[label="",style=dashed,color=red];
- N10 -> N11[label="",style=dashed,color=blue];
- N10 -> N12[label="",style=dashed,color=blue];
- N10 -> N13[label="",style=dashed,color=blue];
- N10 -> N14[label="",style=dashed,color=blue];
- N10 -> N15[label="",style=dashed,color=blue];
- N10 -> N16[label="",style=dashed,color=blue];
- N10 -> N17[label="",style=dashed,color=blue];
- N16 -> N14[label="",style=dashed,color=blue];
-}
diff --git a/clap/clap_dep_graph.png b/clap/clap_dep_graph.png
deleted file mode 100644
index 8290d6f..0000000
--- a/clap/clap_dep_graph.png
+++ /dev/null
Binary files differ
diff --git a/clap/examples/01a_quick_example.rs b/clap/examples/01a_quick_example.rs
deleted file mode 100644
index c7fa20f..0000000
--- a/clap/examples/01a_quick_example.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-extern crate clap;
-
-use clap::{App, SubCommand};
-
-fn main() {
-
- // This example shows how to create an application with several arguments using usage strings, which can be
- // far less verbose that shown in 01b_QuickExample.rs, but is more readable. The downside is you cannot set
- // the more advanced configuration options using this method (well...actually you can, you'll see ;) )
- //
- // The example below is functionally identical to the 01b_quick_example.rs and 01c_quick_example.rs
- //
- // Create an application with 5 possible arguments (2 auto generated) and 2 subcommands (1 auto generated)
- // - A config file
- // + Uses "-c filename" or "--config filename"
- // - An output file
- // + A positional argument (i.e. "$ myapp output_filename")
- // - A debug flag
- // + Uses "-d" or "--debug"
- // + Allows multiple occurrences of such as "-dd" (for vary levels of debugging, as an example)
- // - A help flag (automatically generated by clap)
- // + Uses "-h" or "--help" (Only autogenerated if you do NOT specify your own "-h" or "--help")
- // - A version flag (automatically generated by clap)
- // + Uses "-V" or "--version" (Only autogenerated if you do NOT specify your own "-V" or "--version")
- // - A subcommand "test" (subcommands behave like their own apps, with their own arguments
- // + Used by "$ myapp test" with the following arguments
- // > A list flag
- // = Uses "-l" (usage is "$ myapp test -l"
- // > A help flag (automatically generated by clap
- // = Uses "-h" or "--help" (full usage "$ myapp test -h" or "$ myapp test --help")
- // > A version flag (automatically generated by clap
- // = Uses "-V" or "--version" (full usage "$ myapp test -V" or "$ myapp test --version")
- // - A subcommand "help" (automatically generated by clap because we specified a subcommand of our own)
- // + Used by "$ myapp help" (same functionality as "-h" or "--help")
- let matches = App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .args_from_usage("-c, --config=[FILE] 'Sets a custom config file'
- <output> 'Sets an optional output file'
- -d... 'Turn debugging information on'")
- .subcommand(SubCommand::with_name("test")
- .about("does testing things")
- .arg_from_usage("-l, --list 'lists test values'"))
- .get_matches();
-
- // You can check the value provided by positional arguments, or option arguments
- if let Some(o) = matches.value_of("output") {
- println!("Value for output: {}", o);
- }
-
- if let Some(c) = matches.value_of("config") {
- println!("Value for config: {}", c);
- }
-
- // You can see how many times a particular flag or argument occurred
- // Note, only flags can have multiple occurrences
- match matches.occurrences_of("d") {
- 0 => println!("Debug mode is off"),
- 1 => println!("Debug mode is kind of on"),
- 2 => println!("Debug mode is on"),
- 3 | _ => println!("Don't be crazy"),
- }
-
- // You can check for the existence of subcommands, and if found use their
- // matches just as you would the top level app
- if let Some(matches) = matches.subcommand_matches("test") {
- // "$ myapp test" was run
- if matches.is_present("list") {
- // "$ myapp test -l" was run
- println!("Printing testing lists...");
- } else {
- println!("Not printing testing lists...");
- }
- }
-
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/01b_quick_example.rs b/clap/examples/01b_quick_example.rs
deleted file mode 100644
index 7f455a8..0000000
--- a/clap/examples/01b_quick_example.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, SubCommand};
-
-fn main() {
-
- // This method shows the traditional, and slightly more configurable way to set up arguments. This method is
- // more verbose, but allows setting more configuration options, and even supports easier dynamic generation.
- //
- // The example below is functionally identical to the 01a_quick_example.rs and 01c_quick_example.rs
- //
- // *NOTE:* You can actually achieve the best of both worlds by using Arg::from_usage() (instead of Arg::with_name())
- // and *then* setting any additional properties.
- //
- // Create an application with 5 possible arguments (2 auto generated) and 2 subcommands (1 auto generated)
- // - A config file
- // + Uses "-c filename" or "--config filename"
- // - An output file
- // + A positional argument (i.e. "$ myapp output_filename")
- // - A debug flag
- // + Uses "-d" or "--debug"
- // + Allows multiple occurrences of such as "-dd" (for vary levels of debugging, as an example)
- // - A help flag (automatically generated by clap)
- // + Uses "-h" or "--help" (Only autogenerated if you do NOT specify your own "-h" or "--help")
- // - A version flag (automatically generated by clap)
- // + Uses "-V" or "--version" (Only autogenerated if you do NOT specify your own "-V" or "--version")
- // - A subcommand "test" (subcommands behave like their own apps, with their own arguments
- // + Used by "$ myapp test" with the following arguments
- // > A list flag
- // = Uses "-l" (usage is "$ myapp test -l"
- // > A help flag (automatically generated by clap
- // = Uses "-h" or "--help" (full usage "$ myapp test -h" or "$ myapp test --help")
- // > A version flag (automatically generated by clap
- // = Uses "-V" or "--version" (full usage "$ myapp test -V" or "$ myapp test --version")
- // - A subcommand "help" (automatically generated by clap because we specified a subcommand of our own)
- // + Used by "$ myapp help" (same functionality as "-h" or "--help")
- let matches = App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .arg(Arg::with_name("config")
- .short("c")
- .long("config")
- .value_name("FILE")
- .help("Sets a custom config file")
- .takes_value(true))
- .arg(Arg::with_name("output")
- .help("Sets an optional output file")
- .index(1))
- .arg(Arg::with_name("debug")
- .short("d")
- .multiple(true)
- .help("Turn debugging information on"))
- .subcommand(SubCommand::with_name("test")
- .about("does testing things")
- .arg(Arg::with_name("list")
- .short("l")
- .help("lists test values")))
- .get_matches();
-
- // You can check the value provided by positional arguments, or option arguments
- if let Some(o) = matches.value_of("output") {
- println!("Value for output: {}", o);
- }
-
- if let Some(c) = matches.value_of("config") {
- println!("Value for config: {}", c);
- }
-
- // You can see how many times a particular flag or argument occurred
- // Note, only flags can have multiple occurrences
- match matches.occurrences_of("debug") {
- 0 => println!("Debug mode is off"),
- 1 => println!("Debug mode is kind of on"),
- 2 => println!("Debug mode is on"),
- 3 | _ => println!("Don't be crazy"),
- }
-
- // You can check for the existence of subcommands, and if found use their
- // matches just as you would the top level app
- if let Some(matches) = matches.subcommand_matches("test") {
- // "$ myapp test" was run
- if matches.is_present("list") {
- // "$ myapp test -l" was run
- println!("Printing testing lists...");
- } else {
- println!("Not printing testing lists...");
- }
- }
-
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/01c_quick_example.rs b/clap/examples/01c_quick_example.rs
deleted file mode 100644
index 071bdc0..0000000
--- a/clap/examples/01c_quick_example.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-#[macro_use]
-extern crate clap;
-
-fn main() {
- // This example shows how to create an application with several arguments using macro builder.
- // It combines the simplicity of the from_usage methods and the performance of the Builder Pattern.
- //
- // The example below is functionally identical to the one in 01a_quick_example.rs and 01b_quick_example.rs
- //
- // Create an application with 5 possible arguments (2 auto generated) and 2 subcommands (1 auto generated)
- // - A config file
- // + Uses "-c filename" or "--config filename"
- // - An output file
- // + A positional argument (i.e. "$ myapp output_filename")
- // - A debug flag
- // + Uses "-d" or "--debug"
- // + Allows multiple occurrences of such as "-dd" (for vary levels of debugging, as an example)
- // - A help flag (automatically generated by clap)
- // + Uses "-h" or "--help" (Only autogenerated if you do NOT specify your own "-h" or "--help")
- // - A version flag (automatically generated by clap)
- // + Uses "-V" or "--version" (Only autogenerated if you do NOT specify your own "-V" or "--version")
- // - A subcommand "test" (subcommands behave like their own apps, with their own arguments
- // + Used by "$ myapp test" with the following arguments
- // > A list flag
- // = Uses "-l" (usage is "$ myapp test -l"
- // > A help flag (automatically generated by clap
- // = Uses "-h" or "--help" (full usage "$ myapp test -h" or "$ myapp test --help")
- // > A version flag (automatically generated by clap
- // = Uses "-V" or "--version" (full usage "$ myapp test -V" or "$ myapp test --version")
- // - A subcommand "help" (automatically generated by clap because we specified a subcommand of our own)
- // + Used by "$ myapp help" (same functionality as "-h" or "--help")
- let matches = clap_app!(myapp =>
- (version: "1.0")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (about: "Does awesome things")
- (@arg CONFIG: -c --config +takes_value "Sets a custom config file")
- (@arg INPUT: +required "Sets the input file to use")
- (@arg debug: -d ... "Sets the level of debugging information")
- (@subcommand test =>
- (about: "controls testing features")
- (version: "1.3")
- (author: "Someone E. <someone_else@other.com>")
- (@arg verbose: -v --verbose "Print test information verbosely")
- )
- ).get_matches();
-
- // Calling .unwrap() is safe here because "INPUT" is required (if "INPUT" wasn't
- // required we could have used an 'if let' to conditionally get the value)
- println!("Using input file: {}", matches.value_of("INPUT").unwrap());
-
- // Gets a value for config if supplied by user, or defaults to "default.conf"
- let config = matches.value_of("CONFIG").unwrap_or("default.conf");
- println!("Value for config: {}", config);
-
- // Vary the output based on how many times the user used the "debug" flag
- // (i.e. 'myapp -d -d -d' or 'myapp -ddd' vs 'myapp -d'
- match matches.occurrences_of("debug") {
- 0 => println!("Debug mode is off"),
- 1 => println!("Debug mode is kind of on"),
- 2 => println!("Debug mode is on"),
- 3 | _ => println!("Don't be crazy"),
- }
-
- // You can information about subcommands by requesting their matches by name
- // (as below), requesting just the name used, or both at the same time
- if let Some(matches) = matches.subcommand_matches("test") {
- if matches.is_present("verbose") {
- println!("Printing verbosely...");
- } else {
- println!("Printing normally...");
- }
- }
-
- // more program logic goes here...
-}
diff --git a/clap/examples/02_apps.rs b/clap/examples/02_apps.rs
deleted file mode 100644
index 8e45640..0000000
--- a/clap/examples/02_apps.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-extern crate clap;
-
-use clap::App;
-
-fn main() {
- // Apps describe the top level application
- //
- // You create an App and set various options on that App using the "builder pattern"
- //
- // The options (version(), author(), about()) aren't mandatory, but recommended. There is
- // another option, usage(), which is an exception to the rule. This should only be used when
- // the default usage string automatically generated by clap doesn't suffice.
- //
- // You also set all the valid arguments your App should accept via the arg(), args(), arg_from_usage()
- // and args_from_usage() (as well as subcommands via the subcommand() and subcommands() methods) which
- // will be covered later.
- //
- // Once all options have been set, call one of the .get_matches* family of methods in order to
- // start the parsing and find all valid command line arguments that supplied by the user at
- // runtime. The name given to new() will be displayed when the version or help flags are used.
- App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .get_matches();
-
- // This example doesn't do much, but it *does* give automatic -h, --help, -V, and --version functionality ;)
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/03_args.rs b/clap/examples/03_args.rs
deleted file mode 100644
index c62d576..0000000
--- a/clap/examples/03_args.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
- // Args describe a possible valid argument which may be supplied by the user at runtime. There
- // are three different types of arguments (flags, options, and positional) as well as a fourth
- // special type of argument, called SubCommands (which will be discussed separately).
- //
- // Args are described in the same manner as Apps using the "builder pattern" with multiple
- // methods describing various settings for the individual arguments. Or by supplying a "usage"
- // string. Both methods have their pros and cons.
- //
- // Arguments can be added to applications in two manners, one at a time with the arg(), and
- // arg_from_usage() method, or multiple arguments at once via a Vec<Arg> inside the args() method,
- // or a single &str describing multiple Args (one per line) supplied to args_from_usage().
- //
- // There are various options which can be set for a given argument, some apply to any of the
- // three types of arguments, some only apply one or two of the types. *NOTE* if you set
- // incompatible options on a single argument, clap will panic! at runtime. This is by design,
- // so that you know right away an error was made by the developer, not the end user.
- //
- // # Help and Version
- // clap automatically generates a help and version flag for you, unless you specify your
- // own. By default help uses "-h" and "--help", and version uses "-V" and "--version". You can
- // safely override "-V" and "-h" to your own arguments, and "--help" and "--version" will still
- // be automatically generated for you.
- let matches = App::new("MyApp")
- // All application settings go here...
-
- // A simple "Flag" argument example (i.e. "-d") using the builder pattern
- .arg(Arg::with_name("debug")
- .help("turn on debugging information")
- .short("d"))
-
- // Two arguments, one "Option" argument (i.e. one that takes a value) such
- // as "-c some", and one positional argument (i.e. "myapp some_file")
- .args(&[
- Arg::with_name("config")
- .help("sets the config file to use")
- .takes_value(true)
- .short("c")
- .long("config"),
- Arg::with_name("input")
- .help("the input file to use")
- .index(1)
- .required(true)
- ])
-
- // *Note* the following two examples are convenience methods, if you wish
- // to still get the full configurability of Arg::with_name() and the readability
- // of arg_from_usage(), you can instantiate a new Arg with Arg::from_usage() and
- // still be able to set all the additional properties, just like Arg::with_name()
- //
- //
- // One "Flag" using a usage string
- .arg_from_usage("--license 'display the license file'")
-
- // Two args, one "Positional", and one "Option" using a usage string
- .args_from_usage("[output] 'Supply an output file to use'
- -i, --int=[IFACE] 'Set an interface to use'")
- .get_matches();
-
- // Here are some examples of using the arguments defined above. Keep in mind that this is only
- // an example, and may be somewhat contrived
- //
- // First we check if debugging should be on or not
- println!("Debugging mode is: {}", if matches.is_present("debug") { "ON" } else { "OFF" });
-
- // Next we print the config file we're using, if any was defined with either -c <file> or
- // --config <file>
- if let Some(config) = matches.value_of("config") {
- println!("A config file was passed in: {}", config);
- }
-
- // Let's print the <INPUT> file the user passed in. We can use .unwrap() here becase the arg is
- // required, and parsing would have failed if the user forgot it
- println!("Using input file: {}", matches.value_of("input").unwrap());
-
- // We could continue checking for and using arguments in this manner, such as "license",
- // "output", and "interface". Keep in mind that "output" and "interface" are optional, so you
- // shouldn't call .unwrap(). Instead, prefer using an 'if let' expression as we did with
- // "config"
-}
diff --git a/clap/examples/04_using_matches.rs b/clap/examples/04_using_matches.rs
deleted file mode 100644
index a0a986f..0000000
--- a/clap/examples/04_using_matches.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
-
- // Once all App settings (including all arguments) have been set, you call get_matches() which
- // parses the string provided by the user, and returns all the valid matches to the ones you
- // specified.
- //
- // You can then query the matches struct to get information about how the user ran the program
- // at startup.
- //
- // For this example, let's assume you created an App which accepts three arguments (plus two
- // generated by clap), a flag to display debugging information triggered with "-d" or
- // "--debug" as well as an option argument which specifies a custom configuration file to use
- // triggered with "-c file" or "--config file" or "--config=file" and finally a positional
- // argument which is the input file we want to work with, this will be the only required
- // argument.
- let matches = App::new("MyApp")
- .about("Parses an input file to do awesome things")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .arg(Arg::with_name("debug")
- .help("turn on debugging information")
- .short("d")
- .long("debug"))
- .arg(Arg::with_name("config")
- .help("sets the config file to use")
- .short("c")
- .long("config"))
- .arg(Arg::with_name("input")
- .help("the input file to use")
- .index(1)
- .required(true))
- .get_matches();
-
- // We can find out whether or not debugging was turned on
- if matches.is_present("debug") {
- println!("Debugging is turned on");
- }
-
- // If we wanted to do some custom initialization based off some configuration file
- // provided by the user, we could get the file (A string of the file)
- if let Some(file) = matches.value_of("config") {
- println!("Using config file: {}", file);
- }
-
- // Because "input" is required we can safely call unwrap() because had the user NOT
- // specified a value, clap would have explained the error the user, and exited.
- println!("Doing real work with file: {}", matches.value_of("input").unwrap() );
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/05_flag_args.rs b/clap/examples/05_flag_args.rs
deleted file mode 100644
index a6b8945..0000000
--- a/clap/examples/05_flag_args.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
-
- // Of the three argument types, flags are the most simple. Flags are simple switches which can
- // be either "on" or "off"
- //
- // clap also supports multiple occurrences of flags, the common example is "verbosity" where a
- // user could want a little information with "-v" or tons of information with "-v -v" or "-vv"
- let matches = App::new("MyApp")
- // Regular App configuration goes here...
-
- // We'll add a flag that represents an awesome meter...
- //
- // I'll explain each possible setting that "flags" accept. Keep in mind
- // that you DO NOT need to set each of these for every flag, only the ones
- // you want for your individual case.
- .arg(Arg::with_name("awesome")
- .help("turns up the awesome") // Displayed when showing help info
- .short("a") // Trigger this arg with "-a"
- .long("awesome") // Trigger this arg with "--awesome"
- .multiple(true) // This flag should allow multiple
- // occurrences such as "-aaa" or "-a -a"
- .requires("config") // Says, "If the user uses -a, they MUST
- // also use this other 'config' arg too"
- // Can also specify a list using
- // requires_all(Vec<&str>)
- .conflicts_with("output") // Opposite of requires(), says "if the
- // user uses -a, they CANNOT use 'output'"
- // also has a conflicts_with_all(Vec<&str>)
- )
- // NOTE: In order to compile this example, comment out requires() and
- // conflicts_with() because we have not defined an "output" or "config"
- // argument.
- .get_matches();
-
- // We can find out whether or not awesome was used
- if matches.is_present("awesome") {
- println!("Awesomeness is turned on");
- }
-
- // If we set the multiple() option of a flag we can check how many times the user specified
- //
- // Note: if we did not specify the multiple() option, and the user used "awesome" we would get
- // a 1 (no matter how many times they actually used it), or a 0 if they didn't use it at all
- match matches.occurrences_of("awesome") {
- 0 => println!("Nothing is awesome"),
- 1 => println!("Some things are awesome"),
- 2 => println!("Lots of things are awesome"),
- 3 | _ => println!("EVERYTHING is awesome!"),
- }
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/06_positional_args.rs b/clap/examples/06_positional_args.rs
deleted file mode 100644
index 1f29612..0000000
--- a/clap/examples/06_positional_args.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
-
- // Positional arguments are those values after the program name which are not preceded by any
- // identifier (such as "myapp some_file"). Positionals support many of the same options as
- // flags, as well as a few additional ones.
- let matches = App::new("MyApp")
- // Regular App configuration goes here...
-
- // We'll add two positional arguments, a input file, and a config file.
- //
- // I'll explain each possible setting that "positionals" accept. Keep in
- // mind that you DO NOT need to set each of these for every flag, only the
- // ones that apply to your individual case.
- .arg(Arg::with_name("input")
- .help("the input file to use") // Displayed when showing help info
- .index(1) // Set the order in which the user must
- // specify this argument (Starts at 1)
- .requires("config") // Says, "If the user uses "input", they MUST
- // also use this other 'config' arg too"
- // Can also specify a list using
- // requires_all(Vec<&str>)
- .conflicts_with("output") // Opposite of requires(), says "if the
- // user uses -a, they CANNOT use 'output'"
- // also has a conflicts_with_all(Vec<&str>)
- .required(true) // By default this argument MUST be present
- // NOTE: mutual exclusions take precedence over
- // required arguments
- )
- .arg(Arg::with_name("config")
- .help("the config file to use")
- .index(2)) // Note, we do not need to specify required(true)
- // if we don't want to, because "input" already
- // requires "config"
- // Note, we also do not need to specify requires("input")
- // because requires lists are automatically two-way
-
- // NOTE: In order to compile this example, comment out conflicts_with()
- // because we have not defined an "output" argument.
- .get_matches();
-
- // We can find out whether or not "input" or "config" were used
- if matches.is_present("input") {
- println!("An input file was specified");
- }
-
- // We can also get the values for those arguments
- if let Some(in_file) = matches.value_of("input") {
- // It's safe to call unwrap() because of the required options we set above
- println!("Doing work with {} and {}", in_file, matches.value_of("config").unwrap());
- }
- // Continued program logic goes here...
-}
diff --git a/clap/examples/07_option_args.rs b/clap/examples/07_option_args.rs
deleted file mode 100644
index 85ff0e5..0000000
--- a/clap/examples/07_option_args.rs
+++ /dev/null
@@ -1,71 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
-
- // Option arguments are those that take an additional value, such as "-c value". In clap they
- // support three types of specification, those with short() as "-o some", or those with long()
- // as "--option value" or "--option=value"
- //
- // Options also support a multiple setting, which is discussed in the example below.
- let matches = App::new("MyApp")
- // Regular App configuration goes here...
-
- // Assume we have an application that accepts an input file via the "-i file"
- // or the "--input file" (as well as "--input=file").
- // Below every setting supported by option arguments is discussed.
- // NOTE: You DO NOT need to specify each setting, only those which apply
- // to your particular case.
- .arg(Arg::with_name("input")
- .help("the input file to use") // Displayed when showing help info
- .takes_value(true) // MUST be set to true in order to be an "option" argument
- .short("i") // This argument is triggered with "-i"
- .long("input") // This argument is triggered with "--input"
- .multiple(true) // Set to true if you wish to allow multiple occurrences
- // such as "-i file -i other_file -i third_file"
- .required(true) // By default this argument MUST be present
- // NOTE: mutual exclusions take precedence over
- // required arguments
- .requires("config") // Says, "If the user uses "input", they MUST
- // also use this other 'config' arg too"
- // Can also specify a list using
- // requires_all(Vec<&str>)
- .conflicts_with("output") // Opposite of requires(), says "if the
- // user uses -a, they CANNOT use 'output'"
- // also has a conflicts_with_all(Vec<&str>)
- )
- // NOTE: In order to compile this example, comment out conflicts_with()
- // and requires() because we have not defined an "output" or "config"
- // argument.
- .get_matches();
-
- // We can find out whether or not "input" was used
- if matches.is_present("input") {
- println!("An input file was specified");
- }
-
- // We can also get the value for "input"
- //
- // NOTE: If we specified multiple(), this will only return the _FIRST_
- // occurrence
- if let Some(in_file) = matches.value_of("input") {
- println!("An input file: {}", in_file);
- }
-
- // If we specified the multiple() setting we can get all the values
- if let Some(in_v) = matches.values_of("input") {
- for in_file in in_v {
- println!("An input file: {}", in_file);
- }
- }
-
- // We can see how many times the option was used with the occurrences_of() method
- //
- // NOTE: Just like with flags, if we did not specify the multiple() setting this will only
- // return 1 no matter how many times the argument was used (unless it wasn't used at all, in
- // in which case 0 is returned)
- println!("The \"input\" argument was used {} times", matches.occurrences_of("input"));
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/08_subcommands.rs b/clap/examples/08_subcommands.rs
deleted file mode 100644
index 73bd098..0000000
--- a/clap/examples/08_subcommands.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, SubCommand};
-
-fn main() {
-
- // SubCommands function exactly like sub-Apps, because that's exactly what they are. Each
- // instance of a SubCommand can have it's own version, author(s), Args, and even it's own
- // subcommands.
- //
- // # Help and Version
- // Just like Apps, each subcommand will get it's own "help" and "version" flags automatically
- // generated. Also, like Apps, you can override "-V" or "-h" safely and still get "--help" and
- // "--version" auto generated.
- //
- // NOTE: If you specify a subcommand for your App, clap will also autogenerate a "help"
- // subcommand along with "-h" and "--help" (applies to sub-subcommands as well).
- //
- // Just like arg() and args(), subcommands can be specified one at a time via subcommand() or
- // multiple ones at once with a Vec<SubCommand> provided to subcommands().
- let matches = App::new("MyApp")
- // Normal App and Arg configuration goes here...
-
- // In the following example assume we wanted an application which
- // supported an "add" subcommand, this "add" subcommand also took
- // one positional argument of a file to add:
- .subcommand(SubCommand::with_name("add") // The name we call argument with
- .about("Adds files to myapp") // The message displayed in "myapp -h"
- // or "myapp help"
- .version("0.1") // Subcommands can have independent version
- .author("Kevin K.") // And authors
- .arg(Arg::with_name("input") // And their own arguments
- .help("the file to add")
- .index(1)
- .required(true)))
- .get_matches();
-
- // You can check if a subcommand was used like normal
- if matches.is_present("add") {
- println!("'myapp add' was run.");
- }
-
- // You can get the independent subcommand matches (which function exactly like App matches)
- if let Some(matches) = matches.subcommand_matches("add") {
- // Safe to use unwrap() because of the required() option
- println!("Adding file: {}", matches.value_of("input").unwrap());
- }
-
- // You can also match on a subcommand's name
- match matches.subcommand_name() {
- Some("add") => println!("'myapp add' was used"),
- None => println!("No subcommand was used"),
- _ => println!("Some other subcommand was used"),
- }
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/09_auto_version.rs b/clap/examples/09_auto_version.rs
deleted file mode 100644
index dfd221f..0000000
--- a/clap/examples/09_auto_version.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-#[macro_use]
-extern crate clap;
-
-use clap::App;
-
-fn main() {
- // You can have clap pull the application version directly from your Cargo.toml starting with
- // clap v0.4.14 on crates.io (or master#a81f915 on github). Using Rust's env! macro like this:
- //
- // let version = format!("{}.{}.{}{}",
- // env!("CARGO_PKG_VERSION_MAJOR"),
- // env!("CARGO_PKG_VERSION_MINOR"),
- // env!("CARGO_PKG_VERSION_PATCH"),
- // option_env!("CARGO_PKG_VERSION_PRE").unwrap_or(""));
- //
- // Starting from v0.6.6 on crates.io you can also use the crate_version!() macro instead of
- // manually using the env!() macros. Under the hood, the macro uses this exact method to get
- // the version.
- //
- // Thanks to https://github.com/jhelwig for pointing this out
- App::new("myapp")
- .about("does awesome things")
- // use crate_version! to pull the version number
- .version(crate_version!())
- .get_matches();
-
- // running this app with the -V or --version will display whatever version is in your
- // Cargo.toml, the default being: myapp 0.0.1
-}
diff --git a/clap/examples/10_default_values.rs b/clap/examples/10_default_values.rs
deleted file mode 100644
index ca50981..0000000
--- a/clap/examples/10_default_values.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
- // There are two ways in which to get a default value, one is to use claps Arg::default_value
- // method, and the other is to use Rust's built in Option::unwrap_or method.
- //
- // I'll demo both here.
- //
- // First, we'll use clap's Arg::default_value with an "INPUT" file.
- let matches = App::new("myapp").about("does awesome things")
- .arg(Arg::with_name("INPUT")
- .help("The input file to use") // Note, we don't need to specify
- // anything like, "Defaults to..."
- // because clap will automatically
- // generate that for us, and place
- // it in the help text
- .default_value("input.txt")
- .index(1))
-
- // Next we'll use the Option::unwrap_or method on this "CONFIG" option
- .arg(Arg::with_name("CONFIG")
- // Note that we have to manually include some verbiage to the user
- // telling them what the default will be.
- .help("The config file to use (default is \"config.json\")")
- .short("c")
- .takes_value(true))
- .get_matches();
-
- // It's safe to call unwrap because the value with either be what the user input at runtime
- // or "input.txt"
- let input = matches.value_of("INPUT").unwrap();
-
- // Using Option::unwrap_or we get the same affect, but without the added help text injection
- let config_file = matches.value_of("CONFIG").unwrap_or("config.json");
-
- println!("The input file is: {}", input);
- println!("The config file is: {}", config_file);
-}
diff --git a/clap/examples/11_only_specific_values.rs b/clap/examples/11_only_specific_values.rs
deleted file mode 100644
index 3445218..0000000
--- a/clap/examples/11_only_specific_values.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
- // If you have arguments of specific values you want to test for, you can use the
- // .possible_values() method of Arg
- //
- // This allows you specify the valid values for that argument. If the user does not use one of
- // those specific values, they will receive a graceful exit with error message informing them
- // of the mistake, and what the possible valid values are
- //
- // For this example, assume you want one positional argument of either "fast" or "slow"
- // i.e. the only possible ways to run the program are "myprog fast" or "myprog slow"
- let matches = App::new("myapp").about("does awesome things")
- .arg(Arg::with_name("MODE")
- .help("What mode to run the program in")
- .index(1)
- .possible_values(&["fast", "slow"])
- .required(true))
- .get_matches();
-
- // Note, it's safe to call unwrap() because the arg is required
- match matches.value_of("MODE").unwrap() {
- "fast" => {
- // Do fast things...
- },
- "slow" => {
- // Do slow things...
- },
- _ => unreachable!()
- }
-}
diff --git a/clap/examples/12_typed_values.rs b/clap/examples/12_typed_values.rs
deleted file mode 100644
index 3d03e4f..0000000
--- a/clap/examples/12_typed_values.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-#[macro_use]
-extern crate clap;
-
-use clap::App;
-
-fn main() {
- // You can use some convenience macros provided by clap to get typed values, so long as the
- // type you specify implements std::str::FromStr
- //
- // This works for both single, and multiple values (multiple values returns a Vec<T>)
- //
- // There are also two ways in which to get types, those where failures cause the program to exit
- // with an error and usage string, and those which return a Result<T,String> or Result<Vec<T>,String>
- // respectively. Both methods support single and multiple values.
- //
- // The macro which returns a Result allows you decide what to do upon a failure, exit, provide a
- // default value, etc. You have control. But it also means you have to write the code or boiler plate
- // to handle those instances.
- //
- // That is why the second method exists, so you can simply get a T or Vec<T> back, or be sure the
- // program will exit gracefully. The catch is, the second method should *only* be used on required
- // arguments, because if the argument isn't found, it exits. Just FYI ;)
- //
- // The following example shows both methods.
- //
- // **NOTE:** to use the macros, you must include #[macro_use] just above the 'extern crate clap;'
- // declaration in your crate root.
- let matches = App::new("myapp")
- // Create two arguments, a required positional which accepts multiple values
- // and an optional '-l value'
- .args_from_usage(
- "<seq>... 'A sequence of whole positive numbers, i.e. 20 25 30'
- -l [len] 'A length to use, defaults to 10 when omitted'")
- .get_matches();
-
- // Here we get a value of type u32 from our optional -l argument.
- // If the value provided to len fails to parse, we default to 10
- //
- // Using other methods such as unwrap_or_else(|e| println!("{}",e))
- // are possible too.
- let len = value_t!(matches, "len", u32).unwrap_or(10);
-
- println!("len ({}) + 2 = {}", len, len + 2);
-
- // This code loops through all the values provided to "seq" and adds 2
- // If seq fails to parse, the program exits, you don't have an option
- for v in values_t!(matches, "seq", u32).unwrap_or_else(|e| e.exit()) {
- println!("Sequence part {} + 2: {}", v, v + 2);
- }
-}
diff --git a/clap/examples/13a_enum_values_automatic.rs b/clap/examples/13a_enum_values_automatic.rs
deleted file mode 100644
index 1abe5cb..0000000
--- a/clap/examples/13a_enum_values_automatic.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-// You can use clap's value_t! macro with a custom enum by implementing the std::str::FromStr
-// trait which is very straight forward. There are three ways to do this, for simple enums
-// meaning those that don't require 'pub' or any '#[derive()]' directives you can use clap's
-// simple_enum! macro. For those that require 'pub' or any '#[derive()]'s you can use clap's
-// arg_enum! macro. The third way is to implement std::str::FromStr manually.
-//
-// In most circumstances using either simple_enum! or arg_enum! is fine.
-//
-// In the following example we will create two enums using macros, assign a positional argument
-// that accepts only one of those values, and use clap to parse the argument.
-
-// Add clap like normal
-#[macro_use]
-extern crate clap;
-
-use clap::{App, Arg};
-
-// Using arg_enum! is more like traditional enum declarations
-//
-// **NOTE:** Only bare variants are supported
-arg_enum!{
- #[derive(Debug)]
- pub enum Oof {
- Rab,
- Zab,
- Xuq
- }
-}
-
-arg_enum!{
- #[derive(Debug)]
- enum Foo {
- Bar,
- Baz,
- Qux
- }
-}
-
-fn main() {
- // Create the application like normal
- let enum_vals = ["fast", "slow"];
- let m = App::new("myapp")
- // Use a single positional argument that is required
- .arg(Arg::from_usage("<foo> 'The Foo to use'")
- .possible_values(&Foo::variants()))
- .arg(Arg::from_usage("<speed> 'The speed to use'")
- // You can define a list of possible values if you want the values to be
- // displayed in the help information. Whether you use possible_values() or
- // not, the valid values will ALWAYS be displayed on a failed parse.
- .possible_values(&enum_vals))
- // For the second positional, lets not use possible_values() just to show the difference
- .arg_from_usage("<oof> 'The Oof to use'")
- .get_matches();
-
- let t = value_t!(m.value_of("foo"), Foo).unwrap_or_else(|e| e.exit());
- let t2 = value_t!(m.value_of("oof"), Oof).unwrap_or_else(|e| e.exit());
-
-
- // Now we can use our enum like normal.
- match t {
- Foo::Bar => println!("Found a Bar"),
- Foo::Baz => println!("Found a Baz"),
- Foo::Qux => println!("Found a Qux")
- }
-
- // Since our Oof derives Debug, we can do this:
- println!("Oof: {:?}", t2);
-}
diff --git a/clap/examples/13b_enum_values_manual.rs b/clap/examples/13b_enum_values_manual.rs
deleted file mode 100644
index 81ffe5e..0000000
--- a/clap/examples/13b_enum_values_manual.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-// In the following example we will create an enum with 4 values, assign a positional argument
-// that accepts only one of those values, and use clap to parse the argument.
-//
-// Start with bringing the trait into scope.
-use std::str::FromStr;
-
-// Add clap like normal
-#[macro_use]
-extern crate clap;
-
-use clap::{App, Arg};
-
-// Define your enum
-enum Vals {
- Foo,
- Bar,
- Baz,
- Qux
-}
-
-// Implement the trait
-impl FromStr for Vals {
- type Err = &'static str;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- match s {
- "Foo" => Ok(Vals::Foo),
- "Bar" => Ok(Vals::Bar),
- "Baz" => Ok(Vals::Baz),
- "Qux" => Ok(Vals::Qux),
- _ => Err("no match")
- }
- }
-}
-
-fn main() {
- // Create the application like normal
- let m = App::new("myapp")
- // Use a single positional argument that is required
- .arg(Arg::from_usage("<type> 'The type to use'")
- // Define the list of possible values
- .possible_values(&["Foo", "Bar", "Baz", "Qux"]))
- .get_matches();
-
- let t = value_t!(m, "type", Vals).unwrap_or_else(|e| e.exit());
-
- // Now we can use our enum like normal.
- match t {
- Vals::Foo => println!("Found a Foo"),
- Vals::Bar => println!("Found a Bar"),
- Vals::Baz => println!("Found a Baz"),
- Vals::Qux => println!("Found a Qux")
- }
-}
diff --git a/clap/examples/14_groups.rs b/clap/examples/14_groups.rs
deleted file mode 100644
index e160464..0000000
--- a/clap/examples/14_groups.rs
+++ /dev/null
@@ -1,87 +0,0 @@
-/// `ArgGroup`s are a family of related arguments and way for you to say, "Any of these arguments".
-/// By placing arguments in a logical group, you can make easier requirement and exclusion rules
-/// instead of having to list each individually, or when you want a rule to apply "any but not all"
-/// arguments.
-///
-/// For instance, you can make an entire `ArgGroup` required, this means that one (and *only* one)
-/// argument from that group must be present. Using more than one argument from an `ArgGroup` causes
-/// a failure (graceful exit).
-///
-/// You can also do things such as name an `ArgGroup` as a confliction or requirement, meaning any
-/// of the arguments that belong to that group will cause a failure if present, or must present
-/// respectively.
-///
-/// Perhaps the most common use of `ArgGroup`s is to require one and *only* one argument to be
-/// present out of a given set. Imagine that you had multiple arguments, and you want one of them to
-/// be required, but making all of them required isn't feasible because perhaps they conflict with
-/// each other. For example, lets say that you were building an application where one could set a
-/// given version number by supplying a string with an option argument, i.e. `--set-ver v1.2.3`, you
-/// also wanted to support automatically using a previous version number and simply incrementing one
-/// of the three numbers. So you create three flags `--major`, `--minor`, and `--patch`. All of
-/// these arguments shouldn't be used at one time but you want to specify that *at least one* of
-/// them is used. For this, you can create a group.
-
-extern crate clap;
-
-use clap::{App, Arg, ArgGroup};
-
-fn main() {
- // Create application like normal
- let matches = App::new("myapp")
- // Add the version arguments
- .args_from_usage("--set-ver [ver] 'set version manually'
- --major 'auto inc major'
- --minor 'auto inc minor'
- --patch 'auto inc patch'")
- // Create a group, make it required, and add the above arguments
- .group(ArgGroup::with_name("vers")
- .required(true)
- .args(&["ver", "major", "minor", "patch"]))
- // Arguments can also be added to a group individually, these two arguments
- // are part of the "input" group which is not required
- .arg(Arg::from_usage("[INPUT_FILE] 'some regular input'")
- .group("input"))
- .arg(Arg::from_usage("--spec-in [SPEC_IN] 'some special input argument'")
- .group("input"))
- // Now let's assume we have a -c [config] argument which requires one of
- // (but **not** both) the "input" arguments
- .arg(Arg::with_name("config")
- .short("c")
- .takes_value(true)
- .requires("input"))
- .get_matches();
-
- // Let's assume the old version 1.2.3
- let mut major = 1;
- let mut minor = 2;
- let mut patch = 3;
-
- // See if --set-ver was used to set the version manually
- let version = if let Some(ver) = matches.value_of("ver") {
- format!("{}", ver)
- } else {
- // Increment the one requested (in a real program, we'd reset the lower numbers)
- let (maj, min, pat) = (matches.is_present("major"),
- matches.is_present("minor"),
- matches.is_present("patch"));
- match (maj, min, pat) {
- (true, _, _) => major += 1,
- (_, true, _) => minor += 1,
- (_, _, true) => patch += 1,
- _ => unreachable!(),
- };
- format!("{}.{}.{}", major, minor, patch)
- };
-
- println!("Version: {}", version);
-
- // Check for usage of -c
- if matches.is_present("config") {
- let input = matches.value_of("INPUT_FILE").unwrap_or(matches.value_of("SPEC_IN").unwrap());
- println!("Doing work using input {} and config {}",
- input,
- matches.value_of("config").unwrap());
- }
-
-
-}
diff --git a/clap/examples/15_custom_validator.rs b/clap/examples/15_custom_validator.rs
deleted file mode 100644
index a5c0d42..0000000
--- a/clap/examples/15_custom_validator.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-fn main() {
- // You can define a function (or a closure) to use as a validator to argument values. The
- // function must accept a String and return Result<(), String> where Err(String) is the message
- // displayed to the user.
-
- let matches = App::new("myapp")
- // Application logic goes here...
- .arg(Arg::with_name("input")
- .help("the input file to use")
- .index(1)
- .required(true)
- // You can pass in a closure, or a function
- .validator(is_png))
- .get_matches();
-
- // Here we can call .unwrap() because the argument is required.
- println!("The .PNG file is: {}", matches.value_of("input").unwrap());
-}
-
-fn is_png(val: String) -> Result<(), String> {
- // val is the argument value passed in by the user
- // val has type of String.
- if val.ends_with(".png") {
- Ok(())
- } else {
- // clap automatically adds "error: " to the beginning
- // of the message.
- Err(String::from("the file format must be png."))
- }
- // Of course, you can do more complicated validation as
- // well, but for the simplicity, this example only checks
- // if the value passed in ends with ".png" or not.
-}
diff --git a/clap/examples/16_app_settings.rs b/clap/examples/16_app_settings.rs
deleted file mode 100644
index ab1d185..0000000
--- a/clap/examples/16_app_settings.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-extern crate clap;
-
-use clap::{App, AppSettings, SubCommand};
-
-fn main() {
- // You can use AppSettings to change the application level behavior of clap. .setting() function
- // of App struct takes AppSettings enum as argument. There is also .settings() function which
- // takes slice of AppSettings enum. You can learn more about AppSettings in the documentation,
- // which also has examples on each setting.
- //
- // This example will only show usage of one AppSettings setting. See documentation for more
- // information.
-
- let matches = App::new("myapp")
- .setting(AppSettings::SubcommandsNegateReqs)
- // Negates requirement of parent command.
-
- .arg_from_usage("<input> 'input file to use'")
- // Required positional argument called input. This
- // will be only required if subcommand is not present.
-
- .subcommand(SubCommand::with_name("test")
- .about("does some testing"))
- // if program is invoked with subcommand, you do not
- // need to specify the <input> argument anymore due to
- // the AppSettings::SubcommandsNegateReqs setting.
-
- .get_matches();
-
- // Calling unwrap() on "input" would not be advised here, because although it's required,
- // if the user uses a subcommand, those requirements are no longer required. Hence, we should
- // use some sort of 'if let' construct
- if let Some(inp) = matches.value_of("input") {
- println!("The input file is: {}", inp);
- }
-
- match matches.subcommand() {
- ("test", _) => println!("The 'test' subcommand was used"),
- _ => unreachable!()
- }
-}
diff --git a/clap/examples/17_yaml.rs b/clap/examples/17_yaml.rs
deleted file mode 100644
index 3353d73..0000000
--- a/clap/examples/17_yaml.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-// In order to use YAML to define your CLI you must compile clap with the "yaml" feature because
-// it's **not** included by default.
-//
-// In order to do this, ensure your Cargo.toml looks like one of the following:
-//
-// [dependencies.clap]
-// features = ["yaml"]
-//
-// __OR__
-//
-// [dependencies]
-// clap = { features = ["yaml"] }
-
-
-// Using yaml requires calling a clap macro `load_yaml!()` so we must use the '#[macro_use]'
-// directive
-#[macro_use]
-extern crate clap;
-
-#[cfg(feature = "yaml")]
-fn main() {
- use clap::App;
-
- // To load a yaml file containing our CLI definition such as the example '17_yaml.yml' we can
- // use the convenience macro which loads the file at compile relative to the current file
- // similar to how modules are found.
- //
- // Then we pass that yaml object to App to build the CLI.
- //
- // Finally we call get_matches() to start the parsing process. We use the matches just as we
- // normally would
- let yml = load_yaml!("17_yaml.yml");
- let m = App::from_yaml(yml).get_matches();
-
- // Because the example 17_yaml.yml is rather large we'll just look a single arg so you can
- // see that it works...
- if let Some(mode) = m.value_of("mode") {
- match mode {
- "vi" => println!("You are using vi"),
- "emacs" => println!("You are using emacs..."),
- _ => unreachable!()
- }
- } else {
- println!("--mode <MODE> wasn't used...");
- }
-}
-
-#[cfg(not(feature = "yaml"))]
-fn main() {
- // As stated above, if clap is not compiled with the YAML feature, it is disabled.
- println!("YAML feature is disabled.");
- println!("Pass --features yaml to cargo when trying this example.");
-}
diff --git a/clap/examples/17_yaml.yml b/clap/examples/17_yaml.yml
deleted file mode 100644
index b0d58b3..0000000
--- a/clap/examples/17_yaml.yml
+++ /dev/null
@@ -1,97 +0,0 @@
-name: yml_app
-version: "1.0"
-about: an example using a .yml file to build a CLI
-author: Kevin K. <kbknapp@gmail.com>
-
-# AppSettings can be defined as a list and are **not** ascii case sensitive
-settings:
- - ArgRequiredElseHelp
-
-# All Args must be defined in the 'args:' list where the name of the arg, is the
-# key to a Hash object
-args:
- # The name of this argument, is 'opt' which will be used to access the value
- # later in your Rust code
- - opt:
- help: example option argument from yaml
- short: o
- long: option
- multiple: true
- takes_value: true
- - pos:
- help: example positional argument from yaml
- index: 1
- # A list of possible values can be defined as a list
- possible_values:
- - fast
- - slow
- - flag:
- help: demo flag argument
- short: F
- multiple: true
- global: true
- # Conflicts, mutual overrides, and requirements can all be defined as a
- # list, where the key is the name of the other argument
- conflicts_with:
- - opt
- requires:
- - pos
- - mode:
- long: mode
- help: shows an option with specific values
- # possible_values can also be defined in this list format
- possible_values: [ vi, emacs ]
- takes_value: true
- - mvals:
- long: mult-vals
- help: demos an option which has two named values
- # value names can be described in a list, where the help will be shown
- # --mult-vals <one> <two>
- value_names:
- - one
- - two
- - minvals:
- long: min-vals
- multiple: true
- help: you must supply at least two values to satisfy me
- min_values: 2
- - maxvals:
- long: max-vals
- multiple: true
- help: you can only supply a max of 3 values for me!
- max_values: 3
-
-# All subcommands must be listed in the 'subcommand:' object, where the key to
-# the list is the name of the subcommand, and all settings for that command are
-# are part of a Hash object
-subcommands:
- # The name of this subcommand will be 'subcmd' which can be accessed in your
- # Rust code later
- - subcmd:
- about: demos subcommands from yaml
- version: "0.1"
- author: Kevin K. <kbknapp@gmail.com>
- # Subcommand args are exactly like App args
- args:
- - scopt:
- short: B
- multiple: true
- help: example subcommand option
- takes_value: true
- - scpos1:
- help: example subcommand positional
- index: 1
-
-# ArgGroups are supported as well, and must be sepcified in the 'groups:'
-# object of this file
-groups:
- # the name of the ArgGoup is specified here
- - min-max-vals:
- # All args and groups that are a part of this group are set here
- args:
- - minvals
- - maxvals
- # setting conflicts is done the same manner as setting 'args:'
- #
- # to make this group required, you could set 'required: true' but for
- # this example we won't do that.
diff --git a/clap/examples/18_builder_macro.rs b/clap/examples/18_builder_macro.rs
deleted file mode 100644
index 6bdce47..0000000
--- a/clap/examples/18_builder_macro.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-#[macro_use]
-extern crate clap;
-
-// Note, there isn't a need for "use clap::{ ... };" Because the clap_app! macro uses
-// $crate:: internally
-
-fn main() {
-
- // Validation example testing that a file exists
- let file_exists = |path| {
- if std::fs::metadata(path).is_ok() {
- Ok(())
- } else {
- Err(String::from("File doesn't exist"))
- }
- };
-
- // External module may contain this subcommand. If this exists in another module, a function is
- // required to access it. Recommend `fn clap() -> Clap::SubCommand`.
- let external_sub_command = clap_app!( @subcommand foo =>
- (@arg bar: -b "Bar")
- );
-
- let matches = clap_app!(MyApp =>
- (@setting SubcommandRequiredElseHelp)
- (version: "1.0")
- (author: "Alice")
- (about: "Does awesome things")
- (@arg config: -c --config <conf> #{1, 2} {file_exists} "Sets a custom config file")
- (@arg proxyHostname: --("proxy-hostname") +takes_value "Sets the hostname of the proxy to use")
- (@arg input: * "Input file")
- (@group test =>
- (@attributes +required)
- (@arg output: "Sets an optional output file")
- (@arg debug: -d ... "Turn debugging information on")
- )
- (subcommand: external_sub_command)
- (@subcommand test =>
- (about: "does testing things")
- (version: "2.5")
- (@arg list: -l "Lists test values")
- (@arg test_req: -r requires[list] "Tests requirement for listing")
- (@arg aaaa: --aaaa +takes_value {
- |a| if a.contains('a') {
- Ok(())
- } else {
- Err(String::from("string does not contain at least one a"))
- }
- } "Test if the argument contains an a")
- )
- ).get_matches();
-
- // You can check the value provided by positional arguments, or option arguments
- if let Some(o) = matches.value_of("output") {
- println!("Value for output: {}", o);
- }
-
- if let Some(c) = matches.value_of("config") {
- println!("Value for config: {}", c);
- }
-
- // You can see how many times a particular flag or argument occurred
- // Note, only flags can have multiple occurrences
- match matches.occurrences_of("debug") {
- 0 => println!("Debug mode is off"),
- 1 => println!("Debug mode is kind of on"),
- 2 => println!("Debug mode is on"),
- 3 | _ => println!("Don't be crazy"),
- }
-
- // You can check for the existence of subcommands, and if found use their
- // matches just as you would the top level app
- if let Some(matches) = matches.subcommand_matches("test") {
- // "$ myapp test" was run
- if matches.is_present("list") {
- // "$ myapp test -l" was run
- println!("Printing testing lists...");
- } else {
- println!("Not printing testing lists...");
- }
- }
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/19_auto_authors.rs b/clap/examples/19_auto_authors.rs
deleted file mode 100644
index afbb985..0000000
--- a/clap/examples/19_auto_authors.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-#[macro_use]
-extern crate clap;
-
-use clap::App;
-
-fn main() {
- App::new("myapp")
- .about("does awesome things")
- // use crate_authors! to pull the author(s) names from the Cargo.toml
- .author(crate_authors!())
- .get_matches();
-
- // running this app with -h will display whatever author(s) are in your
- // Cargo.toml
-}
diff --git a/clap/examples/20_subcommands.rs b/clap/examples/20_subcommands.rs
deleted file mode 100644
index f80f46d..0000000
--- a/clap/examples/20_subcommands.rs
+++ /dev/null
@@ -1,143 +0,0 @@
-// Working with subcommands is simple. There are a few key points to remember when working with
-// subcommands in clap. First, SubCommands are really just Apps. This means they can have their own
-// settings, version, authors, args, and even their own subcommands. The next thing to remember is
-// that subcommands are set up in a tree like hierarchy.
-//
-// An ASCII art depiction may help explain this better. Using a fictional version of git as the demo
-// subject. Imagine the following are all subcommands of git (note, the author is aware these aren't
-// actually all subcommands in the real git interface, but it makes explanation easier)
-//
-// Top Level App (git) TOP
-// |
-// -----------------------------------------
-// / | \ \
-// clone push add commit LEVEL 1
-// | / \ / \ |
-// url origin remote ref name message LEVEL 2
-// / /\
-// path remote local LEVEL 3
-//
-// Given the above fictional subcommand hierarchy, valid runtime uses would be (not an all inclusive
-// list):
-//
-// $ git clone url
-// $ git push origin path
-// $ git add ref local
-// $ git commit message
-//
-// Notice only one command per "level" may be used. You could not, for example, do:
-//
-// $ git clone url push origin path
-//
-// It's also important to know that subcommands each have their own set of matches and may have args
-// with the same name as other subcommands in a different part of the tree hierarchy (i.e. the arg
-// names aren't in a flat namespace).
-//
-// In order to use subcommands in clap, you only need to know which subcommand you're at in your
-// tree, and which args are defined on that subcommand.
-//
-// Let's make a quick program to illustrate. We'll be using the same example as above but for
-// brevity sake we won't implement all of the subcommands, only a few.
-
-extern crate clap;
-
-use clap::{App, Arg, SubCommand, AppSettings};
-
-fn main() {
-
- let matches = App::new("git")
- .about("A fictional versioning CLI")
- .version("1.0")
- .author("Me")
- .subcommand(SubCommand::with_name("clone")
- .about("clones repos")
- .arg(Arg::with_name("repo")
- .help("The repo to clone")
- .required(true)))
- .subcommand(SubCommand::with_name("push")
- .about("pushes things")
- .setting(AppSettings::SubcommandRequiredElseHelp)
- .subcommand(SubCommand::with_name("remote") // Subcommands can have their own subcommands,
- // which in turn have their own subcommands
- .about("pushes remote things")
- .arg(Arg::with_name("repo")
- .required(true)
- .help("The remote repo to push things to")))
- .subcommand(SubCommand::with_name("local")
- .about("pushes local things")))
- .subcommand(SubCommand::with_name("add")
- .about("adds things")
- .author("Someone Else") // Subcommands can list different authors
- .version("v2.0 (I'm versioned differently") // or different version from their parents
- .setting(AppSettings::ArgRequiredElseHelp) // They can even have different settings
- .arg(Arg::with_name("stuff")
- .long("stuff")
- .help("Stuff to add")
- .takes_value(true)
- .multiple(true)))
- .get_matches();
-
- // At this point, the matches we have point to git. Keep this in mind...
-
- // You can check if one of git's subcommands was used
- if matches.is_present("clone") {
- println!("'git clone' was run.");
- }
-
- // You can see which subcommand was used
- if let Some(subcommand) = matches.subcommand_name() {
- println!("'git {}' was used", subcommand);
-
- // It's important to note, this *only* check's git's DIRECT children, **NOT** it's
- // grandchildren, great grandchildren, etc.
- //
- // i.e. if the command `git push remove --stuff foo` was run, the above will only print out,
- // `git push` was used. We'd need to get push's matches to see further into the tree
- }
-
- // An alternative to checking the name is matching on known names. Again notice that only the
- // direct children are matched here.
- match matches.subcommand_name() {
- Some("clone") => println!("'git clone' was used"),
- Some("push") => println!("'git push' was used"),
- Some("add") => println!("'git add' was used"),
- None => println!("No subcommand was used"),
- _ => unreachable!(), // Assuming you've listed all direct children above, this is unreachable
- }
-
- // You could get the independent subcommand matches, although this is less common
- if let Some(clone_matches) = matches.subcommand_matches("clone") {
- // Now we have a reference to clone's matches
- println!("Cloning repo: {}", clone_matches.value_of("repo").unwrap());
- }
-
- // The most common way to handle subcommands is via a combined approach using
- // `ArgMatches::subcommand` which returns a tuple of both the name and matches
- match matches.subcommand() {
- ("clone", Some(clone_matches)) =>{
- // Now we have a reference to clone's matches
- println!("Cloning {}", clone_matches.value_of("repo").unwrap());
- },
- ("push", Some(push_matches)) =>{
- // Now we have a reference to push's matches
- match push_matches.subcommand() {
- ("remote", Some(remote_matches)) =>{
- // Now we have a reference to remote's matches
- println!("Pushing to {}", remote_matches.value_of("repo").unwrap());
- },
- ("local", Some(_)) =>{
- println!("'git push local' was used");
- },
- _ => unreachable!(),
- }
- },
- ("add", Some(add_matches)) =>{
- // Now we have a reference to add's matches
- println!("Adding {}", add_matches.values_of("stuff").unwrap().collect::<Vec<_>>().join(", "));
- },
- ("", None) => println!("No subcommand was used"), // If no subcommand was used it'll match the tuple ("", None)
- _ => unreachable!(), // If all subcommands are defined above, anything else is unreachable!()
- }
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/21_aliases.rs b/clap/examples/21_aliases.rs
deleted file mode 100644
index 3be0445..0000000
--- a/clap/examples/21_aliases.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, SubCommand};
-
-fn main() {
-
- let matches = App::new("MyApp")
- .subcommand(SubCommand::with_name("ls")
- .aliases(&["list", "dir"])
- .about("Adds files to myapp")
- .version("0.1")
- .author("Kevin K.")
- .arg(Arg::with_name("input")
- .help("the file to add")
- .index(1)
- .required(true))
- )
- .get_matches();
-
- // You can check if a subcommand was used like normal
- if matches.is_present("add") {
- println!("'myapp add' was run.");
- }
-
- // You can get the independent subcommand matches (which function exactly like App matches)
- if let Some(matches) = matches.subcommand_matches("add") {
- // Safe to use unwrap() because of the required() option
- println!("Adding file: {}", matches.value_of("input").unwrap());
- }
-
- // You can also match on a subcommand's name
- match matches.subcommand_name() {
- Some("add") => println!("'myapp add' was used"),
- None => println!("No subcommand was used"),
- _ => println!("Some other subcommand was used"),
- }
-
- // Continued program logic goes here...
-}
diff --git a/clap/examples/22_stop_parsing_with_--.rs b/clap/examples/22_stop_parsing_with_--.rs
deleted file mode 100644
index a5ba5b3..0000000
--- a/clap/examples/22_stop_parsing_with_--.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-/// myprog -f -p=bob -- sloppy slop slop
-fn main() {
-
- let matches = App::new("myprog")
- .arg(Arg::with_name("eff")
- .short("f"))
- .arg(Arg::with_name("pea")
- .short("p")
- .takes_value(true))
- .arg(Arg::with_name("slop")
- .multiple(true)
- .last(true))
- .get_matches();
-
-
- println!("-f used: {:?}", matches.is_present("eff"));
- println!("-p's value: {:?}", matches.value_of("pea"));
- println!("'slops' values: {:?}", matches.values_of("slop").map(|vals| vals.collect::<Vec<_>>()));
-
- // Continued program logic goes here...
-}
diff --git a/clap/justfile b/clap/justfile
deleted file mode 100644
index 0768764..0000000
--- a/clap/justfile
+++ /dev/null
@@ -1,39 +0,0 @@
-@update-contributors:
- echo 'Removing old CONTRIBUTORS.md'
- mv CONTRIBUTORS.md CONTRIBUTORS.md.bak
- echo 'Downloading a list of new contributors'
- echo "the following is a list of contributors:" > CONTRIBUTORS.md
- echo "" >> CONTRIBUTORS.md
- echo "" >> CONTRIBUTORS.md
- githubcontrib --owner clap-rs --repo clap --sha master --cols 6 --format md --showlogin true --sortBy contributions --sortOrder desc >> CONTRIBUTORS.md
- echo "" >> CONTRIBUTORS.md
- echo "" >> CONTRIBUTORS.md
- echo "This list was generated by [mgechev/github-contributors-list](https://github.com/mgechev/github-contributors-list)" >> CONTRIBUTORS.md
- rm CONTRIBUTORS.md.bak
-
-run-test TEST:
- cargo test --test {{TEST}}
-
-debug TEST:
- cargo test --test {{TEST}} --features debug
-
-run-tests:
- cargo test --features "yaml unstable"
-
-@bench: nightly
- cargo bench && just remove-nightly
-
-nightly:
- rustup override add nightly
-
-remove-nightly:
- rustup override remove
-
-@lint: nightly
- cargo build --features lints && just remove-nightly
-
-clean:
- cargo clean
- find . -type f -name "*.orig" -exec rm {} \;
- find . -type f -name "*.bk" -exec rm {} \;
- find . -type f -name ".*~" -exec rm {} \;
diff --git a/clap/rustfmt.toml b/clap/rustfmt.toml
deleted file mode 100644
index 0136d86..0000000
--- a/clap/rustfmt.toml
+++ /dev/null
@@ -1,4 +0,0 @@
-format_strings = false
-chain_overflow_last = false
-same_line_if_else = true
-fn_single_line = true
diff --git a/clap/src/app/help.rs b/clap/src/app/help.rs
deleted file mode 100644
index 34f97ac..0000000
--- a/clap/src/app/help.rs
+++ /dev/null
@@ -1,1028 +0,0 @@
-// Std
-use std::borrow::Cow;
-use std::cmp;
-use std::collections::BTreeMap;
-use std::fmt::Display;
-use std::io::{self, Cursor, Read, Write};
-use std::usize;
-
-// Internal
-use app::parser::Parser;
-use app::usage;
-use app::{App, AppSettings};
-use args::{AnyArg, ArgSettings, DispOrder};
-use errors::{Error, Result as ClapResult};
-use fmt::{Colorizer, ColorizerOption, Format};
-use map::VecMap;
-use INTERNAL_ERROR_MSG;
-
-// Third Party
-#[cfg(feature = "wrap_help")]
-use term_size;
-use textwrap;
-use unicode_width::UnicodeWidthStr;
-
-#[cfg(not(feature = "wrap_help"))]
-mod term_size {
- pub fn dimensions() -> Option<(usize, usize)> {
- None
- }
-}
-
-fn str_width(s: &str) -> usize {
- UnicodeWidthStr::width(s)
-}
-
-const TAB: &'static str = " ";
-
-// These are just convenient traits to make the code easier to read.
-trait ArgWithDisplay<'b, 'c>: AnyArg<'b, 'c> + Display {}
-impl<'b, 'c, T> ArgWithDisplay<'b, 'c> for T
-where
- T: AnyArg<'b, 'c> + Display,
-{
-}
-
-trait ArgWithOrder<'b, 'c>: ArgWithDisplay<'b, 'c> + DispOrder {
- fn as_base(&self) -> &ArgWithDisplay<'b, 'c>;
-}
-impl<'b, 'c, T> ArgWithOrder<'b, 'c> for T
-where
- T: ArgWithDisplay<'b, 'c> + DispOrder,
-{
- fn as_base(&self) -> &ArgWithDisplay<'b, 'c> {
- self
- }
-}
-
-fn as_arg_trait<'a, 'b, T: ArgWithOrder<'a, 'b>>(x: &T) -> &ArgWithOrder<'a, 'b> {
- x
-}
-
-impl<'b, 'c> DispOrder for App<'b, 'c> {
- fn disp_ord(&self) -> usize {
- 999
- }
-}
-
-macro_rules! color {
- ($_self:ident, $s:expr, $c:ident) => {
- if $_self.color {
- write!($_self.writer, "{}", $_self.cizer.$c($s))
- } else {
- write!($_self.writer, "{}", $s)
- }
- };
- ($_self:ident, $fmt_s:expr, $v:expr, $c:ident) => {
- if $_self.color {
- write!($_self.writer, "{}", $_self.cizer.$c(format!($fmt_s, $v)))
- } else {
- write!($_self.writer, $fmt_s, $v)
- }
- };
-}
-
-/// `clap` Help Writer.
-///
-/// Wraps a writer stream providing different methods to generate help for `clap` objects.
-pub struct Help<'a> {
- writer: &'a mut Write,
- next_line_help: bool,
- hide_pv: bool,
- term_w: usize,
- color: bool,
- cizer: Colorizer,
- longest: usize,
- force_next_line: bool,
- use_long: bool,
-}
-
-// Public Functions
-impl<'a> Help<'a> {
- /// Create a new `Help` instance.
- #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
- pub fn new(
- w: &'a mut Write,
- next_line_help: bool,
- hide_pv: bool,
- color: bool,
- cizer: Colorizer,
- term_w: Option<usize>,
- max_w: Option<usize>,
- use_long: bool,
- ) -> Self {
- debugln!("Help::new;");
- Help {
- writer: w,
- next_line_help: next_line_help,
- hide_pv: hide_pv,
- term_w: match term_w {
- Some(width) => if width == 0 {
- usize::MAX
- } else {
- width
- },
- None => cmp::min(
- term_size::dimensions().map_or(120, |(w, _)| w),
- match max_w {
- None | Some(0) => usize::MAX,
- Some(mw) => mw,
- },
- ),
- },
- color: color,
- cizer: cizer,
- longest: 0,
- force_next_line: false,
- use_long: use_long,
- }
- }
-
- /// Reads help settings from an App
- /// and write its help to the wrapped stream.
- pub fn write_app_help(w: &'a mut Write, app: &App, use_long: bool) -> ClapResult<()> {
- debugln!("Help::write_app_help;");
- Self::write_parser_help(w, &app.p, use_long)
- }
-
- /// Reads help settings from a Parser
- /// and write its help to the wrapped stream.
- pub fn write_parser_help(w: &'a mut Write, parser: &Parser, use_long: bool) -> ClapResult<()> {
- debugln!("Help::write_parser_help;");
- Self::_write_parser_help(w, parser, false, use_long)
- }
-
- /// Reads help settings from a Parser
- /// and write its help to the wrapped stream which will be stderr. This method prevents
- /// formatting when required.
- pub fn write_parser_help_to_stderr(w: &'a mut Write, parser: &Parser) -> ClapResult<()> {
- debugln!("Help::write_parser_help;");
- Self::_write_parser_help(w, parser, true, false)
- }
-
- #[doc(hidden)]
- pub fn _write_parser_help(
- w: &'a mut Write,
- parser: &Parser,
- stderr: bool,
- use_long: bool,
- ) -> ClapResult<()> {
- debugln!("Help::write_parser_help;");
- let nlh = parser.is_set(AppSettings::NextLineHelp);
- let hide_v = parser.is_set(AppSettings::HidePossibleValuesInHelp);
- let color = parser.is_set(AppSettings::ColoredHelp);
- let cizer = Colorizer::new(ColorizerOption {
- use_stderr: stderr,
- when: parser.color(),
- });
- Self::new(
- w,
- nlh,
- hide_v,
- color,
- cizer,
- parser.meta.term_w,
- parser.meta.max_w,
- use_long,
- ).write_help(parser)
- }
-
- /// Writes the parser help to the wrapped stream.
- pub fn write_help(&mut self, parser: &Parser) -> ClapResult<()> {
- debugln!("Help::write_help;");
- if let Some(h) = parser.meta.help_str {
- write!(self.writer, "{}", h).map_err(Error::from)?;
- } else if let Some(tmpl) = parser.meta.template {
- self.write_templated_help(parser, tmpl)?;
- } else {
- self.write_default_help(parser)?;
- }
- Ok(())
- }
-}
-
-// Methods to write AnyArg help.
-impl<'a> Help<'a> {
- /// Writes help for each argument in the order they were declared to the wrapped stream.
- fn write_args_unsorted<'b: 'd, 'c: 'd, 'd, I: 'd>(&mut self, args: I) -> io::Result<()>
- where
- I: Iterator<Item = &'d ArgWithOrder<'b, 'c>>,
- {
- debugln!("Help::write_args_unsorted;");
- // The shortest an arg can legally be is 2 (i.e. '-x')
- self.longest = 2;
- let mut arg_v = Vec::with_capacity(10);
- let use_long = self.use_long;
- for arg in args.filter(|arg| should_show_arg(use_long, *arg)) {
- if arg.longest_filter() {
- self.longest = cmp::max(self.longest, str_width(arg.to_string().as_str()));
- }
- arg_v.push(arg)
- }
- let mut first = true;
- for arg in arg_v {
- if first {
- first = false;
- } else {
- self.writer.write_all(b"\n")?;
- }
- self.write_arg(arg.as_base())?;
- }
- Ok(())
- }
-
- /// Sorts arguments by length and display order and write their help to the wrapped stream.
- fn write_args<'b: 'd, 'c: 'd, 'd, I: 'd>(&mut self, args: I) -> io::Result<()>
- where
- I: Iterator<Item = &'d ArgWithOrder<'b, 'c>>,
- {
- debugln!("Help::write_args;");
- // The shortest an arg can legally be is 2 (i.e. '-x')
- self.longest = 2;
- let mut ord_m = VecMap::new();
- let use_long = self.use_long;
- // Determine the longest
- for arg in args.filter(|arg| {
- // If it's NextLineHelp, but we don't care to compute how long because it may be
- // NextLineHelp on purpose *because* it's so long and would throw off all other
- // args alignment
- should_show_arg(use_long, *arg)
- }) {
- if arg.longest_filter() {
- debugln!("Help::write_args: Current Longest...{}", self.longest);
- self.longest = cmp::max(self.longest, str_width(arg.to_string().as_str()));
- debugln!("Help::write_args: New Longest...{}", self.longest);
- }
- let btm = ord_m.entry(arg.disp_ord()).or_insert(BTreeMap::new());
- btm.insert(arg.name(), arg);
- }
- let mut first = true;
- for btm in ord_m.values() {
- for arg in btm.values() {
- if first {
- first = false;
- } else {
- self.writer.write_all(b"\n")?;
- }
- self.write_arg(arg.as_base())?;
- }
- }
- Ok(())
- }
-
- /// Writes help for an argument to the wrapped stream.
- fn write_arg<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
- debugln!("Help::write_arg;");
- self.short(arg)?;
- self.long(arg)?;
- let spec_vals = self.val(arg)?;
- self.help(arg, &*spec_vals)?;
- Ok(())
- }
-
- /// Writes argument's short command to the wrapped stream.
- fn short<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
- debugln!("Help::short;");
- write!(self.writer, "{}", TAB)?;
- if let Some(s) = arg.short() {
- color!(self, "-{}", s, good)
- } else if arg.has_switch() {
- write!(self.writer, "{}", TAB)
- } else {
- Ok(())
- }
- }
-
- /// Writes argument's long command to the wrapped stream.
- fn long<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
- debugln!("Help::long;");
- if !arg.has_switch() {
- return Ok(());
- }
- if arg.takes_value() {
- if let Some(l) = arg.long() {
- if arg.short().is_some() {
- write!(self.writer, ", ")?;
- }
- color!(self, "--{}", l, good)?
- }
-
- let sep = if arg.is_set(ArgSettings::RequireEquals) {
- "="
- } else {
- " "
- };
- write!(self.writer, "{}", sep)?;
- } else if let Some(l) = arg.long() {
- if arg.short().is_some() {
- write!(self.writer, ", ")?;
- }
- color!(self, "--{}", l, good)?;
- }
- Ok(())
- }
-
- /// Writes argument's possible values to the wrapped stream.
- fn val<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> Result<String, io::Error> {
- debugln!("Help::val: arg={}", arg);
- if arg.takes_value() {
- let delim = if arg.is_set(ArgSettings::RequireDelimiter) {
- arg.val_delim().expect(INTERNAL_ERROR_MSG)
- } else {
- ' '
- };
- if let Some(vec) = arg.val_names() {
- let mut it = vec.iter().peekable();
- while let Some((_, val)) = it.next() {
- color!(self, "<{}>", val, good)?;
- if it.peek().is_some() {
- write!(self.writer, "{}", delim)?;
- }
- }
- let num = vec.len();
- if arg.is_set(ArgSettings::Multiple) && num == 1 {
- color!(self, "...", good)?;
- }
- } else if let Some(num) = arg.num_vals() {
- let mut it = (0..num).peekable();
- while let Some(_) = it.next() {
- color!(self, "<{}>", arg.name(), good)?;
- if it.peek().is_some() {
- write!(self.writer, "{}", delim)?;
- }
- }
- if arg.is_set(ArgSettings::Multiple) && num == 1 {
- color!(self, "...", good)?;
- }
- } else if arg.has_switch() {
- color!(self, "<{}>", arg.name(), good)?;
- if arg.is_set(ArgSettings::Multiple) {
- color!(self, "...", good)?;
- }
- } else {
- color!(self, "{}", arg, good)?;
- }
- }
-
- let spec_vals = self.spec_vals(arg);
- let h = arg.help().unwrap_or("");
- let h_w = str_width(h) + str_width(&*spec_vals);
- let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp);
- let taken = self.longest + 12;
- self.force_next_line = !nlh && self.term_w >= taken
- && (taken as f32 / self.term_w as f32) > 0.40
- && h_w > (self.term_w - taken);
-
- debug!("Help::val: Has switch...");
- if arg.has_switch() {
- sdebugln!("Yes");
- debugln!("Help::val: force_next_line...{:?}", self.force_next_line);
- debugln!("Help::val: nlh...{:?}", nlh);
- debugln!("Help::val: taken...{}", taken);
- debugln!(
- "Help::val: help_width > (width - taken)...{} > ({} - {})",
- h_w,
- self.term_w,
- taken
- );
- debugln!("Help::val: longest...{}", self.longest);
- debug!("Help::val: next_line...");
- if !(nlh || self.force_next_line) {
- sdebugln!("No");
- let self_len = str_width(arg.to_string().as_str());
- // subtract ourself
- let mut spcs = self.longest - self_len;
- // Since we're writing spaces from the tab point we first need to know if we
- // had a long and short, or just short
- if arg.long().is_some() {
- // Only account 4 after the val
- spcs += 4;
- } else {
- // Only account for ', --' + 4 after the val
- spcs += 8;
- }
-
- write_nspaces!(self.writer, spcs);
- } else {
- sdebugln!("Yes");
- }
- } else if !(nlh || self.force_next_line) {
- sdebugln!("No, and not next_line");
- write_nspaces!(
- self.writer,
- self.longest + 4 - (str_width(arg.to_string().as_str()))
- );
- } else {
- sdebugln!("No");
- }
- Ok(spec_vals)
- }
-
- fn write_before_after_help(&mut self, h: &str) -> io::Result<()> {
- debugln!("Help::write_before_after_help;");
- let mut help = String::from(h);
- // determine if our help fits or needs to wrap
- debugln!(
- "Help::write_before_after_help: Term width...{}",
- self.term_w
- );
- let too_long = str_width(h) >= self.term_w;
-
- debug!("Help::write_before_after_help: Too long...");
- if too_long || h.contains("{n}") {
- sdebugln!("Yes");
- debugln!("Help::write_before_after_help: help: {}", help);
- debugln!(
- "Help::write_before_after_help: help width: {}",
- str_width(&*help)
- );
- // Determine how many newlines we need to insert
- debugln!(
- "Help::write_before_after_help: Usable space: {}",
- self.term_w
- );
- help = wrap_help(&help.replace("{n}", "\n"), self.term_w);
- } else {
- sdebugln!("No");
- }
- write!(self.writer, "{}", help)?;
- Ok(())
- }
-
- /// Writes argument's help to the wrapped stream.
- fn help<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>, spec_vals: &str) -> io::Result<()> {
- debugln!("Help::help;");
- let h = if self.use_long && arg.name() != "" {
- arg.long_help().unwrap_or_else(|| arg.help().unwrap_or(""))
- } else {
- arg.help().unwrap_or_else(|| arg.long_help().unwrap_or(""))
- };
- let mut help = String::from(h) + spec_vals;
- let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp) || (self.use_long && arg.name() != "");
- debugln!("Help::help: Next Line...{:?}", nlh);
-
- let spcs = if nlh || self.force_next_line {
- 12 // "tab" * 3
- } else {
- self.longest + 12
- };
-
- let too_long = spcs + str_width(h) + str_width(&*spec_vals) >= self.term_w;
-
- // Is help on next line, if so then indent
- if nlh || self.force_next_line {
- write!(self.writer, "\n{}{}{}", TAB, TAB, TAB)?;
- }
-
- debug!("Help::help: Too long...");
- if too_long && spcs <= self.term_w || h.contains("{n}") {
- sdebugln!("Yes");
- debugln!("Help::help: help...{}", help);
- debugln!("Help::help: help width...{}", str_width(&*help));
- // Determine how many newlines we need to insert
- let avail_chars = self.term_w - spcs;
- debugln!("Help::help: Usable space...{}", avail_chars);
- help = wrap_help(&help.replace("{n}", "\n"), avail_chars);
- } else {
- sdebugln!("No");
- }
- if let Some(part) = help.lines().next() {
- write!(self.writer, "{}", part)?;
- }
- for part in help.lines().skip(1) {
- write!(self.writer, "\n")?;
- if nlh || self.force_next_line {
- write!(self.writer, "{}{}{}", TAB, TAB, TAB)?;
- } else if arg.has_switch() {
- write_nspaces!(self.writer, self.longest + 12);
- } else {
- write_nspaces!(self.writer, self.longest + 8);
- }
- write!(self.writer, "{}", part)?;
- }
- if !help.contains('\n') && (nlh || self.force_next_line) {
- write!(self.writer, "\n")?;
- }
- Ok(())
- }
-
- fn spec_vals(&self, a: &ArgWithDisplay) -> String {
- debugln!("Help::spec_vals: a={}", a);
- let mut spec_vals = vec![];
- if let Some(ref env) = a.env() {
- debugln!(
- "Help::spec_vals: Found environment variable...[{:?}:{:?}]",
- env.0,
- env.1
- );
- let env_val = if !a.is_set(ArgSettings::HideEnvValues) {
- format!(
- "={}",
- env.1.map_or(Cow::Borrowed(""), |val| val.to_string_lossy())
- )
- } else {
- String::new()
- };
- let env_info = format!(" [env: {}{}]", env.0.to_string_lossy(), env_val);
- spec_vals.push(env_info);
- }
- if !a.is_set(ArgSettings::HideDefaultValue) {
- if let Some(pv) = a.default_val() {
- debugln!("Help::spec_vals: Found default value...[{:?}]", pv);
- spec_vals.push(format!(
- " [default: {}]",
- if self.color {
- self.cizer.good(pv.to_string_lossy())
- } else {
- Format::None(pv.to_string_lossy())
- }
- ));
- }
- }
- if let Some(ref aliases) = a.aliases() {
- debugln!("Help::spec_vals: Found aliases...{:?}", aliases);
- spec_vals.push(format!(
- " [aliases: {}]",
- if self.color {
- aliases
- .iter()
- .map(|v| format!("{}", self.cizer.good(v)))
- .collect::<Vec<_>>()
- .join(", ")
- } else {
- aliases.join(", ")
- }
- ));
- }
- if !self.hide_pv && !a.is_set(ArgSettings::HidePossibleValues) {
- if let Some(pv) = a.possible_vals() {
- debugln!("Help::spec_vals: Found possible vals...{:?}", pv);
- spec_vals.push(if self.color {
- format!(
- " [possible values: {}]",
- pv.iter()
- .map(|v| format!("{}", self.cizer.good(v)))
- .collect::<Vec<_>>()
- .join(", ")
- )
- } else {
- format!(" [possible values: {}]", pv.join(", "))
- });
- }
- }
- spec_vals.join(" ")
- }
-}
-
-fn should_show_arg(use_long: bool, arg: &ArgWithOrder) -> bool {
- if arg.is_set(ArgSettings::Hidden) {
- return false;
- }
-
- (!arg.is_set(ArgSettings::HiddenLongHelp) && use_long)
- || (!arg.is_set(ArgSettings::HiddenShortHelp) && !use_long)
- || arg.is_set(ArgSettings::NextLineHelp)
-}
-
-// Methods to write Parser help.
-impl<'a> Help<'a> {
- /// Writes help for all arguments (options, flags, args, subcommands)
- /// including titles of a Parser Object to the wrapped stream.
- #[cfg_attr(feature = "lints", allow(useless_let_if_seq))]
- #[cfg_attr(feature = "cargo-clippy", allow(useless_let_if_seq))]
- pub fn write_all_args(&mut self, parser: &Parser) -> ClapResult<()> {
- debugln!("Help::write_all_args;");
- let flags = parser.has_flags();
- let pos = parser
- .positionals()
- .filter(|arg| !arg.is_set(ArgSettings::Hidden))
- .count() > 0;
- let opts = parser.has_opts();
- let subcmds = parser.has_visible_subcommands();
-
- let unified_help = parser.is_set(AppSettings::UnifiedHelpMessage);
-
- let mut first = true;
-
- if unified_help && (flags || opts) {
- let opts_flags = parser
- .flags()
- .map(as_arg_trait)
- .chain(parser.opts().map(as_arg_trait));
- color!(self, "OPTIONS:\n", warning)?;
- self.write_args(opts_flags)?;
- first = false;
- } else {
- if flags {
- color!(self, "FLAGS:\n", warning)?;
- self.write_args(parser.flags().map(as_arg_trait))?;
- first = false;
- }
- if opts {
- if !first {
- self.writer.write_all(b"\n\n")?;
- }
- color!(self, "OPTIONS:\n", warning)?;
- self.write_args(parser.opts().map(as_arg_trait))?;
- first = false;
- }
- }
-
- if pos {
- if !first {
- self.writer.write_all(b"\n\n")?;
- }
- color!(self, "ARGS:\n", warning)?;
- self.write_args_unsorted(parser.positionals().map(as_arg_trait))?;
- first = false;
- }
-
- if subcmds {
- if !first {
- self.writer.write_all(b"\n\n")?;
- }
- color!(self, "SUBCOMMANDS:\n", warning)?;
- self.write_subcommands(parser)?;
- }
-
- Ok(())
- }
-
- /// Writes help for subcommands of a Parser Object to the wrapped stream.
- fn write_subcommands(&mut self, parser: &Parser) -> io::Result<()> {
- debugln!("Help::write_subcommands;");
- // The shortest an arg can legally be is 2 (i.e. '-x')
- self.longest = 2;
- let mut ord_m = VecMap::new();
- for sc in parser
- .subcommands
- .iter()
- .filter(|s| !s.p.is_set(AppSettings::Hidden))
- {
- let btm = ord_m.entry(sc.p.meta.disp_ord).or_insert(BTreeMap::new());
- self.longest = cmp::max(self.longest, str_width(sc.p.meta.name.as_str()));
- //self.longest = cmp::max(self.longest, sc.p.meta.name.len());
- btm.insert(sc.p.meta.name.clone(), sc.clone());
- }
-
- let mut first = true;
- for btm in ord_m.values() {
- for sc in btm.values() {
- if first {
- first = false;
- } else {
- self.writer.write_all(b"\n")?;
- }
- self.write_arg(sc)?;
- }
- }
- Ok(())
- }
-
- /// Writes version of a Parser Object to the wrapped stream.
- fn write_version(&mut self, parser: &Parser) -> io::Result<()> {
- debugln!("Help::write_version;");
- write!(self.writer, "{}", parser.meta.version.unwrap_or(""))?;
- Ok(())
- }
-
- /// Writes binary name of a Parser Object to the wrapped stream.
- fn write_bin_name(&mut self, parser: &Parser) -> io::Result<()> {
- debugln!("Help::write_bin_name;");
- macro_rules! write_name {
- () => {{
- let mut name = parser.meta.name.clone();
- name = name.replace("{n}", "\n");
- color!(self, wrap_help(&name, self.term_w), good)?;
- }};
- }
- if let Some(bn) = parser.meta.bin_name.as_ref() {
- if bn.contains(' ') {
- // Incase we're dealing with subcommands i.e. git mv is translated to git-mv
- color!(self, bn.replace(" ", "-"), good)?
- } else {
- write_name!();
- }
- } else {
- write_name!();
- }
- Ok(())
- }
-
- /// Writes default help for a Parser Object to the wrapped stream.
- pub fn write_default_help(&mut self, parser: &Parser) -> ClapResult<()> {
- debugln!("Help::write_default_help;");
- if let Some(h) = parser.meta.pre_help {
- self.write_before_after_help(h)?;
- self.writer.write_all(b"\n\n")?;
- }
-
- macro_rules! write_thing {
- ($thing:expr) => {{
- let mut owned_thing = $thing.to_owned();
- owned_thing = owned_thing.replace("{n}", "\n");
- write!(self.writer, "{}\n", wrap_help(&owned_thing, self.term_w))?
- }};
- }
- // Print the version
- self.write_bin_name(parser)?;
- self.writer.write_all(b" ")?;
- self.write_version(parser)?;
- self.writer.write_all(b"\n")?;
- if let Some(author) = parser.meta.author {
- write_thing!(author)
- }
- // if self.use_long {
- // if let Some(about) = parser.meta.long_about {
- // debugln!("Help::write_default_help: writing long about");
- // write_thing!(about)
- // } else if let Some(about) = parser.meta.about {
- // debugln!("Help::write_default_help: writing about");
- // write_thing!(about)
- // }
- // } else
- if let Some(about) = parser.meta.long_about {
- debugln!("Help::write_default_help: writing long about");
- write_thing!(about)
- } else if let Some(about) = parser.meta.about {
- debugln!("Help::write_default_help: writing about");
- write_thing!(about)
- }
-
- color!(self, "\nUSAGE:", warning)?;
- write!(
- self.writer,
- "\n{}{}\n\n",
- TAB,
- usage::create_usage_no_title(parser, &[])
- )?;
-
- let flags = parser.has_flags();
- let pos = parser.has_positionals();
- let opts = parser.has_opts();
- let subcmds = parser.has_subcommands();
-
- if flags || opts || pos || subcmds {
- self.write_all_args(parser)?;
- }
-
- if let Some(h) = parser.meta.more_help {
- if flags || opts || pos || subcmds {
- self.writer.write_all(b"\n\n")?;
- }
- self.write_before_after_help(h)?;
- }
-
- self.writer.flush().map_err(Error::from)
- }
-}
-
-/// Possible results for a copying function that stops when a given
-/// byte was found.
-enum CopyUntilResult {
- DelimiterFound(usize),
- DelimiterNotFound(usize),
- ReaderEmpty,
- ReadError(io::Error),
- WriteError(io::Error),
-}
-
-/// Copies the contents of a reader into a writer until a delimiter byte is found.
-/// On success, the total number of bytes that were
-/// copied from reader to writer is returned.
-fn copy_until<R: Read, W: Write>(r: &mut R, w: &mut W, delimiter_byte: u8) -> CopyUntilResult {
- debugln!("copy_until;");
-
- let mut count = 0;
- for wb in r.bytes() {
- match wb {
- Ok(b) => {
- if b == delimiter_byte {
- return CopyUntilResult::DelimiterFound(count);
- }
- match w.write(&[b]) {
- Ok(c) => count += c,
- Err(e) => return CopyUntilResult::WriteError(e),
- }
- }
- Err(e) => return CopyUntilResult::ReadError(e),
- }
- }
- if count > 0 {
- CopyUntilResult::DelimiterNotFound(count)
- } else {
- CopyUntilResult::ReaderEmpty
- }
-}
-
-/// Copies the contents of a reader into a writer until a {tag} is found,
-/// copying the tag content to a buffer and returning its size.
-/// In addition to errors, there are three possible outputs:
-/// - `None`: The reader was consumed.
-/// - `Some(Ok(0))`: No tag was captured but the reader still contains data.
-/// - `Some(Ok(length>0))`: a tag with `length` was captured to the `tag_buffer`.
-fn copy_and_capture<R: Read, W: Write>(
- r: &mut R,
- w: &mut W,
- tag_buffer: &mut Cursor<Vec<u8>>,
-) -> Option<io::Result<usize>> {
- use self::CopyUntilResult::*;
- debugln!("copy_and_capture;");
-
- // Find the opening byte.
- match copy_until(r, w, b'{') {
- // The end of the reader was reached without finding the opening tag.
- // (either with or without having copied data to the writer)
- // Return None indicating that we are done.
- ReaderEmpty | DelimiterNotFound(_) => None,
-
- // Something went wrong.
- ReadError(e) | WriteError(e) => Some(Err(e)),
-
- // The opening byte was found.
- // (either with or without having copied data to the writer)
- DelimiterFound(_) => {
- // Lets reset the buffer first and find out how long it is.
- tag_buffer.set_position(0);
- let buffer_size = tag_buffer.get_ref().len();
-
- // Find the closing byte,limiting the reader to the length of the buffer.
- let mut rb = r.take(buffer_size as u64);
- match copy_until(&mut rb, tag_buffer, b'}') {
- // We were already at the end of the reader.
- // Return None indicating that we are done.
- ReaderEmpty => None,
-
- // The closing tag was found.
- // Return the tag_length.
- DelimiterFound(tag_length) => Some(Ok(tag_length)),
-
- // The end of the reader was found without finding the closing tag.
- // Write the opening byte and captured text to the writer.
- // Return 0 indicating that nothing was captured but the reader still contains data.
- DelimiterNotFound(not_tag_length) => match w.write(b"{") {
- Err(e) => Some(Err(e)),
- _ => match w.write(&tag_buffer.get_ref()[0..not_tag_length]) {
- Err(e) => Some(Err(e)),
- _ => Some(Ok(0)),
- },
- },
-
- ReadError(e) | WriteError(e) => Some(Err(e)),
- }
- }
- }
-}
-
-// Methods to write Parser help using templates.
-impl<'a> Help<'a> {
- /// Write help to stream for the parser in the format defined by the template.
- ///
- /// Tags arg given inside curly brackets:
- /// Valid tags are:
- /// * `{bin}` - Binary name.
- /// * `{version}` - Version number.
- /// * `{author}` - Author information.
- /// * `{usage}` - Automatically generated or given usage string.
- /// * `{all-args}` - Help for all arguments (options, flags, positionals arguments,
- /// and subcommands) including titles.
- /// * `{unified}` - Unified help for options and flags.
- /// * `{flags}` - Help for flags.
- /// * `{options}` - Help for options.
- /// * `{positionals}` - Help for positionals arguments.
- /// * `{subcommands}` - Help for subcommands.
- /// * `{after-help}` - Info to be displayed after the help message.
- /// * `{before-help}` - Info to be displayed before the help message.
- ///
- /// The template system is, on purpose, very simple. Therefore the tags have to written
- /// in the lowercase and without spacing.
- fn write_templated_help(&mut self, parser: &Parser, template: &str) -> ClapResult<()> {
- debugln!("Help::write_templated_help;");
- let mut tmplr = Cursor::new(&template);
- let mut tag_buf = Cursor::new(vec![0u8; 15]);
-
- // The strategy is to copy the template from the reader to wrapped stream
- // until a tag is found. Depending on its value, the appropriate content is copied
- // to the wrapped stream.
- // The copy from template is then resumed, repeating this sequence until reading
- // the complete template.
-
- loop {
- let tag_length = match copy_and_capture(&mut tmplr, &mut self.writer, &mut tag_buf) {
- None => return Ok(()),
- Some(Err(e)) => return Err(Error::from(e)),
- Some(Ok(val)) if val > 0 => val,
- _ => continue,
- };
-
- debugln!("Help::write_template_help:iter: tag_buf={};", unsafe {
- String::from_utf8_unchecked(
- tag_buf.get_ref()[0..tag_length]
- .iter()
- .map(|&i| i)
- .collect::<Vec<_>>(),
- )
- });
- match &tag_buf.get_ref()[0..tag_length] {
- b"?" => {
- self.writer.write_all(b"Could not decode tag name")?;
- }
- b"bin" => {
- self.write_bin_name(parser)?;
- }
- b"version" => {
- write!(
- self.writer,
- "{}",
- parser.meta.version.unwrap_or("unknown version")
- )?;
- }
- b"author" => {
- write!(
- self.writer,
- "{}",
- parser.meta.author.unwrap_or("unknown author")
- )?;
- }
- b"about" => {
- write!(
- self.writer,
- "{}",
- parser.meta.about.unwrap_or("unknown about")
- )?;
- }
- b"long-about" => {
- write!(
- self.writer,
- "{}",
- parser.meta.long_about.unwrap_or("unknown about")
- )?;
- }
- b"usage" => {
- write!(self.writer, "{}", usage::create_usage_no_title(parser, &[]))?;
- }
- b"all-args" => {
- self.write_all_args(parser)?;
- }
- b"unified" => {
- let opts_flags = parser
- .flags()
- .map(as_arg_trait)
- .chain(parser.opts().map(as_arg_trait));
- self.write_args(opts_flags)?;
- }
- b"flags" => {
- self.write_args(parser.flags().map(as_arg_trait))?;
- }
- b"options" => {
- self.write_args(parser.opts().map(as_arg_trait))?;
- }
- b"positionals" => {
- self.write_args(parser.positionals().map(as_arg_trait))?;
- }
- b"subcommands" => {
- self.write_subcommands(parser)?;
- }
- b"after-help" => {
- write!(
- self.writer,
- "{}",
- parser.meta.more_help.unwrap_or("unknown after-help")
- )?;
- }
- b"before-help" => {
- write!(
- self.writer,
- "{}",
- parser.meta.pre_help.unwrap_or("unknown before-help")
- )?;
- }
- // Unknown tag, write it back.
- r => {
- self.writer.write_all(b"{")?;
- self.writer.write_all(r)?;
- self.writer.write_all(b"}")?;
- }
- }
- }
- }
-}
-
-fn wrap_help(help: &str, avail_chars: usize) -> String {
- let wrapper = textwrap::Wrapper::new(avail_chars).break_words(false);
- help.lines()
- .map(|line| wrapper.fill(line))
- .collect::<Vec<String>>()
- .join("\n")
-}
-
-#[cfg(test)]
-mod test {
- use super::wrap_help;
-
- #[test]
- fn wrap_help_last_word() {
- let help = String::from("foo bar baz");
- assert_eq!(wrap_help(&help, 5), "foo\nbar\nbaz");
- }
-}
diff --git a/clap/src/app/meta.rs b/clap/src/app/meta.rs
deleted file mode 100644
index c7f128f..0000000
--- a/clap/src/app/meta.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-#[doc(hidden)]
-#[allow(missing_debug_implementations)]
-#[derive(Default, Clone)]
-pub struct AppMeta<'b> {
- pub name: String,
- pub bin_name: Option<String>,
- pub author: Option<&'b str>,
- pub version: Option<&'b str>,
- pub long_version: Option<&'b str>,
- pub about: Option<&'b str>,
- pub long_about: Option<&'b str>,
- pub more_help: Option<&'b str>,
- pub pre_help: Option<&'b str>,
- pub aliases: Option<Vec<(&'b str, bool)>>, // (name, visible)
- pub usage_str: Option<&'b str>,
- pub usage: Option<String>,
- pub help_str: Option<&'b str>,
- pub disp_ord: usize,
- pub term_w: Option<usize>,
- pub max_w: Option<usize>,
- pub template: Option<&'b str>,
-}
-
-impl<'b> AppMeta<'b> {
- pub fn new() -> Self { Default::default() }
- pub fn with_name(s: String) -> Self {
- AppMeta {
- name: s,
- disp_ord: 999,
- ..Default::default()
- }
- }
-}
diff --git a/clap/src/app/mod.rs b/clap/src/app/mod.rs
deleted file mode 100644
index 3a1a383..0000000
--- a/clap/src/app/mod.rs
+++ /dev/null
@@ -1,1839 +0,0 @@
-mod settings;
-pub mod parser;
-mod meta;
-mod help;
-mod validator;
-mod usage;
-
-// Std
-use std::env;
-use std::ffi::{OsStr, OsString};
-use std::fmt;
-use std::io::{self, BufRead, BufWriter, Write};
-use std::path::Path;
-use std::process;
-use std::rc::Rc;
-use std::result::Result as StdResult;
-
-// Third Party
-#[cfg(feature = "yaml")]
-use yaml_rust::Yaml;
-
-// Internal
-use app::help::Help;
-use app::parser::Parser;
-use args::{AnyArg, Arg, ArgGroup, ArgMatcher, ArgMatches, ArgSettings};
-use errors::Result as ClapResult;
-pub use self::settings::AppSettings;
-use completions::Shell;
-use map::{self, VecMap};
-
-/// Used to create a representation of a command line program and all possible command line
-/// arguments. Application settings are set using the "builder pattern" with the
-/// [`App::get_matches`] family of methods being the terminal methods that starts the
-/// runtime-parsing process. These methods then return information about the user supplied
-/// arguments (or lack there of).
-///
-/// **NOTE:** There aren't any mandatory "options" that one must set. The "options" may
-/// also appear in any order (so long as one of the [`App::get_matches`] methods is the last method
-/// called).
-///
-/// # Examples
-///
-/// ```no_run
-/// # use clap::{App, Arg};
-/// let m = App::new("My Program")
-/// .author("Me, me@mail.com")
-/// .version("1.0.2")
-/// .about("Explains in brief what the program does")
-/// .arg(
-/// Arg::with_name("in_file").index(1)
-/// )
-/// .after_help("Longer explanation to appear after the options when \
-/// displaying the help information from --help or -h")
-/// .get_matches();
-///
-/// // Your program logic starts here...
-/// ```
-/// [`App::get_matches`]: ./struct.App.html#method.get_matches
-#[allow(missing_debug_implementations)]
-pub struct App<'a, 'b>
-where
- 'a: 'b,
-{
- #[doc(hidden)] pub p: Parser<'a, 'b>,
-}
-
-
-impl<'a, 'b> App<'a, 'b> {
- /// Creates a new instance of an application requiring a name. The name may be, but doesn't
- /// have to be same as the binary. The name will be displayed to the user when they request to
- /// print version or help and usage information.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let prog = App::new("My Program")
- /// # ;
- /// ```
- pub fn new<S: Into<String>>(n: S) -> Self {
- App {
- p: Parser::with_name(n.into()),
- }
- }
-
- /// Get the name of the app
- pub fn get_name(&self) -> &str { &self.p.meta.name }
-
- /// Get the name of the binary
- pub fn get_bin_name(&self) -> Option<&str> { self.p.meta.bin_name.as_ref().map(|s| s.as_str()) }
-
- /// Creates a new instance of an application requiring a name, but uses the [`crate_authors!`]
- /// and [`crate_version!`] macros to fill in the [`App::author`] and [`App::version`] fields.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let prog = App::with_defaults("My Program")
- /// # ;
- /// ```
- /// [`crate_authors!`]: ./macro.crate_authors!.html
- /// [`crate_version!`]: ./macro.crate_version!.html
- /// [`App::author`]: ./struct.App.html#method.author
- /// [`App::version`]: ./struct.App.html#method.author
- #[deprecated(since="2.14.1", note="Can never work; use explicit App::author() and App::version() calls instead")]
- pub fn with_defaults<S: Into<String>>(n: S) -> Self {
- let mut a = App {
- p: Parser::with_name(n.into()),
- };
- a.p.meta.author = Some("Kevin K. <kbknapp@gmail.com>");
- a.p.meta.version = Some("2.19.2");
- a
- }
-
- /// Creates a new instance of [`App`] from a .yml (YAML) file. A full example of supported YAML
- /// objects can be found in [`examples/17_yaml.rs`] and [`examples/17_yaml.yml`]. One great use
- /// for using YAML is when supporting multiple languages and dialects, as each language could
- /// be a distinct YAML file and determined at compiletime via `cargo` "features" in your
- /// `Cargo.toml`
- ///
- /// In order to use this function you must compile `clap` with the `features = ["yaml"]` in
- /// your settings for the `[dependencies.clap]` table of your `Cargo.toml`
- ///
- /// **NOTE:** Due to how the YAML objects are built there is a convenience macro for loading
- /// the YAML file at compile time (relative to the current file, like modules work). That YAML
- /// object can then be passed to this function.
- ///
- /// # Panics
- ///
- /// The YAML file must be properly formatted or this function will [`panic!`]. A good way to
- /// ensure this doesn't happen is to run your program with the `--help` switch. If this passes
- /// without error, you needn't worry because the YAML is properly formatted.
- ///
- /// # Examples
- ///
- /// The following example shows how to load a properly formatted YAML file to build an instance
- /// of an [`App`] struct.
- ///
- /// ```ignore
- /// # #[macro_use]
- /// # extern crate clap;
- /// # use clap::App;
- /// # fn main() {
- /// let yml = load_yaml!("app.yml");
- /// let app = App::from_yaml(yml);
- ///
- /// // continued logic goes here, such as `app.get_matches()` etc.
- /// # }
- /// ```
- /// [`App`]: ./struct.App.html
- /// [`examples/17_yaml.rs`]: https://github.com/clap-rs/clap/blob/master/examples/17_yaml.rs
- /// [`examples/17_yaml.yml`]: https://github.com/clap-rs/clap/blob/master/examples/17_yaml.yml
- /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
- #[cfg(feature = "yaml")]
- pub fn from_yaml(yaml: &'a Yaml) -> App<'a, 'a> { App::from(yaml) }
-
- /// Sets a string of author(s) that will be displayed to the user when they
- /// request the help information with `--help` or `-h`.
- ///
- /// **Pro-tip:** Use `clap`s convenience macro [`crate_authors!`] to automatically set your
- /// application's author(s) to the same thing as your crate at compile time. See the [`examples/`]
- /// directory for more information
- ///
- /// See the [`examples/`]
- /// directory for more information
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .author("Me, me@mymain.com")
- /// # ;
- /// ```
- /// [`crate_authors!`]: ./macro.crate_authors!.html
- /// [`examples/`]: https://github.com/clap-rs/clap/tree/master/examples
- pub fn author<S: Into<&'b str>>(mut self, author: S) -> Self {
- self.p.meta.author = Some(author.into());
- self
- }
-
- /// Overrides the system-determined binary name. This should only be used when absolutely
- /// necessary, such as when the binary name for your application is misleading, or perhaps
- /// *not* how the user should invoke your program.
- ///
- /// **Pro-tip:** When building things such as third party `cargo` subcommands, this setting
- /// **should** be used!
- ///
- /// **NOTE:** This command **should not** be used for [`SubCommand`]s.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("My Program")
- /// .bin_name("my_binary")
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- pub fn bin_name<S: Into<String>>(mut self, name: S) -> Self {
- self.p.meta.bin_name = Some(name.into());
- self
- }
-
- /// Sets a string describing what the program does. This will be displayed when displaying help
- /// information with `-h`.
- ///
- /// **NOTE:** If only `about` is provided, and not [`App::long_about`] but the user requests
- /// `--help` clap will still display the contents of `about` appropriately
- ///
- /// **NOTE:** Only [`App::about`] is used in completion script generation in order to be
- /// concise
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .about("Does really amazing things to great people")
- /// # ;
- /// ```
- /// [`App::long_about`]: ./struct.App.html#method.long_about
- pub fn about<S: Into<&'b str>>(mut self, about: S) -> Self {
- self.p.meta.about = Some(about.into());
- self
- }
-
- /// Sets a string describing what the program does. This will be displayed when displaying help
- /// information.
- ///
- /// **NOTE:** If only `long_about` is provided, and not [`App::about`] but the user requests
- /// `-h` clap will still display the contents of `long_about` appropriately
- ///
- /// **NOTE:** Only [`App::about`] is used in completion script generation in order to be
- /// concise
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .long_about(
- /// "Does really amazing things to great people. Now let's talk a little
- /// more in depth about how this subcommand really works. It may take about
- /// a few lines of text, but that's ok!")
- /// # ;
- /// ```
- /// [`App::about`]: ./struct.App.html#method.about
- pub fn long_about<S: Into<&'b str>>(mut self, about: S) -> Self {
- self.p.meta.long_about = Some(about.into());
- self
- }
-
- /// Sets the program's name. This will be displayed when displaying help information.
- ///
- /// **Pro-top:** This function is particularly useful when configuring a program via
- /// [`App::from_yaml`] in conjunction with the [`crate_name!`] macro to derive the program's
- /// name from its `Cargo.toml`.
- ///
- /// # Examples
- /// ```ignore
- /// # #[macro_use]
- /// # extern crate clap;
- /// # use clap::App;
- /// # fn main() {
- /// let yml = load_yaml!("app.yml");
- /// let app = App::from_yaml(yml)
- /// .name(crate_name!());
- ///
- /// // continued logic goes here, such as `app.get_matches()` etc.
- /// # }
- /// ```
- ///
- /// [`App::from_yaml`]: ./struct.App.html#method.from_yaml
- /// [`crate_name!`]: ./macro.crate_name.html
- pub fn name<S: Into<String>>(mut self, name: S) -> Self {
- self.p.meta.name = name.into();
- self
- }
-
- /// Adds additional help information to be displayed in addition to auto-generated help. This
- /// information is displayed **after** the auto-generated help information. This is often used
- /// to describe how to use the arguments, or caveats to be noted.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::App;
- /// App::new("myprog")
- /// .after_help("Does really amazing things to great people...but be careful with -R")
- /// # ;
- /// ```
- pub fn after_help<S: Into<&'b str>>(mut self, help: S) -> Self {
- self.p.meta.more_help = Some(help.into());
- self
- }
-
- /// Adds additional help information to be displayed in addition to auto-generated help. This
- /// information is displayed **before** the auto-generated help information. This is often used
- /// for header information.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::App;
- /// App::new("myprog")
- /// .before_help("Some info I'd like to appear before the help info")
- /// # ;
- /// ```
- pub fn before_help<S: Into<&'b str>>(mut self, help: S) -> Self {
- self.p.meta.pre_help = Some(help.into());
- self
- }
-
- /// Sets a string of the version number to be displayed when displaying version or help
- /// information with `-V`.
- ///
- /// **NOTE:** If only `version` is provided, and not [`App::long_version`] but the user
- /// requests `--version` clap will still display the contents of `version` appropriately
- ///
- /// **Pro-tip:** Use `clap`s convenience macro [`crate_version!`] to automatically set your
- /// application's version to the same thing as your crate at compile time. See the [`examples/`]
- /// directory for more information
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .version("v0.1.24")
- /// # ;
- /// ```
- /// [`crate_version!`]: ./macro.crate_version!.html
- /// [`examples/`]: https://github.com/clap-rs/clap/tree/master/examples
- /// [`App::long_version`]: ./struct.App.html#method.long_version
- pub fn version<S: Into<&'b str>>(mut self, ver: S) -> Self {
- self.p.meta.version = Some(ver.into());
- self
- }
-
- /// Sets a string of the version number to be displayed when displaying version or help
- /// information with `--version`.
- ///
- /// **NOTE:** If only `long_version` is provided, and not [`App::version`] but the user
- /// requests `-V` clap will still display the contents of `long_version` appropriately
- ///
- /// **Pro-tip:** Use `clap`s convenience macro [`crate_version!`] to automatically set your
- /// application's version to the same thing as your crate at compile time. See the [`examples/`]
- /// directory for more information
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .long_version(
- /// "v0.1.24
- /// commit: abcdef89726d
- /// revision: 123
- /// release: 2
- /// binary: myprog")
- /// # ;
- /// ```
- /// [`crate_version!`]: ./macro.crate_version!.html
- /// [`examples/`]: https://github.com/clap-rs/clap/tree/master/examples
- /// [`App::version`]: ./struct.App.html#method.version
- pub fn long_version<S: Into<&'b str>>(mut self, ver: S) -> Self {
- self.p.meta.long_version = Some(ver.into());
- self
- }
-
- /// Sets a custom usage string to override the auto-generated usage string.
- ///
- /// This will be displayed to the user when errors are found in argument parsing, or when you
- /// call [`ArgMatches::usage`]
- ///
- /// **CAUTION:** Using this setting disables `clap`s "context-aware" usage strings. After this
- /// setting is set, this will be the only usage string displayed to the user!
- ///
- /// **NOTE:** You do not need to specify the "USAGE: \n\t" portion, as that will
- /// still be applied by `clap`, you only need to specify the portion starting
- /// with the binary name.
- ///
- /// **NOTE:** This will not replace the entire help message, *only* the portion
- /// showing the usage.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .usage("myapp [-clDas] <some_file>")
- /// # ;
- /// ```
- /// [`ArgMatches::usage`]: ./struct.ArgMatches.html#method.usage
- pub fn usage<S: Into<&'b str>>(mut self, usage: S) -> Self {
- self.p.meta.usage_str = Some(usage.into());
- self
- }
-
- /// Sets a custom help message and overrides the auto-generated one. This should only be used
- /// when the auto-generated message does not suffice.
- ///
- /// This will be displayed to the user when they use `--help` or `-h`
- ///
- /// **NOTE:** This replaces the **entire** help message, so nothing will be auto-generated.
- ///
- /// **NOTE:** This **only** replaces the help message for the current command, meaning if you
- /// are using subcommands, those help messages will still be auto-generated unless you
- /// specify a [`Arg::help`] for them as well.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myapp")
- /// .help("myapp v1.0\n\
- /// Does awesome things\n\
- /// (C) me@mail.com\n\n\
- ///
- /// USAGE: myapp <opts> <command>\n\n\
- ///
- /// Options:\n\
- /// -h, --help Display this message\n\
- /// -V, --version Display version info\n\
- /// -s <stuff> Do something with stuff\n\
- /// -v Be verbose\n\n\
- ///
- /// Commmands:\n\
- /// help Prints this message\n\
- /// work Do some work")
- /// # ;
- /// ```
- /// [`Arg::help`]: ./struct.Arg.html#method.help
- pub fn help<S: Into<&'b str>>(mut self, help: S) -> Self {
- self.p.meta.help_str = Some(help.into());
- self
- }
-
- /// Sets the [`short`] for the auto-generated `help` argument.
- ///
- /// By default `clap` automatically assigns `h`, but this can be overridden if you have a
- /// different argument which you'd prefer to use the `-h` short with. This can be done by
- /// defining your own argument with a lowercase `h` as the [`short`].
- ///
- /// `clap` lazily generates these `help` arguments **after** you've defined any arguments of
- /// your own.
- ///
- /// **NOTE:** Any leading `-` characters will be stripped, and only the first
- /// non `-` character will be used as the [`short`] version
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .help_short("H") // Using an uppercase `H` instead of the default lowercase `h`
- /// # ;
- /// ```
- /// [`short`]: ./struct.Arg.html#method.short
- pub fn help_short<S: AsRef<str> + 'b>(mut self, s: S) -> Self {
- self.p.help_short(s.as_ref());
- self
- }
-
- /// Sets the [`short`] for the auto-generated `version` argument.
- ///
- /// By default `clap` automatically assigns `V`, but this can be overridden if you have a
- /// different argument which you'd prefer to use the `-V` short with. This can be done by
- /// defining your own argument with an uppercase `V` as the [`short`].
- ///
- /// `clap` lazily generates these `version` arguments **after** you've defined any arguments of
- /// your own.
- ///
- /// **NOTE:** Any leading `-` characters will be stripped, and only the first
- /// non `-` character will be used as the `short` version
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .version_short("v") // Using a lowercase `v` instead of the default capital `V`
- /// # ;
- /// ```
- /// [`short`]: ./struct.Arg.html#method.short
- pub fn version_short<S: AsRef<str>>(mut self, s: S) -> Self {
- self.p.version_short(s.as_ref());
- self
- }
-
- /// Sets the help text for the auto-generated `help` argument.
- ///
- /// By default `clap` sets this to `"Prints help information"`, but if you're using a
- /// different convention for your help messages and would prefer a different phrasing you can
- /// override it.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .help_message("Print help information") // Perhaps you want imperative help messages
- ///
- /// # ;
- /// ```
- pub fn help_message<S: Into<&'a str>>(mut self, s: S) -> Self {
- self.p.help_message = Some(s.into());
- self
- }
-
- /// Sets the help text for the auto-generated `version` argument.
- ///
- /// By default `clap` sets this to `"Prints version information"`, but if you're using a
- /// different convention for your help messages and would prefer a different phrasing then you
- /// can change it.
- ///
- /// # Examples
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .version_message("Print version information") // Perhaps you want imperative help messages
- /// # ;
- /// ```
- pub fn version_message<S: Into<&'a str>>(mut self, s: S) -> Self {
- self.p.version_message = Some(s.into());
- self
- }
-
- /// Sets the help template to be used, overriding the default format.
- ///
- /// Tags arg given inside curly brackets.
- ///
- /// Valid tags are:
- ///
- /// * `{bin}` - Binary name.
- /// * `{version}` - Version number.
- /// * `{author}` - Author information.
- /// * `{about}` - General description (from [`App::about`])
- /// * `{usage}` - Automatically generated or given usage string.
- /// * `{all-args}` - Help for all arguments (options, flags, positionals arguments,
- /// and subcommands) including titles.
- /// * `{unified}` - Unified help for options and flags. Note, you must *also* set
- /// [`AppSettings::UnifiedHelpMessage`] to fully merge both options and
- /// flags, otherwise the ordering is "best effort"
- /// * `{flags}` - Help for flags.
- /// * `{options}` - Help for options.
- /// * `{positionals}` - Help for positionals arguments.
- /// * `{subcommands}` - Help for subcommands.
- /// * `{after-help}` - Help from [`App::after_help`]
- /// * `{before-help}` - Help from [`App::before_help`]
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .version("1.0")
- /// .template("{bin} ({version}) - {usage}")
- /// # ;
- /// ```
- /// **NOTE:** The template system is, on purpose, very simple. Therefore the tags have to be
- /// written in lowercase and without spacing.
- ///
- /// [`App::about`]: ./struct.App.html#method.about
- /// [`App::after_help`]: ./struct.App.html#method.after_help
- /// [`App::before_help`]: ./struct.App.html#method.before_help
- /// [`AppSettings::UnifiedHelpMessage`]: ./enum.AppSettings.html#variant.UnifiedHelpMessage
- pub fn template<S: Into<&'b str>>(mut self, s: S) -> Self {
- self.p.meta.template = Some(s.into());
- self
- }
-
- /// Enables a single command, or [`SubCommand`], level settings.
- ///
- /// See [`AppSettings`] for a full list of possibilities and examples.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::SubcommandRequired)
- /// .setting(AppSettings::WaitOnError)
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings`]: ./enum.AppSettings.html
- pub fn setting(mut self, setting: AppSettings) -> Self {
- self.p.set(setting);
- self
- }
-
- /// Enables multiple command, or [`SubCommand`], level settings
- ///
- /// See [`AppSettings`] for a full list of possibilities and examples.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, AppSettings};
- /// App::new("myprog")
- /// .settings(&[AppSettings::SubcommandRequired,
- /// AppSettings::WaitOnError])
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings`]: ./enum.AppSettings.html
- pub fn settings(mut self, settings: &[AppSettings]) -> Self {
- for s in settings {
- self.p.set(*s);
- }
- self
- }
-
- /// Enables a single setting that is propagated down through all child [`SubCommand`]s.
- ///
- /// See [`AppSettings`] for a full list of possibilities and examples.
- ///
- /// **NOTE**: The setting is *only* propagated *down* and not up through parent commands.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, AppSettings};
- /// App::new("myprog")
- /// .global_setting(AppSettings::SubcommandRequired)
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings`]: ./enum.AppSettings.html
- pub fn global_setting(mut self, setting: AppSettings) -> Self {
- self.p.set(setting);
- self.p.g_settings.set(setting);
- self
- }
-
- /// Enables multiple settings which are propagated *down* through all child [`SubCommand`]s.
- ///
- /// See [`AppSettings`] for a full list of possibilities and examples.
- ///
- /// **NOTE**: The setting is *only* propagated *down* and not up through parent commands.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, AppSettings};
- /// App::new("myprog")
- /// .global_settings(&[AppSettings::SubcommandRequired,
- /// AppSettings::ColoredHelp])
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings`]: ./enum.AppSettings.html
- pub fn global_settings(mut self, settings: &[AppSettings]) -> Self {
- for s in settings {
- self.p.set(*s);
- self.p.g_settings.set(*s)
- }
- self
- }
-
- /// Disables a single command, or [`SubCommand`], level setting.
- ///
- /// See [`AppSettings`] for a full list of possibilities and examples.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, AppSettings};
- /// App::new("myprog")
- /// .unset_setting(AppSettings::ColorAuto)
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings`]: ./enum.AppSettings.html
- pub fn unset_setting(mut self, setting: AppSettings) -> Self {
- self.p.unset(setting);
- self
- }
-
- /// Disables multiple command, or [`SubCommand`], level settings.
- ///
- /// See [`AppSettings`] for a full list of possibilities and examples.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, AppSettings};
- /// App::new("myprog")
- /// .unset_settings(&[AppSettings::ColorAuto,
- /// AppSettings::AllowInvalidUtf8])
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings`]: ./enum.AppSettings.html
- pub fn unset_settings(mut self, settings: &[AppSettings]) -> Self {
- for s in settings {
- self.p.unset(*s);
- }
- self
- }
-
- /// Sets the terminal width at which to wrap help messages. Defaults to `120`. Using `0` will
- /// ignore terminal widths and use source formatting.
- ///
- /// `clap` automatically tries to determine the terminal width on Unix, Linux, macOS and Windows
- /// if the `wrap_help` cargo "feature" has been used while compiling. If the terminal width
- /// cannot be determined, `clap` defaults to `120`.
- ///
- /// **NOTE:** This setting applies globally and *not* on a per-command basis.
- ///
- /// **NOTE:** This setting must be set **before** any subcommands are added!
- ///
- /// # Platform Specific
- ///
- /// Only Unix, Linux, macOS and Windows support automatic determination of terminal width.
- /// Even on those platforms, this setting is useful if for any reason the terminal width
- /// cannot be determined.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::App;
- /// App::new("myprog")
- /// .set_term_width(80)
- /// # ;
- /// ```
- pub fn set_term_width(mut self, width: usize) -> Self {
- self.p.meta.term_w = Some(width);
- self
- }
-
- /// Sets the max terminal width at which to wrap help messages. Using `0` will ignore terminal
- /// widths and use source formatting.
- ///
- /// `clap` automatically tries to determine the terminal width on Unix, Linux, macOS and Windows
- /// if the `wrap_help` cargo "feature" has been used while compiling, but one might want to
- /// limit the size (e.g. when the terminal is running fullscreen).
- ///
- /// **NOTE:** This setting applies globally and *not* on a per-command basis.
- ///
- /// **NOTE:** This setting must be set **before** any subcommands are added!
- ///
- /// # Platform Specific
- ///
- /// Only Unix, Linux, macOS and Windows support automatic determination of terminal width.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::App;
- /// App::new("myprog")
- /// .max_term_width(100)
- /// # ;
- /// ```
- pub fn max_term_width(mut self, w: usize) -> Self {
- self.p.meta.max_w = Some(w);
- self
- }
-
- /// Adds an [argument] to the list of valid possibilities.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// // Adding a single "flag" argument with a short and help text, using Arg::with_name()
- /// .arg(
- /// Arg::with_name("debug")
- /// .short("d")
- /// .help("turns on debugging mode")
- /// )
- /// // Adding a single "option" argument with a short, a long, and help text using the less
- /// // verbose Arg::from_usage()
- /// .arg(
- /// Arg::from_usage("-c --config=[CONFIG] 'Optionally sets a config file to use'")
- /// )
- /// # ;
- /// ```
- /// [argument]: ./struct.Arg.html
- pub fn arg<A: Into<Arg<'a, 'b>>>(mut self, a: A) -> Self {
- self.p.add_arg(a.into());
- self
- }
-
- /// Adds multiple [arguments] to the list of valid possibilities
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .args(
- /// &[Arg::from_usage("[debug] -d 'turns on debugging info'"),
- /// Arg::with_name("input").index(1).help("the input file to use")]
- /// )
- /// # ;
- /// ```
- /// [arguments]: ./struct.Arg.html
- pub fn args(mut self, args: &[Arg<'a, 'b>]) -> Self {
- for arg in args {
- self.p.add_arg_ref(arg);
- }
- self
- }
-
- /// A convenience method for adding a single [argument] from a usage type string. The string
- /// used follows the same rules and syntax as [`Arg::from_usage`]
- ///
- /// **NOTE:** The downside to using this method is that you can not set any additional
- /// properties of the [`Arg`] other than what [`Arg::from_usage`] supports.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .arg_from_usage("-c --config=<FILE> 'Sets a configuration file to use'")
- /// # ;
- /// ```
- /// [argument]: ./struct.Arg.html
- /// [`Arg`]: ./struct.Arg.html
- /// [`Arg::from_usage`]: ./struct.Arg.html#method.from_usage
- pub fn arg_from_usage(mut self, usage: &'a str) -> Self {
- self.p.add_arg(Arg::from_usage(usage));
- self
- }
-
- /// Adds multiple [arguments] at once from a usage string, one per line. See
- /// [`Arg::from_usage`] for details on the syntax and rules supported.
- ///
- /// **NOTE:** Like [`App::arg_from_usage`] the downside is you only set properties for the
- /// [`Arg`]s which [`Arg::from_usage`] supports.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// App::new("myprog")
- /// .args_from_usage(
- /// "-c --config=[FILE] 'Sets a configuration file to use'
- /// [debug]... -d 'Sets the debugging level'
- /// <FILE> 'The input file to use'"
- /// )
- /// # ;
- /// ```
- /// [arguments]: ./struct.Arg.html
- /// [`Arg::from_usage`]: ./struct.Arg.html#method.from_usage
- /// [`App::arg_from_usage`]: ./struct.App.html#method.arg_from_usage
- /// [`Arg`]: ./struct.Arg.html
- pub fn args_from_usage(mut self, usage: &'a str) -> Self {
- for line in usage.lines() {
- let l = line.trim();
- if l.is_empty() {
- continue;
- }
- self.p.add_arg(Arg::from_usage(l));
- }
- self
- }
-
- /// Allows adding a [`SubCommand`] alias, which function as "hidden" subcommands that
- /// automatically dispatch as if this subcommand was used. This is more efficient, and easier
- /// than creating multiple hidden subcommands as one only needs to check for the existence of
- /// this command, and not all variants.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// let m = App::new("myprog")
- /// .subcommand(SubCommand::with_name("test")
- /// .alias("do-stuff"))
- /// .get_matches_from(vec!["myprog", "do-stuff"]);
- /// assert_eq!(m.subcommand_name(), Some("test"));
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- pub fn alias<S: Into<&'b str>>(mut self, name: S) -> Self {
- if let Some(ref mut als) = self.p.meta.aliases {
- als.push((name.into(), false));
- } else {
- self.p.meta.aliases = Some(vec![(name.into(), false)]);
- }
- self
- }
-
- /// Allows adding [`SubCommand`] aliases, which function as "hidden" subcommands that
- /// automatically dispatch as if this subcommand was used. This is more efficient, and easier
- /// than creating multiple hidden subcommands as one only needs to check for the existence of
- /// this command, and not all variants.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, SubCommand};
- /// let m = App::new("myprog")
- /// .subcommand(SubCommand::with_name("test")
- /// .aliases(&["do-stuff", "do-tests", "tests"]))
- /// .arg(Arg::with_name("input")
- /// .help("the file to add")
- /// .index(1)
- /// .required(false))
- /// .get_matches_from(vec!["myprog", "do-tests"]);
- /// assert_eq!(m.subcommand_name(), Some("test"));
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- pub fn aliases(mut self, names: &[&'b str]) -> Self {
- if let Some(ref mut als) = self.p.meta.aliases {
- for n in names {
- als.push((n, false));
- }
- } else {
- self.p.meta.aliases = Some(names.iter().map(|n| (*n, false)).collect::<Vec<_>>());
- }
- self
- }
-
- /// Allows adding a [`SubCommand`] alias that functions exactly like those defined with
- /// [`App::alias`], except that they are visible inside the help message.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// let m = App::new("myprog")
- /// .subcommand(SubCommand::with_name("test")
- /// .visible_alias("do-stuff"))
- /// .get_matches_from(vec!["myprog", "do-stuff"]);
- /// assert_eq!(m.subcommand_name(), Some("test"));
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`App::alias`]: ./struct.App.html#method.alias
- pub fn visible_alias<S: Into<&'b str>>(mut self, name: S) -> Self {
- if let Some(ref mut als) = self.p.meta.aliases {
- als.push((name.into(), true));
- } else {
- self.p.meta.aliases = Some(vec![(name.into(), true)]);
- }
- self
- }
-
- /// Allows adding multiple [`SubCommand`] aliases that functions exactly like those defined
- /// with [`App::aliases`], except that they are visible inside the help message.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// let m = App::new("myprog")
- /// .subcommand(SubCommand::with_name("test")
- /// .visible_aliases(&["do-stuff", "tests"]))
- /// .get_matches_from(vec!["myprog", "do-stuff"]);
- /// assert_eq!(m.subcommand_name(), Some("test"));
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`App::aliases`]: ./struct.App.html#method.aliases
- pub fn visible_aliases(mut self, names: &[&'b str]) -> Self {
- if let Some(ref mut als) = self.p.meta.aliases {
- for n in names {
- als.push((n, true));
- }
- } else {
- self.p.meta.aliases = Some(names.iter().map(|n| (*n, true)).collect::<Vec<_>>());
- }
- self
- }
-
- /// Adds an [`ArgGroup`] to the application. [`ArgGroup`]s are a family of related arguments.
- /// By placing them in a logical group, you can build easier requirement and exclusion rules.
- /// For instance, you can make an entire [`ArgGroup`] required, meaning that one (and *only*
- /// one) argument from that group must be present at runtime.
- ///
- /// You can also do things such as name an [`ArgGroup`] as a conflict to another argument.
- /// Meaning any of the arguments that belong to that group will cause a failure if present with
- /// the conflicting argument.
- ///
- /// Another added benefit of [`ArgGroup`]s is that you can extract a value from a group instead
- /// of determining exactly which argument was used.
- ///
- /// Finally, using [`ArgGroup`]s to ensure exclusion between arguments is another very common
- /// use
- ///
- /// # Examples
- ///
- /// The following example demonstrates using an [`ArgGroup`] to ensure that one, and only one,
- /// of the arguments from the specified group is present at runtime.
- ///
- /// ```no_run
- /// # use clap::{App, ArgGroup};
- /// App::new("app")
- /// .args_from_usage(
- /// "--set-ver [ver] 'set the version manually'
- /// --major 'auto increase major'
- /// --minor 'auto increase minor'
- /// --patch 'auto increase patch'")
- /// .group(ArgGroup::with_name("vers")
- /// .args(&["set-ver", "major", "minor","patch"])
- /// .required(true))
- /// # ;
- /// ```
- /// [`ArgGroup`]: ./struct.ArgGroup.html
- pub fn group(mut self, group: ArgGroup<'a>) -> Self {
- self.p.add_group(group);
- self
- }
-
- /// Adds multiple [`ArgGroup`]s to the [`App`] at once.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, ArgGroup};
- /// App::new("app")
- /// .args_from_usage(
- /// "--set-ver [ver] 'set the version manually'
- /// --major 'auto increase major'
- /// --minor 'auto increase minor'
- /// --patch 'auto increase patch'
- /// -c [FILE] 'a config file'
- /// -i [IFACE] 'an interface'")
- /// .groups(&[
- /// ArgGroup::with_name("vers")
- /// .args(&["set-ver", "major", "minor","patch"])
- /// .required(true),
- /// ArgGroup::with_name("input")
- /// .args(&["c", "i"])
- /// ])
- /// # ;
- /// ```
- /// [`ArgGroup`]: ./struct.ArgGroup.html
- /// [`App`]: ./struct.App.html
- pub fn groups(mut self, groups: &[ArgGroup<'a>]) -> Self {
- for g in groups {
- self = self.group(g.into());
- }
- self
- }
-
- /// Adds a [`SubCommand`] to the list of valid possibilities. Subcommands are effectively
- /// sub-[`App`]s, because they can contain their own arguments, subcommands, version, usage,
- /// etc. They also function just like [`App`]s, in that they get their own auto generated help,
- /// version, and usage.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// App::new("myprog")
- /// .subcommand(SubCommand::with_name("config")
- /// .about("Controls configuration features")
- /// .arg_from_usage("<config> 'Required configuration file to use'"))
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`App`]: ./struct.App.html
- pub fn subcommand(mut self, subcmd: App<'a, 'b>) -> Self {
- self.p.add_subcommand(subcmd);
- self
- }
-
- /// Adds multiple subcommands to the list of valid possibilities by iterating over an
- /// [`IntoIterator`] of [`SubCommand`]s
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, SubCommand};
- /// # App::new("myprog")
- /// .subcommands( vec![
- /// SubCommand::with_name("config").about("Controls configuration functionality")
- /// .arg(Arg::with_name("config_file").index(1)),
- /// SubCommand::with_name("debug").about("Controls debug functionality")])
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`IntoIterator`]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html
- pub fn subcommands<I>(mut self, subcmds: I) -> Self
- where
- I: IntoIterator<Item = App<'a, 'b>>,
- {
- for subcmd in subcmds {
- self.p.add_subcommand(subcmd);
- }
- self
- }
-
- /// Allows custom ordering of [`SubCommand`]s within the help message. Subcommands with a lower
- /// value will be displayed first in the help message. This is helpful when one would like to
- /// emphasise frequently used subcommands, or prioritize those towards the top of the list.
- /// Duplicate values **are** allowed. Subcommands with duplicate display orders will be
- /// displayed in alphabetical order.
- ///
- /// **NOTE:** The default is 999 for all subcommands.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, SubCommand};
- /// let m = App::new("cust-ord")
- /// .subcommand(SubCommand::with_name("alpha") // typically subcommands are grouped
- /// // alphabetically by name. Subcommands
- /// // without a display_order have a value of
- /// // 999 and are displayed alphabetically with
- /// // all other 999 subcommands
- /// .about("Some help and text"))
- /// .subcommand(SubCommand::with_name("beta")
- /// .display_order(1) // In order to force this subcommand to appear *first*
- /// // all we have to do is give it a value lower than 999.
- /// // Any other subcommands with a value of 1 will be displayed
- /// // alphabetically with this one...then 2 values, then 3, etc.
- /// .about("I should be first!"))
- /// .get_matches_from(vec![
- /// "cust-ord", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays the following help message
- ///
- /// ```text
- /// cust-ord
- ///
- /// USAGE:
- /// cust-ord [FLAGS] [OPTIONS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- ///
- /// SUBCOMMANDS:
- /// beta I should be first!
- /// alpha Some help and text
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- pub fn display_order(mut self, ord: usize) -> Self {
- self.p.meta.disp_ord = ord;
- self
- }
-
- /// Prints the full help message to [`io::stdout()`] using a [`BufWriter`] using the same
- /// method as if someone ran `-h` to request the help message
- ///
- /// **NOTE:** clap has the ability to distinguish between "short" and "long" help messages
- /// depending on if the user ran [`-h` (short)] or [`--help` (long)]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::App;
- /// let mut app = App::new("myprog");
- /// app.print_help();
- /// ```
- /// [`io::stdout()`]: https://doc.rust-lang.org/std/io/fn.stdout.html
- /// [`BufWriter`]: https://doc.rust-lang.org/std/io/struct.BufWriter.html
- /// [`-h` (short)]: ./struct.Arg.html#method.help
- /// [`--help` (long)]: ./struct.Arg.html#method.long_help
- pub fn print_help(&mut self) -> ClapResult<()> {
- // If there are global arguments, or settings we need to propagate them down to subcommands
- // before parsing incase we run into a subcommand
- self.p.propagate_globals();
- self.p.propagate_settings();
- self.p.derive_display_order();
-
- self.p.create_help_and_version();
- let out = io::stdout();
- let mut buf_w = BufWriter::new(out.lock());
- self.write_help(&mut buf_w)
- }
-
- /// Prints the full help message to [`io::stdout()`] using a [`BufWriter`] using the same
- /// method as if someone ran `--help` to request the help message
- ///
- /// **NOTE:** clap has the ability to distinguish between "short" and "long" help messages
- /// depending on if the user ran [`-h` (short)] or [`--help` (long)]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::App;
- /// let mut app = App::new("myprog");
- /// app.print_long_help();
- /// ```
- /// [`io::stdout()`]: https://doc.rust-lang.org/std/io/fn.stdout.html
- /// [`BufWriter`]: https://doc.rust-lang.org/std/io/struct.BufWriter.html
- /// [`-h` (short)]: ./struct.Arg.html#method.help
- /// [`--help` (long)]: ./struct.Arg.html#method.long_help
- pub fn print_long_help(&mut self) -> ClapResult<()> {
- let out = io::stdout();
- let mut buf_w = BufWriter::new(out.lock());
- self.write_long_help(&mut buf_w)
- }
-
- /// Writes the full help message to the user to a [`io::Write`] object in the same method as if
- /// the user ran `-h`
- ///
- /// **NOTE:** clap has the ability to distinguish between "short" and "long" help messages
- /// depending on if the user ran [`-h` (short)] or [`--help` (long)]
- ///
- /// **NOTE:** There is a known bug where this method does not write propagated global arguments
- /// or autogenerated arguments (i.e. the default help/version args). Prefer
- /// [`App::write_long_help`] instead if possible!
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::App;
- /// use std::io;
- /// let mut app = App::new("myprog");
- /// let mut out = io::stdout();
- /// app.write_help(&mut out).expect("failed to write to stdout");
- /// ```
- /// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
- /// [`-h` (short)]: ./struct.Arg.html#method.help
- /// [`--help` (long)]: ./struct.Arg.html#method.long_help
- pub fn write_help<W: Write>(&self, w: &mut W) -> ClapResult<()> {
- // PENDING ISSUE: 808
- // https://github.com/clap-rs/clap/issues/808
- // If there are global arguments, or settings we need to propagate them down to subcommands
- // before parsing incase we run into a subcommand
- // self.p.propagate_globals();
- // self.p.propagate_settings();
- // self.p.derive_display_order();
- // self.p.create_help_and_version();
-
- Help::write_app_help(w, self, false)
- }
-
- /// Writes the full help message to the user to a [`io::Write`] object in the same method as if
- /// the user ran `--help`
- ///
- /// **NOTE:** clap has the ability to distinguish between "short" and "long" help messages
- /// depending on if the user ran [`-h` (short)] or [`--help` (long)]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::App;
- /// use std::io;
- /// let mut app = App::new("myprog");
- /// let mut out = io::stdout();
- /// app.write_long_help(&mut out).expect("failed to write to stdout");
- /// ```
- /// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
- /// [`-h` (short)]: ./struct.Arg.html#method.help
- /// [`--help` (long)]: ./struct.Arg.html#method.long_help
- pub fn write_long_help<W: Write>(&mut self, w: &mut W) -> ClapResult<()> {
- // If there are global arguments, or settings we need to propagate them down to subcommands
- // before parsing incase we run into a subcommand
- self.p.propagate_globals();
- self.p.propagate_settings();
- self.p.derive_display_order();
- self.p.create_help_and_version();
-
- Help::write_app_help(w, self, true)
- }
-
- /// Writes the version message to the user to a [`io::Write`] object as if the user ran `-V`.
- ///
- /// **NOTE:** clap has the ability to distinguish between "short" and "long" version messages
- /// depending on if the user ran [`-V` (short)] or [`--version` (long)]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::App;
- /// use std::io;
- /// let mut app = App::new("myprog");
- /// let mut out = io::stdout();
- /// app.write_version(&mut out).expect("failed to write to stdout");
- /// ```
- /// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
- /// [`-V` (short)]: ./struct.App.html#method.version
- /// [`--version` (long)]: ./struct.App.html#method.long_version
- pub fn write_version<W: Write>(&self, w: &mut W) -> ClapResult<()> {
- self.p.write_version(w, false).map_err(From::from)
- }
-
- /// Writes the version message to the user to a [`io::Write`] object
- ///
- /// **NOTE:** clap has the ability to distinguish between "short" and "long" version messages
- /// depending on if the user ran [`-V` (short)] or [`--version` (long)]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::App;
- /// use std::io;
- /// let mut app = App::new("myprog");
- /// let mut out = io::stdout();
- /// app.write_long_version(&mut out).expect("failed to write to stdout");
- /// ```
- /// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
- /// [`-V` (short)]: ./struct.App.html#method.version
- /// [`--version` (long)]: ./struct.App.html#method.long_version
- pub fn write_long_version<W: Write>(&self, w: &mut W) -> ClapResult<()> {
- self.p.write_version(w, true).map_err(From::from)
- }
-
- /// Generate a completions file for a specified shell at compile time.
- ///
- /// **NOTE:** to generate the file at compile time you must use a `build.rs` "Build Script"
- ///
- /// # Examples
- ///
- /// The following example generates a bash completion script via a `build.rs` script. In this
- /// simple example, we'll demo a very small application with only a single subcommand and two
- /// args. Real applications could be many multiple levels deep in subcommands, and have tens or
- /// potentially hundreds of arguments.
- ///
- /// First, it helps if we separate out our `App` definition into a separate file. Whether you
- /// do this as a function, or bare App definition is a matter of personal preference.
- ///
- /// ```
- /// // src/cli.rs
- ///
- /// use clap::{App, Arg, SubCommand};
- ///
- /// pub fn build_cli() -> App<'static, 'static> {
- /// App::new("compl")
- /// .about("Tests completions")
- /// .arg(Arg::with_name("file")
- /// .help("some input file"))
- /// .subcommand(SubCommand::with_name("test")
- /// .about("tests things")
- /// .arg(Arg::with_name("case")
- /// .long("case")
- /// .takes_value(true)
- /// .help("the case to test")))
- /// }
- /// ```
- ///
- /// In our regular code, we can simply call this `build_cli()` function, then call
- /// `get_matches()`, or any of the other normal methods directly after. For example:
- ///
- /// ```ignore
- /// // src/main.rs
- ///
- /// mod cli;
- ///
- /// fn main() {
- /// let m = cli::build_cli().get_matches();
- ///
- /// // normal logic continues...
- /// }
- /// ```
- ///
- /// Next, we set up our `Cargo.toml` to use a `build.rs` build script.
- ///
- /// ```toml
- /// # Cargo.toml
- /// build = "build.rs"
- ///
- /// [build-dependencies]
- /// clap = "2.23"
- /// ```
- ///
- /// Next, we place a `build.rs` in our project root.
- ///
- /// ```ignore
- /// extern crate clap;
- ///
- /// use clap::Shell;
- ///
- /// include!("src/cli.rs");
- ///
- /// fn main() {
- /// let outdir = match env::var_os("OUT_DIR") {
- /// None => return,
- /// Some(outdir) => outdir,
- /// };
- /// let mut app = build_cli();
- /// app.gen_completions("myapp", // We need to specify the bin name manually
- /// Shell::Bash, // Then say which shell to build completions for
- /// outdir); // Then say where write the completions to
- /// }
- /// ```
- /// Now, once we compile there will be a `{bin_name}.bash` file in the directory.
- /// Assuming we compiled with debug mode, it would be somewhere similar to
- /// `<project>/target/debug/build/myapp-<hash>/out/myapp.bash`.
- ///
- /// Fish shell completions will use the file format `{bin_name}.fish`
- pub fn gen_completions<T: Into<OsString>, S: Into<String>>(
- &mut self,
- bin_name: S,
- for_shell: Shell,
- out_dir: T,
- ) {
- self.p.meta.bin_name = Some(bin_name.into());
- self.p.gen_completions(for_shell, out_dir.into());
- }
-
-
- /// Generate a completions file for a specified shell at runtime. Until `cargo install` can
- /// install extra files like a completion script, this may be used e.g. in a command that
- /// outputs the contents of the completion script, to be redirected into a file by the user.
- ///
- /// # Examples
- ///
- /// Assuming a separate `cli.rs` like the [example above](./struct.App.html#method.gen_completions),
- /// we can let users generate a completion script using a command:
- ///
- /// ```ignore
- /// // src/main.rs
- ///
- /// mod cli;
- /// use std::io;
- ///
- /// fn main() {
- /// let matches = cli::build_cli().get_matches();
- ///
- /// if matches.is_present("generate-bash-completions") {
- /// cli::build_cli().gen_completions_to("myapp", Shell::Bash, &mut io::stdout());
- /// }
- ///
- /// // normal logic continues...
- /// }
- ///
- /// ```
- ///
- /// Usage:
- ///
- /// ```shell
- /// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
- /// ```
- pub fn gen_completions_to<W: Write, S: Into<String>>(
- &mut self,
- bin_name: S,
- for_shell: Shell,
- buf: &mut W,
- ) {
- self.p.meta.bin_name = Some(bin_name.into());
- self.p.gen_completions_to(for_shell, buf);
- }
-
- /// Starts the parsing process, upon a failed parse an error will be displayed to the user and
- /// the process will exit with the appropriate error code. By default this method gets all user
- /// provided arguments from [`env::args_os`] in order to allow for invalid UTF-8 code points,
- /// which are legal on many platforms.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let matches = App::new("myprog")
- /// // Args and options go here...
- /// .get_matches();
- /// ```
- /// [`env::args_os`]: https://doc.rust-lang.org/std/env/fn.args_os.html
- pub fn get_matches(self) -> ArgMatches<'a> { self.get_matches_from(&mut env::args_os()) }
-
- /// Starts the parsing process. This method will return a [`clap::Result`] type instead of exiting
- /// the process on failed parse. By default this method gets matches from [`env::args_os`]
- ///
- /// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
- /// used. It will return a [`clap::Error`], where the [`kind`] is a
- /// [`ErrorKind::HelpDisplayed`] or [`ErrorKind::VersionDisplayed`] respectively. You must call
- /// [`Error::exit`] or perform a [`std::process::exit`].
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let matches = App::new("myprog")
- /// // Args and options go here...
- /// .get_matches_safe()
- /// .unwrap_or_else( |e| e.exit() );
- /// ```
- /// [`env::args_os`]: https://doc.rust-lang.org/std/env/fn.args_os.html
- /// [`ErrorKind::HelpDisplayed`]: ./enum.ErrorKind.html#variant.HelpDisplayed
- /// [`ErrorKind::VersionDisplayed`]: ./enum.ErrorKind.html#variant.VersionDisplayed
- /// [`Error::exit`]: ./struct.Error.html#method.exit
- /// [`std::process::exit`]: https://doc.rust-lang.org/std/process/fn.exit.html
- /// [`clap::Result`]: ./type.Result.html
- /// [`clap::Error`]: ./struct.Error.html
- /// [`kind`]: ./struct.Error.html
- pub fn get_matches_safe(self) -> ClapResult<ArgMatches<'a>> {
- // Start the parsing
- self.get_matches_from_safe(&mut env::args_os())
- }
-
- /// Starts the parsing process. Like [`App::get_matches`] this method does not return a [`clap::Result`]
- /// and will automatically exit with an error message. This method, however, lets you specify
- /// what iterator to use when performing matches, such as a [`Vec`] of your making.
- ///
- /// **NOTE:** The first argument will be parsed as the binary name unless
- /// [`AppSettings::NoBinaryName`] is used
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let arg_vec = vec!["my_prog", "some", "args", "to", "parse"];
- ///
- /// let matches = App::new("myprog")
- /// // Args and options go here...
- /// .get_matches_from(arg_vec);
- /// ```
- /// [`App::get_matches`]: ./struct.App.html#method.get_matches
- /// [`clap::Result`]: ./type.Result.html
- /// [`Vec`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
- /// [`AppSettings::NoBinaryName`]: ./enum.AppSettings.html#variant.NoBinaryName
- pub fn get_matches_from<I, T>(mut self, itr: I) -> ArgMatches<'a>
- where
- I: IntoIterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- self.get_matches_from_safe_borrow(itr).unwrap_or_else(|e| {
- // Otherwise, write to stderr and exit
- if e.use_stderr() {
- wlnerr!("{}", e.message);
- if self.p.is_set(AppSettings::WaitOnError) {
- wlnerr!("\nPress [ENTER] / [RETURN] to continue...");
- let mut s = String::new();
- let i = io::stdin();
- i.lock().read_line(&mut s).unwrap();
- }
- drop(self);
- drop(e);
- process::exit(1);
- }
-
- drop(self);
- e.exit()
- })
- }
-
- /// Starts the parsing process. A combination of [`App::get_matches_from`], and
- /// [`App::get_matches_safe`]
- ///
- /// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
- /// used. It will return a [`clap::Error`], where the [`kind`] is a [`ErrorKind::HelpDisplayed`]
- /// or [`ErrorKind::VersionDisplayed`] respectively. You must call [`Error::exit`] or
- /// perform a [`std::process::exit`] yourself.
- ///
- /// **NOTE:** The first argument will be parsed as the binary name unless
- /// [`AppSettings::NoBinaryName`] is used
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let arg_vec = vec!["my_prog", "some", "args", "to", "parse"];
- ///
- /// let matches = App::new("myprog")
- /// // Args and options go here...
- /// .get_matches_from_safe(arg_vec)
- /// .unwrap_or_else( |e| { panic!("An error occurs: {}", e) });
- /// ```
- /// [`App::get_matches_from`]: ./struct.App.html#method.get_matches_from
- /// [`App::get_matches_safe`]: ./struct.App.html#method.get_matches_safe
- /// [`ErrorKind::HelpDisplayed`]: ./enum.ErrorKind.html#variant.HelpDisplayed
- /// [`ErrorKind::VersionDisplayed`]: ./enum.ErrorKind.html#variant.VersionDisplayed
- /// [`Error::exit`]: ./struct.Error.html#method.exit
- /// [`std::process::exit`]: https://doc.rust-lang.org/std/process/fn.exit.html
- /// [`clap::Error`]: ./struct.Error.html
- /// [`Error::exit`]: ./struct.Error.html#method.exit
- /// [`kind`]: ./struct.Error.html
- /// [`AppSettings::NoBinaryName`]: ./enum.AppSettings.html#variant.NoBinaryName
- pub fn get_matches_from_safe<I, T>(mut self, itr: I) -> ClapResult<ArgMatches<'a>>
- where
- I: IntoIterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- self.get_matches_from_safe_borrow(itr)
- }
-
- /// Starts the parsing process without consuming the [`App`] struct `self`. This is normally not
- /// the desired functionality, instead prefer [`App::get_matches_from_safe`] which *does*
- /// consume `self`.
- ///
- /// **NOTE:** The first argument will be parsed as the binary name unless
- /// [`AppSettings::NoBinaryName`] is used
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg};
- /// let arg_vec = vec!["my_prog", "some", "args", "to", "parse"];
- ///
- /// let mut app = App::new("myprog");
- /// // Args and options go here...
- /// let matches = app.get_matches_from_safe_borrow(arg_vec)
- /// .unwrap_or_else( |e| { panic!("An error occurs: {}", e) });
- /// ```
- /// [`App`]: ./struct.App.html
- /// [`App::get_matches_from_safe`]: ./struct.App.html#method.get_matches_from_safe
- /// [`AppSettings::NoBinaryName`]: ./enum.AppSettings.html#variant.NoBinaryName
- pub fn get_matches_from_safe_borrow<I, T>(&mut self, itr: I) -> ClapResult<ArgMatches<'a>>
- where
- I: IntoIterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- // If there are global arguments, or settings we need to propagate them down to subcommands
- // before parsing incase we run into a subcommand
- if !self.p.is_set(AppSettings::Propagated) {
- self.p.propagate_globals();
- self.p.propagate_settings();
- self.p.derive_display_order();
- self.p.set(AppSettings::Propagated);
- }
-
- let mut matcher = ArgMatcher::new();
-
- let mut it = itr.into_iter();
- // Get the name of the program (argument 1 of env::args()) and determine the
- // actual file
- // that was used to execute the program. This is because a program called
- // ./target/release/my_prog -a
- // will have two arguments, './target/release/my_prog', '-a' but we don't want
- // to display
- // the full path when displaying help messages and such
- if !self.p.is_set(AppSettings::NoBinaryName) {
- if let Some(name) = it.next() {
- let bn_os = name.into();
- let p = Path::new(&*bn_os);
- if let Some(f) = p.file_name() {
- if let Some(s) = f.to_os_string().to_str() {
- if self.p.meta.bin_name.is_none() {
- self.p.meta.bin_name = Some(s.to_owned());
- }
- }
- }
- }
- }
-
- // do the real parsing
- if let Err(e) = self.p.get_matches_with(&mut matcher, &mut it.peekable()) {
- return Err(e);
- }
-
- let global_arg_vec: Vec<&str> = (&self).p.global_args.iter().map(|ga| ga.b.name).collect();
- matcher.propagate_globals(&global_arg_vec);
-
- Ok(matcher.into())
- }
-}
-
-#[cfg(feature = "yaml")]
-impl<'a> From<&'a Yaml> for App<'a, 'a> {
- fn from(mut yaml: &'a Yaml) -> Self {
- use args::SubCommand;
- // We WANT this to panic on error...so expect() is good.
- let mut is_sc = None;
- let mut a = if let Some(name) = yaml["name"].as_str() {
- App::new(name)
- } else {
- let yaml_hash = yaml.as_hash().unwrap();
- let sc_key = yaml_hash.keys().nth(0).unwrap();
- is_sc = Some(yaml_hash.get(sc_key).unwrap());
- App::new(sc_key.as_str().unwrap())
- };
- yaml = if let Some(sc) = is_sc { sc } else { yaml };
-
- macro_rules! yaml_str {
- ($a:ident, $y:ident, $i:ident) => {
- if let Some(v) = $y[stringify!($i)].as_str() {
- $a = $a.$i(v);
- } else if $y[stringify!($i)] != Yaml::BadValue {
- panic!("Failed to convert YAML value {:?} to a string", $y[stringify!($i)]);
- }
- };
- }
-
- yaml_str!(a, yaml, version);
- yaml_str!(a, yaml, long_version);
- yaml_str!(a, yaml, author);
- yaml_str!(a, yaml, bin_name);
- yaml_str!(a, yaml, about);
- yaml_str!(a, yaml, long_about);
- yaml_str!(a, yaml, before_help);
- yaml_str!(a, yaml, after_help);
- yaml_str!(a, yaml, template);
- yaml_str!(a, yaml, usage);
- yaml_str!(a, yaml, help);
- yaml_str!(a, yaml, help_short);
- yaml_str!(a, yaml, version_short);
- yaml_str!(a, yaml, help_message);
- yaml_str!(a, yaml, version_message);
- yaml_str!(a, yaml, alias);
- yaml_str!(a, yaml, visible_alias);
-
- if let Some(v) = yaml["display_order"].as_i64() {
- a = a.display_order(v as usize);
- } else if yaml["display_order"] != Yaml::BadValue {
- panic!(
- "Failed to convert YAML value {:?} to a u64",
- yaml["display_order"]
- );
- }
- if let Some(v) = yaml["setting"].as_str() {
- a = a.setting(v.parse().expect("unknown AppSetting found in YAML file"));
- } else if yaml["setting"] != Yaml::BadValue {
- panic!(
- "Failed to convert YAML value {:?} to an AppSetting",
- yaml["setting"]
- );
- }
- if let Some(v) = yaml["settings"].as_vec() {
- for ys in v {
- if let Some(s) = ys.as_str() {
- a = a.setting(s.parse().expect("unknown AppSetting found in YAML file"));
- }
- }
- } else if let Some(v) = yaml["settings"].as_str() {
- a = a.setting(v.parse().expect("unknown AppSetting found in YAML file"));
- } else if yaml["settings"] != Yaml::BadValue {
- panic!(
- "Failed to convert YAML value {:?} to a string",
- yaml["settings"]
- );
- }
- if let Some(v) = yaml["global_setting"].as_str() {
- a = a.setting(v.parse().expect("unknown AppSetting found in YAML file"));
- } else if yaml["global_setting"] != Yaml::BadValue {
- panic!(
- "Failed to convert YAML value {:?} to an AppSetting",
- yaml["setting"]
- );
- }
- if let Some(v) = yaml["global_settings"].as_vec() {
- for ys in v {
- if let Some(s) = ys.as_str() {
- a = a.global_setting(s.parse().expect("unknown AppSetting found in YAML file"));
- }
- }
- } else if let Some(v) = yaml["global_settings"].as_str() {
- a = a.global_setting(v.parse().expect("unknown AppSetting found in YAML file"));
- } else if yaml["global_settings"] != Yaml::BadValue {
- panic!(
- "Failed to convert YAML value {:?} to a string",
- yaml["global_settings"]
- );
- }
-
- macro_rules! vec_or_str {
- ($a:ident, $y:ident, $as_vec:ident, $as_single:ident) => {{
- let maybe_vec = $y[stringify!($as_vec)].as_vec();
- if let Some(vec) = maybe_vec {
- for ys in vec {
- if let Some(s) = ys.as_str() {
- $a = $a.$as_single(s);
- } else {
- panic!("Failed to convert YAML value {:?} to a string", ys);
- }
- }
- } else {
- if let Some(s) = $y[stringify!($as_vec)].as_str() {
- $a = $a.$as_single(s);
- } else if $y[stringify!($as_vec)] != Yaml::BadValue {
- panic!("Failed to convert YAML value {:?} to either a vec or string", $y[stringify!($as_vec)]);
- }
- }
- $a
- }
- };
- }
-
- a = vec_or_str!(a, yaml, aliases, alias);
- a = vec_or_str!(a, yaml, visible_aliases, visible_alias);
-
- if let Some(v) = yaml["args"].as_vec() {
- for arg_yaml in v {
- a = a.arg(Arg::from_yaml(arg_yaml.as_hash().unwrap()));
- }
- }
- if let Some(v) = yaml["subcommands"].as_vec() {
- for sc_yaml in v {
- a = a.subcommand(SubCommand::from_yaml(sc_yaml));
- }
- }
- if let Some(v) = yaml["groups"].as_vec() {
- for ag_yaml in v {
- a = a.group(ArgGroup::from(ag_yaml.as_hash().unwrap()));
- }
- }
-
- a
- }
-}
-
-impl<'a, 'b> Clone for App<'a, 'b> {
- fn clone(&self) -> Self { App { p: self.p.clone() } }
-}
-
-impl<'n, 'e> AnyArg<'n, 'e> for App<'n, 'e> {
- fn name(&self) -> &'n str {
- ""
- }
- fn overrides(&self) -> Option<&[&'e str]> { None }
- fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]> { None }
- fn blacklist(&self) -> Option<&[&'e str]> { None }
- fn required_unless(&self) -> Option<&[&'e str]> { None }
- fn val_names(&self) -> Option<&VecMap<&'e str>> { None }
- fn is_set(&self, _: ArgSettings) -> bool { false }
- fn val_terminator(&self) -> Option<&'e str> { None }
- fn set(&mut self, _: ArgSettings) {
- unreachable!("App struct does not support AnyArg::set, this is a bug!")
- }
- fn has_switch(&self) -> bool { false }
- fn max_vals(&self) -> Option<u64> { None }
- fn num_vals(&self) -> Option<u64> { None }
- fn possible_vals(&self) -> Option<&[&'e str]> { None }
- fn validator(&self) -> Option<&Rc<Fn(String) -> StdResult<(), String>>> { None }
- fn validator_os(&self) -> Option<&Rc<Fn(&OsStr) -> StdResult<(), OsString>>> { None }
- fn min_vals(&self) -> Option<u64> { None }
- fn short(&self) -> Option<char> { None }
- fn long(&self) -> Option<&'e str> { None }
- fn val_delim(&self) -> Option<char> { None }
- fn takes_value(&self) -> bool { true }
- fn help(&self) -> Option<&'e str> { self.p.meta.about }
- fn long_help(&self) -> Option<&'e str> { self.p.meta.long_about }
- fn default_val(&self) -> Option<&'e OsStr> { None }
- fn default_vals_ifs(&self) -> Option<map::Values<(&'n str, Option<&'e OsStr>, &'e OsStr)>> {
- None
- }
- fn env<'s>(&'s self) -> Option<(&'n OsStr, Option<&'s OsString>)> { None }
- fn longest_filter(&self) -> bool { true }
- fn aliases(&self) -> Option<Vec<&'e str>> {
- if let Some(ref aliases) = self.p.meta.aliases {
- let vis_aliases: Vec<_> = aliases
- .iter()
- .filter_map(|&(n, v)| if v { Some(n) } else { None })
- .collect();
- if vis_aliases.is_empty() {
- None
- } else {
- Some(vis_aliases)
- }
- } else {
- None
- }
- }
-}
-
-impl<'n, 'e> fmt::Display for App<'n, 'e> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.p.meta.name) }
-}
diff --git a/clap/src/app/parser.rs b/clap/src/app/parser.rs
deleted file mode 100644
index decfde4..0000000
--- a/clap/src/app/parser.rs
+++ /dev/null
@@ -1,2167 +0,0 @@
-// Std
-use std::ffi::{OsStr, OsString};
-use std::fmt::Display;
-use std::fs::File;
-use std::io::{self, BufWriter, Write};
-#[cfg(all(feature = "debug", not(any(target_os = "windows", target_arch = "wasm32"))))]
-use std::os::unix::ffi::OsStrExt;
-#[cfg(all(feature = "debug", any(target_os = "windows", target_arch = "wasm32")))]
-use osstringext::OsStrExt3;
-use std::path::PathBuf;
-use std::slice::Iter;
-use std::iter::Peekable;
-use std::cell::Cell;
-
-// Internal
-use INTERNAL_ERROR_MSG;
-use INVALID_UTF8;
-use SubCommand;
-use app::App;
-use app::help::Help;
-use app::meta::AppMeta;
-use app::settings::AppFlags;
-use args::{AnyArg, Arg, ArgGroup, ArgMatcher, Base, FlagBuilder, OptBuilder, PosBuilder, Switched};
-use args::settings::ArgSettings;
-use completions::ComplGen;
-use errors::{Error, ErrorKind};
-use errors::Result as ClapResult;
-use fmt::ColorWhen;
-use osstringext::OsStrExt2;
-use completions::Shell;
-use suggestions;
-use app::settings::AppSettings as AS;
-use app::validator::Validator;
-use app::usage;
-use map::{self, VecMap};
-
-#[derive(Debug, PartialEq, Copy, Clone)]
-#[doc(hidden)]
-pub enum ParseResult<'a> {
- Flag,
- Opt(&'a str),
- Pos(&'a str),
- MaybeHyphenValue,
- MaybeNegNum,
- NotFound,
- ValuesDone,
-}
-
-#[allow(missing_debug_implementations)]
-#[doc(hidden)]
-#[derive(Clone, Default)]
-pub struct Parser<'a, 'b>
-where
- 'a: 'b,
-{
- pub meta: AppMeta<'b>,
- settings: AppFlags,
- pub g_settings: AppFlags,
- pub flags: Vec<FlagBuilder<'a, 'b>>,
- pub opts: Vec<OptBuilder<'a, 'b>>,
- pub positionals: VecMap<PosBuilder<'a, 'b>>,
- pub subcommands: Vec<App<'a, 'b>>,
- pub groups: Vec<ArgGroup<'a>>,
- pub global_args: Vec<Arg<'a, 'b>>,
- pub required: Vec<&'a str>,
- pub r_ifs: Vec<(&'a str, &'b str, &'a str)>,
- pub overrides: Vec<(&'b str, &'a str)>,
- help_short: Option<char>,
- version_short: Option<char>,
- cache: Option<&'a str>,
- pub help_message: Option<&'a str>,
- pub version_message: Option<&'a str>,
- cur_idx: Cell<usize>,
-}
-
-impl<'a, 'b> Parser<'a, 'b>
-where
- 'a: 'b,
-{
- pub fn with_name(n: String) -> Self {
- Parser {
- meta: AppMeta::with_name(n),
- g_settings: AppFlags::zeroed(),
- cur_idx: Cell::new(0),
- ..Default::default()
- }
- }
-
- pub fn help_short(&mut self, s: &str) {
- let c = s.trim_left_matches(|c| c == '-')
- .chars()
- .nth(0)
- .unwrap_or('h');
- self.help_short = Some(c);
- }
-
- pub fn version_short(&mut self, s: &str) {
- let c = s.trim_left_matches(|c| c == '-')
- .chars()
- .nth(0)
- .unwrap_or('V');
- self.version_short = Some(c);
- }
-
- pub fn gen_completions_to<W: Write>(&mut self, for_shell: Shell, buf: &mut W) {
- if !self.is_set(AS::Propagated) {
- self.propagate_help_version();
- self.build_bin_names();
- self.propagate_globals();
- self.propagate_settings();
- self.set(AS::Propagated);
- }
-
- ComplGen::new(self).generate(for_shell, buf)
- }
-
- pub fn gen_completions(&mut self, for_shell: Shell, od: OsString) {
- use std::error::Error;
-
- let out_dir = PathBuf::from(od);
- let name = &*self.meta.bin_name.as_ref().unwrap().clone();
- let file_name = match for_shell {
- Shell::Bash => format!("{}.bash", name),
- Shell::Fish => format!("{}.fish", name),
- Shell::Zsh => format!("_{}", name),
- Shell::PowerShell => format!("_{}.ps1", name),
- Shell::Elvish => format!("{}.elv", name),
- };
-
- let mut file = match File::create(out_dir.join(file_name)) {
- Err(why) => panic!("couldn't create completion file: {}", why.description()),
- Ok(file) => file,
- };
- self.gen_completions_to(for_shell, &mut file)
- }
-
- #[inline]
- fn app_debug_asserts(&self) -> bool {
- assert!(self.verify_positionals());
- let should_err = self.groups.iter().all(|g| {
- g.args.iter().all(|arg| {
- (self.flags.iter().any(|f| &f.b.name == arg)
- || self.opts.iter().any(|o| &o.b.name == arg)
- || self.positionals.values().any(|p| &p.b.name == arg)
- || self.groups.iter().any(|g| &g.name == arg))
- })
- });
- let g = self.groups.iter().find(|g| {
- g.args.iter().any(|arg| {
- !(self.flags.iter().any(|f| &f.b.name == arg)
- || self.opts.iter().any(|o| &o.b.name == arg)
- || self.positionals.values().any(|p| &p.b.name == arg)
- || self.groups.iter().any(|g| &g.name == arg))
- })
- });
- assert!(
- should_err,
- "The group '{}' contains the arg '{}' that doesn't actually exist.",
- g.unwrap().name,
- g.unwrap()
- .args
- .iter()
- .find(|arg| !(self.flags.iter().any(|f| &&f.b.name == arg)
- || self.opts.iter().any(|o| &&o.b.name == arg)
- || self.positionals.values().any(|p| &&p.b.name == arg)
- || self.groups.iter().any(|g| &&g.name == arg)))
- .unwrap()
- );
- true
- }
-
- #[inline]
- fn debug_asserts(&self, a: &Arg) -> bool {
- assert!(
- !arg_names!(self).any(|name| name == a.b.name),
- format!("Non-unique argument name: {} is already in use", a.b.name)
- );
- if let Some(l) = a.s.long {
- assert!(
- !self.contains_long(l),
- "Argument long must be unique\n\n\t--{} is already in use",
- l
- );
- }
- if let Some(s) = a.s.short {
- assert!(
- !self.contains_short(s),
- "Argument short must be unique\n\n\t-{} is already in use",
- s
- );
- }
- let i = if a.index.is_none() {
- (self.positionals.len() + 1)
- } else {
- a.index.unwrap() as usize
- };
- assert!(
- !self.positionals.contains_key(i),
- "Argument \"{}\" has the same index as another positional \
- argument\n\n\tPerhaps try .multiple(true) to allow one positional argument \
- to take multiple values",
- a.b.name
- );
- assert!(
- !(a.is_set(ArgSettings::Required) && a.is_set(ArgSettings::Global)),
- "Global arguments cannot be required.\n\n\t'{}' is marked as \
- global and required",
- a.b.name
- );
- if a.b.is_set(ArgSettings::Last) {
- assert!(
- !self.positionals
- .values()
- .any(|p| p.b.is_set(ArgSettings::Last)),
- "Only one positional argument may have last(true) set. Found two."
- );
- assert!(a.s.long.is_none(),
- "Flags or Options may not have last(true) set. {} has both a long and last(true) set.",
- a.b.name);
- assert!(a.s.short.is_none(),
- "Flags or Options may not have last(true) set. {} has both a short and last(true) set.",
- a.b.name);
- }
- true
- }
-
- #[inline]
- fn add_conditional_reqs(&mut self, a: &Arg<'a, 'b>) {
- if let Some(ref r_ifs) = a.r_ifs {
- for &(arg, val) in r_ifs {
- self.r_ifs.push((arg, val, a.b.name));
- }
- }
- }
-
- #[inline]
- fn add_arg_groups(&mut self, a: &Arg<'a, 'b>) {
- if let Some(ref grps) = a.b.groups {
- for g in grps {
- let mut found = false;
- if let Some(ref mut ag) = self.groups.iter_mut().find(|grp| &grp.name == g) {
- ag.args.push(a.b.name);
- found = true;
- }
- if !found {
- let mut ag = ArgGroup::with_name(g);
- ag.args.push(a.b.name);
- self.groups.push(ag);
- }
- }
- }
- }
-
- #[inline]
- fn add_reqs(&mut self, a: &Arg<'a, 'b>) {
- if a.is_set(ArgSettings::Required) {
- // If the arg is required, add all it's requirements to master required list
- self.required.push(a.b.name);
- if let Some(ref areqs) = a.b.requires {
- for name in areqs
- .iter()
- .filter(|&&(val, _)| val.is_none())
- .map(|&(_, name)| name)
- {
- self.required.push(name);
- }
- }
- }
- }
-
- #[inline]
- fn implied_settings(&mut self, a: &Arg<'a, 'b>) {
- if a.is_set(ArgSettings::Last) {
- // if an arg has `Last` set, we need to imply DontCollapseArgsInUsage so that args
- // in the usage string don't get confused or left out.
- self.set(AS::DontCollapseArgsInUsage);
- self.set(AS::ContainsLast);
- }
- if let Some(l) = a.s.long {
- if l == "version" {
- self.unset(AS::NeedsLongVersion);
- } else if l == "help" {
- self.unset(AS::NeedsLongHelp);
- }
- }
- }
-
- // actually adds the arguments
- pub fn add_arg(&mut self, a: Arg<'a, 'b>) {
- // if it's global we have to clone anyways
- if a.is_set(ArgSettings::Global) {
- return self.add_arg_ref(&a);
- }
- debug_assert!(self.debug_asserts(&a));
- self.add_conditional_reqs(&a);
- self.add_arg_groups(&a);
- self.add_reqs(&a);
- self.implied_settings(&a);
- if a.index.is_some() || (a.s.short.is_none() && a.s.long.is_none()) {
- let i = if a.index.is_none() {
- (self.positionals.len() + 1)
- } else {
- a.index.unwrap() as usize
- };
- self.positionals
- .insert(i, PosBuilder::from_arg(a, i as u64));
- } else if a.is_set(ArgSettings::TakesValue) {
- let mut ob = OptBuilder::from(a);
- ob.s.unified_ord = self.flags.len() + self.opts.len();
- self.opts.push(ob);
- } else {
- let mut fb = FlagBuilder::from(a);
- fb.s.unified_ord = self.flags.len() + self.opts.len();
- self.flags.push(fb);
- }
- }
- // actually adds the arguments but from a borrow (which means we have to do some cloning)
- pub fn add_arg_ref(&mut self, a: &Arg<'a, 'b>) {
- debug_assert!(self.debug_asserts(a));
- self.add_conditional_reqs(a);
- self.add_arg_groups(a);
- self.add_reqs(a);
- self.implied_settings(a);
- if a.index.is_some() || (a.s.short.is_none() && a.s.long.is_none()) {
- let i = if a.index.is_none() {
- (self.positionals.len() + 1)
- } else {
- a.index.unwrap() as usize
- };
- let pb = PosBuilder::from_arg_ref(a, i as u64);
- self.positionals.insert(i, pb);
- } else if a.is_set(ArgSettings::TakesValue) {
- let mut ob = OptBuilder::from(a);
- ob.s.unified_ord = self.flags.len() + self.opts.len();
- self.opts.push(ob);
- } else {
- let mut fb = FlagBuilder::from(a);
- fb.s.unified_ord = self.flags.len() + self.opts.len();
- self.flags.push(fb);
- }
- if a.is_set(ArgSettings::Global) {
- self.global_args.push(a.into());
- }
- }
-
- pub fn add_group(&mut self, group: ArgGroup<'a>) {
- if group.required {
- self.required.push(group.name);
- if let Some(ref reqs) = group.requires {
- self.required.extend_from_slice(reqs);
- }
- // if let Some(ref bl) = group.conflicts {
- // self.blacklist.extend_from_slice(bl);
- // }
- }
- if self.groups.iter().any(|g| g.name == group.name) {
- let grp = self.groups
- .iter_mut()
- .find(|g| g.name == group.name)
- .expect(INTERNAL_ERROR_MSG);
- grp.args.extend_from_slice(&group.args);
- grp.requires = group.requires.clone();
- grp.conflicts = group.conflicts.clone();
- grp.required = group.required;
- } else {
- self.groups.push(group);
- }
- }
-
- pub fn add_subcommand(&mut self, mut subcmd: App<'a, 'b>) {
- debugln!(
- "Parser::add_subcommand: term_w={:?}, name={}",
- self.meta.term_w,
- subcmd.p.meta.name
- );
- subcmd.p.meta.term_w = self.meta.term_w;
- if subcmd.p.meta.name == "help" {
- self.unset(AS::NeedsSubcommandHelp);
- }
-
- self.subcommands.push(subcmd);
- }
-
- pub fn propagate_settings(&mut self) {
- debugln!(
- "Parser::propagate_settings: self={}, g_settings={:#?}",
- self.meta.name,
- self.g_settings
- );
- for sc in &mut self.subcommands {
- debugln!(
- "Parser::propagate_settings: sc={}, settings={:#?}, g_settings={:#?}",
- sc.p.meta.name,
- sc.p.settings,
- sc.p.g_settings
- );
- // We have to create a new scope in order to tell rustc the borrow of `sc` is
- // done and to recursively call this method
- {
- let vsc = self.settings.is_set(AS::VersionlessSubcommands);
- let gv = self.settings.is_set(AS::GlobalVersion);
-
- if vsc {
- sc.p.set(AS::DisableVersion);
- }
- if gv && sc.p.meta.version.is_none() && self.meta.version.is_some() {
- sc.p.set(AS::GlobalVersion);
- sc.p.meta.version = Some(self.meta.version.unwrap());
- }
- sc.p.settings = sc.p.settings | self.g_settings;
- sc.p.g_settings = sc.p.g_settings | self.g_settings;
- sc.p.meta.term_w = self.meta.term_w;
- sc.p.meta.max_w = self.meta.max_w;
- }
- sc.p.propagate_settings();
- }
- }
-
- #[cfg_attr(feature = "lints", allow(needless_borrow))]
- pub fn derive_display_order(&mut self) {
- if self.is_set(AS::DeriveDisplayOrder) {
- let unified = self.is_set(AS::UnifiedHelpMessage);
- for (i, o) in self.opts
- .iter_mut()
- .enumerate()
- .filter(|&(_, ref o)| o.s.disp_ord == 999)
- {
- o.s.disp_ord = if unified { o.s.unified_ord } else { i };
- }
- for (i, f) in self.flags
- .iter_mut()
- .enumerate()
- .filter(|&(_, ref f)| f.s.disp_ord == 999)
- {
- f.s.disp_ord = if unified { f.s.unified_ord } else { i };
- }
- for (i, sc) in &mut self.subcommands
- .iter_mut()
- .enumerate()
- .filter(|&(_, ref sc)| sc.p.meta.disp_ord == 999)
- {
- sc.p.meta.disp_ord = i;
- }
- }
- for sc in &mut self.subcommands {
- sc.p.derive_display_order();
- }
- }
-
- pub fn required(&self) -> Iter<&str> { self.required.iter() }
-
- #[cfg_attr(feature = "lints", allow(needless_borrow))]
- #[inline]
- pub fn has_args(&self) -> bool {
- !(self.flags.is_empty() && self.opts.is_empty() && self.positionals.is_empty())
- }
-
- #[inline]
- pub fn has_opts(&self) -> bool { !self.opts.is_empty() }
-
- #[inline]
- pub fn has_flags(&self) -> bool { !self.flags.is_empty() }
-
- #[inline]
- pub fn has_positionals(&self) -> bool { !self.positionals.is_empty() }
-
- #[inline]
- pub fn has_subcommands(&self) -> bool { !self.subcommands.is_empty() }
-
- #[inline]
- pub fn has_visible_opts(&self) -> bool {
- if self.opts.is_empty() {
- return false;
- }
- self.opts.iter().any(|o| !o.is_set(ArgSettings::Hidden))
- }
-
- #[inline]
- pub fn has_visible_flags(&self) -> bool {
- if self.flags.is_empty() {
- return false;
- }
- self.flags.iter().any(|f| !f.is_set(ArgSettings::Hidden))
- }
-
- #[inline]
- pub fn has_visible_positionals(&self) -> bool {
- if self.positionals.is_empty() {
- return false;
- }
- self.positionals
- .values()
- .any(|p| !p.is_set(ArgSettings::Hidden))
- }
-
- #[inline]
- pub fn has_visible_subcommands(&self) -> bool {
- self.has_subcommands()
- && self.subcommands
- .iter()
- .filter(|sc| sc.p.meta.name != "help")
- .any(|sc| !sc.p.is_set(AS::Hidden))
- }
-
- #[inline]
- pub fn is_set(&self, s: AS) -> bool { self.settings.is_set(s) }
-
- #[inline]
- pub fn set(&mut self, s: AS) { self.settings.set(s) }
-
- #[inline]
- pub fn unset(&mut self, s: AS) { self.settings.unset(s) }
-
- #[cfg_attr(feature = "lints", allow(block_in_if_condition_stmt))]
- pub fn verify_positionals(&self) -> bool {
- // Because you must wait until all arguments have been supplied, this is the first chance
- // to make assertions on positional argument indexes
- //
- // First we verify that the index highest supplied index, is equal to the number of
- // positional arguments to verify there are no gaps (i.e. supplying an index of 1 and 3
- // but no 2)
- if let Some((idx, p)) = self.positionals.iter().rev().next() {
- assert!(
- !(idx != self.positionals.len()),
- "Found positional argument \"{}\" whose index is {} but there \
- are only {} positional arguments defined",
- p.b.name,
- idx,
- self.positionals.len()
- );
- }
-
- // Next we verify that only the highest index has a .multiple(true) (if any)
- if self.positionals.values().any(|a| {
- a.b.is_set(ArgSettings::Multiple) && (a.index as usize != self.positionals.len())
- }) {
- let mut it = self.positionals.values().rev();
- let last = it.next().unwrap();
- let second_to_last = it.next().unwrap();
- // Either the final positional is required
- // Or the second to last has a terminator or .last(true) set
- let ok = last.is_set(ArgSettings::Required)
- || (second_to_last.v.terminator.is_some()
- || second_to_last.b.is_set(ArgSettings::Last))
- || last.is_set(ArgSettings::Last);
- assert!(
- ok,
- "When using a positional argument with .multiple(true) that is *not the \
- last* positional argument, the last positional argument (i.e the one \
- with the highest index) *must* have .required(true) or .last(true) set."
- );
- let ok = second_to_last.is_set(ArgSettings::Multiple) || last.is_set(ArgSettings::Last);
- assert!(
- ok,
- "Only the last positional argument, or second to last positional \
- argument may be set to .multiple(true)"
- );
-
- let count = self.positionals
- .values()
- .filter(|p| p.b.settings.is_set(ArgSettings::Multiple) && p.v.num_vals.is_none())
- .count();
- let ok = count <= 1
- || (last.is_set(ArgSettings::Last) && last.is_set(ArgSettings::Multiple)
- && second_to_last.is_set(ArgSettings::Multiple)
- && count == 2);
- assert!(
- ok,
- "Only one positional argument with .multiple(true) set is allowed per \
- command, unless the second one also has .last(true) set"
- );
- }
-
- if self.is_set(AS::AllowMissingPositional) {
- // Check that if a required positional argument is found, all positions with a lower
- // index are also required.
- let mut found = false;
- let mut foundx2 = false;
- for p in self.positionals.values().rev() {
- if foundx2 && !p.b.settings.is_set(ArgSettings::Required) {
- assert!(
- p.b.is_set(ArgSettings::Required),
- "Found positional argument which is not required with a lower \
- index than a required positional argument by two or more: {:?} \
- index {}",
- p.b.name,
- p.index
- );
- } else if p.b.is_set(ArgSettings::Required) && !p.b.is_set(ArgSettings::Last) {
- // Args that .last(true) don't count since they can be required and have
- // positionals with a lower index that aren't required
- // Imagine: prog <req1> [opt1] -- <req2>
- // Both of these are valid invocations:
- // $ prog r1 -- r2
- // $ prog r1 o1 -- r2
- if found {
- foundx2 = true;
- continue;
- }
- found = true;
- continue;
- } else {
- found = false;
- }
- }
- } else {
- // Check that if a required positional argument is found, all positions with a lower
- // index are also required
- let mut found = false;
- for p in self.positionals.values().rev() {
- if found {
- assert!(
- p.b.is_set(ArgSettings::Required),
- "Found positional argument which is not required with a lower \
- index than a required positional argument: {:?} index {}",
- p.b.name,
- p.index
- );
- } else if p.b.is_set(ArgSettings::Required) && !p.b.is_set(ArgSettings::Last) {
- // Args that .last(true) don't count since they can be required and have
- // positionals with a lower index that aren't required
- // Imagine: prog <req1> [opt1] -- <req2>
- // Both of these are valid invocations:
- // $ prog r1 -- r2
- // $ prog r1 o1 -- r2
- found = true;
- continue;
- }
- }
- }
- if self.positionals
- .values()
- .any(|p| p.b.is_set(ArgSettings::Last) && p.b.is_set(ArgSettings::Required))
- && self.has_subcommands() && !self.is_set(AS::SubcommandsNegateReqs)
- {
- panic!(
- "Having a required positional argument with .last(true) set *and* child \
- subcommands without setting SubcommandsNegateReqs isn't compatible."
- );
- }
-
- true
- }
-
- pub fn propagate_globals(&mut self) {
- for sc in &mut self.subcommands {
- // We have to create a new scope in order to tell rustc the borrow of `sc` is
- // done and to recursively call this method
- {
- for a in &self.global_args {
- sc.p.add_arg_ref(a);
- }
- }
- sc.p.propagate_globals();
- }
- }
-
- // Checks if the arg matches a subcommand name, or any of it's aliases (if defined)
- fn possible_subcommand(&self, arg_os: &OsStr) -> (bool, Option<&str>) {
- #[cfg(not(any(target_os = "windows", target_arch = "wasm32")))]
- use std::os::unix::ffi::OsStrExt;
- #[cfg(any(target_os = "windows", target_arch = "wasm32"))]
- use osstringext::OsStrExt3;
- debugln!("Parser::possible_subcommand: arg={:?}", arg_os);
- fn starts(h: &str, n: &OsStr) -> bool {
- let n_bytes = n.as_bytes();
- let h_bytes = OsStr::new(h).as_bytes();
-
- h_bytes.starts_with(n_bytes)
- }
-
- if self.is_set(AS::ArgsNegateSubcommands) && self.is_set(AS::ValidArgFound) {
- return (false, None);
- }
- if !self.is_set(AS::InferSubcommands) {
- if let Some(sc) = find_subcmd!(self, arg_os) {
- return (true, Some(&sc.p.meta.name));
- }
- } else {
- let v = self.subcommands
- .iter()
- .filter(|s| {
- starts(&s.p.meta.name[..], &*arg_os)
- || (s.p.meta.aliases.is_some()
- && s.p
- .meta
- .aliases
- .as_ref()
- .unwrap()
- .iter()
- .filter(|&&(a, _)| starts(a, &*arg_os))
- .count() == 1)
- })
- .map(|sc| &sc.p.meta.name)
- .collect::<Vec<_>>();
-
- for sc in &v {
- if OsStr::new(sc) == arg_os {
- return (true, Some(sc));
- }
- }
-
- if v.len() == 1 {
- return (true, Some(v[0]));
- }
- }
- (false, None)
- }
-
- fn parse_help_subcommand<I, T>(&self, it: &mut I) -> ClapResult<ParseResult<'a>>
- where
- I: Iterator<Item = T>,
- T: Into<OsString>,
- {
- debugln!("Parser::parse_help_subcommand;");
- let cmds: Vec<OsString> = it.map(|c| c.into()).collect();
- let mut help_help = false;
- let mut bin_name = self.meta
- .bin_name
- .as_ref()
- .unwrap_or(&self.meta.name)
- .clone();
- let mut sc = {
- let mut sc: &Parser = self;
- for (i, cmd) in cmds.iter().enumerate() {
- if &*cmd.to_string_lossy() == "help" {
- // cmd help help
- help_help = true;
- }
- if let Some(c) = sc.subcommands
- .iter()
- .find(|s| &*s.p.meta.name == cmd)
- .map(|sc| &sc.p)
- {
- sc = c;
- if i == cmds.len() - 1 {
- break;
- }
- } else if let Some(c) = sc.subcommands
- .iter()
- .find(|s| {
- if let Some(ref als) = s.p.meta.aliases {
- als.iter().any(|&(a, _)| a == &*cmd.to_string_lossy())
- } else {
- false
- }
- })
- .map(|sc| &sc.p)
- {
- sc = c;
- if i == cmds.len() - 1 {
- break;
- }
- } else {
- return Err(Error::unrecognized_subcommand(
- cmd.to_string_lossy().into_owned(),
- self.meta.bin_name.as_ref().unwrap_or(&self.meta.name),
- self.color(),
- ));
- }
- bin_name = format!("{} {}", bin_name, &*sc.meta.name);
- }
- sc.clone()
- };
- if help_help {
- let mut pb = PosBuilder::new("subcommand", 1);
- pb.b.help = Some("The subcommand whose help message to display");
- pb.set(ArgSettings::Multiple);
- sc.positionals.insert(1, pb);
- sc.settings = sc.settings | self.g_settings;
- } else {
- sc.create_help_and_version();
- }
- if sc.meta.bin_name != self.meta.bin_name {
- sc.meta.bin_name = Some(format!("{} {}", bin_name, sc.meta.name));
- }
- Err(sc._help(false))
- }
-
- // allow wrong self convention due to self.valid_neg_num = true and it's a private method
- #[cfg_attr(feature = "lints", allow(wrong_self_convention))]
- fn is_new_arg(&mut self, arg_os: &OsStr, needs_val_of: ParseResult) -> bool {
- debugln!("Parser::is_new_arg:{:?}:{:?}", arg_os, needs_val_of);
- let app_wide_settings = if self.is_set(AS::AllowLeadingHyphen) {
- true
- } else if self.is_set(AS::AllowNegativeNumbers) {
- let a = arg_os.to_string_lossy();
- if a.parse::<i64>().is_ok() || a.parse::<f64>().is_ok() {
- self.set(AS::ValidNegNumFound);
- true
- } else {
- false
- }
- } else {
- false
- };
- let arg_allows_tac = match needs_val_of {
- ParseResult::Opt(name) => {
- let o = self.opts
- .iter()
- .find(|o| o.b.name == name)
- .expect(INTERNAL_ERROR_MSG);
- (o.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings)
- }
- ParseResult::Pos(name) => {
- let p = self.positionals
- .values()
- .find(|p| p.b.name == name)
- .expect(INTERNAL_ERROR_MSG);
- (p.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings)
- }
- ParseResult::ValuesDone => return true,
- _ => false,
- };
- debugln!("Parser::is_new_arg: arg_allows_tac={:?}", arg_allows_tac);
-
- // Is this a new argument, or values from a previous option?
- let mut ret = if arg_os.starts_with(b"--") {
- debugln!("Parser::is_new_arg: -- found");
- if arg_os.len() == 2 && !arg_allows_tac {
- return true; // We have to return true so override everything else
- } else if arg_allows_tac {
- return false;
- }
- true
- } else if arg_os.starts_with(b"-") {
- debugln!("Parser::is_new_arg: - found");
- // a singe '-' by itself is a value and typically means "stdin" on unix systems
- !(arg_os.len() == 1)
- } else {
- debugln!("Parser::is_new_arg: probably value");
- false
- };
-
- ret = ret && !arg_allows_tac;
-
- debugln!("Parser::is_new_arg: starts_new_arg={:?}", ret);
- ret
- }
-
- // The actual parsing function
- #[cfg_attr(feature = "lints", allow(while_let_on_iterator, collapsible_if))]
- pub fn get_matches_with<I, T>(
- &mut self,
- matcher: &mut ArgMatcher<'a>,
- it: &mut Peekable<I>,
- ) -> ClapResult<()>
- where
- I: Iterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- debugln!("Parser::get_matches_with;");
- // Verify all positional assertions pass
- debug_assert!(self.app_debug_asserts());
- if self.positionals.values().any(|a| {
- a.b.is_set(ArgSettings::Multiple) && (a.index as usize != self.positionals.len())
- })
- && self.positionals
- .values()
- .last()
- .map_or(false, |p| !p.is_set(ArgSettings::Last))
- {
- self.settings.set(AS::LowIndexMultiplePositional);
- }
- let has_args = self.has_args();
-
- // Next we create the `--help` and `--version` arguments and add them if
- // necessary
- self.create_help_and_version();
-
- let mut subcmd_name: Option<String> = None;
- let mut needs_val_of: ParseResult<'a> = ParseResult::NotFound;
- let mut pos_counter = 1;
- let mut sc_is_external = false;
- while let Some(arg) = it.next() {
- let arg_os = arg.into();
- debugln!(
- "Parser::get_matches_with: Begin parsing '{:?}' ({:?})",
- arg_os,
- &*arg_os.as_bytes()
- );
-
- self.unset(AS::ValidNegNumFound);
- // Is this a new argument, or values from a previous option?
- let starts_new_arg = self.is_new_arg(&arg_os, needs_val_of);
- if !self.is_set(AS::TrailingValues) && arg_os.starts_with(b"--") && arg_os.len() == 2
- && starts_new_arg
- {
- debugln!("Parser::get_matches_with: setting TrailingVals=true");
- self.set(AS::TrailingValues);
- continue;
- }
-
- // Has the user already passed '--'? Meaning only positional args follow
- if !self.is_set(AS::TrailingValues) {
- // Does the arg match a subcommand name, or any of it's aliases (if defined)
- {
- match needs_val_of {
- ParseResult::Opt(_) | ParseResult::Pos(_) => (),
- _ => {
- let (is_match, sc_name) = self.possible_subcommand(&arg_os);
- debugln!(
- "Parser::get_matches_with: possible_sc={:?}, sc={:?}",
- is_match,
- sc_name
- );
- if is_match {
- let sc_name = sc_name.expect(INTERNAL_ERROR_MSG);
- if sc_name == "help" && self.is_set(AS::NeedsSubcommandHelp) {
- self.parse_help_subcommand(it)?;
- }
- subcmd_name = Some(sc_name.to_owned());
- break;
- }
- }
- }
- }
-
- if starts_new_arg {
- let check_all = self.is_set(AS::AllArgsOverrideSelf);
- {
- let any_arg = find_any_by_name!(self, self.cache.unwrap_or(""));
- matcher.process_arg_overrides(
- any_arg,
- &mut self.overrides,
- &mut self.required,
- check_all,
- );
- }
-
- if arg_os.starts_with(b"--") {
- needs_val_of = self.parse_long_arg(matcher, &arg_os, it)?;
- debugln!(
- "Parser:get_matches_with: After parse_long_arg {:?}",
- needs_val_of
- );
- match needs_val_of {
- ParseResult::Flag | ParseResult::Opt(..) | ParseResult::ValuesDone => {
- continue
- }
- _ => (),
- }
- } else if arg_os.starts_with(b"-") && arg_os.len() != 1 {
- // Try to parse short args like normal, if AllowLeadingHyphen or
- // AllowNegativeNumbers is set, parse_short_arg will *not* throw
- // an error, and instead return Ok(None)
- needs_val_of = self.parse_short_arg(matcher, &arg_os)?;
- // If it's None, we then check if one of those two AppSettings was set
- debugln!(
- "Parser:get_matches_with: After parse_short_arg {:?}",
- needs_val_of
- );
- match needs_val_of {
- ParseResult::MaybeNegNum => {
- if !(arg_os.to_string_lossy().parse::<i64>().is_ok()
- || arg_os.to_string_lossy().parse::<f64>().is_ok())
- {
- return Err(Error::unknown_argument(
- &*arg_os.to_string_lossy(),
- "",
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- }
- ParseResult::Opt(..) | ParseResult::Flag | ParseResult::ValuesDone => {
- continue
- }
- _ => (),
- }
- }
- } else {
- if let ParseResult::Opt(name) = needs_val_of {
- // Check to see if parsing a value from a previous arg
- let arg = self.opts
- .iter()
- .find(|o| o.b.name == name)
- .expect(INTERNAL_ERROR_MSG);
- // get the OptBuilder so we can check the settings
- needs_val_of = self.add_val_to_arg(arg, &arg_os, matcher)?;
- // get the next value from the iterator
- continue;
- }
- }
- }
-
- if !(self.is_set(AS::ArgsNegateSubcommands) && self.is_set(AS::ValidArgFound))
- && !self.is_set(AS::InferSubcommands) && !self.is_set(AS::AllowExternalSubcommands)
- {
- if let Some(cdate) =
- suggestions::did_you_mean(&*arg_os.to_string_lossy(), sc_names!(self))
- {
- return Err(Error::invalid_subcommand(
- arg_os.to_string_lossy().into_owned(),
- cdate,
- self.meta.bin_name.as_ref().unwrap_or(&self.meta.name),
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- }
-
- let low_index_mults = self.is_set(AS::LowIndexMultiplePositional)
- && pos_counter == (self.positionals.len() - 1);
- let missing_pos = self.is_set(AS::AllowMissingPositional)
- && (pos_counter == (self.positionals.len() - 1)
- && !self.is_set(AS::TrailingValues));
- debugln!(
- "Parser::get_matches_with: Positional counter...{}",
- pos_counter
- );
- debugln!(
- "Parser::get_matches_with: Low index multiples...{:?}",
- low_index_mults
- );
- if low_index_mults || missing_pos {
- if let Some(na) = it.peek() {
- let n = (*na).clone().into();
- needs_val_of = if needs_val_of != ParseResult::ValuesDone {
- if let Some(p) = self.positionals.get(pos_counter) {
- ParseResult::Pos(p.b.name)
- } else {
- ParseResult::ValuesDone
- }
- } else {
- ParseResult::ValuesDone
- };
- let sc_match = { self.possible_subcommand(&n).0 };
- if self.is_new_arg(&n, needs_val_of) || sc_match
- || suggestions::did_you_mean(&n.to_string_lossy(), sc_names!(self))
- .is_some()
- {
- debugln!("Parser::get_matches_with: Bumping the positional counter...");
- pos_counter += 1;
- }
- } else {
- debugln!("Parser::get_matches_with: Bumping the positional counter...");
- pos_counter += 1;
- }
- } else if (self.is_set(AS::AllowMissingPositional) && self.is_set(AS::TrailingValues))
- || (self.is_set(AS::ContainsLast) && self.is_set(AS::TrailingValues))
- {
- // Came to -- and one postional has .last(true) set, so we go immediately
- // to the last (highest index) positional
- debugln!("Parser::get_matches_with: .last(true) and --, setting last pos");
- pos_counter = self.positionals.len();
- }
- if let Some(p) = self.positionals.get(pos_counter) {
- if p.is_set(ArgSettings::Last) && !self.is_set(AS::TrailingValues) {
- return Err(Error::unknown_argument(
- &*arg_os.to_string_lossy(),
- "",
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- if !self.is_set(AS::TrailingValues)
- && (self.is_set(AS::TrailingVarArg) && pos_counter == self.positionals.len())
- {
- self.settings.set(AS::TrailingValues);
- }
- if self.cache.map_or(true, |name| name != p.b.name) {
- let check_all = self.is_set(AS::AllArgsOverrideSelf);
- {
- let any_arg = find_any_by_name!(self, self.cache.unwrap_or(""));
- matcher.process_arg_overrides(
- any_arg,
- &mut self.overrides,
- &mut self.required,
- check_all,
- );
- }
- self.cache = Some(p.b.name);
- }
- let _ = self.add_val_to_arg(p, &arg_os, matcher)?;
-
- matcher.inc_occurrence_of(p.b.name);
- let _ = self.groups_for_arg(p.b.name)
- .and_then(|vec| Some(matcher.inc_occurrences_of(&*vec)));
-
- self.settings.set(AS::ValidArgFound);
- // Only increment the positional counter if it doesn't allow multiples
- if !p.b.settings.is_set(ArgSettings::Multiple) {
- pos_counter += 1;
- }
- self.settings.set(AS::ValidArgFound);
- } else if self.is_set(AS::AllowExternalSubcommands) {
- // Get external subcommand name
- let sc_name = match arg_os.to_str() {
- Some(s) => s.to_string(),
- None => {
- if !self.is_set(AS::StrictUtf8) {
- return Err(Error::invalid_utf8(
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- arg_os.to_string_lossy().into_owned()
- }
- };
-
- // Collect the external subcommand args
- let mut sc_m = ArgMatcher::new();
- while let Some(v) = it.next() {
- let a = v.into();
- if a.to_str().is_none() && !self.is_set(AS::StrictUtf8) {
- return Err(Error::invalid_utf8(
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- sc_m.add_val_to("", &a);
- }
-
- matcher.subcommand(SubCommand {
- name: sc_name,
- matches: sc_m.into(),
- });
- sc_is_external = true;
- } else if !((self.is_set(AS::AllowLeadingHyphen)
- || self.is_set(AS::AllowNegativeNumbers))
- && arg_os.starts_with(b"-"))
- && !self.is_set(AS::InferSubcommands)
- {
- return Err(Error::unknown_argument(
- &*arg_os.to_string_lossy(),
- "",
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- } else if !has_args || self.is_set(AS::InferSubcommands) && self.has_subcommands() {
- if let Some(cdate) =
- suggestions::did_you_mean(&*arg_os.to_string_lossy(), sc_names!(self))
- {
- return Err(Error::invalid_subcommand(
- arg_os.to_string_lossy().into_owned(),
- cdate,
- self.meta.bin_name.as_ref().unwrap_or(&self.meta.name),
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- } else {
- return Err(Error::unrecognized_subcommand(
- arg_os.to_string_lossy().into_owned(),
- self.meta.bin_name.as_ref().unwrap_or(&self.meta.name),
- self.color(),
- ));
- }
- } else {
- return Err(Error::unknown_argument(
- &*arg_os.to_string_lossy(),
- "",
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- }
-
- if !sc_is_external {
- if let Some(ref pos_sc_name) = subcmd_name {
- let sc_name = {
- find_subcmd!(self, pos_sc_name)
- .expect(INTERNAL_ERROR_MSG)
- .p
- .meta
- .name
- .clone()
- };
- self.parse_subcommand(&*sc_name, matcher, it)?;
- } else if self.is_set(AS::SubcommandRequired) {
- let bn = self.meta.bin_name.as_ref().unwrap_or(&self.meta.name);
- return Err(Error::missing_subcommand(
- bn,
- &usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- } else if self.is_set(AS::SubcommandRequiredElseHelp) {
- debugln!("Parser::get_matches_with: SubcommandRequiredElseHelp=true");
- let mut out = vec![];
- self.write_help_err(&mut out)?;
- return Err(Error {
- message: String::from_utf8_lossy(&*out).into_owned(),
- kind: ErrorKind::MissingArgumentOrSubcommand,
- info: None,
- });
- }
- }
-
- // In case the last arg was new, we need to process it's overrides
- let check_all = self.is_set(AS::AllArgsOverrideSelf);
- {
- let any_arg = find_any_by_name!(self, self.cache.unwrap_or(""));
- matcher.process_arg_overrides(
- any_arg,
- &mut self.overrides,
- &mut self.required,
- check_all,
- );
- }
-
- self.remove_overrides(matcher);
-
- Validator::new(self).validate(needs_val_of, subcmd_name, matcher)
- }
-
- fn remove_overrides(&mut self, matcher: &mut ArgMatcher) {
- debugln!("Parser::remove_overrides:{:?};", self.overrides);
- for &(overr, name) in &self.overrides {
- debugln!("Parser::remove_overrides:iter:({},{});", overr, name);
- if matcher.is_present(overr) {
- debugln!(
- "Parser::remove_overrides:iter:({},{}): removing {};",
- overr,
- name,
- name
- );
- matcher.remove(name);
- for i in (0..self.required.len()).rev() {
- debugln!(
- "Parser::remove_overrides:iter:({},{}): removing required {};",
- overr,
- name,
- name
- );
- if self.required[i] == name {
- self.required.swap_remove(i);
- break;
- }
- }
- }
- }
- }
-
- fn propagate_help_version(&mut self) {
- debugln!("Parser::propagate_help_version;");
- self.create_help_and_version();
- for sc in &mut self.subcommands {
- sc.p.propagate_help_version();
- }
- }
-
- fn build_bin_names(&mut self) {
- debugln!("Parser::build_bin_names;");
- for sc in &mut self.subcommands {
- debug!("Parser::build_bin_names:iter: bin_name set...");
- if sc.p.meta.bin_name.is_none() {
- sdebugln!("No");
- let bin_name = format!(
- "{}{}{}",
- self.meta
- .bin_name
- .as_ref()
- .unwrap_or(&self.meta.name.clone()),
- if self.meta.bin_name.is_some() {
- " "
- } else {
- ""
- },
- &*sc.p.meta.name
- );
- debugln!(
- "Parser::build_bin_names:iter: Setting bin_name of {} to {}",
- self.meta.name,
- bin_name
- );
- sc.p.meta.bin_name = Some(bin_name);
- } else {
- sdebugln!("yes ({:?})", sc.p.meta.bin_name);
- }
- debugln!(
- "Parser::build_bin_names:iter: Calling build_bin_names from...{}",
- sc.p.meta.name
- );
- sc.p.build_bin_names();
- }
- }
-
- fn parse_subcommand<I, T>(
- &mut self,
- sc_name: &str,
- matcher: &mut ArgMatcher<'a>,
- it: &mut Peekable<I>,
- ) -> ClapResult<()>
- where
- I: Iterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- use std::fmt::Write;
- debugln!("Parser::parse_subcommand;");
- let mut mid_string = String::new();
- if !self.is_set(AS::SubcommandsNegateReqs) {
- let mut hs: Vec<&str> = self.required.iter().map(|n| &**n).collect();
- for k in matcher.arg_names() {
- hs.push(k);
- }
- let reqs = usage::get_required_usage_from(self, &hs, Some(matcher), None, false);
-
- for s in &reqs {
- write!(&mut mid_string, " {}", s).expect(INTERNAL_ERROR_MSG);
- }
- }
- mid_string.push_str(" ");
- if let Some(ref mut sc) = self.subcommands
- .iter_mut()
- .find(|s| s.p.meta.name == sc_name)
- {
- let mut sc_matcher = ArgMatcher::new();
- // bin_name should be parent's bin_name + [<reqs>] + the sc's name separated by
- // a space
- sc.p.meta.usage = Some(format!(
- "{}{}{}",
- self.meta.bin_name.as_ref().unwrap_or(&String::new()),
- if self.meta.bin_name.is_some() {
- &*mid_string
- } else {
- ""
- },
- &*sc.p.meta.name
- ));
- sc.p.meta.bin_name = Some(format!(
- "{}{}{}",
- self.meta.bin_name.as_ref().unwrap_or(&String::new()),
- if self.meta.bin_name.is_some() {
- " "
- } else {
- ""
- },
- &*sc.p.meta.name
- ));
- debugln!(
- "Parser::parse_subcommand: About to parse sc={}",
- sc.p.meta.name
- );
- debugln!("Parser::parse_subcommand: sc settings={:#?}", sc.p.settings);
- sc.p.get_matches_with(&mut sc_matcher, it)?;
- matcher.subcommand(SubCommand {
- name: sc.p.meta.name.clone(),
- matches: sc_matcher.into(),
- });
- }
- Ok(())
- }
-
- pub fn groups_for_arg(&self, name: &str) -> Option<Vec<&'a str>> {
- debugln!("Parser::groups_for_arg: name={}", name);
-
- if self.groups.is_empty() {
- debugln!("Parser::groups_for_arg: No groups defined");
- return None;
- }
- let mut res = vec![];
- debugln!("Parser::groups_for_arg: Searching through groups...");
- for grp in &self.groups {
- for a in &grp.args {
- if a == &name {
- sdebugln!("\tFound '{}'", grp.name);
- res.push(&*grp.name);
- }
- }
- }
- if res.is_empty() {
- return None;
- }
-
- Some(res)
- }
-
- pub fn args_in_group(&self, group: &str) -> Vec<String> {
- debug_assert!(self.app_debug_asserts());
-
- let mut g_vec = vec![];
- let mut args = vec![];
-
- for n in &self.groups
- .iter()
- .find(|g| g.name == group)
- .expect(INTERNAL_ERROR_MSG)
- .args
- {
- if let Some(f) = self.flags.iter().find(|f| &f.b.name == n) {
- args.push(f.to_string());
- } else if let Some(f) = self.opts.iter().find(|o| &o.b.name == n) {
- args.push(f.to_string());
- } else if let Some(p) = self.positionals.values().find(|p| &p.b.name == n) {
- args.push(p.b.name.to_owned());
- } else {
- g_vec.push(*n);
- }
- }
-
- for av in g_vec.iter().map(|g| self.args_in_group(g)) {
- args.extend(av);
- }
- args.dedup();
- args.iter().map(ToOwned::to_owned).collect()
- }
-
- pub fn arg_names_in_group(&self, group: &str) -> Vec<&'a str> {
- let mut g_vec = vec![];
- let mut args = vec![];
-
- for n in &self.groups
- .iter()
- .find(|g| g.name == group)
- .expect(INTERNAL_ERROR_MSG)
- .args
- {
- if self.groups.iter().any(|g| g.name == *n) {
- args.extend(self.arg_names_in_group(n));
- g_vec.push(*n);
- } else if !args.contains(n) {
- args.push(*n);
- }
- }
-
- args.iter().map(|s| *s).collect()
- }
-
- pub fn create_help_and_version(&mut self) {
- debugln!("Parser::create_help_and_version;");
- // name is "hclap_help" because flags are sorted by name
- if !self.is_set(AS::DisableHelpFlags) && !self.contains_long("help") {
- debugln!("Parser::create_help_and_version: Building --help");
- if self.help_short.is_none() && !self.contains_short('h') {
- self.help_short = Some('h');
- }
- let arg = FlagBuilder {
- b: Base {
- name: "hclap_help",
- help: self.help_message.or(Some("Prints help information")),
- ..Default::default()
- },
- s: Switched {
- short: self.help_short,
- long: Some("help"),
- ..Default::default()
- },
- };
- self.flags.push(arg);
- }
- if !self.is_set(AS::DisableVersion) && !self.contains_long("version") {
- debugln!("Parser::create_help_and_version: Building --version");
- if self.version_short.is_none() && !self.contains_short('V') {
- self.version_short = Some('V');
- }
- // name is "vclap_version" because flags are sorted by name
- let arg = FlagBuilder {
- b: Base {
- name: "vclap_version",
- help: self.version_message.or(Some("Prints version information")),
- ..Default::default()
- },
- s: Switched {
- short: self.version_short,
- long: Some("version"),
- ..Default::default()
- },
- };
- self.flags.push(arg);
- }
- if !self.subcommands.is_empty() && !self.is_set(AS::DisableHelpSubcommand)
- && self.is_set(AS::NeedsSubcommandHelp)
- {
- debugln!("Parser::create_help_and_version: Building help");
- self.subcommands.push(
- App::new("help")
- .about("Prints this message or the help of the given subcommand(s)"),
- );
- }
- }
-
- // Retrieves the names of all args the user has supplied thus far, except required ones
- // because those will be listed in self.required
- fn check_for_help_and_version_str(&self, arg: &OsStr) -> ClapResult<()> {
- debugln!("Parser::check_for_help_and_version_str;");
- debug!(
- "Parser::check_for_help_and_version_str: Checking if --{} is help or version...",
- arg.to_str().unwrap()
- );
- if arg == "help" && self.is_set(AS::NeedsLongHelp) {
- sdebugln!("Help");
- return Err(self._help(true));
- }
- if arg == "version" && self.is_set(AS::NeedsLongVersion) {
- sdebugln!("Version");
- return Err(self._version(true));
- }
- sdebugln!("Neither");
-
- Ok(())
- }
-
- fn check_for_help_and_version_char(&self, arg: char) -> ClapResult<()> {
- debugln!("Parser::check_for_help_and_version_char;");
- debug!(
- "Parser::check_for_help_and_version_char: Checking if -{} is help or version...",
- arg
- );
- if let Some(h) = self.help_short {
- if arg == h && self.is_set(AS::NeedsLongHelp) {
- sdebugln!("Help");
- return Err(self._help(false));
- }
- }
- if let Some(v) = self.version_short {
- if arg == v && self.is_set(AS::NeedsLongVersion) {
- sdebugln!("Version");
- return Err(self._version(false));
- }
- }
- sdebugln!("Neither");
- Ok(())
- }
-
- fn use_long_help(&self) -> bool {
- // In this case, both must be checked. This allows the retention of
- // original formatting, but also ensures that the actual -h or --help
- // specified by the user is sent through. If HiddenShortHelp is not included,
- // then items specified with hidden_short_help will also be hidden.
- let should_long = |v: &Base| {
- v.long_help.is_some() ||
- v.is_set(ArgSettings::HiddenLongHelp) ||
- v.is_set(ArgSettings::HiddenShortHelp)
- };
-
- self.meta.long_about.is_some()
- || self.flags.iter().any(|f| should_long(&f.b))
- || self.opts.iter().any(|o| should_long(&o.b))
- || self.positionals.values().any(|p| should_long(&p.b))
- || self.subcommands
- .iter()
- .any(|s| s.p.meta.long_about.is_some())
- }
-
- fn _help(&self, mut use_long: bool) -> Error {
- debugln!("Parser::_help: use_long={:?}", use_long);
- use_long = use_long && self.use_long_help();
- let mut buf = vec![];
- match Help::write_parser_help(&mut buf, self, use_long) {
- Err(e) => e,
- _ => Error {
- message: String::from_utf8(buf).unwrap_or_default(),
- kind: ErrorKind::HelpDisplayed,
- info: None,
- },
- }
- }
-
- fn _version(&self, use_long: bool) -> Error {
- debugln!("Parser::_version: ");
- let out = io::stdout();
- let mut buf_w = BufWriter::new(out.lock());
- match self.print_version(&mut buf_w, use_long) {
- Err(e) => e,
- _ => Error {
- message: String::new(),
- kind: ErrorKind::VersionDisplayed,
- info: None,
- },
- }
- }
-
- fn parse_long_arg<I, T>(
- &mut self,
- matcher: &mut ArgMatcher<'a>,
- full_arg: &OsStr,
- it: &mut Peekable<I>,
- ) -> ClapResult<ParseResult<'a>>
- where
- I: Iterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- // maybe here lifetime should be 'a
- debugln!("Parser::parse_long_arg;");
-
- // Update the current index
- self.cur_idx.set(self.cur_idx.get() + 1);
-
- let mut val = None;
- debug!("Parser::parse_long_arg: Does it contain '='...");
- let arg = if full_arg.contains_byte(b'=') {
- let (p0, p1) = full_arg.trim_left_matches(b'-').split_at_byte(b'=');
- sdebugln!("Yes '{:?}'", p1);
- val = Some(p1);
- p0
- } else {
- sdebugln!("No");
- full_arg.trim_left_matches(b'-')
- };
-
- if let Some(opt) = find_opt_by_long!(@os self, arg) {
- debugln!(
- "Parser::parse_long_arg: Found valid opt '{}'",
- opt.to_string()
- );
- self.settings.set(AS::ValidArgFound);
- let ret = self.parse_opt(val, opt, val.is_some(), matcher)?;
- if self.cache.map_or(true, |name| name != opt.b.name) {
- self.cache = Some(opt.b.name);
- }
-
- return Ok(ret);
- } else if let Some(flag) = find_flag_by_long!(@os self, arg) {
- debugln!(
- "Parser::parse_long_arg: Found valid flag '{}'",
- flag.to_string()
- );
- self.settings.set(AS::ValidArgFound);
- // Only flags could be help or version, and we need to check the raw long
- // so this is the first point to check
- self.check_for_help_and_version_str(arg)?;
-
- self.parse_flag(flag, matcher)?;
-
- // Handle conflicts, requirements, etc.
- if self.cache.map_or(true, |name| name != flag.b.name) {
- self.cache = Some(flag.b.name);
- }
-
- return Ok(ParseResult::Flag);
- } else if self.is_set(AS::AllowLeadingHyphen) {
- return Ok(ParseResult::MaybeHyphenValue);
- } else if self.is_set(AS::ValidNegNumFound) {
- return Ok(ParseResult::MaybeNegNum);
- }
-
- debugln!("Parser::parse_long_arg: Didn't match anything");
-
- let args_rest: Vec<_> = it.map(|x| x.clone().into()).collect();
- let args_rest2: Vec<_> = args_rest.iter().map(|x| x.to_str().expect(INVALID_UTF8)).collect();
- self.did_you_mean_error(
- arg.to_str().expect(INVALID_UTF8),
- matcher,
- &args_rest2[..]
- ).map(|_| ParseResult::NotFound)
- }
-
- #[cfg_attr(feature = "lints", allow(len_zero))]
- fn parse_short_arg(
- &mut self,
- matcher: &mut ArgMatcher<'a>,
- full_arg: &OsStr,
- ) -> ClapResult<ParseResult<'a>> {
- debugln!("Parser::parse_short_arg: full_arg={:?}", full_arg);
- let arg_os = full_arg.trim_left_matches(b'-');
- let arg = arg_os.to_string_lossy();
-
- // If AllowLeadingHyphen is set, we want to ensure `-val` gets parsed as `-val` and not
- // `-v` `-a` `-l` assuming `v` `a` and `l` are all, or mostly, valid shorts.
- if self.is_set(AS::AllowLeadingHyphen) {
- if arg.chars().any(|c| !self.contains_short(c)) {
- debugln!(
- "Parser::parse_short_arg: LeadingHyphenAllowed yet -{} isn't valid",
- arg
- );
- return Ok(ParseResult::MaybeHyphenValue);
- }
- } else if self.is_set(AS::ValidNegNumFound) {
- // TODO: Add docs about having AllowNegativeNumbers and `-2` as a valid short
- // May be better to move this to *after* not finding a valid flag/opt?
- debugln!("Parser::parse_short_arg: Valid negative num...");
- return Ok(ParseResult::MaybeNegNum);
- }
-
- let mut ret = ParseResult::NotFound;
- for c in arg.chars() {
- debugln!("Parser::parse_short_arg:iter:{}", c);
-
- // update each index because `-abcd` is four indices to clap
- self.cur_idx.set(self.cur_idx.get() + 1);
-
- // Check for matching short options, and return the name if there is no trailing
- // concatenated value: -oval
- // Option: -o
- // Value: val
- if let Some(opt) = find_opt_by_short!(self, c) {
- debugln!("Parser::parse_short_arg:iter:{}: Found valid opt", c);
- self.settings.set(AS::ValidArgFound);
- // Check for trailing concatenated value
- let p: Vec<_> = arg.splitn(2, c).collect();
- debugln!(
- "Parser::parse_short_arg:iter:{}: p[0]={:?}, p[1]={:?}",
- c,
- p[0].as_bytes(),
- p[1].as_bytes()
- );
- let i = p[0].as_bytes().len() + 1;
- let val = if p[1].as_bytes().len() > 0 {
- debugln!(
- "Parser::parse_short_arg:iter:{}: val={:?} (bytes), val={:?} (ascii)",
- c,
- arg_os.split_at(i).1.as_bytes(),
- arg_os.split_at(i).1
- );
- Some(arg_os.split_at(i).1)
- } else {
- None
- };
-
- // Default to "we're expecting a value later"
- let ret = self.parse_opt(val, opt, false, matcher)?;
-
- if self.cache.map_or(true, |name| name != opt.b.name) {
- self.cache = Some(opt.b.name);
- }
-
- return Ok(ret);
- } else if let Some(flag) = find_flag_by_short!(self, c) {
- debugln!("Parser::parse_short_arg:iter:{}: Found valid flag", c);
- self.settings.set(AS::ValidArgFound);
- // Only flags can be help or version
- self.check_for_help_and_version_char(c)?;
- ret = self.parse_flag(flag, matcher)?;
-
- // Handle conflicts, requirements, overrides, etc.
- // Must be called here due to mutabililty
- if self.cache.map_or(true, |name| name != flag.b.name) {
- self.cache = Some(flag.b.name);
- }
- } else {
- let arg = format!("-{}", c);
- return Err(Error::unknown_argument(
- &*arg,
- "",
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- }
- Ok(ret)
- }
-
- fn parse_opt(
- &self,
- val: Option<&OsStr>,
- opt: &OptBuilder<'a, 'b>,
- had_eq: bool,
- matcher: &mut ArgMatcher<'a>,
- ) -> ClapResult<ParseResult<'a>> {
- debugln!("Parser::parse_opt; opt={}, val={:?}", opt.b.name, val);
- debugln!("Parser::parse_opt; opt.settings={:?}", opt.b.settings);
- let mut has_eq = false;
- let no_val = val.is_none();
- let empty_vals = opt.is_set(ArgSettings::EmptyValues);
- let min_vals_zero = opt.v.min_vals.unwrap_or(1) == 0;
- let needs_eq = opt.is_set(ArgSettings::RequireEquals);
-
- debug!("Parser::parse_opt; Checking for val...");
- if let Some(fv) = val {
- has_eq = fv.starts_with(&[b'=']) || had_eq;
- let v = fv.trim_left_matches(b'=');
- if !empty_vals && (v.len() == 0 || (needs_eq && !has_eq)) {
- sdebugln!("Found Empty - Error");
- return Err(Error::empty_value(
- opt,
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- }
- sdebugln!("Found - {:?}, len: {}", v, v.len());
- debugln!(
- "Parser::parse_opt: {:?} contains '='...{:?}",
- fv,
- fv.starts_with(&[b'='])
- );
- self.add_val_to_arg(opt, v, matcher)?;
- } else if needs_eq && !(empty_vals || min_vals_zero) {
- sdebugln!("None, but requires equals...Error");
- return Err(Error::empty_value(
- opt,
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ));
- } else {
- sdebugln!("None");
- }
-
- matcher.inc_occurrence_of(opt.b.name);
- // Increment or create the group "args"
- self.groups_for_arg(opt.b.name)
- .and_then(|vec| Some(matcher.inc_occurrences_of(&*vec)));
-
- let needs_delim = opt.is_set(ArgSettings::RequireDelimiter);
- let mult = opt.is_set(ArgSettings::Multiple);
- if no_val && min_vals_zero && !has_eq && needs_eq {
- debugln!("Parser::parse_opt: More arg vals not required...");
- return Ok(ParseResult::ValuesDone);
- } else if no_val || (mult && !needs_delim) && !has_eq && matcher.needs_more_vals(opt) {
- debugln!("Parser::parse_opt: More arg vals required...");
- return Ok(ParseResult::Opt(opt.b.name));
- }
- debugln!("Parser::parse_opt: More arg vals not required...");
- Ok(ParseResult::ValuesDone)
- }
-
- fn add_val_to_arg<A>(
- &self,
- arg: &A,
- val: &OsStr,
- matcher: &mut ArgMatcher<'a>,
- ) -> ClapResult<ParseResult<'a>>
- where
- A: AnyArg<'a, 'b> + Display,
- {
- debugln!("Parser::add_val_to_arg; arg={}, val={:?}", arg.name(), val);
- debugln!(
- "Parser::add_val_to_arg; trailing_vals={:?}, DontDelimTrailingVals={:?}",
- self.is_set(AS::TrailingValues),
- self.is_set(AS::DontDelimitTrailingValues)
- );
- if !(self.is_set(AS::TrailingValues) && self.is_set(AS::DontDelimitTrailingValues)) {
- if let Some(delim) = arg.val_delim() {
- if val.is_empty() {
- Ok(self.add_single_val_to_arg(arg, val, matcher)?)
- } else {
- let mut iret = ParseResult::ValuesDone;
- for v in val.split(delim as u32 as u8) {
- iret = self.add_single_val_to_arg(arg, v, matcher)?;
- }
- // If there was a delimiter used, we're not looking for more values
- if val.contains_byte(delim as u32 as u8)
- || arg.is_set(ArgSettings::RequireDelimiter)
- {
- iret = ParseResult::ValuesDone;
- }
- Ok(iret)
- }
- } else {
- self.add_single_val_to_arg(arg, val, matcher)
- }
- } else {
- self.add_single_val_to_arg(arg, val, matcher)
- }
- }
-
- fn add_single_val_to_arg<A>(
- &self,
- arg: &A,
- v: &OsStr,
- matcher: &mut ArgMatcher<'a>,
- ) -> ClapResult<ParseResult<'a>>
- where
- A: AnyArg<'a, 'b> + Display,
- {
- debugln!("Parser::add_single_val_to_arg;");
- debugln!("Parser::add_single_val_to_arg: adding val...{:?}", v);
-
- // update the current index because each value is a distinct index to clap
- self.cur_idx.set(self.cur_idx.get() + 1);
-
- // @TODO @docs @p4: docs for indices should probably note that a terminator isn't a value
- // and therefore not reported in indices
- if let Some(t) = arg.val_terminator() {
- if t == v {
- return Ok(ParseResult::ValuesDone);
- }
- }
-
- matcher.add_val_to(arg.name(), v);
- matcher.add_index_to(arg.name(), self.cur_idx.get());
-
- // Increment or create the group "args"
- if let Some(grps) = self.groups_for_arg(arg.name()) {
- for grp in grps {
- matcher.add_val_to(&*grp, v);
- }
- }
-
- if matcher.needs_more_vals(arg) {
- return Ok(ParseResult::Opt(arg.name()));
- }
- Ok(ParseResult::ValuesDone)
- }
-
- fn parse_flag(
- &self,
- flag: &FlagBuilder<'a, 'b>,
- matcher: &mut ArgMatcher<'a>,
- ) -> ClapResult<ParseResult<'a>> {
- debugln!("Parser::parse_flag;");
-
- matcher.inc_occurrence_of(flag.b.name);
- matcher.add_index_to(flag.b.name, self.cur_idx.get());
-
- // Increment or create the group "args"
- self.groups_for_arg(flag.b.name)
- .and_then(|vec| Some(matcher.inc_occurrences_of(&*vec)));
-
- Ok(ParseResult::Flag)
- }
-
- fn did_you_mean_error(&self, arg: &str, matcher: &mut ArgMatcher<'a>, args_rest: &[&str]) -> ClapResult<()> {
- // Didn't match a flag or option
- let suffix = suggestions::did_you_mean_flag_suffix(arg, &args_rest, longs!(self), &self.subcommands);
-
- // Add the arg to the matches to build a proper usage string
- if let Some(name) = suffix.1 {
- if let Some(opt) = find_opt_by_long!(self, name) {
- self.groups_for_arg(&*opt.b.name)
- .and_then(|grps| Some(matcher.inc_occurrences_of(&*grps)));
- matcher.insert(&*opt.b.name);
- } else if let Some(flg) = find_flag_by_long!(self, name) {
- self.groups_for_arg(&*flg.b.name)
- .and_then(|grps| Some(matcher.inc_occurrences_of(&*grps)));
- matcher.insert(&*flg.b.name);
- }
- }
-
- let used_arg = format!("--{}", arg);
- Err(Error::unknown_argument(
- &*used_arg,
- &*suffix.0,
- &*usage::create_error_usage(self, matcher, None),
- self.color(),
- ))
- }
-
- // Prints the version to the user and exits if quit=true
- fn print_version<W: Write>(&self, w: &mut W, use_long: bool) -> ClapResult<()> {
- self.write_version(w, use_long)?;
- w.flush().map_err(Error::from)
- }
-
- pub fn write_version<W: Write>(&self, w: &mut W, use_long: bool) -> io::Result<()> {
- let ver = if use_long {
- self.meta
- .long_version
- .unwrap_or_else(|| self.meta.version.unwrap_or(""))
- } else {
- self.meta
- .version
- .unwrap_or_else(|| self.meta.long_version.unwrap_or(""))
- };
- if let Some(bn) = self.meta.bin_name.as_ref() {
- if bn.contains(' ') {
- // Incase we're dealing with subcommands i.e. git mv is translated to git-mv
- write!(w, "{} {}", bn.replace(" ", "-"), ver)
- } else {
- write!(w, "{} {}", &self.meta.name[..], ver)
- }
- } else {
- write!(w, "{} {}", &self.meta.name[..], ver)
- }
- }
-
- pub fn print_help(&self) -> ClapResult<()> {
- let out = io::stdout();
- let mut buf_w = BufWriter::new(out.lock());
- self.write_help(&mut buf_w)
- }
-
- pub fn write_help<W: Write>(&self, w: &mut W) -> ClapResult<()> {
- Help::write_parser_help(w, self, false)
- }
-
- pub fn write_long_help<W: Write>(&self, w: &mut W) -> ClapResult<()> {
- Help::write_parser_help(w, self, true)
- }
-
- pub fn write_help_err<W: Write>(&self, w: &mut W) -> ClapResult<()> {
- Help::write_parser_help_to_stderr(w, self)
- }
-
- pub fn add_defaults(&mut self, matcher: &mut ArgMatcher<'a>) -> ClapResult<()> {
- debugln!("Parser::add_defaults;");
- macro_rules! add_val {
- (@default $_self:ident, $a:ident, $m:ident) => {
- if let Some(ref val) = $a.v.default_val {
- debugln!("Parser::add_defaults:iter:{}: has default vals", $a.b.name);
- if $m.get($a.b.name).map(|ma| ma.vals.len()).map(|len| len == 0).unwrap_or(false) {
- debugln!("Parser::add_defaults:iter:{}: has no user defined vals", $a.b.name);
- $_self.add_val_to_arg($a, OsStr::new(val), $m)?;
-
- if $_self.cache.map_or(true, |name| name != $a.name()) {
- $_self.cache = Some($a.name());
- }
- } else if $m.get($a.b.name).is_some() {
- debugln!("Parser::add_defaults:iter:{}: has user defined vals", $a.b.name);
- } else {
- debugln!("Parser::add_defaults:iter:{}: wasn't used", $a.b.name);
-
- $_self.add_val_to_arg($a, OsStr::new(val), $m)?;
-
- if $_self.cache.map_or(true, |name| name != $a.name()) {
- $_self.cache = Some($a.name());
- }
- }
- } else {
- debugln!("Parser::add_defaults:iter:{}: doesn't have default vals", $a.b.name);
- }
- };
- ($_self:ident, $a:ident, $m:ident) => {
- if let Some(ref vm) = $a.v.default_vals_ifs {
- sdebugln!(" has conditional defaults");
- let mut done = false;
- if $m.get($a.b.name).is_none() {
- for &(arg, val, default) in vm.values() {
- let add = if let Some(a) = $m.get(arg) {
- if let Some(v) = val {
- a.vals.iter().any(|value| v == value)
- } else {
- true
- }
- } else {
- false
- };
- if add {
- $_self.add_val_to_arg($a, OsStr::new(default), $m)?;
- if $_self.cache.map_or(true, |name| name != $a.name()) {
- $_self.cache = Some($a.name());
- }
- done = true;
- break;
- }
- }
- }
-
- if done {
- continue; // outer loop (outside macro)
- }
- } else {
- sdebugln!(" doesn't have conditional defaults");
- }
- add_val!(@default $_self, $a, $m)
- };
- }
-
- for o in &self.opts {
- debug!("Parser::add_defaults:iter:{}:", o.b.name);
- add_val!(self, o, matcher);
- }
- for p in self.positionals.values() {
- debug!("Parser::add_defaults:iter:{}:", p.b.name);
- add_val!(self, p, matcher);
- }
- Ok(())
- }
-
- pub fn add_env(&mut self, matcher: &mut ArgMatcher<'a>) -> ClapResult<()> {
- macro_rules! add_val {
- ($_self:ident, $a:ident, $m:ident) => {
- if let Some(ref val) = $a.v.env {
- if $m.get($a.b.name).map(|ma| ma.vals.len()).map(|len| len == 0).unwrap_or(false) {
- if let Some(ref val) = val.1 {
- $_self.add_val_to_arg($a, OsStr::new(val), $m)?;
-
- if $_self.cache.map_or(true, |name| name != $a.name()) {
- $_self.cache = Some($a.name());
- }
- }
- } else {
- if let Some(ref val) = val.1 {
- $_self.add_val_to_arg($a, OsStr::new(val), $m)?;
-
- if $_self.cache.map_or(true, |name| name != $a.name()) {
- $_self.cache = Some($a.name());
- }
- }
- }
- }
- };
- }
-
- for o in &self.opts {
- add_val!(self, o, matcher);
- }
- for p in self.positionals.values() {
- add_val!(self, p, matcher);
- }
- Ok(())
- }
-
- pub fn flags(&self) -> Iter<FlagBuilder<'a, 'b>> { self.flags.iter() }
-
- pub fn opts(&self) -> Iter<OptBuilder<'a, 'b>> { self.opts.iter() }
-
- pub fn positionals(&self) -> map::Values<PosBuilder<'a, 'b>> { self.positionals.values() }
-
- pub fn subcommands(&self) -> Iter<App> { self.subcommands.iter() }
-
- // Should we color the output? None=determined by output location, true=yes, false=no
- #[doc(hidden)]
- pub fn color(&self) -> ColorWhen {
- debugln!("Parser::color;");
- debug!("Parser::color: Color setting...");
- if self.is_set(AS::ColorNever) {
- sdebugln!("Never");
- ColorWhen::Never
- } else if self.is_set(AS::ColorAlways) {
- sdebugln!("Always");
- ColorWhen::Always
- } else {
- sdebugln!("Auto");
- ColorWhen::Auto
- }
- }
-
- pub fn find_any_arg(&self, name: &str) -> Option<&AnyArg<'a, 'b>> {
- if let Some(f) = find_by_name!(self, name, flags, iter) {
- return Some(f);
- }
- if let Some(o) = find_by_name!(self, name, opts, iter) {
- return Some(o);
- }
- if let Some(p) = find_by_name!(self, name, positionals, values) {
- return Some(p);
- }
- None
- }
-
- /// Check is a given string matches the binary name for this parser
- fn is_bin_name(&self, value: &str) -> bool {
- self.meta
- .bin_name
- .as_ref()
- .and_then(|name| Some(value == name))
- .unwrap_or(false)
- }
-
- /// Check is a given string is an alias for this parser
- fn is_alias(&self, value: &str) -> bool {
- self.meta
- .aliases
- .as_ref()
- .and_then(|aliases| {
- for alias in aliases {
- if alias.0 == value {
- return Some(true);
- }
- }
- Some(false)
- })
- .unwrap_or(false)
- }
-
- // Only used for completion scripts due to bin_name messiness
- #[cfg_attr(feature = "lints", allow(block_in_if_condition_stmt))]
- pub fn find_subcommand(&'b self, sc: &str) -> Option<&'b App<'a, 'b>> {
- debugln!("Parser::find_subcommand: sc={}", sc);
- debugln!(
- "Parser::find_subcommand: Currently in Parser...{}",
- self.meta.bin_name.as_ref().unwrap()
- );
- for s in &self.subcommands {
- if s.p.is_bin_name(sc) {
- return Some(s);
- }
- // XXX: why do we split here?
- // isn't `sc` supposed to be single word already?
- let last = sc.split(' ').rev().next().expect(INTERNAL_ERROR_MSG);
- if s.p.is_alias(last) {
- return Some(s);
- }
-
- if let Some(app) = s.p.find_subcommand(sc) {
- return Some(app);
- }
- }
- None
- }
-
- #[inline]
- fn contains_long(&self, l: &str) -> bool { longs!(self).any(|al| al == &l) }
-
- #[inline]
- fn contains_short(&self, s: char) -> bool { shorts!(self).any(|arg_s| arg_s == &s) }
-}
diff --git a/clap/src/app/settings.rs b/clap/src/app/settings.rs
deleted file mode 100644
index ec03997..0000000
--- a/clap/src/app/settings.rs
+++ /dev/null
@@ -1,1174 +0,0 @@
-// Std
-#[allow(deprecated, unused_imports)]
-use std::ascii::AsciiExt;
-use std::str::FromStr;
-use std::ops::BitOr;
-
-bitflags! {
- struct Flags: u64 {
- const SC_NEGATE_REQS = 1;
- const SC_REQUIRED = 1 << 1;
- const A_REQUIRED_ELSE_HELP = 1 << 2;
- const GLOBAL_VERSION = 1 << 3;
- const VERSIONLESS_SC = 1 << 4;
- const UNIFIED_HELP = 1 << 5;
- const WAIT_ON_ERROR = 1 << 6;
- const SC_REQUIRED_ELSE_HELP= 1 << 7;
- const NEEDS_LONG_HELP = 1 << 8;
- const NEEDS_LONG_VERSION = 1 << 9;
- const NEEDS_SC_HELP = 1 << 10;
- const DISABLE_VERSION = 1 << 11;
- const HIDDEN = 1 << 12;
- const TRAILING_VARARG = 1 << 13;
- const NO_BIN_NAME = 1 << 14;
- const ALLOW_UNK_SC = 1 << 15;
- const UTF8_STRICT = 1 << 16;
- const UTF8_NONE = 1 << 17;
- const LEADING_HYPHEN = 1 << 18;
- const NO_POS_VALUES = 1 << 19;
- const NEXT_LINE_HELP = 1 << 20;
- const DERIVE_DISP_ORDER = 1 << 21;
- const COLORED_HELP = 1 << 22;
- const COLOR_ALWAYS = 1 << 23;
- const COLOR_AUTO = 1 << 24;
- const COLOR_NEVER = 1 << 25;
- const DONT_DELIM_TRAIL = 1 << 26;
- const ALLOW_NEG_NUMS = 1 << 27;
- const LOW_INDEX_MUL_POS = 1 << 28;
- const DISABLE_HELP_SC = 1 << 29;
- const DONT_COLLAPSE_ARGS = 1 << 30;
- const ARGS_NEGATE_SCS = 1 << 31;
- const PROPAGATE_VALS_DOWN = 1 << 32;
- const ALLOW_MISSING_POS = 1 << 33;
- const TRAILING_VALUES = 1 << 34;
- const VALID_NEG_NUM_FOUND = 1 << 35;
- const PROPAGATED = 1 << 36;
- const VALID_ARG_FOUND = 1 << 37;
- const INFER_SUBCOMMANDS = 1 << 38;
- const CONTAINS_LAST = 1 << 39;
- const ARGS_OVERRIDE_SELF = 1 << 40;
- const DISABLE_HELP_FLAGS = 1 << 41;
- }
-}
-
-#[doc(hidden)]
-#[derive(Debug, Copy, Clone, PartialEq)]
-pub struct AppFlags(Flags);
-
-impl BitOr for AppFlags {
- type Output = Self;
- fn bitor(self, rhs: Self) -> Self { AppFlags(self.0 | rhs.0) }
-}
-
-impl Default for AppFlags {
- fn default() -> Self {
- AppFlags(
- Flags::NEEDS_LONG_VERSION | Flags::NEEDS_LONG_HELP | Flags::NEEDS_SC_HELP
- | Flags::UTF8_NONE | Flags::COLOR_AUTO,
- )
- }
-}
-
-#[allow(deprecated)]
-impl AppFlags {
- pub fn new() -> Self { AppFlags::default() }
- pub fn zeroed() -> Self { AppFlags(Flags::empty()) }
-
- impl_settings! { AppSettings,
- ArgRequiredElseHelp => Flags::A_REQUIRED_ELSE_HELP,
- ArgsNegateSubcommands => Flags::ARGS_NEGATE_SCS,
- AllArgsOverrideSelf => Flags::ARGS_OVERRIDE_SELF,
- AllowExternalSubcommands => Flags::ALLOW_UNK_SC,
- AllowInvalidUtf8 => Flags::UTF8_NONE,
- AllowLeadingHyphen => Flags::LEADING_HYPHEN,
- AllowNegativeNumbers => Flags::ALLOW_NEG_NUMS,
- AllowMissingPositional => Flags::ALLOW_MISSING_POS,
- ColoredHelp => Flags::COLORED_HELP,
- ColorAlways => Flags::COLOR_ALWAYS,
- ColorAuto => Flags::COLOR_AUTO,
- ColorNever => Flags::COLOR_NEVER,
- DontDelimitTrailingValues => Flags::DONT_DELIM_TRAIL,
- DontCollapseArgsInUsage => Flags::DONT_COLLAPSE_ARGS,
- DeriveDisplayOrder => Flags::DERIVE_DISP_ORDER,
- DisableHelpFlags => Flags::DISABLE_HELP_FLAGS,
- DisableHelpSubcommand => Flags::DISABLE_HELP_SC,
- DisableVersion => Flags::DISABLE_VERSION,
- GlobalVersion => Flags::GLOBAL_VERSION,
- HidePossibleValuesInHelp => Flags::NO_POS_VALUES,
- Hidden => Flags::HIDDEN,
- LowIndexMultiplePositional => Flags::LOW_INDEX_MUL_POS,
- NeedsLongHelp => Flags::NEEDS_LONG_HELP,
- NeedsLongVersion => Flags::NEEDS_LONG_VERSION,
- NeedsSubcommandHelp => Flags::NEEDS_SC_HELP,
- NoBinaryName => Flags::NO_BIN_NAME,
- PropagateGlobalValuesDown=> Flags::PROPAGATE_VALS_DOWN,
- StrictUtf8 => Flags::UTF8_STRICT,
- SubcommandsNegateReqs => Flags::SC_NEGATE_REQS,
- SubcommandRequired => Flags::SC_REQUIRED,
- SubcommandRequiredElseHelp => Flags::SC_REQUIRED_ELSE_HELP,
- TrailingVarArg => Flags::TRAILING_VARARG,
- UnifiedHelpMessage => Flags::UNIFIED_HELP,
- NextLineHelp => Flags::NEXT_LINE_HELP,
- VersionlessSubcommands => Flags::VERSIONLESS_SC,
- WaitOnError => Flags::WAIT_ON_ERROR,
- TrailingValues => Flags::TRAILING_VALUES,
- ValidNegNumFound => Flags::VALID_NEG_NUM_FOUND,
- Propagated => Flags::PROPAGATED,
- ValidArgFound => Flags::VALID_ARG_FOUND,
- InferSubcommands => Flags::INFER_SUBCOMMANDS,
- ContainsLast => Flags::CONTAINS_LAST
- }
-}
-
-/// Application level settings, which affect how [`App`] operates
-///
-/// **NOTE:** When these settings are used, they apply only to current command, and are *not*
-/// propagated down or up through child or parent subcommands
-///
-/// [`App`]: ./struct.App.html
-#[derive(Debug, PartialEq, Copy, Clone)]
-pub enum AppSettings {
- /// Specifies that any invalid UTF-8 code points should *not* be treated as an error.
- /// This is the default behavior of `clap`.
- ///
- /// **NOTE:** Using argument values with invalid UTF-8 code points requires using
- /// [`ArgMatches::os_value_of`], [`ArgMatches::os_values_of`], [`ArgMatches::lossy_value_of`],
- /// or [`ArgMatches::lossy_values_of`] for those particular arguments which may contain invalid
- /// UTF-8 values
- ///
- /// **NOTE:** This rule only applies to argument values, as flags, options, and
- /// [`SubCommand`]s themselves only allow valid UTF-8 code points.
- ///
- /// # Platform Specific
- ///
- /// Non Windows systems only
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, AppSettings};
- /// use std::ffi::OsString;
- /// use std::os::unix::ffi::{OsStrExt,OsStringExt};
- ///
- /// let r = App::new("myprog")
- /// //.setting(AppSettings::AllowInvalidUtf8)
- /// .arg_from_usage("<arg> 'some positional arg'")
- /// .get_matches_from_safe(
- /// vec![
- /// OsString::from("myprog"),
- /// OsString::from_vec(vec![0xe9])]);
- ///
- /// assert!(r.is_ok());
- /// let m = r.unwrap();
- /// assert_eq!(m.value_of_os("arg").unwrap().as_bytes(), &[0xe9]);
- /// ```
- /// [`ArgMatches::os_value_of`]: ./struct.ArgMatches.html#method.os_value_of
- /// [`ArgMatches::os_values_of`]: ./struct.ArgMatches.html#method.os_values_of
- /// [`ArgMatches::lossy_value_of`]: ./struct.ArgMatches.html#method.lossy_value_of
- /// [`ArgMatches::lossy_values_of`]: ./struct.ArgMatches.html#method.lossy_values_of
- /// [`SubCommand`]: ./struct.SubCommand.html
- AllowInvalidUtf8,
-
- /// Essentially sets [`Arg::overrides_with("itself")`] for all arguments.
- ///
- /// **WARNING:** Positional arguments cannot override themselves (or we would never be able
- /// to advance to the next positional). This setting ignores positional arguments.
- /// [`Arg::overrides_with("itself")`]: ./struct.Arg.html#method.overrides_with
- AllArgsOverrideSelf,
-
- /// Specifies that leading hyphens are allowed in argument *values*, such as negative numbers
- /// like `-10`. (which would otherwise be parsed as another flag or option)
- ///
- /// **NOTE:** Use this setting with caution as it silences certain circumstances which would
- /// otherwise be an error (such as accidentally forgetting to specify a value for leading
- /// option). It is preferred to set this on a per argument basis, via [`Arg::allow_hyphen_values`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{Arg, App, AppSettings};
- /// // Imagine you needed to represent negative numbers as well, such as -10
- /// let m = App::new("nums")
- /// .setting(AppSettings::AllowLeadingHyphen)
- /// .arg(Arg::with_name("neg").index(1))
- /// .get_matches_from(vec![
- /// "nums", "-20"
- /// ]);
- ///
- /// assert_eq!(m.value_of("neg"), Some("-20"));
- /// # ;
- /// ```
- /// [`Arg::allow_hyphen_values`]: ./struct.Arg.html#method.allow_hyphen_values
- AllowLeadingHyphen,
-
- /// Allows negative numbers to pass as values. This is similar to
- /// `AllowLeadingHyphen` except that it only allows numbers, all
- /// other undefined leading hyphens will fail to parse.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// let res = App::new("myprog")
- /// .version("v1.1")
- /// .setting(AppSettings::AllowNegativeNumbers)
- /// .arg(Arg::with_name("num"))
- /// .get_matches_from_safe(vec![
- /// "myprog", "-20"
- /// ]);
- /// assert!(res.is_ok());
- /// let m = res.unwrap();
- /// assert_eq!(m.value_of("num").unwrap(), "-20");
- /// ```
- /// [`AllowLeadingHyphen`]: ./enum.AppSettings.html#variant.AllowLeadingHyphen
- AllowNegativeNumbers,
-
- /// Allows one to implement two styles of CLIs where positionals can be used out of order.
- ///
- /// The first example is a CLI where the second to last positional argument is optional, but
- /// the final positional argument is required. Such as `$ prog [optional] <required>` where one
- /// of the two following usages is allowed:
- ///
- /// * `$ prog [optional] <required>`
- /// * `$ prog <required>`
- ///
- /// This would otherwise not be allowed. This is useful when `[optional]` has a default value.
- ///
- /// **Note:** when using this style of "missing positionals" the final positional *must* be
- /// [required] if `--` will not be used to skip to the final positional argument.
- ///
- /// **Note:** This style also only allows a single positional argument to be "skipped" without
- /// the use of `--`. To skip more than one, see the second example.
- ///
- /// The second example is when one wants to skip multiple optional positional arguments, and use
- /// of the `--` operator is OK (but not required if all arguments will be specified anyways).
- ///
- /// For example, imagine a CLI which has three positional arguments `[foo] [bar] [baz]...` where
- /// `baz` accepts multiple values (similar to man `ARGS...` style training arguments).
- ///
- /// With this setting the following invocations are possible:
- ///
- /// * `$ prog foo bar baz1 baz2 baz3`
- /// * `$ prog foo -- baz1 baz2 baz3`
- /// * `$ prog -- baz1 baz2 baz3`
- ///
- /// # Examples
- ///
- /// Style number one from above:
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// // Assume there is an external subcommand named "subcmd"
- /// let m = App::new("myprog")
- /// .setting(AppSettings::AllowMissingPositional)
- /// .arg(Arg::with_name("arg1"))
- /// .arg(Arg::with_name("arg2")
- /// .required(true))
- /// .get_matches_from(vec![
- /// "prog", "other"
- /// ]);
- ///
- /// assert_eq!(m.value_of("arg1"), None);
- /// assert_eq!(m.value_of("arg2"), Some("other"));
- /// ```
- ///
- /// Now the same example, but using a default value for the first optional positional argument
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// // Assume there is an external subcommand named "subcmd"
- /// let m = App::new("myprog")
- /// .setting(AppSettings::AllowMissingPositional)
- /// .arg(Arg::with_name("arg1")
- /// .default_value("something"))
- /// .arg(Arg::with_name("arg2")
- /// .required(true))
- /// .get_matches_from(vec![
- /// "prog", "other"
- /// ]);
- ///
- /// assert_eq!(m.value_of("arg1"), Some("something"));
- /// assert_eq!(m.value_of("arg2"), Some("other"));
- /// ```
- /// Style number two from above:
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// // Assume there is an external subcommand named "subcmd"
- /// let m = App::new("myprog")
- /// .setting(AppSettings::AllowMissingPositional)
- /// .arg(Arg::with_name("foo"))
- /// .arg(Arg::with_name("bar"))
- /// .arg(Arg::with_name("baz").multiple(true))
- /// .get_matches_from(vec![
- /// "prog", "foo", "bar", "baz1", "baz2", "baz3"
- /// ]);
- ///
- /// assert_eq!(m.value_of("foo"), Some("foo"));
- /// assert_eq!(m.value_of("bar"), Some("bar"));
- /// assert_eq!(m.values_of("baz").unwrap().collect::<Vec<_>>(), &["baz1", "baz2", "baz3"]);
- /// ```
- ///
- /// Now notice if we don't specify `foo` or `baz` but use the `--` operator.
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// // Assume there is an external subcommand named "subcmd"
- /// let m = App::new("myprog")
- /// .setting(AppSettings::AllowMissingPositional)
- /// .arg(Arg::with_name("foo"))
- /// .arg(Arg::with_name("bar"))
- /// .arg(Arg::with_name("baz").multiple(true))
- /// .get_matches_from(vec![
- /// "prog", "--", "baz1", "baz2", "baz3"
- /// ]);
- ///
- /// assert_eq!(m.value_of("foo"), None);
- /// assert_eq!(m.value_of("bar"), None);
- /// assert_eq!(m.values_of("baz").unwrap().collect::<Vec<_>>(), &["baz1", "baz2", "baz3"]);
- /// ```
- /// [required]: ./struct.Arg.html#method.required
- AllowMissingPositional,
-
- /// Specifies that an unexpected positional argument,
- /// which would otherwise cause a [`ErrorKind::UnknownArgument`] error,
- /// should instead be treated as a [`SubCommand`] within the [`ArgMatches`] struct.
- ///
- /// **NOTE:** Use this setting with caution,
- /// as a truly unexpected argument (i.e. one that is *NOT* an external subcommand)
- /// will **not** cause an error and instead be treated as a potential subcommand.
- /// One should check for such cases manually and inform the user appropriately.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings};
- /// // Assume there is an external subcommand named "subcmd"
- /// let m = App::new("myprog")
- /// .setting(AppSettings::AllowExternalSubcommands)
- /// .get_matches_from(vec![
- /// "myprog", "subcmd", "--option", "value", "-fff", "--flag"
- /// ]);
- ///
- /// // All trailing arguments will be stored under the subcommand's sub-matches using an empty
- /// // string argument name
- /// match m.subcommand() {
- /// (external, Some(ext_m)) => {
- /// let ext_args: Vec<&str> = ext_m.values_of("").unwrap().collect();
- /// assert_eq!(external, "subcmd");
- /// assert_eq!(ext_args, ["--option", "value", "-fff", "--flag"]);
- /// },
- /// _ => {},
- /// }
- /// ```
- /// [`ErrorKind::UnknownArgument`]: ./enum.ErrorKind.html#variant.UnknownArgument
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`ArgMatches`]: ./struct.ArgMatches.html
- AllowExternalSubcommands,
-
- /// Specifies that use of a valid [argument] negates [subcommands] being used after. By default
- /// `clap` allows arguments between subcommands such as
- /// `<cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]`. This setting disables that
- /// functionality and says that arguments can only follow the *final* subcommand. For instance
- /// using this setting makes only the following invocations possible:
- ///
- /// * `<cmd> <cmd2> <cmd3> [cmd3_args]`
- /// * `<cmd> <cmd2> [cmd2_args]`
- /// * `<cmd> [cmd_args]`
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::ArgsNegateSubcommands)
- /// # ;
- /// ```
- /// [subcommands]: ./struct.SubCommand.html
- /// [argument]: ./struct.Arg.html
- ArgsNegateSubcommands,
-
- /// Specifies that the help text should be displayed (and then exit gracefully),
- /// if no arguments are present at runtime (i.e. an empty run such as, `$ myprog`.
- ///
- /// **NOTE:** [`SubCommand`]s count as arguments
- ///
- /// **NOTE:** Setting [`Arg::default_value`] effectively disables this option as it will
- /// ensure that some argument is always present.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::ArgRequiredElseHelp)
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`Arg::default_value`]: ./struct.Arg.html#method.default_value
- ArgRequiredElseHelp,
-
- /// Uses colorized help messages.
- ///
- /// **NOTE:** Must be compiled with the `color` cargo feature
- ///
- /// # Platform Specific
- ///
- /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms)
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::ColoredHelp)
- /// .get_matches();
- /// ```
- ColoredHelp,
-
- /// Enables colored output only when the output is going to a terminal or TTY.
- ///
- /// **NOTE:** This is the default behavior of `clap`.
- ///
- /// **NOTE:** Must be compiled with the `color` cargo feature.
- ///
- /// # Platform Specific
- ///
- /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms).
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::ColorAuto)
- /// .get_matches();
- /// ```
- ColorAuto,
-
- /// Enables colored output regardless of whether or not the output is going to a terminal/TTY.
- ///
- /// **NOTE:** Must be compiled with the `color` cargo feature.
- ///
- /// # Platform Specific
- ///
- /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms).
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::ColorAlways)
- /// .get_matches();
- /// ```
- ColorAlways,
-
- /// Disables colored output no matter if the output is going to a terminal/TTY, or not.
- ///
- /// **NOTE:** Must be compiled with the `color` cargo feature
- ///
- /// # Platform Specific
- ///
- /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms)
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::ColorNever)
- /// .get_matches();
- /// ```
- ColorNever,
-
- /// Disables the automatic collapsing of positional args into `[ARGS]` inside the usage string
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::DontCollapseArgsInUsage)
- /// .get_matches();
- /// ```
- DontCollapseArgsInUsage,
-
- /// Disables the automatic delimiting of values when `--` or [`AppSettings::TrailingVarArg`]
- /// was used.
- ///
- /// **NOTE:** The same thing can be done manually by setting the final positional argument to
- /// [`Arg::use_delimiter(false)`]. Using this setting is safer, because it's easier to locate
- /// when making changes.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::DontDelimitTrailingValues)
- /// .get_matches();
- /// ```
- /// [`AppSettings::TrailingVarArg`]: ./enum.AppSettings.html#variant.TrailingVarArg
- /// [`Arg::use_delimiter(false)`]: ./struct.Arg.html#method.use_delimiter
- DontDelimitTrailingValues,
-
- /// Disables `-h` and `--help` [`App`] without affecting any of the [`SubCommand`]s
- /// (Defaults to `false`; application *does* have help flags)
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings, ErrorKind};
- /// let res = App::new("myprog")
- /// .setting(AppSettings::DisableHelpFlags)
- /// .get_matches_from_safe(vec![
- /// "myprog", "-h"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, SubCommand, AppSettings, ErrorKind};
- /// let res = App::new("myprog")
- /// .setting(AppSettings::DisableHelpFlags)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog", "test", "-h"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::HelpDisplayed);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`App`]: ./struct.App.html
- DisableHelpFlags,
-
- /// Disables the `help` subcommand
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings, ErrorKind, SubCommand};
- /// let res = App::new("myprog")
- /// .version("v1.1")
- /// .setting(AppSettings::DisableHelpSubcommand)
- /// // Normally, creating a subcommand causes a `help` subcommand to automatically
- /// // be generated as well
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog", "help"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- DisableHelpSubcommand,
-
- /// Disables `-V` and `--version` [`App`] without affecting any of the [`SubCommand`]s
- /// (Defaults to `false`; application *does* have a version flag)
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings, ErrorKind};
- /// let res = App::new("myprog")
- /// .version("v1.1")
- /// .setting(AppSettings::DisableVersion)
- /// .get_matches_from_safe(vec![
- /// "myprog", "-V"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, SubCommand, AppSettings, ErrorKind};
- /// let res = App::new("myprog")
- /// .version("v1.1")
- /// .setting(AppSettings::DisableVersion)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog", "test", "-V"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::VersionDisplayed);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`App`]: ./struct.App.html
- DisableVersion,
-
- /// Displays the arguments and [`SubCommand`]s in the help message in the order that they were
- /// declared in, and not alphabetically which is the default.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::DeriveDisplayOrder)
- /// .get_matches();
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- DeriveDisplayOrder,
-
- /// Specifies to use the version of the current command for all child [`SubCommand`]s.
- /// (Defaults to `false`; subcommands have independent version strings from their parents.)
- ///
- /// **NOTE:** The version for the current command **and** this setting must be set **prior** to
- /// adding any child subcommands
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .version("v1.1")
- /// .setting(AppSettings::GlobalVersion)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches();
- /// // running `$ myprog test --version` will display
- /// // "myprog-test v1.1"
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- GlobalVersion,
-
- /// Specifies that this [`SubCommand`] should be hidden from help messages
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings, SubCommand};
- /// App::new("myprog")
- /// .subcommand(SubCommand::with_name("test")
- /// .setting(AppSettings::Hidden))
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- Hidden,
-
- /// Tells `clap` *not* to print possible values when displaying help information.
- /// This can be useful if there are many values, or they are explained elsewhere.
- HidePossibleValuesInHelp,
-
- /// Tries to match unknown args to partial [`subcommands`] or their [aliases]. For example to
- /// match a subcommand named `test`, one could use `t`, `te`, `tes`, and `test`.
- ///
- /// **NOTE:** The match *must not* be ambiguous at all in order to succeed. i.e. to match `te`
- /// to `test` there could not also be a subcommand or alias `temp` because both start with `te`
- ///
- /// **CAUTION:** This setting can interfere with [positional/free arguments], take care when
- /// designing CLIs which allow inferred subcommands and have potential positional/free
- /// arguments whose values could start with the same characters as subcommands. If this is the
- /// case, it's recommended to use settings such as [`AppSeettings::ArgsNegateSubcommands`] in
- /// conjunction with this setting.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// let m = App::new("prog")
- /// .setting(AppSettings::InferSubcommands)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from(vec![
- /// "prog", "te"
- /// ]);
- /// assert_eq!(m.subcommand_name(), Some("test"));
- /// ```
- /// [`subcommands`]: ./struct.SubCommand.html
- /// [positional/free arguments]: ./struct.Arg.html#method.index
- /// [aliases]: ./struct.App.html#method.alias
- /// [`AppSeettings::ArgsNegateSubcommands`]: ./enum.AppSettings.html#variant.ArgsNegateSubcommands
- InferSubcommands,
-
- /// Specifies that the parser should not assume the first argument passed is the binary name.
- /// This is normally the case when using a "daemon" style mode, or an interactive CLI where one
- /// one would not normally type the binary or program name for each command.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// let m = App::new("myprog")
- /// .setting(AppSettings::NoBinaryName)
- /// .arg(Arg::from_usage("<cmd>... 'commands to run'"))
- /// .get_matches_from(vec!["command", "set"]);
- ///
- /// let cmds: Vec<&str> = m.values_of("cmd").unwrap().collect();
- /// assert_eq!(cmds, ["command", "set"]);
- /// ```
- NoBinaryName,
-
- /// Places the help string for all arguments on the line after the argument.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::NextLineHelp)
- /// .get_matches();
- /// ```
- NextLineHelp,
-
- /// **DEPRECATED**: This setting is no longer required in order to propagate values up or down
- ///
- /// Specifies that the parser should propagate global arg's values down or up through any *used*
- /// child subcommands. Meaning, if a subcommand wasn't used, the values won't be propagated to
- /// said subcommand.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings, SubCommand};
- /// let m = App::new("myprog")
- /// .arg(Arg::from_usage("[cmd] 'command to run'")
- /// .global(true))
- /// .subcommand(SubCommand::with_name("foo"))
- /// .get_matches_from(vec!["myprog", "set", "foo"]);
- ///
- /// assert_eq!(m.value_of("cmd"), Some("set"));
- ///
- /// let sub_m = m.subcommand_matches("foo").unwrap();
- /// assert_eq!(sub_m.value_of("cmd"), Some("set"));
- /// ```
- /// Now doing the same thing, but *not* using any subcommands will result in the value not being
- /// propagated down.
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings, SubCommand};
- /// let m = App::new("myprog")
- /// .arg(Arg::from_usage("[cmd] 'command to run'")
- /// .global(true))
- /// .subcommand(SubCommand::with_name("foo"))
- /// .get_matches_from(vec!["myprog", "set"]);
- ///
- /// assert_eq!(m.value_of("cmd"), Some("set"));
- ///
- /// assert!(m.subcommand_matches("foo").is_none());
- /// ```
- #[deprecated(since = "2.27.0", note = "No longer required to propagate values")]
- PropagateGlobalValuesDown,
-
- /// Allows [`SubCommand`]s to override all requirements of the parent command.
- /// For example if you had a subcommand or top level application with a required argument
- /// that is only required as long as there is no subcommand present,
- /// using this setting would allow you to set those arguments to [`Arg::required(true)`]
- /// and yet receive no error so long as the user uses a valid subcommand instead.
- ///
- /// **NOTE:** This defaults to false (using subcommand does *not* negate requirements)
- ///
- /// # Examples
- ///
- /// This first example shows that it is an error to not use a required argument
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings, SubCommand, ErrorKind};
- /// let err = App::new("myprog")
- /// .setting(AppSettings::SubcommandsNegateReqs)
- /// .arg(Arg::with_name("opt").required(true))
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog"
- /// ]);
- /// assert!(err.is_err());
- /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// # ;
- /// ```
- ///
- /// This next example shows that it is no longer error to not use a required argument if a
- /// valid subcommand is used.
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings, SubCommand, ErrorKind};
- /// let noerr = App::new("myprog")
- /// .setting(AppSettings::SubcommandsNegateReqs)
- /// .arg(Arg::with_name("opt").required(true))
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog", "test"
- /// ]);
- /// assert!(noerr.is_ok());
- /// # ;
- /// ```
- /// [`Arg::required(true)`]: ./struct.Arg.html#method.required
- /// [`SubCommand`]: ./struct.SubCommand.html
- SubcommandsNegateReqs,
-
- /// Specifies that the help text should be displayed (before exiting gracefully) if no
- /// [`SubCommand`]s are present at runtime (i.e. an empty run such as `$ myprog`).
- ///
- /// **NOTE:** This should *not* be used with [`AppSettings::SubcommandRequired`] as they do
- /// nearly same thing; this prints the help text, and the other prints an error.
- ///
- /// **NOTE:** If the user specifies arguments at runtime, but no subcommand the help text will
- /// still be displayed and exit. If this is *not* the desired result, consider using
- /// [`AppSettings::ArgRequiredElseHelp`] instead.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::SubcommandRequiredElseHelp)
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings::SubcommandRequired`]: ./enum.AppSettings.html#variant.SubcommandRequired
- /// [`AppSettings::ArgRequiredElseHelp`]: ./enum.AppSettings.html#variant.ArgRequiredElseHelp
- SubcommandRequiredElseHelp,
-
- /// Specifies that any invalid UTF-8 code points should be treated as an error and fail
- /// with a [`ErrorKind::InvalidUtf8`] error.
- ///
- /// **NOTE:** This rule only applies to argument values; Things such as flags, options, and
- /// [`SubCommand`]s themselves only allow valid UTF-8 code points.
- ///
- /// # Platform Specific
- ///
- /// Non Windows systems only
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, AppSettings, ErrorKind};
- /// use std::ffi::OsString;
- /// use std::os::unix::ffi::OsStringExt;
- ///
- /// let m = App::new("myprog")
- /// .setting(AppSettings::StrictUtf8)
- /// .arg_from_usage("<arg> 'some positional arg'")
- /// .get_matches_from_safe(
- /// vec![
- /// OsString::from("myprog"),
- /// OsString::from_vec(vec![0xe9])]);
- ///
- /// assert!(m.is_err());
- /// assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`ErrorKind::InvalidUtf8`]: ./enum.ErrorKind.html#variant.InvalidUtf8
- StrictUtf8,
-
- /// Allows specifying that if no [`SubCommand`] is present at runtime,
- /// error and exit gracefully.
- ///
- /// **NOTE:** This defaults to `false` (subcommands do *not* need to be present)
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings, SubCommand, ErrorKind};
- /// let err = App::new("myprog")
- /// .setting(AppSettings::SubcommandRequired)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog",
- /// ]);
- /// assert!(err.is_err());
- /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand);
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- SubcommandRequired,
-
- /// Specifies that the final positional argument is a "VarArg" and that `clap` should not
- /// attempt to parse any further args.
- ///
- /// The values of the trailing positional argument will contain all args from itself on.
- ///
- /// **NOTE:** The final positional argument **must** have [`Arg::multiple(true)`] or the usage
- /// string equivalent.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// let m = App::new("myprog")
- /// .setting(AppSettings::TrailingVarArg)
- /// .arg(Arg::from_usage("<cmd>... 'commands to run'"))
- /// .get_matches_from(vec!["myprog", "arg1", "-r", "val1"]);
- ///
- /// let trail: Vec<&str> = m.values_of("cmd").unwrap().collect();
- /// assert_eq!(trail, ["arg1", "-r", "val1"]);
- /// ```
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- TrailingVarArg,
-
- /// Groups flags and options together, presenting a more unified help message
- /// (a la `getopts` or `docopt` style).
- ///
- /// The default is that the auto-generated help message will group flags, and options
- /// separately.
- ///
- /// **NOTE:** This setting is cosmetic only and does not affect any functionality.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::UnifiedHelpMessage)
- /// .get_matches();
- /// // running `myprog --help` will display a unified "docopt" or "getopts" style help message
- /// ```
- UnifiedHelpMessage,
-
- /// Disables `-V` and `--version` for all [`SubCommand`]s
- /// (Defaults to `false`; subcommands *do* have version flags.)
- ///
- /// **NOTE:** This setting must be set **prior** to adding any subcommands.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, SubCommand, AppSettings, ErrorKind};
- /// let res = App::new("myprog")
- /// .version("v1.1")
- /// .setting(AppSettings::VersionlessSubcommands)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog", "test", "-V"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- VersionlessSubcommands,
-
- /// Will display a message "Press \[ENTER\]/\[RETURN\] to continue..." and wait for user before
- /// exiting
- ///
- /// This is most useful when writing an application which is run from a GUI shortcut, or on
- /// Windows where a user tries to open the binary by double-clicking instead of using the
- /// command line.
- ///
- /// **NOTE:** This setting is **not** recursive with [`SubCommand`]s, meaning if you wish this
- /// behavior for all subcommands, you must set this on each command (needing this is extremely
- /// rare)
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings};
- /// App::new("myprog")
- /// .setting(AppSettings::WaitOnError)
- /// # ;
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- WaitOnError,
-
- #[doc(hidden)] NeedsLongVersion,
-
- #[doc(hidden)] NeedsLongHelp,
-
- #[doc(hidden)] NeedsSubcommandHelp,
-
- #[doc(hidden)] LowIndexMultiplePositional,
-
- #[doc(hidden)] TrailingValues,
-
- #[doc(hidden)] ValidNegNumFound,
-
- #[doc(hidden)] Propagated,
-
- #[doc(hidden)] ValidArgFound,
-
- #[doc(hidden)] ContainsLast,
-}
-
-impl FromStr for AppSettings {
- type Err = String;
- fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> {
- match &*s.to_ascii_lowercase() {
- "disablehelpflags" => Ok(AppSettings::DisableHelpFlags),
- "argrequiredelsehelp" => Ok(AppSettings::ArgRequiredElseHelp),
- "argsnegatesubcommands" => Ok(AppSettings::ArgsNegateSubcommands),
- "allowinvalidutf8" => Ok(AppSettings::AllowInvalidUtf8),
- "allowleadinghyphen" => Ok(AppSettings::AllowLeadingHyphen),
- "allowexternalsubcommands" => Ok(AppSettings::AllowExternalSubcommands),
- "allownegativenumbers" => Ok(AppSettings::AllowNegativeNumbers),
- "colorauto" => Ok(AppSettings::ColorAuto),
- "coloralways" => Ok(AppSettings::ColorAlways),
- "colornever" => Ok(AppSettings::ColorNever),
- "coloredhelp" => Ok(AppSettings::ColoredHelp),
- "derivedisplayorder" => Ok(AppSettings::DeriveDisplayOrder),
- "dontcollapseargsinusage" => Ok(AppSettings::DontCollapseArgsInUsage),
- "dontdelimittrailingvalues" => Ok(AppSettings::DontDelimitTrailingValues),
- "disablehelpsubcommand" => Ok(AppSettings::DisableHelpSubcommand),
- "disableversion" => Ok(AppSettings::DisableVersion),
- "globalversion" => Ok(AppSettings::GlobalVersion),
- "hidden" => Ok(AppSettings::Hidden),
- "hidepossiblevaluesinhelp" => Ok(AppSettings::HidePossibleValuesInHelp),
- "infersubcommands" => Ok(AppSettings::InferSubcommands),
- "lowindexmultiplepositional" => Ok(AppSettings::LowIndexMultiplePositional),
- "nobinaryname" => Ok(AppSettings::NoBinaryName),
- "nextlinehelp" => Ok(AppSettings::NextLineHelp),
- "strictutf8" => Ok(AppSettings::StrictUtf8),
- "subcommandsnegatereqs" => Ok(AppSettings::SubcommandsNegateReqs),
- "subcommandrequired" => Ok(AppSettings::SubcommandRequired),
- "subcommandrequiredelsehelp" => Ok(AppSettings::SubcommandRequiredElseHelp),
- "trailingvararg" => Ok(AppSettings::TrailingVarArg),
- "unifiedhelpmessage" => Ok(AppSettings::UnifiedHelpMessage),
- "versionlesssubcommands" => Ok(AppSettings::VersionlessSubcommands),
- "waitonerror" => Ok(AppSettings::WaitOnError),
- "validnegnumfound" => Ok(AppSettings::ValidNegNumFound),
- "validargfound" => Ok(AppSettings::ValidArgFound),
- "propagated" => Ok(AppSettings::Propagated),
- "trailingvalues" => Ok(AppSettings::TrailingValues),
- _ => Err("unknown AppSetting, cannot convert from str".to_owned()),
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::AppSettings;
-
- #[test]
- fn app_settings_fromstr() {
- assert_eq!(
- "disablehelpflags".parse::<AppSettings>().unwrap(),
- AppSettings::DisableHelpFlags
- );
- assert_eq!(
- "argsnegatesubcommands".parse::<AppSettings>().unwrap(),
- AppSettings::ArgsNegateSubcommands
- );
- assert_eq!(
- "argrequiredelsehelp".parse::<AppSettings>().unwrap(),
- AppSettings::ArgRequiredElseHelp
- );
- assert_eq!(
- "allowexternalsubcommands".parse::<AppSettings>().unwrap(),
- AppSettings::AllowExternalSubcommands
- );
- assert_eq!(
- "allowinvalidutf8".parse::<AppSettings>().unwrap(),
- AppSettings::AllowInvalidUtf8
- );
- assert_eq!(
- "allowleadinghyphen".parse::<AppSettings>().unwrap(),
- AppSettings::AllowLeadingHyphen
- );
- assert_eq!(
- "allownegativenumbers".parse::<AppSettings>().unwrap(),
- AppSettings::AllowNegativeNumbers
- );
- assert_eq!(
- "coloredhelp".parse::<AppSettings>().unwrap(),
- AppSettings::ColoredHelp
- );
- assert_eq!(
- "colorauto".parse::<AppSettings>().unwrap(),
- AppSettings::ColorAuto
- );
- assert_eq!(
- "coloralways".parse::<AppSettings>().unwrap(),
- AppSettings::ColorAlways
- );
- assert_eq!(
- "colornever".parse::<AppSettings>().unwrap(),
- AppSettings::ColorNever
- );
- assert_eq!(
- "disablehelpsubcommand".parse::<AppSettings>().unwrap(),
- AppSettings::DisableHelpSubcommand
- );
- assert_eq!(
- "disableversion".parse::<AppSettings>().unwrap(),
- AppSettings::DisableVersion
- );
- assert_eq!(
- "dontcollapseargsinusage".parse::<AppSettings>().unwrap(),
- AppSettings::DontCollapseArgsInUsage
- );
- assert_eq!(
- "dontdelimittrailingvalues".parse::<AppSettings>().unwrap(),
- AppSettings::DontDelimitTrailingValues
- );
- assert_eq!(
- "derivedisplayorder".parse::<AppSettings>().unwrap(),
- AppSettings::DeriveDisplayOrder
- );
- assert_eq!(
- "globalversion".parse::<AppSettings>().unwrap(),
- AppSettings::GlobalVersion
- );
- assert_eq!(
- "hidden".parse::<AppSettings>().unwrap(),
- AppSettings::Hidden
- );
- assert_eq!(
- "hidepossiblevaluesinhelp".parse::<AppSettings>().unwrap(),
- AppSettings::HidePossibleValuesInHelp
- );
- assert_eq!(
- "lowindexmultiplePositional".parse::<AppSettings>().unwrap(),
- AppSettings::LowIndexMultiplePositional
- );
- assert_eq!(
- "nobinaryname".parse::<AppSettings>().unwrap(),
- AppSettings::NoBinaryName
- );
- assert_eq!(
- "nextlinehelp".parse::<AppSettings>().unwrap(),
- AppSettings::NextLineHelp
- );
- assert_eq!(
- "subcommandsnegatereqs".parse::<AppSettings>().unwrap(),
- AppSettings::SubcommandsNegateReqs
- );
- assert_eq!(
- "subcommandrequired".parse::<AppSettings>().unwrap(),
- AppSettings::SubcommandRequired
- );
- assert_eq!(
- "subcommandrequiredelsehelp".parse::<AppSettings>().unwrap(),
- AppSettings::SubcommandRequiredElseHelp
- );
- assert_eq!(
- "strictutf8".parse::<AppSettings>().unwrap(),
- AppSettings::StrictUtf8
- );
- assert_eq!(
- "trailingvararg".parse::<AppSettings>().unwrap(),
- AppSettings::TrailingVarArg
- );
- assert_eq!(
- "unifiedhelpmessage".parse::<AppSettings>().unwrap(),
- AppSettings::UnifiedHelpMessage
- );
- assert_eq!(
- "versionlesssubcommands".parse::<AppSettings>().unwrap(),
- AppSettings::VersionlessSubcommands
- );
- assert_eq!(
- "waitonerror".parse::<AppSettings>().unwrap(),
- AppSettings::WaitOnError
- );
- assert_eq!(
- "validnegnumfound".parse::<AppSettings>().unwrap(),
- AppSettings::ValidNegNumFound
- );
- assert_eq!(
- "validargfound".parse::<AppSettings>().unwrap(),
- AppSettings::ValidArgFound
- );
- assert_eq!(
- "propagated".parse::<AppSettings>().unwrap(),
- AppSettings::Propagated
- );
- assert_eq!(
- "trailingvalues".parse::<AppSettings>().unwrap(),
- AppSettings::TrailingValues
- );
- assert_eq!(
- "infersubcommands".parse::<AppSettings>().unwrap(),
- AppSettings::InferSubcommands
- );
- assert!("hahahaha".parse::<AppSettings>().is_err());
- }
-}
diff --git a/clap/src/app/usage.rs b/clap/src/app/usage.rs
deleted file mode 100644
index 6090588..0000000
--- a/clap/src/app/usage.rs
+++ /dev/null
@@ -1,479 +0,0 @@
-// std
-use std::collections::{BTreeMap, VecDeque};
-
-// Internal
-use INTERNAL_ERROR_MSG;
-use args::{AnyArg, ArgMatcher, PosBuilder};
-use args::settings::ArgSettings;
-use app::settings::AppSettings as AS;
-use app::parser::Parser;
-
-// Creates a usage string for display. This happens just after all arguments were parsed, but before
-// any subcommands have been parsed (so as to give subcommands their own usage recursively)
-pub fn create_usage_with_title(p: &Parser, used: &[&str]) -> String {
- debugln!("usage::create_usage_with_title;");
- let mut usage = String::with_capacity(75);
- usage.push_str("USAGE:\n ");
- usage.push_str(&*create_usage_no_title(p, used));
- usage
-}
-
-// Creates a usage string to be used in error message (i.e. one with currently used args)
-pub fn create_error_usage<'a, 'b>(
- p: &Parser<'a, 'b>,
- matcher: &'b ArgMatcher<'a>,
- extra: Option<&str>,
-) -> String {
- let mut args: Vec<_> = matcher
- .arg_names()
- .iter()
- .filter(|n| {
- if let Some(o) = find_by_name!(p, **n, opts, iter) {
- !o.b.is_set(ArgSettings::Required) && !o.b.is_set(ArgSettings::Hidden)
- } else if let Some(p) = find_by_name!(p, **n, positionals, values) {
- !p.b.is_set(ArgSettings::Required) && p.b.is_set(ArgSettings::Hidden)
- } else {
- true // flags can't be required, so they're always true
- }
- })
- .map(|&n| n)
- .collect();
- if let Some(r) = extra {
- args.push(r);
- }
- create_usage_with_title(p, &*args)
-}
-
-// Creates a usage string (*without title*) if one was not provided by the user manually.
-pub fn create_usage_no_title(p: &Parser, used: &[&str]) -> String {
- debugln!("usage::create_usage_no_title;");
- if let Some(u) = p.meta.usage_str {
- String::from(&*u)
- } else if used.is_empty() {
- create_help_usage(p, true)
- } else {
- create_smart_usage(p, used)
- }
-}
-
-// Creates a usage string for display in help messages (i.e. not for errors)
-pub fn create_help_usage(p: &Parser, incl_reqs: bool) -> String {
- let mut usage = String::with_capacity(75);
- let name = p.meta
- .usage
- .as_ref()
- .unwrap_or_else(|| p.meta.bin_name.as_ref().unwrap_or(&p.meta.name));
- usage.push_str(&*name);
- let req_string = if incl_reqs {
- let mut reqs: Vec<&str> = p.required().map(|r| &**r).collect();
- reqs.sort();
- reqs.dedup();
- get_required_usage_from(p, &reqs, None, None, false)
- .iter()
- .fold(String::new(), |a, s| a + &format!(" {}", s)[..])
- } else {
- String::new()
- };
-
- let flags = needs_flags_tag(p);
- if flags && !p.is_set(AS::UnifiedHelpMessage) {
- usage.push_str(" [FLAGS]");
- } else if flags {
- usage.push_str(" [OPTIONS]");
- }
- if !p.is_set(AS::UnifiedHelpMessage) && p.opts.iter().any(|o| {
- !o.is_set(ArgSettings::Required) && !o.is_set(ArgSettings::Hidden)
- }) {
- usage.push_str(" [OPTIONS]");
- }
-
- usage.push_str(&req_string[..]);
-
- let has_last = p.positionals.values().any(|p| p.is_set(ArgSettings::Last));
- // places a '--' in the usage string if there are args and options
- // supporting multiple values
- if p.opts.iter().any(|o| o.is_set(ArgSettings::Multiple))
- && p.positionals
- .values()
- .any(|p| !p.is_set(ArgSettings::Required))
- && !(p.has_visible_subcommands() || p.is_set(AS::AllowExternalSubcommands))
- && !has_last
- {
- usage.push_str(" [--]");
- }
- let not_req_or_hidden = |p: &PosBuilder| {
- (!p.is_set(ArgSettings::Required) || p.is_set(ArgSettings::Last))
- && !p.is_set(ArgSettings::Hidden)
- };
- if p.has_positionals() && p.positionals.values().any(not_req_or_hidden) {
- if let Some(args_tag) = get_args_tag(p, incl_reqs) {
- usage.push_str(&*args_tag);
- } else {
- usage.push_str(" [ARGS]");
- }
- if has_last && incl_reqs {
- let pos = p.positionals
- .values()
- .find(|p| p.b.is_set(ArgSettings::Last))
- .expect(INTERNAL_ERROR_MSG);
- debugln!("usage::create_help_usage: '{}' has .last(true)", pos.name());
- let req = pos.is_set(ArgSettings::Required);
- if req
- && p.positionals
- .values()
- .any(|p| !p.is_set(ArgSettings::Required))
- {
- usage.push_str(" -- <");
- } else if req {
- usage.push_str(" [--] <");
- } else {
- usage.push_str(" [-- <");
- }
- usage.push_str(&*pos.name_no_brackets());
- usage.push_str(">");
- usage.push_str(pos.multiple_str());
- if !req {
- usage.push_str("]");
- }
- }
- }
-
- // incl_reqs is only false when this function is called recursively
- if p.has_visible_subcommands() && incl_reqs || p.is_set(AS::AllowExternalSubcommands) {
- if p.is_set(AS::SubcommandsNegateReqs) || p.is_set(AS::ArgsNegateSubcommands) {
- if !p.is_set(AS::ArgsNegateSubcommands) {
- usage.push_str("\n ");
- usage.push_str(&*create_help_usage(p, false));
- usage.push_str(" <SUBCOMMAND>");
- } else {
- usage.push_str("\n ");
- usage.push_str(&*name);
- usage.push_str(" <SUBCOMMAND>");
- }
- } else if p.is_set(AS::SubcommandRequired) || p.is_set(AS::SubcommandRequiredElseHelp) {
- usage.push_str(" <SUBCOMMAND>");
- } else {
- usage.push_str(" [SUBCOMMAND]");
- }
- }
- usage.shrink_to_fit();
- debugln!("usage::create_help_usage: usage={}", usage);
- usage
-}
-
-// Creates a context aware usage string, or "smart usage" from currently used
-// args, and requirements
-fn create_smart_usage(p: &Parser, used: &[&str]) -> String {
- debugln!("usage::smart_usage;");
- let mut usage = String::with_capacity(75);
- let mut hs: Vec<&str> = p.required().map(|s| &**s).collect();
- hs.extend_from_slice(used);
-
- let r_string = get_required_usage_from(p, &hs, None, None, false)
- .iter()
- .fold(String::new(), |acc, s| acc + &format!(" {}", s)[..]);
-
- usage.push_str(
- &p.meta
- .usage
- .as_ref()
- .unwrap_or_else(|| p.meta.bin_name.as_ref().unwrap_or(&p.meta.name))[..],
- );
- usage.push_str(&*r_string);
- if p.is_set(AS::SubcommandRequired) {
- usage.push_str(" <SUBCOMMAND>");
- }
- usage.shrink_to_fit();
- usage
-}
-
-// Gets the `[ARGS]` tag for the usage string
-fn get_args_tag(p: &Parser, incl_reqs: bool) -> Option<String> {
- debugln!("usage::get_args_tag;");
- let mut count = 0;
- 'outer: for pos in p.positionals
- .values()
- .filter(|pos| !pos.is_set(ArgSettings::Required))
- .filter(|pos| !pos.is_set(ArgSettings::Hidden))
- .filter(|pos| !pos.is_set(ArgSettings::Last))
- {
- debugln!("usage::get_args_tag:iter:{}:", pos.b.name);
- if let Some(g_vec) = p.groups_for_arg(pos.b.name) {
- for grp_s in &g_vec {
- debugln!("usage::get_args_tag:iter:{}:iter:{};", pos.b.name, grp_s);
- // if it's part of a required group we don't want to count it
- if p.groups.iter().any(|g| g.required && (&g.name == grp_s)) {
- continue 'outer;
- }
- }
- }
- count += 1;
- debugln!(
- "usage::get_args_tag:iter: {} Args not required or hidden",
- count
- );
- }
- if !p.is_set(AS::DontCollapseArgsInUsage) && count > 1 {
- debugln!("usage::get_args_tag:iter: More than one, returning [ARGS]");
- return None; // [ARGS]
- } else if count == 1 && incl_reqs {
- let pos = p.positionals
- .values()
- .find(|pos| {
- !pos.is_set(ArgSettings::Required) && !pos.is_set(ArgSettings::Hidden)
- && !pos.is_set(ArgSettings::Last)
- })
- .expect(INTERNAL_ERROR_MSG);
- debugln!(
- "usage::get_args_tag:iter: Exactly one, returning '{}'",
- pos.name()
- );
- return Some(format!(
- " [{}]{}",
- pos.name_no_brackets(),
- pos.multiple_str()
- ));
- } else if p.is_set(AS::DontCollapseArgsInUsage) && !p.positionals.is_empty() && incl_reqs {
- debugln!("usage::get_args_tag:iter: Don't collapse returning all");
- return Some(
- p.positionals
- .values()
- .filter(|pos| !pos.is_set(ArgSettings::Required))
- .filter(|pos| !pos.is_set(ArgSettings::Hidden))
- .filter(|pos| !pos.is_set(ArgSettings::Last))
- .map(|pos| {
- format!(" [{}]{}", pos.name_no_brackets(), pos.multiple_str())
- })
- .collect::<Vec<_>>()
- .join(""),
- );
- } else if !incl_reqs {
- debugln!("usage::get_args_tag:iter: incl_reqs=false, building secondary usage string");
- let highest_req_pos = p.positionals
- .iter()
- .filter_map(|(idx, pos)| {
- if pos.b.is_set(ArgSettings::Required) && !pos.b.is_set(ArgSettings::Last) {
- Some(idx)
- } else {
- None
- }
- })
- .max()
- .unwrap_or_else(|| p.positionals.len());
- return Some(
- p.positionals
- .iter()
- .filter_map(|(idx, pos)| {
- if idx <= highest_req_pos {
- Some(pos)
- } else {
- None
- }
- })
- .filter(|pos| !pos.is_set(ArgSettings::Required))
- .filter(|pos| !pos.is_set(ArgSettings::Hidden))
- .filter(|pos| !pos.is_set(ArgSettings::Last))
- .map(|pos| {
- format!(" [{}]{}", pos.name_no_brackets(), pos.multiple_str())
- })
- .collect::<Vec<_>>()
- .join(""),
- );
- }
- Some("".into())
-}
-
-// Determines if we need the `[FLAGS]` tag in the usage string
-fn needs_flags_tag(p: &Parser) -> bool {
- debugln!("usage::needs_flags_tag;");
- 'outer: for f in &p.flags {
- debugln!("usage::needs_flags_tag:iter: f={};", f.b.name);
- if let Some(l) = f.s.long {
- if l == "help" || l == "version" {
- // Don't print `[FLAGS]` just for help or version
- continue;
- }
- }
- if let Some(g_vec) = p.groups_for_arg(f.b.name) {
- for grp_s in &g_vec {
- debugln!("usage::needs_flags_tag:iter:iter: grp_s={};", grp_s);
- if p.groups.iter().any(|g| &g.name == grp_s && g.required) {
- debugln!("usage::needs_flags_tag:iter:iter: Group is required");
- continue 'outer;
- }
- }
- }
- if f.is_set(ArgSettings::Hidden) {
- continue;
- }
- debugln!("usage::needs_flags_tag:iter: [FLAGS] required");
- return true;
- }
-
- debugln!("usage::needs_flags_tag: [FLAGS] not required");
- false
-}
-
-// Returns the required args in usage string form by fully unrolling all groups
-pub fn get_required_usage_from<'a, 'b>(
- p: &Parser<'a, 'b>,
- reqs: &[&'a str],
- matcher: Option<&ArgMatcher<'a>>,
- extra: Option<&str>,
- incl_last: bool,
-) -> VecDeque<String> {
- debugln!(
- "usage::get_required_usage_from: reqs={:?}, extra={:?}",
- reqs,
- extra
- );
- let mut desc_reqs: Vec<&str> = vec![];
- desc_reqs.extend(extra);
- let mut new_reqs: Vec<&str> = vec![];
- macro_rules! get_requires {
- (@group $a: ident, $v:ident, $p:ident) => {{
- if let Some(rl) = p.groups.iter()
- .filter(|g| g.requires.is_some())
- .find(|g| &g.name == $a)
- .map(|g| g.requires.as_ref().unwrap()) {
- for r in rl {
- if !$p.contains(&r) {
- debugln!("usage::get_required_usage_from:iter:{}: adding group req={:?}",
- $a, r);
- $v.push(r);
- }
- }
- }
- }};
- ($a:ident, $what:ident, $how:ident, $v:ident, $p:ident) => {{
- if let Some(rl) = p.$what.$how()
- .filter(|a| a.b.requires.is_some())
- .find(|arg| &arg.b.name == $a)
- .map(|a| a.b.requires.as_ref().unwrap()) {
- for &(_, r) in rl.iter() {
- if !$p.contains(&r) {
- debugln!("usage::get_required_usage_from:iter:{}: adding arg req={:?}",
- $a, r);
- $v.push(r);
- }
- }
- }
- }};
- }
- // initialize new_reqs
- for a in reqs {
- get_requires!(a, flags, iter, new_reqs, reqs);
- get_requires!(a, opts, iter, new_reqs, reqs);
- get_requires!(a, positionals, values, new_reqs, reqs);
- get_requires!(@group a, new_reqs, reqs);
- }
- desc_reqs.extend_from_slice(&*new_reqs);
- debugln!(
- "usage::get_required_usage_from: after init desc_reqs={:?}",
- desc_reqs
- );
- loop {
- let mut tmp = vec![];
- for a in &new_reqs {
- get_requires!(a, flags, iter, tmp, desc_reqs);
- get_requires!(a, opts, iter, tmp, desc_reqs);
- get_requires!(a, positionals, values, tmp, desc_reqs);
- get_requires!(@group a, tmp, desc_reqs);
- }
- if tmp.is_empty() {
- debugln!("usage::get_required_usage_from: no more children");
- break;
- } else {
- debugln!("usage::get_required_usage_from: after iter tmp={:?}", tmp);
- debugln!(
- "usage::get_required_usage_from: after iter new_reqs={:?}",
- new_reqs
- );
- desc_reqs.extend_from_slice(&*new_reqs);
- new_reqs.clear();
- new_reqs.extend_from_slice(&*tmp);
- debugln!(
- "usage::get_required_usage_from: after iter desc_reqs={:?}",
- desc_reqs
- );
- }
- }
- desc_reqs.extend_from_slice(reqs);
- desc_reqs.sort();
- desc_reqs.dedup();
- debugln!(
- "usage::get_required_usage_from: final desc_reqs={:?}",
- desc_reqs
- );
- let mut ret_val = VecDeque::new();
- let args_in_groups = p.groups
- .iter()
- .filter(|gn| desc_reqs.contains(&gn.name))
- .flat_map(|g| p.arg_names_in_group(g.name))
- .collect::<Vec<_>>();
-
- let pmap = if let Some(m) = matcher {
- desc_reqs
- .iter()
- .filter(|a| p.positionals.values().any(|p| &&p.b.name == a))
- .filter(|&pos| !m.contains(pos))
- .filter_map(|pos| p.positionals.values().find(|x| &x.b.name == pos))
- .filter(|&pos| incl_last || !pos.is_set(ArgSettings::Last))
- .filter(|pos| !args_in_groups.contains(&pos.b.name))
- .map(|pos| (pos.index, pos))
- .collect::<BTreeMap<u64, &PosBuilder>>() // sort by index
- } else {
- desc_reqs
- .iter()
- .filter(|a| p.positionals.values().any(|pos| &&pos.b.name == a))
- .filter_map(|pos| p.positionals.values().find(|x| &x.b.name == pos))
- .filter(|&pos| incl_last || !pos.is_set(ArgSettings::Last))
- .filter(|pos| !args_in_groups.contains(&pos.b.name))
- .map(|pos| (pos.index, pos))
- .collect::<BTreeMap<u64, &PosBuilder>>() // sort by index
- };
- debugln!(
- "usage::get_required_usage_from: args_in_groups={:?}",
- args_in_groups
- );
- for &p in pmap.values() {
- let s = p.to_string();
- if args_in_groups.is_empty() || !args_in_groups.contains(&&*s) {
- ret_val.push_back(s);
- }
- }
- for a in desc_reqs
- .iter()
- .filter(|name| !p.positionals.values().any(|p| &&p.b.name == name))
- .filter(|name| !p.groups.iter().any(|g| &&g.name == name))
- .filter(|name| !args_in_groups.contains(name))
- .filter(|name| {
- !(matcher.is_some() && matcher.as_ref().unwrap().contains(name))
- }) {
- debugln!("usage::get_required_usage_from:iter:{}:", a);
- let arg = find_by_name!(p, *a, flags, iter)
- .map(|f| f.to_string())
- .unwrap_or_else(|| {
- find_by_name!(p, *a, opts, iter)
- .map(|o| o.to_string())
- .expect(INTERNAL_ERROR_MSG)
- });
- ret_val.push_back(arg);
- }
- let mut g_vec: Vec<String> = vec![];
- for g in desc_reqs
- .iter()
- .filter(|n| p.groups.iter().any(|g| &&g.name == n))
- {
- let g_string = p.args_in_group(g).join("|");
- let elem = format!("<{}>", &g_string[..g_string.len()]);
- if !g_vec.contains(&elem) {
- g_vec.push(elem);
- }
- }
- for g in g_vec {
- ret_val.push_back(g);
- }
-
- ret_val
-}
diff --git a/clap/src/app/validator.rs b/clap/src/app/validator.rs
deleted file mode 100644
index 181b831..0000000
--- a/clap/src/app/validator.rs
+++ /dev/null
@@ -1,573 +0,0 @@
-// std
-use std::fmt::Display;
-#[allow(deprecated, unused_imports)]
-use std::ascii::AsciiExt;
-
-// Internal
-use INTERNAL_ERROR_MSG;
-use INVALID_UTF8;
-use args::{AnyArg, ArgMatcher, MatchedArg};
-use args::settings::ArgSettings;
-use errors::{Error, ErrorKind};
-use errors::Result as ClapResult;
-use app::settings::AppSettings as AS;
-use app::parser::{ParseResult, Parser};
-use fmt::{Colorizer, ColorizerOption};
-use app::usage;
-
-pub struct Validator<'a, 'b, 'z>(&'z mut Parser<'a, 'b>)
-where
- 'a: 'b,
- 'b: 'z;
-
-impl<'a, 'b, 'z> Validator<'a, 'b, 'z> {
- pub fn new(p: &'z mut Parser<'a, 'b>) -> Self { Validator(p) }
-
- pub fn validate(
- &mut self,
- needs_val_of: ParseResult<'a>,
- subcmd_name: Option<String>,
- matcher: &mut ArgMatcher<'a>,
- ) -> ClapResult<()> {
- debugln!("Validator::validate;");
- let mut reqs_validated = false;
- self.0.add_env(matcher)?;
- self.0.add_defaults(matcher)?;
- if let ParseResult::Opt(a) = needs_val_of {
- debugln!("Validator::validate: needs_val_of={:?}", a);
- let o = {
- self.0
- .opts
- .iter()
- .find(|o| o.b.name == a)
- .expect(INTERNAL_ERROR_MSG)
- .clone()
- };
- self.validate_required(matcher)?;
- reqs_validated = true;
- let should_err = if let Some(v) = matcher.0.args.get(&*o.b.name) {
- v.vals.is_empty() && !(o.v.min_vals.is_some() && o.v.min_vals.unwrap() == 0)
- } else {
- true
- };
- if should_err {
- return Err(Error::empty_value(
- &o,
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- }
-
- if matcher.is_empty() && matcher.subcommand_name().is_none()
- && self.0.is_set(AS::ArgRequiredElseHelp)
- {
- let mut out = vec![];
- self.0.write_help_err(&mut out)?;
- return Err(Error {
- message: String::from_utf8_lossy(&*out).into_owned(),
- kind: ErrorKind::MissingArgumentOrSubcommand,
- info: None,
- });
- }
- self.validate_blacklist(matcher)?;
- if !(self.0.is_set(AS::SubcommandsNegateReqs) && subcmd_name.is_some()) && !reqs_validated {
- self.validate_required(matcher)?;
- }
- self.validate_matched_args(matcher)?;
- matcher.usage(usage::create_usage_with_title(self.0, &[]));
-
- Ok(())
- }
-
- fn validate_arg_values<A>(
- &self,
- arg: &A,
- ma: &MatchedArg,
- matcher: &ArgMatcher<'a>,
- ) -> ClapResult<()>
- where
- A: AnyArg<'a, 'b> + Display,
- {
- debugln!("Validator::validate_arg_values: arg={:?}", arg.name());
- for val in &ma.vals {
- if self.0.is_set(AS::StrictUtf8) && val.to_str().is_none() {
- debugln!(
- "Validator::validate_arg_values: invalid UTF-8 found in val {:?}",
- val
- );
- return Err(Error::invalid_utf8(
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- if let Some(p_vals) = arg.possible_vals() {
- debugln!("Validator::validate_arg_values: possible_vals={:?}", p_vals);
- let val_str = val.to_string_lossy();
- let ok = if arg.is_set(ArgSettings::CaseInsensitive) {
- p_vals.iter().any(|pv| pv.eq_ignore_ascii_case(&*val_str))
- } else {
- p_vals.contains(&&*val_str)
- };
- if !ok {
- return Err(Error::invalid_value(
- val_str,
- p_vals,
- arg,
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- }
- if !arg.is_set(ArgSettings::EmptyValues) && val.is_empty()
- && matcher.contains(&*arg.name())
- {
- debugln!("Validator::validate_arg_values: illegal empty val found");
- return Err(Error::empty_value(
- arg,
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- if let Some(vtor) = arg.validator() {
- debug!("Validator::validate_arg_values: checking validator...");
- if let Err(e) = vtor(val.to_string_lossy().into_owned()) {
- sdebugln!("error");
- return Err(Error::value_validation(Some(arg), e, self.0.color()));
- } else {
- sdebugln!("good");
- }
- }
- if let Some(vtor) = arg.validator_os() {
- debug!("Validator::validate_arg_values: checking validator_os...");
- if let Err(e) = vtor(val) {
- sdebugln!("error");
- return Err(Error::value_validation(
- Some(arg),
- (*e).to_string_lossy().to_string(),
- self.0.color(),
- ));
- } else {
- sdebugln!("good");
- }
- }
- }
- Ok(())
- }
-
- fn build_err(&self, name: &str, matcher: &ArgMatcher) -> ClapResult<()> {
- debugln!("build_err!: name={}", name);
- let mut c_with = find_from!(self.0, &name, blacklist, matcher);
- c_with = c_with.or(
- self.0.find_any_arg(name).map_or(None, |aa| aa.blacklist())
- .map_or(None,
- |bl| bl.iter().find(|arg| matcher.contains(arg)))
- .map_or(None, |an| self.0.find_any_arg(an))
- .map_or(None, |aa| Some(format!("{}", aa)))
- );
- debugln!("build_err!: '{:?}' conflicts with '{}'", c_with, &name);
-// matcher.remove(&name);
- let usg = usage::create_error_usage(self.0, matcher, None);
- if let Some(f) = find_by_name!(self.0, name, flags, iter) {
- debugln!("build_err!: It was a flag...");
- Err(Error::argument_conflict(f, c_with, &*usg, self.0.color()))
- } else if let Some(o) = find_by_name!(self.0, name, opts, iter) {
- debugln!("build_err!: It was an option...");
- Err(Error::argument_conflict(o, c_with, &*usg, self.0.color()))
- } else {
- match find_by_name!(self.0, name, positionals, values) {
- Some(p) => {
- debugln!("build_err!: It was a positional...");
- Err(Error::argument_conflict(p, c_with, &*usg, self.0.color()))
- },
- None => panic!(INTERNAL_ERROR_MSG)
- }
- }
- }
-
- fn validate_blacklist(&self, matcher: &mut ArgMatcher) -> ClapResult<()> {
- debugln!("Validator::validate_blacklist;");
- let mut conflicts: Vec<&str> = vec![];
- for (&name, _) in matcher.iter() {
- debugln!("Validator::validate_blacklist:iter:{};", name);
- if let Some(grps) = self.0.groups_for_arg(name) {
- for grp in &grps {
- if let Some(g) = self.0.groups.iter().find(|g| &g.name == grp) {
- if !g.multiple {
- for arg in &g.args {
- if arg == &name {
- continue;
- }
- conflicts.push(arg);
- }
- }
- if let Some(ref gc) = g.conflicts {
- conflicts.extend(&*gc);
- }
- }
- }
- }
- if let Some(arg) = find_any_by_name!(self.0, name) {
- if let Some(bl) = arg.blacklist() {
- for conf in bl {
- if matcher.get(conf).is_some() {
- conflicts.push(conf);
- }
- }
- }
- } else {
- debugln!("Validator::validate_blacklist:iter:{}:group;", name);
- let args = self.0.arg_names_in_group(name);
- for arg in &args {
- debugln!("Validator::validate_blacklist:iter:{}:group:iter:{};", name, arg);
- if let Some(bl) = find_any_by_name!(self.0, *arg).unwrap().blacklist() {
- for conf in bl {
- if matcher.get(conf).is_some() {
- conflicts.push(conf);
- }
- }
- }
- }
- }
- }
-
- for name in &conflicts {
- debugln!(
- "Validator::validate_blacklist:iter:{}: Checking blacklisted arg",
- name
- );
- let mut should_err = false;
- if self.0.groups.iter().any(|g| &g.name == name) {
- debugln!(
- "Validator::validate_blacklist:iter:{}: groups contains it...",
- name
- );
- for n in self.0.arg_names_in_group(name) {
- debugln!(
- "Validator::validate_blacklist:iter:{}:iter:{}: looking in group...",
- name,
- n
- );
- if matcher.contains(n) {
- debugln!(
- "Validator::validate_blacklist:iter:{}:iter:{}: matcher contains it...",
- name,
- n
- );
- return self.build_err(n, matcher);
- }
- }
- } else if let Some(ma) = matcher.get(name) {
- debugln!(
- "Validator::validate_blacklist:iter:{}: matcher contains it...",
- name
- );
- should_err = ma.occurs > 0;
- }
- if should_err {
- return self.build_err(*name, matcher);
- }
- }
- Ok(())
- }
-
- fn validate_matched_args(&self, matcher: &mut ArgMatcher<'a>) -> ClapResult<()> {
- debugln!("Validator::validate_matched_args;");
- for (name, ma) in matcher.iter() {
- debugln!(
- "Validator::validate_matched_args:iter:{}: vals={:#?}",
- name,
- ma.vals
- );
- if let Some(opt) = find_by_name!(self.0, *name, opts, iter) {
- self.validate_arg_num_vals(opt, ma, matcher)?;
- self.validate_arg_values(opt, ma, matcher)?;
- self.validate_arg_requires(opt, ma, matcher)?;
- self.validate_arg_num_occurs(opt, ma, matcher)?;
- } else if let Some(flag) = find_by_name!(self.0, *name, flags, iter) {
- self.validate_arg_requires(flag, ma, matcher)?;
- self.validate_arg_num_occurs(flag, ma, matcher)?;
- } else if let Some(pos) = find_by_name!(self.0, *name, positionals, values) {
- self.validate_arg_num_vals(pos, ma, matcher)?;
- self.validate_arg_num_occurs(pos, ma, matcher)?;
- self.validate_arg_values(pos, ma, matcher)?;
- self.validate_arg_requires(pos, ma, matcher)?;
- } else {
- let grp = self.0
- .groups
- .iter()
- .find(|g| &g.name == name)
- .expect(INTERNAL_ERROR_MSG);
- if let Some(ref g_reqs) = grp.requires {
- if g_reqs.iter().any(|&n| !matcher.contains(n)) {
- return self.missing_required_error(matcher, None);
- }
- }
- }
- }
- Ok(())
- }
-
- fn validate_arg_num_occurs<A>(
- &self,
- a: &A,
- ma: &MatchedArg,
- matcher: &ArgMatcher,
- ) -> ClapResult<()>
- where
- A: AnyArg<'a, 'b> + Display,
- {
- debugln!("Validator::validate_arg_num_occurs: a={};", a.name());
- if ma.occurs > 1 && !a.is_set(ArgSettings::Multiple) {
- // Not the first time, and we don't allow multiples
- return Err(Error::unexpected_multiple_usage(
- a,
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- Ok(())
- }
-
- fn validate_arg_num_vals<A>(
- &self,
- a: &A,
- ma: &MatchedArg,
- matcher: &ArgMatcher,
- ) -> ClapResult<()>
- where
- A: AnyArg<'a, 'b> + Display,
- {
- debugln!("Validator::validate_arg_num_vals:{}", a.name());
- if let Some(num) = a.num_vals() {
- debugln!("Validator::validate_arg_num_vals: num_vals set...{}", num);
- let should_err = if a.is_set(ArgSettings::Multiple) {
- ((ma.vals.len() as u64) % num) != 0
- } else {
- num != (ma.vals.len() as u64)
- };
- if should_err {
- debugln!("Validator::validate_arg_num_vals: Sending error WrongNumberOfValues");
- return Err(Error::wrong_number_of_values(
- a,
- num,
- if a.is_set(ArgSettings::Multiple) {
- (ma.vals.len() % num as usize)
- } else {
- ma.vals.len()
- },
- if ma.vals.len() == 1
- || (a.is_set(ArgSettings::Multiple) && (ma.vals.len() % num as usize) == 1)
- {
- "as"
- } else {
- "ere"
- },
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- }
- if let Some(num) = a.max_vals() {
- debugln!("Validator::validate_arg_num_vals: max_vals set...{}", num);
- if (ma.vals.len() as u64) > num {
- debugln!("Validator::validate_arg_num_vals: Sending error TooManyValues");
- return Err(Error::too_many_values(
- ma.vals
- .iter()
- .last()
- .expect(INTERNAL_ERROR_MSG)
- .to_str()
- .expect(INVALID_UTF8),
- a,
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- }
- let min_vals_zero = if let Some(num) = a.min_vals() {
- debugln!("Validator::validate_arg_num_vals: min_vals set: {}", num);
- if (ma.vals.len() as u64) < num && num != 0 {
- debugln!("Validator::validate_arg_num_vals: Sending error TooFewValues");
- return Err(Error::too_few_values(
- a,
- num,
- ma.vals.len(),
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- num == 0
- } else {
- false
- };
- // Issue 665 (https://github.com/clap-rs/clap/issues/665)
- // Issue 1105 (https://github.com/clap-rs/clap/issues/1105)
- if a.takes_value() && !min_vals_zero && ma.vals.is_empty() {
- return Err(Error::empty_value(
- a,
- &*usage::create_error_usage(self.0, matcher, None),
- self.0.color(),
- ));
- }
- Ok(())
- }
-
- fn validate_arg_requires<A>(
- &self,
- a: &A,
- ma: &MatchedArg,
- matcher: &ArgMatcher,
- ) -> ClapResult<()>
- where
- A: AnyArg<'a, 'b> + Display,
- {
- debugln!("Validator::validate_arg_requires:{};", a.name());
- if let Some(a_reqs) = a.requires() {
- for &(val, name) in a_reqs.iter().filter(|&&(val, _)| val.is_some()) {
- let missing_req =
- |v| v == val.expect(INTERNAL_ERROR_MSG) && !matcher.contains(name);
- if ma.vals.iter().any(missing_req) {
- return self.missing_required_error(matcher, None);
- }
- }
- for &(_, name) in a_reqs.iter().filter(|&&(val, _)| val.is_none()) {
- if !matcher.contains(name) {
- return self.missing_required_error(matcher, Some(name));
- }
- }
- }
- Ok(())
- }
-
- fn validate_required(&mut self, matcher: &ArgMatcher) -> ClapResult<()> {
- debugln!(
- "Validator::validate_required: required={:?};",
- self.0.required
- );
-
- let mut should_err = false;
- let mut to_rem = Vec::new();
- for name in &self.0.required {
- debugln!("Validator::validate_required:iter:{}:", name);
- if matcher.contains(name) {
- continue;
- }
- if to_rem.contains(name) {
- continue;
- } else if let Some(a) = find_any_by_name!(self.0, *name) {
- if self.is_missing_required_ok(a, matcher) {
- to_rem.push(a.name());
- if let Some(reqs) = a.requires() {
- for r in reqs
- .iter()
- .filter(|&&(val, _)| val.is_none())
- .map(|&(_, name)| name)
- {
- to_rem.push(r);
- }
- }
- continue;
- }
- }
- should_err = true;
- break;
- }
- if should_err {
- for r in &to_rem {
- 'inner: for i in (0 .. self.0.required.len()).rev() {
- if &self.0.required[i] == r {
- self.0.required.swap_remove(i);
- break 'inner;
- }
- }
- }
- return self.missing_required_error(matcher, None);
- }
-
- // Validate the conditionally required args
- for &(a, v, r) in &self.0.r_ifs {
- if let Some(ma) = matcher.get(a) {
- if matcher.get(r).is_none() && ma.vals.iter().any(|val| val == v) {
- return self.missing_required_error(matcher, Some(r));
- }
- }
- }
- Ok(())
- }
-
- fn validate_arg_conflicts(&self, a: &AnyArg, matcher: &ArgMatcher) -> Option<bool> {
- debugln!("Validator::validate_arg_conflicts: a={:?};", a.name());
- a.blacklist().map(|bl| {
- bl.iter().any(|conf| {
- matcher.contains(conf)
- || self.0
- .groups
- .iter()
- .find(|g| &g.name == conf)
- .map_or(false, |g| g.args.iter().any(|arg| matcher.contains(arg)))
- })
- })
- }
-
- fn validate_required_unless(&self, a: &AnyArg, matcher: &ArgMatcher) -> Option<bool> {
- debugln!("Validator::validate_required_unless: a={:?};", a.name());
- macro_rules! check {
- ($how:ident, $_self:expr, $a:ident, $m:ident) => {{
- $a.required_unless().map(|ru| {
- ru.iter().$how(|n| {
- $m.contains(n) || {
- if let Some(grp) = $_self.groups.iter().find(|g| &g.name == n) {
- grp.args.iter().any(|arg| $m.contains(arg))
- } else {
- false
- }
- }
- })
- })
- }};
- }
- if a.is_set(ArgSettings::RequiredUnlessAll) {
- check!(all, self.0, a, matcher)
- } else {
- check!(any, self.0, a, matcher)
- }
- }
-
- fn missing_required_error(&self, matcher: &ArgMatcher, extra: Option<&str>) -> ClapResult<()> {
- debugln!("Validator::missing_required_error: extra={:?}", extra);
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: self.0.color(),
- });
- let mut reqs = self.0.required.iter().map(|&r| &*r).collect::<Vec<_>>();
- if let Some(r) = extra {
- reqs.push(r);
- }
- reqs.retain(|n| !matcher.contains(n));
- reqs.dedup();
- debugln!("Validator::missing_required_error: reqs={:#?}", reqs);
- let req_args =
- usage::get_required_usage_from(self.0, &reqs[..], Some(matcher), extra, true)
- .iter()
- .fold(String::new(), |acc, s| {
- acc + &format!("\n {}", c.error(s))[..]
- });
- debugln!(
- "Validator::missing_required_error: req_args={:#?}",
- req_args
- );
- Err(Error::missing_required_argument(
- &*req_args,
- &*usage::create_error_usage(self.0, matcher, extra),
- self.0.color(),
- ))
- }
-
- #[inline]
- fn is_missing_required_ok(&self, a: &AnyArg, matcher: &ArgMatcher) -> bool {
- debugln!("Validator::is_missing_required_ok: a={}", a.name());
- self.validate_arg_conflicts(a, matcher).unwrap_or(false)
- || self.validate_required_unless(a, matcher).unwrap_or(false)
- }
-}
diff --git a/clap/src/args/any_arg.rs b/clap/src/args/any_arg.rs
deleted file mode 100644
index eee5228..0000000
--- a/clap/src/args/any_arg.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Std
-use std::rc::Rc;
-use std::fmt as std_fmt;
-use std::ffi::{OsStr, OsString};
-
-// Internal
-use args::settings::ArgSettings;
-use map::{self, VecMap};
-use INTERNAL_ERROR_MSG;
-
-#[doc(hidden)]
-pub trait AnyArg<'n, 'e>: std_fmt::Display {
- fn name(&self) -> &'n str;
- fn overrides(&self) -> Option<&[&'e str]>;
- fn aliases(&self) -> Option<Vec<&'e str>>;
- fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]>;
- fn blacklist(&self) -> Option<&[&'e str]>;
- fn required_unless(&self) -> Option<&[&'e str]>;
- fn is_set(&self, ArgSettings) -> bool;
- fn set(&mut self, ArgSettings);
- fn has_switch(&self) -> bool;
- fn max_vals(&self) -> Option<u64>;
- fn min_vals(&self) -> Option<u64>;
- fn num_vals(&self) -> Option<u64>;
- fn possible_vals(&self) -> Option<&[&'e str]>;
- fn validator(&self) -> Option<&Rc<Fn(String) -> Result<(), String>>>;
- fn validator_os(&self) -> Option<&Rc<Fn(&OsStr) -> Result<(), OsString>>>;
- fn short(&self) -> Option<char>;
- fn long(&self) -> Option<&'e str>;
- fn val_delim(&self) -> Option<char>;
- fn takes_value(&self) -> bool;
- fn val_names(&self) -> Option<&VecMap<&'e str>>;
- fn help(&self) -> Option<&'e str>;
- fn long_help(&self) -> Option<&'e str>;
- fn default_val(&self) -> Option<&'e OsStr>;
- fn default_vals_ifs(&self) -> Option<map::Values<(&'n str, Option<&'e OsStr>, &'e OsStr)>>;
- fn env<'s>(&'s self) -> Option<(&'n OsStr, Option<&'s OsString>)>;
- fn longest_filter(&self) -> bool;
- fn val_terminator(&self) -> Option<&'e str>;
-}
-
-pub trait DispOrder {
- fn disp_ord(&self) -> usize;
-}
-
-impl<'n, 'e, 'z, T: ?Sized> AnyArg<'n, 'e> for &'z T where T: AnyArg<'n, 'e> + 'z {
- fn name(&self) -> &'n str { (*self).name() }
- fn overrides(&self) -> Option<&[&'e str]> { (*self).overrides() }
- fn aliases(&self) -> Option<Vec<&'e str>> { (*self).aliases() }
- fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]> { (*self).requires() }
- fn blacklist(&self) -> Option<&[&'e str]> { (*self).blacklist() }
- fn required_unless(&self) -> Option<&[&'e str]> { (*self).required_unless() }
- fn is_set(&self, a: ArgSettings) -> bool { (*self).is_set(a) }
- fn set(&mut self, _: ArgSettings) { panic!(INTERNAL_ERROR_MSG) }
- fn has_switch(&self) -> bool { (*self).has_switch() }
- fn max_vals(&self) -> Option<u64> { (*self).max_vals() }
- fn min_vals(&self) -> Option<u64> { (*self).min_vals() }
- fn num_vals(&self) -> Option<u64> { (*self).num_vals() }
- fn possible_vals(&self) -> Option<&[&'e str]> { (*self).possible_vals() }
- fn validator(&self) -> Option<&Rc<Fn(String) -> Result<(), String>>> { (*self).validator() }
- fn validator_os(&self) -> Option<&Rc<Fn(&OsStr) -> Result<(), OsString>>> { (*self).validator_os() }
- fn short(&self) -> Option<char> { (*self).short() }
- fn long(&self) -> Option<&'e str> { (*self).long() }
- fn val_delim(&self) -> Option<char> { (*self).val_delim() }
- fn takes_value(&self) -> bool { (*self).takes_value() }
- fn val_names(&self) -> Option<&VecMap<&'e str>> { (*self).val_names() }
- fn help(&self) -> Option<&'e str> { (*self).help() }
- fn long_help(&self) -> Option<&'e str> { (*self).long_help() }
- fn default_val(&self) -> Option<&'e OsStr> { (*self).default_val() }
- fn default_vals_ifs(&self) -> Option<map::Values<(&'n str, Option<&'e OsStr>, &'e OsStr)>> { (*self).default_vals_ifs() }
- fn env<'s>(&'s self) -> Option<(&'n OsStr, Option<&'s OsString>)> { (*self).env() }
- fn longest_filter(&self) -> bool { (*self).longest_filter() }
- fn val_terminator(&self) -> Option<&'e str> { (*self).val_terminator() }
-}
diff --git a/clap/src/args/arg.rs b/clap/src/args/arg.rs
deleted file mode 100644
index 50a30ab..0000000
--- a/clap/src/args/arg.rs
+++ /dev/null
@@ -1,3954 +0,0 @@
-#[cfg(feature = "yaml")]
-use std::collections::BTreeMap;
-use std::rc::Rc;
-use std::ffi::{OsStr, OsString};
-#[cfg(any(target_os = "windows", target_arch = "wasm32"))]
-use osstringext::OsStrExt3;
-#[cfg(not(any(target_os = "windows", target_arch = "wasm32")))]
-use std::os::unix::ffi::OsStrExt;
-use std::env;
-
-#[cfg(feature = "yaml")]
-use yaml_rust::Yaml;
-use map::VecMap;
-
-use usage_parser::UsageParser;
-use args::settings::ArgSettings;
-use args::arg_builder::{Base, Switched, Valued};
-
-/// The abstract representation of a command line argument. Used to set all the options and
-/// relationships that define a valid argument for the program.
-///
-/// There are two methods for constructing [`Arg`]s, using the builder pattern and setting options
-/// manually, or using a usage string which is far less verbose but has fewer options. You can also
-/// use a combination of the two methods to achieve the best of both worlds.
-///
-/// # Examples
-///
-/// ```rust
-/// # use clap::Arg;
-/// // Using the traditional builder pattern and setting each option manually
-/// let cfg = Arg::with_name("config")
-/// .short("c")
-/// .long("config")
-/// .takes_value(true)
-/// .value_name("FILE")
-/// .help("Provides a config file to myprog");
-/// // Using a usage string (setting a similar argument to the one above)
-/// let input = Arg::from_usage("-i, --input=[FILE] 'Provides an input file to the program'");
-/// ```
-/// [`Arg`]: ./struct.Arg.html
-#[allow(missing_debug_implementations)]
-#[derive(Default, Clone)]
-pub struct Arg<'a, 'b>
-where
- 'a: 'b,
-{
- #[doc(hidden)] pub b: Base<'a, 'b>,
- #[doc(hidden)] pub s: Switched<'b>,
- #[doc(hidden)] pub v: Valued<'a, 'b>,
- #[doc(hidden)] pub index: Option<u64>,
- #[doc(hidden)] pub r_ifs: Option<Vec<(&'a str, &'b str)>>,
-}
-
-impl<'a, 'b> Arg<'a, 'b> {
- /// Creates a new instance of [`Arg`] using a unique string name. The name will be used to get
- /// information about whether or not the argument was used at runtime, get values, set
- /// relationships with other args, etc..
- ///
- /// **NOTE:** In the case of arguments that take values (i.e. [`Arg::takes_value(true)`])
- /// and positional arguments (i.e. those without a preceding `-` or `--`) the name will also
- /// be displayed when the user prints the usage/help information of the program.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// # ;
- /// ```
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- /// [`Arg`]: ./struct.Arg.html
- pub fn with_name(n: &'a str) -> Self {
- Arg {
- b: Base::new(n),
- ..Default::default()
- }
- }
-
- /// Creates a new instance of [`Arg`] from a .yml (YAML) file.
- ///
- /// # Examples
- ///
- /// ```ignore
- /// # #[macro_use]
- /// # extern crate clap;
- /// # use clap::Arg;
- /// # fn main() {
- /// let yml = load_yaml!("arg.yml");
- /// let arg = Arg::from_yaml(yml);
- /// # }
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- #[cfg(feature = "yaml")]
- pub fn from_yaml(y: &BTreeMap<Yaml, Yaml>) -> Arg {
- // We WANT this to panic on error...so expect() is good.
- let name_yml = y.keys().nth(0).unwrap();
- let name_str = name_yml.as_str().unwrap();
- let mut a = Arg::with_name(name_str);
- let arg_settings = y.get(name_yml).unwrap().as_hash().unwrap();
-
- for (k, v) in arg_settings.iter() {
- a = match k.as_str().unwrap() {
- "short" => yaml_to_str!(a, v, short),
- "long" => yaml_to_str!(a, v, long),
- "aliases" => yaml_vec_or_str!(v, a, alias),
- "help" => yaml_to_str!(a, v, help),
- "long_help" => yaml_to_str!(a, v, long_help),
- "required" => yaml_to_bool!(a, v, required),
- "required_if" => yaml_tuple2!(a, v, required_if),
- "required_ifs" => yaml_tuple2!(a, v, required_if),
- "takes_value" => yaml_to_bool!(a, v, takes_value),
- "index" => yaml_to_u64!(a, v, index),
- "global" => yaml_to_bool!(a, v, global),
- "multiple" => yaml_to_bool!(a, v, multiple),
- "hidden" => yaml_to_bool!(a, v, hidden),
- "next_line_help" => yaml_to_bool!(a, v, next_line_help),
- "empty_values" => yaml_to_bool!(a, v, empty_values),
- "group" => yaml_to_str!(a, v, group),
- "number_of_values" => yaml_to_u64!(a, v, number_of_values),
- "max_values" => yaml_to_u64!(a, v, max_values),
- "min_values" => yaml_to_u64!(a, v, min_values),
- "value_name" => yaml_to_str!(a, v, value_name),
- "use_delimiter" => yaml_to_bool!(a, v, use_delimiter),
- "allow_hyphen_values" => yaml_to_bool!(a, v, allow_hyphen_values),
- "last" => yaml_to_bool!(a, v, last),
- "require_delimiter" => yaml_to_bool!(a, v, require_delimiter),
- "value_delimiter" => yaml_to_str!(a, v, value_delimiter),
- "required_unless" => yaml_to_str!(a, v, required_unless),
- "display_order" => yaml_to_usize!(a, v, display_order),
- "default_value" => yaml_to_str!(a, v, default_value),
- "default_value_if" => yaml_tuple3!(a, v, default_value_if),
- "default_value_ifs" => yaml_tuple3!(a, v, default_value_if),
- "env" => yaml_to_str!(a, v, env),
- "value_names" => yaml_vec_or_str!(v, a, value_name),
- "groups" => yaml_vec_or_str!(v, a, group),
- "requires" => yaml_vec_or_str!(v, a, requires),
- "requires_if" => yaml_tuple2!(a, v, requires_if),
- "requires_ifs" => yaml_tuple2!(a, v, requires_if),
- "conflicts_with" => yaml_vec_or_str!(v, a, conflicts_with),
- "overrides_with" => yaml_vec_or_str!(v, a, overrides_with),
- "possible_values" => yaml_vec_or_str!(v, a, possible_value),
- "case_insensitive" => yaml_to_bool!(a, v, case_insensitive),
- "required_unless_one" => yaml_vec_or_str!(v, a, required_unless),
- "required_unless_all" => {
- a = yaml_vec_or_str!(v, a, required_unless);
- a.setb(ArgSettings::RequiredUnlessAll);
- a
- }
- s => panic!(
- "Unknown Arg setting '{}' in YAML file for arg '{}'",
- s, name_str
- ),
- }
- }
-
- a
- }
-
- /// Creates a new instance of [`Arg`] from a usage string. Allows creation of basic settings
- /// for the [`Arg`]. The syntax is flexible, but there are some rules to follow.
- ///
- /// **NOTE**: Not all settings may be set using the usage string method. Some properties are
- /// only available via the builder pattern.
- ///
- /// **NOTE**: Only ASCII values are officially supported in [`Arg::from_usage`] strings. Some
- /// UTF-8 codepoints may work just fine, but this is not guaranteed.
- ///
- /// # Syntax
- ///
- /// Usage strings typically following the form:
- ///
- /// ```notrust
- /// [explicit name] [short] [long] [value names] [help string]
- /// ```
- ///
- /// This is not a hard rule as the attributes can appear in other orders. There are also
- /// several additional sigils which denote additional settings. Below are the details of each
- /// portion of the string.
- ///
- /// ### Explicit Name
- ///
- /// This is an optional field, if it's omitted the argument will use one of the additional
- /// fields as the name using the following priority order:
- ///
- /// * Explicit Name (This always takes precedence when present)
- /// * Long
- /// * Short
- /// * Value Name
- ///
- /// `clap` determines explicit names as the first string of characters between either `[]` or
- /// `<>` where `[]` has the dual notation of meaning the argument is optional, and `<>` meaning
- /// the argument is required.
- ///
- /// Explicit names may be followed by:
- /// * The multiple denotation `...`
- ///
- /// Example explicit names as follows (`ename` for an optional argument, and `rname` for a
- /// required argument):
- ///
- /// ```notrust
- /// [ename] -s, --long 'some flag'
- /// <rname> -r, --longer 'some other flag'
- /// ```
- ///
- /// ### Short
- ///
- /// This is set by placing a single character after a leading `-`.
- ///
- /// Shorts may be followed by
- /// * The multiple denotation `...`
- /// * An optional comma `,` which is cosmetic only
- /// * Value notation
- ///
- /// Example shorts are as follows (`-s`, and `-r`):
- ///
- /// ```notrust
- /// -s, --long 'some flag'
- /// <rname> -r [val], --longer 'some option'
- /// ```
- ///
- /// ### Long
- ///
- /// This is set by placing a word (no spaces) after a leading `--`.
- ///
- /// Shorts may be followed by
- /// * The multiple denotation `...`
- /// * Value notation
- ///
- /// Example longs are as follows (`--some`, and `--rapid`):
- ///
- /// ```notrust
- /// -s, --some 'some flag'
- /// --rapid=[FILE] 'some option'
- /// ```
- ///
- /// ### Values (Value Notation)
- ///
- /// This is set by placing a word(s) between `[]` or `<>` optionally after `=` (although this
- /// is cosmetic only and does not affect functionality). If an explicit name has **not** been
- /// set, using `<>` will denote a required argument, and `[]` will denote an optional argument
- ///
- /// Values may be followed by
- /// * The multiple denotation `...`
- /// * More Value notation
- ///
- /// More than one value will also implicitly set the arguments number of values, i.e. having
- /// two values, `--option [val1] [val2]` specifies that in order for option to be satisified it
- /// must receive exactly two values
- ///
- /// Example values are as follows (`FILE`, and `SPEED`):
- ///
- /// ```notrust
- /// -s, --some [FILE] 'some option'
- /// --rapid=<SPEED>... 'some required multiple option'
- /// ```
- ///
- /// ### Help String
- ///
- /// The help string is denoted between a pair of single quotes `''` and may contain any
- /// characters.
- ///
- /// Example help strings are as follows:
- ///
- /// ```notrust
- /// -s, --some [FILE] 'some option'
- /// --rapid=<SPEED>... 'some required multiple option'
- /// ```
- ///
- /// ### Additional Sigils
- ///
- /// Multiple notation `...` (three consecutive dots/periods) specifies that this argument may
- /// be used multiple times. Do not confuse multiple occurrences (`...`) with multiple values.
- /// `--option val1 val2` is a single occurrence with multiple values. `--flag --flag` is
- /// multiple occurrences (and then you can obviously have instances of both as well)
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// App::new("prog")
- /// .args(&[
- /// Arg::from_usage("--config <FILE> 'a required file for the configuration and no short'"),
- /// Arg::from_usage("-d, --debug... 'turns on debugging information and allows multiples'"),
- /// Arg::from_usage("[input] 'an optional input file to use'")
- /// ])
- /// # ;
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- /// [`Arg::from_usage`]: ./struct.Arg.html#method.from_usage
- pub fn from_usage(u: &'a str) -> Self {
- let parser = UsageParser::from_usage(u);
- parser.parse()
- }
-
- /// Sets the short version of the argument without the preceding `-`.
- ///
- /// By default `clap` automatically assigns `V` and `h` to the auto-generated `version` and
- /// `help` arguments respectively. You may use the uppercase `V` or lowercase `h` for your own
- /// arguments, in which case `clap` simply will not assign those to the auto-generated
- /// `version` or `help` arguments.
- ///
- /// **NOTE:** Any leading `-` characters will be stripped, and only the first
- /// non `-` character will be used as the [`short`] version
- ///
- /// # Examples
- ///
- /// To set [`short`] use a single valid UTF-8 code point. If you supply a leading `-` such as
- /// `-c`, the `-` will be stripped.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .short("c")
- /// # ;
- /// ```
- ///
- /// Setting [`short`] allows using the argument via a single hyphen (`-`) such as `-c`
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("config")
- /// .short("c"))
- /// .get_matches_from(vec![
- /// "prog", "-c"
- /// ]);
- ///
- /// assert!(m.is_present("config"));
- /// ```
- /// [`short`]: ./struct.Arg.html#method.short
- pub fn short<S: AsRef<str>>(mut self, s: S) -> Self {
- self.s.short = s.as_ref().trim_left_matches(|c| c == '-').chars().nth(0);
- self
- }
-
- /// Sets the long version of the argument without the preceding `--`.
- ///
- /// By default `clap` automatically assigns `version` and `help` to the auto-generated
- /// `version` and `help` arguments respectively. You may use the word `version` or `help` for
- /// the long form of your own arguments, in which case `clap` simply will not assign those to
- /// the auto-generated `version` or `help` arguments.
- ///
- /// **NOTE:** Any leading `-` characters will be stripped
- ///
- /// # Examples
- ///
- /// To set `long` use a word containing valid UTF-8 codepoints. If you supply a double leading
- /// `--` such as `--config` they will be stripped. Hyphens in the middle of the word, however,
- /// will *not* be stripped (i.e. `config-file` is allowed)
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("cfg")
- /// .long("config")
- /// # ;
- /// ```
- ///
- /// Setting `long` allows using the argument via a double hyphen (`--`) such as `--config`
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config"))
- /// .get_matches_from(vec![
- /// "prog", "--config"
- /// ]);
- ///
- /// assert!(m.is_present("cfg"));
- /// ```
- pub fn long(mut self, l: &'b str) -> Self {
- self.s.long = Some(l.trim_left_matches(|c| c == '-'));
- self
- }
-
- /// Allows adding a [`Arg`] alias, which function as "hidden" arguments that
- /// automatically dispatch as if this argument was used. This is more efficient, and easier
- /// than creating multiple hidden arguments as one only needs to check for the existence of
- /// this command, and not all variants.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("test")
- /// .long("test")
- /// .alias("alias")
- /// .takes_value(true))
- /// .get_matches_from(vec![
- /// "prog", "--alias", "cool"
- /// ]);
- /// assert!(m.is_present("test"));
- /// assert_eq!(m.value_of("test"), Some("cool"));
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- pub fn alias<S: Into<&'b str>>(mut self, name: S) -> Self {
- if let Some(ref mut als) = self.s.aliases {
- als.push((name.into(), false));
- } else {
- self.s.aliases = Some(vec![(name.into(), false)]);
- }
- self
- }
-
- /// Allows adding [`Arg`] aliases, which function as "hidden" arguments that
- /// automatically dispatch as if this argument was used. This is more efficient, and easier
- /// than creating multiple hidden subcommands as one only needs to check for the existence of
- /// this command, and not all variants.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("test")
- /// .long("test")
- /// .aliases(&["do-stuff", "do-tests", "tests"])
- /// .help("the file to add")
- /// .required(false))
- /// .get_matches_from(vec![
- /// "prog", "--do-tests"
- /// ]);
- /// assert!(m.is_present("test"));
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- pub fn aliases(mut self, names: &[&'b str]) -> Self {
- if let Some(ref mut als) = self.s.aliases {
- for n in names {
- als.push((n, false));
- }
- } else {
- self.s.aliases = Some(names.iter().map(|n| (*n, false)).collect::<Vec<_>>());
- }
- self
- }
-
- /// Allows adding a [`Arg`] alias that functions exactly like those defined with
- /// [`Arg::alias`], except that they are visible inside the help message.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("test")
- /// .visible_alias("something-awesome")
- /// .long("test")
- /// .takes_value(true))
- /// .get_matches_from(vec![
- /// "prog", "--something-awesome", "coffee"
- /// ]);
- /// assert!(m.is_present("test"));
- /// assert_eq!(m.value_of("test"), Some("coffee"));
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- /// [`App::alias`]: ./struct.Arg.html#method.alias
- pub fn visible_alias<S: Into<&'b str>>(mut self, name: S) -> Self {
- if let Some(ref mut als) = self.s.aliases {
- als.push((name.into(), true));
- } else {
- self.s.aliases = Some(vec![(name.into(), true)]);
- }
- self
- }
-
- /// Allows adding multiple [`Arg`] aliases that functions exactly like those defined
- /// with [`Arg::aliases`], except that they are visible inside the help message.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("test")
- /// .long("test")
- /// .visible_aliases(&["something", "awesome", "cool"]))
- /// .get_matches_from(vec![
- /// "prog", "--awesome"
- /// ]);
- /// assert!(m.is_present("test"));
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- /// [`App::aliases`]: ./struct.Arg.html#method.aliases
- pub fn visible_aliases(mut self, names: &[&'b str]) -> Self {
- if let Some(ref mut als) = self.s.aliases {
- for n in names {
- als.push((n, true));
- }
- } else {
- self.s.aliases = Some(names.iter().map(|n| (*n, true)).collect::<Vec<_>>());
- }
- self
- }
-
- /// Sets the short help text of the argument that will be displayed to the user when they print
- /// the help information with `-h`. Typically, this is a short (one line) description of the
- /// arg.
- ///
- /// **NOTE:** If only `Arg::help` is provided, and not [`Arg::long_help`] but the user requests
- /// `--help` clap will still display the contents of `help` appropriately
- ///
- /// **NOTE:** Only `Arg::help` is used in completion script generation in order to be concise
- ///
- /// # Examples
- ///
- /// Any valid UTF-8 is allowed in the help text. The one exception is when one wishes to
- /// include a newline in the help text and have the following text be properly aligned with all
- /// the other help text.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .help("The config file used by the myprog")
- /// # ;
- /// ```
- ///
- /// Setting `help` displays a short message to the side of the argument when the user passes
- /// `-h` or `--help` (by default).
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .help("Some help text describing the --config arg"))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// --config Some help text describing the --config arg
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- /// ```
- /// [`Arg::long_help`]: ./struct.Arg.html#method.long_help
- pub fn help(mut self, h: &'b str) -> Self {
- self.b.help = Some(h);
- self
- }
-
- /// Sets the long help text of the argument that will be displayed to the user when they print
- /// the help information with `--help`. Typically this a more detailed (multi-line) message
- /// that describes the arg.
- ///
- /// **NOTE:** If only `long_help` is provided, and not [`Arg::help`] but the user requests `-h`
- /// clap will still display the contents of `long_help` appropriately
- ///
- /// **NOTE:** Only [`Arg::help`] is used in completion script generation in order to be concise
- ///
- /// # Examples
- ///
- /// Any valid UTF-8 is allowed in the help text. The one exception is when one wishes to
- /// include a newline in the help text and have the following text be properly aligned with all
- /// the other help text.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .long_help(
- /// "The config file used by the myprog must be in JSON format
- /// with only valid keys and may not contain other nonsense
- /// that cannot be read by this program. Obviously I'm going on
- /// and on, so I'll stop now.")
- /// # ;
- /// ```
- ///
- /// Setting `help` displays a short message to the side of the argument when the user passes
- /// `-h` or `--help` (by default).
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .long_help(
- /// "The config file used by the myprog must be in JSON format
- /// with only valid keys and may not contain other nonsense
- /// that cannot be read by this program. Obviously I'm going on
- /// and on, so I'll stop now."))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// --config
- /// The config file used by the myprog must be in JSON format
- /// with only valid keys and may not contain other nonsense
- /// that cannot be read by this program. Obviously I'm going on
- /// and on, so I'll stop now.
- ///
- /// -h, --help
- /// Prints help information
- ///
- /// -V, --version
- /// Prints version information
- /// ```
- /// [`Arg::help`]: ./struct.Arg.html#method.help
- pub fn long_help(mut self, h: &'b str) -> Self {
- self.b.long_help = Some(h);
- self
- }
-
- /// Specifies that this arg is the last, or final, positional argument (i.e. has the highest
- /// index) and is *only* able to be accessed via the `--` syntax (i.e. `$ prog args --
- /// last_arg`). Even, if no other arguments are left to parse, if the user omits the `--` syntax
- /// they will receive an [`UnknownArgument`] error. Setting an argument to `.last(true)` also
- /// allows one to access this arg early using the `--` syntax. Accessing an arg early, even with
- /// the `--` syntax is otherwise not possible.
- ///
- /// **NOTE:** This will change the usage string to look like `$ prog [FLAGS] [-- <ARG>]` if
- /// `ARG` is marked as `.last(true)`.
- ///
- /// **NOTE:** This setting will imply [`AppSettings::DontCollapseArgsInUsage`] because failing
- /// to set this can make the usage string very confusing.
- ///
- /// **NOTE**: This setting only applies to positional arguments, and has no affect on FLAGS /
- /// OPTIONS
- ///
- /// **CAUTION:** Setting an argument to `.last(true)` *and* having child subcommands is not
- /// recommended with the exception of *also* using [`AppSettings::ArgsNegateSubcommands`]
- /// (or [`AppSettings::SubcommandsNegateReqs`] if the argument marked `.last(true)` is also
- /// marked [`.required(true)`])
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("args")
- /// .last(true)
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::last(true)`] ensures the arg has the highest [index] of all positional args
- /// and requires that the `--` syntax be used to access it early.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("first"))
- /// .arg(Arg::with_name("second"))
- /// .arg(Arg::with_name("third").last(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "one", "--", "three"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// let m = res.unwrap();
- /// assert_eq!(m.value_of("third"), Some("three"));
- /// assert!(m.value_of("second").is_none());
- /// ```
- ///
- /// Even if the positional argument marked `.last(true)` is the only argument left to parse,
- /// failing to use the `--` syntax results in an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("first"))
- /// .arg(Arg::with_name("second"))
- /// .arg(Arg::with_name("third").last(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "one", "two", "three"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- /// [`Arg::last(true)`]: ./struct.Arg.html#method.last
- /// [index]: ./struct.Arg.html#method.index
- /// [`AppSettings::DontCollapseArgsInUsage`]: ./enum.AppSettings.html#variant.DontCollapseArgsInUsage
- /// [`AppSettings::ArgsNegateSubcommands`]: ./enum.AppSettings.html#variant.ArgsNegateSubcommands
- /// [`AppSettings::SubcommandsNegateReqs`]: ./enum.AppSettings.html#variant.SubcommandsNegateReqs
- /// [`.required(true)`]: ./struct.Arg.html#method.required
- /// [`UnknownArgument`]: ./enum.ErrorKind.html#variant.UnknownArgument
- pub fn last(self, l: bool) -> Self {
- if l {
- self.set(ArgSettings::Last)
- } else {
- self.unset(ArgSettings::Last)
- }
- }
-
- /// Sets whether or not the argument is required by default. Required by default means it is
- /// required, when no other conflicting rules have been evaluated. Conflicting rules take
- /// precedence over being required. **Default:** `false`
- ///
- /// **NOTE:** Flags (i.e. not positional, or arguments that take values) cannot be required by
- /// default. This is simply because if a flag should be required, it should simply be implied
- /// as no additional information is required from user. Flags by their very nature are simply
- /// yes/no, or true/false.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .required(true)
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::required(true)`] requires that the argument be used at runtime.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required(true)
- /// .takes_value(true)
- /// .long("config"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "file.conf"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// ```
- ///
- /// Setting [`Arg::required(true)`] and *not* supplying that argument is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required(true)
- /// .takes_value(true)
- /// .long("config"))
- /// .get_matches_from_safe(vec![
- /// "prog"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::required(true)`]: ./struct.Arg.html#method.required
- pub fn required(self, r: bool) -> Self {
- if r {
- self.set(ArgSettings::Required)
- } else {
- self.unset(ArgSettings::Required)
- }
- }
-
- /// Requires that options use the `--option=val` syntax (i.e. an equals between the option and
- /// associated value) **Default:** `false`
- ///
- /// **NOTE:** This setting also removes the default of allowing empty values and implies
- /// [`Arg::empty_values(false)`].
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .long("config")
- /// .takes_value(true)
- /// .require_equals(true)
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::require_equals(true)`] requires that the option have an equals sign between
- /// it and the associated value.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .require_equals(true)
- /// .takes_value(true)
- /// .long("config"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config=file.conf"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// ```
- ///
- /// Setting [`Arg::require_equals(true)`] and *not* supplying the equals will cause an error
- /// unless [`Arg::empty_values(true)`] is set.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .require_equals(true)
- /// .takes_value(true)
- /// .long("config"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "file.conf"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
- /// ```
- /// [`Arg::require_equals(true)`]: ./struct.Arg.html#method.require_equals
- /// [`Arg::empty_values(true)`]: ./struct.Arg.html#method.empty_values
- /// [`Arg::empty_values(false)`]: ./struct.Arg.html#method.empty_values
- pub fn require_equals(mut self, r: bool) -> Self {
- if r {
- self.unsetb(ArgSettings::EmptyValues);
- self.set(ArgSettings::RequireEquals)
- } else {
- self.unset(ArgSettings::RequireEquals)
- }
- }
-
- /// Allows values which start with a leading hyphen (`-`)
- ///
- /// **WARNING**: Take caution when using this setting combined with [`Arg::multiple(true)`], as
- /// this becomes ambiguous `$ prog --arg -- -- val`. All three `--, --, val` will be values
- /// when the user may have thought the second `--` would constitute the normal, "Only
- /// positional args follow" idiom. To fix this, consider using [`Arg::number_of_values(1)`]
- ///
- /// **WARNING**: When building your CLIs, consider the effects of allowing leading hyphens and
- /// the user passing in a value that matches a valid short. For example `prog -opt -F` where
- /// `-F` is supposed to be a value, yet `-F` is *also* a valid short for another arg. Care should
- /// should be taken when designing these args. This is compounded by the ability to "stack"
- /// short args. I.e. if `-val` is supposed to be a value, but `-v`, `-a`, and `-l` are all valid
- /// shorts.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("pattern")
- /// .allow_hyphen_values(true)
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("pat")
- /// .allow_hyphen_values(true)
- /// .takes_value(true)
- /// .long("pattern"))
- /// .get_matches_from(vec![
- /// "prog", "--pattern", "-file"
- /// ]);
- ///
- /// assert_eq!(m.value_of("pat"), Some("-file"));
- /// ```
- ///
- /// Not setting [`Arg::allow_hyphen_values(true)`] and supplying a value which starts with a
- /// hyphen is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("pat")
- /// .takes_value(true)
- /// .long("pattern"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--pattern", "-file"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- /// [`Arg::allow_hyphen_values(true)`]: ./struct.Arg.html#method.allow_hyphen_values
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- /// [`Arg::number_of_values(1)`]: ./struct.Arg.html#method.number_of_values
- pub fn allow_hyphen_values(self, a: bool) -> Self {
- if a {
- self.set(ArgSettings::AllowLeadingHyphen)
- } else {
- self.unset(ArgSettings::AllowLeadingHyphen)
- }
- }
- /// Sets an arg that override this arg's required setting. (i.e. this arg will be required
- /// unless this other argument is present).
- ///
- /// **Pro Tip:** Using [`Arg::required_unless`] implies [`Arg::required`] and is therefore not
- /// mandatory to also set.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .required_unless("debug")
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::required_unless(name)`] requires that the argument be used at runtime
- /// *unless* `name` is present. In the following example, the required argument is *not*
- /// provided, but it's not an error because the `unless` arg has been supplied.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_unless("dbg")
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("dbg")
- /// .long("debug"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--debug"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// ```
- ///
- /// Setting [`Arg::required_unless(name)`] and *not* supplying `name` or this arg is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_unless("dbg")
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("dbg")
- /// .long("debug"))
- /// .get_matches_from_safe(vec![
- /// "prog"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::required_unless`]: ./struct.Arg.html#method.required_unless
- /// [`Arg::required`]: ./struct.Arg.html#method.required
- /// [`Arg::required_unless(name)`]: ./struct.Arg.html#method.required_unless
- pub fn required_unless(mut self, name: &'a str) -> Self {
- if let Some(ref mut vec) = self.b.r_unless {
- vec.push(name);
- } else {
- self.b.r_unless = Some(vec![name]);
- }
- self.required(true)
- }
-
- /// Sets args that override this arg's required setting. (i.e. this arg will be required unless
- /// all these other arguments are present).
- ///
- /// **NOTE:** If you wish for this argument to only be required if *one of* these args are
- /// present see [`Arg::required_unless_one`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .required_unless_all(&["cfg", "dbg"])
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::required_unless_all(names)`] requires that the argument be used at runtime
- /// *unless* *all* the args in `names` are present. In the following example, the required
- /// argument is *not* provided, but it's not an error because all the `unless` args have been
- /// supplied.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_unless_all(&["dbg", "infile"])
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("dbg")
- /// .long("debug"))
- /// .arg(Arg::with_name("infile")
- /// .short("i")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "--debug", "-i", "file"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// ```
- ///
- /// Setting [`Arg::required_unless_all(names)`] and *not* supplying *all* of `names` or this
- /// arg is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_unless_all(&["dbg", "infile"])
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("dbg")
- /// .long("debug"))
- /// .arg(Arg::with_name("infile")
- /// .short("i")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![
- /// "prog"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::required_unless_one`]: ./struct.Arg.html#method.required_unless_one
- /// [`Arg::required_unless_all(names)`]: ./struct.Arg.html#method.required_unless_all
- pub fn required_unless_all(mut self, names: &[&'a str]) -> Self {
- if let Some(ref mut vec) = self.b.r_unless {
- for s in names {
- vec.push(s);
- }
- } else {
- self.b.r_unless = Some(names.iter().map(|s| *s).collect::<Vec<_>>());
- }
- self.setb(ArgSettings::RequiredUnlessAll);
- self.required(true)
- }
-
- /// Sets args that override this arg's [required] setting. (i.e. this arg will be required
- /// unless *at least one of* these other arguments are present).
- ///
- /// **NOTE:** If you wish for this argument to only be required if *all of* these args are
- /// present see [`Arg::required_unless_all`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .required_unless_all(&["cfg", "dbg"])
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::required_unless_one(names)`] requires that the argument be used at runtime
- /// *unless* *at least one of* the args in `names` are present. In the following example, the
- /// required argument is *not* provided, but it's not an error because one the `unless` args
- /// have been supplied.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_unless_one(&["dbg", "infile"])
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("dbg")
- /// .long("debug"))
- /// .arg(Arg::with_name("infile")
- /// .short("i")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "--debug"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// ```
- ///
- /// Setting [`Arg::required_unless_one(names)`] and *not* supplying *at least one of* `names`
- /// or this arg is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_unless_one(&["dbg", "infile"])
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("dbg")
- /// .long("debug"))
- /// .arg(Arg::with_name("infile")
- /// .short("i")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![
- /// "prog"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [required]: ./struct.Arg.html#method.required
- /// [`Arg::required_unless_one(names)`]: ./struct.Arg.html#method.required_unless_one
- /// [`Arg::required_unless_all`]: ./struct.Arg.html#method.required_unless_all
- pub fn required_unless_one(mut self, names: &[&'a str]) -> Self {
- if let Some(ref mut vec) = self.b.r_unless {
- for s in names {
- vec.push(s);
- }
- } else {
- self.b.r_unless = Some(names.iter().map(|s| *s).collect::<Vec<_>>());
- }
- self.required(true)
- }
-
- /// Sets a conflicting argument by name. I.e. when using this argument,
- /// the following argument can't be present and vice versa.
- ///
- /// **NOTE:** Conflicting rules take precedence over being required by default. Conflict rules
- /// only need to be set for one of the two arguments, they do not need to be set for each.
- ///
- /// **NOTE:** Defining a conflict is two-way, but does *not* need to defined for both arguments
- /// (i.e. if A conflicts with B, defining A.conflicts_with(B) is sufficient. You do not need
- /// need to also do B.conflicts_with(A))
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .conflicts_with("debug")
- /// # ;
- /// ```
- ///
- /// Setting conflicting argument, and having both arguments present at runtime is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .conflicts_with("debug")
- /// .long("config"))
- /// .arg(Arg::with_name("debug")
- /// .long("debug"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--debug", "--config", "file.conf"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::ArgumentConflict);
- /// ```
- pub fn conflicts_with(mut self, name: &'a str) -> Self {
- if let Some(ref mut vec) = self.b.blacklist {
- vec.push(name);
- } else {
- self.b.blacklist = Some(vec![name]);
- }
- self
- }
-
- /// The same as [`Arg::conflicts_with`] but allows specifying multiple two-way conlicts per
- /// argument.
- ///
- /// **NOTE:** Conflicting rules take precedence over being required by default. Conflict rules
- /// only need to be set for one of the two arguments, they do not need to be set for each.
- ///
- /// **NOTE:** Defining a conflict is two-way, but does *not* need to defined for both arguments
- /// (i.e. if A conflicts with B, defining A.conflicts_with(B) is sufficient. You do not need
- /// need to also do B.conflicts_with(A))
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .conflicts_with_all(&["debug", "input"])
- /// # ;
- /// ```
- ///
- /// Setting conflicting argument, and having any of the arguments present at runtime with a
- /// conflicting argument is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .conflicts_with_all(&["debug", "input"])
- /// .long("config"))
- /// .arg(Arg::with_name("debug")
- /// .long("debug"))
- /// .arg(Arg::with_name("input")
- /// .index(1))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "file.conf", "file.txt"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::ArgumentConflict);
- /// ```
- /// [`Arg::conflicts_with`]: ./struct.Arg.html#method.conflicts_with
- pub fn conflicts_with_all(mut self, names: &[&'a str]) -> Self {
- if let Some(ref mut vec) = self.b.blacklist {
- for s in names {
- vec.push(s);
- }
- } else {
- self.b.blacklist = Some(names.iter().map(|s| *s).collect::<Vec<_>>());
- }
- self
- }
-
- /// Sets a overridable argument by name. I.e. this argument and the following argument
- /// will override each other in POSIX style (whichever argument was specified at runtime
- /// **last** "wins")
- ///
- /// **NOTE:** When an argument is overridden it is essentially as if it never was used, any
- /// conflicts, requirements, etc. are evaluated **after** all "overrides" have been removed
- ///
- /// **WARNING:** Positional arguments cannot override themselves (or we would never be able
- /// to advance to the next positional). If a positional agument lists itself as an override,
- /// it is simply ignored.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::from_usage("-f, --flag 'some flag'")
- /// .conflicts_with("debug"))
- /// .arg(Arg::from_usage("-d, --debug 'other flag'"))
- /// .arg(Arg::from_usage("-c, --color 'third flag'")
- /// .overrides_with("flag"))
- /// .get_matches_from(vec![
- /// "prog", "-f", "-d", "-c"]);
- /// // ^~~~~~~~~~~~^~~~~ flag is overridden by color
- ///
- /// assert!(m.is_present("color"));
- /// assert!(m.is_present("debug")); // even though flag conflicts with debug, it's as if flag
- /// // was never used because it was overridden with color
- /// assert!(!m.is_present("flag"));
- /// ```
- /// Care must be taken when using this setting, and having an arg override with itself. This
- /// is common practice when supporting things like shell aliases, config files, etc.
- /// However, when combined with multiple values, it can get dicy.
- /// Here is how clap handles such situations:
- ///
- /// When a flag overrides itself, it's as if the flag was only ever used once (essentially
- /// preventing a "Unexpected multiple usage" error):
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("posix")
- /// .arg(Arg::from_usage("--flag 'some flag'").overrides_with("flag"))
- /// .get_matches_from(vec!["posix", "--flag", "--flag"]);
- /// assert!(m.is_present("flag"));
- /// assert_eq!(m.occurrences_of("flag"), 1);
- /// ```
- /// Making a arg `multiple(true)` and override itself is essentially meaningless. Therefore
- /// clap ignores an override of self if it's a flag and it already accepts multiple occurrences.
- ///
- /// ```
- /// # use clap::{App, Arg};
- /// let m = App::new("posix")
- /// .arg(Arg::from_usage("--flag... 'some flag'").overrides_with("flag"))
- /// .get_matches_from(vec!["", "--flag", "--flag", "--flag", "--flag"]);
- /// assert!(m.is_present("flag"));
- /// assert_eq!(m.occurrences_of("flag"), 4);
- /// ```
- /// Now notice with options (which *do not* set `multiple(true)`), it's as if only the last
- /// occurrence happened.
- ///
- /// ```
- /// # use clap::{App, Arg};
- /// let m = App::new("posix")
- /// .arg(Arg::from_usage("--opt [val] 'some option'").overrides_with("opt"))
- /// .get_matches_from(vec!["", "--opt=some", "--opt=other"]);
- /// assert!(m.is_present("opt"));
- /// assert_eq!(m.occurrences_of("opt"), 1);
- /// assert_eq!(m.value_of("opt"), Some("other"));
- /// ```
- ///
- /// Just like flags, options with `multiple(true)` set, will ignore the "override self" setting.
- ///
- /// ```
- /// # use clap::{App, Arg};
- /// let m = App::new("posix")
- /// .arg(Arg::from_usage("--opt [val]... 'some option'")
- /// .overrides_with("opt"))
- /// .get_matches_from(vec!["", "--opt", "first", "over", "--opt", "other", "val"]);
- /// assert!(m.is_present("opt"));
- /// assert_eq!(m.occurrences_of("opt"), 2);
- /// assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["first", "over", "other", "val"]);
- /// ```
- ///
- /// A safe thing to do if you'd like to support an option which supports multiple values, but
- /// also is "overridable" by itself, is to use `use_delimiter(false)` and *not* use
- /// `multiple(true)` while telling users to seperate values with a comma (i.e. `val1,val2`)
- ///
- /// ```
- /// # use clap::{App, Arg};
- /// let m = App::new("posix")
- /// .arg(Arg::from_usage("--opt [val] 'some option'")
- /// .overrides_with("opt")
- /// .use_delimiter(false))
- /// .get_matches_from(vec!["", "--opt=some,other", "--opt=one,two"]);
- /// assert!(m.is_present("opt"));
- /// assert_eq!(m.occurrences_of("opt"), 1);
- /// assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["one,two"]);
- /// ```
- pub fn overrides_with(mut self, name: &'a str) -> Self {
- if let Some(ref mut vec) = self.b.overrides {
- vec.push(name);
- } else {
- self.b.overrides = Some(vec![name]);
- }
- self
- }
-
- /// Sets multiple mutually overridable arguments by name. I.e. this argument and the following
- /// argument will override each other in POSIX style (whichever argument was specified at
- /// runtime **last** "wins")
- ///
- /// **NOTE:** When an argument is overridden it is essentially as if it never was used, any
- /// conflicts, requirements, etc. are evaluated **after** all "overrides" have been removed
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::from_usage("-f, --flag 'some flag'")
- /// .conflicts_with("color"))
- /// .arg(Arg::from_usage("-d, --debug 'other flag'"))
- /// .arg(Arg::from_usage("-c, --color 'third flag'")
- /// .overrides_with_all(&["flag", "debug"]))
- /// .get_matches_from(vec![
- /// "prog", "-f", "-d", "-c"]);
- /// // ^~~~~~^~~~~~~~~ flag and debug are overridden by color
- ///
- /// assert!(m.is_present("color")); // even though flag conflicts with color, it's as if flag
- /// // and debug were never used because they were overridden
- /// // with color
- /// assert!(!m.is_present("debug"));
- /// assert!(!m.is_present("flag"));
- /// ```
- pub fn overrides_with_all(mut self, names: &[&'a str]) -> Self {
- if let Some(ref mut vec) = self.b.overrides {
- for s in names {
- vec.push(s);
- }
- } else {
- self.b.overrides = Some(names.iter().map(|s| *s).collect::<Vec<_>>());
- }
- self
- }
-
- /// Sets an argument by name that is required when this one is present I.e. when
- /// using this argument, the following argument *must* be present.
- ///
- /// **NOTE:** [Conflicting] rules and [override] rules take precedence over being required
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .requires("input")
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::requires(name)`] requires that the argument be used at runtime if the
- /// defining argument is used. If the defining argument isn't used, the other argument isn't
- /// required
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires("input")
- /// .long("config"))
- /// .arg(Arg::with_name("input")
- /// .index(1))
- /// .get_matches_from_safe(vec![
- /// "prog"
- /// ]);
- ///
- /// assert!(res.is_ok()); // We didn't use cfg, so input wasn't required
- /// ```
- ///
- /// Setting [`Arg::requires(name)`] and *not* supplying that argument is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires("input")
- /// .long("config"))
- /// .arg(Arg::with_name("input")
- /// .index(1))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "file.conf"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::requires(name)`]: ./struct.Arg.html#method.requires
- /// [Conflicting]: ./struct.Arg.html#method.conflicts_with
- /// [override]: ./struct.Arg.html#method.overrides_with
- pub fn requires(mut self, name: &'a str) -> Self {
- if let Some(ref mut vec) = self.b.requires {
- vec.push((None, name));
- } else {
- let mut vec = vec![];
- vec.push((None, name));
- self.b.requires = Some(vec);
- }
- self
- }
-
- /// Allows a conditional requirement. The requirement will only become valid if this arg's value
- /// equals `val`.
- ///
- /// **NOTE:** If using YAML the values should be laid out as follows
- ///
- /// ```yaml
- /// requires_if:
- /// - [val, arg]
- /// ```
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .requires_if("val", "arg")
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::requires_if(val, arg)`] requires that the `arg` be used at runtime if the
- /// defining argument's value is equal to `val`. If the defining argument is anything other than
- /// `val`, the other argument isn't required.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires_if("my.cfg", "other")
- /// .long("config"))
- /// .arg(Arg::with_name("other"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "some.cfg"
- /// ]);
- ///
- /// assert!(res.is_ok()); // We didn't use --config=my.cfg, so other wasn't required
- /// ```
- ///
- /// Setting [`Arg::requires_if(val, arg)`] and setting the value to `val` but *not* supplying
- /// `arg` is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires_if("my.cfg", "input")
- /// .long("config"))
- /// .arg(Arg::with_name("input"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "my.cfg"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::requires(name)`]: ./struct.Arg.html#method.requires
- /// [Conflicting]: ./struct.Arg.html#method.conflicts_with
- /// [override]: ./struct.Arg.html#method.overrides_with
- pub fn requires_if(mut self, val: &'b str, arg: &'a str) -> Self {
- if let Some(ref mut vec) = self.b.requires {
- vec.push((Some(val), arg));
- } else {
- self.b.requires = Some(vec![(Some(val), arg)]);
- }
- self
- }
-
- /// Allows multiple conditional requirements. The requirement will only become valid if this arg's value
- /// equals `val`.
- ///
- /// **NOTE:** If using YAML the values should be laid out as follows
- ///
- /// ```yaml
- /// requires_if:
- /// - [val, arg]
- /// - [val2, arg2]
- /// ```
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .requires_ifs(&[
- /// ("val", "arg"),
- /// ("other_val", "arg2"),
- /// ])
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::requires_ifs(&["val", "arg"])`] requires that the `arg` be used at runtime if the
- /// defining argument's value is equal to `val`. If the defining argument's value is anything other
- /// than `val`, `arg` isn't required.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires_ifs(&[
- /// ("special.conf", "opt"),
- /// ("other.conf", "other"),
- /// ])
- /// .long("config"))
- /// .arg(Arg::with_name("opt")
- /// .long("option")
- /// .takes_value(true))
- /// .arg(Arg::with_name("other"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "special.conf"
- /// ]);
- ///
- /// assert!(res.is_err()); // We used --config=special.conf so --option <val> is required
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::requires(name)`]: ./struct.Arg.html#method.requires
- /// [Conflicting]: ./struct.Arg.html#method.conflicts_with
- /// [override]: ./struct.Arg.html#method.overrides_with
- pub fn requires_ifs(mut self, ifs: &[(&'b str, &'a str)]) -> Self {
- if let Some(ref mut vec) = self.b.requires {
- for &(val, arg) in ifs {
- vec.push((Some(val), arg));
- }
- } else {
- let mut vec = vec![];
- for &(val, arg) in ifs {
- vec.push((Some(val), arg));
- }
- self.b.requires = Some(vec);
- }
- self
- }
-
- /// Allows specifying that an argument is [required] conditionally. The requirement will only
- /// become valid if the specified `arg`'s value equals `val`.
- ///
- /// **NOTE:** If using YAML the values should be laid out as follows
- ///
- /// ```yaml
- /// required_if:
- /// - [arg, val]
- /// ```
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .required_if("other_arg", "value")
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::required_if(arg, val)`] makes this arg required if the `arg` is used at
- /// runtime and it's value is equal to `val`. If the `arg`'s value is anything other than `val`,
- /// this argument isn't required.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .required_if("other", "special")
- /// .long("config"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "--other", "not-special"
- /// ]);
- ///
- /// assert!(res.is_ok()); // We didn't use --other=special, so "cfg" wasn't required
- /// ```
- ///
- /// Setting [`Arg::required_if(arg, val)`] and having `arg` used with a value of `val` but *not*
- /// using this arg is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .required_if("other", "special")
- /// .long("config"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "--other", "special"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::requires(name)`]: ./struct.Arg.html#method.requires
- /// [Conflicting]: ./struct.Arg.html#method.conflicts_with
- /// [required]: ./struct.Arg.html#method.required
- pub fn required_if(mut self, arg: &'a str, val: &'b str) -> Self {
- if let Some(ref mut vec) = self.r_ifs {
- vec.push((arg, val));
- } else {
- self.r_ifs = Some(vec![(arg, val)]);
- }
- self
- }
-
- /// Allows specifying that an argument is [required] based on multiple conditions. The
- /// conditions are set up in a `(arg, val)` style tuple. The requirement will only become valid
- /// if one of the specified `arg`'s value equals it's corresponding `val`.
- ///
- /// **NOTE:** If using YAML the values should be laid out as follows
- ///
- /// ```yaml
- /// required_if:
- /// - [arg, val]
- /// - [arg2, val2]
- /// ```
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .required_ifs(&[
- /// ("extra", "val"),
- /// ("option", "spec")
- /// ])
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::required_ifs(&[(arg, val)])`] makes this arg required if any of the `arg`s
- /// are used at runtime and it's corresponding value is equal to `val`. If the `arg`'s value is
- /// anything other than `val`, this argument isn't required.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_ifs(&[
- /// ("extra", "val"),
- /// ("option", "spec")
- /// ])
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("extra")
- /// .takes_value(true)
- /// .long("extra"))
- /// .arg(Arg::with_name("option")
- /// .takes_value(true)
- /// .long("option"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--option", "other"
- /// ]);
- ///
- /// assert!(res.is_ok()); // We didn't use --option=spec, or --extra=val so "cfg" isn't required
- /// ```
- ///
- /// Setting [`Arg::required_ifs(&[(arg, val)])`] and having any of the `arg`s used with it's
- /// value of `val` but *not* using this arg is an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .required_ifs(&[
- /// ("extra", "val"),
- /// ("option", "spec")
- /// ])
- /// .takes_value(true)
- /// .long("config"))
- /// .arg(Arg::with_name("extra")
- /// .takes_value(true)
- /// .long("extra"))
- /// .arg(Arg::with_name("option")
- /// .takes_value(true)
- /// .long("option"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--option", "spec"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`Arg::requires(name)`]: ./struct.Arg.html#method.requires
- /// [Conflicting]: ./struct.Arg.html#method.conflicts_with
- /// [required]: ./struct.Arg.html#method.required
- pub fn required_ifs(mut self, ifs: &[(&'a str, &'b str)]) -> Self {
- if let Some(ref mut vec) = self.r_ifs {
- for r_if in ifs {
- vec.push((r_if.0, r_if.1));
- }
- } else {
- let mut vec = vec![];
- for r_if in ifs {
- vec.push((r_if.0, r_if.1));
- }
- self.r_ifs = Some(vec);
- }
- self
- }
-
- /// Sets multiple arguments by names that are required when this one is present I.e. when
- /// using this argument, the following arguments *must* be present.
- ///
- /// **NOTE:** [Conflicting] rules and [override] rules take precedence over being required
- /// by default.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::Arg;
- /// Arg::with_name("config")
- /// .requires_all(&["input", "output"])
- /// # ;
- /// ```
- ///
- /// Setting [`Arg::requires_all(&[arg, arg2])`] requires that all the arguments be used at
- /// runtime if the defining argument is used. If the defining argument isn't used, the other
- /// argument isn't required
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires("input")
- /// .long("config"))
- /// .arg(Arg::with_name("input")
- /// .index(1))
- /// .arg(Arg::with_name("output")
- /// .index(2))
- /// .get_matches_from_safe(vec![
- /// "prog"
- /// ]);
- ///
- /// assert!(res.is_ok()); // We didn't use cfg, so input and output weren't required
- /// ```
- ///
- /// Setting [`Arg::requires_all(&[arg, arg2])`] and *not* supplying all the arguments is an
- /// error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .takes_value(true)
- /// .requires_all(&["input", "output"])
- /// .long("config"))
- /// .arg(Arg::with_name("input")
- /// .index(1))
- /// .arg(Arg::with_name("output")
- /// .index(2))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config", "file.conf", "in.txt"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// // We didn't use output
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [Conflicting]: ./struct.Arg.html#method.conflicts_with
- /// [override]: ./struct.Arg.html#method.overrides_with
- /// [`Arg::requires_all(&[arg, arg2])`]: ./struct.Arg.html#method.requires_all
- pub fn requires_all(mut self, names: &[&'a str]) -> Self {
- if let Some(ref mut vec) = self.b.requires {
- for s in names {
- vec.push((None, s));
- }
- } else {
- let mut vec = vec![];
- for s in names {
- vec.push((None, *s));
- }
- self.b.requires = Some(vec);
- }
- self
- }
-
- /// Specifies that the argument takes a value at run time.
- ///
- /// **NOTE:** values for arguments may be specified in any of the following methods
- ///
- /// * Using a space such as `-o value` or `--option value`
- /// * Using an equals and no space such as `-o=value` or `--option=value`
- /// * Use a short and no space such as `-ovalue`
- ///
- /// **NOTE:** By default, args which allow [multiple values] are delimited by commas, meaning
- /// `--option=val1,val2,val3` is three values for the `--option` argument. If you wish to
- /// change the delimiter to another character you can use [`Arg::value_delimiter(char)`],
- /// alternatively you can turn delimiting values **OFF** by using [`Arg::use_delimiter(false)`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .takes_value(true)
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .long("mode")
- /// .takes_value(true))
- /// .get_matches_from(vec![
- /// "prog", "--mode", "fast"
- /// ]);
- ///
- /// assert!(m.is_present("mode"));
- /// assert_eq!(m.value_of("mode"), Some("fast"));
- /// ```
- /// [`Arg::value_delimiter(char)`]: ./struct.Arg.html#method.value_delimiter
- /// [`Arg::use_delimiter(false)`]: ./struct.Arg.html#method.use_delimiter
- /// [multiple values]: ./struct.Arg.html#method.multiple
- pub fn takes_value(self, tv: bool) -> Self {
- if tv {
- self.set(ArgSettings::TakesValue)
- } else {
- self.unset(ArgSettings::TakesValue)
- }
- }
-
- /// Specifies if the possible values of an argument should be displayed in the help text or
- /// not. Defaults to `false` (i.e. show possible values)
- ///
- /// This is useful for args with many values, or ones which are explained elsewhere in the
- /// help text.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .hide_possible_values(true)
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .long("mode")
- /// .possible_values(&["fast", "slow"])
- /// .takes_value(true)
- /// .hide_possible_values(true));
- ///
- /// ```
- ///
- /// If we were to run the above program with `--help` the `[values: fast, slow]` portion of
- /// the help text would be omitted.
- pub fn hide_possible_values(self, hide: bool) -> Self {
- if hide {
- self.set(ArgSettings::HidePossibleValues)
- } else {
- self.unset(ArgSettings::HidePossibleValues)
- }
- }
-
- /// Specifies if the default value of an argument should be displayed in the help text or
- /// not. Defaults to `false` (i.e. show default value)
- ///
- /// This is useful when default behavior of an arg is explained elsewhere in the help text.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .hide_default_value(true)
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("connect")
- /// .arg(Arg::with_name("host")
- /// .long("host")
- /// .default_value("localhost")
- /// .hide_default_value(true));
- ///
- /// ```
- ///
- /// If we were to run the above program with `--help` the `[default: localhost]` portion of
- /// the help text would be omitted.
- pub fn hide_default_value(self, hide: bool) -> Self {
- if hide {
- self.set(ArgSettings::HideDefaultValue)
- } else {
- self.unset(ArgSettings::HideDefaultValue)
- }
- }
-
- /// Specifies the index of a positional argument **starting at** 1.
- ///
- /// **NOTE:** The index refers to position according to **other positional argument**. It does
- /// not define position in the argument list as a whole.
- ///
- /// **NOTE:** If no [`Arg::short`], or [`Arg::long`] have been defined, you can optionally
- /// leave off the `index` method, and the index will be assigned in order of evaluation.
- /// Utilizing the `index` method allows for setting indexes out of order
- ///
- /// **NOTE:** When utilized with [`Arg::multiple(true)`], only the **last** positional argument
- /// may be defined as multiple (i.e. with the highest index)
- ///
- /// # Panics
- ///
- /// Although not in this method directly, [`App`] will [`panic!`] if indexes are skipped (such
- /// as defining `index(1)` and `index(3)` but not `index(2)`, or a positional argument is
- /// defined as multiple and is not the highest index
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("config")
- /// .index(1)
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .index(1))
- /// .arg(Arg::with_name("debug")
- /// .long("debug"))
- /// .get_matches_from(vec![
- /// "prog", "--debug", "fast"
- /// ]);
- ///
- /// assert!(m.is_present("mode"));
- /// assert_eq!(m.value_of("mode"), Some("fast")); // notice index(1) means "first positional"
- /// // *not* first argument
- /// ```
- /// [`Arg::short`]: ./struct.Arg.html#method.short
- /// [`Arg::long`]: ./struct.Arg.html#method.long
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- /// [`App`]: ./struct.App.html
- /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
- pub fn index(mut self, idx: u64) -> Self {
- self.index = Some(idx);
- self
- }
-
- /// Specifies that the argument may appear more than once. For flags, this results
- /// in the number of occurrences of the flag being recorded. For example `-ddd` or `-d -d -d`
- /// would count as three occurrences. For options there is a distinct difference in multiple
- /// occurrences vs multiple values.
- ///
- /// For example, `--opt val1 val2` is one occurrence, but two values. Whereas
- /// `--opt val1 --opt val2` is two occurrences.
- ///
- /// **WARNING:**
- ///
- /// Setting `multiple(true)` for an [option] with no other details, allows multiple values
- /// **and** multiple occurrences because it isn't possible to have more occurrences than values
- /// for options. Because multiple values are allowed, `--option val1 val2 val3` is perfectly
- /// valid, be careful when designing a CLI where positional arguments are expected after a
- /// option which accepts multiple values, as `clap` will continue parsing *values* until it
- /// reaches the max or specific number of values defined, or another flag or option.
- ///
- /// **Pro Tip**:
- ///
- /// It's possible to define an option which allows multiple occurrences, but only one value per
- /// occurrence. To do this use [`Arg::number_of_values(1)`] in coordination with
- /// [`Arg::multiple(true)`].
- ///
- /// **WARNING:**
- ///
- /// When using args with `multiple(true)` on [options] or [positionals] (i.e. those args that
- /// accept values) and [subcommands], one needs to consider the possibility of an argument value
- /// being the same as a valid subcommand. By default `clap` will parse the argument in question
- /// as a value *only if* a value is possible at that moment. Otherwise it will be parsed as a
- /// subcommand. In effect, this means using `multiple(true)` with no additional parameters and
- /// a possible value that coincides with a subcommand name, the subcommand cannot be called
- /// unless another argument is passed first.
- ///
- /// As an example, consider a CLI with an option `--ui-paths=<paths>...` and subcommand `signer`
- ///
- /// The following would be parsed as values to `--ui-paths`.
- ///
- /// ```notrust
- /// $ program --ui-paths path1 path2 signer
- /// ```
- ///
- /// This is because `--ui-paths` accepts multiple values. `clap` will continue parsing values
- /// until another argument is reached and it knows `--ui-paths` is done.
- ///
- /// By adding additional parameters to `--ui-paths` we can solve this issue. Consider adding
- /// [`Arg::number_of_values(1)`] as discussed above. The following are all valid, and `signer`
- /// is parsed as both a subcommand and a value in the second case.
- ///
- /// ```notrust
- /// $ program --ui-paths path1 signer
- /// $ program --ui-paths path1 --ui-paths signer signer
- /// ```
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .short("d")
- /// .multiple(true)
- /// # ;
- /// ```
- /// An example with flags
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("verbose")
- /// .multiple(true)
- /// .short("v"))
- /// .get_matches_from(vec![
- /// "prog", "-v", "-v", "-v" // note, -vvv would have same result
- /// ]);
- ///
- /// assert!(m.is_present("verbose"));
- /// assert_eq!(m.occurrences_of("verbose"), 3);
- /// ```
- ///
- /// An example with options
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .multiple(true)
- /// .takes_value(true)
- /// .short("F"))
- /// .get_matches_from(vec![
- /// "prog", "-F", "file1", "file2", "file3"
- /// ]);
- ///
- /// assert!(m.is_present("file"));
- /// assert_eq!(m.occurrences_of("file"), 1); // notice only one occurrence
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2", "file3"]);
- /// ```
- /// This is functionally equivalent to the example above
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .multiple(true)
- /// .takes_value(true)
- /// .short("F"))
- /// .get_matches_from(vec![
- /// "prog", "-F", "file1", "-F", "file2", "-F", "file3"
- /// ]);
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2", "file3"]);
- ///
- /// assert!(m.is_present("file"));
- /// assert_eq!(m.occurrences_of("file"), 3); // Notice 3 occurrences
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2", "file3"]);
- /// ```
- ///
- /// A common mistake is to define an option which allows multiples, and a positional argument
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .multiple(true)
- /// .takes_value(true)
- /// .short("F"))
- /// .arg(Arg::with_name("word")
- /// .index(1))
- /// .get_matches_from(vec![
- /// "prog", "-F", "file1", "file2", "file3", "word"
- /// ]);
- ///
- /// assert!(m.is_present("file"));
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2", "file3", "word"]); // wait...what?!
- /// assert!(!m.is_present("word")); // but we clearly used word!
- /// ```
- /// The problem is clap doesn't know when to stop parsing values for "files". This is further
- /// compounded by if we'd said `word -F file1 file2` it would have worked fine, so it would
- /// appear to only fail sometimes...not good!
- ///
- /// A solution for the example above is to specify that `-F` only accepts one value, but is
- /// allowed to appear multiple times
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .multiple(true)
- /// .takes_value(true)
- /// .number_of_values(1)
- /// .short("F"))
- /// .arg(Arg::with_name("word")
- /// .index(1))
- /// .get_matches_from(vec![
- /// "prog", "-F", "file1", "-F", "file2", "-F", "file3", "word"
- /// ]);
- ///
- /// assert!(m.is_present("file"));
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2", "file3"]);
- /// assert!(m.is_present("word"));
- /// assert_eq!(m.value_of("word"), Some("word"));
- /// ```
- /// As a final example, notice if we define [`Arg::number_of_values(1)`] and try to run the
- /// problem example above, it would have been a runtime error with a pretty message to the
- /// user :)
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .multiple(true)
- /// .takes_value(true)
- /// .number_of_values(1)
- /// .short("F"))
- /// .arg(Arg::with_name("word")
- /// .index(1))
- /// .get_matches_from_safe(vec![
- /// "prog", "-F", "file1", "file2", "file3", "word"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- /// [option]: ./struct.Arg.html#method.takes_value
- /// [options]: ./struct.Arg.html#method.takes_value
- /// [subcommands]: ./struct.SubCommand.html
- /// [positionals]: ./struct.Arg.html#method.index
- /// [`Arg::number_of_values(1)`]: ./struct.Arg.html#method.number_of_values
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- pub fn multiple(self, multi: bool) -> Self {
- if multi {
- self.set(ArgSettings::Multiple)
- } else {
- self.unset(ArgSettings::Multiple)
- }
- }
-
- /// Specifies a value that *stops* parsing multiple values of a give argument. By default when
- /// one sets [`multiple(true)`] on an argument, clap will continue parsing values for that
- /// argument until it reaches another valid argument, or one of the other more specific settings
- /// for multiple values is used (such as [`min_values`], [`max_values`] or
- /// [`number_of_values`]).
- ///
- /// **NOTE:** This setting only applies to [options] and [positional arguments]
- ///
- /// **NOTE:** When the terminator is passed in on the command line, it is **not** stored as one
- /// of the values
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("vals")
- /// .takes_value(true)
- /// .multiple(true)
- /// .value_terminator(";")
- /// # ;
- /// ```
- /// The following example uses two arguments, a sequence of commands, and the location in which
- /// to perform them
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cmds")
- /// .multiple(true)
- /// .allow_hyphen_values(true)
- /// .value_terminator(";"))
- /// .arg(Arg::with_name("location"))
- /// .get_matches_from(vec![
- /// "prog", "find", "-type", "f", "-name", "special", ";", "/home/clap"
- /// ]);
- /// let cmds: Vec<_> = m.values_of("cmds").unwrap().collect();
- /// assert_eq!(&cmds, &["find", "-type", "f", "-name", "special"]);
- /// assert_eq!(m.value_of("location"), Some("/home/clap"));
- /// ```
- /// [options]: ./struct.Arg.html#method.takes_value
- /// [positional arguments]: ./struct.Arg.html#method.index
- /// [`multiple(true)`]: ./struct.Arg.html#method.multiple
- /// [`min_values`]: ./struct.Arg.html#method.min_values
- /// [`number_of_values`]: ./struct.Arg.html#method.number_of_values
- /// [`max_values`]: ./struct.Arg.html#method.max_values
- pub fn value_terminator(mut self, term: &'b str) -> Self {
- self.setb(ArgSettings::TakesValue);
- self.v.terminator = Some(term);
- self
- }
-
- /// Specifies that an argument can be matched to all child [`SubCommand`]s.
- ///
- /// **NOTE:** Global arguments *only* propagate down, **not** up (to parent commands), however
- /// their values once a user uses them will be propagated back up to parents. In effect, this
- /// means one should *define* all global arguments at the top level, however it doesn't matter
- /// where the user *uses* the global argument.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .short("d")
- /// .global(true)
- /// # ;
- /// ```
- ///
- /// For example, assume an application with two subcommands, and you'd like to define a
- /// `--verbose` flag that can be called on any of the subcommands and parent, but you don't
- /// want to clutter the source with three duplicate [`Arg`] definitions.
- ///
- /// ```rust
- /// # use clap::{App, Arg, SubCommand};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("verb")
- /// .long("verbose")
- /// .short("v")
- /// .global(true))
- /// .subcommand(SubCommand::with_name("test"))
- /// .subcommand(SubCommand::with_name("do-stuff"))
- /// .get_matches_from(vec![
- /// "prog", "do-stuff", "--verbose"
- /// ]);
- ///
- /// assert_eq!(m.subcommand_name(), Some("do-stuff"));
- /// let sub_m = m.subcommand_matches("do-stuff").unwrap();
- /// assert!(sub_m.is_present("verb"));
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [required]: ./struct.Arg.html#method.required
- /// [`ArgMatches`]: ./struct.ArgMatches.html
- /// [`ArgMatches::is_present("flag")`]: ./struct.ArgMatches.html#method.is_present
- /// [`Arg`]: ./struct.Arg.html
- pub fn global(self, g: bool) -> Self {
- if g {
- self.set(ArgSettings::Global)
- } else {
- self.unset(ArgSettings::Global)
- }
- }
-
- /// Allows an argument to accept explicitly empty values. An empty value must be specified at
- /// the command line with an explicit `""`, or `''`
- ///
- /// **NOTE:** Defaults to `true` (Explicitly empty values are allowed)
- ///
- /// **NOTE:** Implicitly sets [`Arg::takes_value(true)`] when set to `false`
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("file")
- /// .long("file")
- /// .empty_values(false)
- /// # ;
- /// ```
- /// The default is to allow empty values, such as `--option ""` would be an empty value. But
- /// we can change to make empty values become an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .short("v")
- /// .empty_values(false))
- /// .get_matches_from_safe(vec![
- /// "prog", "--config="
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
- /// ```
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- pub fn empty_values(mut self, ev: bool) -> Self {
- if ev {
- self.set(ArgSettings::EmptyValues)
- } else {
- self = self.set(ArgSettings::TakesValue);
- self.unset(ArgSettings::EmptyValues)
- }
- }
-
- /// Hides an argument from help message output.
- ///
- /// **NOTE:** Implicitly sets [`Arg::hidden_short_help(true)`] and [`Arg::hidden_long_help(true)`]
- /// when set to true
- ///
- /// **NOTE:** This does **not** hide the argument from usage strings on error
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .hidden(true)
- /// # ;
- /// ```
- /// Setting `hidden(true)` will hide the argument when displaying help text
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .hidden(true)
- /// .help("Some help text describing the --config arg"))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- /// ```
- /// [`Arg::hidden_short_help(true)`]: ./struct.Arg.html#method.hidden_short_help
- /// [`Arg::hidden_long_help(true)`]: ./struct.Arg.html#method.hidden_long_help
- pub fn hidden(self, h: bool) -> Self {
- if h {
- self.set(ArgSettings::Hidden)
- } else {
- self.unset(ArgSettings::Hidden)
- }
- }
-
- /// Specifies a list of possible values for this argument. At runtime, `clap` verifies that
- /// only one of the specified values was used, or fails with an error message.
- ///
- /// **NOTE:** This setting only applies to [options] and [positional arguments]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("mode")
- /// .takes_value(true)
- /// .possible_values(&["fast", "slow", "medium"])
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .long("mode")
- /// .takes_value(true)
- /// .possible_values(&["fast", "slow", "medium"]))
- /// .get_matches_from(vec![
- /// "prog", "--mode", "fast"
- /// ]);
- /// assert!(m.is_present("mode"));
- /// assert_eq!(m.value_of("mode"), Some("fast"));
- /// ```
- ///
- /// The next example shows a failed parse from using a value which wasn't defined as one of the
- /// possible values.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .long("mode")
- /// .takes_value(true)
- /// .possible_values(&["fast", "slow", "medium"]))
- /// .get_matches_from_safe(vec![
- /// "prog", "--mode", "wrong"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::InvalidValue);
- /// ```
- /// [options]: ./struct.Arg.html#method.takes_value
- /// [positional arguments]: ./struct.Arg.html#method.index
- pub fn possible_values(mut self, names: &[&'b str]) -> Self {
- if let Some(ref mut vec) = self.v.possible_vals {
- for s in names {
- vec.push(s);
- }
- } else {
- self.v.possible_vals = Some(names.iter().map(|s| *s).collect::<Vec<_>>());
- }
- self
- }
-
- /// Specifies a possible value for this argument, one at a time. At runtime, `clap` verifies
- /// that only one of the specified values was used, or fails with error message.
- ///
- /// **NOTE:** This setting only applies to [options] and [positional arguments]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("mode")
- /// .takes_value(true)
- /// .possible_value("fast")
- /// .possible_value("slow")
- /// .possible_value("medium")
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .long("mode")
- /// .takes_value(true)
- /// .possible_value("fast")
- /// .possible_value("slow")
- /// .possible_value("medium"))
- /// .get_matches_from(vec![
- /// "prog", "--mode", "fast"
- /// ]);
- /// assert!(m.is_present("mode"));
- /// assert_eq!(m.value_of("mode"), Some("fast"));
- /// ```
- ///
- /// The next example shows a failed parse from using a value which wasn't defined as one of the
- /// possible values.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("mode")
- /// .long("mode")
- /// .takes_value(true)
- /// .possible_value("fast")
- /// .possible_value("slow")
- /// .possible_value("medium"))
- /// .get_matches_from_safe(vec![
- /// "prog", "--mode", "wrong"
- /// ]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::InvalidValue);
- /// ```
- /// [options]: ./struct.Arg.html#method.takes_value
- /// [positional arguments]: ./struct.Arg.html#method.index
- pub fn possible_value(mut self, name: &'b str) -> Self {
- if let Some(ref mut vec) = self.v.possible_vals {
- vec.push(name);
- } else {
- self.v.possible_vals = Some(vec![name]);
- }
- self
- }
-
- /// When used with [`Arg::possible_values`] it allows the argument value to pass validation even if
- /// the case differs from that of the specified `possible_value`.
- ///
- /// **Pro Tip:** Use this setting with [`arg_enum!`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// # use std::ascii::AsciiExt;
- /// let m = App::new("pv")
- /// .arg(Arg::with_name("option")
- /// .long("--option")
- /// .takes_value(true)
- /// .possible_value("test123")
- /// .case_insensitive(true))
- /// .get_matches_from(vec![
- /// "pv", "--option", "TeSt123",
- /// ]);
- ///
- /// assert!(m.value_of("option").unwrap().eq_ignore_ascii_case("test123"));
- /// ```
- ///
- /// This setting also works when multiple values can be defined:
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("pv")
- /// .arg(Arg::with_name("option")
- /// .short("-o")
- /// .long("--option")
- /// .takes_value(true)
- /// .possible_value("test123")
- /// .possible_value("test321")
- /// .multiple(true)
- /// .case_insensitive(true))
- /// .get_matches_from(vec![
- /// "pv", "--option", "TeSt123", "teST123", "tESt321"
- /// ]);
- ///
- /// let matched_vals = m.values_of("option").unwrap().collect::<Vec<_>>();
- /// assert_eq!(&*matched_vals, &["TeSt123", "teST123", "tESt321"]);
- /// ```
- /// [`Arg::case_insensitive(true)`]: ./struct.Arg.html#method.possible_values
- /// [`arg_enum!`]: ./macro.arg_enum.html
- pub fn case_insensitive(self, ci: bool) -> Self {
- if ci {
- self.set(ArgSettings::CaseInsensitive)
- } else {
- self.unset(ArgSettings::CaseInsensitive)
- }
- }
-
- /// Specifies the name of the [`ArgGroup`] the argument belongs to.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .long("debug")
- /// .group("mode")
- /// # ;
- /// ```
- ///
- /// Multiple arguments can be a member of a single group and then the group checked as if it
- /// was one of said arguments.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("debug")
- /// .long("debug")
- /// .group("mode"))
- /// .arg(Arg::with_name("verbose")
- /// .long("verbose")
- /// .group("mode"))
- /// .get_matches_from(vec![
- /// "prog", "--debug"
- /// ]);
- /// assert!(m.is_present("mode"));
- /// ```
- /// [`ArgGroup`]: ./struct.ArgGroup.html
- pub fn group(mut self, name: &'a str) -> Self {
- if let Some(ref mut vec) = self.b.groups {
- vec.push(name);
- } else {
- self.b.groups = Some(vec![name]);
- }
- self
- }
-
- /// Specifies the names of multiple [`ArgGroup`]'s the argument belongs to.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .long("debug")
- /// .groups(&["mode", "verbosity"])
- /// # ;
- /// ```
- ///
- /// Arguments can be members of multiple groups and then the group checked as if it
- /// was one of said arguments.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("debug")
- /// .long("debug")
- /// .groups(&["mode", "verbosity"]))
- /// .arg(Arg::with_name("verbose")
- /// .long("verbose")
- /// .groups(&["mode", "verbosity"]))
- /// .get_matches_from(vec![
- /// "prog", "--debug"
- /// ]);
- /// assert!(m.is_present("mode"));
- /// assert!(m.is_present("verbosity"));
- /// ```
- /// [`ArgGroup`]: ./struct.ArgGroup.html
- pub fn groups(mut self, names: &[&'a str]) -> Self {
- if let Some(ref mut vec) = self.b.groups {
- for s in names {
- vec.push(s);
- }
- } else {
- self.b.groups = Some(names.into_iter().map(|s| *s).collect::<Vec<_>>());
- }
- self
- }
-
- /// Specifies how many values are required to satisfy this argument. For example, if you had a
- /// `-f <file>` argument where you wanted exactly 3 'files' you would set
- /// `.number_of_values(3)`, and this argument wouldn't be satisfied unless the user provided
- /// 3 and only 3 values.
- ///
- /// **NOTE:** Does *not* require [`Arg::multiple(true)`] to be set. Setting
- /// [`Arg::multiple(true)`] would allow `-f <file> <file> <file> -f <file> <file> <file>` where
- /// as *not* setting [`Arg::multiple(true)`] would only allow one occurrence of this argument.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("file")
- /// .short("f")
- /// .number_of_values(3)
- /// # ;
- /// ```
- ///
- /// Not supplying the correct number of values is an error
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .takes_value(true)
- /// .number_of_values(2)
- /// .short("F"))
- /// .get_matches_from_safe(vec![
- /// "prog", "-F", "file1"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
- /// ```
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- pub fn number_of_values(mut self, qty: u64) -> Self {
- self.setb(ArgSettings::TakesValue);
- self.v.num_vals = Some(qty);
- self
- }
-
- /// Allows one to perform a custom validation on the argument value. You provide a closure
- /// which accepts a [`String`] value, and return a [`Result`] where the [`Err(String)`] is a
- /// message displayed to the user.
- ///
- /// **NOTE:** The error message does *not* need to contain the `error:` portion, only the
- /// message as all errors will appear as
- /// `error: Invalid value for '<arg>': <YOUR MESSAGE>` where `<arg>` is replaced by the actual
- /// arg, and `<YOUR MESSAGE>` is the `String` you return as the error.
- ///
- /// **NOTE:** There is a small performance hit for using validators, as they are implemented
- /// with [`Rc`] pointers. And the value to be checked will be allocated an extra time in order
- /// to to be passed to the closure. This performance hit is extremely minimal in the grand
- /// scheme of things.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// fn has_at(v: String) -> Result<(), String> {
- /// if v.contains("@") { return Ok(()); }
- /// Err(String::from("The value did not contain the required @ sigil"))
- /// }
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .index(1)
- /// .validator(has_at))
- /// .get_matches_from_safe(vec![
- /// "prog", "some@file"
- /// ]);
- /// assert!(res.is_ok());
- /// assert_eq!(res.unwrap().value_of("file"), Some("some@file"));
- /// ```
- /// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html
- /// [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
- /// [`Err(String)`]: https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err
- /// [`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html
- pub fn validator<F>(mut self, f: F) -> Self
- where
- F: Fn(String) -> Result<(), String> + 'static,
- {
- self.v.validator = Some(Rc::new(f));
- self
- }
-
- /// Works identically to Validator but is intended to be used with values that could
- /// contain non UTF-8 formatted strings.
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```rust")]
- /// # use clap::{App, Arg};
- /// # use std::ffi::{OsStr, OsString};
- /// # use std::os::unix::ffi::OsStrExt;
- /// fn has_ampersand(v: &OsStr) -> Result<(), OsString> {
- /// if v.as_bytes().iter().any(|b| *b == b'&') { return Ok(()); }
- /// Err(OsString::from("The value did not contain the required & sigil"))
- /// }
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .index(1)
- /// .validator_os(has_ampersand))
- /// .get_matches_from_safe(vec![
- /// "prog", "Fish & chips"
- /// ]);
- /// assert!(res.is_ok());
- /// assert_eq!(res.unwrap().value_of("file"), Some("Fish & chips"));
- /// ```
- /// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html
- /// [`OsStr`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html
- /// [`OsString`]: https://doc.rust-lang.org/std/ffi/struct.OsString.html
- /// [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
- /// [`Err(String)`]: https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err
- /// [`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html
- pub fn validator_os<F>(mut self, f: F) -> Self
- where
- F: Fn(&OsStr) -> Result<(), OsString> + 'static,
- {
- self.v.validator_os = Some(Rc::new(f));
- self
- }
-
- /// Specifies the *maximum* number of values are for this argument. For example, if you had a
- /// `-f <file>` argument where you wanted up to 3 'files' you would set `.max_values(3)`, and
- /// this argument would be satisfied if the user provided, 1, 2, or 3 values.
- ///
- /// **NOTE:** This does *not* implicitly set [`Arg::multiple(true)`]. This is because
- /// `-o val -o val` is multiple occurrences but a single value and `-o val1 val2` is a single
- /// occurrence with multiple values. For positional arguments this **does** set
- /// [`Arg::multiple(true)`] because there is no way to determine the difference between multiple
- /// occurrences and multiple values.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("file")
- /// .short("f")
- /// .max_values(3)
- /// # ;
- /// ```
- ///
- /// Supplying less than the maximum number of values is allowed
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .takes_value(true)
- /// .max_values(3)
- /// .short("F"))
- /// .get_matches_from_safe(vec![
- /// "prog", "-F", "file1", "file2"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// let m = res.unwrap();
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2"]);
- /// ```
- ///
- /// Supplying more than the maximum number of values is an error
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .takes_value(true)
- /// .max_values(2)
- /// .short("F"))
- /// .get_matches_from_safe(vec![
- /// "prog", "-F", "file1", "file2", "file3"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::TooManyValues);
- /// ```
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- pub fn max_values(mut self, qty: u64) -> Self {
- self.setb(ArgSettings::TakesValue);
- self.v.max_vals = Some(qty);
- self
- }
-
- /// Specifies the *minimum* number of values for this argument. For example, if you had a
- /// `-f <file>` argument where you wanted at least 2 'files' you would set
- /// `.min_values(2)`, and this argument would be satisfied if the user provided, 2 or more
- /// values.
- ///
- /// **NOTE:** This does not implicitly set [`Arg::multiple(true)`]. This is because
- /// `-o val -o val` is multiple occurrences but a single value and `-o val1 val2` is a single
- /// occurrence with multiple values. For positional arguments this **does** set
- /// [`Arg::multiple(true)`] because there is no way to determine the difference between multiple
- /// occurrences and multiple values.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("file")
- /// .short("f")
- /// .min_values(3)
- /// # ;
- /// ```
- ///
- /// Supplying more than the minimum number of values is allowed
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .takes_value(true)
- /// .min_values(2)
- /// .short("F"))
- /// .get_matches_from_safe(vec![
- /// "prog", "-F", "file1", "file2", "file3"
- /// ]);
- ///
- /// assert!(res.is_ok());
- /// let m = res.unwrap();
- /// let files: Vec<_> = m.values_of("file").unwrap().collect();
- /// assert_eq!(files, ["file1", "file2", "file3"]);
- /// ```
- ///
- /// Supplying less than the minimum number of values is an error
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("file")
- /// .takes_value(true)
- /// .min_values(2)
- /// .short("F"))
- /// .get_matches_from_safe(vec![
- /// "prog", "-F", "file1"
- /// ]);
- ///
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::TooFewValues);
- /// ```
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- pub fn min_values(mut self, qty: u64) -> Self {
- self.v.min_vals = Some(qty);
- self.set(ArgSettings::TakesValue)
- }
-
- /// Specifies whether or not an argument should allow grouping of multiple values via a
- /// delimiter. I.e. should `--option=val1,val2,val3` be parsed as three values (`val1`, `val2`,
- /// and `val3`) or as a single value (`val1,val2,val3`). Defaults to using `,` (comma) as the
- /// value delimiter for all arguments that accept values (options and positional arguments)
- ///
- /// **NOTE:** The default is `false`. When set to `true` the default [`Arg::value_delimiter`]
- /// is the comma `,`.
- ///
- /// # Examples
- ///
- /// The following example shows the default behavior.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let delims = App::new("prog")
- /// .arg(Arg::with_name("option")
- /// .long("option")
- /// .use_delimiter(true)
- /// .takes_value(true))
- /// .get_matches_from(vec![
- /// "prog", "--option=val1,val2,val3",
- /// ]);
- ///
- /// assert!(delims.is_present("option"));
- /// assert_eq!(delims.occurrences_of("option"), 1);
- /// assert_eq!(delims.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
- /// ```
- /// The next example shows the difference when turning delimiters off. This is the default
- /// behavior
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let nodelims = App::new("prog")
- /// .arg(Arg::with_name("option")
- /// .long("option")
- /// .use_delimiter(false)
- /// .takes_value(true))
- /// .get_matches_from(vec![
- /// "prog", "--option=val1,val2,val3",
- /// ]);
- ///
- /// assert!(nodelims.is_present("option"));
- /// assert_eq!(nodelims.occurrences_of("option"), 1);
- /// assert_eq!(nodelims.value_of("option").unwrap(), "val1,val2,val3");
- /// ```
- /// [`Arg::value_delimiter`]: ./struct.Arg.html#method.value_delimiter
- pub fn use_delimiter(mut self, d: bool) -> Self {
- if d {
- if self.v.val_delim.is_none() {
- self.v.val_delim = Some(',');
- }
- self.setb(ArgSettings::TakesValue);
- self.setb(ArgSettings::UseValueDelimiter);
- self.unset(ArgSettings::ValueDelimiterNotSet)
- } else {
- self.v.val_delim = None;
- self.unsetb(ArgSettings::UseValueDelimiter);
- self.unset(ArgSettings::ValueDelimiterNotSet)
- }
- }
-
- /// Specifies that *multiple values* may only be set using the delimiter. This means if an
- /// if an option is encountered, and no delimiter is found, it automatically assumed that no
- /// additional values for that option follow. This is unlike the default, where it is generally
- /// assumed that more values will follow regardless of whether or not a delimiter is used.
- ///
- /// **NOTE:** The default is `false`.
- ///
- /// **NOTE:** Setting this to true implies [`Arg::use_delimiter(true)`]
- ///
- /// **NOTE:** It's a good idea to inform the user that use of a delimiter is required, either
- /// through help text or other means.
- ///
- /// # Examples
- ///
- /// These examples demonstrate what happens when `require_delimiter(true)` is used. Notice
- /// everything works in this first example, as we use a delimiter, as expected.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let delims = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true)
- /// .require_delimiter(true))
- /// .get_matches_from(vec![
- /// "prog", "-o", "val1,val2,val3",
- /// ]);
- ///
- /// assert!(delims.is_present("opt"));
- /// assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
- /// ```
- /// In this next example, we will *not* use a delimiter. Notice it's now an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true)
- /// .require_delimiter(true))
- /// .get_matches_from_safe(vec![
- /// "prog", "-o", "val1", "val2", "val3",
- /// ]);
- ///
- /// assert!(res.is_err());
- /// let err = res.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::UnknownArgument);
- /// ```
- /// What's happening is `-o` is getting `val1`, and because delimiters are required yet none
- /// were present, it stops parsing `-o`. At this point it reaches `val2` and because no
- /// positional arguments have been defined, it's an error of an unexpected argument.
- ///
- /// In this final example, we contrast the above with `clap`'s default behavior where the above
- /// is *not* an error.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let delims = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true))
- /// .get_matches_from(vec![
- /// "prog", "-o", "val1", "val2", "val3",
- /// ]);
- ///
- /// assert!(delims.is_present("opt"));
- /// assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
- /// ```
- /// [`Arg::use_delimiter(true)`]: ./struct.Arg.html#method.use_delimiter
- pub fn require_delimiter(mut self, d: bool) -> Self {
- if d {
- self = self.use_delimiter(true);
- self.unsetb(ArgSettings::ValueDelimiterNotSet);
- self.setb(ArgSettings::UseValueDelimiter);
- self.set(ArgSettings::RequireDelimiter)
- } else {
- self = self.use_delimiter(false);
- self.unsetb(ArgSettings::UseValueDelimiter);
- self.unset(ArgSettings::RequireDelimiter)
- }
- }
-
- /// Specifies the separator to use when values are clumped together, defaults to `,` (comma).
- ///
- /// **NOTE:** implicitly sets [`Arg::use_delimiter(true)`]
- ///
- /// **NOTE:** implicitly sets [`Arg::takes_value(true)`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("config")
- /// .short("c")
- /// .long("config")
- /// .value_delimiter(";"))
- /// .get_matches_from(vec![
- /// "prog", "--config=val1;val2;val3"
- /// ]);
- ///
- /// assert_eq!(m.values_of("config").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"])
- /// ```
- /// [`Arg::use_delimiter(true)`]: ./struct.Arg.html#method.use_delimiter
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- pub fn value_delimiter(mut self, d: &str) -> Self {
- self.unsetb(ArgSettings::ValueDelimiterNotSet);
- self.setb(ArgSettings::TakesValue);
- self.setb(ArgSettings::UseValueDelimiter);
- self.v.val_delim = Some(
- d.chars()
- .nth(0)
- .expect("Failed to get value_delimiter from arg"),
- );
- self
- }
-
- /// Specify multiple names for values of option arguments. These names are cosmetic only, used
- /// for help and usage strings only. The names are **not** used to access arguments. The values
- /// of the arguments are accessed in numeric order (i.e. if you specify two names `one` and
- /// `two` `one` will be the first matched value, `two` will be the second).
- ///
- /// This setting can be very helpful when describing the type of input the user should be
- /// using, such as `FILE`, `INTERFACE`, etc. Although not required, it's somewhat convention to
- /// use all capital letters for the value name.
- ///
- /// **Pro Tip:** It may help to use [`Arg::next_line_help(true)`] if there are long, or
- /// multiple value names in order to not throw off the help text alignment of all options.
- ///
- /// **NOTE:** This implicitly sets [`Arg::number_of_values`] if the number of value names is
- /// greater than one. I.e. be aware that the number of "names" you set for the values, will be
- /// the *exact* number of values required to satisfy this argument
- ///
- /// **NOTE:** implicitly sets [`Arg::takes_value(true)`]
- ///
- /// **NOTE:** Does *not* require or imply [`Arg::multiple(true)`].
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("speed")
- /// .short("s")
- /// .value_names(&["fast", "slow"])
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("io")
- /// .long("io-files")
- /// .value_names(&["INFILE", "OUTFILE"]))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- /// Running the above program produces the following output
- ///
- /// ```notrust
- /// valnames
- ///
- /// USAGE:
- /// valnames [FLAGS] [OPTIONS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- ///
- /// OPTIONS:
- /// --io-files <INFILE> <OUTFILE> Some help text
- /// ```
- /// [`Arg::next_line_help(true)`]: ./struct.Arg.html#method.next_line_help
- /// [`Arg::number_of_values`]: ./struct.Arg.html#method.number_of_values
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- pub fn value_names(mut self, names: &[&'b str]) -> Self {
- self.setb(ArgSettings::TakesValue);
- if self.is_set(ArgSettings::ValueDelimiterNotSet) {
- self.unsetb(ArgSettings::ValueDelimiterNotSet);
- self.setb(ArgSettings::UseValueDelimiter);
- }
- if let Some(ref mut vals) = self.v.val_names {
- let mut l = vals.len();
- for s in names {
- vals.insert(l, s);
- l += 1;
- }
- } else {
- let mut vm = VecMap::new();
- for (i, n) in names.iter().enumerate() {
- vm.insert(i, *n);
- }
- self.v.val_names = Some(vm);
- }
- self
- }
-
- /// Specifies the name for value of [option] or [positional] arguments inside of help
- /// documentation. This name is cosmetic only, the name is **not** used to access arguments.
- /// This setting can be very helpful when describing the type of input the user should be
- /// using, such as `FILE`, `INTERFACE`, etc. Although not required, it's somewhat convention to
- /// use all capital letters for the value name.
- ///
- /// **NOTE:** implicitly sets [`Arg::takes_value(true)`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("cfg")
- /// .long("config")
- /// .value_name("FILE")
- /// # ;
- /// ```
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("config")
- /// .long("config")
- /// .value_name("FILE"))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- /// Running the above program produces the following output
- ///
- /// ```notrust
- /// valnames
- ///
- /// USAGE:
- /// valnames [FLAGS] [OPTIONS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- ///
- /// OPTIONS:
- /// --config <FILE> Some help text
- /// ```
- /// [option]: ./struct.Arg.html#method.takes_value
- /// [positional]: ./struct.Arg.html#method.index
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- pub fn value_name(mut self, name: &'b str) -> Self {
- self.setb(ArgSettings::TakesValue);
- if let Some(ref mut vals) = self.v.val_names {
- let l = vals.len();
- vals.insert(l, name);
- } else {
- let mut vm = VecMap::new();
- vm.insert(0, name);
- self.v.val_names = Some(vm);
- }
- self
- }
-
- /// Specifies the value of the argument when *not* specified at runtime.
- ///
- /// **NOTE:** If the user *does not* use this argument at runtime, [`ArgMatches::occurrences_of`]
- /// will return `0` even though the [`ArgMatches::value_of`] will return the default specified.
- ///
- /// **NOTE:** If the user *does not* use this argument at runtime [`ArgMatches::is_present`] will
- /// still return `true`. If you wish to determine whether the argument was used at runtime or
- /// not, consider [`ArgMatches::occurrences_of`] which will return `0` if the argument was *not*
- /// used at runtime.
- ///
- /// **NOTE:** This setting is perfectly compatible with [`Arg::default_value_if`] but slightly
- /// different. `Arg::default_value` *only* takes affect when the user has not provided this arg
- /// at runtime. `Arg::default_value_if` however only takes affect when the user has not provided
- /// a value at runtime **and** these other conditions are met as well. If you have set
- /// `Arg::default_value` and `Arg::default_value_if`, and the user **did not** provide a this
- /// arg at runtime, nor did were the conditions met for `Arg::default_value_if`, the
- /// `Arg::default_value` will be applied.
- ///
- /// **NOTE:** This implicitly sets [`Arg::takes_value(true)`].
- ///
- /// **NOTE:** This setting effectively disables `AppSettings::ArgRequiredElseHelp` if used in
- /// conjunction as it ensures that some argument will always be present.
- ///
- /// # Examples
- ///
- /// First we use the default value without providing any value at runtime.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .long("myopt")
- /// .default_value("myval"))
- /// .get_matches_from(vec![
- /// "prog"
- /// ]);
- ///
- /// assert_eq!(m.value_of("opt"), Some("myval"));
- /// assert!(m.is_present("opt"));
- /// assert_eq!(m.occurrences_of("opt"), 0);
- /// ```
- ///
- /// Next we provide a value at runtime to override the default.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .long("myopt")
- /// .default_value("myval"))
- /// .get_matches_from(vec![
- /// "prog", "--myopt=non_default"
- /// ]);
- ///
- /// assert_eq!(m.value_of("opt"), Some("non_default"));
- /// assert!(m.is_present("opt"));
- /// assert_eq!(m.occurrences_of("opt"), 1);
- /// ```
- /// [`ArgMatches::occurrences_of`]: ./struct.ArgMatches.html#method.occurrences_of
- /// [`ArgMatches::value_of`]: ./struct.ArgMatches.html#method.value_of
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- /// [`ArgMatches::is_present`]: ./struct.ArgMatches.html#method.is_present
- /// [`Arg::default_value_if`]: ./struct.Arg.html#method.default_value_if
- pub fn default_value(self, val: &'a str) -> Self {
- self.default_value_os(OsStr::from_bytes(val.as_bytes()))
- }
-
- /// Provides a default value in the exact same manner as [`Arg::default_value`]
- /// only using [`OsStr`]s instead.
- /// [`Arg::default_value`]: ./struct.Arg.html#method.default_value
- /// [`OsStr`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html
- pub fn default_value_os(mut self, val: &'a OsStr) -> Self {
- self.setb(ArgSettings::TakesValue);
- self.v.default_val = Some(val);
- self
- }
-
- /// Specifies the value of the argument if `arg` has been used at runtime. If `val` is set to
- /// `None`, `arg` only needs to be present. If `val` is set to `"some-val"` then `arg` must be
- /// present at runtime **and** have the value `val`.
- ///
- /// **NOTE:** This setting is perfectly compatible with [`Arg::default_value`] but slightly
- /// different. `Arg::default_value` *only* takes affect when the user has not provided this arg
- /// at runtime. This setting however only takes affect when the user has not provided a value at
- /// runtime **and** these other conditions are met as well. If you have set `Arg::default_value`
- /// and `Arg::default_value_if`, and the user **did not** provide a this arg at runtime, nor did
- /// were the conditions met for `Arg::default_value_if`, the `Arg::default_value` will be
- /// applied.
- ///
- /// **NOTE:** This implicitly sets [`Arg::takes_value(true)`].
- ///
- /// **NOTE:** If using YAML the values should be laid out as follows (`None` can be represented
- /// as `null` in YAML)
- ///
- /// ```yaml
- /// default_value_if:
- /// - [arg, val, default]
- /// ```
- ///
- /// # Examples
- ///
- /// First we use the default value only if another arg is present at runtime.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_if("flag", None, "default"))
- /// .get_matches_from(vec![
- /// "prog", "--flag"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), Some("default"));
- /// ```
- ///
- /// Next we run the same test, but without providing `--flag`.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_if("flag", None, "default"))
- /// .get_matches_from(vec![
- /// "prog"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), None);
- /// ```
- ///
- /// Now lets only use the default value if `--opt` contains the value `special`.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .takes_value(true)
- /// .long("opt"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_if("opt", Some("special"), "default"))
- /// .get_matches_from(vec![
- /// "prog", "--opt", "special"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), Some("default"));
- /// ```
- ///
- /// We can run the same test and provide any value *other than* `special` and we won't get a
- /// default value.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .takes_value(true)
- /// .long("opt"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_if("opt", Some("special"), "default"))
- /// .get_matches_from(vec![
- /// "prog", "--opt", "hahaha"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), None);
- /// ```
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- /// [`Arg::default_value`]: ./struct.Arg.html#method.default_value
- pub fn default_value_if(self, arg: &'a str, val: Option<&'b str>, default: &'b str) -> Self {
- self.default_value_if_os(
- arg,
- val.map(str::as_bytes).map(OsStr::from_bytes),
- OsStr::from_bytes(default.as_bytes()),
- )
- }
-
- /// Provides a conditional default value in the exact same manner as [`Arg::default_value_if`]
- /// only using [`OsStr`]s instead.
- /// [`Arg::default_value_if`]: ./struct.Arg.html#method.default_value_if
- /// [`OsStr`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html
- pub fn default_value_if_os(
- mut self,
- arg: &'a str,
- val: Option<&'b OsStr>,
- default: &'b OsStr,
- ) -> Self {
- self.setb(ArgSettings::TakesValue);
- if let Some(ref mut vm) = self.v.default_vals_ifs {
- let l = vm.len();
- vm.insert(l, (arg, val, default));
- } else {
- let mut vm = VecMap::new();
- vm.insert(0, (arg, val, default));
- self.v.default_vals_ifs = Some(vm);
- }
- self
- }
-
- /// Specifies multiple values and conditions in the same manner as [`Arg::default_value_if`].
- /// The method takes a slice of tuples in the `(arg, Option<val>, default)` format.
- ///
- /// **NOTE**: The conditions are stored in order and evaluated in the same order. I.e. the first
- /// if multiple conditions are true, the first one found will be applied and the ultimate value.
- ///
- /// **NOTE:** If using YAML the values should be laid out as follows
- ///
- /// ```yaml
- /// default_value_if:
- /// - [arg, val, default]
- /// - [arg2, null, default2]
- /// ```
- ///
- /// # Examples
- ///
- /// First we use the default value only if another arg is present at runtime.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag"))
- /// .arg(Arg::with_name("opt")
- /// .long("opt")
- /// .takes_value(true))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_ifs(&[
- /// ("flag", None, "default"),
- /// ("opt", Some("channal"), "chan"),
- /// ]))
- /// .get_matches_from(vec![
- /// "prog", "--opt", "channal"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), Some("chan"));
- /// ```
- ///
- /// Next we run the same test, but without providing `--flag`.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag"))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_ifs(&[
- /// ("flag", None, "default"),
- /// ("opt", Some("channal"), "chan"),
- /// ]))
- /// .get_matches_from(vec![
- /// "prog"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), None);
- /// ```
- ///
- /// We can also see that these values are applied in order, and if more than one condition is
- /// true, only the first evaluated "wins"
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag"))
- /// .arg(Arg::with_name("opt")
- /// .long("opt")
- /// .takes_value(true))
- /// .arg(Arg::with_name("other")
- /// .long("other")
- /// .default_value_ifs(&[
- /// ("flag", None, "default"),
- /// ("opt", Some("channal"), "chan"),
- /// ]))
- /// .get_matches_from(vec![
- /// "prog", "--opt", "channal", "--flag"
- /// ]);
- ///
- /// assert_eq!(m.value_of("other"), Some("default"));
- /// ```
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- /// [`Arg::default_value`]: ./struct.Arg.html#method.default_value
- pub fn default_value_ifs(mut self, ifs: &[(&'a str, Option<&'b str>, &'b str)]) -> Self {
- for &(arg, val, default) in ifs {
- self = self.default_value_if_os(
- arg,
- val.map(str::as_bytes).map(OsStr::from_bytes),
- OsStr::from_bytes(default.as_bytes()),
- );
- }
- self
- }
-
- /// Provides multiple conditional default values in the exact same manner as
- /// [`Arg::default_value_ifs`] only using [`OsStr`]s instead.
- /// [`Arg::default_value_ifs`]: ./struct.Arg.html#method.default_value_ifs
- /// [`OsStr`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html
- #[cfg_attr(feature = "lints", allow(explicit_counter_loop))]
- pub fn default_value_ifs_os(mut self, ifs: &[(&'a str, Option<&'b OsStr>, &'b OsStr)]) -> Self {
- for &(arg, val, default) in ifs {
- self = self.default_value_if_os(arg, val, default);
- }
- self
- }
-
- /// Specifies that if the value is not passed in as an argument, that it should be retrieved
- /// from the environment, if available. If it is not present in the environment, then default
- /// rules will apply.
- ///
- /// **NOTE:** If the user *does not* use this argument at runtime, [`ArgMatches::occurrences_of`]
- /// will return `0` even though the [`ArgMatches::value_of`] will return the default specified.
- ///
- /// **NOTE:** If the user *does not* use this argument at runtime [`ArgMatches::is_present`] will
- /// return `true` if the variable is present in the environment . If you wish to determine whether
- /// the argument was used at runtime or not, consider [`ArgMatches::occurrences_of`] which will
- /// return `0` if the argument was *not* used at runtime.
- ///
- /// **NOTE:** This implicitly sets [`Arg::takes_value(true)`].
- ///
- /// **NOTE:** If [`Arg::multiple(true)`] is set then [`Arg::use_delimiter(true)`] should also be
- /// set. Otherwise, only a single argument will be returned from the environment variable. The
- /// default delimiter is `,` and follows all the other delimiter rules.
- ///
- /// # Examples
- ///
- /// In this example, we show the variable coming from the environment:
- ///
- /// ```rust
- /// # use std::env;
- /// # use clap::{App, Arg};
- ///
- /// env::set_var("MY_FLAG", "env");
- ///
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag")
- /// .env("MY_FLAG"))
- /// .get_matches_from(vec![
- /// "prog"
- /// ]);
- ///
- /// assert_eq!(m.value_of("flag"), Some("env"));
- /// ```
- ///
- /// In this example, we show the variable coming from an option on the CLI:
- ///
- /// ```rust
- /// # use std::env;
- /// # use clap::{App, Arg};
- ///
- /// env::set_var("MY_FLAG", "env");
- ///
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag")
- /// .env("MY_FLAG"))
- /// .get_matches_from(vec![
- /// "prog", "--flag", "opt"
- /// ]);
- ///
- /// assert_eq!(m.value_of("flag"), Some("opt"));
- /// ```
- ///
- /// In this example, we show the variable coming from the environment even with the
- /// presence of a default:
- ///
- /// ```rust
- /// # use std::env;
- /// # use clap::{App, Arg};
- ///
- /// env::set_var("MY_FLAG", "env");
- ///
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag")
- /// .env("MY_FLAG")
- /// .default_value("default"))
- /// .get_matches_from(vec![
- /// "prog"
- /// ]);
- ///
- /// assert_eq!(m.value_of("flag"), Some("env"));
- /// ```
- ///
- /// In this example, we show the use of multiple values in a single environment variable:
- ///
- /// ```rust
- /// # use std::env;
- /// # use clap::{App, Arg};
- ///
- /// env::set_var("MY_FLAG_MULTI", "env1,env2");
- ///
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("flag")
- /// .long("flag")
- /// .env("MY_FLAG_MULTI")
- /// .multiple(true)
- /// .use_delimiter(true))
- /// .get_matches_from(vec![
- /// "prog"
- /// ]);
- ///
- /// assert_eq!(m.values_of("flag").unwrap().collect::<Vec<_>>(), vec!["env1", "env2"]);
- /// ```
- /// [`ArgMatches::occurrences_of`]: ./struct.ArgMatches.html#method.occurrences_of
- /// [`ArgMatches::value_of`]: ./struct.ArgMatches.html#method.value_of
- /// [`ArgMatches::is_present`]: ./struct.ArgMatches.html#method.is_present
- /// [`Arg::takes_value(true)`]: ./struct.Arg.html#method.takes_value
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- /// [`Arg::use_delimiter(true)`]: ./struct.Arg.html#method.use_delimiter
- pub fn env(self, name: &'a str) -> Self {
- self.env_os(OsStr::new(name))
- }
-
- /// Specifies that if the value is not passed in as an argument, that it should be retrieved
- /// from the environment if available in the exact same manner as [`Arg::env`] only using
- /// [`OsStr`]s instead.
- pub fn env_os(mut self, name: &'a OsStr) -> Self {
- self.setb(ArgSettings::TakesValue);
-
- self.v.env = Some((name, env::var_os(name)));
- self
- }
-
- /// @TODO @p2 @docs @release: write docs
- pub fn hide_env_values(self, hide: bool) -> Self {
- if hide {
- self.set(ArgSettings::HideEnvValues)
- } else {
- self.unset(ArgSettings::HideEnvValues)
- }
- }
-
- /// When set to `true` the help string will be displayed on the line after the argument and
- /// indented once. This can be helpful for arguments with very long or complex help messages.
- /// This can also be helpful for arguments with very long flag names, or many/long value names.
- ///
- /// **NOTE:** To apply this setting to all arguments consider using
- /// [`AppSettings::NextLineHelp`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("opt")
- /// .long("long-option-flag")
- /// .short("o")
- /// .takes_value(true)
- /// .value_names(&["value1", "value2"])
- /// .help("Some really long help and complex\n\
- /// help that makes more sense to be\n\
- /// on a line after the option")
- /// .next_line_help(true))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays the following help message
- ///
- /// ```notrust
- /// nlh
- ///
- /// USAGE:
- /// nlh [FLAGS] [OPTIONS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- ///
- /// OPTIONS:
- /// -o, --long-option-flag <value1> <value2>
- /// Some really long help and complex
- /// help that makes more sense to be
- /// on a line after the option
- /// ```
- /// [`AppSettings::NextLineHelp`]: ./enum.AppSettings.html#variant.NextLineHelp
- pub fn next_line_help(mut self, nlh: bool) -> Self {
- if nlh {
- self.setb(ArgSettings::NextLineHelp);
- } else {
- self.unsetb(ArgSettings::NextLineHelp);
- }
- self
- }
-
- /// Allows custom ordering of args within the help message. Args with a lower value will be
- /// displayed first in the help message. This is helpful when one would like to emphasise
- /// frequently used args, or prioritize those towards the top of the list. Duplicate values
- /// **are** allowed. Args with duplicate display orders will be displayed in alphabetical
- /// order.
- ///
- /// **NOTE:** The default is 999 for all arguments.
- ///
- /// **NOTE:** This setting is ignored for [positional arguments] which are always displayed in
- /// [index] order.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("a") // Typically args are grouped alphabetically by name.
- /// // Args without a display_order have a value of 999 and are
- /// // displayed alphabetically with all other 999 valued args.
- /// .long("long-option")
- /// .short("o")
- /// .takes_value(true)
- /// .help("Some help and text"))
- /// .arg(Arg::with_name("b")
- /// .long("other-option")
- /// .short("O")
- /// .takes_value(true)
- /// .display_order(1) // In order to force this arg to appear *first*
- /// // all we have to do is give it a value lower than 999.
- /// // Any other args with a value of 1 will be displayed
- /// // alphabetically with this one...then 2 values, then 3, etc.
- /// .help("I should be first!"))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays the following help message
- ///
- /// ```notrust
- /// cust-ord
- ///
- /// USAGE:
- /// cust-ord [FLAGS] [OPTIONS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- ///
- /// OPTIONS:
- /// -O, --other-option <b> I should be first!
- /// -o, --long-option <a> Some help and text
- /// ```
- /// [positional arguments]: ./struct.Arg.html#method.index
- /// [index]: ./struct.Arg.html#method.index
- pub fn display_order(mut self, ord: usize) -> Self {
- self.s.disp_ord = ord;
- self
- }
-
- /// Indicates that all parameters passed after this should not be parsed
- /// individually, but rather passed in their entirety. It is worth noting
- /// that setting this requires all values to come after a `--` to indicate they
- /// should all be captured. For example:
- ///
- /// ```notrust
- /// --foo something -- -v -v -v -b -b -b --baz -q -u -x
- /// ```
- /// Will result in everything after `--` to be considered one raw argument. This behavior
- /// may not be exactly what you are expecting and using [`AppSettings::TrailingVarArg`]
- /// may be more appropriate.
- ///
- /// **NOTE:** Implicitly sets [`Arg::multiple(true)`], [`Arg::allow_hyphen_values(true)`], and
- /// [`Arg::last(true)`] when set to `true`
- ///
- /// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
- /// [`Arg::allow_hyphen_values(true)`]: ./struct.Arg.html#method.allow_hyphen_values
- /// [`Arg::last(true)`]: ./struct.Arg.html#method.last
- /// [`AppSettings::TrailingVarArg`]: ./enum.AppSettings.html#variant.TrailingVarArg
- pub fn raw(self, raw: bool) -> Self {
- self.multiple(raw).allow_hyphen_values(raw).last(raw)
- }
-
- /// Hides an argument from short help message output.
- ///
- /// **NOTE:** This does **not** hide the argument from usage strings on error
- ///
- /// **NOTE:** Setting this option will cause next-line-help output style to be used
- /// when long help (`--help`) is called.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .hidden_short_help(true)
- /// # ;
- /// ```
- /// Setting `hidden_short_help(true)` will hide the argument when displaying short help text
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .hidden_short_help(true)
- /// .help("Some help text describing the --config arg"))
- /// .get_matches_from(vec![
- /// "prog", "-h"
- /// ]);
- /// ```
- ///
- /// The above example displays
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- /// ```
- ///
- /// However, when --help is called
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .hidden_short_help(true)
- /// .help("Some help text describing the --config arg"))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// Then the following would be displayed
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// --config Some help text describing the --config arg
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- /// ```
- pub fn hidden_short_help(self, hide: bool) -> Self {
- if hide {
- self.set(ArgSettings::HiddenShortHelp)
- } else {
- self.unset(ArgSettings::HiddenShortHelp)
- }
- }
-
- /// Hides an argument from long help message output.
- ///
- /// **NOTE:** This does **not** hide the argument from usage strings on error
- ///
- /// **NOTE:** Setting this option will cause next-line-help output style to be used
- /// when long help (`--help`) is called.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// Arg::with_name("debug")
- /// .hidden_long_help(true)
- /// # ;
- /// ```
- /// Setting `hidden_long_help(true)` will hide the argument when displaying long help text
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .hidden_long_help(true)
- /// .help("Some help text describing the --config arg"))
- /// .get_matches_from(vec![
- /// "prog", "--help"
- /// ]);
- /// ```
- ///
- /// The above example displays
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- /// ```
- ///
- /// However, when -h is called
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("prog")
- /// .arg(Arg::with_name("cfg")
- /// .long("config")
- /// .hidden_long_help(true)
- /// .help("Some help text describing the --config arg"))
- /// .get_matches_from(vec![
- /// "prog", "-h"
- /// ]);
- /// ```
- ///
- /// Then the following would be displayed
- ///
- /// ```notrust
- /// helptest
- ///
- /// USAGE:
- /// helptest [FLAGS]
- ///
- /// FLAGS:
- /// --config Some help text describing the --config arg
- /// -h, --help Prints help information
- /// -V, --version Prints version information
- /// ```
- pub fn hidden_long_help(self, hide: bool) -> Self {
- if hide {
- self.set(ArgSettings::HiddenLongHelp)
- } else {
- self.unset(ArgSettings::HiddenLongHelp)
- }
- }
-
- /// Checks if one of the [`ArgSettings`] settings is set for the argument.
- ///
- /// [`ArgSettings`]: ./enum.ArgSettings.html
- pub fn is_set(&self, s: ArgSettings) -> bool {
- self.b.is_set(s)
- }
-
- /// Sets one of the [`ArgSettings`] settings for the argument.
- ///
- /// [`ArgSettings`]: ./enum.ArgSettings.html
- pub fn set(mut self, s: ArgSettings) -> Self {
- self.setb(s);
- self
- }
-
- /// Unsets one of the [`ArgSettings`] settings for the argument.
- ///
- /// [`ArgSettings`]: ./enum.ArgSettings.html
- pub fn unset(mut self, s: ArgSettings) -> Self {
- self.unsetb(s);
- self
- }
-
- #[doc(hidden)]
- pub fn setb(&mut self, s: ArgSettings) {
- self.b.set(s);
- }
-
- #[doc(hidden)]
- pub fn unsetb(&mut self, s: ArgSettings) {
- self.b.unset(s);
- }
-}
-
-impl<'a, 'b, 'z> From<&'z Arg<'a, 'b>> for Arg<'a, 'b> {
- fn from(a: &'z Arg<'a, 'b>) -> Self {
- Arg {
- b: a.b.clone(),
- v: a.v.clone(),
- s: a.s.clone(),
- index: a.index,
- r_ifs: a.r_ifs.clone(),
- }
- }
-}
-
-impl<'n, 'e> PartialEq for Arg<'n, 'e> {
- fn eq(&self, other: &Arg<'n, 'e>) -> bool {
- self.b == other.b
- }
-}
diff --git a/clap/src/args/arg_builder/base.rs b/clap/src/args/arg_builder/base.rs
deleted file mode 100644
index fef9d8a..0000000
--- a/clap/src/args/arg_builder/base.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use args::{Arg, ArgFlags, ArgSettings};
-
-#[derive(Debug, Clone, Default)]
-pub struct Base<'a, 'b>
-where
- 'a: 'b,
-{
- pub name: &'a str,
- pub help: Option<&'b str>,
- pub long_help: Option<&'b str>,
- pub blacklist: Option<Vec<&'a str>>,
- pub settings: ArgFlags,
- pub r_unless: Option<Vec<&'a str>>,
- pub overrides: Option<Vec<&'a str>>,
- pub groups: Option<Vec<&'a str>>,
- pub requires: Option<Vec<(Option<&'b str>, &'a str)>>,
-}
-
-impl<'n, 'e> Base<'n, 'e> {
- pub fn new(name: &'n str) -> Self {
- Base {
- name: name,
- ..Default::default()
- }
- }
-
- pub fn set(&mut self, s: ArgSettings) { self.settings.set(s); }
- pub fn unset(&mut self, s: ArgSettings) { self.settings.unset(s); }
- pub fn is_set(&self, s: ArgSettings) -> bool { self.settings.is_set(s) }
-}
-
-impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for Base<'n, 'e> {
- fn from(a: &'z Arg<'n, 'e>) -> Self { a.b.clone() }
-}
-
-impl<'n, 'e> PartialEq for Base<'n, 'e> {
- fn eq(&self, other: &Base<'n, 'e>) -> bool { self.name == other.name }
-}
diff --git a/clap/src/args/arg_builder/flag.rs b/clap/src/args/arg_builder/flag.rs
deleted file mode 100644
index 641e777..0000000
--- a/clap/src/args/arg_builder/flag.rs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Std
-use std::convert::From;
-use std::fmt::{Display, Formatter, Result};
-use std::rc::Rc;
-use std::result::Result as StdResult;
-use std::ffi::{OsStr, OsString};
-use std::mem;
-
-// Internal
-use Arg;
-use args::{AnyArg, ArgSettings, Base, DispOrder, Switched};
-use map::{self, VecMap};
-
-#[derive(Default, Clone, Debug)]
-#[doc(hidden)]
-pub struct FlagBuilder<'n, 'e>
-where
- 'n: 'e,
-{
- pub b: Base<'n, 'e>,
- pub s: Switched<'e>,
-}
-
-impl<'n, 'e> FlagBuilder<'n, 'e> {
- pub fn new(name: &'n str) -> Self {
- FlagBuilder {
- b: Base::new(name),
- ..Default::default()
- }
- }
-}
-
-impl<'a, 'b, 'z> From<&'z Arg<'a, 'b>> for FlagBuilder<'a, 'b> {
- fn from(a: &'z Arg<'a, 'b>) -> Self {
- FlagBuilder {
- b: Base::from(a),
- s: Switched::from(a),
- }
- }
-}
-
-impl<'a, 'b> From<Arg<'a, 'b>> for FlagBuilder<'a, 'b> {
- fn from(mut a: Arg<'a, 'b>) -> Self {
- FlagBuilder {
- b: mem::replace(&mut a.b, Base::default()),
- s: mem::replace(&mut a.s, Switched::default()),
- }
- }
-}
-
-impl<'n, 'e> Display for FlagBuilder<'n, 'e> {
- fn fmt(&self, f: &mut Formatter) -> Result {
- if let Some(l) = self.s.long {
- write!(f, "--{}", l)?;
- } else {
- write!(f, "-{}", self.s.short.unwrap())?;
- }
-
- Ok(())
- }
-}
-
-impl<'n, 'e> AnyArg<'n, 'e> for FlagBuilder<'n, 'e> {
- fn name(&self) -> &'n str { self.b.name }
- fn overrides(&self) -> Option<&[&'e str]> { self.b.overrides.as_ref().map(|o| &o[..]) }
- fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]> {
- self.b.requires.as_ref().map(|o| &o[..])
- }
- fn blacklist(&self) -> Option<&[&'e str]> { self.b.blacklist.as_ref().map(|o| &o[..]) }
- fn required_unless(&self) -> Option<&[&'e str]> { self.b.r_unless.as_ref().map(|o| &o[..]) }
- fn is_set(&self, s: ArgSettings) -> bool { self.b.settings.is_set(s) }
- fn has_switch(&self) -> bool { true }
- fn takes_value(&self) -> bool { false }
- fn set(&mut self, s: ArgSettings) { self.b.settings.set(s) }
- fn max_vals(&self) -> Option<u64> { None }
- fn val_names(&self) -> Option<&VecMap<&'e str>> { None }
- fn num_vals(&self) -> Option<u64> { None }
- fn possible_vals(&self) -> Option<&[&'e str]> { None }
- fn validator(&self) -> Option<&Rc<Fn(String) -> StdResult<(), String>>> { None }
- fn validator_os(&self) -> Option<&Rc<Fn(&OsStr) -> StdResult<(), OsString>>> { None }
- fn min_vals(&self) -> Option<u64> { None }
- fn short(&self) -> Option<char> { self.s.short }
- fn long(&self) -> Option<&'e str> { self.s.long }
- fn val_delim(&self) -> Option<char> { None }
- fn help(&self) -> Option<&'e str> { self.b.help }
- fn long_help(&self) -> Option<&'e str> { self.b.long_help }
- fn val_terminator(&self) -> Option<&'e str> { None }
- fn default_val(&self) -> Option<&'e OsStr> { None }
- fn default_vals_ifs(&self) -> Option<map::Values<(&'n str, Option<&'e OsStr>, &'e OsStr)>> {
- None
- }
- fn env<'s>(&'s self) -> Option<(&'n OsStr, Option<&'s OsString>)> { None }
- fn longest_filter(&self) -> bool { self.s.long.is_some() }
- fn aliases(&self) -> Option<Vec<&'e str>> {
- if let Some(ref aliases) = self.s.aliases {
- let vis_aliases: Vec<_> = aliases
- .iter()
- .filter_map(|&(n, v)| if v { Some(n) } else { None })
- .collect();
- if vis_aliases.is_empty() {
- None
- } else {
- Some(vis_aliases)
- }
- } else {
- None
- }
- }
-}
-
-impl<'n, 'e> DispOrder for FlagBuilder<'n, 'e> {
- fn disp_ord(&self) -> usize { self.s.disp_ord }
-}
-
-impl<'n, 'e> PartialEq for FlagBuilder<'n, 'e> {
- fn eq(&self, other: &FlagBuilder<'n, 'e>) -> bool { self.b == other.b }
-}
-
-#[cfg(test)]
-mod test {
- use args::settings::ArgSettings;
- use super::FlagBuilder;
-
- #[test]
- fn flagbuilder_display() {
- let mut f = FlagBuilder::new("flg");
- f.b.settings.set(ArgSettings::Multiple);
- f.s.long = Some("flag");
-
- assert_eq!(&*format!("{}", f), "--flag");
-
- let mut f2 = FlagBuilder::new("flg");
- f2.s.short = Some('f');
-
- assert_eq!(&*format!("{}", f2), "-f");
- }
-
- #[test]
- fn flagbuilder_display_single_alias() {
- let mut f = FlagBuilder::new("flg");
- f.s.long = Some("flag");
- f.s.aliases = Some(vec![("als", true)]);
-
- assert_eq!(&*format!("{}", f), "--flag");
- }
-
- #[test]
- fn flagbuilder_display_multiple_aliases() {
- let mut f = FlagBuilder::new("flg");
- f.s.short = Some('f');
- f.s.aliases = Some(vec![
- ("alias_not_visible", false),
- ("f2", true),
- ("f3", true),
- ("f4", true),
- ]);
- assert_eq!(&*format!("{}", f), "-f");
- }
-}
diff --git a/clap/src/args/arg_builder/mod.rs b/clap/src/args/arg_builder/mod.rs
deleted file mode 100644
index d1a7a66..0000000
--- a/clap/src/args/arg_builder/mod.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-pub use self::flag::FlagBuilder;
-pub use self::option::OptBuilder;
-pub use self::positional::PosBuilder;
-pub use self::base::Base;
-pub use self::switched::Switched;
-pub use self::valued::Valued;
-
-mod flag;
-mod positional;
-mod option;
-mod base;
-mod valued;
-mod switched;
diff --git a/clap/src/args/arg_builder/option.rs b/clap/src/args/arg_builder/option.rs
deleted file mode 100644
index 4bb147a..0000000
--- a/clap/src/args/arg_builder/option.rs
+++ /dev/null
@@ -1,244 +0,0 @@
-// Std
-use std::fmt::{Display, Formatter, Result};
-use std::rc::Rc;
-use std::result::Result as StdResult;
-use std::ffi::{OsStr, OsString};
-use std::mem;
-
-// Internal
-use args::{AnyArg, Arg, ArgSettings, Base, DispOrder, Switched, Valued};
-use map::{self, VecMap};
-use INTERNAL_ERROR_MSG;
-
-#[allow(missing_debug_implementations)]
-#[doc(hidden)]
-#[derive(Default, Clone)]
-pub struct OptBuilder<'n, 'e>
-where
- 'n: 'e,
-{
- pub b: Base<'n, 'e>,
- pub s: Switched<'e>,
- pub v: Valued<'n, 'e>,
-}
-
-impl<'n, 'e> OptBuilder<'n, 'e> {
- pub fn new(name: &'n str) -> Self {
- OptBuilder {
- b: Base::new(name),
- ..Default::default()
- }
- }
-}
-
-impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for OptBuilder<'n, 'e> {
- fn from(a: &'z Arg<'n, 'e>) -> Self {
- OptBuilder {
- b: Base::from(a),
- s: Switched::from(a),
- v: Valued::from(a),
- }
- }
-}
-
-impl<'n, 'e> From<Arg<'n, 'e>> for OptBuilder<'n, 'e> {
- fn from(mut a: Arg<'n, 'e>) -> Self {
- a.v.fill_in();
- OptBuilder {
- b: mem::replace(&mut a.b, Base::default()),
- s: mem::replace(&mut a.s, Switched::default()),
- v: mem::replace(&mut a.v, Valued::default()),
- }
- }
-}
-
-impl<'n, 'e> Display for OptBuilder<'n, 'e> {
- fn fmt(&self, f: &mut Formatter) -> Result {
- debugln!("OptBuilder::fmt:{}", self.b.name);
- let sep = if self.b.is_set(ArgSettings::RequireEquals) {
- "="
- } else {
- " "
- };
- // Write the name such --long or -l
- if let Some(l) = self.s.long {
- write!(f, "--{}{}", l, sep)?;
- } else {
- write!(f, "-{}{}", self.s.short.unwrap(), sep)?;
- }
- let delim = if self.is_set(ArgSettings::RequireDelimiter) {
- self.v.val_delim.expect(INTERNAL_ERROR_MSG)
- } else {
- ' '
- };
-
- // Write the values such as <name1> <name2>
- if let Some(ref vec) = self.v.val_names {
- let mut it = vec.iter().peekable();
- while let Some((_, val)) = it.next() {
- write!(f, "<{}>", val)?;
- if it.peek().is_some() {
- write!(f, "{}", delim)?;
- }
- }
- let num = vec.len();
- if self.is_set(ArgSettings::Multiple) && num == 1 {
- write!(f, "...")?;
- }
- } else if let Some(num) = self.v.num_vals {
- let mut it = (0..num).peekable();
- while let Some(_) = it.next() {
- write!(f, "<{}>", self.b.name)?;
- if it.peek().is_some() {
- write!(f, "{}", delim)?;
- }
- }
- if self.is_set(ArgSettings::Multiple) && num == 1 {
- write!(f, "...")?;
- }
- } else {
- write!(
- f,
- "<{}>{}",
- self.b.name,
- if self.is_set(ArgSettings::Multiple) {
- "..."
- } else {
- ""
- }
- )?;
- }
-
- Ok(())
- }
-}
-
-impl<'n, 'e> AnyArg<'n, 'e> for OptBuilder<'n, 'e> {
- fn name(&self) -> &'n str { self.b.name }
- fn overrides(&self) -> Option<&[&'e str]> { self.b.overrides.as_ref().map(|o| &o[..]) }
- fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]> {
- self.b.requires.as_ref().map(|o| &o[..])
- }
- fn blacklist(&self) -> Option<&[&'e str]> { self.b.blacklist.as_ref().map(|o| &o[..]) }
- fn required_unless(&self) -> Option<&[&'e str]> { self.b.r_unless.as_ref().map(|o| &o[..]) }
- fn val_names(&self) -> Option<&VecMap<&'e str>> { self.v.val_names.as_ref() }
- fn is_set(&self, s: ArgSettings) -> bool { self.b.settings.is_set(s) }
- fn has_switch(&self) -> bool { true }
- fn set(&mut self, s: ArgSettings) { self.b.settings.set(s) }
- fn max_vals(&self) -> Option<u64> { self.v.max_vals }
- fn val_terminator(&self) -> Option<&'e str> { self.v.terminator }
- fn num_vals(&self) -> Option<u64> { self.v.num_vals }
- fn possible_vals(&self) -> Option<&[&'e str]> { self.v.possible_vals.as_ref().map(|o| &o[..]) }
- fn validator(&self) -> Option<&Rc<Fn(String) -> StdResult<(), String>>> {
- self.v.validator.as_ref()
- }
- fn validator_os(&self) -> Option<&Rc<Fn(&OsStr) -> StdResult<(), OsString>>> {
- self.v.validator_os.as_ref()
- }
- fn min_vals(&self) -> Option<u64> { self.v.min_vals }
- fn short(&self) -> Option<char> { self.s.short }
- fn long(&self) -> Option<&'e str> { self.s.long }
- fn val_delim(&self) -> Option<char> { self.v.val_delim }
- fn takes_value(&self) -> bool { true }
- fn help(&self) -> Option<&'e str> { self.b.help }
- fn long_help(&self) -> Option<&'e str> { self.b.long_help }
- fn default_val(&self) -> Option<&'e OsStr> { self.v.default_val }
- fn default_vals_ifs(&self) -> Option<map::Values<(&'n str, Option<&'e OsStr>, &'e OsStr)>> {
- self.v.default_vals_ifs.as_ref().map(|vm| vm.values())
- }
- fn env<'s>(&'s self) -> Option<(&'n OsStr, Option<&'s OsString>)> {
- self.v
- .env
- .as_ref()
- .map(|&(key, ref value)| (key, value.as_ref()))
- }
- fn longest_filter(&self) -> bool { true }
- fn aliases(&self) -> Option<Vec<&'e str>> {
- if let Some(ref aliases) = self.s.aliases {
- let vis_aliases: Vec<_> = aliases
- .iter()
- .filter_map(|&(n, v)| if v { Some(n) } else { None })
- .collect();
- if vis_aliases.is_empty() {
- None
- } else {
- Some(vis_aliases)
- }
- } else {
- None
- }
- }
-}
-
-impl<'n, 'e> DispOrder for OptBuilder<'n, 'e> {
- fn disp_ord(&self) -> usize { self.s.disp_ord }
-}
-
-impl<'n, 'e> PartialEq for OptBuilder<'n, 'e> {
- fn eq(&self, other: &OptBuilder<'n, 'e>) -> bool { self.b == other.b }
-}
-
-#[cfg(test)]
-mod test {
- use args::settings::ArgSettings;
- use super::OptBuilder;
- use map::VecMap;
-
- #[test]
- fn optbuilder_display1() {
- let mut o = OptBuilder::new("opt");
- o.s.long = Some("option");
- o.b.settings.set(ArgSettings::Multiple);
-
- assert_eq!(&*format!("{}", o), "--option <opt>...");
- }
-
- #[test]
- fn optbuilder_display2() {
- let mut v_names = VecMap::new();
- v_names.insert(0, "file");
- v_names.insert(1, "name");
-
- let mut o2 = OptBuilder::new("opt");
- o2.s.short = Some('o');
- o2.v.val_names = Some(v_names);
-
- assert_eq!(&*format!("{}", o2), "-o <file> <name>");
- }
-
- #[test]
- fn optbuilder_display3() {
- let mut v_names = VecMap::new();
- v_names.insert(0, "file");
- v_names.insert(1, "name");
-
- let mut o2 = OptBuilder::new("opt");
- o2.s.short = Some('o');
- o2.v.val_names = Some(v_names);
- o2.b.settings.set(ArgSettings::Multiple);
-
- assert_eq!(&*format!("{}", o2), "-o <file> <name>");
- }
-
- #[test]
- fn optbuilder_display_single_alias() {
- let mut o = OptBuilder::new("opt");
- o.s.long = Some("option");
- o.s.aliases = Some(vec![("als", true)]);
-
- assert_eq!(&*format!("{}", o), "--option <opt>");
- }
-
- #[test]
- fn optbuilder_display_multiple_aliases() {
- let mut o = OptBuilder::new("opt");
- o.s.long = Some("option");
- o.s.aliases = Some(vec![
- ("als_not_visible", false),
- ("als2", true),
- ("als3", true),
- ("als4", true),
- ]);
- assert_eq!(&*format!("{}", o), "--option <opt>");
- }
-}
diff --git a/clap/src/args/arg_builder/positional.rs b/clap/src/args/arg_builder/positional.rs
deleted file mode 100644
index 43fdca4..0000000
--- a/clap/src/args/arg_builder/positional.rs
+++ /dev/null
@@ -1,229 +0,0 @@
-// Std
-use std::borrow::Cow;
-use std::fmt::{Display, Formatter, Result};
-use std::rc::Rc;
-use std::result::Result as StdResult;
-use std::ffi::{OsStr, OsString};
-use std::mem;
-
-// Internal
-use Arg;
-use args::{AnyArg, ArgSettings, Base, DispOrder, Valued};
-use INTERNAL_ERROR_MSG;
-use map::{self, VecMap};
-
-#[allow(missing_debug_implementations)]
-#[doc(hidden)]
-#[derive(Clone, Default)]
-pub struct PosBuilder<'n, 'e>
-where
- 'n: 'e,
-{
- pub b: Base<'n, 'e>,
- pub v: Valued<'n, 'e>,
- pub index: u64,
-}
-
-impl<'n, 'e> PosBuilder<'n, 'e> {
- pub fn new(name: &'n str, idx: u64) -> Self {
- PosBuilder {
- b: Base::new(name),
- index: idx,
- ..Default::default()
- }
- }
-
- pub fn from_arg_ref(a: &Arg<'n, 'e>, idx: u64) -> Self {
- let mut pb = PosBuilder {
- b: Base::from(a),
- v: Valued::from(a),
- index: idx,
- };
- if a.v.max_vals.is_some() || a.v.min_vals.is_some()
- || (a.v.num_vals.is_some() && a.v.num_vals.unwrap() > 1)
- {
- pb.b.settings.set(ArgSettings::Multiple);
- }
- pb
- }
-
- pub fn from_arg(mut a: Arg<'n, 'e>, idx: u64) -> Self {
- if a.v.max_vals.is_some() || a.v.min_vals.is_some()
- || (a.v.num_vals.is_some() && a.v.num_vals.unwrap() > 1)
- {
- a.b.settings.set(ArgSettings::Multiple);
- }
- PosBuilder {
- b: mem::replace(&mut a.b, Base::default()),
- v: mem::replace(&mut a.v, Valued::default()),
- index: idx,
- }
- }
-
- pub fn multiple_str(&self) -> &str {
- let mult_vals = self.v
- .val_names
- .as_ref()
- .map_or(true, |names| names.len() < 2);
- if self.is_set(ArgSettings::Multiple) && mult_vals {
- "..."
- } else {
- ""
- }
- }
-
- pub fn name_no_brackets(&self) -> Cow<str> {
- debugln!("PosBuilder::name_no_brackets;");
- let mut delim = String::new();
- delim.push(if self.is_set(ArgSettings::RequireDelimiter) {
- self.v.val_delim.expect(INTERNAL_ERROR_MSG)
- } else {
- ' '
- });
- if let Some(ref names) = self.v.val_names {
- debugln!("PosBuilder:name_no_brackets: val_names={:#?}", names);
- if names.len() > 1 {
- Cow::Owned(
- names
- .values()
- .map(|n| format!("<{}>", n))
- .collect::<Vec<_>>()
- .join(&*delim),
- )
- } else {
- Cow::Borrowed(names.values().next().expect(INTERNAL_ERROR_MSG))
- }
- } else {
- debugln!("PosBuilder:name_no_brackets: just name");
- Cow::Borrowed(self.b.name)
- }
- }
-}
-
-impl<'n, 'e> Display for PosBuilder<'n, 'e> {
- fn fmt(&self, f: &mut Formatter) -> Result {
- let mut delim = String::new();
- delim.push(if self.is_set(ArgSettings::RequireDelimiter) {
- self.v.val_delim.expect(INTERNAL_ERROR_MSG)
- } else {
- ' '
- });
- if let Some(ref names) = self.v.val_names {
- write!(
- f,
- "{}",
- names
- .values()
- .map(|n| format!("<{}>", n))
- .collect::<Vec<_>>()
- .join(&*delim)
- )?;
- } else {
- write!(f, "<{}>", self.b.name)?;
- }
- if self.b.settings.is_set(ArgSettings::Multiple)
- && (self.v.val_names.is_none() || self.v.val_names.as_ref().unwrap().len() == 1)
- {
- write!(f, "...")?;
- }
-
- Ok(())
- }
-}
-
-impl<'n, 'e> AnyArg<'n, 'e> for PosBuilder<'n, 'e> {
- fn name(&self) -> &'n str { self.b.name }
- fn overrides(&self) -> Option<&[&'e str]> { self.b.overrides.as_ref().map(|o| &o[..]) }
- fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]> {
- self.b.requires.as_ref().map(|o| &o[..])
- }
- fn blacklist(&self) -> Option<&[&'e str]> { self.b.blacklist.as_ref().map(|o| &o[..]) }
- fn required_unless(&self) -> Option<&[&'e str]> { self.b.r_unless.as_ref().map(|o| &o[..]) }
- fn val_names(&self) -> Option<&VecMap<&'e str>> { self.v.val_names.as_ref() }
- fn is_set(&self, s: ArgSettings) -> bool { self.b.settings.is_set(s) }
- fn set(&mut self, s: ArgSettings) { self.b.settings.set(s) }
- fn has_switch(&self) -> bool { false }
- fn max_vals(&self) -> Option<u64> { self.v.max_vals }
- fn val_terminator(&self) -> Option<&'e str> { self.v.terminator }
- fn num_vals(&self) -> Option<u64> { self.v.num_vals }
- fn possible_vals(&self) -> Option<&[&'e str]> { self.v.possible_vals.as_ref().map(|o| &o[..]) }
- fn validator(&self) -> Option<&Rc<Fn(String) -> StdResult<(), String>>> {
- self.v.validator.as_ref()
- }
- fn validator_os(&self) -> Option<&Rc<Fn(&OsStr) -> StdResult<(), OsString>>> {
- self.v.validator_os.as_ref()
- }
- fn min_vals(&self) -> Option<u64> { self.v.min_vals }
- fn short(&self) -> Option<char> { None }
- fn long(&self) -> Option<&'e str> { None }
- fn val_delim(&self) -> Option<char> { self.v.val_delim }
- fn takes_value(&self) -> bool { true }
- fn help(&self) -> Option<&'e str> { self.b.help }
- fn long_help(&self) -> Option<&'e str> { self.b.long_help }
- fn default_vals_ifs(&self) -> Option<map::Values<(&'n str, Option<&'e OsStr>, &'e OsStr)>> {
- self.v.default_vals_ifs.as_ref().map(|vm| vm.values())
- }
- fn default_val(&self) -> Option<&'e OsStr> { self.v.default_val }
- fn env<'s>(&'s self) -> Option<(&'n OsStr, Option<&'s OsString>)> {
- self.v
- .env
- .as_ref()
- .map(|&(key, ref value)| (key, value.as_ref()))
- }
- fn longest_filter(&self) -> bool { true }
- fn aliases(&self) -> Option<Vec<&'e str>> { None }
-}
-
-impl<'n, 'e> DispOrder for PosBuilder<'n, 'e> {
- fn disp_ord(&self) -> usize { self.index as usize }
-}
-
-impl<'n, 'e> PartialEq for PosBuilder<'n, 'e> {
- fn eq(&self, other: &PosBuilder<'n, 'e>) -> bool { self.b == other.b }
-}
-
-#[cfg(test)]
-mod test {
- use args::settings::ArgSettings;
- use super::PosBuilder;
- use map::VecMap;
-
- #[test]
- fn display_mult() {
- let mut p = PosBuilder::new("pos", 1);
- p.b.settings.set(ArgSettings::Multiple);
-
- assert_eq!(&*format!("{}", p), "<pos>...");
- }
-
- #[test]
- fn display_required() {
- let mut p2 = PosBuilder::new("pos", 1);
- p2.b.settings.set(ArgSettings::Required);
-
- assert_eq!(&*format!("{}", p2), "<pos>");
- }
-
- #[test]
- fn display_val_names() {
- let mut p2 = PosBuilder::new("pos", 1);
- let mut vm = VecMap::new();
- vm.insert(0, "file1");
- vm.insert(1, "file2");
- p2.v.val_names = Some(vm);
-
- assert_eq!(&*format!("{}", p2), "<file1> <file2>");
- }
-
- #[test]
- fn display_val_names_req() {
- let mut p2 = PosBuilder::new("pos", 1);
- p2.b.settings.set(ArgSettings::Required);
- let mut vm = VecMap::new();
- vm.insert(0, "file1");
- vm.insert(1, "file2");
- p2.v.val_names = Some(vm);
-
- assert_eq!(&*format!("{}", p2), "<file1> <file2>");
- }
-}
diff --git a/clap/src/args/arg_builder/switched.rs b/clap/src/args/arg_builder/switched.rs
deleted file mode 100644
index 224b2f2..0000000
--- a/clap/src/args/arg_builder/switched.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use Arg;
-
-#[derive(Debug)]
-pub struct Switched<'b> {
- pub short: Option<char>,
- pub long: Option<&'b str>,
- pub aliases: Option<Vec<(&'b str, bool)>>, // (name, visible)
- pub disp_ord: usize,
- pub unified_ord: usize,
-}
-
-impl<'e> Default for Switched<'e> {
- fn default() -> Self {
- Switched {
- short: None,
- long: None,
- aliases: None,
- disp_ord: 999,
- unified_ord: 999,
- }
- }
-}
-
-impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for Switched<'e> {
- fn from(a: &'z Arg<'n, 'e>) -> Self { a.s.clone() }
-}
-
-impl<'e> Clone for Switched<'e> {
- fn clone(&self) -> Self {
- Switched {
- short: self.short,
- long: self.long,
- aliases: self.aliases.clone(),
- disp_ord: self.disp_ord,
- unified_ord: self.unified_ord,
- }
- }
-}
diff --git a/clap/src/args/arg_builder/valued.rs b/clap/src/args/arg_builder/valued.rs
deleted file mode 100644
index d70854d..0000000
--- a/clap/src/args/arg_builder/valued.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-use std::rc::Rc;
-use std::ffi::{OsStr, OsString};
-
-use map::VecMap;
-
-use Arg;
-
-#[allow(missing_debug_implementations)]
-#[derive(Clone)]
-pub struct Valued<'a, 'b>
-where
- 'a: 'b,
-{
- pub possible_vals: Option<Vec<&'b str>>,
- pub val_names: Option<VecMap<&'b str>>,
- pub num_vals: Option<u64>,
- pub max_vals: Option<u64>,
- pub min_vals: Option<u64>,
- pub validator: Option<Rc<Fn(String) -> Result<(), String>>>,
- pub validator_os: Option<Rc<Fn(&OsStr) -> Result<(), OsString>>>,
- pub val_delim: Option<char>,
- pub default_val: Option<&'b OsStr>,
- pub default_vals_ifs: Option<VecMap<(&'a str, Option<&'b OsStr>, &'b OsStr)>>,
- pub env: Option<(&'a OsStr, Option<OsString>)>,
- pub terminator: Option<&'b str>,
-}
-
-impl<'n, 'e> Default for Valued<'n, 'e> {
- fn default() -> Self {
- Valued {
- possible_vals: None,
- num_vals: None,
- min_vals: None,
- max_vals: None,
- val_names: None,
- validator: None,
- validator_os: None,
- val_delim: None,
- default_val: None,
- default_vals_ifs: None,
- env: None,
- terminator: None,
- }
- }
-}
-
-impl<'n, 'e> Valued<'n, 'e> {
- pub fn fill_in(&mut self) {
- if let Some(ref vec) = self.val_names {
- if vec.len() > 1 {
- self.num_vals = Some(vec.len() as u64);
- }
- }
- }
-}
-
-impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for Valued<'n, 'e> {
- fn from(a: &'z Arg<'n, 'e>) -> Self {
- let mut v = a.v.clone();
- if let Some(ref vec) = a.v.val_names {
- if vec.len() > 1 {
- v.num_vals = Some(vec.len() as u64);
- }
- }
- v
- }
-}
diff --git a/clap/src/args/arg_matcher.rs b/clap/src/args/arg_matcher.rs
deleted file mode 100644
index e1d8067..0000000
--- a/clap/src/args/arg_matcher.rs
+++ /dev/null
@@ -1,218 +0,0 @@
-// Std
-use std::collections::hash_map::{Entry, Iter};
-use std::collections::HashMap;
-use std::ffi::OsStr;
-use std::ops::Deref;
-use std::mem;
-
-// Internal
-use args::{ArgMatches, MatchedArg, SubCommand};
-use args::AnyArg;
-use args::settings::ArgSettings;
-
-#[doc(hidden)]
-#[allow(missing_debug_implementations)]
-pub struct ArgMatcher<'a>(pub ArgMatches<'a>);
-
-impl<'a> Default for ArgMatcher<'a> {
- fn default() -> Self { ArgMatcher(ArgMatches::default()) }
-}
-
-impl<'a> ArgMatcher<'a> {
- pub fn new() -> Self { ArgMatcher::default() }
-
- pub fn process_arg_overrides<'b>(&mut self, a: Option<&AnyArg<'a, 'b>>, overrides: &mut Vec<(&'b str, &'a str)>, required: &mut Vec<&'a str>, check_all: bool) {
- debugln!("ArgMatcher::process_arg_overrides:{:?};", a.map_or(None, |a| Some(a.name())));
- if let Some(aa) = a {
- let mut self_done = false;
- if let Some(a_overrides) = aa.overrides() {
- for overr in a_overrides {
- debugln!("ArgMatcher::process_arg_overrides:iter:{};", overr);
- if overr == &aa.name() {
- self_done = true;
- self.handle_self_overrides(a);
- } else if self.is_present(overr) {
- debugln!("ArgMatcher::process_arg_overrides:iter:{}: removing from matches;", overr);
- self.remove(overr);
- for i in (0 .. required.len()).rev() {
- if &required[i] == overr {
- debugln!("ArgMatcher::process_arg_overrides:iter:{}: removing required;", overr);
- required.swap_remove(i);
- break;
- }
- }
- overrides.push((overr, aa.name()));
- } else {
- overrides.push((overr, aa.name()));
- }
- }
- }
- if check_all && !self_done {
- self.handle_self_overrides(a);
- }
- }
- }
-
- pub fn handle_self_overrides<'b>(&mut self, a: Option<&AnyArg<'a, 'b>>) {
- debugln!("ArgMatcher::handle_self_overrides:{:?};", a.map_or(None, |a| Some(a.name())));
- if let Some(aa) = a {
- if !aa.has_switch() || aa.is_set(ArgSettings::Multiple) {
- // positional args can't override self or else we would never advance to the next
-
- // Also flags with --multiple set are ignored otherwise we could never have more
- // than one
- return;
- }
- if let Some(ma) = self.get_mut(aa.name()) {
- if ma.vals.len() > 1 {
- // swap_remove(0) would be O(1) but does not preserve order, which
- // we need
- ma.vals.remove(0);
- ma.occurs = 1;
- } else if !aa.takes_value() && ma.occurs > 1 {
- ma.occurs = 1;
- }
- }
- }
- }
-
- pub fn is_present(&self, name: &str) -> bool {
- self.0.is_present(name)
- }
-
- pub fn propagate_globals(&mut self, global_arg_vec: &[&'a str]) {
- debugln!( "ArgMatcher::get_global_values: global_arg_vec={:?}", global_arg_vec );
- let mut vals_map = HashMap::new();
- self.fill_in_global_values(global_arg_vec, &mut vals_map);
- }
-
- fn fill_in_global_values(
- &mut self,
- global_arg_vec: &[&'a str],
- vals_map: &mut HashMap<&'a str, MatchedArg>,
- ) {
- for global_arg in global_arg_vec {
- if let Some(ma) = self.get(global_arg) {
- // We have to check if the parent's global arg wasn't used but still exists
- // such as from a default value.
- //
- // For example, `myprog subcommand --global-arg=value` where --global-arg defines
- // a default value of `other` myprog would have an existing MatchedArg for
- // --global-arg where the value is `other`, however the occurs will be 0.
- let to_update = if let Some(parent_ma) = vals_map.get(global_arg) {
- if parent_ma.occurs > 0 && ma.occurs == 0 {
- parent_ma.clone()
- } else {
- ma.clone()
- }
- } else {
- ma.clone()
- };
- vals_map.insert(global_arg, to_update);
- }
- }
- if let Some(ref mut sc) = self.0.subcommand {
- let mut am = ArgMatcher(mem::replace(&mut sc.matches, ArgMatches::new()));
- am.fill_in_global_values(global_arg_vec, vals_map);
- mem::swap(&mut am.0, &mut sc.matches);
- }
-
- for (name, matched_arg) in vals_map.into_iter() {
- self.0.args.insert(name, matched_arg.clone());
- }
- }
-
- pub fn get_mut(&mut self, arg: &str) -> Option<&mut MatchedArg> { self.0.args.get_mut(arg) }
-
- pub fn get(&self, arg: &str) -> Option<&MatchedArg> { self.0.args.get(arg) }
-
- pub fn remove(&mut self, arg: &str) { self.0.args.remove(arg); }
-
- pub fn remove_all(&mut self, args: &[&str]) {
- for &arg in args {
- self.0.args.remove(arg);
- }
- }
-
- pub fn insert(&mut self, name: &'a str) { self.0.args.insert(name, MatchedArg::new()); }
-
- pub fn contains(&self, arg: &str) -> bool { self.0.args.contains_key(arg) }
-
- pub fn is_empty(&self) -> bool { self.0.args.is_empty() }
-
- pub fn usage(&mut self, usage: String) { self.0.usage = Some(usage); }
-
- pub fn arg_names(&'a self) -> Vec<&'a str> { self.0.args.keys().map(Deref::deref).collect() }
-
- pub fn entry(&mut self, arg: &'a str) -> Entry<&'a str, MatchedArg> { self.0.args.entry(arg) }
-
- pub fn subcommand(&mut self, sc: SubCommand<'a>) { self.0.subcommand = Some(Box::new(sc)); }
-
- pub fn subcommand_name(&self) -> Option<&str> { self.0.subcommand_name() }
-
- pub fn iter(&self) -> Iter<&str, MatchedArg> { self.0.args.iter() }
-
- pub fn inc_occurrence_of(&mut self, arg: &'a str) {
- debugln!("ArgMatcher::inc_occurrence_of: arg={}", arg);
- if let Some(a) = self.get_mut(arg) {
- a.occurs += 1;
- return;
- }
- debugln!("ArgMatcher::inc_occurrence_of: first instance");
- self.insert(arg);
- }
-
- pub fn inc_occurrences_of(&mut self, args: &[&'a str]) {
- debugln!("ArgMatcher::inc_occurrences_of: args={:?}", args);
- for arg in args {
- self.inc_occurrence_of(arg);
- }
- }
-
- pub fn add_val_to(&mut self, arg: &'a str, val: &OsStr) {
- let ma = self.entry(arg).or_insert(MatchedArg {
- occurs: 0,
- indices: Vec::with_capacity(1),
- vals: Vec::with_capacity(1),
- });
- ma.vals.push(val.to_owned());
- }
-
- pub fn add_index_to(&mut self, arg: &'a str, idx: usize) {
- let ma = self.entry(arg).or_insert(MatchedArg {
- occurs: 0,
- indices: Vec::with_capacity(1),
- vals: Vec::new(),
- });
- ma.indices.push(idx);
- }
-
- pub fn needs_more_vals<'b, A>(&self, o: &A) -> bool
- where
- A: AnyArg<'a, 'b>,
- {
- debugln!("ArgMatcher::needs_more_vals: o={}", o.name());
- if let Some(ma) = self.get(o.name()) {
- if let Some(num) = o.num_vals() {
- debugln!("ArgMatcher::needs_more_vals: num_vals...{}", num);
- return if o.is_set(ArgSettings::Multiple) {
- ((ma.vals.len() as u64) % num) != 0
- } else {
- num != (ma.vals.len() as u64)
- };
- } else if let Some(num) = o.max_vals() {
- debugln!("ArgMatcher::needs_more_vals: max_vals...{}", num);
- return !((ma.vals.len() as u64) > num);
- } else if o.min_vals().is_some() {
- debugln!("ArgMatcher::needs_more_vals: min_vals...true");
- return true;
- }
- return o.is_set(ArgSettings::Multiple);
- }
- true
- }
-}
-
-impl<'a> Into<ArgMatches<'a>> for ArgMatcher<'a> {
- fn into(self) -> ArgMatches<'a> { self.0 }
-}
diff --git a/clap/src/args/arg_matches.rs b/clap/src/args/arg_matches.rs
deleted file mode 100644
index 6cf70a4..0000000
--- a/clap/src/args/arg_matches.rs
+++ /dev/null
@@ -1,963 +0,0 @@
-// Std
-use std::borrow::Cow;
-use std::collections::HashMap;
-use std::ffi::{OsStr, OsString};
-use std::iter::Map;
-use std::slice::Iter;
-
-// Internal
-use INVALID_UTF8;
-use args::MatchedArg;
-use args::SubCommand;
-
-/// Used to get information about the arguments that where supplied to the program at runtime by
-/// the user. New instances of this struct are obtained by using the [`App::get_matches`] family of
-/// methods.
-///
-/// # Examples
-///
-/// ```no_run
-/// # use clap::{App, Arg};
-/// let matches = App::new("MyApp")
-/// .arg(Arg::with_name("out")
-/// .long("output")
-/// .required(true)
-/// .takes_value(true))
-/// .arg(Arg::with_name("debug")
-/// .short("d")
-/// .multiple(true))
-/// .arg(Arg::with_name("cfg")
-/// .short("c")
-/// .takes_value(true))
-/// .get_matches(); // builds the instance of ArgMatches
-///
-/// // to get information about the "cfg" argument we created, such as the value supplied we use
-/// // various ArgMatches methods, such as ArgMatches::value_of
-/// if let Some(c) = matches.value_of("cfg") {
-/// println!("Value for -c: {}", c);
-/// }
-///
-/// // The ArgMatches::value_of method returns an Option because the user may not have supplied
-/// // that argument at runtime. But if we specified that the argument was "required" as we did
-/// // with the "out" argument, we can safely unwrap because `clap` verifies that was actually
-/// // used at runtime.
-/// println!("Value for --output: {}", matches.value_of("out").unwrap());
-///
-/// // You can check the presence of an argument
-/// if matches.is_present("out") {
-/// // Another way to check if an argument was present, or if it occurred multiple times is to
-/// // use occurrences_of() which returns 0 if an argument isn't found at runtime, or the
-/// // number of times that it occurred, if it was. To allow an argument to appear more than
-/// // once, you must use the .multiple(true) method, otherwise it will only return 1 or 0.
-/// if matches.occurrences_of("debug") > 2 {
-/// println!("Debug mode is REALLY on, don't be crazy");
-/// } else {
-/// println!("Debug mode kind of on");
-/// }
-/// }
-/// ```
-/// [`App::get_matches`]: ./struct.App.html#method.get_matches
-#[derive(Debug, Clone)]
-pub struct ArgMatches<'a> {
- #[doc(hidden)] pub args: HashMap<&'a str, MatchedArg>,
- #[doc(hidden)] pub subcommand: Option<Box<SubCommand<'a>>>,
- #[doc(hidden)] pub usage: Option<String>,
-}
-
-impl<'a> Default for ArgMatches<'a> {
- fn default() -> Self {
- ArgMatches {
- args: HashMap::new(),
- subcommand: None,
- usage: None,
- }
- }
-}
-
-impl<'a> ArgMatches<'a> {
- #[doc(hidden)]
- pub fn new() -> Self {
- ArgMatches {
- ..Default::default()
- }
- }
-
- /// Gets the value of a specific [option] or [positional] argument (i.e. an argument that takes
- /// an additional value at runtime). If the option wasn't present at runtime
- /// it returns `None`.
- ///
- /// *NOTE:* If getting a value for an option or positional argument that allows multiples,
- /// prefer [`ArgMatches::values_of`] as `ArgMatches::value_of` will only return the *first*
- /// value.
- ///
- /// # Panics
- ///
- /// This method will [`panic!`] if the value contains invalid UTF-8 code points.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("output")
- /// .takes_value(true))
- /// .get_matches_from(vec!["myapp", "something"]);
- ///
- /// assert_eq!(m.value_of("output"), Some("something"));
- /// ```
- /// [option]: ./struct.Arg.html#method.takes_value
- /// [positional]: ./struct.Arg.html#method.index
- /// [`ArgMatches::values_of`]: ./struct.ArgMatches.html#method.values_of
- /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
- pub fn value_of<S: AsRef<str>>(&self, name: S) -> Option<&str> {
- if let Some(arg) = self.args.get(name.as_ref()) {
- if let Some(v) = arg.vals.get(0) {
- return Some(v.to_str().expect(INVALID_UTF8));
- }
- }
- None
- }
-
- /// Gets the lossy value of a specific argument. If the argument wasn't present at runtime
- /// it returns `None`. A lossy value is one which contains invalid UTF-8 code points, those
- /// invalid points will be replaced with `\u{FFFD}`
- ///
- /// *NOTE:* If getting a value for an option or positional argument that allows multiples,
- /// prefer [`Arg::values_of_lossy`] as `value_of_lossy()` will only return the *first* value.
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, Arg};
- /// use std::ffi::OsString;
- /// use std::os::unix::ffi::{OsStrExt,OsStringExt};
- ///
- /// let m = App::new("utf8")
- /// .arg(Arg::from_usage("<arg> 'some arg'"))
- /// .get_matches_from(vec![OsString::from("myprog"),
- /// // "Hi {0xe9}!"
- /// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
- /// assert_eq!(&*m.value_of_lossy("arg").unwrap(), "Hi \u{FFFD}!");
- /// ```
- /// [`Arg::values_of_lossy`]: ./struct.ArgMatches.html#method.values_of_lossy
- pub fn value_of_lossy<S: AsRef<str>>(&'a self, name: S) -> Option<Cow<'a, str>> {
- if let Some(arg) = self.args.get(name.as_ref()) {
- if let Some(v) = arg.vals.get(0) {
- return Some(v.to_string_lossy());
- }
- }
- None
- }
-
- /// Gets the OS version of a string value of a specific argument. If the option wasn't present
- /// at runtime it returns `None`. An OS value on Unix-like systems is any series of bytes,
- /// regardless of whether or not they contain valid UTF-8 code points. Since [`String`]s in
- /// Rust are guaranteed to be valid UTF-8, a valid filename on a Unix system as an argument
- /// value may contain invalid UTF-8 code points.
- ///
- /// *NOTE:* If getting a value for an option or positional argument that allows multiples,
- /// prefer [`ArgMatches::values_of_os`] as `Arg::value_of_os` will only return the *first*
- /// value.
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, Arg};
- /// use std::ffi::OsString;
- /// use std::os::unix::ffi::{OsStrExt,OsStringExt};
- ///
- /// let m = App::new("utf8")
- /// .arg(Arg::from_usage("<arg> 'some arg'"))
- /// .get_matches_from(vec![OsString::from("myprog"),
- /// // "Hi {0xe9}!"
- /// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
- /// assert_eq!(&*m.value_of_os("arg").unwrap().as_bytes(), [b'H', b'i', b' ', 0xe9, b'!']);
- /// ```
- /// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html
- /// [`ArgMatches::values_of_os`]: ./struct.ArgMatches.html#method.values_of_os
- pub fn value_of_os<S: AsRef<str>>(&self, name: S) -> Option<&OsStr> {
- self.args
- .get(name.as_ref())
- .and_then(|arg| arg.vals.get(0).map(|v| v.as_os_str()))
- }
-
- /// Gets a [`Values`] struct which implements [`Iterator`] for values of a specific argument
- /// (i.e. an argument that takes multiple values at runtime). If the option wasn't present at
- /// runtime it returns `None`
- ///
- /// # Panics
- ///
- /// This method will panic if any of the values contain invalid UTF-8 code points.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("output")
- /// .multiple(true)
- /// .short("o")
- /// .takes_value(true))
- /// .get_matches_from(vec![
- /// "myprog", "-o", "val1", "val2", "val3"
- /// ]);
- /// let vals: Vec<&str> = m.values_of("output").unwrap().collect();
- /// assert_eq!(vals, ["val1", "val2", "val3"]);
- /// ```
- /// [`Values`]: ./struct.Values.html
- /// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
- pub fn values_of<S: AsRef<str>>(&'a self, name: S) -> Option<Values<'a>> {
- if let Some(arg) = self.args.get(name.as_ref()) {
- fn to_str_slice(o: &OsString) -> &str { o.to_str().expect(INVALID_UTF8) }
- let to_str_slice: fn(&OsString) -> &str = to_str_slice; // coerce to fn pointer
- return Some(Values {
- iter: arg.vals.iter().map(to_str_slice),
- });
- }
- None
- }
-
- /// Gets the lossy values of a specific argument. If the option wasn't present at runtime
- /// it returns `None`. A lossy value is one where if it contains invalid UTF-8 code points,
- /// those invalid points will be replaced with `\u{FFFD}`
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, Arg};
- /// use std::ffi::OsString;
- /// use std::os::unix::ffi::OsStringExt;
- ///
- /// let m = App::new("utf8")
- /// .arg(Arg::from_usage("<arg>... 'some arg'"))
- /// .get_matches_from(vec![OsString::from("myprog"),
- /// // "Hi"
- /// OsString::from_vec(vec![b'H', b'i']),
- /// // "{0xe9}!"
- /// OsString::from_vec(vec![0xe9, b'!'])]);
- /// let mut itr = m.values_of_lossy("arg").unwrap().into_iter();
- /// assert_eq!(&itr.next().unwrap()[..], "Hi");
- /// assert_eq!(&itr.next().unwrap()[..], "\u{FFFD}!");
- /// assert_eq!(itr.next(), None);
- /// ```
- pub fn values_of_lossy<S: AsRef<str>>(&'a self, name: S) -> Option<Vec<String>> {
- if let Some(arg) = self.args.get(name.as_ref()) {
- return Some(
- arg.vals
- .iter()
- .map(|v| v.to_string_lossy().into_owned())
- .collect(),
- );
- }
- None
- }
-
- /// Gets a [`OsValues`] struct which is implements [`Iterator`] for [`OsString`] values of a
- /// specific argument. If the option wasn't present at runtime it returns `None`. An OS value
- /// on Unix-like systems is any series of bytes, regardless of whether or not they contain
- /// valid UTF-8 code points. Since [`String`]s in Rust are guaranteed to be valid UTF-8, a valid
- /// filename as an argument value on Linux (for example) may contain invalid UTF-8 code points.
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, Arg};
- /// use std::ffi::{OsStr,OsString};
- /// use std::os::unix::ffi::{OsStrExt,OsStringExt};
- ///
- /// let m = App::new("utf8")
- /// .arg(Arg::from_usage("<arg>... 'some arg'"))
- /// .get_matches_from(vec![OsString::from("myprog"),
- /// // "Hi"
- /// OsString::from_vec(vec![b'H', b'i']),
- /// // "{0xe9}!"
- /// OsString::from_vec(vec![0xe9, b'!'])]);
- ///
- /// let mut itr = m.values_of_os("arg").unwrap().into_iter();
- /// assert_eq!(itr.next(), Some(OsStr::new("Hi")));
- /// assert_eq!(itr.next(), Some(OsStr::from_bytes(&[0xe9, b'!'])));
- /// assert_eq!(itr.next(), None);
- /// ```
- /// [`OsValues`]: ./struct.OsValues.html
- /// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
- /// [`OsString`]: https://doc.rust-lang.org/std/ffi/struct.OsString.html
- /// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html
- pub fn values_of_os<S: AsRef<str>>(&'a self, name: S) -> Option<OsValues<'a>> {
- fn to_str_slice(o: &OsString) -> &OsStr { &*o }
- let to_str_slice: fn(&'a OsString) -> &'a OsStr = to_str_slice; // coerce to fn pointer
- if let Some(arg) = self.args.get(name.as_ref()) {
- return Some(OsValues {
- iter: arg.vals.iter().map(to_str_slice),
- });
- }
- None
- }
-
- /// Returns `true` if an argument was present at runtime, otherwise `false`.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("debug")
- /// .short("d"))
- /// .get_matches_from(vec![
- /// "myprog", "-d"
- /// ]);
- ///
- /// assert!(m.is_present("debug"));
- /// ```
- pub fn is_present<S: AsRef<str>>(&self, name: S) -> bool {
- if let Some(ref sc) = self.subcommand {
- if sc.name == name.as_ref() {
- return true;
- }
- }
- self.args.contains_key(name.as_ref())
- }
-
- /// Returns the number of times an argument was used at runtime. If an argument isn't present
- /// it will return `0`.
- ///
- /// **NOTE:** This returns the number of times the argument was used, *not* the number of
- /// values. For example, `-o val1 val2 val3 -o val4` would return `2` (2 occurrences, but 4
- /// values).
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("debug")
- /// .short("d")
- /// .multiple(true))
- /// .get_matches_from(vec![
- /// "myprog", "-d", "-d", "-d"
- /// ]);
- ///
- /// assert_eq!(m.occurrences_of("debug"), 3);
- /// ```
- ///
- /// This next example shows that counts actual uses of the argument, not just `-`'s
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("debug")
- /// .short("d")
- /// .multiple(true))
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .get_matches_from(vec![
- /// "myprog", "-ddfd"
- /// ]);
- ///
- /// assert_eq!(m.occurrences_of("debug"), 3);
- /// assert_eq!(m.occurrences_of("flag"), 1);
- /// ```
- pub fn occurrences_of<S: AsRef<str>>(&self, name: S) -> u64 {
- self.args.get(name.as_ref()).map_or(0, |a| a.occurs)
- }
-
- /// Gets the starting index of the argument in respect to all other arguments. Indices are
- /// similar to argv indices, but are not exactly 1:1.
- ///
- /// For flags (i.e. those arguments which don't have an associated value), indices refer
- /// to occurrence of the switch, such as `-f`, or `--flag`. However, for options the indices
- /// refer to the *values* `-o val` would therefore not represent two distinct indices, only the
- /// index for `val` would be recorded. This is by design.
- ///
- /// Besides the flag/option descrepancy, the primary difference between an argv index and clap
- /// index, is that clap continues counting once all arguments have properly seperated, whereas
- /// an argv index does not.
- ///
- /// The examples should clear this up.
- ///
- /// *NOTE:* If an argument is allowed multiple times, this method will only give the *first*
- /// index.
- ///
- /// # Examples
- ///
- /// The argv indices are listed in the comments below. See how they correspond to the clap
- /// indices. Note that if it's not listed in a clap index, this is becuase it's not saved in
- /// in an `ArgMatches` struct for querying.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true))
- /// .get_matches_from(vec!["myapp", "-f", "-o", "val"]);
- /// // ARGV idices: ^0 ^1 ^2 ^3
- /// // clap idices: ^1 ^3
- ///
- /// assert_eq!(m.index_of("flag"), Some(1));
- /// assert_eq!(m.index_of("option"), Some(3));
- /// ```
- ///
- /// Now notice, if we use one of the other styles of options:
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true))
- /// .get_matches_from(vec!["myapp", "-f", "-o=val"]);
- /// // ARGV idices: ^0 ^1 ^2
- /// // clap idices: ^1 ^3
- ///
- /// assert_eq!(m.index_of("flag"), Some(1));
- /// assert_eq!(m.index_of("option"), Some(3));
- /// ```
- ///
- /// Things become much more complicated, or clear if we look at a more complex combination of
- /// flags. Let's also throw in the final option style for good measure.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("flag2")
- /// .short("F"))
- /// .arg(Arg::with_name("flag3")
- /// .short("z"))
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true))
- /// .get_matches_from(vec!["myapp", "-fzF", "-oval"]);
- /// // ARGV idices: ^0 ^1 ^2
- /// // clap idices: ^1,2,3 ^5
- /// //
- /// // clap sees the above as 'myapp -f -z -F -o val'
- /// // ^0 ^1 ^2 ^3 ^4 ^5
- /// assert_eq!(m.index_of("flag"), Some(1));
- /// assert_eq!(m.index_of("flag2"), Some(3));
- /// assert_eq!(m.index_of("flag3"), Some(2));
- /// assert_eq!(m.index_of("option"), Some(5));
- /// ```
- ///
- /// One final combination of flags/options to see how they combine:
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("flag2")
- /// .short("F"))
- /// .arg(Arg::with_name("flag3")
- /// .short("z"))
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true))
- /// .get_matches_from(vec!["myapp", "-fzFoval"]);
- /// // ARGV idices: ^0 ^1
- /// // clap idices: ^1,2,3^5
- /// //
- /// // clap sees the above as 'myapp -f -z -F -o val'
- /// // ^0 ^1 ^2 ^3 ^4 ^5
- /// assert_eq!(m.index_of("flag"), Some(1));
- /// assert_eq!(m.index_of("flag2"), Some(3));
- /// assert_eq!(m.index_of("flag3"), Some(2));
- /// assert_eq!(m.index_of("option"), Some(5));
- /// ```
- ///
- /// The last part to mention is when values are sent in multiple groups with a [delimiter].
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true))
- /// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
- /// // ARGV idices: ^0 ^1
- /// // clap idices: ^2 ^3 ^4
- /// //
- /// // clap sees the above as 'myapp -o val1 val2 val3'
- /// // ^0 ^1 ^2 ^3 ^4
- /// assert_eq!(m.index_of("option"), Some(2));
- /// ```
- /// [`ArgMatches`]: ./struct.ArgMatches.html
- /// [delimiter]: ./struct.Arg.html#method.value_delimiter
- pub fn index_of<S: AsRef<str>>(&self, name: S) -> Option<usize> {
- if let Some(arg) = self.args.get(name.as_ref()) {
- if let Some(i) = arg.indices.get(0) {
- return Some(*i);
- }
- }
- None
- }
-
- /// Gets all indices of the argument in respect to all other arguments. Indices are
- /// similar to argv indices, but are not exactly 1:1.
- ///
- /// For flags (i.e. those arguments which don't have an associated value), indices refer
- /// to occurrence of the switch, such as `-f`, or `--flag`. However, for options the indices
- /// refer to the *values* `-o val` would therefore not represent two distinct indices, only the
- /// index for `val` would be recorded. This is by design.
- ///
- /// *NOTE:* For more information about how clap indices compare to argv indices, see
- /// [`ArgMatches::index_of`]
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true)
- /// .use_delimiter(true)
- /// .multiple(true))
- /// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
- /// // ARGV idices: ^0 ^1
- /// // clap idices: ^2 ^3 ^4
- /// //
- /// // clap sees the above as 'myapp -o val1 val2 val3'
- /// // ^0 ^1 ^2 ^3 ^4
- /// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]);
- /// ```
- ///
- /// Another quick example is when flags and options are used together
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true))
- /// .arg(Arg::with_name("flag")
- /// .short("f")
- /// .multiple(true))
- /// .get_matches_from(vec!["myapp", "-o", "val1", "-f", "-o", "val2", "-f"]);
- /// // ARGV idices: ^0 ^1 ^2 ^3 ^4 ^5 ^6
- /// // clap idices: ^2 ^3 ^5 ^6
- ///
- /// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 5]);
- /// assert_eq!(m.indices_of("flag").unwrap().collect::<Vec<_>>(), &[3, 6]);
- /// ```
- ///
- /// One final example, which is an odd case; if we *don't* use value delimiter as we did with
- /// the first example above instead of `val1`, `val2` and `val3` all being distinc values, they
- /// would all be a single value of `val1,val2,val3`, in which case case they'd only receive a
- /// single index.
- ///
- /// ```rust
- /// # use clap::{App, Arg};
- /// let m = App::new("myapp")
- /// .arg(Arg::with_name("option")
- /// .short("o")
- /// .takes_value(true)
- /// .multiple(true))
- /// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
- /// // ARGV idices: ^0 ^1
- /// // clap idices: ^2
- /// //
- /// // clap sees the above as 'myapp -o "val1,val2,val3"'
- /// // ^0 ^1 ^2
- /// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2]);
- /// ```
- /// [`ArgMatches`]: ./struct.ArgMatches.html
- /// [`ArgMatches::index_of`]: ./struct.ArgMatches.html#method.index_of
- /// [delimiter]: ./struct.Arg.html#method.value_delimiter
- pub fn indices_of<S: AsRef<str>>(&'a self, name: S) -> Option<Indices<'a>> {
- if let Some(arg) = self.args.get(name.as_ref()) {
- fn to_usize(i: &usize) -> usize { *i }
- let to_usize: fn(&usize) -> usize = to_usize; // coerce to fn pointer
- return Some(Indices {
- iter: arg.indices.iter().map(to_usize),
- });
- }
- None
- }
-
- /// Because [`Subcommand`]s are essentially "sub-[`App`]s" they have their own [`ArgMatches`]
- /// as well. This method returns the [`ArgMatches`] for a particular subcommand or `None` if
- /// the subcommand wasn't present at runtime.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, SubCommand};
- /// let app_m = App::new("myprog")
- /// .arg(Arg::with_name("debug")
- /// .short("d"))
- /// .subcommand(SubCommand::with_name("test")
- /// .arg(Arg::with_name("opt")
- /// .long("option")
- /// .takes_value(true)))
- /// .get_matches_from(vec![
- /// "myprog", "-d", "test", "--option", "val"
- /// ]);
- ///
- /// // Both parent commands, and child subcommands can have arguments present at the same times
- /// assert!(app_m.is_present("debug"));
- ///
- /// // Get the subcommand's ArgMatches instance
- /// if let Some(sub_m) = app_m.subcommand_matches("test") {
- /// // Use the struct like normal
- /// assert_eq!(sub_m.value_of("opt"), Some("val"));
- /// }
- /// ```
- /// [`Subcommand`]: ./struct.SubCommand.html
- /// [`App`]: ./struct.App.html
- /// [`ArgMatches`]: ./struct.ArgMatches.html
- pub fn subcommand_matches<S: AsRef<str>>(&self, name: S) -> Option<&ArgMatches<'a>> {
- if let Some(ref s) = self.subcommand {
- if s.name == name.as_ref() {
- return Some(&s.matches);
- }
- }
- None
- }
-
- /// Because [`Subcommand`]s are essentially "sub-[`App`]s" they have their own [`ArgMatches`]
- /// as well.But simply getting the sub-[`ArgMatches`] doesn't help much if we don't also know
- /// which subcommand was actually used. This method returns the name of the subcommand that was
- /// used at runtime, or `None` if one wasn't.
- ///
- /// *NOTE*: Subcommands form a hierarchy, where multiple subcommands can be used at runtime,
- /// but only a single subcommand from any group of sibling commands may used at once.
- ///
- /// An ASCII art depiction may help explain this better...Using a fictional version of `git` as
- /// the demo subject. Imagine the following are all subcommands of `git` (note, the author is
- /// aware these aren't actually all subcommands in the real `git` interface, but it makes
- /// explanation easier)
- ///
- /// ```notrust
- /// Top Level App (git) TOP
- /// |
- /// -----------------------------------------
- /// / | \ \
- /// clone push add commit LEVEL 1
- /// | / \ / \ |
- /// url origin remote ref name message LEVEL 2
- /// / /\
- /// path remote local LEVEL 3
- /// ```
- ///
- /// Given the above fictional subcommand hierarchy, valid runtime uses would be (not an all
- /// inclusive list, and not including argument options per command for brevity and clarity):
- ///
- /// ```sh
- /// $ git clone url
- /// $ git push origin path
- /// $ git add ref local
- /// $ git commit message
- /// ```
- ///
- /// Notice only one command per "level" may be used. You could not, for example, do `$ git
- /// clone url push origin path`
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// let app_m = App::new("git")
- /// .subcommand(SubCommand::with_name("clone"))
- /// .subcommand(SubCommand::with_name("push"))
- /// .subcommand(SubCommand::with_name("commit"))
- /// .get_matches();
- ///
- /// match app_m.subcommand_name() {
- /// Some("clone") => {}, // clone was used
- /// Some("push") => {}, // push was used
- /// Some("commit") => {}, // commit was used
- /// _ => {}, // Either no subcommand or one not tested for...
- /// }
- /// ```
- /// [`Subcommand`]: ./struct.SubCommand.html
- /// [`App`]: ./struct.App.html
- /// [`ArgMatches`]: ./struct.ArgMatches.html
- pub fn subcommand_name(&self) -> Option<&str> {
- self.subcommand.as_ref().map(|sc| &sc.name[..])
- }
-
- /// This brings together [`ArgMatches::subcommand_matches`] and [`ArgMatches::subcommand_name`]
- /// by returning a tuple with both pieces of information.
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// let app_m = App::new("git")
- /// .subcommand(SubCommand::with_name("clone"))
- /// .subcommand(SubCommand::with_name("push"))
- /// .subcommand(SubCommand::with_name("commit"))
- /// .get_matches();
- ///
- /// match app_m.subcommand() {
- /// ("clone", Some(sub_m)) => {}, // clone was used
- /// ("push", Some(sub_m)) => {}, // push was used
- /// ("commit", Some(sub_m)) => {}, // commit was used
- /// _ => {}, // Either no subcommand or one not tested for...
- /// }
- /// ```
- ///
- /// Another useful scenario is when you want to support third party, or external, subcommands.
- /// In these cases you can't know the subcommand name ahead of time, so use a variable instead
- /// with pattern matching!
- ///
- /// ```rust
- /// # use clap::{App, AppSettings};
- /// // Assume there is an external subcommand named "subcmd"
- /// let app_m = App::new("myprog")
- /// .setting(AppSettings::AllowExternalSubcommands)
- /// .get_matches_from(vec![
- /// "myprog", "subcmd", "--option", "value", "-fff", "--flag"
- /// ]);
- ///
- /// // All trailing arguments will be stored under the subcommand's sub-matches using an empty
- /// // string argument name
- /// match app_m.subcommand() {
- /// (external, Some(sub_m)) => {
- /// let ext_args: Vec<&str> = sub_m.values_of("").unwrap().collect();
- /// assert_eq!(external, "subcmd");
- /// assert_eq!(ext_args, ["--option", "value", "-fff", "--flag"]);
- /// },
- /// _ => {},
- /// }
- /// ```
- /// [`ArgMatches::subcommand_matches`]: ./struct.ArgMatches.html#method.subcommand_matches
- /// [`ArgMatches::subcommand_name`]: ./struct.ArgMatches.html#method.subcommand_name
- pub fn subcommand(&self) -> (&str, Option<&ArgMatches<'a>>) {
- self.subcommand
- .as_ref()
- .map_or(("", None), |sc| (&sc.name[..], Some(&sc.matches)))
- }
-
- /// Returns a string slice of the usage statement for the [`App`] or [`SubCommand`]
- ///
- /// # Examples
- ///
- /// ```no_run
- /// # use clap::{App, Arg, SubCommand};
- /// let app_m = App::new("myprog")
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches();
- ///
- /// println!("{}", app_m.usage());
- /// ```
- /// [`Subcommand`]: ./struct.SubCommand.html
- /// [`App`]: ./struct.App.html
- pub fn usage(&self) -> &str { self.usage.as_ref().map_or("", |u| &u[..]) }
-}
-
-
-// The following were taken and adapated from vec_map source
-// repo: https://github.com/contain-rs/vec-map
-// commit: be5e1fa3c26e351761b33010ddbdaf5f05dbcc33
-// license: MIT - Copyright (c) 2015 The Rust Project Developers
-
-/// An iterator for getting multiple values out of an argument via the [`ArgMatches::values_of`]
-/// method.
-///
-/// # Examples
-///
-/// ```rust
-/// # use clap::{App, Arg};
-/// let m = App::new("myapp")
-/// .arg(Arg::with_name("output")
-/// .short("o")
-/// .multiple(true)
-/// .takes_value(true))
-/// .get_matches_from(vec!["myapp", "-o", "val1", "val2"]);
-///
-/// let mut values = m.values_of("output").unwrap();
-///
-/// assert_eq!(values.next(), Some("val1"));
-/// assert_eq!(values.next(), Some("val2"));
-/// assert_eq!(values.next(), None);
-/// ```
-/// [`ArgMatches::values_of`]: ./struct.ArgMatches.html#method.values_of
-#[derive(Debug, Clone)]
-pub struct Values<'a> {
- iter: Map<Iter<'a, OsString>, fn(&'a OsString) -> &'a str>,
-}
-
-impl<'a> Iterator for Values<'a> {
- type Item = &'a str;
-
- fn next(&mut self) -> Option<&'a str> { self.iter.next() }
- fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
-}
-
-impl<'a> DoubleEndedIterator for Values<'a> {
- fn next_back(&mut self) -> Option<&'a str> { self.iter.next_back() }
-}
-
-impl<'a> ExactSizeIterator for Values<'a> {}
-
-/// Creates an empty iterator.
-impl<'a> Default for Values<'a> {
- fn default() -> Self {
- static EMPTY: [OsString; 0] = [];
- // This is never called because the iterator is empty:
- fn to_str_slice(_: &OsString) -> &str { unreachable!() };
- Values {
- iter: EMPTY[..].iter().map(to_str_slice),
- }
- }
-}
-
-/// An iterator for getting multiple values out of an argument via the [`ArgMatches::values_of_os`]
-/// method. Usage of this iterator allows values which contain invalid UTF-8 code points unlike
-/// [`Values`].
-///
-/// # Examples
-///
-#[cfg_attr(not(unix), doc = " ```ignore")]
-#[cfg_attr(unix, doc = " ```")]
-/// # use clap::{App, Arg};
-/// use std::ffi::OsString;
-/// use std::os::unix::ffi::{OsStrExt,OsStringExt};
-///
-/// let m = App::new("utf8")
-/// .arg(Arg::from_usage("<arg> 'some arg'"))
-/// .get_matches_from(vec![OsString::from("myprog"),
-/// // "Hi {0xe9}!"
-/// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
-/// assert_eq!(&*m.value_of_os("arg").unwrap().as_bytes(), [b'H', b'i', b' ', 0xe9, b'!']);
-/// ```
-/// [`ArgMatches::values_of_os`]: ./struct.ArgMatches.html#method.values_of_os
-/// [`Values`]: ./struct.Values.html
-#[derive(Debug, Clone)]
-pub struct OsValues<'a> {
- iter: Map<Iter<'a, OsString>, fn(&'a OsString) -> &'a OsStr>,
-}
-
-impl<'a> Iterator for OsValues<'a> {
- type Item = &'a OsStr;
-
- fn next(&mut self) -> Option<&'a OsStr> { self.iter.next() }
- fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
-}
-
-impl<'a> DoubleEndedIterator for OsValues<'a> {
- fn next_back(&mut self) -> Option<&'a OsStr> { self.iter.next_back() }
-}
-
-impl<'a> ExactSizeIterator for OsValues<'a> {}
-
-/// Creates an empty iterator.
-impl<'a> Default for OsValues<'a> {
- fn default() -> Self {
- static EMPTY: [OsString; 0] = [];
- // This is never called because the iterator is empty:
- fn to_str_slice(_: &OsString) -> &OsStr { unreachable!() };
- OsValues {
- iter: EMPTY[..].iter().map(to_str_slice),
- }
- }
-}
-
-/// An iterator for getting multiple indices out of an argument via the [`ArgMatches::indices_of`]
-/// method.
-///
-/// # Examples
-///
-/// ```rust
-/// # use clap::{App, Arg};
-/// let m = App::new("myapp")
-/// .arg(Arg::with_name("output")
-/// .short("o")
-/// .multiple(true)
-/// .takes_value(true))
-/// .get_matches_from(vec!["myapp", "-o", "val1", "val2"]);
-///
-/// let mut indices = m.indices_of("output").unwrap();
-///
-/// assert_eq!(indices.next(), Some(2));
-/// assert_eq!(indices.next(), Some(3));
-/// assert_eq!(indices.next(), None);
-/// ```
-/// [`ArgMatches::indices_of`]: ./struct.ArgMatches.html#method.indices_of
-#[derive(Debug, Clone)]
-pub struct Indices<'a> { // would rather use '_, but: https://github.com/rust-lang/rust/issues/48469
- iter: Map<Iter<'a, usize>, fn(&'a usize) -> usize>,
-}
-
-impl<'a> Iterator for Indices<'a> {
- type Item = usize;
-
- fn next(&mut self) -> Option<usize> { self.iter.next() }
- fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
-}
-
-impl<'a> DoubleEndedIterator for Indices<'a> {
- fn next_back(&mut self) -> Option<usize> { self.iter.next_back() }
-}
-
-impl<'a> ExactSizeIterator for Indices<'a> {}
-
-/// Creates an empty iterator.
-impl<'a> Default for Indices<'a> {
- fn default() -> Self {
- static EMPTY: [usize; 0] = [];
- // This is never called because the iterator is empty:
- fn to_usize(_: &usize) -> usize { unreachable!() };
- Indices {
- iter: EMPTY[..].iter().map(to_usize),
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn test_default_values() {
- let mut values: Values = Values::default();
- assert_eq!(values.next(), None);
- }
-
- #[test]
- fn test_default_values_with_shorter_lifetime() {
- let matches = ArgMatches::new();
- let mut values = matches.values_of("").unwrap_or_default();
- assert_eq!(values.next(), None);
- }
-
- #[test]
- fn test_default_osvalues() {
- let mut values: OsValues = OsValues::default();
- assert_eq!(values.next(), None);
- }
-
- #[test]
- fn test_default_osvalues_with_shorter_lifetime() {
- let matches = ArgMatches::new();
- let mut values = matches.values_of_os("").unwrap_or_default();
- assert_eq!(values.next(), None);
- }
-
- #[test]
- fn test_default_indices() {
- let mut indices: Indices = Indices::default();
- assert_eq!(indices.next(), None);
- }
-
- #[test]
- fn test_default_indices_with_shorter_lifetime() {
- let matches = ArgMatches::new();
- let mut indices = matches.indices_of("").unwrap_or_default();
- assert_eq!(indices.next(), None);
- }
-}
diff --git a/clap/src/args/group.rs b/clap/src/args/group.rs
deleted file mode 100644
index f8bfb7a..0000000
--- a/clap/src/args/group.rs
+++ /dev/null
@@ -1,635 +0,0 @@
-#[cfg(feature = "yaml")]
-use std::collections::BTreeMap;
-use std::fmt::{Debug, Formatter, Result};
-
-#[cfg(feature = "yaml")]
-use yaml_rust::Yaml;
-
-/// `ArgGroup`s are a family of related [arguments] and way for you to express, "Any of these
-/// arguments". By placing arguments in a logical group, you can create easier requirement and
-/// exclusion rules instead of having to list each argument individually, or when you want a rule
-/// to apply "any but not all" arguments.
-///
-/// For instance, you can make an entire `ArgGroup` required. If [`ArgGroup::multiple(true)`] is
-/// set, this means that at least one argument from that group must be present. If
-/// [`ArgGroup::multiple(false)`] is set (the default), one and *only* one must be present.
-///
-/// You can also do things such as name an entire `ArgGroup` as a [conflict] or [requirement] for
-/// another argument, meaning any of the arguments that belong to that group will cause a failure
-/// if present, or must present respectively.
-///
-/// Perhaps the most common use of `ArgGroup`s is to require one and *only* one argument to be
-/// present out of a given set. Imagine that you had multiple arguments, and you want one of them
-/// to be required, but making all of them required isn't feasible because perhaps they conflict
-/// with each other. For example, lets say that you were building an application where one could
-/// set a given version number by supplying a string with an option argument, i.e.
-/// `--set-ver v1.2.3`, you also wanted to support automatically using a previous version number
-/// and simply incrementing one of the three numbers. So you create three flags `--major`,
-/// `--minor`, and `--patch`. All of these arguments shouldn't be used at one time but you want to
-/// specify that *at least one* of them is used. For this, you can create a group.
-///
-/// Finally, you may use `ArgGroup`s to pull a value from a group of arguments when you don't care
-/// exactly which argument was actually used at runtime.
-///
-/// # Examples
-///
-/// The following example demonstrates using an `ArgGroup` to ensure that one, and only one, of
-/// the arguments from the specified group is present at runtime.
-///
-/// ```rust
-/// # use clap::{App, ArgGroup, ErrorKind};
-/// let result = App::new("app")
-/// .args_from_usage(
-/// "--set-ver [ver] 'set the version manually'
-/// --major 'auto increase major'
-/// --minor 'auto increase minor'
-/// --patch 'auto increase patch'")
-/// .group(ArgGroup::with_name("vers")
-/// .args(&["set-ver", "major", "minor", "patch"])
-/// .required(true))
-/// .get_matches_from_safe(vec!["app", "--major", "--patch"]);
-/// // Because we used two args in the group it's an error
-/// assert!(result.is_err());
-/// let err = result.unwrap_err();
-/// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-/// ```
-/// This next example shows a passing parse of the same scenario
-///
-/// ```rust
-/// # use clap::{App, ArgGroup};
-/// let result = App::new("app")
-/// .args_from_usage(
-/// "--set-ver [ver] 'set the version manually'
-/// --major 'auto increase major'
-/// --minor 'auto increase minor'
-/// --patch 'auto increase patch'")
-/// .group(ArgGroup::with_name("vers")
-/// .args(&["set-ver", "major", "minor","patch"])
-/// .required(true))
-/// .get_matches_from_safe(vec!["app", "--major"]);
-/// assert!(result.is_ok());
-/// let matches = result.unwrap();
-/// // We may not know which of the args was used, so we can test for the group...
-/// assert!(matches.is_present("vers"));
-/// // we could also alternatively check each arg individually (not shown here)
-/// ```
-/// [`ArgGroup::multiple(true)`]: ./struct.ArgGroup.html#method.multiple
-/// [arguments]: ./struct.Arg.html
-/// [conflict]: ./struct.Arg.html#method.conflicts_with
-/// [requirement]: ./struct.Arg.html#method.requires
-#[derive(Default)]
-pub struct ArgGroup<'a> {
- #[doc(hidden)] pub name: &'a str,
- #[doc(hidden)] pub args: Vec<&'a str>,
- #[doc(hidden)] pub required: bool,
- #[doc(hidden)] pub requires: Option<Vec<&'a str>>,
- #[doc(hidden)] pub conflicts: Option<Vec<&'a str>>,
- #[doc(hidden)] pub multiple: bool,
-}
-
-impl<'a> ArgGroup<'a> {
- /// Creates a new instance of `ArgGroup` using a unique string name. The name will be used to
- /// get values from the group or refer to the group inside of conflict and requirement rules.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, ArgGroup};
- /// ArgGroup::with_name("config")
- /// # ;
- /// ```
- pub fn with_name(n: &'a str) -> Self {
- ArgGroup {
- name: n,
- required: false,
- args: vec![],
- requires: None,
- conflicts: None,
- multiple: false,
- }
- }
-
- /// Creates a new instance of `ArgGroup` from a .yml (YAML) file.
- ///
- /// # Examples
- ///
- /// ```ignore
- /// # #[macro_use]
- /// # extern crate clap;
- /// # use clap::ArgGroup;
- /// # fn main() {
- /// let yml = load_yaml!("group.yml");
- /// let ag = ArgGroup::from_yaml(yml);
- /// # }
- /// ```
- #[cfg(feature = "yaml")]
- pub fn from_yaml(y: &'a Yaml) -> ArgGroup<'a> { ArgGroup::from(y.as_hash().unwrap()) }
-
- /// Adds an [argument] to this group by name
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .arg("flag")
- /// .arg("color"))
- /// .get_matches_from(vec!["myprog", "-f"]);
- /// // maybe we don't know which of the two flags was used...
- /// assert!(m.is_present("req_flags"));
- /// // but we can also check individually if needed
- /// assert!(m.is_present("flag"));
- /// ```
- /// [argument]: ./struct.Arg.html
- #[cfg_attr(feature = "lints", allow(should_assert_eq))]
- pub fn arg(mut self, n: &'a str) -> Self {
- assert!(
- self.name != n,
- "ArgGroup '{}' can not have same name as arg inside it",
- &*self.name
- );
- self.args.push(n);
- self
- }
-
- /// Adds multiple [arguments] to this group by name
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"]))
- /// .get_matches_from(vec!["myprog", "-f"]);
- /// // maybe we don't know which of the two flags was used...
- /// assert!(m.is_present("req_flags"));
- /// // but we can also check individually if needed
- /// assert!(m.is_present("flag"));
- /// ```
- /// [arguments]: ./struct.Arg.html
- pub fn args(mut self, ns: &[&'a str]) -> Self {
- for n in ns {
- self = self.arg(n);
- }
- self
- }
-
- /// Allows more than one of the ['Arg']s in this group to be used. (Default: `false`)
- ///
- /// # Examples
- ///
- /// Notice in this example we use *both* the `-f` and `-c` flags which are both part of the
- /// group
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup};
- /// let m = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"])
- /// .multiple(true))
- /// .get_matches_from(vec!["myprog", "-f", "-c"]);
- /// // maybe we don't know which of the two flags was used...
- /// assert!(m.is_present("req_flags"));
- /// ```
- /// In this next example, we show the default behavior (i.e. `multiple(false)) which will throw
- /// an error if more than one of the args in the group was used.
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup, ErrorKind};
- /// let result = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"]))
- /// .get_matches_from_safe(vec!["myprog", "-f", "-c"]);
- /// // Because we used both args in the group it's an error
- /// assert!(result.is_err());
- /// let err = result.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
- /// ```
- /// ['Arg']: ./struct.Arg.html
- pub fn multiple(mut self, m: bool) -> Self {
- self.multiple = m;
- self
- }
-
- /// Sets the group as required or not. A required group will be displayed in the usage string
- /// of the application in the format `<arg|arg2|arg3>`. A required `ArgGroup` simply states
- /// that one argument from this group *must* be present at runtime (unless
- /// conflicting with another argument).
- ///
- /// **NOTE:** This setting only applies to the current [`App`] / [`SubCommand`], and not
- /// globally.
- ///
- /// **NOTE:** By default, [`ArgGroup::multiple`] is set to `false` which when combined with
- /// `ArgGroup::required(true)` states, "One and *only one* arg must be used from this group.
- /// Use of more than one arg is an error." Vice setting `ArgGroup::multiple(true)` which
- /// states, '*At least* one arg from this group must be used. Using multiple is OK."
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup, ErrorKind};
- /// let result = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"])
- /// .required(true))
- /// .get_matches_from_safe(vec!["myprog"]);
- /// // Because we didn't use any of the args in the group, it's an error
- /// assert!(result.is_err());
- /// let err = result.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [`App`]: ./struct.App.html
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`ArgGroup::multiple`]: ./struct.ArgGroup.html#method.multiple
- pub fn required(mut self, r: bool) -> Self {
- self.required = r;
- self
- }
-
- /// Sets the requirement rules of this group. This is not to be confused with a
- /// [required group]. Requirement rules function just like [argument requirement rules], you
- /// can name other arguments or groups that must be present when any one of the arguments from
- /// this group is used.
- ///
- /// **NOTE:** The name provided may be an argument, or group name
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup, ErrorKind};
- /// let result = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .arg(Arg::with_name("debug")
- /// .short("d"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"])
- /// .requires("debug"))
- /// .get_matches_from_safe(vec!["myprog", "-c"]);
- /// // because we used an arg from the group, and the group requires "-d" to be used, it's an
- /// // error
- /// assert!(result.is_err());
- /// let err = result.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [required group]: ./struct.ArgGroup.html#method.required
- /// [argument requirement rules]: ./struct.Arg.html#method.requires
- pub fn requires(mut self, n: &'a str) -> Self {
- if let Some(ref mut reqs) = self.requires {
- reqs.push(n);
- } else {
- self.requires = Some(vec![n]);
- }
- self
- }
-
- /// Sets the requirement rules of this group. This is not to be confused with a
- /// [required group]. Requirement rules function just like [argument requirement rules], you
- /// can name other arguments or groups that must be present when one of the arguments from this
- /// group is used.
- ///
- /// **NOTE:** The names provided may be an argument, or group name
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup, ErrorKind};
- /// let result = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .arg(Arg::with_name("debug")
- /// .short("d"))
- /// .arg(Arg::with_name("verb")
- /// .short("v"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"])
- /// .requires_all(&["debug", "verb"]))
- /// .get_matches_from_safe(vec!["myprog", "-c", "-d"]);
- /// // because we used an arg from the group, and the group requires "-d" and "-v" to be used,
- /// // yet we only used "-d" it's an error
- /// assert!(result.is_err());
- /// let err = result.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
- /// ```
- /// [required group]: ./struct.ArgGroup.html#method.required
- /// [argument requirement rules]: ./struct.Arg.html#method.requires_all
- pub fn requires_all(mut self, ns: &[&'a str]) -> Self {
- for n in ns {
- self = self.requires(n);
- }
- self
- }
-
- /// Sets the exclusion rules of this group. Exclusion (aka conflict) rules function just like
- /// [argument exclusion rules], you can name other arguments or groups that must *not* be
- /// present when one of the arguments from this group are used.
- ///
- /// **NOTE:** The name provided may be an argument, or group name
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup, ErrorKind};
- /// let result = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .arg(Arg::with_name("debug")
- /// .short("d"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"])
- /// .conflicts_with("debug"))
- /// .get_matches_from_safe(vec!["myprog", "-c", "-d"]);
- /// // because we used an arg from the group, and the group conflicts with "-d", it's an error
- /// assert!(result.is_err());
- /// let err = result.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
- /// ```
- /// [argument exclusion rules]: ./struct.Arg.html#method.conflicts_with
- pub fn conflicts_with(mut self, n: &'a str) -> Self {
- if let Some(ref mut confs) = self.conflicts {
- confs.push(n);
- } else {
- self.conflicts = Some(vec![n]);
- }
- self
- }
-
- /// Sets the exclusion rules of this group. Exclusion rules function just like
- /// [argument exclusion rules], you can name other arguments or groups that must *not* be
- /// present when one of the arguments from this group are used.
- ///
- /// **NOTE:** The names provided may be an argument, or group name
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ArgGroup, ErrorKind};
- /// let result = App::new("myprog")
- /// .arg(Arg::with_name("flag")
- /// .short("f"))
- /// .arg(Arg::with_name("color")
- /// .short("c"))
- /// .arg(Arg::with_name("debug")
- /// .short("d"))
- /// .arg(Arg::with_name("verb")
- /// .short("v"))
- /// .group(ArgGroup::with_name("req_flags")
- /// .args(&["flag", "color"])
- /// .conflicts_with_all(&["debug", "verb"]))
- /// .get_matches_from_safe(vec!["myprog", "-c", "-v"]);
- /// // because we used an arg from the group, and the group conflicts with either "-v" or "-d"
- /// // it's an error
- /// assert!(result.is_err());
- /// let err = result.unwrap_err();
- /// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
- /// ```
- /// [argument exclusion rules]: ./struct.Arg.html#method.conflicts_with_all
- pub fn conflicts_with_all(mut self, ns: &[&'a str]) -> Self {
- for n in ns {
- self = self.conflicts_with(n);
- }
- self
- }
-}
-
-impl<'a> Debug for ArgGroup<'a> {
- fn fmt(&self, f: &mut Formatter) -> Result {
- write!(
- f,
- "{{\n\
- \tname: {:?},\n\
- \targs: {:?},\n\
- \trequired: {:?},\n\
- \trequires: {:?},\n\
- \tconflicts: {:?},\n\
- }}",
- self.name,
- self.args,
- self.required,
- self.requires,
- self.conflicts
- )
- }
-}
-
-impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
- fn from(g: &'z ArgGroup<'a>) -> Self {
- ArgGroup {
- name: g.name,
- required: g.required,
- args: g.args.clone(),
- requires: g.requires.clone(),
- conflicts: g.conflicts.clone(),
- multiple: g.multiple,
- }
- }
-}
-
-#[cfg(feature = "yaml")]
-impl<'a> From<&'a BTreeMap<Yaml, Yaml>> for ArgGroup<'a> {
- fn from(b: &'a BTreeMap<Yaml, Yaml>) -> Self {
- // We WANT this to panic on error...so expect() is good.
- let mut a = ArgGroup::default();
- let group_settings = if b.len() == 1 {
- let name_yml = b.keys().nth(0).expect("failed to get name");
- let name_str = name_yml
- .as_str()
- .expect("failed to convert arg YAML name to str");
- a.name = name_str;
- b.get(name_yml)
- .expect("failed to get name_str")
- .as_hash()
- .expect("failed to convert to a hash")
- } else {
- b
- };
-
- for (k, v) in group_settings {
- a = match k.as_str().unwrap() {
- "required" => a.required(v.as_bool().unwrap()),
- "multiple" => a.multiple(v.as_bool().unwrap()),
- "args" => yaml_vec_or_str!(v, a, arg),
- "arg" => {
- if let Some(ys) = v.as_str() {
- a = a.arg(ys);
- }
- a
- }
- "requires" => yaml_vec_or_str!(v, a, requires),
- "conflicts_with" => yaml_vec_or_str!(v, a, conflicts_with),
- "name" => {
- if let Some(ys) = v.as_str() {
- a.name = ys;
- }
- a
- }
- s => panic!(
- "Unknown ArgGroup setting '{}' in YAML file for \
- ArgGroup '{}'",
- s,
- a.name
- ),
- }
- }
-
- a
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::ArgGroup;
- #[cfg(feature = "yaml")]
- use yaml_rust::YamlLoader;
-
- #[test]
- fn groups() {
- let g = ArgGroup::with_name("test")
- .arg("a1")
- .arg("a4")
- .args(&["a2", "a3"])
- .required(true)
- .conflicts_with("c1")
- .conflicts_with_all(&["c2", "c3"])
- .conflicts_with("c4")
- .requires("r1")
- .requires_all(&["r2", "r3"])
- .requires("r4");
-
- let args = vec!["a1", "a4", "a2", "a3"];
- let reqs = vec!["r1", "r2", "r3", "r4"];
- let confs = vec!["c1", "c2", "c3", "c4"];
-
- assert_eq!(g.args, args);
- assert_eq!(g.requires, Some(reqs));
- assert_eq!(g.conflicts, Some(confs));
- }
-
- #[test]
- fn test_debug() {
- let g = ArgGroup::with_name("test")
- .arg("a1")
- .arg("a4")
- .args(&["a2", "a3"])
- .required(true)
- .conflicts_with("c1")
- .conflicts_with_all(&["c2", "c3"])
- .conflicts_with("c4")
- .requires("r1")
- .requires_all(&["r2", "r3"])
- .requires("r4");
-
- let args = vec!["a1", "a4", "a2", "a3"];
- let reqs = vec!["r1", "r2", "r3", "r4"];
- let confs = vec!["c1", "c2", "c3", "c4"];
-
- let debug_str = format!(
- "{{\n\
- \tname: \"test\",\n\
- \targs: {:?},\n\
- \trequired: {:?},\n\
- \trequires: {:?},\n\
- \tconflicts: {:?},\n\
- }}",
- args,
- true,
- Some(reqs),
- Some(confs)
- );
- assert_eq!(&*format!("{:?}", g), &*debug_str);
- }
-
- #[test]
- fn test_from() {
- let g = ArgGroup::with_name("test")
- .arg("a1")
- .arg("a4")
- .args(&["a2", "a3"])
- .required(true)
- .conflicts_with("c1")
- .conflicts_with_all(&["c2", "c3"])
- .conflicts_with("c4")
- .requires("r1")
- .requires_all(&["r2", "r3"])
- .requires("r4");
-
- let args = vec!["a1", "a4", "a2", "a3"];
- let reqs = vec!["r1", "r2", "r3", "r4"];
- let confs = vec!["c1", "c2", "c3", "c4"];
-
- let g2 = ArgGroup::from(&g);
- assert_eq!(g2.args, args);
- assert_eq!(g2.requires, Some(reqs));
- assert_eq!(g2.conflicts, Some(confs));
- }
-
- #[cfg(feature = "yaml")]
- #[cfg_attr(feature = "yaml", test)]
- fn test_yaml() {
- let g_yaml = "name: test
-args:
-- a1
-- a4
-- a2
-- a3
-conflicts_with:
-- c1
-- c2
-- c3
-- c4
-requires:
-- r1
-- r2
-- r3
-- r4";
- let yml = &YamlLoader::load_from_str(g_yaml).expect("failed to load YAML file")[0];
- let g = ArgGroup::from_yaml(yml);
- let args = vec!["a1", "a4", "a2", "a3"];
- let reqs = vec!["r1", "r2", "r3", "r4"];
- let confs = vec!["c1", "c2", "c3", "c4"];
- assert_eq!(g.args, args);
- assert_eq!(g.requires, Some(reqs));
- assert_eq!(g.conflicts, Some(confs));
- }
-}
-
-impl<'a> Clone for ArgGroup<'a> {
- fn clone(&self) -> Self {
- ArgGroup {
- name: self.name,
- required: self.required,
- args: self.args.clone(),
- requires: self.requires.clone(),
- conflicts: self.conflicts.clone(),
- multiple: self.multiple,
- }
- }
-}
diff --git a/clap/src/args/macros.rs b/clap/src/args/macros.rs
deleted file mode 100644
index 1de12f4..0000000
--- a/clap/src/args/macros.rs
+++ /dev/null
@@ -1,109 +0,0 @@
-#[cfg(feature = "yaml")]
-macro_rules! yaml_tuple2 {
- ($a:ident, $v:ident, $c:ident) => {{
- if let Some(vec) = $v.as_vec() {
- for ys in vec {
- if let Some(tup) = ys.as_vec() {
- debug_assert_eq!(2, tup.len());
- $a = $a.$c(yaml_str!(tup[0]), yaml_str!(tup[1]));
- } else {
- panic!("Failed to convert YAML value to vec");
- }
- }
- } else {
- panic!("Failed to convert YAML value to vec");
- }
- $a
- }
- };
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_tuple3 {
- ($a:ident, $v:ident, $c:ident) => {{
- if let Some(vec) = $v.as_vec() {
- for ys in vec {
- if let Some(tup) = ys.as_vec() {
- debug_assert_eq!(3, tup.len());
- $a = $a.$c(yaml_str!(tup[0]), yaml_opt_str!(tup[1]), yaml_str!(tup[2]));
- } else {
- panic!("Failed to convert YAML value to vec");
- }
- }
- } else {
- panic!("Failed to convert YAML value to vec");
- }
- $a
- }
- };
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_vec_or_str {
- ($v:ident, $a:ident, $c:ident) => {{
- let maybe_vec = $v.as_vec();
- if let Some(vec) = maybe_vec {
- for ys in vec {
- if let Some(s) = ys.as_str() {
- $a = $a.$c(s);
- } else {
- panic!("Failed to convert YAML value {:?} to a string", ys);
- }
- }
- } else {
- if let Some(s) = $v.as_str() {
- $a = $a.$c(s);
- } else {
- panic!("Failed to convert YAML value {:?} to either a vec or string", $v);
- }
- }
- $a
- }
- };
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_opt_str {
- ($v:expr) => {{
- if $v.is_null() {
- Some($v.as_str().unwrap_or_else(|| panic!("failed to convert YAML {:?} value to a string", $v)))
- } else {
- None
- }
- }};
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_str {
- ($v:expr) => {{
- $v.as_str().unwrap_or_else(|| panic!("failed to convert YAML {:?} value to a string", $v))
- }};
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_to_str {
- ($a:ident, $v:ident, $c:ident) => {{
- $a.$c(yaml_str!($v))
- }};
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_to_bool {
- ($a:ident, $v:ident, $c:ident) => {{
- $a.$c($v.as_bool().unwrap_or_else(|| panic!("failed to convert YAML {:?} value to a string", $v)))
- }};
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_to_u64 {
- ($a:ident, $v:ident, $c:ident) => {{
- $a.$c($v.as_i64().unwrap_or_else(|| panic!("failed to convert YAML {:?} value to a string", $v)) as u64)
- }};
-}
-
-#[cfg(feature = "yaml")]
-macro_rules! yaml_to_usize {
- ($a:ident, $v:ident, $c:ident) => {{
- $a.$c($v.as_i64().unwrap_or_else(|| panic!("failed to convert YAML {:?} value to a string", $v)) as usize)
- }};
-}
diff --git a/clap/src/args/matched_arg.rs b/clap/src/args/matched_arg.rs
deleted file mode 100644
index eeda261..0000000
--- a/clap/src/args/matched_arg.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Std
-use std::ffi::OsString;
-
-#[doc(hidden)]
-#[derive(Debug, Clone)]
-pub struct MatchedArg {
- #[doc(hidden)] pub occurs: u64,
- #[doc(hidden)] pub indices: Vec<usize>,
- #[doc(hidden)] pub vals: Vec<OsString>,
-}
-
-impl Default for MatchedArg {
- fn default() -> Self {
- MatchedArg {
- occurs: 1,
- indices: Vec::new(),
- vals: Vec::new(),
- }
- }
-}
-
-impl MatchedArg {
- pub fn new() -> Self { MatchedArg::default() }
-}
diff --git a/clap/src/args/mod.rs b/clap/src/args/mod.rs
deleted file mode 100644
index 21f9b85..0000000
--- a/clap/src/args/mod.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-pub use self::any_arg::{AnyArg, DispOrder};
-pub use self::arg::Arg;
-pub use self::arg_builder::{Base, FlagBuilder, OptBuilder, PosBuilder, Switched, Valued};
-pub use self::arg_matcher::ArgMatcher;
-pub use self::arg_matches::{ArgMatches, OsValues, Values};
-pub use self::group::ArgGroup;
-pub use self::matched_arg::MatchedArg;
-pub use self::settings::{ArgFlags, ArgSettings};
-pub use self::subcommand::SubCommand;
-
-#[macro_use]
-mod macros;
-mod arg;
-pub mod any_arg;
-mod arg_matches;
-mod arg_matcher;
-mod subcommand;
-mod arg_builder;
-mod matched_arg;
-mod group;
-pub mod settings;
diff --git a/clap/src/args/settings.rs b/clap/src/args/settings.rs
deleted file mode 100644
index 7b0e0a2..0000000
--- a/clap/src/args/settings.rs
+++ /dev/null
@@ -1,231 +0,0 @@
-// Std
-#[allow(deprecated, unused_imports)]
-use std::ascii::AsciiExt;
-use std::str::FromStr;
-
-bitflags! {
- struct Flags: u32 {
- const REQUIRED = 1;
- const MULTIPLE = 1 << 1;
- const EMPTY_VALS = 1 << 2;
- const GLOBAL = 1 << 3;
- const HIDDEN = 1 << 4;
- const TAKES_VAL = 1 << 5;
- const USE_DELIM = 1 << 6;
- const NEXT_LINE_HELP = 1 << 7;
- const R_UNLESS_ALL = 1 << 8;
- const REQ_DELIM = 1 << 9;
- const DELIM_NOT_SET = 1 << 10;
- const HIDE_POS_VALS = 1 << 11;
- const ALLOW_TAC_VALS = 1 << 12;
- const REQUIRE_EQUALS = 1 << 13;
- const LAST = 1 << 14;
- const HIDE_DEFAULT_VAL = 1 << 15;
- const CASE_INSENSITIVE = 1 << 16;
- const HIDE_ENV_VALS = 1 << 17;
- const HIDDEN_SHORT_H = 1 << 18;
- const HIDDEN_LONG_H = 1 << 19;
- }
-}
-
-#[doc(hidden)]
-#[derive(Debug, Clone, Copy)]
-pub struct ArgFlags(Flags);
-
-impl ArgFlags {
- pub fn new() -> Self { ArgFlags::default() }
-
- impl_settings!{ArgSettings,
- Required => Flags::REQUIRED,
- Multiple => Flags::MULTIPLE,
- EmptyValues => Flags::EMPTY_VALS,
- Global => Flags::GLOBAL,
- Hidden => Flags::HIDDEN,
- TakesValue => Flags::TAKES_VAL,
- UseValueDelimiter => Flags::USE_DELIM,
- NextLineHelp => Flags::NEXT_LINE_HELP,
- RequiredUnlessAll => Flags::R_UNLESS_ALL,
- RequireDelimiter => Flags::REQ_DELIM,
- ValueDelimiterNotSet => Flags::DELIM_NOT_SET,
- HidePossibleValues => Flags::HIDE_POS_VALS,
- AllowLeadingHyphen => Flags::ALLOW_TAC_VALS,
- RequireEquals => Flags::REQUIRE_EQUALS,
- Last => Flags::LAST,
- CaseInsensitive => Flags::CASE_INSENSITIVE,
- HideEnvValues => Flags::HIDE_ENV_VALS,
- HideDefaultValue => Flags::HIDE_DEFAULT_VAL,
- HiddenShortHelp => Flags::HIDDEN_SHORT_H,
- HiddenLongHelp => Flags::HIDDEN_LONG_H
- }
-}
-
-impl Default for ArgFlags {
- fn default() -> Self { ArgFlags(Flags::EMPTY_VALS | Flags::DELIM_NOT_SET) }
-}
-
-/// Various settings that apply to arguments and may be set, unset, and checked via getter/setter
-/// methods [`Arg::set`], [`Arg::unset`], and [`Arg::is_set`]
-///
-/// [`Arg::set`]: ./struct.Arg.html#method.set
-/// [`Arg::unset`]: ./struct.Arg.html#method.unset
-/// [`Arg::is_set`]: ./struct.Arg.html#method.is_set
-#[derive(Debug, PartialEq, Copy, Clone)]
-pub enum ArgSettings {
- /// The argument must be used
- Required,
- /// The argument may be used multiple times such as `--flag --flag`
- Multiple,
- /// The argument allows empty values such as `--option ""`
- EmptyValues,
- /// The argument should be propagated down through all child [`SubCommand`]s
- ///
- /// [`SubCommand`]: ./struct.SubCommand.html
- Global,
- /// The argument should **not** be shown in help text
- Hidden,
- /// The argument accepts a value, such as `--option <value>`
- TakesValue,
- /// Determines if the argument allows values to be grouped via a delimiter
- UseValueDelimiter,
- /// Prints the help text on the line after the argument
- NextLineHelp,
- /// Requires the use of a value delimiter for all multiple values
- RequireDelimiter,
- /// Hides the possible values from the help string
- HidePossibleValues,
- /// Allows vals that start with a '-'
- AllowLeadingHyphen,
- /// Require options use `--option=val` syntax
- RequireEquals,
- /// Specifies that the arg is the last positional argument and may be accessed early via `--`
- /// syntax
- Last,
- /// Hides the default value from the help string
- HideDefaultValue,
- /// Makes `Arg::possible_values` case insensitive
- CaseInsensitive,
- /// Hides ENV values in the help message
- HideEnvValues,
- /// The argument should **not** be shown in short help text
- HiddenShortHelp,
- /// The argument should **not** be shown in long help text
- HiddenLongHelp,
- #[doc(hidden)] RequiredUnlessAll,
- #[doc(hidden)] ValueDelimiterNotSet,
-}
-
-impl FromStr for ArgSettings {
- type Err = String;
- fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> {
- match &*s.to_ascii_lowercase() {
- "required" => Ok(ArgSettings::Required),
- "multiple" => Ok(ArgSettings::Multiple),
- "global" => Ok(ArgSettings::Global),
- "emptyvalues" => Ok(ArgSettings::EmptyValues),
- "hidden" => Ok(ArgSettings::Hidden),
- "takesvalue" => Ok(ArgSettings::TakesValue),
- "usevaluedelimiter" => Ok(ArgSettings::UseValueDelimiter),
- "nextlinehelp" => Ok(ArgSettings::NextLineHelp),
- "requiredunlessall" => Ok(ArgSettings::RequiredUnlessAll),
- "requiredelimiter" => Ok(ArgSettings::RequireDelimiter),
- "valuedelimiternotset" => Ok(ArgSettings::ValueDelimiterNotSet),
- "hidepossiblevalues" => Ok(ArgSettings::HidePossibleValues),
- "allowleadinghyphen" => Ok(ArgSettings::AllowLeadingHyphen),
- "requireequals" => Ok(ArgSettings::RequireEquals),
- "last" => Ok(ArgSettings::Last),
- "hidedefaultvalue" => Ok(ArgSettings::HideDefaultValue),
- "caseinsensitive" => Ok(ArgSettings::CaseInsensitive),
- "hideenvvalues" => Ok(ArgSettings::HideEnvValues),
- "hiddenshorthelp" => Ok(ArgSettings::HiddenShortHelp),
- "hiddenlonghelp" => Ok(ArgSettings::HiddenLongHelp),
- _ => Err("unknown ArgSetting, cannot convert from str".to_owned()),
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::ArgSettings;
-
- #[test]
- fn arg_settings_fromstr() {
- assert_eq!(
- "allowleadinghyphen".parse::<ArgSettings>().unwrap(),
- ArgSettings::AllowLeadingHyphen
- );
- assert_eq!(
- "emptyvalues".parse::<ArgSettings>().unwrap(),
- ArgSettings::EmptyValues
- );
- assert_eq!(
- "global".parse::<ArgSettings>().unwrap(),
- ArgSettings::Global
- );
- assert_eq!(
- "hidepossiblevalues".parse::<ArgSettings>().unwrap(),
- ArgSettings::HidePossibleValues
- );
- assert_eq!(
- "hidden".parse::<ArgSettings>().unwrap(),
- ArgSettings::Hidden
- );
- assert_eq!(
- "multiple".parse::<ArgSettings>().unwrap(),
- ArgSettings::Multiple
- );
- assert_eq!(
- "nextlinehelp".parse::<ArgSettings>().unwrap(),
- ArgSettings::NextLineHelp
- );
- assert_eq!(
- "requiredunlessall".parse::<ArgSettings>().unwrap(),
- ArgSettings::RequiredUnlessAll
- );
- assert_eq!(
- "requiredelimiter".parse::<ArgSettings>().unwrap(),
- ArgSettings::RequireDelimiter
- );
- assert_eq!(
- "required".parse::<ArgSettings>().unwrap(),
- ArgSettings::Required
- );
- assert_eq!(
- "takesvalue".parse::<ArgSettings>().unwrap(),
- ArgSettings::TakesValue
- );
- assert_eq!(
- "usevaluedelimiter".parse::<ArgSettings>().unwrap(),
- ArgSettings::UseValueDelimiter
- );
- assert_eq!(
- "valuedelimiternotset".parse::<ArgSettings>().unwrap(),
- ArgSettings::ValueDelimiterNotSet
- );
- assert_eq!(
- "requireequals".parse::<ArgSettings>().unwrap(),
- ArgSettings::RequireEquals
- );
- assert_eq!("last".parse::<ArgSettings>().unwrap(), ArgSettings::Last);
- assert_eq!(
- "hidedefaultvalue".parse::<ArgSettings>().unwrap(),
- ArgSettings::HideDefaultValue
- );
- assert_eq!(
- "caseinsensitive".parse::<ArgSettings>().unwrap(),
- ArgSettings::CaseInsensitive
- );
- assert_eq!(
- "hideenvvalues".parse::<ArgSettings>().unwrap(),
- ArgSettings::HideEnvValues
- );
- assert_eq!(
- "hiddenshorthelp".parse::<ArgSettings>().unwrap(),
- ArgSettings::HiddenShortHelp
- );
- assert_eq!(
- "hiddenlonghelp".parse::<ArgSettings>().unwrap(),
- ArgSettings::HiddenLongHelp
- );
- assert!("hahahaha".parse::<ArgSettings>().is_err());
- }
-}
diff --git a/clap/src/args/subcommand.rs b/clap/src/args/subcommand.rs
deleted file mode 100644
index eebbf82..0000000
--- a/clap/src/args/subcommand.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Third Party
-#[cfg(feature = "yaml")]
-use yaml_rust::Yaml;
-
-// Internal
-use App;
-use ArgMatches;
-
-/// The abstract representation of a command line subcommand.
-///
-/// This struct describes all the valid options of the subcommand for the program. Subcommands are
-/// essentially "sub-[`App`]s" and contain all the same possibilities (such as their own
-/// [arguments], subcommands, and settings).
-///
-/// # Examples
-///
-/// ```rust
-/// # use clap::{App, Arg, SubCommand};
-/// App::new("myprog")
-/// .subcommand(
-/// SubCommand::with_name("config")
-/// .about("Used for configuration")
-/// .arg(Arg::with_name("config_file")
-/// .help("The configuration file to use")
-/// .index(1)))
-/// # ;
-/// ```
-/// [`App`]: ./struct.App.html
-/// [arguments]: ./struct.Arg.html
-#[derive(Debug, Clone)]
-pub struct SubCommand<'a> {
- #[doc(hidden)] pub name: String,
- #[doc(hidden)] pub matches: ArgMatches<'a>,
-}
-
-impl<'a> SubCommand<'a> {
- /// Creates a new instance of a subcommand requiring a name. The name will be displayed
- /// to the user when they print version or help and usage information.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, SubCommand};
- /// App::new("myprog")
- /// .subcommand(
- /// SubCommand::with_name("config"))
- /// # ;
- /// ```
- pub fn with_name<'b>(name: &str) -> App<'a, 'b> { App::new(name) }
-
- /// Creates a new instance of a subcommand from a YAML (.yml) document
- ///
- /// # Examples
- ///
- /// ```ignore
- /// # #[macro_use]
- /// # extern crate clap;
- /// # use clap::Subcommand;
- /// # fn main() {
- /// let sc_yaml = load_yaml!("test_subcommand.yml");
- /// let sc = SubCommand::from_yaml(sc_yaml);
- /// # }
- /// ```
- #[cfg(feature = "yaml")]
- pub fn from_yaml(yaml: &Yaml) -> App { App::from_yaml(yaml) }
-}
diff --git a/clap/src/completions/bash.rs b/clap/src/completions/bash.rs
deleted file mode 100644
index 37dfa66..0000000
--- a/clap/src/completions/bash.rs
+++ /dev/null
@@ -1,219 +0,0 @@
-// Std
-use std::io::Write;
-
-// Internal
-use app::parser::Parser;
-use args::OptBuilder;
-use completions;
-
-pub struct BashGen<'a, 'b>
-where
- 'a: 'b,
-{
- p: &'b Parser<'a, 'b>,
-}
-
-impl<'a, 'b> BashGen<'a, 'b> {
- pub fn new(p: &'b Parser<'a, 'b>) -> Self { BashGen { p: p } }
-
- pub fn generate_to<W: Write>(&self, buf: &mut W) {
- w!(
- buf,
- format!(
- r#"_{name}() {{
- local i cur prev opts cmds
- COMPREPLY=()
- cur="${{COMP_WORDS[COMP_CWORD]}}"
- prev="${{COMP_WORDS[COMP_CWORD-1]}}"
- cmd=""
- opts=""
-
- for i in ${{COMP_WORDS[@]}}
- do
- case "${{i}}" in
- {name})
- cmd="{name}"
- ;;
- {subcmds}
- *)
- ;;
- esac
- done
-
- case "${{cmd}}" in
- {name})
- opts="{name_opts}"
- if [[ ${{cur}} == -* || ${{COMP_CWORD}} -eq 1 ]] ; then
- COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") )
- return 0
- fi
- case "${{prev}}" in
- {name_opts_details}
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") )
- return 0
- ;;
- {subcmd_details}
- esac
-}}
-
-complete -F _{name} -o bashdefault -o default {name}
-"#,
- name = self.p.meta.bin_name.as_ref().unwrap(),
- name_opts = self.all_options_for_path(self.p.meta.bin_name.as_ref().unwrap()),
- name_opts_details =
- self.option_details_for_path(self.p.meta.bin_name.as_ref().unwrap()),
- subcmds = self.all_subcommands(),
- subcmd_details = self.subcommand_details()
- ).as_bytes()
- );
- }
-
- fn all_subcommands(&self) -> String {
- debugln!("BashGen::all_subcommands;");
- let mut subcmds = String::new();
- let scs = completions::all_subcommand_names(self.p);
-
- for sc in &scs {
- subcmds = format!(
- r#"{}
- {name})
- cmd+="__{fn_name}"
- ;;"#,
- subcmds,
- name = sc,
- fn_name = sc.replace("-", "__")
- );
- }
-
- subcmds
- }
-
- fn subcommand_details(&self) -> String {
- debugln!("BashGen::subcommand_details;");
- let mut subcmd_dets = String::new();
- let mut scs = completions::get_all_subcommand_paths(self.p, true);
- scs.sort();
- scs.dedup();
-
- for sc in &scs {
- subcmd_dets = format!(
- r#"{}
- {subcmd})
- opts="{sc_opts}"
- if [[ ${{cur}} == -* || ${{COMP_CWORD}} -eq {level} ]] ; then
- COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") )
- return 0
- fi
- case "${{prev}}" in
- {opts_details}
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") )
- return 0
- ;;"#,
- subcmd_dets,
- subcmd = sc.replace("-", "__"),
- sc_opts = self.all_options_for_path(&*sc),
- level = sc.split("__").map(|_| 1).fold(0, |acc, n| acc + n),
- opts_details = self.option_details_for_path(&*sc)
- );
- }
-
- subcmd_dets
- }
-
- fn option_details_for_path(&self, path: &str) -> String {
- debugln!("BashGen::option_details_for_path: path={}", path);
- let mut p = self.p;
- for sc in path.split("__").skip(1) {
- debugln!("BashGen::option_details_for_path:iter: sc={}", sc);
- p = &find_subcmd!(p, sc).unwrap().p;
- }
- let mut opts = String::new();
- for o in p.opts() {
- if let Some(l) = o.s.long {
- opts = format!(
- "{}
- --{})
- COMPREPLY=({})
- return 0
- ;;",
- opts,
- l,
- self.vals_for(o)
- );
- }
- if let Some(s) = o.s.short {
- opts = format!(
- "{}
- -{})
- COMPREPLY=({})
- return 0
- ;;",
- opts,
- s,
- self.vals_for(o)
- );
- }
- }
- opts
- }
-
- fn vals_for(&self, o: &OptBuilder) -> String {
- debugln!("BashGen::vals_for: o={}", o.b.name);
- use args::AnyArg;
- if let Some(vals) = o.possible_vals() {
- format!(r#"$(compgen -W "{}" -- "${{cur}}")"#, vals.join(" "))
- } else {
- String::from(r#"$(compgen -f "${cur}")"#)
- }
- }
-
- fn all_options_for_path(&self, path: &str) -> String {
- debugln!("BashGen::all_options_for_path: path={}", path);
- let mut p = self.p;
- for sc in path.split("__").skip(1) {
- debugln!("BashGen::all_options_for_path:iter: sc={}", sc);
- p = &find_subcmd!(p, sc).unwrap().p;
- }
- let mut opts = shorts!(p).fold(String::new(), |acc, s| format!("{} -{}", acc, s));
- opts = format!(
- "{} {}",
- opts,
- longs!(p).fold(String::new(), |acc, l| format!("{} --{}", acc, l))
- );
- opts = format!(
- "{} {}",
- opts,
- p.positionals
- .values()
- .fold(String::new(), |acc, p| format!("{} {}", acc, p))
- );
- opts = format!(
- "{} {}",
- opts,
- p.subcommands
- .iter()
- .fold(String::new(), |acc, s| format!("{} {}", acc, s.p.meta.name))
- );
- for sc in &p.subcommands {
- if let Some(ref aliases) = sc.p.meta.aliases {
- opts = format!(
- "{} {}",
- opts,
- aliases
- .iter()
- .map(|&(n, _)| n)
- .fold(String::new(), |acc, a| format!("{} {}", acc, a))
- );
- }
- }
- opts
- }
-}
diff --git a/clap/src/completions/elvish.rs b/clap/src/completions/elvish.rs
deleted file mode 100644
index 9a5f21a..0000000
--- a/clap/src/completions/elvish.rs
+++ /dev/null
@@ -1,126 +0,0 @@
-// Std
-use std::io::Write;
-
-// Internal
-use app::parser::Parser;
-use INTERNAL_ERROR_MSG;
-
-pub struct ElvishGen<'a, 'b>
-where
- 'a: 'b,
-{
- p: &'b Parser<'a, 'b>,
-}
-
-impl<'a, 'b> ElvishGen<'a, 'b> {
- pub fn new(p: &'b Parser<'a, 'b>) -> Self { ElvishGen { p: p } }
-
- pub fn generate_to<W: Write>(&self, buf: &mut W) {
- let bin_name = self.p.meta.bin_name.as_ref().unwrap();
-
- let mut names = vec![];
- let subcommands_cases =
- generate_inner(self.p, "", &mut names);
-
- let result = format!(r#"
-edit:completion:arg-completer[{bin_name}] = [@words]{{
- fn spaces [n]{{
- repeat $n ' ' | joins ''
- }}
- fn cand [text desc]{{
- edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
- }}
- command = '{bin_name}'
- for word $words[1:-1] {{
- if (has-prefix $word '-') {{
- break
- }}
- command = $command';'$word
- }}
- completions = [{subcommands_cases}
- ]
- $completions[$command]
-}}
-"#,
- bin_name = bin_name,
- subcommands_cases = subcommands_cases
- );
-
- w!(buf, result.as_bytes());
- }
-}
-
-// Escape string inside single quotes
-fn escape_string(string: &str) -> String { string.replace("'", "''") }
-
-fn get_tooltip<T : ToString>(help: Option<&str>, data: T) -> String {
- match help {
- Some(help) => escape_string(help),
- _ => data.to_string()
- }
-}
-
-fn generate_inner<'a, 'b, 'p>(
- p: &'p Parser<'a, 'b>,
- previous_command_name: &str,
- names: &mut Vec<&'p str>,
-) -> String {
- debugln!("ElvishGen::generate_inner;");
- let command_name = if previous_command_name.is_empty() {
- p.meta.bin_name.as_ref().expect(INTERNAL_ERROR_MSG).clone()
- } else {
- format!("{};{}", previous_command_name, &p.meta.name)
- };
-
- let mut completions = String::new();
- let preamble = String::from("\n cand ");
-
- for option in p.opts() {
- if let Some(data) = option.s.short {
- let tooltip = get_tooltip(option.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("-{} '{}'", data, tooltip).as_str());
- }
- if let Some(data) = option.s.long {
- let tooltip = get_tooltip(option.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("--{} '{}'", data, tooltip).as_str());
- }
- }
-
- for flag in p.flags() {
- if let Some(data) = flag.s.short {
- let tooltip = get_tooltip(flag.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("-{} '{}'", data, tooltip).as_str());
- }
- if let Some(data) = flag.s.long {
- let tooltip = get_tooltip(flag.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("--{} '{}'", data, tooltip).as_str());
- }
- }
-
- for subcommand in &p.subcommands {
- let data = &subcommand.p.meta.name;
- let tooltip = get_tooltip(subcommand.p.meta.about, data);
- completions.push_str(&preamble);
- completions.push_str(format!("{} '{}'", data, tooltip).as_str());
- }
-
- let mut subcommands_cases = format!(
- r"
- &'{}'= {{{}
- }}",
- &command_name,
- completions
- );
-
- for subcommand in &p.subcommands {
- let subcommand_subcommands_cases =
- generate_inner(&subcommand.p, &command_name, names);
- subcommands_cases.push_str(&subcommand_subcommands_cases);
- }
-
- subcommands_cases
-}
diff --git a/clap/src/completions/fish.rs b/clap/src/completions/fish.rs
deleted file mode 100644
index c2c5a5e..0000000
--- a/clap/src/completions/fish.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Std
-use std::io::Write;
-
-// Internal
-use app::parser::Parser;
-
-pub struct FishGen<'a, 'b>
-where
- 'a: 'b,
-{
- p: &'b Parser<'a, 'b>,
-}
-
-impl<'a, 'b> FishGen<'a, 'b> {
- pub fn new(p: &'b Parser<'a, 'b>) -> Self { FishGen { p: p } }
-
- pub fn generate_to<W: Write>(&self, buf: &mut W) {
- let command = self.p.meta.bin_name.as_ref().unwrap();
- let mut buffer = String::new();
- gen_fish_inner(command, self, command, &mut buffer);
- w!(buf, buffer.as_bytes());
- }
-}
-
-// Escape string inside single quotes
-fn escape_string(string: &str) -> String { string.replace("\\", "\\\\").replace("'", "\\'") }
-
-fn gen_fish_inner(root_command: &str, comp_gen: &FishGen, subcommand: &str, buffer: &mut String) {
- debugln!("FishGen::gen_fish_inner;");
- // example :
- //
- // complete
- // -c {command}
- // -d "{description}"
- // -s {short}
- // -l {long}
- // -a "{possible_arguments}"
- // -r # if require parameter
- // -f # don't use file completion
- // -n "__fish_use_subcommand" # complete for command "myprog"
- // -n "__fish_seen_subcommand_from subcmd1" # complete for command "myprog subcmd1"
-
- let mut basic_template = format!("complete -c {} -n ", root_command);
- if root_command == subcommand {
- basic_template.push_str("\"__fish_use_subcommand\"");
- } else {
- basic_template.push_str(format!("\"__fish_seen_subcommand_from {}\"", subcommand).as_str());
- }
-
- for option in comp_gen.p.opts() {
- let mut template = basic_template.clone();
- if let Some(data) = option.s.short {
- template.push_str(format!(" -s {}", data).as_str());
- }
- if let Some(data) = option.s.long {
- template.push_str(format!(" -l {}", data).as_str());
- }
- if let Some(data) = option.b.help {
- template.push_str(format!(" -d '{}'", escape_string(data)).as_str());
- }
- if let Some(ref data) = option.v.possible_vals {
- template.push_str(format!(" -r -f -a \"{}\"", data.join(" ")).as_str());
- }
- buffer.push_str(template.as_str());
- buffer.push_str("\n");
- }
-
- for flag in comp_gen.p.flags() {
- let mut template = basic_template.clone();
- if let Some(data) = flag.s.short {
- template.push_str(format!(" -s {}", data).as_str());
- }
- if let Some(data) = flag.s.long {
- template.push_str(format!(" -l {}", data).as_str());
- }
- if let Some(data) = flag.b.help {
- template.push_str(format!(" -d '{}'", escape_string(data)).as_str());
- }
- buffer.push_str(template.as_str());
- buffer.push_str("\n");
- }
-
- for subcommand in &comp_gen.p.subcommands {
- let mut template = basic_template.clone();
- template.push_str(" -f");
- template.push_str(format!(" -a \"{}\"", &subcommand.p.meta.name).as_str());
- if let Some(data) = subcommand.p.meta.about {
- template.push_str(format!(" -d '{}'", escape_string(data)).as_str())
- }
- buffer.push_str(template.as_str());
- buffer.push_str("\n");
- }
-
- // generate options of subcommands
- for subcommand in &comp_gen.p.subcommands {
- let sub_comp_gen = FishGen::new(&subcommand.p);
- gen_fish_inner(root_command, &sub_comp_gen, &subcommand.to_string(), buffer);
- }
-}
diff --git a/clap/src/completions/macros.rs b/clap/src/completions/macros.rs
deleted file mode 100644
index 653c72c..0000000
--- a/clap/src/completions/macros.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-macro_rules! w {
- ($buf:expr, $to_w:expr) => {
- match $buf.write_all($to_w) {
- Ok(..) => (),
- Err(..) => panic!("Failed to write to completions file"),
- }
- };
-}
-
-macro_rules! get_zsh_arg_conflicts {
- ($p:ident, $arg:ident, $msg:ident) => {
- if let Some(conf_vec) = $arg.blacklist() {
- let mut v = vec![];
- for arg_name in conf_vec {
- let arg = $p.find_any_arg(arg_name).expect($msg);
- if let Some(s) = arg.short() {
- v.push(format!("-{}", s));
- }
- if let Some(l) = arg.long() {
- v.push(format!("--{}", l));
- }
- }
- v.join(" ")
- } else {
- String::new()
- }
- }
-}
diff --git a/clap/src/completions/mod.rs b/clap/src/completions/mod.rs
deleted file mode 100644
index a3306d7..0000000
--- a/clap/src/completions/mod.rs
+++ /dev/null
@@ -1,179 +0,0 @@
-#[macro_use]
-mod macros;
-mod bash;
-mod fish;
-mod zsh;
-mod powershell;
-mod elvish;
-mod shell;
-
-// Std
-use std::io::Write;
-
-// Internal
-use app::parser::Parser;
-use self::bash::BashGen;
-use self::fish::FishGen;
-use self::zsh::ZshGen;
-use self::powershell::PowerShellGen;
-use self::elvish::ElvishGen;
-pub use self::shell::Shell;
-
-pub struct ComplGen<'a, 'b>
-where
- 'a: 'b,
-{
- p: &'b Parser<'a, 'b>,
-}
-
-impl<'a, 'b> ComplGen<'a, 'b> {
- pub fn new(p: &'b Parser<'a, 'b>) -> Self { ComplGen { p: p } }
-
- pub fn generate<W: Write>(&self, for_shell: Shell, buf: &mut W) {
- match for_shell {
- Shell::Bash => BashGen::new(self.p).generate_to(buf),
- Shell::Fish => FishGen::new(self.p).generate_to(buf),
- Shell::Zsh => ZshGen::new(self.p).generate_to(buf),
- Shell::PowerShell => PowerShellGen::new(self.p).generate_to(buf),
- Shell::Elvish => ElvishGen::new(self.p).generate_to(buf),
- }
- }
-}
-
-// Gets all subcommands including child subcommands in the form of 'name' where the name
-// is a single word (i.e. "install") of the path to said subcommand (i.e.
-// "rustup toolchain install")
-//
-// Also note, aliases are treated as their own subcommands but duplicates of whatever they're
-// aliasing.
-pub fn all_subcommand_names(p: &Parser) -> Vec<String> {
- debugln!("all_subcommand_names;");
- let mut subcmds: Vec<_> = subcommands_of(p)
- .iter()
- .map(|&(ref n, _)| n.clone())
- .collect();
- for sc_v in p.subcommands.iter().map(|s| all_subcommand_names(&s.p)) {
- subcmds.extend(sc_v);
- }
- subcmds.sort();
- subcmds.dedup();
- subcmds
-}
-
-// Gets all subcommands including child subcommands in the form of ('name', 'bin_name') where the name
-// is a single word (i.e. "install") of the path and full bin_name of said subcommand (i.e.
-// "rustup toolchain install")
-//
-// Also note, aliases are treated as their own subcommands but duplicates of whatever they're
-// aliasing.
-pub fn all_subcommands(p: &Parser) -> Vec<(String, String)> {
- debugln!("all_subcommands;");
- let mut subcmds: Vec<_> = subcommands_of(p);
- for sc_v in p.subcommands.iter().map(|s| all_subcommands(&s.p)) {
- subcmds.extend(sc_v);
- }
- subcmds
-}
-
-// Gets all subcommands excluding child subcommands in the form of (name, bin_name) where the name
-// is a single word (i.e. "install") and the bin_name is a space delineated list of the path to said
-// subcommand (i.e. "rustup toolchain install")
-//
-// Also note, aliases are treated as their own subcommands but duplicates of whatever they're
-// aliasing.
-pub fn subcommands_of(p: &Parser) -> Vec<(String, String)> {
- debugln!(
- "subcommands_of: name={}, bin_name={}",
- p.meta.name,
- p.meta.bin_name.as_ref().unwrap()
- );
- let mut subcmds = vec![];
-
- debugln!(
- "subcommands_of: Has subcommands...{:?}",
- p.has_subcommands()
- );
- if !p.has_subcommands() {
- let mut ret = vec![];
- debugln!("subcommands_of: Looking for aliases...");
- if let Some(ref aliases) = p.meta.aliases {
- for &(n, _) in aliases {
- debugln!("subcommands_of:iter:iter: Found alias...{}", n);
- let mut als_bin_name: Vec<_> =
- p.meta.bin_name.as_ref().unwrap().split(' ').collect();
- als_bin_name.push(n);
- let old = als_bin_name.len() - 2;
- als_bin_name.swap_remove(old);
- ret.push((n.to_owned(), als_bin_name.join(" ")));
- }
- }
- return ret;
- }
- for sc in &p.subcommands {
- debugln!(
- "subcommands_of:iter: name={}, bin_name={}",
- sc.p.meta.name,
- sc.p.meta.bin_name.as_ref().unwrap()
- );
-
- debugln!("subcommands_of:iter: Looking for aliases...");
- if let Some(ref aliases) = sc.p.meta.aliases {
- for &(n, _) in aliases {
- debugln!("subcommands_of:iter:iter: Found alias...{}", n);
- let mut als_bin_name: Vec<_> =
- p.meta.bin_name.as_ref().unwrap().split(' ').collect();
- als_bin_name.push(n);
- let old = als_bin_name.len() - 2;
- als_bin_name.swap_remove(old);
- subcmds.push((n.to_owned(), als_bin_name.join(" ")));
- }
- }
- subcmds.push((
- sc.p.meta.name.clone(),
- sc.p.meta.bin_name.as_ref().unwrap().clone(),
- ));
- }
- subcmds
-}
-
-pub fn get_all_subcommand_paths(p: &Parser, first: bool) -> Vec<String> {
- debugln!("get_all_subcommand_paths;");
- let mut subcmds = vec![];
- if !p.has_subcommands() {
- if !first {
- let name = &*p.meta.name;
- let path = p.meta.bin_name.as_ref().unwrap().clone().replace(" ", "__");
- let mut ret = vec![path.clone()];
- if let Some(ref aliases) = p.meta.aliases {
- for &(n, _) in aliases {
- ret.push(path.replace(name, n));
- }
- }
- return ret;
- }
- return vec![];
- }
- for sc in &p.subcommands {
- let name = &*sc.p.meta.name;
- let path = sc.p
- .meta
- .bin_name
- .as_ref()
- .unwrap()
- .clone()
- .replace(" ", "__");
- subcmds.push(path.clone());
- if let Some(ref aliases) = sc.p.meta.aliases {
- for &(n, _) in aliases {
- subcmds.push(path.replace(name, n));
- }
- }
- }
- for sc_v in p.subcommands
- .iter()
- .map(|s| get_all_subcommand_paths(&s.p, false))
- {
- subcmds.extend(sc_v);
- }
- subcmds
-}
diff --git a/clap/src/completions/powershell.rs b/clap/src/completions/powershell.rs
deleted file mode 100644
index 9fc77c7..0000000
--- a/clap/src/completions/powershell.rs
+++ /dev/null
@@ -1,139 +0,0 @@
-// Std
-use std::io::Write;
-
-// Internal
-use app::parser::Parser;
-use INTERNAL_ERROR_MSG;
-
-pub struct PowerShellGen<'a, 'b>
-where
- 'a: 'b,
-{
- p: &'b Parser<'a, 'b>,
-}
-
-impl<'a, 'b> PowerShellGen<'a, 'b> {
- pub fn new(p: &'b Parser<'a, 'b>) -> Self { PowerShellGen { p: p } }
-
- pub fn generate_to<W: Write>(&self, buf: &mut W) {
- let bin_name = self.p.meta.bin_name.as_ref().unwrap();
-
- let mut names = vec![];
- let subcommands_cases =
- generate_inner(self.p, "", &mut names);
-
- let result = format!(r#"
-using namespace System.Management.Automation
-using namespace System.Management.Automation.Language
-
-Register-ArgumentCompleter -Native -CommandName '{bin_name}' -ScriptBlock {{
- param($wordToComplete, $commandAst, $cursorPosition)
-
- $commandElements = $commandAst.CommandElements
- $command = @(
- '{bin_name}'
- for ($i = 1; $i -lt $commandElements.Count; $i++) {{
- $element = $commandElements[$i]
- if ($element -isnot [StringConstantExpressionAst] -or
- $element.StringConstantType -ne [StringConstantType]::BareWord -or
- $element.Value.StartsWith('-')) {{
- break
- }}
- $element.Value
- }}) -join ';'
-
- $completions = @(switch ($command) {{{subcommands_cases}
- }})
-
- $completions.Where{{ $_.CompletionText -like "$wordToComplete*" }} |
- Sort-Object -Property ListItemText
-}}
-"#,
- bin_name = bin_name,
- subcommands_cases = subcommands_cases
- );
-
- w!(buf, result.as_bytes());
- }
-}
-
-// Escape string inside single quotes
-fn escape_string(string: &str) -> String { string.replace("'", "''") }
-
-fn get_tooltip<T : ToString>(help: Option<&str>, data: T) -> String {
- match help {
- Some(help) => escape_string(help),
- _ => data.to_string()
- }
-}
-
-fn generate_inner<'a, 'b, 'p>(
- p: &'p Parser<'a, 'b>,
- previous_command_name: &str,
- names: &mut Vec<&'p str>,
-) -> String {
- debugln!("PowerShellGen::generate_inner;");
- let command_name = if previous_command_name.is_empty() {
- p.meta.bin_name.as_ref().expect(INTERNAL_ERROR_MSG).clone()
- } else {
- format!("{};{}", previous_command_name, &p.meta.name)
- };
-
- let mut completions = String::new();
- let preamble = String::from("\n [CompletionResult]::new(");
-
- for option in p.opts() {
- if let Some(data) = option.s.short {
- let tooltip = get_tooltip(option.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("'-{}', '{}', {}, '{}')",
- data, data, "[CompletionResultType]::ParameterName", tooltip).as_str());
- }
- if let Some(data) = option.s.long {
- let tooltip = get_tooltip(option.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("'--{}', '{}', {}, '{}')",
- data, data, "[CompletionResultType]::ParameterName", tooltip).as_str());
- }
- }
-
- for flag in p.flags() {
- if let Some(data) = flag.s.short {
- let tooltip = get_tooltip(flag.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("'-{}', '{}', {}, '{}')",
- data, data, "[CompletionResultType]::ParameterName", tooltip).as_str());
- }
- if let Some(data) = flag.s.long {
- let tooltip = get_tooltip(flag.b.help, data);
- completions.push_str(&preamble);
- completions.push_str(format!("'--{}', '{}', {}, '{}')",
- data, data, "[CompletionResultType]::ParameterName", tooltip).as_str());
- }
- }
-
- for subcommand in &p.subcommands {
- let data = &subcommand.p.meta.name;
- let tooltip = get_tooltip(subcommand.p.meta.about, data);
- completions.push_str(&preamble);
- completions.push_str(format!("'{}', '{}', {}, '{}')",
- data, data, "[CompletionResultType]::ParameterValue", tooltip).as_str());
- }
-
- let mut subcommands_cases = format!(
- r"
- '{}' {{{}
- break
- }}",
- &command_name,
- completions
- );
-
- for subcommand in &p.subcommands {
- let subcommand_subcommands_cases =
- generate_inner(&subcommand.p, &command_name, names);
- subcommands_cases.push_str(&subcommand_subcommands_cases);
- }
-
- subcommands_cases
-}
diff --git a/clap/src/completions/shell.rs b/clap/src/completions/shell.rs
deleted file mode 100644
index 19aab86..0000000
--- a/clap/src/completions/shell.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-#[allow(deprecated, unused_imports)]
-use std::ascii::AsciiExt;
-use std::str::FromStr;
-use std::fmt;
-
-/// Describes which shell to produce a completions file for
-#[cfg_attr(feature = "lints", allow(enum_variant_names))]
-#[derive(Debug, Copy, Clone)]
-pub enum Shell {
- /// Generates a .bash completion file for the Bourne Again SHell (BASH)
- Bash,
- /// Generates a .fish completion file for the Friendly Interactive SHell (fish)
- Fish,
- /// Generates a completion file for the Z SHell (ZSH)
- Zsh,
- /// Generates a completion file for PowerShell
- PowerShell,
- /// Generates a completion file for Elvish
- Elvish,
-}
-
-impl Shell {
- /// A list of possible variants in `&'static str` form
- pub fn variants() -> [&'static str; 5] { ["zsh", "bash", "fish", "powershell", "elvish"] }
-}
-
-impl FromStr for Shell {
- type Err = String;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- match s {
- "ZSH" | _ if s.eq_ignore_ascii_case("zsh") => Ok(Shell::Zsh),
- "FISH" | _ if s.eq_ignore_ascii_case("fish") => Ok(Shell::Fish),
- "BASH" | _ if s.eq_ignore_ascii_case("bash") => Ok(Shell::Bash),
- "POWERSHELL" | _ if s.eq_ignore_ascii_case("powershell") => Ok(Shell::PowerShell),
- "ELVISH" | _ if s.eq_ignore_ascii_case("elvish") => Ok(Shell::Elvish),
- _ => Err(String::from("[valid values: bash, fish, zsh, powershell, elvish]")),
- }
- }
-}
-
-impl fmt::Display for Shell {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match *self {
- Shell::Bash => write!(f, "BASH"),
- Shell::Fish => write!(f, "FISH"),
- Shell::Zsh => write!(f, "ZSH"),
- Shell::PowerShell => write!(f, "POWERSHELL"),
- Shell::Elvish => write!(f, "ELVISH"),
- }
- }
-}
diff --git a/clap/src/completions/zsh.rs b/clap/src/completions/zsh.rs
deleted file mode 100644
index 5d23fd2..0000000
--- a/clap/src/completions/zsh.rs
+++ /dev/null
@@ -1,472 +0,0 @@
-// Std
-use std::io::Write;
-#[allow(deprecated, unused_imports)]
-use std::ascii::AsciiExt;
-
-// Internal
-use app::App;
-use app::parser::Parser;
-use args::{AnyArg, ArgSettings};
-use completions;
-use INTERNAL_ERROR_MSG;
-
-pub struct ZshGen<'a, 'b>
-where
- 'a: 'b,
-{
- p: &'b Parser<'a, 'b>,
-}
-
-impl<'a, 'b> ZshGen<'a, 'b> {
- pub fn new(p: &'b Parser<'a, 'b>) -> Self {
- debugln!("ZshGen::new;");
- ZshGen { p: p }
- }
-
- pub fn generate_to<W: Write>(&self, buf: &mut W) {
- debugln!("ZshGen::generate_to;");
- w!(
- buf,
- format!(
- "\
-#compdef {name}
-
-autoload -U is-at-least
-
-_{name}() {{
- typeset -A opt_args
- typeset -a _arguments_options
- local ret=1
-
- if is-at-least 5.2; then
- _arguments_options=(-s -S -C)
- else
- _arguments_options=(-s -C)
- fi
-
- local context curcontext=\"$curcontext\" state line
- {initial_args}
- {subcommands}
-}}
-
-{subcommand_details}
-
-_{name} \"$@\"",
- name = self.p.meta.bin_name.as_ref().unwrap(),
- initial_args = get_args_of(self.p),
- subcommands = get_subcommands_of(self.p),
- subcommand_details = subcommand_details(self.p)
- ).as_bytes()
- );
- }
-}
-
-// Displays the commands of a subcommand
-// (( $+functions[_[bin_name_underscore]_commands] )) ||
-// _[bin_name_underscore]_commands() {
-// local commands; commands=(
-// '[arg_name]:[arg_help]'
-// )
-// _describe -t commands '[bin_name] commands' commands "$@"
-//
-// Where the following variables are present:
-// [bin_name_underscore]: The full space delineated bin_name, where spaces have been replaced by
-// underscore characters
-// [arg_name]: The name of the subcommand
-// [arg_help]: The help message of the subcommand
-// [bin_name]: The full space delineated bin_name
-//
-// Here's a snippet from rustup:
-//
-// (( $+functions[_rustup_commands] )) ||
-// _rustup_commands() {
-// local commands; commands=(
-// 'show:Show the active and installed toolchains'
-// 'update:Update Rust toolchains'
-// # ... snip for brevity
-// 'help:Prints this message or the help of the given subcommand(s)'
-// )
-// _describe -t commands 'rustup commands' commands "$@"
-//
-fn subcommand_details(p: &Parser) -> String {
- debugln!("ZshGen::subcommand_details;");
- // First we do ourself
- let mut ret = vec![
- format!(
- "\
-(( $+functions[_{bin_name_underscore}_commands] )) ||
-_{bin_name_underscore}_commands() {{
- local commands; commands=(
- {subcommands_and_args}
- )
- _describe -t commands '{bin_name} commands' commands \"$@\"
-}}",
- bin_name_underscore = p.meta.bin_name.as_ref().unwrap().replace(" ", "__"),
- bin_name = p.meta.bin_name.as_ref().unwrap(),
- subcommands_and_args = subcommands_of(p)
- ),
- ];
-
- // Next we start looping through all the children, grandchildren, etc.
- let mut all_subcommands = completions::all_subcommands(p);
- all_subcommands.sort();
- all_subcommands.dedup();
- for &(_, ref bin_name) in &all_subcommands {
- debugln!("ZshGen::subcommand_details:iter: bin_name={}", bin_name);
- ret.push(format!(
- "\
-(( $+functions[_{bin_name_underscore}_commands] )) ||
-_{bin_name_underscore}_commands() {{
- local commands; commands=(
- {subcommands_and_args}
- )
- _describe -t commands '{bin_name} commands' commands \"$@\"
-}}",
- bin_name_underscore = bin_name.replace(" ", "__"),
- bin_name = bin_name,
- subcommands_and_args = subcommands_of(parser_of(p, bin_name))
- ));
- }
-
- ret.join("\n")
-}
-
-// Generates subcommand completions in form of
-//
-// '[arg_name]:[arg_help]'
-//
-// Where:
-// [arg_name]: the subcommand's name
-// [arg_help]: the help message of the subcommand
-//
-// A snippet from rustup:
-// 'show:Show the active and installed toolchains'
-// 'update:Update Rust toolchains'
-fn subcommands_of(p: &Parser) -> String {
- debugln!("ZshGen::subcommands_of;");
- let mut ret = vec![];
- fn add_sc(sc: &App, n: &str, ret: &mut Vec<String>) {
- debugln!("ZshGen::add_sc;");
- let s = format!(
- "\"{name}:{help}\" \\",
- name = n,
- help = sc.p
- .meta
- .about
- .unwrap_or("")
- .replace("[", "\\[")
- .replace("]", "\\]")
- );
- if !s.is_empty() {
- ret.push(s);
- }
- }
-
- // The subcommands
- for sc in p.subcommands() {
- debugln!(
- "ZshGen::subcommands_of:iter: subcommand={}",
- sc.p.meta.name
- );
- add_sc(sc, &sc.p.meta.name, &mut ret);
- if let Some(ref v) = sc.p.meta.aliases {
- for alias in v.iter().filter(|&&(_, vis)| vis).map(|&(n, _)| n) {
- add_sc(sc, alias, &mut ret);
- }
- }
- }
-
- ret.join("\n")
-}
-
-// Get's the subcommand section of a completion file
-// This looks roughly like:
-//
-// case $state in
-// ([bin_name]_args)
-// curcontext=\"${curcontext%:*:*}:[name_hyphen]-command-$words[1]:\"
-// case $line[1] in
-//
-// ([name])
-// _arguments -C -s -S \
-// [subcommand_args]
-// && ret=0
-//
-// [RECURSIVE_CALLS]
-//
-// ;;",
-//
-// [repeat]
-//
-// esac
-// ;;
-// esac",
-//
-// Where the following variables are present:
-// [name] = The subcommand name in the form of "install" for "rustup toolchain install"
-// [bin_name] = The full space delineated bin_name such as "rustup toolchain install"
-// [name_hyphen] = The full space delineated bin_name, but replace spaces with hyphens
-// [repeat] = From the same recursive calls, but for all subcommands
-// [subcommand_args] = The same as zsh::get_args_of
-fn get_subcommands_of(p: &Parser) -> String {
- debugln!("get_subcommands_of;");
-
- debugln!(
- "get_subcommands_of: Has subcommands...{:?}",
- p.has_subcommands()
- );
- if !p.has_subcommands() {
- return String::new();
- }
-
- let sc_names = completions::subcommands_of(p);
-
- let mut subcmds = vec![];
- for &(ref name, ref bin_name) in &sc_names {
- let mut v = vec![format!("({})", name)];
- let subcommand_args = get_args_of(parser_of(p, &*bin_name));
- if !subcommand_args.is_empty() {
- v.push(subcommand_args);
- }
- let subcommands = get_subcommands_of(parser_of(p, &*bin_name));
- if !subcommands.is_empty() {
- v.push(subcommands);
- }
- v.push(String::from(";;"));
- subcmds.push(v.join("\n"));
- }
-
- format!(
- "case $state in
- ({name})
- words=($line[{pos}] \"${{words[@]}}\")
- (( CURRENT += 1 ))
- curcontext=\"${{curcontext%:*:*}}:{name_hyphen}-command-$line[{pos}]:\"
- case $line[{pos}] in
- {subcommands}
- esac
- ;;
-esac",
- name = p.meta.name,
- name_hyphen = p.meta.bin_name.as_ref().unwrap().replace(" ", "-"),
- subcommands = subcmds.join("\n"),
- pos = p.positionals().len() + 1
- )
-}
-
-fn parser_of<'a, 'b>(p: &'b Parser<'a, 'b>, sc: &str) -> &'b Parser<'a, 'b> {
- debugln!("parser_of: sc={}", sc);
- if sc == p.meta.bin_name.as_ref().unwrap_or(&String::new()) {
- return p;
- }
- &p.find_subcommand(sc).expect(INTERNAL_ERROR_MSG).p
-}
-
-// Writes out the args section, which ends up being the flags, opts and postionals, and a jump to
-// another ZSH function if there are subcommands.
-// The structer works like this:
-// ([conflicting_args]) [multiple] arg [takes_value] [[help]] [: :(possible_values)]
-// ^-- list '-v -h' ^--'*' ^--'+' ^-- list 'one two three'
-//
-// An example from the rustup command:
-//
-// _arguments -C -s -S \
-// '(-h --help --verbose)-v[Enable verbose output]' \
-// '(-V -v --version --verbose --help)-h[Prints help information]' \
-// # ... snip for brevity
-// ':: :_rustup_commands' \ # <-- displays subcommands
-// '*::: :->rustup' \ # <-- displays subcommand args and child subcommands
-// && ret=0
-//
-// The args used for _arguments are as follows:
-// -C: modify the $context internal variable
-// -s: Allow stacking of short args (i.e. -a -b -c => -abc)
-// -S: Do not complete anything after '--' and treat those as argument values
-fn get_args_of(p: &Parser) -> String {
- debugln!("get_args_of;");
- let mut ret = vec![String::from("_arguments \"${_arguments_options[@]}\" \\")];
- let opts = write_opts_of(p);
- let flags = write_flags_of(p);
- let positionals = write_positionals_of(p);
- let sc_or_a = if p.has_subcommands() {
- format!(
- "\":: :_{name}_commands\" \\",
- name = p.meta.bin_name.as_ref().unwrap().replace(" ", "__")
- )
- } else {
- String::new()
- };
- let sc = if p.has_subcommands() {
- format!("\"*::: :->{name}\" \\", name = p.meta.name)
- } else {
- String::new()
- };
-
- if !opts.is_empty() {
- ret.push(opts);
- }
- if !flags.is_empty() {
- ret.push(flags);
- }
- if !positionals.is_empty() {
- ret.push(positionals);
- }
- if !sc_or_a.is_empty() {
- ret.push(sc_or_a);
- }
- if !sc.is_empty() {
- ret.push(sc);
- }
- ret.push(String::from("&& ret=0"));
-
- ret.join("\n")
-}
-
-// Escape help string inside single quotes and brackets
-fn escape_help(string: &str) -> String {
- string
- .replace("\\", "\\\\")
- .replace("'", "'\\''")
- .replace("[", "\\[")
- .replace("]", "\\]")
-}
-
-// Escape value string inside single quotes and parentheses
-fn escape_value(string: &str) -> String {
- string
- .replace("\\", "\\\\")
- .replace("'", "'\\''")
- .replace("(", "\\(")
- .replace(")", "\\)")
- .replace(" ", "\\ ")
-}
-
-fn write_opts_of(p: &Parser) -> String {
- debugln!("write_opts_of;");
- let mut ret = vec![];
- for o in p.opts() {
- debugln!("write_opts_of:iter: o={}", o.name());
- let help = o.help().map_or(String::new(), escape_help);
- let mut conflicts = get_zsh_arg_conflicts!(p, o, INTERNAL_ERROR_MSG);
- conflicts = if conflicts.is_empty() {
- String::new()
- } else {
- format!("({})", conflicts)
- };
-
- let multiple = if o.is_set(ArgSettings::Multiple) {
- "*"
- } else {
- ""
- };
- let pv = if let Some(pv_vec) = o.possible_vals() {
- format!(": :({})", pv_vec.iter().map(
- |v| escape_value(*v)).collect::<Vec<String>>().join(" "))
- } else {
- String::new()
- };
- if let Some(short) = o.short() {
- let s = format!(
- "'{conflicts}{multiple}-{arg}+[{help}]{possible_values}' \\",
- conflicts = conflicts,
- multiple = multiple,
- arg = short,
- possible_values = pv,
- help = help
- );
-
- debugln!("write_opts_of:iter: Wrote...{}", &*s);
- ret.push(s);
- }
- if let Some(long) = o.long() {
- let l = format!(
- "'{conflicts}{multiple}--{arg}=[{help}]{possible_values}' \\",
- conflicts = conflicts,
- multiple = multiple,
- arg = long,
- possible_values = pv,
- help = help
- );
-
- debugln!("write_opts_of:iter: Wrote...{}", &*l);
- ret.push(l);
- }
- }
-
- ret.join("\n")
-}
-
-fn write_flags_of(p: &Parser) -> String {
- debugln!("write_flags_of;");
- let mut ret = vec![];
- for f in p.flags() {
- debugln!("write_flags_of:iter: f={}", f.name());
- let help = f.help().map_or(String::new(), escape_help);
- let mut conflicts = get_zsh_arg_conflicts!(p, f, INTERNAL_ERROR_MSG);
- conflicts = if conflicts.is_empty() {
- String::new()
- } else {
- format!("({})", conflicts)
- };
-
- let multiple = if f.is_set(ArgSettings::Multiple) {
- "*"
- } else {
- ""
- };
- if let Some(short) = f.short() {
- let s = format!(
- "'{conflicts}{multiple}-{arg}[{help}]' \\",
- multiple = multiple,
- conflicts = conflicts,
- arg = short,
- help = help
- );
-
- debugln!("write_flags_of:iter: Wrote...{}", &*s);
- ret.push(s);
- }
-
- if let Some(long) = f.long() {
- let l = format!(
- "'{conflicts}{multiple}--{arg}[{help}]' \\",
- conflicts = conflicts,
- multiple = multiple,
- arg = long,
- help = help
- );
-
- debugln!("write_flags_of:iter: Wrote...{}", &*l);
- ret.push(l);
- }
- }
-
- ret.join("\n")
-}
-
-fn write_positionals_of(p: &Parser) -> String {
- debugln!("write_positionals_of;");
- let mut ret = vec![];
- for arg in p.positionals() {
- debugln!("write_positionals_of:iter: arg={}", arg.b.name);
- let a = format!(
- "'{optional}:{name}{help}:{action}' \\",
- optional = if !arg.b.is_set(ArgSettings::Required) { ":" } else { "" },
- name = arg.b.name,
- help = arg.b
- .help
- .map_or("".to_owned(), |v| " -- ".to_owned() + v)
- .replace("[", "\\[")
- .replace("]", "\\]"),
- action = arg.possible_vals().map_or("_files".to_owned(), |values| {
- format!("({})",
- values.iter().map(|v| escape_value(*v)).collect::<Vec<String>>().join(" "))
- })
- );
-
- debugln!("write_positionals_of:iter: Wrote...{}", a);
- ret.push(a);
- }
-
- ret.join("\n")
-}
diff --git a/clap/src/errors.rs b/clap/src/errors.rs
deleted file mode 100644
index c6087c0..0000000
--- a/clap/src/errors.rs
+++ /dev/null
@@ -1,912 +0,0 @@
-// Std
-use std::convert::From;
-use std::error::Error as StdError;
-use std::fmt as std_fmt;
-use std::fmt::Display;
-use std::io::{self, Write};
-use std::process;
-use std::result::Result as StdResult;
-
-// Internal
-use args::AnyArg;
-use fmt::{ColorWhen, Colorizer, ColorizerOption};
-use suggestions;
-
-/// Short hand for [`Result`] type
-///
-/// [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
-pub type Result<T> = StdResult<T, Error>;
-
-/// Command line argument parser kind of error
-#[derive(Debug, Copy, Clone, PartialEq)]
-pub enum ErrorKind {
- /// Occurs when an [`Arg`] has a set of possible values,
- /// and the user provides a value which isn't in that set.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("speed")
- /// .possible_value("fast")
- /// .possible_value("slow"))
- /// .get_matches_from_safe(vec!["prog", "other"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidValue);
- /// ```
- /// [`Arg`]: ./struct.Arg.html
- InvalidValue,
-
- /// Occurs when a user provides a flag, option, argument or subcommand which isn't defined.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::from_usage("--flag 'some flag'"))
- /// .get_matches_from_safe(vec!["prog", "--other"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::UnknownArgument);
- /// ```
- UnknownArgument,
-
- /// Occurs when the user provides an unrecognized [`SubCommand`] which meets the threshold for
- /// being similar enough to an existing subcommand.
- /// If it doesn't meet the threshold, or the 'suggestions' feature is disabled,
- /// the more general [`UnknownArgument`] error is returned.
- ///
- /// # Examples
- ///
- #[cfg_attr(not(feature = "suggestions"), doc = " ```no_run")]
- #[cfg_attr(feature = "suggestions", doc = " ```")]
- /// # use clap::{App, Arg, ErrorKind, SubCommand};
- /// let result = App::new("prog")
- /// .subcommand(SubCommand::with_name("config")
- /// .about("Used for configuration")
- /// .arg(Arg::with_name("config_file")
- /// .help("The configuration file to use")
- /// .index(1)))
- /// .get_matches_from_safe(vec!["prog", "confi"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidSubcommand);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`UnknownArgument`]: ./enum.ErrorKind.html#variant.UnknownArgument
- InvalidSubcommand,
-
- /// Occurs when the user provides an unrecognized [`SubCommand`] which either
- /// doesn't meet the threshold for being similar enough to an existing subcommand,
- /// or the 'suggestions' feature is disabled.
- /// Otherwise the more detailed [`InvalidSubcommand`] error is returned.
- ///
- /// This error typically happens when passing additional subcommand names to the `help`
- /// subcommand. Otherwise, the more general [`UnknownArgument`] error is used.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind, SubCommand};
- /// let result = App::new("prog")
- /// .subcommand(SubCommand::with_name("config")
- /// .about("Used for configuration")
- /// .arg(Arg::with_name("config_file")
- /// .help("The configuration file to use")
- /// .index(1)))
- /// .get_matches_from_safe(vec!["prog", "help", "nothing"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::UnrecognizedSubcommand);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`InvalidSubcommand`]: ./enum.ErrorKind.html#variant.InvalidSubcommand
- /// [`UnknownArgument`]: ./enum.ErrorKind.html#variant.UnknownArgument
- UnrecognizedSubcommand,
-
- /// Occurs when the user provides an empty value for an option that does not allow empty
- /// values.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let res = App::new("prog")
- /// .arg(Arg::with_name("color")
- /// .long("color")
- /// .empty_values(false))
- /// .get_matches_from_safe(vec!["prog", "--color="]);
- /// assert!(res.is_err());
- /// assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
- /// ```
- EmptyValue,
-
- /// Occurs when the user provides a value for an argument with a custom validation and the
- /// value fails that validation.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// fn is_numeric(val: String) -> Result<(), String> {
- /// match val.parse::<i64>() {
- /// Ok(..) => Ok(()),
- /// Err(..) => Err(String::from("Value wasn't a number!")),
- /// }
- /// }
- ///
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("num")
- /// .validator(is_numeric))
- /// .get_matches_from_safe(vec!["prog", "NotANumber"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::ValueValidation);
- /// ```
- ValueValidation,
-
- /// Occurs when a user provides more values for an argument than were defined by setting
- /// [`Arg::max_values`].
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("arg")
- /// .multiple(true)
- /// .max_values(2))
- /// .get_matches_from_safe(vec!["prog", "too", "many", "values"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::TooManyValues);
- /// ```
- /// [`Arg::max_values`]: ./struct.Arg.html#method.max_values
- TooManyValues,
-
- /// Occurs when the user provides fewer values for an argument than were defined by setting
- /// [`Arg::min_values`].
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("some_opt")
- /// .long("opt")
- /// .min_values(3))
- /// .get_matches_from_safe(vec!["prog", "--opt", "too", "few"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::TooFewValues);
- /// ```
- /// [`Arg::min_values`]: ./struct.Arg.html#method.min_values
- TooFewValues,
-
- /// Occurs when the user provides a different number of values for an argument than what's
- /// been defined by setting [`Arg::number_of_values`] or than was implicitly set by
- /// [`Arg::value_names`].
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("some_opt")
- /// .long("opt")
- /// .takes_value(true)
- /// .number_of_values(2))
- /// .get_matches_from_safe(vec!["prog", "--opt", "wrong"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
- /// ```
- ///
- /// [`Arg::number_of_values`]: ./struct.Arg.html#method.number_of_values
- /// [`Arg::value_names`]: ./struct.Arg.html#method.value_names
- WrongNumberOfValues,
-
- /// Occurs when the user provides two values which conflict with each other and can't be used
- /// together.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("debug")
- /// .long("debug")
- /// .conflicts_with("color"))
- /// .arg(Arg::with_name("color")
- /// .long("color"))
- /// .get_matches_from_safe(vec!["prog", "--debug", "--color"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::ArgumentConflict);
- /// ```
- ArgumentConflict,
-
- /// Occurs when the user does not provide one or more required arguments.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("debug")
- /// .required(true))
- /// .get_matches_from_safe(vec!["prog"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
- /// ```
- MissingRequiredArgument,
-
- /// Occurs when a subcommand is required (as defined by [`AppSettings::SubcommandRequired`]),
- /// but the user does not provide one.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, AppSettings, SubCommand, ErrorKind};
- /// let err = App::new("prog")
- /// .setting(AppSettings::SubcommandRequired)
- /// .subcommand(SubCommand::with_name("test"))
- /// .get_matches_from_safe(vec![
- /// "myprog",
- /// ]);
- /// assert!(err.is_err());
- /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand);
- /// # ;
- /// ```
- /// [`AppSettings::SubcommandRequired`]: ./enum.AppSettings.html#variant.SubcommandRequired
- MissingSubcommand,
-
- /// Occurs when either an argument or [`SubCommand`] is required, as defined by
- /// [`AppSettings::ArgRequiredElseHelp`], but the user did not provide one.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, AppSettings, ErrorKind, SubCommand};
- /// let result = App::new("prog")
- /// .setting(AppSettings::ArgRequiredElseHelp)
- /// .subcommand(SubCommand::with_name("config")
- /// .about("Used for configuration")
- /// .arg(Arg::with_name("config_file")
- /// .help("The configuration file to use")))
- /// .get_matches_from_safe(vec!["prog"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::MissingArgumentOrSubcommand);
- /// ```
- /// [`SubCommand`]: ./struct.SubCommand.html
- /// [`AppSettings::ArgRequiredElseHelp`]: ./enum.AppSettings.html#variant.ArgRequiredElseHelp
- MissingArgumentOrSubcommand,
-
- /// Occurs when the user provides multiple values to an argument which doesn't allow that.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .arg(Arg::with_name("debug")
- /// .long("debug")
- /// .multiple(false))
- /// .get_matches_from_safe(vec!["prog", "--debug", "--debug"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::UnexpectedMultipleUsage);
- /// ```
- UnexpectedMultipleUsage,
-
- /// Occurs when the user provides a value containing invalid UTF-8 for an argument and
- /// [`AppSettings::StrictUtf8`] is set.
- ///
- /// # Platform Specific
- ///
- /// Non-Windows platforms only (such as Linux, Unix, macOS, etc.)
- ///
- /// # Examples
- ///
- #[cfg_attr(not(unix), doc = " ```ignore")]
- #[cfg_attr(unix, doc = " ```")]
- /// # use clap::{App, Arg, ErrorKind, AppSettings};
- /// # use std::os::unix::ffi::OsStringExt;
- /// # use std::ffi::OsString;
- /// let result = App::new("prog")
- /// .setting(AppSettings::StrictUtf8)
- /// .arg(Arg::with_name("utf8")
- /// .short("u")
- /// .takes_value(true))
- /// .get_matches_from_safe(vec![OsString::from("myprog"),
- /// OsString::from("-u"),
- /// OsString::from_vec(vec![0xE9])]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidUtf8);
- /// ```
- /// [`AppSettings::StrictUtf8`]: ./enum.AppSettings.html#variant.StrictUtf8
- InvalidUtf8,
-
- /// Not a true "error" as it means `--help` or similar was used.
- /// The help message will be sent to `stdout`.
- ///
- /// **Note**: If the help is displayed due to an error (such as missing subcommands) it will
- /// be sent to `stderr` instead of `stdout`.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .get_matches_from_safe(vec!["prog", "--help"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::HelpDisplayed);
- /// ```
- HelpDisplayed,
-
- /// Not a true "error" as it means `--version` or similar was used.
- /// The message will be sent to `stdout`.
- ///
- /// # Examples
- ///
- /// ```rust
- /// # use clap::{App, Arg, ErrorKind};
- /// let result = App::new("prog")
- /// .get_matches_from_safe(vec!["prog", "--version"]);
- /// assert!(result.is_err());
- /// assert_eq!(result.unwrap_err().kind, ErrorKind::VersionDisplayed);
- /// ```
- VersionDisplayed,
-
- /// Occurs when using the [`value_t!`] and [`values_t!`] macros to convert an argument value
- /// into type `T`, but the argument you requested wasn't used. I.e. you asked for an argument
- /// with name `config` to be converted, but `config` wasn't used by the user.
- /// [`value_t!`]: ./macro.value_t!.html
- /// [`values_t!`]: ./macro.values_t!.html
- ArgumentNotFound,
-
- /// Represents an [I/O error].
- /// Can occur when writing to `stderr` or `stdout` or reading a configuration file.
- /// [I/O error]: https://doc.rust-lang.org/std/io/struct.Error.html
- Io,
-
- /// Represents a [Format error] (which is a part of [`Display`]).
- /// Typically caused by writing to `stderr` or `stdout`.
- ///
- /// [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
- /// [Format error]: https://doc.rust-lang.org/std/fmt/struct.Error.html
- Format,
-}
-
-/// Command Line Argument Parser Error
-#[derive(Debug)]
-pub struct Error {
- /// Formatted error message
- pub message: String,
- /// The type of error
- pub kind: ErrorKind,
- /// Any additional information passed along, such as the argument name that caused the error
- pub info: Option<Vec<String>>,
-}
-
-impl Error {
- /// Should the message be written to `stdout` or not
- pub fn use_stderr(&self) -> bool {
- match self.kind {
- ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed => false,
- _ => true,
- }
- }
-
- /// Prints the error to `stderr` and exits with a status of `1`
- pub fn exit(&self) -> ! {
- if self.use_stderr() {
- wlnerr!("{}", self.message);
- process::exit(1);
- }
- let out = io::stdout();
- writeln!(&mut out.lock(), "{}", self.message).expect("Error writing Error to stdout");
- process::exit(0);
- }
-
- #[doc(hidden)]
- pub fn write_to<W: Write>(&self, w: &mut W) -> io::Result<()> { write!(w, "{}", self.message) }
-
- #[doc(hidden)]
- pub fn argument_conflict<O, U>(
- arg: &AnyArg,
- other: Option<O>,
- usage: U,
- color: ColorWhen,
- ) -> Self
- where
- O: Into<String>,
- U: Display,
- {
- let mut v = vec![arg.name().to_owned()];
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The argument '{}' cannot be used with {}\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(&*arg.to_string()),
- match other {
- Some(name) => {
- let n = name.into();
- v.push(n.clone());
- c.warning(format!("'{}'", n))
- }
- None => c.none("one or more of the other specified arguments".to_owned()),
- },
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::ArgumentConflict,
- info: Some(v),
- }
- }
-
- #[doc(hidden)]
- pub fn empty_value<U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
- where
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The argument '{}' requires a value but none was supplied\
- \n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(arg.to_string()),
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::EmptyValue,
- info: Some(vec![arg.name().to_owned()]),
- }
- }
-
- #[doc(hidden)]
- pub fn invalid_value<B, G, U>(
- bad_val: B,
- good_vals: &[G],
- arg: &AnyArg,
- usage: U,
- color: ColorWhen,
- ) -> Self
- where
- B: AsRef<str>,
- G: AsRef<str> + Display,
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- let suffix = suggestions::did_you_mean_value_suffix(bad_val.as_ref(), good_vals.iter());
-
- let mut sorted = vec![];
- for v in good_vals {
- let val = format!("{}", c.good(v));
- sorted.push(val);
- }
- sorted.sort();
- let valid_values = sorted.join(", ");
- Error {
- message: format!(
- "{} '{}' isn't a valid value for '{}'\n\t\
- [possible values: {}]\n\
- {}\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(bad_val.as_ref()),
- c.warning(arg.to_string()),
- valid_values,
- suffix.0,
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::InvalidValue,
- info: Some(vec![arg.name().to_owned(), bad_val.as_ref().to_owned()]),
- }
- }
-
- #[doc(hidden)]
- pub fn invalid_subcommand<S, D, N, U>(
- subcmd: S,
- did_you_mean: D,
- name: N,
- usage: U,
- color: ColorWhen,
- ) -> Self
- where
- S: Into<String>,
- D: AsRef<str> + Display,
- N: Display,
- U: Display,
- {
- let s = subcmd.into();
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The subcommand '{}' wasn't recognized\n\t\
- Did you mean '{}'?\n\n\
- If you believe you received this message in error, try \
- re-running with '{} {} {}'\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(&*s),
- c.good(did_you_mean.as_ref()),
- name,
- c.good("--"),
- &*s,
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::InvalidSubcommand,
- info: Some(vec![s]),
- }
- }
-
- #[doc(hidden)]
- pub fn unrecognized_subcommand<S, N>(subcmd: S, name: N, color: ColorWhen) -> Self
- where
- S: Into<String>,
- N: Display,
- {
- let s = subcmd.into();
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The subcommand '{}' wasn't recognized\n\n\
- {}\n\t\
- {} help <subcommands>...\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(&*s),
- c.warning("USAGE:"),
- name,
- c.good("--help")
- ),
- kind: ErrorKind::UnrecognizedSubcommand,
- info: Some(vec![s]),
- }
- }
-
- #[doc(hidden)]
- pub fn missing_required_argument<R, U>(required: R, usage: U, color: ColorWhen) -> Self
- where
- R: Display,
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The following required arguments were not provided:{}\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- required,
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::MissingRequiredArgument,
- info: None,
- }
- }
-
- #[doc(hidden)]
- pub fn missing_subcommand<N, U>(name: N, usage: U, color: ColorWhen) -> Self
- where
- N: AsRef<str> + Display,
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} '{}' requires a subcommand, but one was not provided\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(name),
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::MissingSubcommand,
- info: None,
- }
- }
-
-
- #[doc(hidden)]
- pub fn invalid_utf8<U>(usage: U, color: ColorWhen) -> Self
- where
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} Invalid UTF-8 was detected in one or more arguments\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::InvalidUtf8,
- info: None,
- }
- }
-
- #[doc(hidden)]
- pub fn too_many_values<V, U>(val: V, arg: &AnyArg, usage: U, color: ColorWhen) -> Self
- where
- V: AsRef<str> + Display + ToOwned,
- U: Display,
- {
- let v = val.as_ref();
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The value '{}' was provided to '{}', but it wasn't expecting \
- any more values\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(v),
- c.warning(arg.to_string()),
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::TooManyValues,
- info: Some(vec![arg.name().to_owned(), v.to_owned()]),
- }
- }
-
- #[doc(hidden)]
- pub fn too_few_values<U>(
- arg: &AnyArg,
- min_vals: u64,
- curr_vals: usize,
- usage: U,
- color: ColorWhen,
- ) -> Self
- where
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The argument '{}' requires at least {} values, but only {} w{} \
- provided\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(arg.to_string()),
- c.warning(min_vals.to_string()),
- c.warning(curr_vals.to_string()),
- if curr_vals > 1 { "ere" } else { "as" },
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::TooFewValues,
- info: Some(vec![arg.name().to_owned()]),
- }
- }
-
- #[doc(hidden)]
- pub fn value_validation(arg: Option<&AnyArg>, err: String, color: ColorWhen) -> Self
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} Invalid value{}: {}",
- c.error("error:"),
- if let Some(a) = arg {
- format!(" for '{}'", c.warning(a.to_string()))
- } else {
- "".to_string()
- },
- err
- ),
- kind: ErrorKind::ValueValidation,
- info: None,
- }
- }
-
- #[doc(hidden)]
- pub fn value_validation_auto(err: String) -> Self {
- let n: Option<&AnyArg> = None;
- Error::value_validation(n, err, ColorWhen::Auto)
- }
-
- #[doc(hidden)]
- pub fn wrong_number_of_values<S, U>(
- arg: &AnyArg,
- num_vals: u64,
- curr_vals: usize,
- suffix: S,
- usage: U,
- color: ColorWhen,
- ) -> Self
- where
- S: Display,
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The argument '{}' requires {} values, but {} w{} \
- provided\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(arg.to_string()),
- c.warning(num_vals.to_string()),
- c.warning(curr_vals.to_string()),
- suffix,
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::WrongNumberOfValues,
- info: Some(vec![arg.name().to_owned()]),
- }
- }
-
- #[doc(hidden)]
- pub fn unexpected_multiple_usage<U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
- where
- U: Display,
- {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} The argument '{}' was provided more than once, but cannot \
- be used multiple times\n\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(arg.to_string()),
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::UnexpectedMultipleUsage,
- info: Some(vec![arg.name().to_owned()]),
- }
- }
-
- #[doc(hidden)]
- pub fn unknown_argument<A, U>(arg: A, did_you_mean: &str, usage: U, color: ColorWhen) -> Self
- where
- A: Into<String>,
- U: Display,
- {
- let a = arg.into();
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!(
- "{} Found argument '{}' which wasn't expected, or isn't valid in \
- this context{}\n\
- {}\n\n\
- For more information try {}",
- c.error("error:"),
- c.warning(&*a),
- if did_you_mean.is_empty() {
- "\n".to_owned()
- } else {
- format!("{}\n", did_you_mean)
- },
- usage,
- c.good("--help")
- ),
- kind: ErrorKind::UnknownArgument,
- info: Some(vec![a]),
- }
- }
-
- #[doc(hidden)]
- pub fn io_error(e: &Error, color: ColorWhen) -> Self {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: color,
- });
- Error {
- message: format!("{} {}", c.error("error:"), e.description()),
- kind: ErrorKind::Io,
- info: None,
- }
- }
-
- #[doc(hidden)]
- pub fn argument_not_found_auto<A>(arg: A) -> Self
- where
- A: Into<String>,
- {
- let a = arg.into();
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: ColorWhen::Auto,
- });
- Error {
- message: format!(
- "{} The argument '{}' wasn't found",
- c.error("error:"),
- a.clone()
- ),
- kind: ErrorKind::ArgumentNotFound,
- info: Some(vec![a]),
- }
- }
-
- /// Create an error with a custom description.
- ///
- /// This can be used in combination with `Error::exit` to exit your program
- /// with a custom error message.
- pub fn with_description(description: &str, kind: ErrorKind) -> Self {
- let c = Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: ColorWhen::Auto,
- });
- Error {
- message: format!("{} {}", c.error("error:"), description),
- kind: kind,
- info: None,
- }
- }
-}
-
-impl StdError for Error {
- fn description(&self) -> &str { &*self.message }
-}
-
-impl Display for Error {
- fn fmt(&self, f: &mut std_fmt::Formatter) -> std_fmt::Result { writeln!(f, "{}", self.message) }
-}
-
-impl From<io::Error> for Error {
- fn from(e: io::Error) -> Self { Error::with_description(e.description(), ErrorKind::Io) }
-}
-
-impl From<std_fmt::Error> for Error {
- fn from(e: std_fmt::Error) -> Self {
- Error::with_description(e.description(), ErrorKind::Format)
- }
-}
diff --git a/clap/src/fmt.rs b/clap/src/fmt.rs
deleted file mode 100644
index 108a635..0000000
--- a/clap/src/fmt.rs
+++ /dev/null
@@ -1,189 +0,0 @@
-#[cfg(all(feature = "color", not(target_os = "windows")))]
-use ansi_term::ANSIString;
-
-#[cfg(all(feature = "color", not(target_os = "windows")))]
-use ansi_term::Colour::{Green, Red, Yellow};
-
-#[cfg(feature = "color")]
-use atty;
-use std::fmt;
-use std::env;
-
-#[doc(hidden)]
-#[derive(Debug, Copy, Clone, PartialEq)]
-pub enum ColorWhen {
- Auto,
- Always,
- Never,
-}
-
-#[cfg(feature = "color")]
-pub fn is_a_tty(stderr: bool) -> bool {
- debugln!("is_a_tty: stderr={:?}", stderr);
- let stream = if stderr {
- atty::Stream::Stderr
- } else {
- atty::Stream::Stdout
- };
- atty::is(stream)
-}
-
-#[cfg(not(feature = "color"))]
-pub fn is_a_tty(_: bool) -> bool {
- debugln!("is_a_tty;");
- false
-}
-
-pub fn is_term_dumb() -> bool { env::var("TERM").ok() == Some(String::from("dumb")) }
-
-#[doc(hidden)]
-pub struct ColorizerOption {
- pub use_stderr: bool,
- pub when: ColorWhen,
-}
-
-#[doc(hidden)]
-pub struct Colorizer {
- when: ColorWhen,
-}
-
-macro_rules! color {
- ($_self:ident, $c:ident, $m:expr) => {
- match $_self.when {
- ColorWhen::Auto => Format::$c($m),
- ColorWhen::Always => Format::$c($m),
- ColorWhen::Never => Format::None($m),
- }
- };
-}
-
-impl Colorizer {
- pub fn new(option: ColorizerOption) -> Colorizer {
- let is_a_tty = is_a_tty(option.use_stderr);
- let is_term_dumb = is_term_dumb();
- Colorizer {
- when: match option.when {
- ColorWhen::Auto if is_a_tty && !is_term_dumb => ColorWhen::Auto,
- ColorWhen::Auto => ColorWhen::Never,
- when => when,
- }
- }
- }
-
- pub fn good<T>(&self, msg: T) -> Format<T>
- where
- T: fmt::Display + AsRef<str>,
- {
- debugln!("Colorizer::good;");
- color!(self, Good, msg)
- }
-
- pub fn warning<T>(&self, msg: T) -> Format<T>
- where
- T: fmt::Display + AsRef<str>,
- {
- debugln!("Colorizer::warning;");
- color!(self, Warning, msg)
- }
-
- pub fn error<T>(&self, msg: T) -> Format<T>
- where
- T: fmt::Display + AsRef<str>,
- {
- debugln!("Colorizer::error;");
- color!(self, Error, msg)
- }
-
- pub fn none<T>(&self, msg: T) -> Format<T>
- where
- T: fmt::Display + AsRef<str>,
- {
- debugln!("Colorizer::none;");
- Format::None(msg)
- }
-}
-
-impl Default for Colorizer {
- fn default() -> Self {
- Colorizer::new(ColorizerOption {
- use_stderr: true,
- when: ColorWhen::Auto,
- })
- }
-}
-
-/// Defines styles for different types of error messages. Defaults to Error=Red, Warning=Yellow,
-/// and Good=Green
-#[derive(Debug)]
-#[doc(hidden)]
-pub enum Format<T> {
- /// Defines the style used for errors, defaults to Red
- Error(T),
- /// Defines the style used for warnings, defaults to Yellow
- Warning(T),
- /// Defines the style used for good values, defaults to Green
- Good(T),
- /// Defines no formatting style
- None(T),
-}
-
-#[cfg(all(feature = "color", not(target_os = "windows")))]
-impl<T: AsRef<str>> Format<T> {
- fn format(&self) -> ANSIString {
- match *self {
- Format::Error(ref e) => Red.bold().paint(e.as_ref()),
- Format::Warning(ref e) => Yellow.paint(e.as_ref()),
- Format::Good(ref e) => Green.paint(e.as_ref()),
- Format::None(ref e) => ANSIString::from(e.as_ref()),
- }
- }
-}
-
-#[cfg(any(not(feature = "color"), target_os = "windows"))]
-#[cfg_attr(feature = "lints", allow(match_same_arms))]
-impl<T: fmt::Display> Format<T> {
- fn format(&self) -> &T {
- match *self {
- Format::Error(ref e) => e,
- Format::Warning(ref e) => e,
- Format::Good(ref e) => e,
- Format::None(ref e) => e,
- }
- }
-}
-
-
-#[cfg(all(feature = "color", not(target_os = "windows")))]
-impl<T: AsRef<str>> fmt::Display for Format<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", &self.format()) }
-}
-
-#[cfg(any(not(feature = "color"), target_os = "windows"))]
-impl<T: fmt::Display> fmt::Display for Format<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", &self.format()) }
-}
-
-#[cfg(all(test, feature = "color", not(target_os = "windows")))]
-mod test {
- use ansi_term::ANSIString;
- use ansi_term::Colour::{Green, Red, Yellow};
- use super::Format;
-
- #[test]
- fn colored_output() {
- let err = Format::Error("error");
- assert_eq!(
- &*format!("{}", err),
- &*format!("{}", Red.bold().paint("error"))
- );
- let good = Format::Good("good");
- assert_eq!(&*format!("{}", good), &*format!("{}", Green.paint("good")));
- let warn = Format::Warning("warn");
- assert_eq!(&*format!("{}", warn), &*format!("{}", Yellow.paint("warn")));
- let none = Format::None("none");
- assert_eq!(
- &*format!("{}", none),
- &*format!("{}", ANSIString::from("none"))
- );
- }
-}
diff --git a/clap/src/lib.rs b/clap/src/lib.rs
deleted file mode 100644
index 0a3e1bb..0000000
--- a/clap/src/lib.rs
+++ /dev/null
@@ -1,629 +0,0 @@
-// Copyright ⓒ 2015-2016 Kevin B. Knapp and [`clap-rs` contributors](https://github.com/clap-rs/clap/blob/master/CONTRIBUTORS.md).
-// Licensed under the MIT license
-// (see LICENSE or <http://opensource.org/licenses/MIT>) All files in the project carrying such
-// notice may not be copied, modified, or distributed except according to those terms.
-
-//! `clap` is a simple-to-use, efficient, and full-featured library for parsing command line
-//! arguments and subcommands when writing console/terminal applications.
-//!
-//! ## About
-//!
-//! `clap` is used to parse *and validate* the string of command line arguments provided by the user
-//! at runtime. You provide the list of valid possibilities, and `clap` handles the rest. This means
-//! you focus on your *applications* functionality, and less on the parsing and validating of
-//! arguments.
-//!
-//! `clap` also provides the traditional version and help switches (or flags) 'for free' meaning
-//! automatically with no configuration. It does this by checking list of valid possibilities you
-//! supplied and adding only the ones you haven't already defined. If you are using subcommands,
-//! `clap` will also auto-generate a `help` subcommand for you in addition to the traditional flags.
-//!
-//! Once `clap` parses the user provided string of arguments, it returns the matches along with any
-//! applicable values. If the user made an error or typo, `clap` informs them of the mistake and
-//! exits gracefully (or returns a `Result` type and allows you to perform any clean up prior to
-//! exit). Because of this, you can make reasonable assumptions in your code about the validity of
-//! the arguments.
-//!
-//!
-//! ## Quick Example
-//!
-//! The following examples show a quick example of some of the very basic functionality of `clap`.
-//! For more advanced usage, such as requirements, conflicts, groups, multiple values and
-//! occurrences see the [documentation](https://docs.rs/clap/), [examples/] directory of
-//! this repository or the [video tutorials].
-//!
-//! **NOTE:** All of these examples are functionally the same, but show different styles in which to
-//! use `clap`
-//!
-//! The first example shows a method that allows more advanced configuration options (not shown in
-//! this small example), or even dynamically generating arguments when desired. The downside is it's
-//! more verbose.
-//!
-//! ```no_run
-//! // (Full example with detailed comments in examples/01b_quick_example.rs)
-//! //
-//! // This example demonstrates clap's full 'builder pattern' style of creating arguments which is
-//! // more verbose, but allows easier editing, and at times more advanced options, or the possibility
-//! // to generate arguments dynamically.
-//! extern crate clap;
-//! use clap::{Arg, App, SubCommand};
-//!
-//! fn main() {
-//! let matches = App::new("My Super Program")
-//! .version("1.0")
-//! .author("Kevin K. <kbknapp@gmail.com>")
-//! .about("Does awesome things")
-//! .arg(Arg::with_name("config")
-//! .short("c")
-//! .long("config")
-//! .value_name("FILE")
-//! .help("Sets a custom config file")
-//! .takes_value(true))
-//! .arg(Arg::with_name("INPUT")
-//! .help("Sets the input file to use")
-//! .required(true)
-//! .index(1))
-//! .arg(Arg::with_name("v")
-//! .short("v")
-//! .multiple(true)
-//! .help("Sets the level of verbosity"))
-//! .subcommand(SubCommand::with_name("test")
-//! .about("controls testing features")
-//! .version("1.3")
-//! .author("Someone E. <someone_else@other.com>")
-//! .arg(Arg::with_name("debug")
-//! .short("d")
-//! .help("print debug information verbosely")))
-//! .get_matches();
-//!
-//! // Gets a value for config if supplied by user, or defaults to "default.conf"
-//! let config = matches.value_of("config").unwrap_or("default.conf");
-//! println!("Value for config: {}", config);
-//!
-//! // Calling .unwrap() is safe here because "INPUT" is required (if "INPUT" wasn't
-//! // required we could have used an 'if let' to conditionally get the value)
-//! println!("Using input file: {}", matches.value_of("INPUT").unwrap());
-//!
-//! // Vary the output based on how many times the user used the "verbose" flag
-//! // (i.e. 'myprog -v -v -v' or 'myprog -vvv' vs 'myprog -v'
-//! match matches.occurrences_of("v") {
-//! 0 => println!("No verbose info"),
-//! 1 => println!("Some verbose info"),
-//! 2 => println!("Tons of verbose info"),
-//! 3 | _ => println!("Don't be crazy"),
-//! }
-//!
-//! // You can handle information about subcommands by requesting their matches by name
-//! // (as below), requesting just the name used, or both at the same time
-//! if let Some(matches) = matches.subcommand_matches("test") {
-//! if matches.is_present("debug") {
-//! println!("Printing debug info...");
-//! } else {
-//! println!("Printing normally...");
-//! }
-//! }
-//!
-//! // more program logic goes here...
-//! }
-//! ```
-//!
-//! The next example shows a far less verbose method, but sacrifices some of the advanced
-//! configuration options (not shown in this small example). This method also takes a *very* minor
-//! runtime penalty.
-//!
-//! ```no_run
-//! // (Full example with detailed comments in examples/01a_quick_example.rs)
-//! //
-//! // This example demonstrates clap's "usage strings" method of creating arguments
-//! // which is less verbose
-//! extern crate clap;
-//! use clap::{Arg, App, SubCommand};
-//!
-//! fn main() {
-//! let matches = App::new("myapp")
-//! .version("1.0")
-//! .author("Kevin K. <kbknapp@gmail.com>")
-//! .about("Does awesome things")
-//! .args_from_usage(
-//! "-c, --config=[FILE] 'Sets a custom config file'
-//! <INPUT> 'Sets the input file to use'
-//! -v... 'Sets the level of verbosity'")
-//! .subcommand(SubCommand::with_name("test")
-//! .about("controls testing features")
-//! .version("1.3")
-//! .author("Someone E. <someone_else@other.com>")
-//! .arg_from_usage("-d, --debug 'Print debug information'"))
-//! .get_matches();
-//!
-//! // Same as previous example...
-//! }
-//! ```
-//!
-//! This third method shows how you can use a YAML file to build your CLI and keep your Rust source
-//! tidy or support multiple localized translations by having different YAML files for each
-//! localization.
-//!
-//! First, create the `cli.yml` file to hold your CLI options, but it could be called anything we
-//! like:
-//!
-//! ```yaml
-//! name: myapp
-//! version: "1.0"
-//! author: Kevin K. <kbknapp@gmail.com>
-//! about: Does awesome things
-//! args:
-//! - config:
-//! short: c
-//! long: config
-//! value_name: FILE
-//! help: Sets a custom config file
-//! takes_value: true
-//! - INPUT:
-//! help: Sets the input file to use
-//! required: true
-//! index: 1
-//! - verbose:
-//! short: v
-//! multiple: true
-//! help: Sets the level of verbosity
-//! subcommands:
-//! - test:
-//! about: controls testing features
-//! version: "1.3"
-//! author: Someone E. <someone_else@other.com>
-//! args:
-//! - debug:
-//! short: d
-//! help: print debug information
-//! ```
-//!
-//! Since this feature requires additional dependencies that not everyone may want, it is *not*
-//! compiled in by default and we need to enable a feature flag in Cargo.toml:
-//!
-//! Simply change your `clap = "~2.27.0"` to `clap = {version = "~2.27.0", features = ["yaml"]}`.
-//!
-//! At last we create our `main.rs` file just like we would have with the previous two examples:
-//!
-//! ```ignore
-//! // (Full example with detailed comments in examples/17_yaml.rs)
-//! //
-//! // This example demonstrates clap's building from YAML style of creating arguments which is far
-//! // more clean, but takes a very small performance hit compared to the other two methods.
-//! #[macro_use]
-//! extern crate clap;
-//! use clap::App;
-//!
-//! fn main() {
-//! // The YAML file is found relative to the current file, similar to how modules are found
-//! let yaml = load_yaml!("cli.yml");
-//! let matches = App::from_yaml(yaml).get_matches();
-//!
-//! // Same as previous examples...
-//! }
-//! ```
-//!
-//! Finally there is a macro version, which is like a hybrid approach offering the speed of the
-//! builder pattern (the first example), but without all the verbosity.
-//!
-//! ```no_run
-//! #[macro_use]
-//! extern crate clap;
-//!
-//! fn main() {
-//! let matches = clap_app!(myapp =>
-//! (version: "1.0")
-//! (author: "Kevin K. <kbknapp@gmail.com>")
-//! (about: "Does awesome things")
-//! (@arg CONFIG: -c --config +takes_value "Sets a custom config file")
-//! (@arg INPUT: +required "Sets the input file to use")
-//! (@arg debug: -d ... "Sets the level of debugging information")
-//! (@subcommand test =>
-//! (about: "controls testing features")
-//! (version: "1.3")
-//! (author: "Someone E. <someone_else@other.com>")
-//! (@arg verbose: -v --verbose "Print test information verbosely")
-//! )
-//! ).get_matches();
-//!
-//! // Same as before...
-//! }
-//! ```
-//!
-//! If you were to compile any of the above programs and run them with the flag `--help` or `-h` (or
-//! `help` subcommand, since we defined `test` as a subcommand) the following would be output
-//!
-//! ```text
-//! $ myprog --help
-//! My Super Program 1.0
-//! Kevin K. <kbknapp@gmail.com>
-//! Does awesome things
-//!
-//! USAGE:
-//! MyApp [FLAGS] [OPTIONS] <INPUT> [SUBCOMMAND]
-//!
-//! FLAGS:
-//! -h, --help Prints this message
-//! -v Sets the level of verbosity
-//! -V, --version Prints version information
-//!
-//! OPTIONS:
-//! -c, --config <FILE> Sets a custom config file
-//!
-//! ARGS:
-//! INPUT The input file to use
-//!
-//! SUBCOMMANDS:
-//! help Prints this message
-//! test Controls testing features
-//! ```
-//!
-//! **NOTE:** You could also run `myapp test --help` to see similar output and options for the
-//! `test` subcommand.
-//!
-//! ## Try it!
-//!
-//! ### Pre-Built Test
-//!
-//! To try out the pre-built example, use the following steps:
-//!
-//! * Clone the repository `$ git clone https://github.com/clap-rs/clap && cd clap-rs/tests`
-//! * Compile the example `$ cargo build --release`
-//! * Run the help info `$ ./target/release/claptests --help`
-//! * Play with the arguments!
-//!
-//! ### BYOB (Build Your Own Binary)
-//!
-//! To test out `clap`'s default auto-generated help/version follow these steps:
-//!
-//! * Create a new cargo project `$ cargo new fake --bin && cd fake`
-//! * Add `clap` to your `Cargo.toml`
-//!
-//! ```toml
-//! [dependencies]
-//! clap = "2"
-//! ```
-//!
-//! * Add the following to your `src/main.rs`
-//!
-//! ```no_run
-//! extern crate clap;
-//! use clap::App;
-//!
-//! fn main() {
-//! App::new("fake").version("v1.0-beta").get_matches();
-//! }
-//! ```
-//!
-//! * Build your program `$ cargo build --release`
-//! * Run with help or version `$ ./target/release/fake --help` or `$ ./target/release/fake
-//! --version`
-//!
-//! ## Usage
-//!
-//! For full usage, add `clap` as a dependency in your `Cargo.toml` (it is **highly** recommended to
-//! use the `~major.minor.patch` style versions in your `Cargo.toml`, for more information see
-//! [Compatibility Policy](#compatibility-policy)) to use from crates.io:
-//!
-//! ```toml
-//! [dependencies]
-//! clap = "~2.27.0"
-//! ```
-//!
-//! Or get the latest changes from the master branch at github:
-//!
-//! ```toml
-//! [dependencies.clap]
-//! git = "https://github.com/clap-rs/clap.git"
-//! ```
-//!
-//! Add `extern crate clap;` to your crate root.
-//!
-//! Define a list of valid arguments for your program (see the
-//! [documentation](https://docs.rs/clap/) or [examples/] directory of this repo)
-//!
-//! Then run `cargo build` or `cargo update && cargo build` for your project.
-//!
-//! ### Optional Dependencies / Features
-//!
-//! #### Features enabled by default
-//!
-//! * `suggestions`: Turns on the `Did you mean '--myoption'?` feature for when users make typos. (builds dependency `strsim`)
-//! * `color`: Turns on colored error messages. This feature only works on non-Windows OSs. (builds dependency `ansi-term` and `atty`)
-//! * `wrap_help`: Wraps the help at the actual terminal width when
-//! available, instead of 120 characters. (builds dependency `textwrap`
-//! with feature `term_size`)
-//!
-//! To disable these, add this to your `Cargo.toml`:
-//!
-//! ```toml
-//! [dependencies.clap]
-//! version = "~2.27.0"
-//! default-features = false
-//! ```
-//!
-//! You can also selectively enable only the features you'd like to include, by adding:
-//!
-//! ```toml
-//! [dependencies.clap]
-//! version = "~2.27.0"
-//! default-features = false
-//!
-//! # Cherry-pick the features you'd like to use
-//! features = [ "suggestions", "color" ]
-//! ```
-//!
-//! #### Opt-in features
-//!
-//! * **"yaml"**: Enables building CLIs from YAML documents. (builds dependency `yaml-rust`)
-//! * **"unstable"**: Enables unstable `clap` features that may change from release to release
-//!
-//! ### Dependencies Tree
-//!
-//! The following graphic depicts `clap`s dependency graph (generated using
-//! [cargo-graph](https://github.com/kbknapp/cargo-graph)).
-//!
-//! * **Dashed** Line: Optional dependency
-//! * **Red** Color: **NOT** included by default (must use cargo `features` to enable)
-//! * **Blue** Color: Dev dependency, only used while developing.
-//!
-//! ![clap dependencies](https://raw.githubusercontent.com/clap-rs/clap/master/clap_dep_graph.png)
-//!
-//! ### More Information
-//!
-//! You can find complete documentation on the [docs.rs](https://docs.rs/clap/) for this project.
-//!
-//! You can also find usage examples in the [examples/] directory of this repo.
-//!
-//! #### Video Tutorials
-//!
-//! There's also the video tutorial series [Argument Parsing with Rust v2][video tutorials].
-//!
-//! These videos slowly trickle out as I finish them and currently a work in progress.
-//!
-//! ## How to Contribute
-//!
-//! Contributions are always welcome! And there is a multitude of ways in which you can help
-//! depending on what you like to do, or are good at. Anything from documentation, code cleanup,
-//! issue completion, new features, you name it, even filing issues is contributing and greatly
-//! appreciated!
-//!
-//! Another really great way to help is if you find an interesting, or helpful way in which to use
-//! `clap`. You can either add it to the [examples/] directory, or file an issue and tell
-//! me. I'm all about giving credit where credit is due :)
-//!
-//! Please read [CONTRIBUTING.md](https://raw.githubusercontent.com/clap-rs/clap/master/.github/CONTRIBUTING.md) before you start contributing.
-//!
-//!
-//! ### Testing Code
-//!
-//! To test with all features both enabled and disabled, you can run theese commands:
-//!
-//! ```text
-//! $ cargo test --no-default-features
-//! $ cargo test --features "yaml unstable"
-//! ```
-//!
-//! Alternatively, if you have [`just`](https://github.com/casey/just) installed you can run the
-//! prebuilt recipes. *Not* using `just` is perfectly fine as well, it simply bundles commands
-//! automatically.
-//!
-//! For example, to test the code, as above simply run:
-//!
-//! ```text
-//! $ just run-tests
-//! ```
-//!
-//! From here on, I will list the appropriate `cargo` command as well as the `just` command.
-//!
-//! Sometimes it's helpful to only run a subset of the tests, which can be done via:
-//!
-//! ```text
-//! $ cargo test --test <test_name>
-//!
-//! # Or
-//!
-//! $ just run-test <test_name>
-//! ```
-//!
-//! ### Linting Code
-//!
-//! During the CI process `clap` runs against many different lints using
-//! [`clippy`](https://github.com/Manishearth/rust-clippy). In order to check if these lints pass on
-//! your own computer prior to submitting a PR you'll need a nightly compiler.
-//!
-//! In order to check the code for lints run either:
-//!
-//! ```text
-//! $ rustup override add nightly
-//! $ cargo build --features lints
-//! $ rustup override remove
-//!
-//! # Or
-//!
-//! $ just lint
-//! ```
-//!
-//! ### Debugging Code
-//!
-//! Another helpful technique is to see the `clap` debug output while developing features. In order
-//! to see the debug output while running the full test suite or individual tests, run:
-//!
-//! ```text
-//! $ cargo test --features debug
-//!
-//! # Or for individual tests
-//! $ cargo test --test <test_name> --features debug
-//!
-//! # The corresponding just command for individual debugging tests is:
-//! $ just debug <test_name>
-//! ```
-//!
-//! ### Goals
-//!
-//! There are a few goals of `clap` that I'd like to maintain throughout contributions. If your
-//! proposed changes break, or go against any of these goals we'll discuss the changes further
-//! before merging (but will *not* be ignored, all contributes are welcome!). These are by no means
-//! hard-and-fast rules, as I'm no expert and break them myself from time to time (even if by
-//! mistake or ignorance).
-//!
-//! * Remain backwards compatible when possible
-//! - If backwards compatibility *must* be broken, use deprecation warnings if at all possible before
-//! removing legacy code - This does not apply for security concerns
-//! * Parse arguments quickly
-//! - Parsing of arguments shouldn't slow down usage of the main program - This is also true of
-//! generating help and usage information (although *slightly* less stringent, as the program is about
-//! to exit)
-//! * Try to be cognizant of memory usage
-//! - Once parsing is complete, the memory footprint of `clap` should be low since the main program
-//! is the star of the show
-//! * `panic!` on *developer* error, exit gracefully on *end-user* error
-//!
-//! ### Compatibility Policy
-//!
-//! Because `clap` takes `SemVer` and compatibility seriously, this is the official policy regarding
-//! breaking changes and previous versions of Rust.
-//!
-//! `clap` will pin the minimum required version of Rust to the CI builds. Bumping the minimum
-//! version of Rust is considered a minor breaking change, meaning *at a minimum* the minor version
-//! of `clap` will be bumped.
-//!
-//! In order to keep from being surprised by breaking changes, it is **highly** recommended to use
-//! the `~major.minor.patch` style in your `Cargo.toml`:
-//!
-//! ```toml
-//! [dependencies] clap = "~2.27.0"
-//! ```
-//!
-//! This will cause *only* the patch version to be updated upon a `cargo update` call, and therefore
-//! cannot break due to new features, or bumped minimum versions of Rust.
-//!
-//! #### Minimum Version of Rust
-//!
-//! `clap` will officially support current stable Rust, minus two releases, but may work with prior
-//! releases as well. For example, current stable Rust at the time of this writing is 1.21.0,
-//! meaning `clap` is guaranteed to compile with 1.19.0 and beyond. At the 1.22.0 release, `clap`
-//! will be guaranteed to compile with 1.20.0 and beyond, etc.
-//!
-//! Upon bumping the minimum version of Rust (assuming it's within the stable-2 range), it *must* be
-//! clearly annotated in the `CHANGELOG.md`
-//!
-//! ## License
-//!
-//! `clap` is licensed under the MIT license. Please read the [LICENSE-MIT][license] file in
-//! this repository for more information.
-//!
-//! [examples/]: https://github.com/clap-rs/clap/tree/master/examples
-//! [video tutorials]: https://www.youtube.com/playlist?list=PLza5oFLQGTl2Z5T8g1pRkIynR3E0_pc7U
-//! [license]: https://raw.githubusercontent.com/clap-rs/clap/master/LICENSE-MIT
-
-#![crate_type = "lib"]
-#![doc(html_root_url = "https://docs.rs/clap/2.33.0")]
-#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts,
- unused_import_braces, unused_allocation)]
-// Lints we'd like to deny but are currently failing for upstream crates
-// unused_qualifications (bitflags, clippy)
-// trivial_numeric_casts (bitflags)
-#![cfg_attr(not(any(feature = "lints", feature = "nightly")), forbid(unstable_features))]
-#![cfg_attr(feature = "lints", feature(plugin))]
-#![cfg_attr(feature = "lints", plugin(clippy))]
-// Need to disable deny(warnings) while deprecations are active
-// #![cfg_attr(feature = "lints", deny(warnings))]
-#![cfg_attr(feature = "lints", allow(cyclomatic_complexity))]
-#![cfg_attr(feature = "lints", allow(doc_markdown))]
-#![cfg_attr(feature = "lints", allow(explicit_iter_loop))]
-
-#[cfg(all(feature = "color", not(target_os = "windows")))]
-extern crate ansi_term;
-#[cfg(feature = "color")]
-extern crate atty;
-#[macro_use]
-extern crate bitflags;
-#[cfg(feature = "suggestions")]
-extern crate strsim;
-#[cfg(feature = "wrap_help")]
-extern crate term_size;
-extern crate textwrap;
-extern crate unicode_width;
-#[cfg(feature = "vec_map")]
-extern crate vec_map;
-#[cfg(feature = "yaml")]
-extern crate yaml_rust;
-
-#[cfg(feature = "yaml")]
-pub use yaml_rust::YamlLoader;
-pub use args::{Arg, ArgGroup, ArgMatches, ArgSettings, OsValues, SubCommand, Values};
-pub use app::{App, AppSettings};
-pub use fmt::Format;
-pub use errors::{Error, ErrorKind, Result};
-pub use completions::Shell;
-
-#[macro_use]
-mod macros;
-mod app;
-mod args;
-mod usage_parser;
-mod fmt;
-mod suggestions;
-mod errors;
-mod osstringext;
-mod strext;
-mod completions;
-mod map;
-
-const INTERNAL_ERROR_MSG: &'static str = "Fatal internal error. Please consider filing a bug \
- report at https://github.com/clap-rs/clap/issues";
-const INVALID_UTF8: &'static str = "unexpected invalid UTF-8 code point";
-
-#[cfg(unstable)]
-pub use derive::{ArgEnum, ClapApp, FromArgMatches, IntoApp};
-
-#[cfg(unstable)]
-mod derive {
- /// @TODO @release @docs
- pub trait ClapApp: IntoApp + FromArgMatches + Sized {
- /// @TODO @release @docs
- fn parse() -> Self { Self::from_argmatches(Self::into_app().get_matches()) }
-
- /// @TODO @release @docs
- fn parse_from<I, T>(argv: I) -> Self
- where
- I: IntoIterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- Self::from_argmatches(Self::into_app().get_matches_from(argv))
- }
-
- /// @TODO @release @docs
- fn try_parse() -> Result<Self, clap::Error> {
- Self::try_from_argmatches(Self::into_app().get_matches_safe()?)
- }
-
-
- /// @TODO @release @docs
- fn try_parse_from<I, T>(argv: I) -> Result<Self, clap::Error>
- where
- I: IntoIterator<Item = T>,
- T: Into<OsString> + Clone,
- {
- Self::try_from_argmatches(Self::into_app().get_matches_from_safe(argv)?)
- }
- }
-
- /// @TODO @release @docs
- pub trait IntoApp {
- /// @TODO @release @docs
- fn into_app<'a, 'b>() -> clap::App<'a, 'b>;
- }
-
- /// @TODO @release @docs
- pub trait FromArgMatches: Sized {
- /// @TODO @release @docs
- fn from_argmatches<'a>(matches: clap::ArgMatches<'a>) -> Self;
-
- /// @TODO @release @docs
- fn try_from_argmatches<'a>(matches: clap::ArgMatches<'a>) -> Result<Self, clap::Error>;
- }
-
- /// @TODO @release @docs
- pub trait ArgEnum {}
-}
diff --git a/clap/src/macros.rs b/clap/src/macros.rs
deleted file mode 100644
index 8198e19..0000000
--- a/clap/src/macros.rs
+++ /dev/null
@@ -1,1108 +0,0 @@
-/// A convenience macro for loading the YAML file at compile time (relative to the current file,
-/// like modules work). That YAML object can then be passed to this function.
-///
-/// # Panics
-///
-/// The YAML file must be properly formatted or this function will panic!(). A good way to
-/// ensure this doesn't happen is to run your program with the `--help` switch. If this passes
-/// without error, you needn't worry because the YAML is properly formatted.
-///
-/// # Examples
-///
-/// The following example shows how to load a properly formatted YAML file to build an instance
-/// of an `App` struct.
-///
-/// ```ignore
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let yml = load_yaml!("app.yml");
-/// let app = App::from_yaml(yml);
-///
-/// // continued logic goes here, such as `app.get_matches()` etc.
-/// # }
-/// ```
-#[cfg(feature = "yaml")]
-#[macro_export]
-macro_rules! load_yaml {
- ($yml:expr) => (
- &::clap::YamlLoader::load_from_str(include_str!($yml)).expect("failed to load YAML file")[0]
- );
-}
-
-/// Convenience macro getting a typed value `T` where `T` implements [`std::str::FromStr`] from an
-/// argument value. This macro returns a `Result<T,String>` which allows you as the developer to
-/// decide what you'd like to do on a failed parse. There are two types of errors, parse failures
-/// and those where the argument wasn't present (such as a non-required argument). You can use
-/// it to get a single value, or a iterator as with the [`ArgMatches::values_of`]
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let matches = App::new("myapp")
-/// .arg_from_usage("[length] 'Set the length to use as a pos whole num, i.e. 20'")
-/// .get_matches();
-///
-/// let len = value_t!(matches.value_of("length"), u32).unwrap_or_else(|e| e.exit());
-/// let also_len = value_t!(matches, "length", u32).unwrap_or_else(|e| e.exit());
-///
-/// println!("{} + 2: {}", len, len + 2);
-/// # }
-/// ```
-/// [`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
-/// [`ArgMatches::values_of`]: ./struct.ArgMatches.html#method.values_of
-/// [`Result<T,String>`]: https://doc.rust-lang.org/std/result/enum.Result.html
-#[macro_export]
-macro_rules! value_t {
- ($m:ident, $v:expr, $t:ty) => {
- value_t!($m.value_of($v), $t)
- };
- ($m:ident.value_of($v:expr), $t:ty) => {
- if let Some(v) = $m.value_of($v) {
- match v.parse::<$t>() {
- Ok(val) => Ok(val),
- Err(_) =>
- Err(::clap::Error::value_validation_auto(
- format!("The argument '{}' isn't a valid value", v))),
- }
- } else {
- Err(::clap::Error::argument_not_found_auto($v))
- }
- };
-}
-
-/// Convenience macro getting a typed value `T` where `T` implements [`std::str::FromStr`] or
-/// exiting upon error, instead of returning a [`Result`] type.
-///
-/// **NOTE:** This macro is for backwards compatibility sake. Prefer
-/// [`value_t!(/* ... */).unwrap_or_else(|e| e.exit())`]
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let matches = App::new("myapp")
-/// .arg_from_usage("[length] 'Set the length to use as a pos whole num, i.e. 20'")
-/// .get_matches();
-///
-/// let len = value_t_or_exit!(matches.value_of("length"), u32);
-/// let also_len = value_t_or_exit!(matches, "length", u32);
-///
-/// println!("{} + 2: {}", len, len + 2);
-/// # }
-/// ```
-/// [`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
-/// [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
-/// [`value_t!(/* ... */).unwrap_or_else(|e| e.exit())`]: ./macro.value_t!.html
-#[macro_export]
-macro_rules! value_t_or_exit {
- ($m:ident, $v:expr, $t:ty) => {
- value_t_or_exit!($m.value_of($v), $t)
- };
- ($m:ident.value_of($v:expr), $t:ty) => {
- if let Some(v) = $m.value_of($v) {
- match v.parse::<$t>() {
- Ok(val) => val,
- Err(_) =>
- ::clap::Error::value_validation_auto(
- format!("The argument '{}' isn't a valid value", v)).exit(),
- }
- } else {
- ::clap::Error::argument_not_found_auto($v).exit()
- }
- };
-}
-
-/// Convenience macro getting a typed value [`Vec<T>`] where `T` implements [`std::str::FromStr`]
-/// This macro returns a [`clap::Result<Vec<T>>`] which allows you as the developer to decide
-/// what you'd like to do on a failed parse.
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let matches = App::new("myapp")
-/// .arg_from_usage("[seq]... 'A sequence of pos whole nums, i.e. 20 45'")
-/// .get_matches();
-///
-/// let vals = values_t!(matches.values_of("seq"), u32).unwrap_or_else(|e| e.exit());
-/// for v in &vals {
-/// println!("{} + 2: {}", v, v + 2);
-/// }
-///
-/// let vals = values_t!(matches, "seq", u32).unwrap_or_else(|e| e.exit());
-/// for v in &vals {
-/// println!("{} + 2: {}", v, v + 2);
-/// }
-/// # }
-/// ```
-/// [`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
-/// [`Vec<T>`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
-/// [`clap::Result<Vec<T>>`]: ./type.Result.html
-#[macro_export]
-macro_rules! values_t {
- ($m:ident, $v:expr, $t:ty) => {
- values_t!($m.values_of($v), $t)
- };
- ($m:ident.values_of($v:expr), $t:ty) => {
- if let Some(vals) = $m.values_of($v) {
- let mut tmp = vec![];
- let mut err = None;
- for pv in vals {
- match pv.parse::<$t>() {
- Ok(rv) => tmp.push(rv),
- Err(..) => {
- err = Some(::clap::Error::value_validation_auto(
- format!("The argument '{}' isn't a valid value", pv)));
- break
- }
- }
- }
- match err {
- Some(e) => Err(e),
- None => Ok(tmp),
- }
- } else {
- Err(::clap::Error::argument_not_found_auto($v))
- }
- };
-}
-
-/// Convenience macro getting a typed value [`Vec<T>`] where `T` implements [`std::str::FromStr`]
-/// or exiting upon error.
-///
-/// **NOTE:** This macro is for backwards compatibility sake. Prefer
-/// [`values_t!(/* ... */).unwrap_or_else(|e| e.exit())`]
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let matches = App::new("myapp")
-/// .arg_from_usage("[seq]... 'A sequence of pos whole nums, i.e. 20 45'")
-/// .get_matches();
-///
-/// let vals = values_t_or_exit!(matches.values_of("seq"), u32);
-/// for v in &vals {
-/// println!("{} + 2: {}", v, v + 2);
-/// }
-///
-/// // type for example only
-/// let vals: Vec<u32> = values_t_or_exit!(matches, "seq", u32);
-/// for v in &vals {
-/// println!("{} + 2: {}", v, v + 2);
-/// }
-/// # }
-/// ```
-/// [`values_t!(/* ... */).unwrap_or_else(|e| e.exit())`]: ./macro.values_t!.html
-/// [`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
-/// [`Vec<T>`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
-#[macro_export]
-macro_rules! values_t_or_exit {
- ($m:ident, $v:expr, $t:ty) => {
- values_t_or_exit!($m.values_of($v), $t)
- };
- ($m:ident.values_of($v:expr), $t:ty) => {
- if let Some(vals) = $m.values_of($v) {
- vals.map(|v| v.parse::<$t>().unwrap_or_else(|_|{
- ::clap::Error::value_validation_auto(
- format!("One or more arguments aren't valid values")).exit()
- })).collect::<Vec<$t>>()
- } else {
- ::clap::Error::argument_not_found_auto($v).exit()
- }
- };
-}
-
-// _clap_count_exprs! is derived from https://github.com/DanielKeep/rust-grabbag
-// commit: 82a35ca5d9a04c3b920622d542104e3310ee5b07
-// License: MIT
-// Copyright ⓒ 2015 grabbag contributors.
-// Licensed under the MIT license (see LICENSE or <http://opensource.org
-// /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
-// <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
-// files in the project carrying such notice may not be copied, modified,
-// or distributed except according to those terms.
-//
-/// Counts the number of comma-delimited expressions passed to it. The result is a compile-time
-/// evaluable expression, suitable for use as a static array size, or the value of a `const`.
-///
-/// # Examples
-///
-/// ```
-/// # #[macro_use] extern crate clap;
-/// # fn main() {
-/// const COUNT: usize = _clap_count_exprs!(a, 5+1, "hi there!".into_string());
-/// assert_eq!(COUNT, 3);
-/// # }
-/// ```
-#[macro_export]
-macro_rules! _clap_count_exprs {
- () => { 0 };
- ($e:expr) => { 1 };
- ($e:expr, $($es:expr),+) => { 1 + $crate::_clap_count_exprs!($($es),*) };
-}
-
-/// Convenience macro to generate more complete enums with variants to be used as a type when
-/// parsing arguments. This enum also provides a `variants()` function which can be used to
-/// retrieve a `Vec<&'static str>` of the variant names, as well as implementing [`FromStr`] and
-/// [`Display`] automatically.
-///
-/// **NOTE:** Case insensitivity is supported for ASCII characters only. It's highly recommended to
-/// use [`Arg::case_insensitive(true)`] for args that will be used with these enums
-///
-/// **NOTE:** This macro automatically implements [`std::str::FromStr`] and [`std::fmt::Display`]
-///
-/// **NOTE:** These enums support pub (or not) and uses of the `#[derive()]` traits
-///
-/// # Examples
-///
-/// ```rust
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::{App, Arg};
-/// arg_enum!{
-/// #[derive(PartialEq, Debug)]
-/// pub enum Foo {
-/// Bar,
-/// Baz,
-/// Qux
-/// }
-/// }
-/// // Foo enum can now be used via Foo::Bar, or Foo::Baz, etc
-/// // and implements std::str::FromStr to use with the value_t! macros
-/// fn main() {
-/// let m = App::new("app")
-/// .arg(Arg::from_usage("<foo> 'the foo'")
-/// .possible_values(&Foo::variants())
-/// .case_insensitive(true))
-/// .get_matches_from(vec![
-/// "app", "baz"
-/// ]);
-/// let f = value_t!(m, "foo", Foo).unwrap_or_else(|e| e.exit());
-///
-/// assert_eq!(f, Foo::Baz);
-/// }
-/// ```
-/// [`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
-/// [`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
-/// [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
-/// [`std::fmt::Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
-/// [`Arg::case_insensitive(true)`]: ./struct.Arg.html#method.case_insensitive
-#[macro_export]
-macro_rules! arg_enum {
- (@as_item $($i:item)*) => ($($i)*);
- (@impls ( $($tts:tt)* ) -> ($e:ident, $($v:ident),+)) => {
- arg_enum!(@as_item
- $($tts)*
-
- impl ::std::str::FromStr for $e {
- type Err = String;
-
- fn from_str(s: &str) -> ::std::result::Result<Self,Self::Err> {
- #[allow(deprecated, unused_imports)]
- use ::std::ascii::AsciiExt;
- match s {
- $(stringify!($v) |
- _ if s.eq_ignore_ascii_case(stringify!($v)) => Ok($e::$v)),+,
- _ => Err({
- let v = vec![
- $(stringify!($v),)+
- ];
- format!("valid values: {}",
- v.join(", "))
- }),
- }
- }
- }
- impl ::std::fmt::Display for $e {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- match *self {
- $($e::$v => write!(f, stringify!($v)),)+
- }
- }
- }
- impl $e {
- #[allow(dead_code)]
- pub fn variants() -> [&'static str; $crate::_clap_count_exprs!($(stringify!($v)),+)] {
- [
- $(stringify!($v),)+
- ]
- }
- });
- };
- ($(#[$($m:meta),+])+ pub enum $e:ident { $($v:ident $(=$val:expr)*,)+ } ) => {
- arg_enum!(@impls
- ($(#[$($m),+])+
- pub enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- ($(#[$($m:meta),+])+ pub enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
- arg_enum!(@impls
- ($(#[$($m),+])+
- pub enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- ($(#[$($m:meta),+])+ enum $e:ident { $($v:ident $(=$val:expr)*,)+ } ) => {
- arg_enum!(@impls
- ($(#[$($m),+])+
- enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- ($(#[$($m:meta),+])+ enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
- arg_enum!(@impls
- ($(#[$($m),+])+
- enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- (pub enum $e:ident { $($v:ident $(=$val:expr)*,)+ } ) => {
- arg_enum!(@impls
- (pub enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- (pub enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
- arg_enum!(@impls
- (pub enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- (enum $e:ident { $($v:ident $(=$val:expr)*,)+ } ) => {
- arg_enum!(@impls
- (enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
- (enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
- arg_enum!(@impls
- (enum $e {
- $($v$(=$val)*),+
- }) -> ($e, $($v),+)
- );
- };
-}
-
-/// Allows you to pull the version from your Cargo.toml at compile time as
-/// `MAJOR.MINOR.PATCH_PKGVERSION_PRE`
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let m = App::new("app")
-/// .version(crate_version!())
-/// .get_matches();
-/// # }
-/// ```
-#[cfg(not(feature = "no_cargo"))]
-#[macro_export]
-macro_rules! crate_version {
- () => {
- env!("CARGO_PKG_VERSION")
- };
-}
-
-/// Allows you to pull the authors for the app from your Cargo.toml at
-/// compile time in the form:
-/// `"author1 lastname <author1@example.com>:author2 lastname <author2@example.com>"`
-///
-/// You can replace the colons with a custom separator by supplying a
-/// replacement string, so, for example,
-/// `crate_authors!(",\n")` would become
-/// `"author1 lastname <author1@example.com>,\nauthor2 lastname <author2@example.com>,\nauthor3 lastname <author3@example.com>"`
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let m = App::new("app")
-/// .author(crate_authors!("\n"))
-/// .get_matches();
-/// # }
-/// ```
-#[cfg(not(feature = "no_cargo"))]
-#[macro_export]
-macro_rules! crate_authors {
- ($sep:expr) => {{
- use std::ops::Deref;
- use std::sync::{ONCE_INIT, Once};
-
- #[allow(missing_copy_implementations)]
- #[allow(dead_code)]
- struct CargoAuthors { __private_field: () };
-
- impl Deref for CargoAuthors {
- type Target = str;
-
- #[allow(unsafe_code)]
- fn deref(&self) -> &'static str {
- static ONCE: Once = ONCE_INIT;
- static mut VALUE: *const String = 0 as *const String;
-
- unsafe {
- ONCE.call_once(|| {
- let s = env!("CARGO_PKG_AUTHORS").replace(':', $sep);
- VALUE = Box::into_raw(Box::new(s));
- });
-
- &(*VALUE)[..]
- }
- }
- }
-
- &*CargoAuthors { __private_field: () }
- }};
- () => {
- env!("CARGO_PKG_AUTHORS")
- };
-}
-
-/// Allows you to pull the description from your Cargo.toml at compile time.
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let m = App::new("app")
-/// .about(crate_description!())
-/// .get_matches();
-/// # }
-/// ```
-#[cfg(not(feature = "no_cargo"))]
-#[macro_export]
-macro_rules! crate_description {
- () => {
- env!("CARGO_PKG_DESCRIPTION")
- };
-}
-
-/// Allows you to pull the name from your Cargo.toml at compile time.
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # use clap::App;
-/// # fn main() {
-/// let m = App::new(crate_name!())
-/// .get_matches();
-/// # }
-/// ```
-#[cfg(not(feature = "no_cargo"))]
-#[macro_export]
-macro_rules! crate_name {
- () => {
- env!("CARGO_PKG_NAME")
- };
-}
-
-/// Allows you to build the `App` instance from your Cargo.toml at compile time.
-///
-/// Equivalent to using the `crate_*!` macros with their respective fields.
-///
-/// Provided separator is for the [`crate_authors!`](macro.crate_authors.html) macro,
-/// refer to the documentation therefor.
-///
-/// **NOTE:** Changing the values in your `Cargo.toml` does not trigger a re-build automatically,
-/// and therefore won't change the generated output until you recompile.
-///
-/// **Pro Tip:** In some cases you can "trick" the compiler into triggering a rebuild when your
-/// `Cargo.toml` is changed by including this in your `src/main.rs` file
-/// `include_str!("../Cargo.toml");`
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # fn main() {
-/// let m = app_from_crate!().get_matches();
-/// # }
-/// ```
-#[cfg(not(feature = "no_cargo"))]
-#[macro_export]
-macro_rules! app_from_crate {
- () => {
- $crate::App::new(crate_name!())
- .version(crate_version!())
- .author(crate_authors!())
- .about(crate_description!())
- };
- ($sep:expr) => {
- $crate::App::new(crate_name!())
- .version(crate_version!())
- .author(crate_authors!($sep))
- .about(crate_description!())
- };
-}
-
-/// Build `App`, `Arg`s, `SubCommand`s and `Group`s with Usage-string like input
-/// but without the associated parsing runtime cost.
-///
-/// `clap_app!` also supports several shorthand syntaxes.
-///
-/// # Examples
-///
-/// ```no_run
-/// # #[macro_use]
-/// # extern crate clap;
-/// # fn main() {
-/// let matches = clap_app!(myapp =>
-/// (version: "1.0")
-/// (author: "Kevin K. <kbknapp@gmail.com>")
-/// (about: "Does awesome things")
-/// (@arg CONFIG: -c --config +takes_value "Sets a custom config file")
-/// (@arg INPUT: +required "Sets the input file to use")
-/// (@arg debug: -d ... "Sets the level of debugging information")
-/// (@group difficulty =>
-/// (@arg hard: -h --hard "Sets hard mode")
-/// (@arg normal: -n --normal "Sets normal mode")
-/// (@arg easy: -e --easy "Sets easy mode")
-/// )
-/// (@subcommand test =>
-/// (about: "controls testing features")
-/// (version: "1.3")
-/// (author: "Someone E. <someone_else@other.com>")
-/// (@arg verbose: -v --verbose "Print test information verbosely")
-/// )
-/// )
-/// .get_matches();
-/// # }
-/// ```
-/// # Shorthand Syntax for Args
-///
-/// * A single hyphen followed by a character (such as `-c`) sets the [`Arg::short`]
-/// * A double hyphen followed by a character or word (such as `--config`) sets [`Arg::long`]
-/// * If one wishes to use a [`Arg::long`] with a hyphen inside (i.e. `--config-file`), you
-/// must use `--("config-file")` due to limitations of the Rust macro system.
-/// * Three dots (`...`) sets [`Arg::multiple(true)`]
-/// * Angled brackets after either a short or long will set [`Arg::value_name`] and
-/// `Arg::required(true)` such as `--config <FILE>` = `Arg::value_name("FILE")` and
-/// `Arg::required(true)`
-/// * Square brackets after either a short or long will set [`Arg::value_name`] and
-/// `Arg::required(false)` such as `--config [FILE]` = `Arg::value_name("FILE")` and
-/// `Arg::required(false)`
-/// * There are short hand syntaxes for Arg methods that accept booleans
-/// * A plus sign will set that method to `true` such as `+required` = `Arg::required(true)`
-/// * An exclamation will set that method to `false` such as `!required` = `Arg::required(false)`
-/// * A `#{min, max}` will set [`Arg::min_values(min)`] and [`Arg::max_values(max)`]
-/// * An asterisk (`*`) will set `Arg::required(true)`
-/// * Curly brackets around a `fn` will set [`Arg::validator`] as in `{fn}` = `Arg::validator(fn)`
-/// * An Arg method that accepts a string followed by square brackets will set that method such as
-/// `conflicts_with[FOO]` will set `Arg::conflicts_with("FOO")` (note the lack of quotes around
-/// `FOO` in the macro)
-/// * An Arg method that takes a string and can be set multiple times (such as
-/// [`Arg::conflicts_with`]) followed by square brackets and a list of values separated by spaces
-/// will set that method such as `conflicts_with[FOO BAR BAZ]` will set
-/// `Arg::conflicts_with("FOO")`, `Arg::conflicts_with("BAR")`, and `Arg::conflicts_with("BAZ")`
-/// (note the lack of quotes around the values in the macro)
-///
-/// # Shorthand Syntax for Groups
-///
-/// * There are short hand syntaxes for `ArgGroup` methods that accept booleans
-/// * A plus sign will set that method to `true` such as `+required` = `ArgGroup::required(true)`
-/// * An exclamation will set that method to `false` such as `!required` = `ArgGroup::required(false)`
-///
-/// [`Arg::short`]: ./struct.Arg.html#method.short
-/// [`Arg::long`]: ./struct.Arg.html#method.long
-/// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
-/// [`Arg::value_name`]: ./struct.Arg.html#method.value_name
-/// [`Arg::min_values(min)`]: ./struct.Arg.html#method.min_values
-/// [`Arg::max_values(max)`]: ./struct.Arg.html#method.max_values
-/// [`Arg::validator`]: ./struct.Arg.html#method.validator
-/// [`Arg::conflicts_with`]: ./struct.Arg.html#method.conflicts_with
-#[macro_export]
-macro_rules! clap_app {
- (@app ($builder:expr)) => { $builder };
- (@app ($builder:expr) (@arg ($name:expr): $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @app
- ($builder.arg(
- clap_app!{ @arg ($crate::Arg::with_name($name)) (-) $($tail)* }))
- $($tt)*
- }
- };
- (@app ($builder:expr) (@arg $name:ident: $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @app
- ($builder.arg(
- clap_app!{ @arg ($crate::Arg::with_name(stringify!($name))) (-) $($tail)* }))
- $($tt)*
- }
- };
- (@app ($builder:expr) (@setting $setting:ident) $($tt:tt)*) => {
- clap_app!{ @app
- ($builder.setting($crate::AppSettings::$setting))
- $($tt)*
- }
- };
-// Treat the application builder as an argument to set its attributes
- (@app ($builder:expr) (@attributes $($attr:tt)*) $($tt:tt)*) => {
- clap_app!{ @app (clap_app!{ @arg ($builder) $($attr)* }) $($tt)* }
- };
- (@app ($builder:expr) (@group $name:ident => $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @app
- (clap_app!{ @group ($builder, $crate::ArgGroup::with_name(stringify!($name))) $($tail)* })
- $($tt)*
- }
- };
- (@app ($builder:expr) (@group $name:ident !$ident:ident => $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @app
- (clap_app!{ @group ($builder, $crate::ArgGroup::with_name(stringify!($name)).$ident(false)) $($tail)* })
- $($tt)*
- }
- };
- (@app ($builder:expr) (@group $name:ident +$ident:ident => $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @app
- (clap_app!{ @group ($builder, $crate::ArgGroup::with_name(stringify!($name)).$ident(true)) $($tail)* })
- $($tt)*
- }
- };
-// Handle subcommand creation
- (@app ($builder:expr) (@subcommand $name:ident => $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @app
- ($builder.subcommand(
- clap_app!{ @app ($crate::SubCommand::with_name(stringify!($name))) $($tail)* }
- ))
- $($tt)*
- }
- };
-// Yaml like function calls - used for setting various meta directly against the app
- (@app ($builder:expr) ($ident:ident: $($v:expr),*) $($tt:tt)*) => {
-// clap_app!{ @app ($builder.$ident($($v),*)) $($tt)* }
- clap_app!{ @app
- ($builder.$ident($($v),*))
- $($tt)*
- }
- };
-
-// Add members to group and continue argument handling with the parent builder
- (@group ($builder:expr, $group:expr)) => { $builder.group($group) };
- // Treat the group builder as an argument to set its attributes
- (@group ($builder:expr, $group:expr) (@attributes $($attr:tt)*) $($tt:tt)*) => {
- clap_app!{ @group ($builder, clap_app!{ @arg ($group) (-) $($attr)* }) $($tt)* }
- };
- (@group ($builder:expr, $group:expr) (@arg $name:ident: $($tail:tt)*) $($tt:tt)*) => {
- clap_app!{ @group
- (clap_app!{ @app ($builder) (@arg $name: $($tail)*) },
- $group.arg(stringify!($name)))
- $($tt)*
- }
- };
-
-// No more tokens to munch
- (@arg ($arg:expr) $modes:tt) => { $arg };
-// Shorthand tokens influenced by the usage_string
- (@arg ($arg:expr) $modes:tt --($long:expr) $($tail:tt)*) => {
- clap_app!{ @arg ($arg.long($long)) $modes $($tail)* }
- };
- (@arg ($arg:expr) $modes:tt --$long:ident $($tail:tt)*) => {
- clap_app!{ @arg ($arg.long(stringify!($long))) $modes $($tail)* }
- };
- (@arg ($arg:expr) $modes:tt -$short:ident $($tail:tt)*) => {
- clap_app!{ @arg ($arg.short(stringify!($short))) $modes $($tail)* }
- };
- (@arg ($arg:expr) (-) <$var:ident> $($tail:tt)*) => {
- clap_app!{ @arg ($arg.value_name(stringify!($var))) (+) +takes_value +required $($tail)* }
- };
- (@arg ($arg:expr) (+) <$var:ident> $($tail:tt)*) => {
- clap_app!{ @arg ($arg.value_name(stringify!($var))) (+) $($tail)* }
- };
- (@arg ($arg:expr) (-) [$var:ident] $($tail:tt)*) => {
- clap_app!{ @arg ($arg.value_name(stringify!($var))) (+) +takes_value $($tail)* }
- };
- (@arg ($arg:expr) (+) [$var:ident] $($tail:tt)*) => {
- clap_app!{ @arg ($arg.value_name(stringify!($var))) (+) $($tail)* }
- };
- (@arg ($arg:expr) $modes:tt ... $($tail:tt)*) => {
- clap_app!{ @arg ($arg) $modes +multiple $($tail)* }
- };
-// Shorthand magic
- (@arg ($arg:expr) $modes:tt #{$n:expr, $m:expr} $($tail:tt)*) => {
- clap_app!{ @arg ($arg) $modes min_values($n) max_values($m) $($tail)* }
- };
- (@arg ($arg:expr) $modes:tt * $($tail:tt)*) => {
- clap_app!{ @arg ($arg) $modes +required $($tail)* }
- };
-// !foo -> .foo(false)
- (@arg ($arg:expr) $modes:tt !$ident:ident $($tail:tt)*) => {
- clap_app!{ @arg ($arg.$ident(false)) $modes $($tail)* }
- };
-// +foo -> .foo(true)
- (@arg ($arg:expr) $modes:tt +$ident:ident $($tail:tt)*) => {
- clap_app!{ @arg ($arg.$ident(true)) $modes $($tail)* }
- };
-// Validator
- (@arg ($arg:expr) $modes:tt {$fn_:expr} $($tail:tt)*) => {
- clap_app!{ @arg ($arg.validator($fn_)) $modes $($tail)* }
- };
- (@as_expr $expr:expr) => { $expr };
-// Help
- (@arg ($arg:expr) $modes:tt $desc:tt) => { $arg.help(clap_app!{ @as_expr $desc }) };
-// Handle functions that need to be called multiple times for each argument
- (@arg ($arg:expr) $modes:tt $ident:ident[$($target:ident)*] $($tail:tt)*) => {
- clap_app!{ @arg ($arg $( .$ident(stringify!($target)) )*) $modes $($tail)* }
- };
-// Inherit builder's functions, e.g. `index(2)`, `requires_if("val", "arg")`
- (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr),*) $($tail:tt)*) => {
- clap_app!{ @arg ($arg.$ident($($expr),*)) $modes $($tail)* }
- };
-// Inherit builder's functions with trailing comma, e.g. `index(2,)`, `requires_if("val", "arg",)`
- (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr,)*) $($tail:tt)*) => {
- clap_app!{ @arg ($arg.$ident($($expr),*)) $modes $($tail)* }
- };
-
-// Build a subcommand outside of an app.
- (@subcommand $name:ident => $($tail:tt)*) => {
- clap_app!{ @app ($crate::SubCommand::with_name(stringify!($name))) $($tail)* }
- };
-// Start the magic
- (($name:expr) => $($tail:tt)*) => {{
- clap_app!{ @app ($crate::App::new($name)) $($tail)*}
- }};
-
- ($name:ident => $($tail:tt)*) => {{
- clap_app!{ @app ($crate::App::new(stringify!($name))) $($tail)*}
- }};
-}
-
-macro_rules! impl_settings {
- ($n:ident, $($v:ident => $c:path),+) => {
- pub fn set(&mut self, s: $n) {
- match s {
- $($n::$v => self.0.insert($c)),+
- }
- }
-
- pub fn unset(&mut self, s: $n) {
- match s {
- $($n::$v => self.0.remove($c)),+
- }
- }
-
- pub fn is_set(&self, s: $n) -> bool {
- match s {
- $($n::$v => self.0.contains($c)),+
- }
- }
- };
-}
-
-// Convenience for writing to stderr thanks to https://github.com/BurntSushi
-macro_rules! wlnerr(
- ($($arg:tt)*) => ({
- use std::io::{Write, stderr};
- writeln!(&mut stderr(), $($arg)*).ok();
- })
-);
-
-#[cfg(feature = "debug")]
-#[cfg_attr(feature = "debug", macro_use)]
-#[cfg_attr(feature = "debug", allow(unused_macros))]
-mod debug_macros {
- macro_rules! debugln {
- ($fmt:expr) => (println!(concat!("DEBUG:clap:", $fmt)));
- ($fmt:expr, $($arg:tt)*) => (println!(concat!("DEBUG:clap:",$fmt), $($arg)*));
- }
- macro_rules! sdebugln {
- ($fmt:expr) => (println!($fmt));
- ($fmt:expr, $($arg:tt)*) => (println!($fmt, $($arg)*));
- }
- macro_rules! debug {
- ($fmt:expr) => (print!(concat!("DEBUG:clap:", $fmt)));
- ($fmt:expr, $($arg:tt)*) => (print!(concat!("DEBUG:clap:",$fmt), $($arg)*));
- }
- macro_rules! sdebug {
- ($fmt:expr) => (print!($fmt));
- ($fmt:expr, $($arg:tt)*) => (print!($fmt, $($arg)*));
- }
-}
-
-#[cfg(not(feature = "debug"))]
-#[cfg_attr(not(feature = "debug"), macro_use)]
-mod debug_macros {
- macro_rules! debugln {
- ($fmt:expr) => ();
- ($fmt:expr, $($arg:tt)*) => ();
- }
- macro_rules! sdebugln {
- ($fmt:expr) => ();
- ($fmt:expr, $($arg:tt)*) => ();
- }
- macro_rules! debug {
- ($fmt:expr) => ();
- ($fmt:expr, $($arg:tt)*) => ();
- }
-}
-
-// Helper/deduplication macro for printing the correct number of spaces in help messages
-// used in:
-// src/args/arg_builder/*.rs
-// src/app/mod.rs
-macro_rules! write_nspaces {
- ($dst:expr, $num:expr) => ({
- debugln!("write_spaces!: num={}", $num);
- for _ in 0..$num {
- $dst.write_all(b" ")?;
- }
- })
-}
-
-// convenience macro for remove an item from a vec
-//macro_rules! vec_remove_all {
-// ($vec:expr, $to_rem:expr) => {
-// debugln!("vec_remove_all! to_rem={:?}", $to_rem);
-// for i in (0 .. $vec.len()).rev() {
-// let should_remove = $to_rem.any(|name| name == &$vec[i]);
-// if should_remove { $vec.swap_remove(i); }
-// }
-// };
-//}
-macro_rules! find_from {
- ($_self:expr, $arg_name:expr, $from:ident, $matcher:expr) => {{
- let mut ret = None;
- for k in $matcher.arg_names() {
- if let Some(f) = find_by_name!($_self, k, flags, iter) {
- if let Some(ref v) = f.$from() {
- if v.contains($arg_name) {
- ret = Some(f.to_string());
- }
- }
- }
- if let Some(o) = find_by_name!($_self, k, opts, iter) {
- if let Some(ref v) = o.$from() {
- if v.contains(&$arg_name) {
- ret = Some(o.to_string());
- }
- }
- }
- if let Some(pos) = find_by_name!($_self, k, positionals, values) {
- if let Some(ref v) = pos.$from() {
- if v.contains($arg_name) {
- ret = Some(pos.b.name.to_owned());
- }
- }
- }
- }
- ret
- }};
-}
-
-//macro_rules! find_name_from {
-// ($_self:expr, $arg_name:expr, $from:ident, $matcher:expr) => {{
-// let mut ret = None;
-// for k in $matcher.arg_names() {
-// if let Some(f) = find_by_name!($_self, k, flags, iter) {
-// if let Some(ref v) = f.$from() {
-// if v.contains($arg_name) {
-// ret = Some(f.b.name);
-// }
-// }
-// }
-// if let Some(o) = find_by_name!($_self, k, opts, iter) {
-// if let Some(ref v) = o.$from() {
-// if v.contains(&$arg_name) {
-// ret = Some(o.b.name);
-// }
-// }
-// }
-// if let Some(pos) = find_by_name!($_self, k, positionals, values) {
-// if let Some(ref v) = pos.$from() {
-// if v.contains($arg_name) {
-// ret = Some(pos.b.name);
-// }
-// }
-// }
-// }
-// ret
-// }};
-//}
-
-
-macro_rules! find_any_by_name {
- ($p:expr, $name:expr) => {
- {
- fn as_trait_obj<'a, 'b, T: AnyArg<'a, 'b>>(x: &T) -> &AnyArg<'a, 'b> { x }
- find_by_name!($p, $name, flags, iter).map(as_trait_obj).or(
- find_by_name!($p, $name, opts, iter).map(as_trait_obj).or(
- find_by_name!($p, $name, positionals, values).map(as_trait_obj)
- )
- )
- }
- }
-}
-// Finds an arg by name
-macro_rules! find_by_name {
- ($p:expr, $name:expr, $what:ident, $how:ident) => {
- $p.$what.$how().find(|o| o.b.name == $name)
- }
-}
-
-// Finds an option including if it's aliased
-macro_rules! find_opt_by_long {
- (@os $_self:ident, $long:expr) => {{
- _find_by_long!($_self, $long, opts)
- }};
- ($_self:ident, $long:expr) => {{
- _find_by_long!($_self, $long, opts)
- }};
-}
-
-macro_rules! find_flag_by_long {
- (@os $_self:ident, $long:expr) => {{
- _find_by_long!($_self, $long, flags)
- }};
- ($_self:ident, $long:expr) => {{
- _find_by_long!($_self, $long, flags)
- }};
-}
-
-macro_rules! _find_by_long {
- ($_self:ident, $long:expr, $what:ident) => {{
- $_self.$what
- .iter()
- .filter(|a| a.s.long.is_some())
- .find(|a| {
- a.s.long.unwrap() == $long ||
- (a.s.aliases.is_some() &&
- a.s
- .aliases
- .as_ref()
- .unwrap()
- .iter()
- .any(|&(alias, _)| alias == $long))
- })
- }}
-}
-
-// Finds an option
-macro_rules! find_opt_by_short {
- ($_self:ident, $short:expr) => {{
- _find_by_short!($_self, $short, opts)
- }}
-}
-
-macro_rules! find_flag_by_short {
- ($_self:ident, $short:expr) => {{
- _find_by_short!($_self, $short, flags)
- }}
-}
-
-macro_rules! _find_by_short {
- ($_self:ident, $short:expr, $what:ident) => {{
- $_self.$what
- .iter()
- .filter(|a| a.s.short.is_some())
- .find(|a| a.s.short.unwrap() == $short)
- }}
-}
-
-macro_rules! find_subcmd {
- ($_self:expr, $sc:expr) => {{
- $_self.subcommands
- .iter()
- .find(|s| {
- &*s.p.meta.name == $sc ||
- (s.p.meta.aliases.is_some() &&
- s.p
- .meta
- .aliases
- .as_ref()
- .unwrap()
- .iter()
- .any(|&(n, _)| n == $sc))
- })
- }};
-}
-
-macro_rules! shorts {
- ($_self:ident) => {{
- _shorts_longs!($_self, short)
- }};
-}
-
-
-macro_rules! longs {
- ($_self:ident) => {{
- _shorts_longs!($_self, long)
- }};
-}
-
-macro_rules! _shorts_longs {
- ($_self:ident, $what:ident) => {{
- $_self.flags
- .iter()
- .filter(|f| f.s.$what.is_some())
- .map(|f| f.s.$what.as_ref().unwrap())
- .chain($_self.opts.iter()
- .filter(|o| o.s.$what.is_some())
- .map(|o| o.s.$what.as_ref().unwrap()))
- }};
-}
-
-macro_rules! arg_names {
- ($_self:ident) => {{
- _names!(@args $_self)
- }};
-}
-
-macro_rules! sc_names {
- ($_self:ident) => {{
- _names!(@sc $_self)
- }};
-}
-
-macro_rules! _names {
- (@args $_self:ident) => {{
- $_self.flags
- .iter()
- .map(|f| &*f.b.name)
- .chain($_self.opts.iter()
- .map(|o| &*o.b.name)
- .chain($_self.positionals.values()
- .map(|p| &*p.b.name)))
- }};
- (@sc $_self:ident) => {{
- $_self.subcommands
- .iter()
- .map(|s| &*s.p.meta.name)
- .chain($_self.subcommands
- .iter()
- .filter(|s| s.p.meta.aliases.is_some())
- .flat_map(|s| s.p.meta.aliases.as_ref().unwrap().iter().map(|&(n, _)| n)))
-
- }}
-}
diff --git a/clap/src/map.rs b/clap/src/map.rs
deleted file mode 100644
index 063a860..0000000
--- a/clap/src/map.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-#[cfg(feature = "vec_map")]
-pub use vec_map::{Values, VecMap};
-
-#[cfg(not(feature = "vec_map"))]
-pub use self::vec_map::{Values, VecMap};
-
-#[cfg(not(feature = "vec_map"))]
-mod vec_map {
- use std::collections::BTreeMap;
- use std::collections::btree_map;
- use std::fmt::{self, Debug, Formatter};
-
- #[derive(Clone, Default, Debug)]
- pub struct VecMap<V> {
- inner: BTreeMap<usize, V>,
- }
-
- impl<V> VecMap<V> {
- pub fn new() -> Self {
- VecMap {
- inner: Default::default(),
- }
- }
-
- pub fn len(&self) -> usize { self.inner.len() }
-
- pub fn is_empty(&self) -> bool { self.inner.is_empty() }
-
- pub fn insert(&mut self, key: usize, value: V) -> Option<V> {
- self.inner.insert(key, value)
- }
-
- pub fn values(&self) -> Values<V> { self.inner.values() }
-
- pub fn iter(&self) -> Iter<V> {
- Iter {
- inner: self.inner.iter(),
- }
- }
-
- pub fn contains_key(&self, key: usize) -> bool { self.inner.contains_key(&key) }
-
- pub fn entry(&mut self, key: usize) -> Entry<V> { self.inner.entry(key) }
-
- pub fn get(&self, key: usize) -> Option<&V> { self.inner.get(&key) }
- }
-
- pub type Values<'a, V> = btree_map::Values<'a, usize, V>;
-
- pub type Entry<'a, V> = btree_map::Entry<'a, usize, V>;
-
- #[derive(Clone)]
- pub struct Iter<'a, V: 'a> {
- inner: btree_map::Iter<'a, usize, V>,
- }
-
- impl<'a, V: 'a + Debug> Debug for Iter<'a, V> {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- f.debug_list().entries(self.inner.clone()).finish()
- }
- }
-
- impl<'a, V: 'a> Iterator for Iter<'a, V> {
- type Item = (usize, &'a V);
-
- fn next(&mut self) -> Option<Self::Item> { self.inner.next().map(|(k, v)| (*k, v)) }
- }
-
- impl<'a, V: 'a> DoubleEndedIterator for Iter<'a, V> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.inner.next_back().map(|(k, v)| (*k, v))
- }
- }
-}
diff --git a/clap/src/osstringext.rs b/clap/src/osstringext.rs
deleted file mode 100644
index 061c01d..0000000
--- a/clap/src/osstringext.rs
+++ /dev/null
@@ -1,119 +0,0 @@
-#[cfg(any(target_os = "windows", target_arch = "wasm32"))]
-use INVALID_UTF8;
-use std::ffi::OsStr;
-#[cfg(not(any(target_os = "windows", target_arch = "wasm32")))]
-use std::os::unix::ffi::OsStrExt;
-
-#[cfg(any(target_os = "windows", target_arch = "wasm32"))]
-pub trait OsStrExt3 {
- fn from_bytes(b: &[u8]) -> &Self;
- fn as_bytes(&self) -> &[u8];
-}
-
-#[doc(hidden)]
-pub trait OsStrExt2 {
- fn starts_with(&self, s: &[u8]) -> bool;
- fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
- fn split_at(&self, i: usize) -> (&OsStr, &OsStr);
- fn trim_left_matches(&self, b: u8) -> &OsStr;
- fn contains_byte(&self, b: u8) -> bool;
- fn split(&self, b: u8) -> OsSplit;
-}
-
-#[cfg(any(target_os = "windows", target_arch = "wasm32"))]
-impl OsStrExt3 for OsStr {
- fn from_bytes(b: &[u8]) -> &Self {
- use std::mem;
- unsafe { mem::transmute(b) }
- }
- fn as_bytes(&self) -> &[u8] {
- self.to_str().map(|s| s.as_bytes()).expect(INVALID_UTF8)
- }
-}
-
-impl OsStrExt2 for OsStr {
- fn starts_with(&self, s: &[u8]) -> bool {
- self.as_bytes().starts_with(s)
- }
-
- fn contains_byte(&self, byte: u8) -> bool {
- for b in self.as_bytes() {
- if b == &byte {
- return true;
- }
- }
- false
- }
-
- fn split_at_byte(&self, byte: u8) -> (&OsStr, &OsStr) {
- for (i, b) in self.as_bytes().iter().enumerate() {
- if b == &byte {
- return (
- OsStr::from_bytes(&self.as_bytes()[..i]),
- OsStr::from_bytes(&self.as_bytes()[i + 1..]),
- );
- }
- }
- (
- &*self,
- OsStr::from_bytes(&self.as_bytes()[self.len()..self.len()]),
- )
- }
-
- fn trim_left_matches(&self, byte: u8) -> &OsStr {
- let mut found = false;
- for (i, b) in self.as_bytes().iter().enumerate() {
- if b != &byte {
- return OsStr::from_bytes(&self.as_bytes()[i..]);
- } else {
- found = true;
- }
- }
- if found {
- return OsStr::from_bytes(&self.as_bytes()[self.len()..]);
- }
- &*self
- }
-
- fn split_at(&self, i: usize) -> (&OsStr, &OsStr) {
- (
- OsStr::from_bytes(&self.as_bytes()[..i]),
- OsStr::from_bytes(&self.as_bytes()[i..]),
- )
- }
-
- fn split(&self, b: u8) -> OsSplit {
- OsSplit {
- sep: b,
- val: self.as_bytes(),
- pos: 0,
- }
- }
-}
-
-#[doc(hidden)]
-#[derive(Clone, Debug)]
-pub struct OsSplit<'a> {
- sep: u8,
- val: &'a [u8],
- pos: usize,
-}
-
-impl<'a> Iterator for OsSplit<'a> {
- type Item = &'a OsStr;
-
- fn next(&mut self) -> Option<&'a OsStr> {
- debugln!("OsSplit::next: self={:?}", self);
- if self.pos == self.val.len() {
- return None;
- }
- let start = self.pos;
- for b in &self.val[start..] {
- self.pos += 1;
- if *b == self.sep {
- return Some(OsStr::from_bytes(&self.val[start..self.pos - 1]));
- }
- }
- Some(OsStr::from_bytes(&self.val[start..]))
- }
-}
diff --git a/clap/src/strext.rs b/clap/src/strext.rs
deleted file mode 100644
index 6f81367..0000000
--- a/clap/src/strext.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-pub trait _StrExt {
- fn _is_char_boundary(&self, index: usize) -> bool;
-}
-
-impl _StrExt for str {
- #[inline]
- fn _is_char_boundary(&self, index: usize) -> bool {
- if index == self.len() {
- return true;
- }
- match self.as_bytes().get(index) {
- None => false,
- Some(&b) => b < 128 || b >= 192,
- }
- }
-}
diff --git a/clap/src/suggestions.rs b/clap/src/suggestions.rs
deleted file mode 100644
index 06071d2..0000000
--- a/clap/src/suggestions.rs
+++ /dev/null
@@ -1,147 +0,0 @@
-use app::App;
-// Third Party
-#[cfg(feature = "suggestions")]
-use strsim;
-
-// Internal
-use fmt::Format;
-
-/// Produces a string from a given list of possible values which is similar to
-/// the passed in value `v` with a certain confidence.
-/// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yield
-/// `Some("foo")`, whereas "blark" would yield `None`.
-#[cfg(feature = "suggestions")]
-#[cfg_attr(feature = "lints", allow(needless_lifetimes))]
-pub fn did_you_mean<'a, T: ?Sized, I>(v: &str, possible_values: I) -> Option<&'a str>
-where
- T: AsRef<str> + 'a,
- I: IntoIterator<Item = &'a T>,
-{
- let mut candidate: Option<(f64, &str)> = None;
- for pv in possible_values {
- let confidence = strsim::jaro_winkler(v, pv.as_ref());
- if confidence > 0.8 && (candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence))
- {
- candidate = Some((confidence, pv.as_ref()));
- }
- }
- match candidate {
- None => None,
- Some((_, candidate)) => Some(candidate),
- }
-}
-
-#[cfg(not(feature = "suggestions"))]
-pub fn did_you_mean<'a, T: ?Sized, I>(_: &str, _: I) -> Option<&'a str>
-where
- T: AsRef<str> + 'a,
- I: IntoIterator<Item = &'a T>,
-{
- None
-}
-
-/// Returns a suffix that can be empty, or is the standard 'did you mean' phrase
-#[cfg_attr(feature = "lints", allow(needless_lifetimes))]
-pub fn did_you_mean_flag_suffix<'z, T, I>(
- arg: &str,
- args_rest: &'z [&str],
- longs: I,
- subcommands: &'z [App],
-) -> (String, Option<&'z str>)
-where
- T: AsRef<str> + 'z,
- I: IntoIterator<Item = &'z T>,
-{
- if let Some(candidate) = did_you_mean(arg, longs) {
- let suffix = format!(
- "\n\tDid you mean {}{}?",
- Format::Good("--"),
- Format::Good(candidate)
- );
- return (suffix, Some(candidate));
- }
-
- subcommands
- .into_iter()
- .filter_map(|subcommand| {
- let opts = subcommand
- .p
- .flags
- .iter()
- .filter_map(|f| f.s.long)
- .chain(subcommand.p.opts.iter().filter_map(|o| o.s.long));
-
- let candidate = match did_you_mean(arg, opts) {
- Some(candidate) => candidate,
- None => return None
- };
- let score = match args_rest.iter().position(|x| *x == subcommand.get_name()) {
- Some(score) => score,
- None => return None
- };
-
- let suffix = format!(
- "\n\tDid you mean to put '{}{}' after the subcommand '{}'?",
- Format::Good("--"),
- Format::Good(candidate),
- Format::Good(subcommand.get_name())
- );
-
- Some((score, (suffix, Some(candidate))))
- })
- .min_by_key(|&(score, _)| score)
- .map(|(_, suggestion)| suggestion)
- .unwrap_or_else(|| (String::new(), None))
-}
-
-/// Returns a suffix that can be empty, or is the standard 'did you mean' phrase
-pub fn did_you_mean_value_suffix<'z, T, I>(arg: &str, values: I) -> (String, Option<&'z str>)
-where
- T: AsRef<str> + 'z,
- I: IntoIterator<Item = &'z T>,
-{
- match did_you_mean(arg, values) {
- Some(candidate) => {
- let suffix = format!("\n\tDid you mean '{}'?", Format::Good(candidate));
- (suffix, Some(candidate))
- }
- None => (String::new(), None),
- }
-}
-
-#[cfg(all(test, features = "suggestions"))]
-mod test {
- use super::*;
-
- #[test]
- fn possible_values_match() {
- let p_vals = ["test", "possible", "values"];
- assert_eq!(did_you_mean("tst", p_vals.iter()), Some("test"));
- }
-
- #[test]
- fn possible_values_nomatch() {
- let p_vals = ["test", "possible", "values"];
- assert!(did_you_mean("hahaahahah", p_vals.iter()).is_none());
- }
-
- #[test]
- fn suffix_long() {
- let p_vals = ["test", "possible", "values"];
- let suffix = "\n\tDid you mean \'--test\'?";
- assert_eq!(
- did_you_mean_flag_suffix("tst", p_vals.iter(), []),
- (suffix, Some("test"))
- );
- }
-
- #[test]
- fn suffix_enum() {
- let p_vals = ["test", "possible", "values"];
- let suffix = "\n\tDid you mean \'test\'?";
- assert_eq!(
- did_you_mean_value_suffix("tst", p_vals.iter()),
- (suffix, Some("test"))
- );
- }
-}
diff --git a/clap/src/usage_parser.rs b/clap/src/usage_parser.rs
deleted file mode 100644
index f6d5ac6..0000000
--- a/clap/src/usage_parser.rs
+++ /dev/null
@@ -1,1347 +0,0 @@
-// Internal
-use INTERNAL_ERROR_MSG;
-use args::Arg;
-use args::settings::ArgSettings;
-use map::VecMap;
-
-#[derive(PartialEq, Debug)]
-enum UsageToken {
- Name,
- ValName,
- Short,
- Long,
- Help,
- Multiple,
- Unknown,
-}
-
-#[doc(hidden)]
-#[derive(Debug)]
-pub struct UsageParser<'a> {
- usage: &'a str,
- pos: usize,
- start: usize,
- prev: UsageToken,
- explicit_name_set: bool,
-}
-
-impl<'a> UsageParser<'a> {
- fn new(usage: &'a str) -> Self {
- debugln!("UsageParser::new: usage={:?}", usage);
- UsageParser {
- usage: usage,
- pos: 0,
- start: 0,
- prev: UsageToken::Unknown,
- explicit_name_set: false,
- }
- }
-
- pub fn from_usage(usage: &'a str) -> Self {
- debugln!("UsageParser::from_usage;");
- UsageParser::new(usage)
- }
-
- pub fn parse(mut self) -> Arg<'a, 'a> {
- debugln!("UsageParser::parse;");
- let mut arg = Arg::default();
- loop {
- debugln!("UsageParser::parse:iter: pos={};", self.pos);
- self.stop_at(token);
- if let Some(&c) = self.usage.as_bytes().get(self.pos) {
- match c {
- b'-' => self.short_or_long(&mut arg),
- b'.' => self.multiple(&mut arg),
- b'\'' => self.help(&mut arg),
- _ => self.name(&mut arg),
- }
- } else {
- break;
- }
- }
- debug_assert!(
- !arg.b.name.is_empty(),
- format!(
- "No name found for Arg when parsing usage string: {}",
- self.usage
- )
- );
- arg.v.num_vals = match arg.v.val_names {
- Some(ref v) if v.len() >= 2 => Some(v.len() as u64),
- _ => None,
- };
- debugln!("UsageParser::parse: vals...{:?}", arg.v.val_names);
- arg
- }
-
- fn name(&mut self, arg: &mut Arg<'a, 'a>) {
- debugln!("UsageParser::name;");
- if *self.usage
- .as_bytes()
- .get(self.pos)
- .expect(INTERNAL_ERROR_MSG) == b'<' && !self.explicit_name_set
- {
- arg.setb(ArgSettings::Required);
- }
- self.pos += 1;
- self.stop_at(name_end);
- let name = &self.usage[self.start..self.pos];
- if self.prev == UsageToken::Unknown {
- debugln!("UsageParser::name: setting name...{}", name);
- arg.b.name = name;
- if arg.s.long.is_none() && arg.s.short.is_none() {
- debugln!("UsageParser::name: explicit name set...");
- self.explicit_name_set = true;
- self.prev = UsageToken::Name;
- }
- } else {
- debugln!("UsageParser::name: setting val name...{}", name);
- if let Some(ref mut v) = arg.v.val_names {
- let len = v.len();
- v.insert(len, name);
- } else {
- let mut v = VecMap::new();
- v.insert(0, name);
- arg.v.val_names = Some(v);
- arg.setb(ArgSettings::TakesValue);
- }
- self.prev = UsageToken::ValName;
- }
- }
-
- fn stop_at<F>(&mut self, f: F)
- where
- F: Fn(u8) -> bool,
- {
- debugln!("UsageParser::stop_at;");
- self.start = self.pos;
- self.pos += self.usage[self.start..]
- .bytes()
- .take_while(|&b| f(b))
- .count();
- }
-
- fn short_or_long(&mut self, arg: &mut Arg<'a, 'a>) {
- debugln!("UsageParser::short_or_long;");
- self.pos += 1;
- if *self.usage
- .as_bytes()
- .get(self.pos)
- .expect(INTERNAL_ERROR_MSG) == b'-'
- {
- self.pos += 1;
- self.long(arg);
- return;
- }
- self.short(arg)
- }
-
- fn long(&mut self, arg: &mut Arg<'a, 'a>) {
- debugln!("UsageParser::long;");
- self.stop_at(long_end);
- let name = &self.usage[self.start..self.pos];
- if !self.explicit_name_set {
- debugln!("UsageParser::long: setting name...{}", name);
- arg.b.name = name;
- }
- debugln!("UsageParser::long: setting long...{}", name);
- arg.s.long = Some(name);
- self.prev = UsageToken::Long;
- }
-
- fn short(&mut self, arg: &mut Arg<'a, 'a>) {
- debugln!("UsageParser::short;");
- let start = &self.usage[self.pos..];
- let short = start.chars().nth(0).expect(INTERNAL_ERROR_MSG);
- debugln!("UsageParser::short: setting short...{}", short);
- arg.s.short = Some(short);
- if arg.b.name.is_empty() {
- // --long takes precedence but doesn't set self.explicit_name_set
- let name = &start[..short.len_utf8()];
- debugln!("UsageParser::short: setting name...{}", name);
- arg.b.name = name;
- }
- self.prev = UsageToken::Short;
- }
-
- // "something..."
- fn multiple(&mut self, arg: &mut Arg) {
- debugln!("UsageParser::multiple;");
- let mut dot_counter = 1;
- let start = self.pos;
- let mut bytes = self.usage[start..].bytes();
- while bytes.next() == Some(b'.') {
- dot_counter += 1;
- self.pos += 1;
- if dot_counter == 3 {
- debugln!("UsageParser::multiple: setting multiple");
- arg.setb(ArgSettings::Multiple);
- if arg.is_set(ArgSettings::TakesValue) {
- arg.setb(ArgSettings::UseValueDelimiter);
- arg.unsetb(ArgSettings::ValueDelimiterNotSet);
- if arg.v.val_delim.is_none() {
- arg.v.val_delim = Some(',');
- }
- }
- self.prev = UsageToken::Multiple;
- self.pos += 1;
- break;
- }
- }
- }
-
- fn help(&mut self, arg: &mut Arg<'a, 'a>) {
- debugln!("UsageParser::help;");
- self.stop_at(help_start);
- self.start = self.pos + 1;
- self.pos = self.usage.len() - 1;
- debugln!(
- "UsageParser::help: setting help...{}",
- &self.usage[self.start..self.pos]
- );
- arg.b.help = Some(&self.usage[self.start..self.pos]);
- self.pos += 1; // Move to next byte to keep from thinking ending ' is a start
- self.prev = UsageToken::Help;
- }
-}
-
-#[inline]
-fn name_end(b: u8) -> bool { b != b']' && b != b'>' }
-
-#[inline]
-fn token(b: u8) -> bool { b != b'\'' && b != b'.' && b != b'<' && b != b'[' && b != b'-' }
-
-#[inline]
-fn long_end(b: u8) -> bool {
- b != b'\'' && b != b'.' && b != b'<' && b != b'[' && b != b'=' && b != b' '
-}
-
-#[inline]
-fn help_start(b: u8) -> bool { b != b'\'' }
-
-#[cfg(test)]
-mod test {
- use args::Arg;
- use args::ArgSettings;
-
- #[test]
- fn create_flag_usage() {
- let a = Arg::from_usage("[flag] -f 'some help info'");
- assert_eq!(a.b.name, "flag");
- assert_eq!(a.s.short.unwrap(), 'f');
- assert!(a.s.long.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.v.val_names.is_none());
- assert!(a.v.num_vals.is_none());
-
- let b = Arg::from_usage("[flag] --flag 'some help info'");
- assert_eq!(b.b.name, "flag");
- assert_eq!(b.s.long.unwrap(), "flag");
- assert!(b.s.short.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(a.v.val_names.is_none());
- assert!(a.v.num_vals.is_none());
-
- let b = Arg::from_usage("--flag 'some help info'");
- assert_eq!(b.b.name, "flag");
- assert_eq!(b.s.long.unwrap(), "flag");
- assert!(b.s.short.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.v.val_names.is_none());
- assert!(b.v.num_vals.is_none());
-
- let c = Arg::from_usage("[flag] -f --flag 'some help info'");
- assert_eq!(c.b.name, "flag");
- assert_eq!(c.s.short.unwrap(), 'f');
- assert_eq!(c.s.long.unwrap(), "flag");
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(!c.is_set(ArgSettings::Multiple));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
-
- let d = Arg::from_usage("[flag] -f... 'some help info'");
- assert_eq!(d.b.name, "flag");
- assert_eq!(d.s.short.unwrap(), 'f');
- assert!(d.s.long.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.v.val_names.is_none());
- assert!(d.v.num_vals.is_none());
-
- let e = Arg::from_usage("[flag] -f --flag... 'some help info'");
- assert_eq!(e.b.name, "flag");
- assert_eq!(e.s.long.unwrap(), "flag");
- assert_eq!(e.s.short.unwrap(), 'f');
- assert_eq!(e.b.help.unwrap(), "some help info");
- assert!(e.is_set(ArgSettings::Multiple));
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let e = Arg::from_usage("-f --flag... 'some help info'");
- assert_eq!(e.b.name, "flag");
- assert_eq!(e.s.long.unwrap(), "flag");
- assert_eq!(e.s.short.unwrap(), 'f');
- assert_eq!(e.b.help.unwrap(), "some help info");
- assert!(e.is_set(ArgSettings::Multiple));
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let e = Arg::from_usage("--flags");
- assert_eq!(e.b.name, "flags");
- assert_eq!(e.s.long.unwrap(), "flags");
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let e = Arg::from_usage("--flags...");
- assert_eq!(e.b.name, "flags");
- assert_eq!(e.s.long.unwrap(), "flags");
- assert!(e.is_set(ArgSettings::Multiple));
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let e = Arg::from_usage("[flags] -f");
- assert_eq!(e.b.name, "flags");
- assert_eq!(e.s.short.unwrap(), 'f');
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let e = Arg::from_usage("[flags] -f...");
- assert_eq!(e.b.name, "flags");
- assert_eq!(e.s.short.unwrap(), 'f');
- assert!(e.is_set(ArgSettings::Multiple));
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let a = Arg::from_usage("-f 'some help info'");
- assert_eq!(a.b.name, "f");
- assert_eq!(a.s.short.unwrap(), 'f');
- assert!(a.s.long.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.v.val_names.is_none());
- assert!(a.v.num_vals.is_none());
-
- let e = Arg::from_usage("-f");
- assert_eq!(e.b.name, "f");
- assert_eq!(e.s.short.unwrap(), 'f');
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
-
- let e = Arg::from_usage("-f...");
- assert_eq!(e.b.name, "f");
- assert_eq!(e.s.short.unwrap(), 'f');
- assert!(e.is_set(ArgSettings::Multiple));
- assert!(e.v.val_names.is_none());
- assert!(e.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage0() {
- // Short only
- let a = Arg::from_usage("[option] -o [opt] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert!(a.s.long.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage1() {
- let b = Arg::from_usage("-o [opt] 'some help info'");
- assert_eq!(b.b.name, "o");
- assert_eq!(b.s.short.unwrap(), 'o');
- assert!(b.s.long.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage2() {
- let c = Arg::from_usage("<option> -o <opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert!(c.s.long.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(!c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage3() {
- let d = Arg::from_usage("-o <opt> 'some help info'");
- assert_eq!(d.b.name, "o");
- assert_eq!(d.s.short.unwrap(), 'o');
- assert!(d.s.long.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage4() {
- let a = Arg::from_usage("[option] -o [opt]... 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert!(a.s.long.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage5() {
- let a = Arg::from_usage("[option]... -o [opt] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert!(a.s.long.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage6() {
- let b = Arg::from_usage("-o [opt]... 'some help info'");
- assert_eq!(b.b.name, "o");
- assert_eq!(b.s.short.unwrap(), 'o');
- assert!(b.s.long.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage7() {
- let c = Arg::from_usage("<option> -o <opt>... 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert!(c.s.long.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage8() {
- let c = Arg::from_usage("<option>... -o <opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert!(c.s.long.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage9() {
- let d = Arg::from_usage("-o <opt>... 'some help info'");
- assert_eq!(d.b.name, "o");
- assert_eq!(d.s.short.unwrap(), 'o');
- assert!(d.s.long.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long1() {
- let a = Arg::from_usage("[option] --opt [opt] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert!(a.s.short.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long2() {
- let b = Arg::from_usage("--opt [option] 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert!(b.s.short.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long3() {
- let c = Arg::from_usage("<option> --opt <opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert!(c.s.short.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(!c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long4() {
- let d = Arg::from_usage("--opt <option> 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert!(d.s.short.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long5() {
- let a = Arg::from_usage("[option] --opt [opt]... 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert!(a.s.short.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long6() {
- let a = Arg::from_usage("[option]... --opt [opt] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert!(a.s.short.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long7() {
- let b = Arg::from_usage("--opt [option]... 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert!(b.s.short.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long8() {
- let c = Arg::from_usage("<option> --opt <opt>... 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert!(c.s.short.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long9() {
- let c = Arg::from_usage("<option>... --opt <opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert!(c.s.short.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long10() {
- let d = Arg::from_usage("--opt <option>... 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert!(d.s.short.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals1() {
- let a = Arg::from_usage("[option] --opt=[opt] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert!(a.s.short.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals2() {
- let b = Arg::from_usage("--opt=[option] 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert!(b.s.short.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals3() {
- let c = Arg::from_usage("<option> --opt=<opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert!(c.s.short.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(!c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals4() {
- let d = Arg::from_usage("--opt=<option> 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert!(d.s.short.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals5() {
- let a = Arg::from_usage("[option] --opt=[opt]... 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert!(a.s.short.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals6() {
- let a = Arg::from_usage("[option]... --opt=[opt] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert!(a.s.short.is_none());
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals7() {
- let b = Arg::from_usage("--opt=[option]... 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert!(b.s.short.is_none());
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals8() {
- let c = Arg::from_usage("<option> --opt=<opt>... 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert!(c.s.short.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals9() {
- let c = Arg::from_usage("<option>... --opt=<opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert!(c.s.short.is_none());
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_long_equals10() {
- let d = Arg::from_usage("--opt=<option>... 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert!(d.s.short.is_none());
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both1() {
- let a = Arg::from_usage("[option] -o --opt [option] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both2() {
- let b = Arg::from_usage("-o --opt [option] 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert_eq!(b.s.short.unwrap(), 'o');
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both3() {
- let c = Arg::from_usage("<option> -o --opt <opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(!c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both4() {
- let d = Arg::from_usage("-o --opt <option> 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.s.short.unwrap(), 'o');
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both5() {
- let a = Arg::from_usage("[option]... -o --opt [option] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both6() {
- let b = Arg::from_usage("-o --opt [option]... 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert_eq!(b.s.short.unwrap(), 'o');
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both7() {
- let c = Arg::from_usage("<option>... -o --opt <opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both8() {
- let d = Arg::from_usage("-o --opt <option>... 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.s.short.unwrap(), 'o');
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals1() {
- let a = Arg::from_usage("[option] -o --opt=[option] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals2() {
- let b = Arg::from_usage("-o --opt=[option] 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert_eq!(b.s.short.unwrap(), 'o');
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals3() {
- let c = Arg::from_usage("<option> -o --opt=<opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(!c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals4() {
- let d = Arg::from_usage("-o --opt=<option> 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.s.short.unwrap(), 'o');
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals5() {
- let a = Arg::from_usage("[option]... -o --opt=[option] 'some help info'");
- assert_eq!(a.b.name, "option");
- assert_eq!(a.s.long.unwrap(), "opt");
- assert_eq!(a.s.short.unwrap(), 'o');
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(a.is_set(ArgSettings::Multiple));
- assert!(a.is_set(ArgSettings::TakesValue));
- assert!(!a.is_set(ArgSettings::Required));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals6() {
- let b = Arg::from_usage("-o --opt=[option]... 'some help info'");
- assert_eq!(b.b.name, "opt");
- assert_eq!(b.s.long.unwrap(), "opt");
- assert_eq!(b.s.short.unwrap(), 'o');
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::TakesValue));
- assert!(!b.is_set(ArgSettings::Required));
- assert_eq!(
- b.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals7() {
- let c = Arg::from_usage("<option>... -o --opt=<opt> 'some help info'");
- assert_eq!(c.b.name, "option");
- assert_eq!(c.s.long.unwrap(), "opt");
- assert_eq!(c.s.short.unwrap(), 'o');
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(c.is_set(ArgSettings::TakesValue));
- assert!(c.is_set(ArgSettings::Required));
- assert_eq!(
- c.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"opt"]
- );
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_usage_both_equals8() {
- let d = Arg::from_usage("-o --opt=<option>... 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.s.short.unwrap(), 'o');
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"option"]
- );
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn create_option_with_vals1() {
- let d = Arg::from_usage("-o <file> <mode> 'some help info'");
- assert_eq!(d.b.name, "o");
- assert!(d.s.long.is_none());
- assert_eq!(d.s.short.unwrap(), 'o');
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"file", &"mode"]
- );
- assert_eq!(d.v.num_vals.unwrap(), 2);
- }
-
- #[test]
- fn create_option_with_vals2() {
- let d = Arg::from_usage("-o <file> <mode>... 'some help info'");
- assert_eq!(d.b.name, "o");
- assert!(d.s.long.is_none());
- assert_eq!(d.s.short.unwrap(), 'o');
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"file", &"mode"]
- );
- assert_eq!(d.v.num_vals.unwrap(), 2);
- }
-
- #[test]
- fn create_option_with_vals3() {
- let d = Arg::from_usage("--opt <file> <mode>... 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert!(d.s.short.is_none());
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"file", &"mode"]
- );
- assert_eq!(d.v.num_vals.unwrap(), 2);
- }
-
- #[test]
- fn create_option_with_vals4() {
- let d = Arg::from_usage("[myopt] --opt <file> <mode> 'some help info'");
- assert_eq!(d.b.name, "myopt");
- assert!(d.s.short.is_none());
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(!d.is_set(ArgSettings::Required));
- assert_eq!(
- d.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"file", &"mode"]
- );
- assert_eq!(d.v.num_vals.unwrap(), 2);
- }
-
- #[test]
- fn create_option_with_vals5() {
- let d = Arg::from_usage("--opt <file> <mode> 'some help info'");
- assert_eq!(d.b.name, "opt");
- assert!(d.s.short.is_none());
- assert_eq!(d.s.long.unwrap(), "opt");
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(!d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::TakesValue));
- assert!(d.is_set(ArgSettings::Required));
- assert_eq!(d.v.num_vals.unwrap(), 2);
- }
-
- #[test]
- fn create_positional_usage() {
- let a = Arg::from_usage("[pos] 'some help info'");
- assert_eq!(a.b.name, "pos");
- assert_eq!(a.b.help.unwrap(), "some help info");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(!a.is_set(ArgSettings::Required));
- assert!(a.v.val_names.is_none());
- assert!(a.v.num_vals.is_none());
- }
-
- #[test]
- fn create_positional_usage0() {
- let b = Arg::from_usage("<pos> 'some help info'");
- assert_eq!(b.b.name, "pos");
- assert_eq!(b.b.help.unwrap(), "some help info");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::Required));
- assert!(b.v.val_names.is_none());
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_mult_help() {
- let c = Arg::from_usage("[pos]... 'some help info'");
- assert_eq!(c.b.name, "pos");
- assert_eq!(c.b.help.unwrap(), "some help info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(!c.is_set(ArgSettings::Required));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_help_lit_single_quote() {
- let c = Arg::from_usage("[pos]... 'some help\' info'");
- assert_eq!(c.b.name, "pos");
- assert_eq!(c.b.help.unwrap(), "some help' info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(!c.is_set(ArgSettings::Required));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_help_double_lit_single_quote() {
- let c = Arg::from_usage("[pos]... 'some \'help\' info'");
- assert_eq!(c.b.name, "pos");
- assert_eq!(c.b.help.unwrap(), "some 'help' info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(!c.is_set(ArgSettings::Required));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_help_newline() {
- let c = Arg::from_usage(
- "[pos]... 'some help{n}\
- info'",
- );
- assert_eq!(c.b.name, "pos");
- assert_eq!(c.b.help.unwrap(), "some help{n}info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(!c.is_set(ArgSettings::Required));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_help_newline_lit_sq() {
- let c = Arg::from_usage(
- "[pos]... 'some help\' stuff{n}\
- info'",
- );
- assert_eq!(c.b.name, "pos");
- assert_eq!(c.b.help.unwrap(), "some help' stuff{n}info");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(!c.is_set(ArgSettings::Required));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_req_mult_help() {
- let d = Arg::from_usage("<pos>... 'some help info'");
- assert_eq!(d.b.name, "pos");
- assert_eq!(d.b.help.unwrap(), "some help info");
- assert!(d.is_set(ArgSettings::Multiple));
- assert!(d.is_set(ArgSettings::Required));
- assert!(d.v.val_names.is_none());
- assert!(d.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_req() {
- let b = Arg::from_usage("<pos>");
- assert_eq!(b.b.name, "pos");
- assert!(!b.is_set(ArgSettings::Multiple));
- assert!(b.is_set(ArgSettings::Required));
- assert!(b.v.val_names.is_none());
- assert!(b.v.num_vals.is_none());
- }
-
- #[test]
- fn pos_mult() {
- let c = Arg::from_usage("[pos]...");
- assert_eq!(c.b.name, "pos");
- assert!(c.is_set(ArgSettings::Multiple));
- assert!(!c.is_set(ArgSettings::Required));
- assert!(c.v.val_names.is_none());
- assert!(c.v.num_vals.is_none());
- }
-
- #[test]
- fn nonascii() {
- let a = Arg::from_usage("<ASCII> 'üñíčöĐ€'");
- assert_eq!(a.b.name, "ASCII");
- assert_eq!(a.b.help, Some("üñíčöĐ€"));
- let a = Arg::from_usage("<üñíčöĐ€> 'ASCII'");
- assert_eq!(a.b.name, "üñíčöĐ€");
- assert_eq!(a.b.help, Some("ASCII"));
- let a = Arg::from_usage("<üñíčöĐ€> 'üñíčöĐ€'");
- assert_eq!(a.b.name, "üñíčöĐ€");
- assert_eq!(a.b.help, Some("üñíčöĐ€"));
- let a = Arg::from_usage("-ø 'ø'");
- assert_eq!(a.b.name, "ø");
- assert_eq!(a.s.short, Some('ø'));
- assert_eq!(a.b.help, Some("ø"));
- let a = Arg::from_usage("--üñíčöĐ€ 'Nōṫ ASCII'");
- assert_eq!(a.b.name, "üñíčöĐ€");
- assert_eq!(a.s.long, Some("üñíčöĐ€"));
- assert_eq!(a.b.help, Some("Nōṫ ASCII"));
- let a = Arg::from_usage("[ñämê] --ôpt=[üñíčöĐ€] 'hælp'");
- assert_eq!(a.b.name, "ñämê");
- assert_eq!(a.s.long, Some("ôpt"));
- assert_eq!(
- a.v.val_names.unwrap().values().collect::<Vec<_>>(),
- [&"üñíčöĐ€"]
- );
- assert_eq!(a.b.help, Some("hælp"));
- }
-}
diff --git a/clap/tests/app.yml b/clap/tests/app.yml
deleted file mode 100644
index 850bb82..0000000
--- a/clap/tests/app.yml
+++ /dev/null
@@ -1,121 +0,0 @@
-name: claptests
-version: "1.0"
-about: tests clap library
-author: Kevin K. <kbknapp@gmail.com>
-settings:
- - ArgRequiredElseHelp
-help_message: prints help with a nonstandard description
-args:
- - opt:
- short: o
- long: option
- multiple: true
- help: tests options
- - positional:
- help: tests positionals
- index: 1
- - positional2:
- help: tests positionals with exclusions
- index: 2
- default_value_if:
- - [flag, Null, some]
- - [postional, other, something]
- - flag:
- short: f
- long: flag
- multiple: true
- help: tests flags
- global: true
- - flag2:
- short: F
- help: tests flags with exclusions
- conflicts_with:
- - flag
- requires:
- - option2
- - option2:
- long: long-option-2
- help: tests long options with exclusions
- conflicts_with:
- - option
- requires:
- - positional2
- - option3:
- short: O
- long: Option
- help: tests options with specific value sets
- takes_value: true
- possible_values:
- - fast
- - slow
- requires_if:
- - [fast, flag]
- - positional3:
- index: 3
- help: tests positionals with specific values
- possible_values: [ vi, emacs ]
- - multvals:
- long: multvals
- help: Tests multiple values, not mult occs
- value_names:
- - one
- - two
- - multvalsmo:
- long: multvalsmo
- multiple: true
- help: Tests multiple values, not mult occs
- value_names: [one, two]
- - multvalsdelim:
- long: multvalsdelim
- help: Tests multiple values with required delimiter
- multiple: true
- require_delimiter: true
- - singlealias:
- long: singlealias
- help: Tests single alias
- aliases: [alias]
- required_if:
- - [multvalsmo, two]
- - multaliases:
- long: multaliases
- help: Tests multiple aliases
- aliases: [als1, als2, als3]
- - minvals2:
- long: minvals2
- multiple: true
- help: Tests 2 min vals
- min_values: 2
- - maxvals3:
- long: maxvals3
- multiple: true
- help: Tests 3 max vals
- max_values: 3
- - case_insensitive:
- help: Test case_insensitive
- possible_values: [test123, test321]
- case_insensitive: true
-
-arg_groups:
- - test:
- args:
- - maxvals3
- - minmals2
- conflicts_with:
- - option3
- requires:
- - multvals
-subcommands:
- - subcmd:
- about: tests subcommands
- version: "0.1"
- author: Kevin K. <kbknapp@gmail.com>
- args:
- - scoption:
- short: o
- long: option
- multiple: true
- help: tests options
- takes_value: true
- - scpositional:
- help: tests positionals
- index: 1
diff --git a/clap/tests/app_settings.rs b/clap/tests/app_settings.rs
deleted file mode 100644
index 3d72a3b..0000000
--- a/clap/tests/app_settings.rs
+++ /dev/null
@@ -1,965 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-use clap::{App, Arg, SubCommand, AppSettings, ErrorKind};
-
-include!("../clap-test.rs");
-
-static ALLOW_EXT_SC: &'static str = "clap-test v1.4.8
-
-USAGE:
- clap-test [SUBCOMMAND]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information";
-
-static DONT_COLLAPSE_ARGS: &'static str = "clap-test v1.4.8
-
-USAGE:
- clap-test [arg1] [arg2] [arg3]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <arg1> some
- <arg2> some
- <arg3> some";
-
-static REQUIRE_EQUALS: &'static str = "clap-test v1.4.8
-
-USAGE:
- clap-test --opt=<FILE>
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt=<FILE> some";
-
-static UNIFIED_HELP: &'static str = "test 1.3
-Kevin K.
-tests stuff
-
-USAGE:
- test [OPTIONS] [arg1]
-
-OPTIONS:
- -f, --flag some flag
- -h, --help Prints help information
- --option <opt> some option
- -V, --version Prints version information
-
-ARGS:
- <arg1> some pos arg";
-
-static SKIP_POS_VALS: &'static str = "test 1.3
-Kevin K.
-tests stuff
-
-USAGE:
- test [OPTIONS] [arg1]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <opt> some option
-
-ARGS:
- <arg1> some pos arg";
-
-#[test]
-fn sub_command_negate_required() {
- App::new("sub_command_negate")
- .setting(AppSettings::SubcommandsNegateReqs)
- .arg(Arg::with_name("test")
- .required(true)
- .index(1))
- .subcommand(SubCommand::with_name("sub1"))
- .get_matches_from(vec!["myprog", "sub1"]);
-}
-
-#[test]
-fn global_version() {
- let mut app = App::new("global_version")
- .setting(AppSettings::GlobalVersion)
- .version("1.1")
- .subcommand(SubCommand::with_name("sub1"));
- app.p.propagate_settings();
- assert_eq!(app.p.subcommands[0].p.meta.version, Some("1.1"));
-}
-
-#[test]
-fn sub_command_negate_required_2() {
- let result = App::new("sub_command_negate")
- .setting(AppSettings::SubcommandsNegateReqs)
- .arg(Arg::with_name("test")
- .required(true)
- .index(1))
- .subcommand(SubCommand::with_name("sub1"))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn sub_command_required() {
- let result = App::new("sc_required")
- .setting(AppSettings::SubcommandRequired)
- .subcommand(SubCommand::with_name("sub1"))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingSubcommand);
-}
-
-#[test]
-fn arg_required_else_help() {
- let result = App::new("arg_required")
- .setting(AppSettings::ArgRequiredElseHelp)
- .arg(Arg::with_name("test")
- .index(1))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingArgumentOrSubcommand);
-}
-
-#[test]
-fn arg_required_else_help_over_reqs() {
- let result = App::new("arg_required")
- .setting(AppSettings::ArgRequiredElseHelp)
- .arg(Arg::with_name("test")
- .index(1).required(true))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingArgumentOrSubcommand);
-}
-
-#[cfg(not(feature = "suggestions"))]
-#[test]
-fn infer_subcommands_fail_no_args() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from_safe(vec![
- "prog", "te"
- ]);
- assert!(m.is_err(), "{:#?}", m.unwrap());
- assert_eq!(m.unwrap_err().kind, ErrorKind::UnrecognizedSubcommand);
-}
-
-#[cfg(feature = "suggestions")]
-#[test]
-fn infer_subcommands_fail_no_args() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from_safe(vec![
- "prog", "te"
- ]);
- assert!(m.is_err(), "{:#?}", m.unwrap());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidSubcommand);
-}
-
-#[test]
-fn infer_subcommands_fail_with_args() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .arg(Arg::with_name("some"))
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from_safe(vec![
- "prog", "t"
- ]);
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- assert_eq!(m.unwrap().value_of("some"), Some("t"));
-}
-
-#[test]
-fn infer_subcommands_fail_with_args2() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .arg(Arg::with_name("some"))
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from_safe(vec![
- "prog", "te"
- ]);
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- assert_eq!(m.unwrap().value_of("some"), Some("te"));
-}
-
-#[test]
-fn infer_subcommands_pass() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .get_matches_from(vec![
- "prog", "te"
- ]);
- assert_eq!(m.subcommand_name(), Some("test"));
-}
-
-#[test]
-fn infer_subcommands_pass_close() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from(vec![
- "prog", "tes"
- ]);
- assert_eq!(m.subcommand_name(), Some("test"));
-}
-
-#[test]
-fn infer_subcommands_pass_exact_match() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("testa"))
- .subcommand(SubCommand::with_name("testb"))
- .get_matches_from(vec![
- "prog", "test"
- ]);
- assert_eq!(m.subcommand_name(), Some("test"));
-}
-
-#[cfg(feature = "suggestions")]
-#[test]
-fn infer_subcommands_fail_suggestions() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from_safe(vec![
- "prog", "temps"
- ]);
- assert!(m.is_err(), "{:#?}", m.unwrap());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidSubcommand);
-}
-
-#[cfg(not(feature = "suggestions"))]
-#[test]
-fn infer_subcommands_fail_suggestions() {
- let m = App::new("prog")
- .setting(AppSettings::InferSubcommands)
- .subcommand(SubCommand::with_name("test"))
- .subcommand(SubCommand::with_name("temp"))
- .get_matches_from_safe(vec![
- "prog", "temps"
- ]);
- assert!(m.is_err(), "{:#?}", m.unwrap());
- assert_eq!(m.unwrap_err().kind, ErrorKind::UnrecognizedSubcommand);
-}
-
-#[test]
-fn no_bin_name() {
- let result = App::new("arg_required")
- .setting(AppSettings::NoBinaryName)
- .arg(Arg::with_name("test")
- .required(true)
- .index(1))
- .get_matches_from_safe(vec!["testing"]);
- assert!(result.is_ok());
- let matches = result.unwrap();
- assert_eq!(matches.value_of("test").unwrap(), "testing");
-}
-
-#[test]
-fn unified_help() {
- let app = App::new("myTest")
- .name("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .setting(AppSettings::UnifiedHelpMessage)
- .args_from_usage("-f, --flag 'some flag'
- [arg1] 'some pos arg'
- --option [opt] 'some option'");
-
- assert!(test::compare_output(app, "test --help", UNIFIED_HELP, false));
-}
-
-#[test]
-fn skip_possible_values() {
- let app = App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .setting(AppSettings::HidePossibleValuesInHelp)
- .args(&[Arg::from_usage("-o, --opt [opt] 'some option'").possible_values(&["one", "two"]),
- Arg::from_usage("[arg1] 'some pos arg'").possible_values(&["three", "four"])]);
-
- assert!(test::compare_output(app, "test --help", SKIP_POS_VALS, false));
-}
-
-#[test]
-fn global_setting() {
- let mut app = App::new("test")
- .global_setting(AppSettings::ColoredHelp)
- .subcommand(SubCommand::with_name("subcmd"));
- app.p.propagate_settings();
- assert!(app.p
- .subcommands
- .iter()
- .filter(|s| s.p
- .meta
- .name == "subcmd")
- .next()
- .unwrap()
- .p
- .is_set(AppSettings::ColoredHelp));
-}
-
-#[test]
-fn global_settings() {
- let mut app = App::new("test")
- .global_settings(&[AppSettings::ColoredHelp, AppSettings::TrailingVarArg])
- .subcommand(SubCommand::with_name("subcmd"));
- app.p.propagate_settings();
- assert!(app.p
- .subcommands
- .iter()
- .filter(|s| s.p
- .meta
- .name == "subcmd")
- .next()
- .unwrap()
- .p
- .is_set(AppSettings::ColoredHelp));
- assert!(app.p
- .subcommands
- .iter()
- .filter(|s| s.p
- .meta
- .name == "subcmd")
- .next()
- .unwrap()
- .p
- .is_set(AppSettings::TrailingVarArg));
-
-}
-
-#[test]
-fn stop_delim_values_only_pos_follows() {
- let r = App::new("onlypos")
- .setting(AppSettings::DontDelimitTrailingValues)
- .args(&[Arg::from_usage("-f [flag] 'some opt'"),
- Arg::from_usage("[arg]... 'some arg'")])
- .get_matches_from_safe(vec!["", "--", "-f", "-g,x"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert!(!m.is_present("f"));
- assert_eq!(m.values_of("arg").unwrap().collect::<Vec<_>>(), &["-f", "-g,x"]);
-}
-
-#[test]
-fn dont_delim_values_trailingvararg() {
- let m = App::new("positional")
- .setting(AppSettings::TrailingVarArg)
- .setting(AppSettings::DontDelimitTrailingValues)
- .arg(
- Arg::from_usage("[opt]... 'some pos'"),
- )
- .get_matches_from(vec!["", "test", "--foo", "-Wl,-bar"]);
- assert!(m.is_present("opt"));
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["test", "--foo", "-Wl,-bar"]);
-}
-
-#[test]
-fn delim_values_only_pos_follows() {
- let r = App::new("onlypos")
- .args(&[Arg::from_usage("-f [flag] 'some opt'"),
- Arg::from_usage("[arg]... 'some arg'")])
- .get_matches_from_safe(vec!["", "--", "-f", "-g,x"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert!(!m.is_present("f"));
- assert_eq!(m.values_of("arg").unwrap().collect::<Vec<_>>(), &["-f", "-g,x"]);
-}
-
-#[test]
-fn delim_values_trailingvararg() {
- let m = App::new("positional")
- .setting(AppSettings::TrailingVarArg)
- .arg(
- Arg::from_usage("[opt]... 'some pos'"),
- )
- .get_matches_from(vec!["", "test", "--foo", "-Wl,-bar"]);
- assert!(m.is_present("opt"));
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["test", "--foo", "-Wl,-bar"]);
-}
-
-#[test]
-fn delim_values_only_pos_follows_with_delim() {
- let r = App::new("onlypos")
- .args(&[Arg::from_usage("-f [flag] 'some opt'"),
- Arg::from_usage("[arg]... 'some arg'").use_delimiter(true)])
- .get_matches_from_safe(vec!["", "--", "-f", "-g,x"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert!(!m.is_present("f"));
- assert_eq!(m.values_of("arg").unwrap().collect::<Vec<_>>(), &["-f", "-g", "x"]);
-}
-
-#[test]
-fn delim_values_trailingvararg_with_delim() {
- let m = App::new("positional")
- .setting(AppSettings::TrailingVarArg)
- .arg(
- Arg::from_usage("[opt]... 'some pos'").use_delimiter(true),
- )
- .get_matches_from(vec!["", "test", "--foo", "-Wl,-bar"]);
- assert!(m.is_present("opt"));
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["test", "--foo", "-Wl", "-bar"]);
-}
-
-#[test]
-fn leading_hyphen_short() {
- let res = App::new("leadhy")
- .setting(AppSettings::AllowLeadingHyphen)
- .arg(Arg::with_name("some"))
- .arg(Arg::with_name("other")
- .short("o"))
- .get_matches_from_safe(vec!["", "-bar", "-o"]);
- assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert!(m.is_present("some"));
- assert!(m.is_present("other"));
- assert_eq!(m.value_of("some").unwrap(), "-bar");
-}
-
-#[test]
-fn leading_hyphen_long() {
- let res = App::new("leadhy")
- .setting(AppSettings::AllowLeadingHyphen)
- .arg(Arg::with_name("some"))
- .arg(Arg::with_name("other")
- .short("o"))
- .get_matches_from_safe(vec!["", "--bar", "-o"]);
- assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert!(m.is_present("some"));
- assert!(m.is_present("other"));
- assert_eq!(m.value_of("some").unwrap(), "--bar");
-}
-
-#[test]
-fn leading_hyphen_opt() {
- let res = App::new("leadhy")
- .setting(AppSettings::AllowLeadingHyphen)
- .arg(Arg::with_name("some")
- .takes_value(true)
- .long("opt"))
- .arg(Arg::with_name("other")
- .short("o"))
- .get_matches_from_safe(vec!["", "--opt", "--bar", "-o"]);
- assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert!(m.is_present("some"));
- assert!(m.is_present("other"));
- assert_eq!(m.value_of("some").unwrap(), "--bar");
-}
-
-#[test]
-fn allow_negative_numbers() {
- let res = App::new("negnum")
- .setting(AppSettings::AllowNegativeNumbers)
- .arg(Arg::with_name("panum"))
- .arg(Arg::with_name("onum")
- .short("o")
- .takes_value(true))
- .get_matches_from_safe(vec!["negnum", "-20", "-o", "-1.2"]);
- assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert_eq!(m.value_of("panum").unwrap(), "-20");
- assert_eq!(m.value_of("onum").unwrap(), "-1.2");
-}
-
-#[test]
-fn allow_negative_numbers_fail() {
- let res = App::new("negnum")
- .setting(AppSettings::AllowNegativeNumbers)
- .arg(Arg::with_name("panum"))
- .arg(Arg::with_name("onum")
- .short("o")
- .takes_value(true))
- .get_matches_from_safe(vec!["negnum", "--foo", "-o", "-1.2"]);
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument)
-}
-
-#[test]
-fn leading_double_hyphen_trailingvararg() {
- let m = App::new("positional")
- .setting(AppSettings::TrailingVarArg)
- .setting(AppSettings::AllowLeadingHyphen)
- .arg(
- Arg::from_usage("[opt]... 'some pos'"),
- )
- .get_matches_from(vec!["", "--foo", "-Wl", "bar"]);
- assert!(m.is_present("opt"));
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["--foo", "-Wl", "bar"]);
-}
-
-#[test]
-fn test_unset_setting() {
- let m = App::new("unset_setting");
- assert!(m.p.is_set(AppSettings::AllowInvalidUtf8));
-
- let m = m.unset_setting(AppSettings::AllowInvalidUtf8);
- assert!(!m.p.is_set(AppSettings::AllowInvalidUtf8));
-}
-
-#[test]
-fn test_unset_settings() {
- let m = App::new("unset_settings");
- assert!(&m.p.is_set(AppSettings::AllowInvalidUtf8));
- assert!(&m.p.is_set(AppSettings::ColorAuto));
-
- let m = m.unset_settings(&[AppSettings::AllowInvalidUtf8,
- AppSettings::ColorAuto]);
- assert!(!m.p.is_set(AppSettings::AllowInvalidUtf8));
- assert!(!m.p.is_set(AppSettings::ColorAuto));
-}
-
-#[test]
-fn disable_help_subcommand() {
- let result = App::new("disablehelp")
- .setting(AppSettings::DisableHelpSubcommand)
- .subcommand(SubCommand::with_name("sub1"))
- .get_matches_from_safe(vec!["", "help"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn dont_collapse_args() {
- let app = App::new("clap-test")
- .version("v1.4.8")
- .setting(AppSettings::DontCollapseArgsInUsage)
- .args(&[
- Arg::with_name("arg1").help("some"),
- Arg::with_name("arg2").help("some"),
- Arg::with_name("arg3").help("some"),
- ]);
- assert!(test::compare_output(app, "clap-test --help", DONT_COLLAPSE_ARGS, false));
-}
-
-#[test]
-fn require_eq() {
- let app = App::new("clap-test")
- .version("v1.4.8")
- .arg(
- Arg::with_name("opt")
- .long("opt")
- .short("o")
- .required(true)
- .require_equals(true)
- .value_name("FILE")
- .help("some"),
- );
- assert!(test::compare_output(app, "clap-test --help", REQUIRE_EQUALS, false));
-}
-
-#[test]
-fn args_negate_subcommands_one_level() {
- let res = App::new("disablehelp")
- .setting(AppSettings::ArgsNegateSubcommands)
- .setting(AppSettings::SubcommandsNegateReqs)
- .arg_from_usage("<arg1> 'some arg'")
- .arg_from_usage("<arg2> 'some arg'")
- .subcommand(SubCommand::with_name("sub1")
- .subcommand(SubCommand::with_name("sub2")
- .subcommand(SubCommand::with_name("sub3"))
- )
- )
- .get_matches_from_safe(vec!["", "pickles", "sub1"]);
- assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert_eq!(m.value_of("arg2"), Some("sub1"));
-}
-
-#[test]
-fn args_negate_subcommands_two_levels() {
- let res = App::new("disablehelp")
- .global_setting(AppSettings::ArgsNegateSubcommands)
- .global_setting(AppSettings::SubcommandsNegateReqs)
- .arg_from_usage("<arg1> 'some arg'")
- .arg_from_usage("<arg2> 'some arg'")
- .subcommand(SubCommand::with_name("sub1")
- .arg_from_usage("<arg> 'some'")
- .arg_from_usage("<arg2> 'some'")
- .subcommand(SubCommand::with_name("sub2")
- .subcommand(SubCommand::with_name("sub3"))
- )
- )
- .get_matches_from_safe(vec!["", "sub1", "arg", "sub2"]);
- assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert_eq!(m.subcommand_matches("sub1").unwrap().value_of("arg2"), Some("sub2"));
-}
-
-
-#[test]
-fn propagate_vals_down() {
- let m = App::new("myprog")
- .arg(Arg::from_usage("[cmd] 'command to run'").global(true))
- .subcommand(SubCommand::with_name("foo"))
- .get_matches_from_safe(vec!["myprog", "set", "foo"]);
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
- assert_eq!(m.value_of("cmd"), Some("set"));
- let sub_m = m.subcommand_matches("foo").unwrap();
- assert_eq!(sub_m.value_of("cmd"), Some("set"));
-}
-
-#[test]
-fn allow_missing_positional() {
- let m = App::new("test")
- .setting(AppSettings::AllowMissingPositional)
- .arg(Arg::from_usage("[src] 'some file'").default_value("src"))
- .arg_from_usage("<dest> 'some file'")
- .get_matches_from_safe(vec!["test", "file"]);
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
- assert_eq!(m.value_of("src"), Some("src"));
- assert_eq!(m.value_of("dest"), Some("file"));
-}
-
-#[test]
-fn allow_missing_positional_no_default() {
- let m = App::new("test")
- .setting(AppSettings::AllowMissingPositional)
- .arg(Arg::from_usage("[src] 'some file'"))
- .arg_from_usage("<dest> 'some file'")
- .get_matches_from_safe(vec!["test", "file"]);
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
- assert_eq!(m.value_of("src"), None);
- assert_eq!(m.value_of("dest"), Some("file"));
-}
-
-#[test]
-fn missing_positional_no_hyphen() {
- let r = App::new("bench")
- .setting(AppSettings::AllowMissingPositional)
- .arg(Arg::from_usage("[BENCH] 'some bench'"))
- .arg(Arg::from_usage("[ARGS]... 'some args'"))
- .get_matches_from_safe(vec!["bench", "foo", "arg1", "arg2", "arg3"]);
- assert!(r.is_ok(), "{:?}", r.unwrap_err().kind);
-
- let m = r.unwrap();
-
- let expected_bench = Some("foo");
- let expected_args = vec!["arg1", "arg2", "arg3"];
-
- assert_eq!(m.value_of("BENCH"), expected_bench);
- assert_eq!(m.values_of("ARGS").unwrap().collect::<Vec<_>>(), &*expected_args);
-}
-
-#[test]
-fn missing_positional_hyphen() {
- let r = App::new("bench")
- .setting(AppSettings::AllowMissingPositional)
- .arg(Arg::from_usage("[BENCH] 'some bench'"))
- .arg(Arg::from_usage("[ARGS]... 'some args'"))
- .get_matches_from_safe(vec!["bench", "--", "arg1", "arg2", "arg3"]);
- assert!(r.is_ok(), "{:?}", r.unwrap_err().kind);
-
- let m = r.unwrap();
-
- let expected_bench = None;
- let expected_args = vec!["arg1", "arg2", "arg3"];
-
- assert_eq!(m.value_of("BENCH"), expected_bench);
- assert_eq!(m.values_of("ARGS").unwrap().collect::<Vec<_>>(), &*expected_args);
-}
-
-#[test]
-fn missing_positional_hyphen_far_back() {
- let r = App::new("bench")
- .setting(AppSettings::AllowMissingPositional)
- .arg(Arg::from_usage("[BENCH1] 'some bench'"))
- .arg(Arg::from_usage("[BENCH2] 'some bench'"))
- .arg(Arg::from_usage("[BENCH3] 'some bench'"))
- .arg(Arg::from_usage("[ARGS]... 'some args'"))
- .get_matches_from_safe(vec!["bench", "foo", "--", "arg1", "arg2", "arg3"]);
- assert!(r.is_ok(), "{:?}", r.unwrap_err().kind);
-
- let m = r.unwrap();
-
- let expected_bench1 = Some("foo");
- let expected_bench2 = None;
- let expected_bench3 = None;
- let expected_args = vec!["arg1", "arg2", "arg3"];
-
- assert_eq!(m.value_of("BENCH1"), expected_bench1);
- assert_eq!(m.value_of("BENCH2"), expected_bench2);
- assert_eq!(m.value_of("BENCH3"), expected_bench3);
- assert_eq!(m.values_of("ARGS").unwrap().collect::<Vec<_>>(), &*expected_args);
-}
-
-#[test]
-fn missing_positional_hyphen_req_error() {
- let r = App::new("bench")
- .setting(AppSettings::AllowMissingPositional)
- .arg(Arg::from_usage("[BENCH1] 'some bench'"))
- .arg(Arg::from_usage("<BENCH2> 'some bench'"))
- .arg(Arg::from_usage("[ARGS]... 'some args'"))
- .get_matches_from_safe(vec!["bench", "foo", "--", "arg1", "arg2", "arg3"]);
- assert!(r.is_err());
- assert_eq!(r.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn issue_1066_allow_leading_hyphen_and_unknown_args() {
- let res = App::new("prog")
- .global_setting(AppSettings::AllowLeadingHyphen)
- .arg(Arg::from_usage("--some-argument"))
- .get_matches_from_safe(vec!["prog", "hello"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn issue_1066_allow_leading_hyphen_and_unknown_args_no_vals() {
- let res = App::new("prog")
- .global_setting(AppSettings::AllowLeadingHyphen)
- .arg(Arg::from_usage("--some-argument"))
- .get_matches_from_safe(vec!["prog", "--hello"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn issue_1066_allow_leading_hyphen_and_unknown_args_option() {
- let res = App::new("prog")
- .global_setting(AppSettings::AllowLeadingHyphen)
- .arg(Arg::from_usage("--some-argument=[val]"))
- .get_matches_from_safe(vec!["prog", "-hello"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn issue_1093_allow_ext_sc() {
- let app = App::new("clap-test")
- .version("v1.4.8")
- .setting(AppSettings::AllowExternalSubcommands);
- assert!(test::compare_output(app, "clap-test --help", ALLOW_EXT_SC, false));
-}
-
-
-#[test]
-fn allow_ext_sc_when_sc_required() {
- let res = App::new("clap-test")
- .version("v1.4.8")
- .setting(AppSettings::AllowExternalSubcommands)
- .setting(AppSettings::SubcommandRequiredElseHelp)
- .get_matches_from_safe(vec!["clap-test", "external-cmd", "foo"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- match m.subcommand() {
- (name, Some(args)) => {
- assert_eq!(name, "external-cmd");
- assert_eq!(args.values_of_lossy(""), Some(vec!["foo".to_string()]));
- }
- _ => assert!(false),
- }
-}
-
-#[test]
-fn external_subcommand_looks_like_built_in() {
- let res = App::new("cargo")
- .version("1.26.0")
- .setting(AppSettings::AllowExternalSubcommands)
- .subcommand(SubCommand::with_name("install"))
- .get_matches_from_safe(vec!["cargo", "install-update", "foo"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- match m.subcommand() {
- (name, Some(args)) => {
- assert_eq!(name, "install-update");
- assert_eq!(args.values_of_lossy(""), Some(vec!["foo".to_string()]));
- }
- _ => assert!(false),
- }
-}
-
-#[test]
-fn aaos_flags() {
- // flags
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--flag 'some flag'"))
- .get_matches_from_safe(vec!["", "--flag", "--flag"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 1);
-}
-
-#[test]
-fn aaos_flags_mult() {
- // flags with multiple
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--flag... 'some flag'"))
- .get_matches_from_safe(vec!["", "--flag", "--flag", "--flag", "--flag"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 4);
-}
-
-#[test]
-fn aaos_opts() {
- // opts
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val] 'some option'"))
- .get_matches_from_safe(vec!["", "--opt=some", "--opt=other"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 1);
- assert_eq!(m.value_of("opt"), Some("other"));
-}
-
-#[test]
-fn aaos_opts_w_other_overrides() {
- // opts with other overrides
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val] 'some option'"))
- .arg(Arg::from_usage("--other [val] 'some other option'").overrides_with("opt"))
- .get_matches_from_safe(vec!["", "--opt=some", "--other=test", "--opt=other"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert!(!m.is_present("other"));
- assert_eq!(m.occurrences_of("opt"), 1);
- assert_eq!(m.value_of("opt"), Some("other"));
-}
-
-#[test]
-fn aaos_opts_w_other_overrides_rev() {
- // opts with other overrides, rev
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val] 'some option'"))
- .arg(Arg::from_usage("--other [val] 'some other option'").overrides_with("opt"))
- .get_matches_from_safe(vec!["", "--opt=some", "--opt=other", "--other=val"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(!m.is_present("opt"));
- assert!(m.is_present("other"));
- assert_eq!(m.value_of("other"), Some("val"));
-}
-
-#[test]
-fn aaos_opts_w_other_overrides_2() {
- // opts with other overrides
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val] 'some option'").overrides_with("other"))
- .arg(Arg::from_usage("--other [val] 'some other option'"))
- .get_matches_from_safe(vec!["", "--opt=some", "--other=test", "--opt=other"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert!(!m.is_present("other"));
- assert_eq!(m.occurrences_of("opt"), 1);
- assert_eq!(m.value_of("opt"), Some("other"));
-}
-
-#[test]
-fn aaos_opts_w_other_overrides_rev_2() {
- // opts with other overrides, rev
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val] 'some option'").overrides_with("other"))
- .arg(Arg::from_usage("--other [val] 'some other option'"))
- .get_matches_from_safe(vec!["", "--opt=some", "--opt=other", "--other=val"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(!m.is_present("opt"));
- assert!(m.is_present("other"));
- assert_eq!(m.value_of("other"), Some("val"));
-}
-
-#[test]
-fn aaos_opts_mult() {
- // opts with multiple
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val]... 'some option'")
- .number_of_values(1)
- .require_delimiter(true))
- .get_matches_from_safe(vec!["", "--opt=some", "--opt=other", "--opt=one,two"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 3);
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["some", "other", "one", "two"]);
-}
-
-#[test]
-fn aaos_opts_mult_req_delims() {
- // opts with multiple and require delims
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val]... 'some option'"))
- .get_matches_from_safe(vec!["", "--opt", "first", "overides", "--opt", "some", "other", "val"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 2);
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["first", "overides", "some", "other", "val"]);
-}
-
-#[test]
-fn aaos_pos_mult() {
- // opts with multiple
- let res = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("[val]... 'some pos'"))
- .get_matches_from_safe(vec!["", "some", "other", "value"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("val"));
- assert_eq!(m.occurrences_of("val"), 3);
- assert_eq!(m.values_of("val").unwrap().collect::<Vec<_>>(), &["some", "other", "value"]);
-}
-
-#[test]
-fn aaos_option_use_delim_false() {
-
- let m = App::new("posix")
- .setting(AppSettings::AllArgsOverrideSelf)
- .arg(Arg::from_usage("--opt [val] 'some option'")
- .use_delimiter(false))
- .get_matches_from(vec!["", "--opt=some,other", "--opt=one,two"]);
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 1);
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["one,two"]);
-}
diff --git a/clap/tests/arg_aliases.rs b/clap/tests/arg_aliases.rs
deleted file mode 100644
index 77bcd17..0000000
--- a/clap/tests/arg_aliases.rs
+++ /dev/null
@@ -1,200 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg, SubCommand};
-
-static SC_VISIBLE_ALIAS_HELP: &'static str = "ct-test 1.2
-Some help
-
-USAGE:
- ct test [FLAGS] [OPTIONS]
-
-FLAGS:
- -f, --flag [aliases: v_flg, flag2, flg3]
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <opt> [aliases: visible]";
-
-static SC_INVISIBLE_ALIAS_HELP: &'static str = "ct-test 1.2
-Some help
-
-USAGE:
- ct test [FLAGS] [OPTIONS]
-
-FLAGS:
- -f, --flag
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <opt> ";
-
-#[test]
-fn single_alias_of_option() {
- let a = App::new("single_alias")
- .arg(Arg::with_name("alias")
- .long("alias")
- .takes_value(true)
- .help("single alias")
- .alias("new-opt"))
- .get_matches_from_safe(vec![
- "", "--new-opt", "cool"
- ]);
- assert!(a.is_ok());
- let a = a.unwrap();
- assert!(a.is_present("alias"));
- assert_eq!(a.value_of("alias").unwrap(), "cool");
-}
-
-#[test]
-fn multiple_aliases_of_option() {
- let a = App::new("multiple_aliases")
- .arg(Arg::with_name("aliases")
- .long("aliases")
- .takes_value(true)
- .help("multiple aliases")
- .aliases(&[
- "alias1",
- "alias2",
- "alias3"
- ]));
- let long = a.clone().get_matches_from_safe(vec![
- "", "--aliases", "value"
- ]);
- assert!(long.is_ok());
- let long = long.unwrap();
-
- let als1 = a.clone().get_matches_from_safe(vec![
- "", "--alias1", "value"
- ]);
- assert!(als1.is_ok());
- let als1 = als1.unwrap();
-
- let als2 = a.clone().get_matches_from_safe(vec![
- "", "--alias2", "value"
- ]);
- assert!(als2.is_ok());
- let als2 = als2.unwrap();
-
- let als3 = a.clone().get_matches_from_safe(vec![
- "", "--alias3", "value"
- ]);
- assert!(als3.is_ok());
- let als3 = als3.unwrap();
-
- assert!(long.is_present("aliases"));
- assert!(als1.is_present("aliases"));
- assert!(als2.is_present("aliases"));
- assert!(als3.is_present("aliases"));
- assert_eq!(long.value_of("aliases").unwrap(), "value");
- assert_eq!(als1.value_of("aliases").unwrap(), "value");
- assert_eq!(als2.value_of("aliases").unwrap(), "value");
- assert_eq!(als3.value_of("aliases").unwrap(), "value");
-}
-
-#[test]
-fn single_alias_of_flag() {
- let a = App::new("test")
- .arg(Arg::with_name("flag")
- .long("flag")
- .alias("alias"))
- .get_matches_from_safe(vec!["", "--alias"]);
- assert!(a.is_ok());
- let a = a.unwrap();
- assert!(a.is_present("flag"));
-}
-
-#[test]
-fn multiple_aliases_of_flag() {
- let a = App::new("test")
- .arg(Arg::with_name("flag")
- .long("flag")
- .aliases(&["invisible",
- "set", "of",
- "cool", "aliases"]));
-
- let flag = a.clone().get_matches_from_safe(vec!["", "--flag"]);
- assert!(flag.is_ok());
- let flag = flag.unwrap();
-
- let inv = a.clone().get_matches_from_safe(vec!["", "--invisible"]);
- assert!(inv.is_ok());
- let inv = inv.unwrap();
-
- let cool = a.clone().get_matches_from_safe(vec!["", "--cool"]);
- assert!(cool.is_ok());
- let cool = cool.unwrap();
-
- let als = a.clone().get_matches_from_safe(vec!["", "--aliases"]);
- assert!(als.is_ok());
- let als = als.unwrap();
-
- assert!(flag.is_present("flag"));
- assert!(inv.is_present("flag"));
- assert!(cool.is_present("flag"));
- assert!(als.is_present("flag"));
-}
-
-#[test]
-fn alias_on_a_subcommand_option() {
- let m = App::new("test")
- .subcommand(SubCommand::with_name("some")
- .arg(Arg::with_name("test")
- .short("t")
- .long("test")
- .takes_value(true)
- .alias("opt")
- .help("testing testing")))
- .arg(Arg::with_name("other")
- .long("other")
- .aliases(&["o1", "o2", "o3"]))
- .get_matches_from(vec![
- "test", "some", "--opt", "awesome"
- ]);
-
- assert!(m.subcommand_matches("some").is_some());
- let sub_m = m.subcommand_matches("some").unwrap();
- assert!(sub_m.is_present("test"));
- assert_eq!(sub_m.value_of("test").unwrap(), "awesome");
-}
-
-#[test]
-fn invisible_arg_aliases_help_output() {
- let app = App::new("ct")
- .author("Salim Afiune")
- .subcommand(SubCommand::with_name("test")
- .about("Some help")
- .version("1.2")
- .arg(Arg::with_name("opt")
- .long("opt")
- .short("o")
- .takes_value(true)
- .aliases(&["invisible", "als1", "more"]))
- .arg(Arg::from_usage("-f, --flag")
- .aliases(&["invisible", "flg1", "anyway"])));
- assert!(test::compare_output(app, "ct test --help", SC_INVISIBLE_ALIAS_HELP, false));
-}
-
-#[test]
-fn visible_arg_aliases_help_output() {
- let app = App::new("ct")
- .author("Salim Afiune")
- .subcommand(SubCommand::with_name("test")
- .about("Some help")
- .version("1.2")
- .arg(Arg::with_name("opt")
- .long("opt")
- .short("o")
- .takes_value(true)
- .alias("invisible")
- .visible_alias("visible"))
- .arg(Arg::with_name("flg")
- .long("flag")
- .short("f")
- .visible_aliases(&["v_flg", "flag2", "flg3"])));
- assert!(test::compare_output(app, "ct test --help", SC_VISIBLE_ALIAS_HELP, false));
-}
diff --git a/clap/tests/borrowed.rs b/clap/tests/borrowed.rs
deleted file mode 100644
index e7a184b..0000000
--- a/clap/tests/borrowed.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-use clap::{App, Arg, SubCommand};
-
-include!("../clap-test.rs");
-
-#[test]
-fn borrowed_args() {
- let arg = Arg::with_name("some").short("s").long("some").help("other help");
- let arg2 = Arg::with_name("some2").short("S").long("some-thing").help("other help");
- let result = App::new("sub_command_negate")
- .arg(Arg::with_name("test").index(1))
- .arg(&arg)
- .arg(&arg2)
- .subcommand(SubCommand::with_name("sub1").arg(&arg))
- .get_matches_from_safe(vec!["prog"]);
- assert!(result.is_ok());
-}
diff --git a/clap/tests/completions.rs b/clap/tests/completions.rs
deleted file mode 100644
index 24409ad..0000000
--- a/clap/tests/completions.rs
+++ /dev/null
@@ -1,883 +0,0 @@
-extern crate regex;
-extern crate clap;
-
-use clap::{App, Arg, SubCommand, Shell};
-use regex::Regex;
-
-static BASH: &'static str = r#"_myapp() {
- local i cur prev opts cmds
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- cmd=""
- opts=""
-
- for i in ${COMP_WORDS[@]}
- do
- case "${i}" in
- myapp)
- cmd="myapp"
- ;;
-
- help)
- cmd+="__help"
- ;;
- test)
- cmd+="__test"
- ;;
- *)
- ;;
- esac
- done
-
- case "${cmd}" in
- myapp)
- opts=" -h -V --help --version <file> test help"
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
-
- myapp__help)
- opts=" -h -V --help --version "
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
- myapp__test)
- opts=" -h -V --help --version --case "
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- --case)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
- esac
-}
-
-complete -F _myapp -o bashdefault -o default myapp
-"#;
-
-static ZSH: &'static str = r#"#compdef myapp
-
-autoload -U is-at-least
-
-_myapp() {
- typeset -A opt_args
- typeset -a _arguments_options
- local ret=1
-
- if is-at-least 5.2; then
- _arguments_options=(-s -S -C)
- else
- _arguments_options=(-s -C)
- fi
-
- local context curcontext="$curcontext" state line
- _arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::file -- some input file:_files' \
-":: :_myapp_commands" \
-"*::: :->myapp" \
-&& ret=0
- case $state in
- (myapp)
- words=($line[2] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:myapp-command-$line[2]:"
- case $line[2] in
- (test)
-_arguments "${_arguments_options[@]}" \
-'--case=[the case to test]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-}
-
-(( $+functions[_myapp_commands] )) ||
-_myapp_commands() {
- local commands; commands=(
- "test:tests things" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'myapp commands' commands "$@"
-}
-(( $+functions[_myapp__help_commands] )) ||
-_myapp__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'myapp help commands' commands "$@"
-}
-(( $+functions[_myapp__test_commands] )) ||
-_myapp__test_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'myapp test commands' commands "$@"
-}
-
-_myapp "$@""#;
-
-static FISH: &'static str = r#"complete -c myapp -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
-complete -c myapp -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
-complete -c myapp -n "__fish_use_subcommand" -f -a "test" -d 'tests things'
-complete -c myapp -n "__fish_use_subcommand" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
-complete -c myapp -n "__fish_seen_subcommand_from test" -l case -d 'the case to test'
-complete -c myapp -n "__fish_seen_subcommand_from test" -s h -l help -d 'Prints help information'
-complete -c myapp -n "__fish_seen_subcommand_from test" -s V -l version -d 'Prints version information'
-complete -c myapp -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
-complete -c myapp -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
-"#;
-
-static POWERSHELL: &'static str = r#"
-using namespace System.Management.Automation
-using namespace System.Management.Automation.Language
-
-Register-ArgumentCompleter -Native -CommandName 'my_app' -ScriptBlock {
- param($wordToComplete, $commandAst, $cursorPosition)
-
- $commandElements = $commandAst.CommandElements
- $command = @(
- 'my_app'
- for ($i = 1; $i -lt $commandElements.Count; $i++) {
- $element = $commandElements[$i]
- if ($element -isnot [StringConstantExpressionAst] -or
- $element.StringConstantType -ne [StringConstantType]::BareWord -or
- $element.Value.StartsWith('-')) {
- break
- }
- $element.Value
- }) -join ';'
-
- $completions = @(switch ($command) {
- 'my_app' {
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'tests things')
- [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Prints this message or the help of the given subcommand(s)')
- break
- }
- 'my_app;test' {
- [CompletionResult]::new('--case', 'case', [CompletionResultType]::ParameterName, 'the case to test')
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- break
- }
- 'my_app;help' {
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- break
- }
- })
-
- $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
- Sort-Object -Property ListItemText
-}
-"#;
-
-static ELVISH: &'static str = r#"
-edit:completion:arg-completer[my_app] = [@words]{
- fn spaces [n]{
- repeat $n ' ' | joins ''
- }
- fn cand [text desc]{
- edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
- }
- command = 'my_app'
- for word $words[1:-1] {
- if (has-prefix $word '-') {
- break
- }
- command = $command';'$word
- }
- completions = [
- &'my_app'= {
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- cand test 'tests things'
- cand help 'Prints this message or the help of the given subcommand(s)'
- }
- &'my_app;test'= {
- cand --case 'the case to test'
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- }
- &'my_app;help'= {
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- }
- ]
- $completions[$command]
-}
-"#;
-
-static ELVISH_SPECIAL_CMDS: &'static str = r#"
-edit:completion:arg-completer[my_app] = [@words]{
- fn spaces [n]{
- repeat $n ' ' | joins ''
- }
- fn cand [text desc]{
- edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
- }
- command = 'my_app'
- for word $words[1:-1] {
- if (has-prefix $word '-') {
- break
- }
- command = $command';'$word
- }
- completions = [
- &'my_app'= {
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- cand test 'tests things'
- cand some_cmd 'tests other things'
- cand some-cmd-with-hypens 'some-cmd-with-hypens'
- cand help 'Prints this message or the help of the given subcommand(s)'
- }
- &'my_app;test'= {
- cand --case 'the case to test'
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- }
- &'my_app;some_cmd'= {
- cand --config 'the other case to test'
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- }
- &'my_app;some-cmd-with-hypens'= {
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- }
- &'my_app;help'= {
- cand -h 'Prints help information'
- cand --help 'Prints help information'
- cand -V 'Prints version information'
- cand --version 'Prints version information'
- }
- ]
- $completions[$command]
-}
-"#;
-
-static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
-using namespace System.Management.Automation
-using namespace System.Management.Automation.Language
-
-Register-ArgumentCompleter -Native -CommandName 'my_app' -ScriptBlock {
- param($wordToComplete, $commandAst, $cursorPosition)
-
- $commandElements = $commandAst.CommandElements
- $command = @(
- 'my_app'
- for ($i = 1; $i -lt $commandElements.Count; $i++) {
- $element = $commandElements[$i]
- if ($element -isnot [StringConstantExpressionAst] -or
- $element.StringConstantType -ne [StringConstantType]::BareWord -or
- $element.Value.StartsWith('-')) {
- break
- }
- $element.Value
- }) -join ';'
-
- $completions = @(switch ($command) {
- 'my_app' {
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('test', 'test', [CompletionResultType]::ParameterValue, 'tests things')
- [CompletionResult]::new('some_cmd', 'some_cmd', [CompletionResultType]::ParameterValue, 'tests other things')
- [CompletionResult]::new('some-cmd-with-hypens', 'some-cmd-with-hypens', [CompletionResultType]::ParameterValue, 'some-cmd-with-hypens')
- [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Prints this message or the help of the given subcommand(s)')
- break
- }
- 'my_app;test' {
- [CompletionResult]::new('--case', 'case', [CompletionResultType]::ParameterName, 'the case to test')
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- break
- }
- 'my_app;some_cmd' {
- [CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'the other case to test')
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- break
- }
- 'my_app;some-cmd-with-hypens' {
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- break
- }
- 'my_app;help' {
- [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
- [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
- [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
- break
- }
- })
-
- $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
- Sort-Object -Property ListItemText
-}
-"#;
-
-static ZSH_SPECIAL_CMDS: &'static str = r#"#compdef my_app
-
-autoload -U is-at-least
-
-_my_app() {
- typeset -A opt_args
- typeset -a _arguments_options
- local ret=1
-
- if is-at-least 5.2; then
- _arguments_options=(-s -S -C)
- else
- _arguments_options=(-s -C)
- fi
-
- local context curcontext="$curcontext" state line
- _arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-'::file -- some input file:_files' \
-":: :_my_app_commands" \
-"*::: :->my_app" \
-&& ret=0
- case $state in
- (my_app)
- words=($line[2] "${words[@]}")
- (( CURRENT += 1 ))
- curcontext="${curcontext%:*:*}:my_app-command-$line[2]:"
- case $line[2] in
- (test)
-_arguments "${_arguments_options[@]}" \
-'--case=[the case to test]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(some_cmd)
-_arguments "${_arguments_options[@]}" \
-'--config=[the other case to test]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(some-cmd-with-hypens)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
-(help)
-_arguments "${_arguments_options[@]}" \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-;;
- esac
- ;;
-esac
-}
-
-(( $+functions[_my_app_commands] )) ||
-_my_app_commands() {
- local commands; commands=(
- "test:tests things" \
-"some_cmd:tests other things" \
-"some-cmd-with-hypens:" \
-"help:Prints this message or the help of the given subcommand(s)" \
- )
- _describe -t commands 'my_app commands' commands "$@"
-}
-(( $+functions[_my_app__help_commands] )) ||
-_my_app__help_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'my_app help commands' commands "$@"
-}
-(( $+functions[_my_app__some-cmd-with-hypens_commands] )) ||
-_my_app__some-cmd-with-hypens_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'my_app some-cmd-with-hypens commands' commands "$@"
-}
-(( $+functions[_my_app__some_cmd_commands] )) ||
-_my_app__some_cmd_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'my_app some_cmd commands' commands "$@"
-}
-(( $+functions[_my_app__test_commands] )) ||
-_my_app__test_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'my_app test commands' commands "$@"
-}
-
-_my_app "$@""#;
-
-static FISH_SPECIAL_CMDS: &'static str = r#"complete -c my_app -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
-complete -c my_app -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
-complete -c my_app -n "__fish_use_subcommand" -f -a "test" -d 'tests things'
-complete -c my_app -n "__fish_use_subcommand" -f -a "some_cmd" -d 'tests other things'
-complete -c my_app -n "__fish_use_subcommand" -f -a "some-cmd-with-hypens"
-complete -c my_app -n "__fish_use_subcommand" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
-complete -c my_app -n "__fish_seen_subcommand_from test" -l case -d 'the case to test'
-complete -c my_app -n "__fish_seen_subcommand_from test" -s h -l help -d 'Prints help information'
-complete -c my_app -n "__fish_seen_subcommand_from test" -s V -l version -d 'Prints version information'
-complete -c my_app -n "__fish_seen_subcommand_from some_cmd" -l config -d 'the other case to test'
-complete -c my_app -n "__fish_seen_subcommand_from some_cmd" -s h -l help -d 'Prints help information'
-complete -c my_app -n "__fish_seen_subcommand_from some_cmd" -s V -l version -d 'Prints version information'
-complete -c my_app -n "__fish_seen_subcommand_from some-cmd-with-hypens" -s h -l help -d 'Prints help information'
-complete -c my_app -n "__fish_seen_subcommand_from some-cmd-with-hypens" -s V -l version -d 'Prints version information'
-complete -c my_app -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
-complete -c my_app -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
-"#;
-
-static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() {
- local i cur prev opts cmds
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- cmd=""
- opts=""
-
- for i in ${COMP_WORDS[@]}
- do
- case "${i}" in
- my_app)
- cmd="my_app"
- ;;
-
- help)
- cmd+="__help"
- ;;
- some-cmd-with-hypens)
- cmd+="__some__cmd__with__hypens"
- ;;
- some_cmd)
- cmd+="__some_cmd"
- ;;
- test)
- cmd+="__test"
- ;;
- *)
- ;;
- esac
- done
-
- case "${cmd}" in
- my_app)
- opts=" -h -V --help --version <file> test some_cmd some-cmd-with-hypens help"
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
-
- my_app__help)
- opts=" -h -V --help --version "
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
- my_app__some__cmd__with__hypens)
- opts=" -h -V --help --version "
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
- my_app__some_cmd)
- opts=" -h -V --help --version --config "
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- --config)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
- my_app__test)
- opts=" -h -V --help --version --case "
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- fi
- case "${prev}" in
-
- --case)
- COMPREPLY=($(compgen -f "${cur}"))
- return 0
- ;;
- *)
- COMPREPLY=()
- ;;
- esac
- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
- return 0
- ;;
- esac
-}
-
-complete -F _my_app -o bashdefault -o default my_app
-"#;
-
-static FISH_SPECIAL_HELP: &'static str = r#"complete -c my_app -n "__fish_use_subcommand" -l single-quotes -d 'Can be \'always\', \'auto\', or \'never\''
-complete -c my_app -n "__fish_use_subcommand" -l double-quotes -d 'Can be "always", "auto", or "never"'
-complete -c my_app -n "__fish_use_subcommand" -l backticks -d 'For more information see `echo test`'
-complete -c my_app -n "__fish_use_subcommand" -l backslash -d 'Avoid \'\\n\''
-complete -c my_app -n "__fish_use_subcommand" -l brackets -d 'List packages [filter]'
-complete -c my_app -n "__fish_use_subcommand" -l expansions -d 'Execute the shell command with $SHELL'
-complete -c my_app -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
-complete -c my_app -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
-"#;
-
-static ZSH_SPECIAL_HELP: &'static str = r#"#compdef my_app
-
-autoload -U is-at-least
-
-_my_app() {
- typeset -A opt_args
- typeset -a _arguments_options
- local ret=1
-
- if is-at-least 5.2; then
- _arguments_options=(-s -S -C)
- else
- _arguments_options=(-s -C)
- fi
-
- local context curcontext="$curcontext" state line
- _arguments "${_arguments_options[@]}" \
-'--single-quotes[Can be '\''always'\'', '\''auto'\'', or '\''never'\'']' \
-'--double-quotes[Can be "always", "auto", or "never"]' \
-'--backticks[For more information see `echo test`]' \
-'--backslash[Avoid '\''\\n'\'']' \
-'--brackets[List packages \[filter\]]' \
-'--expansions[Execute the shell command with $SHELL]' \
-'-h[Prints help information]' \
-'--help[Prints help information]' \
-'-V[Prints version information]' \
-'--version[Prints version information]' \
-&& ret=0
-
-}
-
-(( $+functions[_my_app_commands] )) ||
-_my_app_commands() {
- local commands; commands=(
-
- )
- _describe -t commands 'my_app commands' commands "$@"
-}
-
-_my_app "$@""#;
-
-fn compare(left: &str, right: &str) -> bool {
- let b = left == right;
- if !b {
- let re = Regex::new(" ").unwrap();
- println!();
- println!("--> left");
- // println!("{}", left);
- println!("{}", re.replace_all(left, "\u{2022}"));
- println!("--> right");
- println!("{}", re.replace_all(right, "\u{2022}"));
- // println!("{}", right);
- println!("--")
- }
- b
-}
-
-fn build_app() -> App<'static, 'static> { build_app_with_name("myapp") }
-
-fn build_app_with_name(s: &'static str) -> App<'static, 'static> {
- App::new(s)
- .about("Tests completions")
- .arg(Arg::with_name("file").help("some input file"))
- .subcommand(SubCommand::with_name("test")
- .about("tests things")
- .arg(Arg::with_name("case")
- .long("case")
- .takes_value(true)
- .help("the case to test")))
-}
-
-fn build_app_special_commands() -> App<'static, 'static> {
- build_app_with_name("my_app")
- .subcommand(SubCommand::with_name("some_cmd")
- .about("tests other things")
- .arg(Arg::with_name("config")
- .long("--config")
- .takes_value(true)
- .help("the other case to test")))
- .subcommand(SubCommand::with_name("some-cmd-with-hypens"))
-}
-
-fn build_app_special_help() -> App<'static, 'static> {
- App::new("my_app")
- .arg(Arg::with_name("single-quotes")
- .long("single-quotes")
- .help("Can be 'always', 'auto', or 'never'"))
- .arg(Arg::with_name("double-quotes")
- .long("double-quotes")
- .help("Can be \"always\", \"auto\", or \"never\""))
- .arg(Arg::with_name("backticks")
- .long("backticks")
- .help("For more information see `echo test`"))
- .arg(Arg::with_name("backslash")
- .long("backslash")
- .help("Avoid '\\n'"))
- .arg(Arg::with_name("brackets")
- .long("brackets")
- .help("List packages [filter]"))
- .arg(Arg::with_name("expansions")
- .long("expansions")
- .help("Execute the shell command with $SHELL"))
-}
-
-#[test]
-fn bash() {
- let mut app = build_app();
- let mut buf = vec![];
- app.gen_completions_to("myapp", Shell::Bash, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, BASH));
-}
-
-#[test]
-fn zsh() {
- let mut app = build_app();
- let mut buf = vec![];
- app.gen_completions_to("myapp", Shell::Zsh, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, ZSH));
-}
-
-#[test]
-fn fish() {
- let mut app = build_app();
- let mut buf = vec![];
- app.gen_completions_to("myapp", Shell::Fish, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, FISH));
-}
-
-#[test]
-fn powershell() {
- let mut app = build_app();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::PowerShell, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, POWERSHELL));
-}
-
-#[test]
-fn elvish() {
- let mut app = build_app();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Elvish, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, ELVISH));
-}
-
-#[test]
-fn elvish_with_special_commands() {
- let mut app = build_app_special_commands();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Elvish, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, ELVISH_SPECIAL_CMDS));
-}
-
-#[test]
-fn powershell_with_special_commands() {
- let mut app = build_app_special_commands();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::PowerShell, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, POWERSHELL_SPECIAL_CMDS));
-}
-
-#[test]
-fn bash_with_special_commands() {
- let mut app = build_app_special_commands();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Bash, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, BASH_SPECIAL_CMDS));
-}
-
-#[test]
-fn fish_with_special_commands() {
- let mut app = build_app_special_commands();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Fish, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, FISH_SPECIAL_CMDS));
-}
-
-#[test]
-fn zsh_with_special_commands() {
- let mut app = build_app_special_commands();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Zsh, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, ZSH_SPECIAL_CMDS));
-}
-
-#[test]
-fn fish_with_special_help() {
- let mut app = build_app_special_help();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Fish, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, FISH_SPECIAL_HELP));
-}
-
-#[test]
-fn zsh_with_special_help() {
- let mut app = build_app_special_help();
- let mut buf = vec![];
- app.gen_completions_to("my_app", Shell::Zsh, &mut buf);
- let string = String::from_utf8(buf).unwrap();
-
- assert!(compare(&*string, ZSH_SPECIAL_HELP));
-}
diff --git a/clap/tests/conflicts.rs b/clap/tests/conflicts.rs
deleted file mode 100644
index 72a9e05..0000000
--- a/clap/tests/conflicts.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg, ErrorKind, ArgGroup};
-
-static CONFLICT_ERR: &'static str = "error: The argument '-F' cannot be used with '--flag'
-
-USAGE:
- clap-test <positional> <positional2> --flag --long-option-2 <option2>
-
-For more information try --help";
-
-static CONFLICT_ERR_REV: &'static str = "error: The argument '--flag' cannot be used with '-F'
-
-USAGE:
- clap-test <positional> <positional2> -F --long-option-2 <option2>
-
-For more information try --help";
-
-#[test]
-fn flag_conflict() {
- let result = App::new("flag_conflict")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("other"))
- .arg(Arg::from_usage("-o, --other 'some flag'"))
- .get_matches_from_safe(vec!["myprog", "-f", "-o"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
-
-#[test]
-fn flag_conflict_2() {
- let result = App::new("flag_conflict")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("other"))
- .arg(Arg::from_usage("-o, --other 'some flag'"))
- .get_matches_from_safe(vec!["myprog", "-o", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
-
-#[test]
-fn group_conflict() {
- let result = App::new("group_conflict")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("gr"))
- .group(ArgGroup::with_name("gr")
- .required(true)
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from_safe(vec!["myprog", "--other", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
-
-#[test]
-fn group_conflict_2() {
- let result = App::new("group_conflict")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("gr"))
- .group(ArgGroup::with_name("gr")
- .required(true)
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from_safe(vec!["myprog", "-f", "--some"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
-
-#[test]
-fn conflict_output() {
- test::compare_output(test::complex_app(), "clap-test val1 --flag --long-option-2 val2 -F", CONFLICT_ERR, true);
-}
-
-#[test]
-fn conflict_output_rev() {
- test::compare_output(test::complex_app(), "clap-test val1 -F --long-option-2 val2 --flag", CONFLICT_ERR_REV, true);
-}
-
-#[test]
-fn conflict_with_unused_default_value() {
- let result = App::new("conflict")
- .arg(Arg::from_usage("-o, --opt=[opt] 'some opt'")
- .default_value("default"))
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("opt"))
- .get_matches_from_safe(vec!["myprog", "-f"]);
- assert!(result.is_ok());
- let m = result.unwrap();
- assert_eq!(m.value_of("opt"), Some("default"));
- assert!(m.is_present("flag"));
-}
diff --git a/clap/tests/default_vals.rs b/clap/tests/default_vals.rs
deleted file mode 100644
index 0dfd3c8..0000000
--- a/clap/tests/default_vals.rs
+++ /dev/null
@@ -1,498 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg, ErrorKind};
-
-#[test]
-fn opts() {
- let r = App::new("df")
- .arg(
- Arg::from_usage("-o [opt] 'some opt'").default_value("default"),
- )
- .get_matches_from_safe(vec![""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.value_of("o").unwrap(), "default");
-}
-
-#[test]
-fn opt_user_override() {
- let r = App::new("df")
- .arg(
- Arg::from_usage("--opt [FILE] 'some arg'").default_value("default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.value_of("opt").unwrap(), "value");
-}
-
-#[test]
-fn positionals() {
- let r = App::new("df")
- .arg(Arg::from_usage("[arg] 'some opt'").default_value("default"))
- .get_matches_from_safe(vec![""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn positional_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("[arg] 'some arg'").default_value("default"))
- .get_matches_from_safe(vec!["", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "value");
-}
-
-// OsStr Default Values
-
-#[test]
-fn osstr_opts() {
- use std::ffi::OsStr;
- let expected = OsStr::new("default");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("-o [opt] 'some opt'").default_value_os(expected),
- )
- .get_matches_from_safe(vec![""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.value_of("o").unwrap(), expected);
-}
-
-#[test]
-fn osstr_opt_user_override() {
- use std::ffi::OsStr;
- let default = OsStr::new("default");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("--opt [FILE] 'some arg'").default_value_os(default),
- )
- .get_matches_from_safe(vec!["", "--opt", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.value_of("opt").unwrap(), "value");
-}
-
-#[test]
-fn osstr_positionals() {
- use std::ffi::OsStr;
- let expected = OsStr::new("default");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'").default_value_os(expected),
- )
- .get_matches_from_safe(vec![""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), expected);
-}
-
-#[test]
-fn osstr_positional_user_override() {
- use std::ffi::OsStr;
- let default = OsStr::new("default");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some arg'").default_value_os(default),
- )
- .get_matches_from_safe(vec!["", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "value");
-}
-
-// --- Default if arg is present
-
-#[test]
-fn default_if_arg_present_no_default() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("[arg] 'some arg'").default_value_if(
- "opt",
- None,
- "default",
- ))
- .get_matches_from_safe(vec!["", "--opt", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn default_if_arg_present_no_default_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("[arg] 'some arg'").default_value_if(
- "opt",
- None,
- "default",
- ))
- .get_matches_from_safe(vec!["", "--opt", "some", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-#[test]
-fn default_if_arg_present_no_arg_with_default() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", None, "default"),
- )
- .get_matches_from_safe(vec![""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "first");
-}
-
-#[test]
-fn default_if_arg_present_with_default() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", None, "default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn default_if_arg_present_with_default_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", None, "default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "some", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-#[test]
-fn default_if_arg_present_no_arg_with_default_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", None, "default"),
- )
- .get_matches_from_safe(vec!["", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-// Conditional Default Values
-
-#[test]
-fn default_if_arg_present_with_value_no_default() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("[arg] 'some arg'").default_value_if(
- "opt",
- Some("value"),
- "default",
- ))
- .get_matches_from_safe(vec!["", "--opt", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn default_if_arg_present_with_value_no_default_fail() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("[arg] 'some arg'").default_value_if(
- "opt",
- Some("value"),
- "default",
- ))
- .get_matches_from_safe(vec!["", "--opt", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(!m.is_present("arg"));
- //assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn default_if_arg_present_with_value_no_default_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("[arg] 'some arg'").default_value_if(
- "opt",
- Some("some"),
- "default",
- ))
- .get_matches_from_safe(vec!["", "--opt", "some", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-#[test]
-fn default_if_arg_present_with_value_no_arg_with_default() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", Some("some"), "default"),
- )
- .get_matches_from_safe(vec![""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "first");
-}
-
-#[test]
-fn default_if_arg_present_with_value_no_arg_with_default_fail() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", Some("some"), "default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "first");
-}
-
-#[test]
-fn default_if_arg_present_with_value_with_default() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", Some("some"), "default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn default_if_arg_present_with_value_with_default_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", Some("some"), "default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "some", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-#[test]
-fn default_if_arg_present_no_arg_with_value_with_default_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", Some("some"), "default"),
- )
- .get_matches_from_safe(vec!["", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-#[test]
-fn default_if_arg_present_no_arg_with_value_with_default_user_override_fail() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_if("opt", Some("some"), "default"),
- )
- .get_matches_from_safe(vec!["", "--opt", "value", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "other");
-}
-
-// Multiple conditions
-
-#[test]
-fn default_ifs_arg_present() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("--flag 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_ifs(&[("opt", Some("some"), "default"), ("flag", None, "flg")]),
- )
- .get_matches_from_safe(vec!["", "--flag"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "flg");
-}
-
-#[test]
-fn default_ifs_arg_present_user_override() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("--flag 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_ifs(&[("opt", Some("some"), "default"), ("flag", None, "flg")]),
- )
- .get_matches_from_safe(vec!["", "--flag", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "value");
-}
-
-#[test]
-fn default_ifs_arg_present_order() {
- let r = App::new("df")
- .arg(Arg::from_usage("--opt [FILE] 'some arg'"))
- .arg(Arg::from_usage("--flag 'some arg'"))
- .arg(
- Arg::from_usage("[arg] 'some arg'")
- .default_value("first")
- .default_value_ifs(&[("opt", Some("some"), "default"), ("flag", None, "flg")]),
- )
- .get_matches_from_safe(vec!["", "--opt=some", "--flag"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.value_of("arg").unwrap(), "default");
-}
-
-#[test]
-fn conditional_reqs_fail() {
- let m = App::new("Test app")
- .version("1.0")
- .author("F0x06")
- .about("Arg test")
- .arg(
- Arg::with_name("target")
- .takes_value(true)
- .default_value("file")
- .possible_values(&["file", "stdout"])
- .long("target"),
- )
- .arg(
- Arg::with_name("input")
- .takes_value(true)
- .required(true)
- .long("input"),
- )
- .arg(
- Arg::with_name("output")
- .takes_value(true)
- .required_if("target", "file")
- .long("output"),
- )
- .get_matches_from_safe(vec!["test", "--input", "some"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn conditional_reqs_pass() {
- let m = App::new("Test app")
- .version("1.0")
- .author("F0x06")
- .about("Arg test")
- .arg(
- Arg::with_name("target")
- .takes_value(true)
- .default_value("file")
- .possible_values(&["file", "stdout"])
- .long("target"),
- )
- .arg(
- Arg::with_name("input")
- .takes_value(true)
- .required(true)
- .long("input"),
- )
- .arg(
- Arg::with_name("output")
- .takes_value(true)
- .required_if("target", "file")
- .long("output"),
- )
- .get_matches_from_safe(vec!["test", "--input", "some", "--output", "other"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
- assert_eq!(m.value_of("output"), Some("other"));
- assert_eq!(m.value_of("input"), Some("some"));
-}
-
-#[test]
-fn issue_1050_num_vals_and_defaults() {
- let res = App::new("hello")
- .arg(
- Arg::with_name("exit-code")
- .long("exit-code")
- .required(true)
- .takes_value(true)
- .number_of_values(1)
- .default_value("0"),
- )
- .get_matches_from_safe(vec!["hello", "--exit-code=1"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert_eq!(m.value_of("exit-code"), Some("1"));
-}
diff --git a/clap/tests/delimiters.rs b/clap/tests/delimiters.rs
deleted file mode 100644
index d5b60b9..0000000
--- a/clap/tests/delimiters.rs
+++ /dev/null
@@ -1,139 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-#[test]
-fn opt_default_no_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .long("option")
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "--option", "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn opt_eq_no_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .long("option")
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "--option=val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn opt_s_eq_no_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "-o=val1,val2,val3",
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn opt_s_default_no_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1,val2,val3",
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn opt_s_no_space_no_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn opt_s_no_space_mult_no_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .short("o")
- .multiple(true)
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn opt_eq_mult_def_delim() {
- let m = App::new("no_delim")
- .arg(Arg::with_name("option")
- .long("opt")
- .multiple(true)
- .use_delimiter(true)
- .takes_value(true))
- .get_matches_from_safe(vec![
- "",
- "--opt=val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), &["val1", "val2", "val3"]);
-}
diff --git a/clap/tests/derive_order.rs b/clap/tests/derive_order.rs
deleted file mode 100644
index b30c8ad..0000000
--- a/clap/tests/derive_order.rs
+++ /dev/null
@@ -1,245 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-use std::str;
-
-use clap::{App, Arg, SubCommand, AppSettings};
-
-include!("../clap-test.rs");
-
-static NO_DERIVE_ORDER: &'static str = "test 1.2
-
-USAGE:
- test [FLAGS] [OPTIONS]
-
-FLAGS:
- --flag_a second flag
- --flag_b first flag
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- --option_a <option_a> second option
- --option_b <option_b> first option";
-
-static DERIVE_ORDER: &'static str = "test 1.2
-
-USAGE:
- test [FLAGS] [OPTIONS]
-
-FLAGS:
- --flag_b first flag
- --flag_a second flag
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- --option_b <option_b> first option
- --option_a <option_a> second option";
-
-static UNIFIED_HELP: &'static str = "test 1.2
-
-USAGE:
- test [OPTIONS]
-
-OPTIONS:
- --flag_a second flag
- --flag_b first flag
- -h, --help Prints help information
- --option_a <option_a> second option
- --option_b <option_b> first option
- -V, --version Prints version information";
-
-static UNIFIED_HELP_AND_DERIVE: &'static str = "test 1.2
-
-USAGE:
- test [OPTIONS]
-
-OPTIONS:
- --flag_b first flag
- --option_b <option_b> first option
- --flag_a second flag
- --option_a <option_a> second option
- -h, --help Prints help information
- -V, --version Prints version information";
-
-static DERIVE_ORDER_SC_PROP: &'static str = "test-sub 1.2
-
-USAGE:
- test sub [FLAGS] [OPTIONS]
-
-FLAGS:
- --flag_b first flag
- --flag_a second flag
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- --option_b <option_b> first option
- --option_a <option_a> second option";
-
-static UNIFIED_SC_PROP: &'static str = "test-sub 1.2
-
-USAGE:
- test sub [OPTIONS]
-
-OPTIONS:
- --flag_a second flag
- --flag_b first flag
- -h, --help Prints help information
- --option_a <option_a> second option
- --option_b <option_b> first option
- -V, --version Prints version information";
-
-static UNIFIED_DERIVE_SC_PROP: &'static str = "test-sub 1.2
-
-USAGE:
- test sub [OPTIONS]
-
-OPTIONS:
- --flag_b first flag
- --option_b <option_b> first option
- --flag_a second flag
- --option_a <option_a> second option
- -h, --help Prints help information
- -V, --version Prints version information";
-
-static UNIFIED_DERIVE_SC_PROP_EXPLICIT_ORDER: &'static str = "test-sub 1.2
-
-USAGE:
- test sub [OPTIONS]
-
-OPTIONS:
- --flag_a second flag
- --flag_b first flag
- --option_b <option_b> first option
- --option_a <option_a> second option
- -h, --help Prints help information
- -V, --version Prints version information";
-
-#[test]
-fn no_derive_order() {
- let app = App::new("test")
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]);
-
- assert!(test::compare_output(app, "test --help", NO_DERIVE_ORDER, false));
-}
-
-#[test]
-fn derive_order() {
- let app = App::new("test")
- .setting(AppSettings::DeriveDisplayOrder)
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]);
-
- assert!(test::compare_output(app, "test --help", DERIVE_ORDER, false));
-}
-
-#[test]
-fn unified_help() {
- let app = App::new("test")
- .setting(AppSettings::UnifiedHelpMessage)
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]);
-
- assert!(test::compare_output(app, "test --help", UNIFIED_HELP, false));
-}
-
-#[test]
-fn unified_help_and_derive_order() {
- let app = App::new("test")
- .setting(AppSettings::DeriveDisplayOrder)
- .setting(AppSettings::UnifiedHelpMessage)
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]);
-
- assert!(test::compare_output(app, "test --help", UNIFIED_HELP_AND_DERIVE, false));
-}
-
-#[test]
-fn derive_order_subcommand_propagate() {
- let app = App::new("test")
- .global_setting(AppSettings::DeriveDisplayOrder)
- .version("1.2")
- .subcommand(SubCommand::with_name("sub")
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]));
-
- assert!(test::compare_output(app, "test sub --help", DERIVE_ORDER_SC_PROP, false));
-}
-
-#[test]
-fn unified_help_subcommand_propagate() {
- let app = App::new("test")
- .global_setting(AppSettings::UnifiedHelpMessage)
- .subcommand(SubCommand::with_name("sub")
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]));
-
- assert!(test::compare_output(app, "test sub --help", UNIFIED_SC_PROP, false));
-}
-
-#[test]
-fn unified_help_and_derive_order_subcommand_propagate() {
- let app = App::new("test")
- .global_setting(AppSettings::DeriveDisplayOrder)
- .global_setting(AppSettings::UnifiedHelpMessage)
- .subcommand(SubCommand::with_name("sub")
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag"),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]));
-
- assert!(test::compare_output(app, "test sub --help", UNIFIED_DERIVE_SC_PROP, false));
-}
-
-#[test]
-fn unified_help_and_derive_order_subcommand_propagate_with_explicit_display_order() {
- let app = App::new("test")
- .global_setting(AppSettings::DeriveDisplayOrder)
- .global_setting(AppSettings::UnifiedHelpMessage)
- .subcommand(SubCommand::with_name("sub")
- .version("1.2")
- .args(&[
- Arg::with_name("flag_b").long("flag_b").help("first flag"),
- Arg::with_name("option_b").long("option_b").takes_value(true).help("first option"),
- Arg::with_name("flag_a").long("flag_a").help("second flag").display_order(0),
- Arg::with_name("option_a").long("option_a").takes_value(true).help("second option"),
- ]));
-
- assert!(test::compare_output(app, "test sub --help", UNIFIED_DERIVE_SC_PROP_EXPLICIT_ORDER, false));
-}
diff --git a/clap/tests/env.rs b/clap/tests/env.rs
deleted file mode 100644
index 62833ba..0000000
--- a/clap/tests/env.rs
+++ /dev/null
@@ -1,263 +0,0 @@
-extern crate clap;
-
-use std::env;
-use std::ffi::OsStr;
-
-use clap::{App, Arg};
-
-#[test]
-fn env() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(Arg::from_usage("[arg] 'some opt'").env("CLP_TEST_ENV"))
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg").unwrap(), "env");
-}
-
-#[test]
-fn env_os() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'").env_os(OsStr::new("CLP_TEST_ENV")),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg").unwrap(), "env");
-}
-
-#[test]
-fn no_env() {
- // All the other tests use the presence of the Environment variable...
- // we need another variable just in case one of the others is running at the same time...
- env::remove_var("CLP_TEST_ENV_NONE");
-
- let r = App::new("df")
- .arg(Arg::from_usage("[arg] 'some opt'").env("CLP_TEST_ENV_NONE"))
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(!m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg"), None);
-}
-
-#[test]
-fn with_default() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV")
- .default_value("default"),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg").unwrap(), "env");
-}
-
-#[test]
-fn opt_user_override() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("--arg [FILE] 'some arg'").env("CLP_TEST_ENV"),
- )
- .get_matches_from_safe(vec!["", "--arg", "opt"]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 1);
- assert_eq!(m.value_of("arg").unwrap(), "opt");
-}
-
-#[test]
-fn positionals() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(Arg::from_usage("[arg] 'some opt'").env("CLP_TEST_ENV"))
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg").unwrap(), "env");
-}
-
-#[test]
-fn positionals_user_override() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(Arg::from_usage("[arg] 'some opt'").env("CLP_TEST_ENV"))
- .get_matches_from_safe(vec!["", "opt"]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 1);
- assert_eq!(m.value_of("arg").unwrap(), "opt");
-}
-
-#[test]
-fn multiple_one() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV")
- .use_delimiter(true)
- .multiple(true),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.values_of("arg").unwrap().collect::<Vec<_>>(), vec!["env"]);
-}
-
-#[test]
-fn multiple_three() {
- env::set_var("CLP_TEST_ENV_MULTI1", "env1,env2,env3");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV_MULTI1")
- .use_delimiter(true)
- .multiple(true),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(
- m.values_of("arg").unwrap().collect::<Vec<_>>(),
- vec!["env1", "env2", "env3"]
- );
-}
-
-#[test]
-fn multiple_no_delimiter() {
- env::set_var("CLP_TEST_ENV_MULTI2", "env1 env2 env3");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV_MULTI2")
- .multiple(true),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(
- m.values_of("arg").unwrap().collect::<Vec<_>>(),
- vec!["env1 env2 env3"]
- );
-}
-
-#[test]
-fn possible_value() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV")
- .possible_value("env"),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg").unwrap(), "env");
-}
-
-
-#[test]
-fn not_possible_value() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV")
- .possible_value("never"),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_err());
-}
-
-#[test]
-fn validator() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV")
- .validator(|s| if s == "env" {
- Ok(())
- } else {
- Err("not equal".to_string())
- }),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("arg"), 0);
- assert_eq!(m.value_of("arg").unwrap(), "env");
-}
-
-#[test]
-fn validator_invalid() {
- env::set_var("CLP_TEST_ENV", "env");
-
- let r = App::new("df")
- .arg(
- Arg::from_usage("[arg] 'some opt'")
- .env("CLP_TEST_ENV")
- .validator(|s| if s != "env" {
- Ok(())
- } else {
- Err("is equal".to_string())
- }),
- )
- .get_matches_from_safe(vec![""]);
-
- assert!(r.is_err());
-}
diff --git a/clap/tests/example1_tmpl_full.txt b/clap/tests/example1_tmpl_full.txt
deleted file mode 100644
index 6ae57fa..0000000
--- a/clap/tests/example1_tmpl_full.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-{bin} {version}
-{author}
-{about}
-
-USAGE:
- {usage}
-
-FLAGS:
-{flags}
-OPTIONS:
-{options}
-ARGS:
-{positionals}
-SUBCOMMANDS:
-{subcommands}
diff --git a/clap/tests/example1_tmpl_simple.txt b/clap/tests/example1_tmpl_simple.txt
deleted file mode 100644
index af6c4b0..0000000
--- a/clap/tests/example1_tmpl_simple.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-{bin} {version}
-{author}
-{about}
-
-USAGE:
- {usage}
-
-{all-args}
diff --git a/clap/tests/flags.rs b/clap/tests/flags.rs
deleted file mode 100644
index 143404e..0000000
--- a/clap/tests/flags.rs
+++ /dev/null
@@ -1,147 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, ArgSettings};
-
-#[test]
-fn flag_using_short() {
- let m = App::new("flag")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::from_usage("-c, --color 'some other flag'")
- ])
- .get_matches_from(vec!["", "-f", "-c"]);
- assert!(m.is_present("flag"));
- assert!(m.is_present("color"));
-}
-
-#[test]
-fn lots_o_flags_sep() {
- let r = App::new("opts")
- .arg(
- Arg::from_usage("-o... 'some flag'"),
- )
- .get_matches_from_safe(vec!["",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o",
- ]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.occurrences_of("o"), 297); // i.e. more than u8
-}
-
-#[test]
-fn lots_o_flags_combined() {
- let r = App::new("opts")
- .arg(
- Arg::from_usage("-o... 'some flag'"),
- )
- .get_matches_from_safe(vec!["",
- "-oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
- "-oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
- "-oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
- "-oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
- "-ooooooooooooooooooooooooooooooooooooooooo",
- ]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.occurrences_of("o"), 297); // i.e. more than u8
-}
-
-#[test]
-fn flag_using_long() {
- let m = App::new("flag")
- .args(&[
- Arg::from_usage("--flag 'some flag'"),
- Arg::from_usage("--color 'some other flag'")
- ])
- .get_matches_from(vec!["", "--flag", "--color"]);
- assert!(m.is_present("flag"));
- assert!(m.is_present("color"));
-}
-
-#[test]
-fn flag_using_mixed() {
- let m = App::new("flag")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::from_usage("-c, --color 'some other flag'")
- ])
- .get_matches_from(vec!["", "-f", "--color"]);
- assert!(m.is_present("flag"));
- assert!(m.is_present("color"));
-
- let m = App::new("flag")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::from_usage("-c, --color 'some other flag'")
- ])
- .get_matches_from(vec!["", "--flag", "-c"]);
- assert!(m.is_present("flag"));
- assert!(m.is_present("color"));
-}
-
-#[test]
-fn multiple_flags_in_single() {
- let m = App::new("multe_flags")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::from_usage("-c, --color 'some other flag'"),
- Arg::from_usage("-d, --debug 'another other flag'")
- ])
- .get_matches_from(vec!["", "-fcd"]);
- assert!(m.is_present("flag"));
- assert!(m.is_present("color"));
- assert!(m.is_present("debug"));
-}
-
-#[test]
-fn short_flag_misspel() {
- let a = Arg::from_usage("-f1, --flag 'some flag'");
- assert_eq!(a.b.name, "flag");
- assert_eq!(a.s.short.unwrap(), 'f');
- assert_eq!(a.s.long.unwrap(), "flag");
- assert_eq!(a.b.help.unwrap(), "some flag");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.v.val_names.is_none());
- assert!(a.v.num_vals.is_none());
-}
-
-#[test]
-fn short_flag_name_missing() {
- let a = Arg::from_usage("-f 'some flag'");
- assert_eq!(a.b.name, "f");
- assert_eq!(a.s.short.unwrap(), 'f');
- assert!(a.s.long.is_none());
- assert_eq!(a.b.help.unwrap(), "some flag");
- assert!(!a.is_set(ArgSettings::Multiple));
- assert!(a.v.val_names.is_none());
- assert!(a.v.num_vals.is_none());
-
-}
diff --git a/clap/tests/global_args.rs b/clap/tests/global_args.rs
deleted file mode 100644
index 4adc685..0000000
--- a/clap/tests/global_args.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-#[cfg(test)]
-mod tests {
- include!("../clap-test.rs");
- use clap::{App, Arg, SubCommand};
-
- fn get_app() -> App<'static, 'static> {
- App::new("myprog")
- .arg(Arg::with_name("GLOBAL_ARG")
- .long("global-arg")
- .help(
- "Specifies something needed by the subcommands",
- )
- .global(true)
- .takes_value(true)
- .default_value("default_value"))
- .arg(Arg::with_name("GLOBAL_FLAG")
- .long("global-flag")
- .help(
- "Specifies something needed by the subcommands",
- )
- .multiple(true)
- .global(true))
- .subcommand(SubCommand::with_name("outer")
- .subcommand(SubCommand::with_name("inner")))
- }
-
- #[test]
- fn issue_1076() {
- let mut app = get_app();
- let _ = app.get_matches_from_safe_borrow(vec!["myprog"]);
- let _ = app.get_matches_from_safe_borrow(vec!["myprog"]);
- let _ = app.get_matches_from_safe_borrow(vec!["myprog"]);
- }
-}
diff --git a/clap/tests/groups.rs b/clap/tests/groups.rs
deleted file mode 100644
index bb108ea..0000000
--- a/clap/tests/groups.rs
+++ /dev/null
@@ -1,207 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg, ArgGroup, ErrorKind, SubCommand};
-
-static REQ_GROUP_USAGE: &'static str = "error: The following required arguments were not provided:
- <base|--delete>
-
-USAGE:
- clap-test <base|--delete>
-
-For more information try --help";
-
-static REQ_GROUP_CONFLICT_USAGE: &'static str = "error: The argument '<base>' cannot be used with '--delete'
-
-USAGE:
- clap-test <base|--delete>
-
-For more information try --help";
-
-static REQ_GROUP_CONFLICT_REV: &'static str = "error: The argument '--delete' cannot be used with 'base'
-
-USAGE:
- clap-test <base|--delete>
-
-For more information try --help";
-
-#[test]
-fn required_group_missing_arg() {
- let result = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color 'some other flag'")
- .group(ArgGroup::with_name("req")
- .args(&["flag", "color"])
- .required(true))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-#[should_panic]
-fn non_existing_arg() {
- let _ = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color 'some other flag'")
- .group(ArgGroup::with_name("req")
- .args(&["flg", "color"])
- .required(true))
- .get_matches_from_safe(vec![""]);
-}
-
-#[test]
-#[should_panic(expected = "The group 'c' contains the arg 'd' that doesn't actually exist.")]
-fn non_existing_arg_in_subcommand_help() {
- let _ = App::new("a")
- .subcommand(
- SubCommand::with_name("b")
- .group(
- ArgGroup::with_name("c")
- .args(&["d"])
- .required(true),
- )
- ).get_matches_from_safe(vec!["a", "help", "b"]);
-}
-
-#[test]
-fn group_single_value() {
- let res = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color [color] 'some option'")
- .group(ArgGroup::with_name("grp")
- .args(&["flag", "color"]))
- .get_matches_from_safe(vec!["", "-c", "blue"]);
- assert!(res.is_ok());
-
- let m = res.unwrap();
- assert!(m.is_present("grp"));
- assert_eq!(m.value_of("grp").unwrap(), "blue");
-}
-
-#[test]
-fn group_single_flag() {
- let res = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color [color] 'some option'")
- .group(ArgGroup::with_name("grp")
- .args(&["flag", "color"]))
- .get_matches_from_safe(vec!["", "-f"]);
- assert!(res.is_ok());
-
- let m = res.unwrap();
- assert!(m.is_present("grp"));
- assert!(m.value_of("grp").is_none());
-}
-
-#[test]
-fn group_empty() {
- let res = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color [color] 'some option'")
- .group(ArgGroup::with_name("grp")
- .args(&["flag", "color"]))
- .get_matches_from_safe(vec![""]);
- assert!(res.is_ok());
-
- let m = res.unwrap();
- assert!(!m.is_present("grp"));
- assert!(m.value_of("grp").is_none());
-}
-
-#[test]
-fn group_reqired_flags_empty() {
- let result = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color 'some option'")
- .group(ArgGroup::with_name("grp")
- .required(true)
- .args(&["flag", "color"]))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn group_multi_value_single_arg() {
- let res = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color [color]... 'some option'")
- .group(ArgGroup::with_name("grp")
- .args(&["flag", "color"]))
- .get_matches_from_safe(vec!["", "-c", "blue", "red", "green"]);
- assert!(res.is_ok(), "{:?}", res.unwrap_err().kind);
-
- let m = res.unwrap();
- assert!(m.is_present("grp"));
- assert_eq!(&*m.values_of("grp").unwrap().collect::<Vec<_>>(), &["blue", "red", "green"]);
-}
-
-#[test]
-fn empty_group() {
- let r = App::new("empty_group")
- .arg(Arg::from_usage("-f, --flag 'some flag'"))
- .group(ArgGroup::with_name("vers")
- .required(true))
- .get_matches_from_safe(vec!["empty_prog"]);
- assert!(r.is_err());
- let err = r.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn req_group_usage_string() {
- let app = App::new("req_group")
- .args_from_usage("[base] 'Base commit'
- -d, --delete 'Remove the base commit information'")
- .group(ArgGroup::with_name("base_or_delete")
- .args(&["base", "delete"])
- .required(true));
-
- assert!(test::compare_output(app, "clap-test", REQ_GROUP_USAGE, true));
-}
-
-#[test]
-fn req_group_with_conflict_usage_string() {
- let app = App::new("req_group")
- .arg(Arg::from_usage("[base] 'Base commit'").conflicts_with("delete"))
- .arg(Arg::from_usage("-d, --delete 'Remove the base commit information'"))
- .group(ArgGroup::with_name("base_or_delete")
- .args(&["base", "delete"])
- .required(true));
-
- assert!(test::compare_output2(app, "clap-test --delete base", REQ_GROUP_CONFLICT_REV, REQ_GROUP_CONFLICT_USAGE, true));
-}
-
-#[test]
-fn required_group_multiple_args() {
- let result = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color 'some other flag'")
- .group(ArgGroup::with_name("req")
- .args(&["flag", "color"])
- .required(true)
- .multiple(true))
- .get_matches_from_safe(vec!["group", "-f", "-c"]);
- assert!(result.is_ok());
- let m = result.unwrap();
- assert!(m.is_present("flag"));
- assert!(m.is_present("color"));
-}
-
-#[test]
-fn group_multiple_args_error() {
- let result = App::new("group")
- .args_from_usage("-f, --flag 'some flag'
- -c, --color 'some other flag'")
- .group(ArgGroup::with_name("req")
- .args(&["flag", "color"]))
- .get_matches_from_safe(vec!["group", "-f", "-c"]);
- assert!(result.is_err());
- let err = result.unwrap_err();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
diff --git a/clap/tests/help.rs b/clap/tests/help.rs
deleted file mode 100644
index 4b15281..0000000
--- a/clap/tests/help.rs
+++ /dev/null
@@ -1,1205 +0,0 @@
-#[macro_use]
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, AppSettings, SubCommand, ErrorKind, Arg};
-
-static REQUIRE_DELIM_HELP: &'static str = "test 1.3
-Kevin K.
-tests stuff
-
-USAGE:
- test --fake <some>:<val>
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -f, --fake <some>:<val> some help";
-
-static HELP: &'static str = "clap-test v1.4.8
-Kevin K. <kbknapp@gmail.com>
-tests clap library
-
-USAGE:
- clap-test [FLAGS] [OPTIONS] [ARGS] [SUBCOMMAND]
-
-FLAGS:
- -f, --flag tests flags
- -F tests flags with exclusions
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -O, --Option <option3> specific vals [possible values: fast, slow]
- --long-option-2 <option2> tests long options with exclusions
- --maxvals3 <maxvals>... Tests 3 max vals
- --minvals2 <minvals>... Tests 2 min vals
- --multvals <one> <two> Tests multiple values, not mult occs
- --multvalsmo <one> <two> Tests multiple values, and mult occs
- -o, --option <opt>... tests options
-
-ARGS:
- <positional> tests positionals
- <positional2> tests positionals with exclusions
- <positional3>... tests specific values [possible values: vi, emacs]
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- subcmd tests subcommands";
-
-static SC_NEGATES_REQS: &'static str = "prog 1.0
-
-USAGE:
- prog --opt <FILE> [PATH]
- prog [PATH] <SUBCOMMAND>
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <FILE> tests options
-
-ARGS:
- <PATH> help
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test";
-
-static ARGS_NEGATE_SC: &'static str = "prog 1.0
-
-USAGE:
- prog [FLAGS] [OPTIONS] [PATH]
- prog <SUBCOMMAND>
-
-FLAGS:
- -f, --flag testing flags
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <FILE> tests options
-
-ARGS:
- <PATH> help
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test";
-
-static AFTER_HELP: &'static str = "some text that comes before the help
-
-clap-test v1.4.8
-tests clap library
-
-USAGE:
- clap-test
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-some text that comes after the help";
-
-static HIDDEN_ARGS: &'static str = "prog 1.0
-
-USAGE:
- prog [FLAGS] [OPTIONS]
-
-FLAGS:
- -f, --flag testing flags
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <FILE> tests options";
-
-static SC_HELP: &'static str = "clap-test-subcmd 0.1
-Kevin K. <kbknapp@gmail.com>
-tests subcommands
-
-USAGE:
- clap-test subcmd [FLAGS] [OPTIONS] [--] [scpositional]
-
-FLAGS:
- -f, --flag tests flags
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --option <scoption>... tests options
- -s, --subcmdarg <subcmdarg> tests other args
-
-ARGS:
- <scpositional> tests positionals";
-
-static ISSUE_1046_HIDDEN_SCS: &'static str = "prog 1.0
-
-USAGE:
- prog [FLAGS] [OPTIONS] [PATH]
-
-FLAGS:
- -f, --flag testing flags
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --opt <FILE> tests options
-
-ARGS:
- <PATH> some";
-
-// Using number_of_values(1) with multiple(true) misaligns help message
-static ISSUE_760: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -O, --opt <opt> tests options
- -o, --option <option>... tests options";
-
-static RIPGREP_USAGE: &'static str = "ripgrep 0.5
-
-USAGE:
- rg [OPTIONS] <pattern> [<path> ...]
- rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
- rg [OPTIONS] --files [<path> ...]
- rg [OPTIONS] --type-list
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information";
-
-
-static MULTI_SC_HELP: &'static str = "ctest-subcmd-multi 0.1
-Kevin K. <kbknapp@gmail.com>
-tests subcommands
-
-USAGE:
- ctest subcmd multi [FLAGS] [OPTIONS]
-
-FLAGS:
- -f, --flag tests flags
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -o, --option <scoption>... tests options";
-
-static ISSUE_626_CUTOFF: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -c, --cafe <FILE> A coffeehouse, coffee shop, or café is an
- establishment which primarily serves hot
- coffee, related coffee beverages (e.g., café
- latte, cappuccino, espresso), tea, and other
- hot beverages. Some coffeehouses also serve
- cold beverages such as iced coffee and iced
- tea. Many cafés also serve some type of food,
- such as light snacks, muffins, or pastries.";
-
-static ISSUE_626_PANIC: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -c, --cafe <FILE>
- La culture du café est très développée
- dans de nombreux pays à climat chaud
- d\'Amérique, d\'Afrique et d\'Asie, dans
- des plantations qui sont cultivées pour
- les marchés d\'exportation. Le café est
- souvent une contribution majeure aux
- exportations des régions productrices.";
-
-static HIDE_POS_VALS: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -c, --cafe <FILE> A coffeehouse, coffee shop, or café.
- -p, --pos <VAL> Some vals [possible values: fast, slow]";
-
-static FINAL_WORD_WRAPPING: &'static str = "ctest 0.1
-
-USAGE:
- ctest
-
-FLAGS:
- -h, --help
- Prints help
- information
- -V, --version
- Prints
- version
- information";
-
-static OLD_NEWLINE_CHARS: &'static str = "ctest 0.1
-
-USAGE:
- ctest [FLAGS]
-
-FLAGS:
- -h, --help Prints help information
- -m Some help with some wrapping
- (Defaults to something)
- -V, --version Prints version information";
-
-static WRAPPING_NEWLINE_CHARS: &'static str = "ctest 0.1
-
-USAGE:
- ctest [mode]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <mode> x, max, maximum 20 characters, contains
- symbols.
- l, long Copy-friendly, 14
- characters, contains symbols.
- m, med, medium Copy-friendly, 8
- characters, contains symbols.";
-
-static ISSUE_688: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- --filter <filter> Sets the filter, or sampling method, to use for interpolation when resizing the particle
- images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic,
- Gaussian, Lanczos3]";
-
-static ISSUE_702: &'static str = "myapp 1.0
-foo
-bar
-
-USAGE:
- myapp [OPTIONS] [--] [ARGS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -l, --label <label>... a label
- -o, --other <other> some other option
- -s, --some <some> some option
-
-ARGS:
- <arg1> some option
- <arg2>... some option";
-
-static ISSUE_777: &'static str = "A app with a crazy very long long
-long name hahaha 1.0
-Some Very Long Name and crazy long
-email <email@server.com>
-Show how the about text is not
-wrapped
-
-USAGE:
- ctest
-
-FLAGS:
- -h, --help
- Prints help information
-
- -V, --version
- Prints version
- information";
-
-static CUSTOM_VERSION_AND_HELP: &'static str = "customize 0.1
-Nobody <odysseus@example.com>
-You can customize the version and help text
-
-USAGE:
- customize
-
-FLAGS:
- -H, --help Print help information
- -v, --version Print version information";
-
-static LAST_ARG: &'static str = "last 0.1
-
-USAGE:
- last <TARGET> [CORPUS] [-- <ARGS>...]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <TARGET> some
- <CORPUS> some
- <ARGS>... some";
-
-static LAST_ARG_SC: &'static str = "last 0.1
-
-USAGE:
- last <TARGET> [CORPUS] [-- <ARGS>...]
- last <SUBCOMMAND>
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <TARGET> some
- <CORPUS> some
- <ARGS>... some
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test some";
-
-static LAST_ARG_REQ: &'static str = "last 0.1
-
-USAGE:
- last <TARGET> [CORPUS] -- <ARGS>...
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <TARGET> some
- <CORPUS> some
- <ARGS>... some";
-
-static LAST_ARG_REQ_SC: &'static str = "last 0.1
-
-USAGE:
- last <TARGET> [CORPUS] -- <ARGS>...
- last <SUBCOMMAND>
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <TARGET> some
- <CORPUS> some
- <ARGS>... some
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test some";
-
-static HIDE_DEFAULT_VAL: &'static str = "default 0.1
-
-USAGE:
- default [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- --arg <argument> Pass an argument to the program. [default: default-argument]";
-
-static LAST_ARG_USAGE: &'static str = "flamegraph 0.1
-
-USAGE:
- flamegraph [FLAGS] [OPTIONS] [BINFILE] [-- <ARGS>...]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
- -v, --verbose Prints out more stuff.
-
-OPTIONS:
- -f, --frequency <HERTZ> The sampling frequency.
- -t, --timeout <SECONDS> Timeout in seconds.
-
-ARGS:
- <BINFILE> The path of the binary to be profiled. for a binary.
- <ARGS>... Any arguments you wish to pass to the being profiled.";
-
-static LAST_ARG_REQ_MULT: &'static str = "example 1.0
-
-USAGE:
- example <FIRST>... [--] <SECOND>...
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-ARGS:
- <FIRST>... First
- <SECOND>... Second";
-
-static DEFAULT_HELP: &'static str = "ctest 1.0
-
-USAGE:
- ctest
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information";
-
-static LONG_ABOUT: &'static str = "myapp 1.0
-foo
-something really really long, with
-multiple lines of text
-that should be displayed
-
-USAGE:
- myapp [arg1]
-
-FLAGS:
- -h, --help
- Prints help information
-
- -V, --version
- Prints version information
-
-
-ARGS:
- <arg1>
- some option";
-
-static HIDE_ENV_VALS: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -c, --cafe <FILE> A coffeehouse, coffee shop, or café. [env: ENVVAR]
- -p, --pos <VAL> Some vals [possible values: fast, slow]";
-
-static SHOW_ENV_VALS: &'static str = "ctest 0.1
-
-USAGE:
- ctest [OPTIONS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -c, --cafe <FILE> A coffeehouse, coffee shop, or café. [env: ENVVAR=MYVAL]
- -p, --pos <VAL> Some vals [possible values: fast, slow]";
-
-fn setup() -> App<'static, 'static> {
- App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
-}
-
-#[test]
-fn help_short() {
- let m = setup()
- .get_matches_from_safe(vec!["myprog", "-h"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn help_long() {
- let m = setup()
- .get_matches_from_safe(vec!["myprog", "--help"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn help_no_subcommand() {
- let m = setup()
- .get_matches_from_safe(vec!["myprog", "help"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn help_subcommand() {
- let m = setup()
- .subcommand(SubCommand::with_name("test")
- .about("tests things")
- .arg_from_usage("-v --verbose 'with verbosity'"))
- .get_matches_from_safe(vec!["myprog", "help"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn req_last_arg_usage() {
- let app = clap_app!(example =>
- (version: "1.0")
- (@arg FIRST: ... * "First")
- (@arg SECOND: ... * +last "Second")
- );
- assert!(test::compare_output(app, "example --help", LAST_ARG_REQ_MULT, false));
-}
-
-#[test]
-fn args_with_last_usage() {
- let app = App::new("flamegraph")
- .version("0.1")
- .setting(AppSettings::TrailingVarArg)
- .arg(Arg::with_name("verbose")
- .help("Prints out more stuff.")
- .short("v")
- .long("verbose")
- .multiple(true)
- )
- .arg(Arg::with_name("timeout")
- .help("Timeout in seconds.")
- .short("t")
- .long("timeout")
- .value_name("SECONDS")
- .takes_value(true)
- )
- .arg(Arg::with_name("frequency")
- .help("The sampling frequency.")
- .short("f")
- .long("frequency")
- .value_name("HERTZ")
- .takes_value(true)
- )
- .arg(Arg::with_name("binary path")
- .help("The path of the binary to be profiled. for a binary.")
- .takes_value(true)
- .value_name("BINFILE")
- )
- .arg(Arg::with_name("pass through args")
- .help("Any arguments you wish to pass to the being profiled.")
- .value_name("ARGS")
- .last(true)
- .multiple(true)
- );
- assert!(test::compare_output(app, "flamegraph --help", LAST_ARG_USAGE, false));
-}
-
-#[test]
-fn subcommand_short_help() {
- let m = test::complex_app().get_matches_from_safe(vec!["clap-test", "subcmd", "-h"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn subcommand_long_help() {
- let m = test::complex_app().get_matches_from_safe(vec!["clap-test", "subcmd", "--help"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn subcommand_help_rev() {
- let m = test::complex_app().get_matches_from_safe(vec!["clap-test", "help", "subcmd"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn complex_help_output() {
- assert!(test::compare_output(test::complex_app(), "clap-test --help", HELP, false));
-}
-
-#[test]
-fn after_and_before_help_output() {
- let app = App::new("clap-test")
- .version("v1.4.8")
- .about("tests clap library")
- .before_help("some text that comes before the help")
- .after_help("some text that comes after the help");
- assert!(test::compare_output(app, "clap-test --help", AFTER_HELP, false));
-}
-
-#[test]
-fn multi_level_sc_help() {
- let app = App::new("ctest")
- .subcommand(SubCommand::with_name("subcmd").subcommand(SubCommand::with_name("multi")
- .about("tests subcommands")
- .author("Kevin K. <kbknapp@gmail.com>")
- .version("0.1")
- .args_from_usage("
- -f, --flag 'tests flags'
- -o, --option [scoption]... 'tests options'
- ")));
- assert!(test::compare_output(app, "ctest help subcmd multi", MULTI_SC_HELP, false));
-}
-
-#[test]
-fn no_wrap_help() {
- let app = App::new("ctest")
- .set_term_width(0)
- .help(MULTI_SC_HELP);
- assert!(test::compare_output(app, "ctest --help", MULTI_SC_HELP, false));
-}
-
-#[test]
-fn no_wrap_default_help() {
- let app = App::new("ctest").version("1.0").set_term_width(0);
- assert!(test::compare_output(app, "ctest --help", DEFAULT_HELP, false));
-}
-
-#[test]
-fn complex_subcommand_help_output() {
- let a = test::complex_app();
- assert!(test::compare_output(a, "clap-test subcmd --help", SC_HELP, false));
-}
-
-
-#[test]
-fn issue_626_unicode_cutoff() {
- let app = App::new("ctest")
- .version("0.1")
- .set_term_width(70)
- .arg(Arg::with_name("cafe")
- .short("c")
- .long("cafe")
- .value_name("FILE")
- .help("A coffeehouse, coffee shop, or café is an establishment \
- which primarily serves hot coffee, related coffee beverages \
- (e.g., café latte, cappuccino, espresso), tea, and other hot \
- beverages. Some coffeehouses also serve cold beverages such as \
- iced coffee and iced tea. Many cafés also serve some type of \
- food, such as light snacks, muffins, or pastries.")
- .takes_value(true));
- assert!(test::compare_output(app, "ctest --help", ISSUE_626_CUTOFF, false));
-}
-
-#[test]
-fn hide_possible_vals() {
- let app = App::new("ctest")
- .version("0.1")
- .arg(Arg::with_name("pos")
- .short("p")
- .long("pos")
- .value_name("VAL")
- .possible_values(&["fast", "slow"])
- .help("Some vals")
- .takes_value(true))
- .arg(Arg::with_name("cafe")
- .short("c")
- .long("cafe")
- .value_name("FILE")
- .hide_possible_values(true)
- .possible_values(&["fast", "slow"])
- .help("A coffeehouse, coffee shop, or café.")
- .takes_value(true));
- assert!(test::compare_output(app, "ctest --help", HIDE_POS_VALS, false));
-}
-
-#[test]
-fn issue_626_panic() {
- let app = App::new("ctest")
- .version("0.1")
- .set_term_width(52)
- .arg(Arg::with_name("cafe")
- .short("c")
- .long("cafe")
- .value_name("FILE")
- .help("La culture du café est très développée dans de nombreux pays à climat chaud d'Amérique, \
- d'Afrique et d'Asie, dans des plantations qui sont cultivées pour les marchés d'exportation. \
- Le café est souvent une contribution majeure aux exportations des régions productrices.")
- .takes_value(true));
- assert!(test::compare_output(app, "ctest --help", ISSUE_626_PANIC, false));
-}
-
-#[test]
-fn issue_626_variable_panic() {
- for i in 10..320 {
- let _ = App::new("ctest")
- .version("0.1")
- .set_term_width(i)
- .arg(Arg::with_name("cafe")
- .short("c")
- .long("cafe")
- .value_name("FILE")
- .help("La culture du café est très développée dans de nombreux pays à climat chaud d'Amérique, \
- d'Afrique et d'Asie, dans des plantations qui sont cultivées pour les marchés d'exportation. \
- Le café est souvent une contribution majeure aux exportations des régions productrices.")
- .takes_value(true))
- .get_matches_from_safe(vec!["ctest", "--help"]);
- }
-}
-
-#[test]
-fn final_word_wrapping() {
- let app = App::new("ctest").version("0.1").set_term_width(24);
- assert!(test::compare_output(app, "ctest --help", FINAL_WORD_WRAPPING, false));
-}
-
-#[test]
-fn wrapping_newline_chars() {
- let app = App::new("ctest")
- .version("0.1")
- .set_term_width(60)
- .arg(Arg::with_name("mode")
- .help("x, max, maximum 20 characters, contains symbols.{n}\
- l, long Copy-friendly, 14 characters, contains symbols.{n}\
- m, med, medium Copy-friendly, 8 characters, contains symbols.{n}"));
- assert!(test::compare_output(app, "ctest --help", WRAPPING_NEWLINE_CHARS, false));
-}
-
-#[test]
-fn old_newline_chars() {
- let app = App::new("ctest")
- .version("0.1")
- .arg(Arg::with_name("mode")
- .short("m")
- .help("Some help with some wrapping{n}(Defaults to something)"));
- assert!(test::compare_output(app, "ctest --help", OLD_NEWLINE_CHARS, false));
-}
-
-#[test]
-fn issue_688_hidden_pos_vals() {
- let filter_values = ["Nearest", "Linear", "Cubic", "Gaussian", "Lanczos3"];
-
- let app1 = App::new("ctest")
- .version("0.1")
- .set_term_width(120)
- .setting(AppSettings::HidePossibleValuesInHelp)
- .arg(Arg::with_name("filter")
- .help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
- images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
- .long("filter")
- .possible_values(&filter_values)
- .takes_value(true));
- assert!(test::compare_output(app1, "ctest --help", ISSUE_688, false));
-
- let app2 = App::new("ctest")
- .version("0.1")
- .set_term_width(120)
- .arg(Arg::with_name("filter")
- .help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
- images. The default is Linear (Bilinear).")
- .long("filter")
- .possible_values(&filter_values)
- .takes_value(true));
- assert!(test::compare_output(app2, "ctest --help", ISSUE_688, false));
-
- let app3 = App::new("ctest")
- .version("0.1")
- .set_term_width(120)
- .arg(Arg::with_name("filter")
- .help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
- images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
- .long("filter")
- .takes_value(true));
- assert!(test::compare_output(app3, "ctest --help", ISSUE_688, false));
-}
-
-#[test]
-fn issue_702_multiple_values() {
- let app = App::new("myapp")
- .version("1.0")
- .author("foo")
- .about("bar")
- .arg(Arg::with_name("arg1").help("some option"))
- .arg(Arg::with_name("arg2")
- .multiple(true)
- .help("some option"))
- .arg(Arg::with_name("some")
- .help("some option")
- .short("s")
- .long("some")
- .takes_value(true))
- .arg(Arg::with_name("other")
- .help("some other option")
- .short("o")
- .long("other")
- .takes_value(true))
- .arg(Arg::with_name("label")
- .help("a label")
- .short("l")
- .long("label")
- .multiple(true)
- .takes_value(true));
- assert!(test::compare_output(app, "myapp --help", ISSUE_702, false));
-}
-
-#[test]
-fn long_about() {
- let app = App::new("myapp")
- .version("1.0")
- .author("foo")
- .about("bar")
- .long_about("something really really long, with\nmultiple lines of text\nthat should be displayed")
- .arg(Arg::with_name("arg1").help("some option"));
- assert!(test::compare_output(app, "myapp --help", LONG_ABOUT, false));
-}
-
-#[test]
-fn issue_760() {
- let app = App::new("ctest")
- .version("0.1")
- .arg(Arg::with_name("option")
- .help("tests options")
- .short("o")
- .long("option")
- .takes_value(true)
- .multiple(true)
- .number_of_values(1))
- .arg(Arg::with_name("opt")
- .help("tests options")
- .short("O")
- .long("opt")
- .takes_value(true));
- assert!(test::compare_output(app, "ctest --help", ISSUE_760, false));
-}
-
-#[test]
-fn ripgrep_usage() {
- let app = App::new("ripgrep")
- .version("0.5")
- .usage("rg [OPTIONS] <pattern> [<path> ...]
- rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
- rg [OPTIONS] --files [<path> ...]
- rg [OPTIONS] --type-list");
-
- assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
-}
-
-#[test]
-fn ripgrep_usage_using_templates() {
- let app = App::new("ripgrep")
- .version("0.5")
- .usage("
- rg [OPTIONS] <pattern> [<path> ...]
- rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
- rg [OPTIONS] --files [<path> ...]
- rg [OPTIONS] --type-list")
- .template("\
-{bin} {version}
-
-USAGE:{usage}
-
-FLAGS:
-{flags}");
-
- assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
-}
-
-#[test]
-fn sc_negates_reqs() {
- let app = App::new("prog")
- .version("1.0")
- .setting(AppSettings::SubcommandsNegateReqs)
- .arg_from_usage("-o, --opt <FILE> 'tests options'")
- .arg(Arg::with_name("PATH").help("help"))
- .subcommand(SubCommand::with_name("test"));
- assert!(test::compare_output(app, "prog --help", SC_NEGATES_REQS, false));
-}
-
-#[test]
-fn hidden_args() {
- let app = App::new("prog")
- .version("1.0")
- .args_from_usage("-f, --flag 'testing flags'
- -o, --opt [FILE] 'tests options'")
- .arg(Arg::with_name("pos").hidden(true));
- assert!(test::compare_output(app, "prog --help", HIDDEN_ARGS, false));
-}
-
-#[test]
-fn args_negate_sc() {
- let app = App::new("prog")
- .version("1.0")
- .setting(AppSettings::ArgsNegateSubcommands)
- .args_from_usage("-f, --flag 'testing flags'
- -o, --opt [FILE] 'tests options'")
- .arg(Arg::with_name("PATH").help("help"))
- .subcommand(SubCommand::with_name("test"));
- assert!(test::compare_output(app, "prog --help", ARGS_NEGATE_SC, false));
-}
-
-#[test]
-fn issue_1046_hidden_scs() {
- let app = App::new("prog")
- .version("1.0")
- .args_from_usage("-f, --flag 'testing flags'
- -o, --opt [FILE] 'tests options'")
- .arg(Arg::with_name("PATH").help("some"))
- .subcommand(SubCommand::with_name("test").setting(AppSettings::Hidden));
- assert!(test::compare_output(app, "prog --help", ISSUE_1046_HIDDEN_SCS, false));
-}
-
-#[test]
-fn issue_777_wrap_all_things() {
- let app = App::new("A app with a crazy very long long long name hahaha")
- .version("1.0")
- .author("Some Very Long Name and crazy long email <email@server.com>")
- .about("Show how the about text is not wrapped")
- .set_term_width(35);
- assert!(test::compare_output(app, "ctest --help", ISSUE_777, false));
-}
-
-#[test]
-fn customize_version_and_help() {
- let app = App::new("customize")
- .version("0.1")
- .author("Nobody <odysseus@example.com>")
- .about("You can customize the version and help text")
- .help_short("H")
- .help_message("Print help information")
- .version_short("v")
- .version_message("Print version information");
- assert!(test::compare_output(app, "customize --help", CUSTOM_VERSION_AND_HELP, false));
-}
-
-#[test]
-fn last_arg_mult_usage() {
- let app = App::new("last")
- .version("0.1")
- .arg(Arg::with_name("TARGET").required(true).help("some"))
- .arg(Arg::with_name("CORPUS").help("some"))
- .arg(Arg::with_name("ARGS").multiple(true).last(true).help("some"));
- assert!(test::compare_output(app, "last --help", LAST_ARG, false));
-}
-
-#[test]
-fn last_arg_mult_usage_req() {
- let app = App::new("last")
- .version("0.1")
- .arg(Arg::with_name("TARGET").required(true).help("some"))
- .arg(Arg::with_name("CORPUS").help("some"))
- .arg(Arg::with_name("ARGS").multiple(true).last(true).required(true).help("some"));
- assert!(test::compare_output(app, "last --help", LAST_ARG_REQ, false));
-}
-
-#[test]
-fn last_arg_mult_usage_req_with_sc() {
- let app = App::new("last")
- .version("0.1")
- .setting(AppSettings::SubcommandsNegateReqs)
- .arg(Arg::with_name("TARGET").required(true).help("some"))
- .arg(Arg::with_name("CORPUS").help("some"))
- .arg(Arg::with_name("ARGS").multiple(true).last(true).required(true).help("some"))
- .subcommand(SubCommand::with_name("test").about("some"));
- assert!(test::compare_output(app, "last --help", LAST_ARG_REQ_SC, false));
-}
-
-#[test]
-fn last_arg_mult_usage_with_sc() {
- let app = App::new("last")
- .version("0.1")
- .setting(AppSettings::ArgsNegateSubcommands)
- .arg(Arg::with_name("TARGET").required(true).help("some"))
- .arg(Arg::with_name("CORPUS").help("some"))
- .arg(Arg::with_name("ARGS").multiple(true).last(true).help("some"))
- .subcommand(SubCommand::with_name("test").about("some"));
- assert!(test::compare_output(app, "last --help", LAST_ARG_SC, false));
-}
-
-
-#[test]
-fn hidden_default_val() {
- let app1 = App::new("default")
- .version("0.1")
- .set_term_width(120)
- .arg(Arg::with_name("argument")
- .help("Pass an argument to the program. [default: default-argument]")
- .long("arg")
- .default_value("default-argument")
- .hide_default_value(true));
- assert!(test::compare_output(app1, "default --help", HIDE_DEFAULT_VAL, false));
-
- let app2 = App::new("default")
- .version("0.1")
- .set_term_width(120)
- .arg(Arg::with_name("argument")
- .help("Pass an argument to the program.")
- .long("arg")
- .default_value("default-argument"));
- assert!(test::compare_output(app2, "default --help", HIDE_DEFAULT_VAL, false));
-}
-
-fn issue_1112_setup() -> App<'static, 'static> {
- App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .arg(Arg::from_usage("-h, --help 'some help'"))
- .subcommand(SubCommand::with_name("foo")
- .arg(Arg::from_usage("-h, --help 'some help'")))
-}
-
-#[test]
-fn issue_1112_override_help_long() {
- let m = issue_1112_setup()
- .get_matches_from_safe(vec!["test", "--help"]);
-
- assert!(m.is_ok());
- assert!(m.unwrap().is_present("help"));
-}
-
-#[test]
-fn issue_1112_override_help_short() {
- let m = issue_1112_setup()
- .get_matches_from_safe(vec!["test", "-h"]);
-
- assert!(m.is_ok());
- assert!(m.unwrap().is_present("help"));
-}
-
-#[test]
-fn issue_1112_override_help_subcmd_long() {
- let m = issue_1112_setup()
- .get_matches_from_safe(vec!["test", "foo", "--help"]);
-
- assert!(m.is_ok());
- assert!(m.unwrap().subcommand_matches("foo").unwrap().is_present("help"));
-}
-
-#[test]
-fn issue_1112_override_help_subcmd_short() {
- let m = issue_1112_setup()
- .get_matches_from_safe(vec!["test", "foo", "-h"]);
-
- assert!(m.is_ok());
- assert!(m.unwrap().subcommand_matches("foo").unwrap().is_present("help"));
-}
-
-#[test]
-fn issue_1052_require_delim_help() {
- let app = App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .arg(Arg::from_usage("-f, --fake <some> <val> 'some help'").require_delimiter(true).value_delimiter(":"));
-
- assert!(test::compare_output(app, "test --help", REQUIRE_DELIM_HELP, false));
-}
-
-#[test]
-fn hide_env_vals() {
- use std::env;
-
- env::set_var("ENVVAR", "MYVAL");
- let app = App::new("ctest")
- .version("0.1")
- .arg(Arg::with_name("pos")
- .short("p")
- .long("pos")
- .value_name("VAL")
- .possible_values(&["fast", "slow"])
- .help("Some vals")
- .takes_value(true))
- .arg(Arg::with_name("cafe")
- .short("c")
- .long("cafe")
- .value_name("FILE")
- .hide_env_values(true)
- .env("ENVVAR")
- .help("A coffeehouse, coffee shop, or café.")
- .takes_value(true));
- assert!(test::compare_output(app, "ctest --help", HIDE_ENV_VALS, false));
-}
-
-#[test]
-fn show_env_vals() {
- use std::env;
-
- env::set_var("ENVVAR", "MYVAL");
- let app = App::new("ctest")
- .version("0.1")
- .arg(Arg::with_name("pos")
- .short("p")
- .long("pos")
- .value_name("VAL")
- .possible_values(&["fast", "slow"])
- .help("Some vals")
- .takes_value(true))
- .arg(Arg::with_name("cafe")
- .short("c")
- .long("cafe")
- .value_name("FILE")
- .hide_possible_values(true)
- .env("ENVVAR")
- .help("A coffeehouse, coffee shop, or café.")
- .takes_value(true));
- assert!(test::compare_output(app, "ctest --help", SHOW_ENV_VALS, false));
-}
-
-static ISSUE_897: &'static str = "ctest-foo 0.1
-Long about foo
-
-USAGE:
- ctest foo
-
-FLAGS:
- -h, --help
- Prints help information
-
- -V, --version
- Prints version information";
-
-#[test]
-fn show_long_about_issue_897() {
- let app = App::new("ctest")
- .version("0.1")
- .subcommand(SubCommand::with_name("foo")
- .version("0.1")
- .about("About foo")
- .long_about("Long about foo"));
- assert!(test::compare_output(app, "ctest foo --help", ISSUE_897, false));
-}
-
-static ISSUE_897_SHORT: &'static str = "ctest-foo 0.1
-Long about foo
-
-USAGE:
- ctest foo
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information";
-
-#[test]
-fn show_short_about_issue_897() {
- let app = App::new("ctest")
- .version("0.1")
- .subcommand(SubCommand::with_name("foo")
- .version("0.1")
- .about("About foo")
- .long_about("Long about foo"));
- assert!(test::compare_output(app, "ctest foo -h", ISSUE_897_SHORT, false));
-}
diff --git a/clap/tests/hidden_args.rs b/clap/tests/hidden_args.rs
deleted file mode 100644
index 635e25e..0000000
--- a/clap/tests/hidden_args.rs
+++ /dev/null
@@ -1,178 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-use clap::{App, Arg};
-
-include!("../clap-test.rs");
-
-static HIDDEN_ARGS: &'static str = "test 1.4
-Kevin K.
-tests stuff
-
-USAGE:
- test [FLAGS] [OPTIONS]
-
-FLAGS:
- -F, --flag2 some other flag
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- --option <opt> some option";
-
-#[test]
-fn hidden_args() {
- let app = App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.4")
- .args(&[Arg::from_usage("-f, --flag 'some flag'").hidden(true),
- Arg::from_usage("-F, --flag2 'some other flag'"),
- Arg::from_usage("--option [opt] 'some option'"),
- Arg::with_name("DUMMY").required(false).hidden(true)]);
- assert!(test::compare_output(app, "test --help", HIDDEN_ARGS, false));
-}
-
-static HIDDEN_SHORT_ARGS: &'static str = "test 2.31.2
-Steve P.
-hides short args
-
-USAGE:
- test [FLAGS]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
- -v, --visible This text should be visible";
-
-static HIDDEN_SHORT_ARGS_LONG_HELP: &'static str = "test 2.31.2
-Steve P.
-hides short args
-
-USAGE:
- test [FLAGS]
-
-FLAGS:
- -c, --config
- Some help text describing the --config arg
-
- -h, --help
- Prints help information
-
- -V, --version
- Prints version information
-
- -v, --visible
- This text should be visible";
-
-/// Ensure hidden with short option
-#[test]
-fn hidden_short_args() {
- let app = App::new("test")
- .about("hides short args")
- .author("Steve P.")
- .version("2.31.2")
- .args(&[
- Arg::with_name("cfg")
- .short("c")
- .long("config")
- .hidden_short_help(true)
- .help("Some help text describing the --config arg"),
- Arg::with_name("visible")
- .short("v")
- .long("visible")
- .help("This text should be visible")]);
-
- assert!(test::compare_output(app, "test -h", HIDDEN_SHORT_ARGS, false));
-}
-
-/// Ensure visible with opposite option
-#[test]
-fn hidden_short_args_long_help() {
- let app = App::new("test")
- .about("hides short args")
- .author("Steve P.")
- .version("2.31.2")
- .args(&[
- Arg::with_name("cfg")
- .short("c")
- .long("config")
- .hidden_short_help(true)
- .help("Some help text describing the --config arg"),
- Arg::with_name("visible")
- .short("v")
- .long("visible")
- .help("This text should be visible")]);
-
- assert!(test::compare_output(app, "test --help", HIDDEN_SHORT_ARGS_LONG_HELP, false));
-}
-
-static HIDDEN_LONG_ARGS: &'static str = "test 2.31.2
-Steve P.
-hides long args
-
-USAGE:
- test [FLAGS]
-
-FLAGS:
- -h, --help
- Prints help information
-
- -V, --version
- Prints version information
-
- -v, --visible
- This text should be visible";
-
-#[test]
-fn hidden_long_args() {
- let app = App::new("test")
- .about("hides long args")
- .author("Steve P.")
- .version("2.31.2")
- .args(&[
- Arg::with_name("cfg")
- .short("c")
- .long("config")
- .hidden_long_help(true)
- .help("Some help text describing the --config arg"),
- Arg::with_name("visible")
- .short("v")
- .long("visible")
- .help("This text should be visible")]);
-
- assert!(test::compare_output(app, "test --help", HIDDEN_LONG_ARGS, false));
-}
-
-static HIDDEN_LONG_ARGS_SHORT_HELP: &'static str = "test 2.31.2
-Steve P.
-hides long args
-
-USAGE:
- test [FLAGS]
-
-FLAGS:
- -c, --config Some help text describing the --config arg
- -h, --help Prints help information
- -V, --version Prints version information
- -v, --visible This text should be visible";
-
-#[test]
-fn hidden_long_args_short_help() {
- let app = App::new("test")
- .about("hides long args")
- .author("Steve P.")
- .version("2.31.2")
- .args(&[
- Arg::with_name("cfg")
- .short("c")
- .long("config")
- .hidden_long_help(true)
- .help("Some help text describing the --config arg"),
- Arg::with_name("visible")
- .short("v")
- .long("visible")
- .help("This text should be visible")]);
-
- assert!(test::compare_output(app, "test -h", HIDDEN_LONG_ARGS_SHORT_HELP, false));
-}
diff --git a/clap/tests/indices.rs b/clap/tests/indices.rs
deleted file mode 100644
index 910529e..0000000
--- a/clap/tests/indices.rs
+++ /dev/null
@@ -1,175 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg};
-
-#[test]
-fn indices_mult_opts() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .takes_value(true)
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .takes_value(true)
- .multiple(true))
- .get_matches_from(vec!["ind", "-e", "A", "B", "-i", "B", "C", "-e", "C"]);
-
- assert_eq!(m.indices_of("exclude").unwrap().collect::<Vec<_>>(), &[2, 3, 8]);
- assert_eq!(m.indices_of("include").unwrap().collect::<Vec<_>>(), &[5, 6]);
-}
-
-#[test]
-fn index_mult_opts() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .takes_value(true)
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .takes_value(true)
- .multiple(true))
- .get_matches_from(vec!["ind", "-e", "A", "B", "-i", "B", "C", "-e", "C"]);
-
- assert_eq!(m.index_of("exclude"), Some(2));
- assert_eq!(m.index_of("include"), Some(5));
-}
-
-#[test]
-fn index_flag() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e"))
- .arg(Arg::with_name("include")
- .short("i"))
- .get_matches_from(vec!["ind", "-e", "-i"]);
-
- assert_eq!(m.index_of("exclude"), Some(1));
- assert_eq!(m.index_of("include"), Some(2));
-}
-
-#[test]
-fn index_flags() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .multiple(true))
- .get_matches_from(vec!["ind", "-e", "-i", "-e", "-e", "-i"]);
-
- assert_eq!(m.index_of("exclude"), Some(1));
- assert_eq!(m.index_of("include"), Some(2));
-}
-
-#[test]
-fn indices_mult_flags() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .multiple(true))
- .get_matches_from(vec!["ind", "-e", "-i", "-e", "-e", "-i"]);
-
- assert_eq!(m.indices_of("exclude").unwrap().collect::<Vec<_>>(), &[1, 3, 4]);
- assert_eq!(m.indices_of("include").unwrap().collect::<Vec<_>>(), &[2, 5]);
-}
-
-#[test]
-fn indices_mult_flags_combined() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .multiple(true))
- .get_matches_from(vec!["ind", "-eieei"]);
-
- assert_eq!(m.indices_of("exclude").unwrap().collect::<Vec<_>>(), &[1, 3, 4]);
- assert_eq!(m.indices_of("include").unwrap().collect::<Vec<_>>(), &[2, 5]);
-}
-
-#[test]
-fn indices_mult_flags_opt_combined() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .multiple(true))
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true))
- .get_matches_from(vec!["ind", "-eieeio", "val"]);
-
- assert_eq!(m.indices_of("exclude").unwrap().collect::<Vec<_>>(), &[1, 3, 4]);
- assert_eq!(m.indices_of("include").unwrap().collect::<Vec<_>>(), &[2, 5]);
- assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[7]);
-}
-
-#[test]
-fn indices_mult_flags_opt_combined_eq() {
- let m = App::new("ind")
- .arg(Arg::with_name("exclude")
- .short("e")
- .multiple(true))
- .arg(Arg::with_name("include")
- .short("i")
- .multiple(true))
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true))
- .get_matches_from(vec!["ind", "-eieeio=val"]);
-
- assert_eq!(m.indices_of("exclude").unwrap().collect::<Vec<_>>(), &[1, 3, 4]);
- assert_eq!(m.indices_of("include").unwrap().collect::<Vec<_>>(), &[2, 5]);
- assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[7]);
-}
-
-#[test]
-fn indices_mult_opt_value_delim_eq() {
- let m = App::new("myapp")
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true)
- .use_delimiter(true)
- .multiple(true))
- .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
- assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]);
-}
-
-#[test]
-fn indices_mult_opt_value_no_delim_eq() {
- let m = App::new("myapp")
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true)
- .multiple(true))
- .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
- assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2]);
-}
-
-#[test]
-fn indices_mult_opt_mult_flag() {
- let m = App::new("myapp")
- .arg(Arg::with_name("option")
- .short("o")
- .takes_value(true)
- .multiple(true))
- .arg(Arg::with_name("flag")
- .short("f")
- .multiple(true))
- .get_matches_from(vec!["myapp", "-o", "val1", "-f", "-o", "val2", "-f"]);
-
- assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 5]);
- assert_eq!(m.indices_of("flag").unwrap().collect::<Vec<_>>(), &[3, 6]);
-}
diff --git a/clap/tests/macros.rs b/clap/tests/macros.rs
deleted file mode 100755
index 0cdcb52..0000000
--- a/clap/tests/macros.rs
+++ /dev/null
@@ -1,391 +0,0 @@
-#[macro_use]
-extern crate clap;
-
-use clap::ErrorKind;
-
-#[test]
-fn basic() {
- clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg opt: -o --option +takes_value ... "tests options")
- (@arg positional: index(1) "tests positionals")
- (@arg flag: -f --flag ... +global "tests flags")
- (@arg flag2: -F conflicts_with[flag] requires[option2]
- "tests flags with exclusions")
- (@arg option2: --long_option_2 conflicts_with[option] requires[positional2]
- "tests long options with exclusions")
- (@arg positional2: index(2) "tests positionals with exclusions")
- (@arg option3: -O --Option +takes_value possible_value[fast slow]
- "tests options with specific value sets")
- (@arg positional3: index(3) ... possible_value[vi emacs]
- "tests positionals with specific values")
- (@arg multvals: --multvals +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg multvalsmo: --multvalsmo ... +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg minvals: --minvals2 min_values(1) ... +takes_value "Tests 2 min vals")
- (@arg maxvals: --maxvals3 ... +takes_value max_values(3) "Tests 3 max vals")
- (@subcommand subcmd =>
- (about: "tests subcommands")
- (version: "0.1")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg scoption: -o --option ... +takes_value "tests options")
- (@arg scpositional: index(1) "tests positionals"))
- );
-}
-
-#[test]
-fn quoted_app_name() {
- let app = clap_app!(("app name with spaces-and-hyphens") =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg opt: -o --option +takes_value ... "tests options")
- (@arg positional: index(1) "tests positionals")
- (@arg flag: -f --flag ... +global "tests flags")
- (@arg flag2: -F conflicts_with[flag] requires[option2]
- "tests flags with exclusions")
- (@arg option2: --long_option_2 conflicts_with[option] requires[positional2]
- "tests long options with exclusions")
- (@arg positional2: index(2) "tests positionals with exclusions")
- (@arg option3: -O --Option +takes_value possible_value[fast slow]
- "tests options with specific value sets")
- (@arg positional3: index(3) ... possible_value[vi emacs]
- "tests positionals with specific values")
- (@arg multvals: --multvals +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg multvalsmo: --multvalsmo ... +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg minvals: --minvals2 min_values(1) ... +takes_value "Tests 2 min vals")
- (@arg maxvals: --maxvals3 ... +takes_value max_values(3) "Tests 3 max vals")
- (@subcommand subcmd =>
- (about: "tests subcommands")
- (version: "0.1")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg scoption: -o --option ... +takes_value "tests options")
- (@arg scpositional: index(1) "tests positionals"))
- );
-
- assert_eq!(app.p.meta.name, "app name with spaces-and-hyphens");
-
- let mut help_text = vec![];
- app.write_help(&mut help_text).expect("Could not write help text.");
- let help_text = String::from_utf8(help_text).expect("Help text is not valid utf-8");
- assert!(help_text.starts_with("app name with spaces-and-hyphens 0.1\n"));
-}
-
-#[test]
-fn quoted_arg_long_name() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg opt: -o --option +takes_value ... "tests options")
- (@arg positional: index(1) "tests positionals")
- (@arg flag: -f --flag ... +global "tests flags")
- (@arg flag2: -F conflicts_with[flag] requires[option2]
- "tests flags with exclusions")
- (@arg option2: --("long-option-2") conflicts_with[option] requires[positional2]
- "tests long options with exclusions")
- (@arg positional2: index(2) "tests positionals with exclusions")
- (@arg option3: -O --Option +takes_value possible_value[fast slow]
- "tests options with specific value sets")
- (@arg positional3: index(3) ... possible_value[vi emacs]
- "tests positionals with specific values")
- (@arg multvals: --multvals +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg multvalsmo: --multvalsmo ... +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg minvals: --minvals2 min_values(1) ... +takes_value "Tests 2 min vals")
- (@arg maxvals: --maxvals3 ... +takes_value max_values(3) "Tests 3 max vals")
- (@subcommand subcmd =>
- (about: "tests subcommands")
- (version: "0.1")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg scoption: -o --option ... +takes_value "tests options")
- (@arg scpositional: index(1) "tests positionals"))
- );
-
- let matches = app.get_matches_from_safe(vec!["bin_name", "value1", "value2", "--long-option-2"])
- .expect("Expected to successfully match the given args.");
- assert!(matches.is_present("option2"));
-}
-
-#[test]
-fn quoted_arg_name() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg opt: -o --option +takes_value ... "tests options")
- (@arg ("positional-arg"): index(1) "tests positionals")
- (@arg flag: -f --flag ... +global "tests flags")
- (@arg flag2: -F conflicts_with[flag] requires[option2]
- "tests flags with exclusions")
- (@arg option2: --("long-option-2") conflicts_with[option] requires[positional2]
- "tests long options with exclusions")
- (@arg positional2: index(2) "tests positionals with exclusions")
- (@arg option3: -O --Option +takes_value possible_value[fast slow]
- "tests options with specific value sets")
- (@arg ("positional-3"): index(3) ... possible_value[vi emacs]
- "tests positionals with specific values")
- (@arg multvals: --multvals +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg multvalsmo: --multvalsmo ... +takes_value value_name[one two]
- "Tests multiple values, not mult occs")
- (@arg minvals: --minvals2 min_values(1) ... +takes_value "Tests 2 min vals")
- (@arg maxvals: --maxvals3 ... +takes_value max_values(3) "Tests 3 max vals")
- (@subcommand subcmd =>
- (about: "tests subcommands")
- (version: "0.1")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@arg scoption: -o --option ... +takes_value "tests options")
- (@arg scpositional: index(1) "tests positionals"))
- );
-
- let matches = app.get_matches_from_safe(vec!["bin_name", "value1", "value2", "--long-option-2"])
- .expect("Expected to successfully match the given args.");
- assert!(matches.is_present("option2"));
-}
-
-#[test]
-fn group_macro() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@group difficulty =>
- (@arg hard: -h --hard "Sets hard mode")
- (@arg normal: -n --normal "Sets normal mode")
- (@arg easy: -e --easy "Sets easy mode")
- )
- );
-
- let result = app.get_matches_from_safe(vec!["bin_name", "--hard"]);
- assert!(result.is_ok());
- let matches = result.expect("Expected to successfully match the given args.");
- assert!(matches.is_present("difficulty"));
- assert!(matches.is_present("hard"));
-}
-
-#[test]
-fn group_macro_set_multiple() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@group difficulty +multiple =>
- (@arg hard: -h --hard "Sets hard mode")
- (@arg normal: -n --normal "Sets normal mode")
- (@arg easy: -e --easy "Sets easy mode")
- )
- );
-
- let result = app.get_matches_from_safe(vec!["bin_name", "--hard", "--easy"]);
- assert!(result.is_ok());
- let matches = result.expect("Expected to successfully match the given args.");
- assert!(matches.is_present("difficulty"));
- assert!(matches.is_present("hard"));
- assert!(matches.is_present("easy"));
- assert!(!matches.is_present("normal"));
-}
-
-#[test]
-fn group_macro_set_not_multiple() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@group difficulty !multiple =>
- (@arg hard: -h --hard "Sets hard mode")
- (@arg normal: -n --normal "Sets normal mode")
- (@arg easy: -e --easy "Sets easy mode")
- )
- );
-
- let result = app.get_matches_from_safe(vec!["bin_name", "--hard", "--easy"]);
- assert!(result.is_err());
- let err = result.unwrap_err();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
-
-#[test]
-fn group_macro_set_required() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@group difficulty +required =>
- (@arg hard: -h --hard "Sets hard mode")
- (@arg normal: -n --normal "Sets normal mode")
- (@arg easy: -e --easy "Sets easy mode")
- )
- );
-
- let result = app.get_matches_from_safe(vec!["bin_name"]);
- assert!(result.is_err());
- let err = result.unwrap_err();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn group_macro_set_not_required() {
- let app = clap_app!(claptests =>
- (version: "0.1")
- (about: "tests clap library")
- (author: "Kevin K. <kbknapp@gmail.com>")
- (@group difficulty !required =>
- (@arg hard: -h --hard "Sets hard mode")
- (@arg normal: -n --normal "Sets normal mode")
- (@arg easy: -e --easy "Sets easy mode")
- )
- );
-
- let result = app.get_matches_from_safe(vec!["bin_name"]);
- assert!(result.is_ok());
- let matches = result.expect("Expected to successfully match the given args.");
- assert!(!matches.is_present("difficulty"));
-}
-
-#[test]
-fn multiarg() {
- let app = || clap_app!(
- claptests =>
- (@arg flag: --flag "value")
- (@arg multiarg: --multiarg
- default_value("flag-unset") default_value_if("flag", None, "flag-set")
- "multiarg")
- (@arg multiarg2: --multiarg2
- default_value("flag-unset") default_value_if("flag", None, "flag-set",)
- "multiarg2")
- );
-
- let matches = app()
- .get_matches_from_safe(vec!["bin_name"])
- .expect("match failed");
- assert_eq!(matches.value_of("multiarg"), Some("flag-unset"));
- assert_eq!(matches.value_of("multiarg2"), Some("flag-unset"));
-
- let matches = app()
- .get_matches_from_safe(vec!["bin_name", "--flag"])
- .expect("match failed");
- assert_eq!(matches.value_of("multiarg"), Some("flag-set"));
- assert_eq!(matches.value_of("multiarg2"), Some("flag-set"));
-}
-
-#[test]
-fn arg_enum() {
- // Helper macros to avoid repetition
- macro_rules! test_greek {
- ($arg_enum:item, $tests:block) => {{
- $arg_enum
- // FromStr implementation
- assert!("Charlie".parse::<Greek>().is_err());
- // Display implementation
- assert_eq!(format!("{}", Greek::Alpha), "Alpha");
- assert_eq!(format!("{}", Greek::Bravo), "Bravo");
- // fn variants()
- assert_eq!(Greek::variants(), ["Alpha", "Bravo"]);
- // rest of tests
- $tests
- }};
- }
- macro_rules! test_greek_no_meta {
- {$arg_enum:item} => {
- test_greek!($arg_enum, {
- // FromStr implementation
- assert!("Alpha".parse::<Greek>().is_ok());
- assert!("Bravo".parse::<Greek>().is_ok());
- })
- };
- }
- macro_rules! test_greek_meta {
- {$arg_enum:item} => {
- test_greek!($arg_enum, {
- // FromStr implementation
- assert_eq!("Alpha".parse::<Greek>(), Ok(Greek::Alpha));
- assert_eq!("Bravo".parse::<Greek>(), Ok(Greek::Bravo));
- })
- };
- }
-
- // Tests for each pattern
- // meta NO, pub NO, trailing comma NO
- test_greek_no_meta!{
- arg_enum!{
- enum Greek {
- Alpha,
- Bravo
- }
- }
- };
- // meta NO, pub NO, trailing comma YES
- test_greek_no_meta!{
- arg_enum!{
- enum Greek {
- Alpha,
- Bravo,
- }
- }
- };
- // meta NO, pub YES, trailing comma NO
- test_greek_no_meta!{
- arg_enum!{
- pub enum Greek {
- Alpha,
- Bravo
- }
- }
- };
- // meta NO, pub YES, trailing comma YES
- test_greek_no_meta!{
- arg_enum!{
- pub enum Greek {
- Alpha,
- Bravo,
- }
- }
- };
- // meta YES, pub NO, trailing comma NO
- test_greek_meta!{
- arg_enum!{
- #[derive(Debug, PartialEq, Copy, Clone)]
- enum Greek {
- Alpha,
- Bravo
- }
- }
- };
- // meta YES, pub NO, trailing comma YES
- test_greek_meta!{
- arg_enum!{
- #[derive(Debug, PartialEq, Copy, Clone)]
- enum Greek {
- Alpha,
- Bravo,
- }
- }
- };
- // meta YES, pub YES, trailing comma NO
- test_greek_meta!{
- arg_enum!{
- #[derive(Debug, PartialEq, Copy, Clone)]
- pub enum Greek {
- Alpha,
- Bravo
- }
- }
- };
- // meta YES, pub YES, trailing comma YES
- test_greek_meta!{
- arg_enum!{
- #[derive(Debug, PartialEq, Copy, Clone)]
- pub enum Greek {
- Alpha,
- Bravo,
- }
- }
- };
-}
diff --git a/clap/tests/multiple_occurrences.rs b/clap/tests/multiple_occurrences.rs
deleted file mode 100644
index 2f92fb1..0000000
--- a/clap/tests/multiple_occurrences.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-#[test]
-fn multiple_occurrences_of_flags_long() {
- let m = App::new("mo_flags_long")
- .arg(Arg::from_usage("--multflag 'allowed multiple flag'")
- .multiple(true))
- .arg(Arg::from_usage("--flag 'disallowed multiple flag'"))
- .get_matches_from(vec![
- "",
- "--multflag",
- "--flag",
- "--multflag"
- ]);
- assert!(m.is_present("multflag"));
- assert_eq!(m.occurrences_of("multflag"), 2);
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 1)
-}
-
-#[test]
-fn multiple_occurrences_of_flags_short() {
- let m = App::new("mo_flags_short")
- .arg(Arg::from_usage("-m --multflag 'allowed multiple flag'")
- .multiple(true))
- .arg(Arg::from_usage("-f --flag 'disallowed multiple flag'"))
- .get_matches_from(vec![
- "",
- "-m",
- "-f",
- "-m"
- ]);
- assert!(m.is_present("multflag"));
- assert_eq!(m.occurrences_of("multflag"), 2);
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 1);
-}
-
-#[test]
-fn multiple_occurrences_of_flags_mixed() {
- let m = App::new("mo_flags_mixed")
- .arg(Arg::from_usage("-m, --multflag1 'allowed multiple flag'")
- .multiple(true))
- .arg(Arg::from_usage("-n, --multflag2 'another allowed multiple flag'")
- .multiple(true))
- .arg(Arg::from_usage("-f, --flag 'disallowed multiple flag'"))
- .get_matches_from(vec![
- "",
- "-m",
- "-f",
- "-n",
- "--multflag1",
- "-m",
- "--multflag2"
- ]);
- assert!(m.is_present("multflag1"));
- assert_eq!(m.occurrences_of("multflag1"), 3);
- assert!(m.is_present("multflag2"));
- assert_eq!(m.occurrences_of("multflag2"), 2);
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 1);
-}
-
-#[test]
-fn multiple_occurrences_of_flags_large_quantity() {
- let args : Vec<&str> = vec![""].into_iter().chain(vec!["-m"; 1024].into_iter()).collect();
- let m = App::new("mo_flags_larg_qty")
- .arg(Arg::from_usage("-m --multflag 'allowed multiple flag'")
- .multiple(true))
- .get_matches_from(args);
- assert!(m.is_present("multflag"));
- assert_eq!(m.occurrences_of("multflag"), 1024);
-}
diff --git a/clap/tests/multiple_values.rs b/clap/tests/multiple_values.rs
deleted file mode 100644
index 551aff1..0000000
--- a/clap/tests/multiple_values.rs
+++ /dev/null
@@ -1,1122 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, ErrorKind, SubCommand};
-
-#[test]
-fn option_long() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .help("multiple options")
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "--option", "val1",
- "--option", "val2",
- "--option", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 3);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn option_short() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 3);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn option_mixed() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "--option", "val2",
- "--option", "val3",
- "-o", "val4",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 4);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3", "val4"]);
-}
-
-#[test]
-fn option_exact_exact() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .number_of_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 3);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn option_exact_exact_not_mult() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .number_of_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1", "val2", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn option_exact_exact_mult() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .number_of_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1", "val2", "val3",
- "-o", "val4", "val5", "val6",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 2);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3", "val4", "val5", "val6"]);
-}
-
-#[test]
-fn option_exact_less() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .number_of_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- ]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
-}
-
-#[test]
-fn option_exact_more() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .number_of_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- "-o", "val4",
- ]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
-}
-
-#[test]
-fn option_min_exact() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .min_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 3);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn option_min_less() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .min_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- ]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::TooFewValues);
-}
-
-#[test]
-fn option_short_min_more_mult_occurs() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("arg")
- .required(true))
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .min_values(3))
- .get_matches_from_safe(vec![
- "",
- "pos",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- "-o", "val4",
- ]);
-
- let m = m.map_err(|e| println!("failed to unwrap err with error kind {:?}", e.kind)).unwrap();
-
- assert!(m.is_present("option"));
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("option"), 4);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3", "val4"]);
- assert_eq!(m.value_of("arg"), Some("pos"));
-}
-
-#[test]
-fn option_short_min_more_single_occur() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("arg")
- .required(true))
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .min_values(3))
- .get_matches_from_safe(vec![
- "",
- "pos",
- "-o", "val1",
- "val2",
- "val3",
- "val4",
- ]);
-
- let m = m.map_err(|e| println!("failed to unwrap err with error kind {:#?}", e)).unwrap();
-
- assert!(m.is_present("option"));
- assert!(m.is_present("arg"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3", "val4"]);
- assert_eq!(m.value_of("arg"), Some("pos"));
-}
-
-#[test]
-fn option_max_exact() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .max_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 3);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn option_max_less() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .max_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 2);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2"]);
-}
-
-#[test]
-fn option_max_more() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .takes_value(true)
- .multiple(true)
- .max_values(3))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1",
- "-o", "val2",
- "-o", "val3",
- "-o", "val4",
- ]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::TooManyValues);
-}
-
-#[test]
-fn positional() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .multiple(true))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("pos"));
- assert_eq!(m.occurrences_of("pos"), 3);
- assert_eq!(m.values_of("pos").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn positional_exact_exact() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .number_of_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("pos"));
- assert_eq!(m.occurrences_of("pos"), 3);
- assert_eq!(m.values_of("pos").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn positional_exact_less() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .number_of_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
-}
-
-#[test]
-fn positional_exact_more() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .number_of_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3", "val4"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
-}
-
-#[test]
-fn positional_min_exact() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .min_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("pos"));
- assert_eq!(m.occurrences_of("pos"), 3);
- assert_eq!(m.values_of("pos").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn positional_min_less() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .min_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::TooFewValues);
-}
-
-#[test]
-fn positional_min_more() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .min_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3", "val4"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("pos"));
- assert_eq!(m.occurrences_of("pos"), 4);
- assert_eq!(m.values_of("pos").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3", "val4"]);
-}
-
-#[test]
-fn positional_max_exact() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .max_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("pos"));
- assert_eq!(m.occurrences_of("pos"), 3);
- assert_eq!(m.values_of("pos").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn positional_max_less() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .max_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("pos"));
- assert_eq!(m.occurrences_of("pos"), 2);
- assert_eq!(m.values_of("pos").unwrap().collect::<Vec<_>>(), ["val1", "val2"]);
-}
-
-#[test]
-fn positional_max_more() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("pos")
- .help("multiple positionals")
- .max_values(3))
- .get_matches_from_safe(vec!["myprog", "val1", "val2", "val3", "val4"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::TooManyValues);
-}
-
-#[test]
-fn sep_long_equals() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .use_delimiter(true)
- .help("multiple options")
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "--option=val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn sep_long_space() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .use_delimiter(true)
- .help("multiple options")
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "--option",
- "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn sep_short_equals() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .use_delimiter(true)
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "-o=val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn sep_short_space() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .use_delimiter(true)
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "-o",
- "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn sep_short_no_space() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .help("multiple options")
- .use_delimiter(true)
- .takes_value(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "-oval1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn sep_positional() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .help("multiple options")
- .use_delimiter(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "",
- "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn different_sep() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .help("multiple options")
- .takes_value(true)
- .value_delimiter(";"))
- .get_matches_from_safe(vec![
- "",
- "--option=val1;val2;val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn different_sep_positional() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .help("multiple options")
- .value_delimiter(";"))
- .get_matches_from_safe(vec![
- "",
- "val1;val2;val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
-}
-
-#[test]
-fn no_sep() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .help("multiple options")
- .takes_value(true)
- .use_delimiter(false))
- .get_matches_from_safe(vec![
- "",
- "--option=val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn no_sep_positional() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .help("multiple options")
- .use_delimiter(false))
- .get_matches_from_safe(vec![
- "",
- "val1,val2,val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
-}
-
-#[test]
-fn req_delimiter_long() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .multiple(true)
- .use_delimiter(true)
- .require_delimiter(true)
- .takes_value(true))
- .arg(Arg::with_name("args")
- .multiple(true)
- .index(1))
- .get_matches_from_safe(vec![
- "",
- "--option", "val1", "val2", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), &["val1"]);
- assert_eq!(m.values_of("args").unwrap().collect::<Vec<_>>(), &["val2", "val3"]);
-}
-
-#[test]
-fn req_delimiter_long_with_equal() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .multiple(true)
- .use_delimiter(true)
- .require_delimiter(true)
- .takes_value(true))
- .arg(Arg::with_name("args")
- .multiple(true)
- .index(1))
- .get_matches_from_safe(vec![
- "",
- "--option=val1", "val2", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), &["val1"]);
- assert_eq!(m.values_of("args").unwrap().collect::<Vec<_>>(), &["val2", "val3"]);
-}
-
-#[test]
-fn req_delimiter_short_with_space() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .multiple(true)
- .use_delimiter(true)
- .require_delimiter(true)
- .takes_value(true))
- .arg(Arg::with_name("args")
- .multiple(true)
- .index(1))
- .get_matches_from_safe(vec![
- "",
- "-o", "val1", "val2", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), &["val1"]);
- assert_eq!(m.values_of("args").unwrap().collect::<Vec<_>>(), &["val2", "val3"]);
-}
-
-#[test]
-fn req_delimiter_short_with_no_space() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("o")
- .multiple(true)
- .use_delimiter(true)
- .require_delimiter(true)
- .takes_value(true))
- .arg(Arg::with_name("args")
- .multiple(true)
- .index(1))
- .get_matches_from_safe(vec![
- "",
- "-oval1", "val2", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), &["val1"]);
- assert_eq!(m.values_of("args").unwrap().collect::<Vec<_>>(), &["val2", "val3"]);
-}
-
-#[test]
-fn req_delimiter_short_with_equal() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .short("option")
- .multiple(true)
- .use_delimiter(true)
- .require_delimiter(true)
- .takes_value(true))
- .arg(Arg::with_name("args")
- .multiple(true)
- .index(1))
- .get_matches_from_safe(vec![
- "",
- "-o=val1", "val2", "val3",
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 1);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), &["val1"]);
- assert_eq!(m.values_of("args").unwrap().collect::<Vec<_>>(), &["val2", "val3"]);
-}
-
-#[test]
-fn req_delimiter_complex() {
- let m = App::new("multiple_values")
- .arg(Arg::with_name("option")
- .long("option")
- .short("o")
- .multiple(true)
- .use_delimiter(true)
- .require_delimiter(true)
- .takes_value(true))
- .arg(Arg::with_name("args")
- .multiple(true)
- .index(1))
- .get_matches_from_safe(vec![
- "",
- "val1",
- "-oval2", "val3",
- "-o", "val4", "val5",
- "-o=val6", "val7",
- "--option=val8", "val9",
- "--option", "val10", "val11",
- "-oval12,val13", "val14",
- "-o", "val15,val16", "val17",
- "-o=val18,val19", "val20",
- "--option=val21,val22", "val23",
- "--option", "val24,val25", "val26"
- ]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.occurrences_of("option"), 10);
- assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(),
- &["val2", "val4", "val6", "val8", "val10", "val12", "val13", "val15",
- "val16", "val18", "val19", "val21", "val22", "val24", "val25"]);
- assert_eq!(m.values_of("args").unwrap().collect::<Vec<_>>(),
- &["val1", "val3", "val5", "val7", "val9", "val11", "val14", "val17",
- "val20", "val23", "val26"]);
-}
-
-#[test]
-#[should_panic]
-fn low_index_positional_not_required() {
- let _ = App::new("lip")
- .arg(Arg::with_name("files")
- .index(1)
- .required(true)
- .multiple(true))
- .arg(Arg::with_name("target")
- .index(2))
- .get_matches_from_safe(vec![
- "lip",
- "file1", "file2",
- "file3", "target",
- ]);
-}
-
-#[test]
-#[should_panic]
-fn low_index_positional_last_multiple_too() {
- let _ = App::new("lip")
- .arg(Arg::with_name("files")
- .index(1)
- .required(true)
- .multiple(true))
- .arg(Arg::with_name("target")
- .index(2)
- .required(true)
- .multiple(true))
- .get_matches_from_safe(vec![
- "lip",
- "file1", "file2",
- "file3", "target",
- ]);
-}
-
-#[test]
-#[should_panic]
-fn low_index_positional_too_far_back() {
- let _ = App::new("lip")
- .arg(Arg::with_name("files")
- .index(1)
- .required(true)
- .multiple(true))
- .arg(Arg::with_name("target")
- .required(true)
- .index(2))
- .arg(Arg::with_name("target2")
- .required(true)
- .index(3))
- .get_matches_from_safe(vec![
- "lip",
- "file1", "file2",
- "file3", "target",
- ]);
-}
-
-#[test]
-fn low_index_positional() {
- let m = App::new("lip")
- .arg(Arg::with_name("files")
- .index(1)
- .required(true)
- .multiple(true))
- .arg(Arg::with_name("target")
- .index(2)
- .required(true))
- .get_matches_from_safe(vec![
- "lip",
- "file1", "file2",
- "file3", "target",
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
-
- assert!(m.is_present("files"));
- assert_eq!(m.occurrences_of("files"), 3);
- assert!(m.is_present("target"));
- assert_eq!(m.occurrences_of("target"), 1);
- assert_eq!(m.values_of("files").unwrap().collect::<Vec<_>>(), ["file1", "file2", "file3"]);
- assert_eq!(m.value_of("target").unwrap(), "target");
-}
-
-#[test]
-fn low_index_positional_in_subcmd() {
- let m = App::new("lip")
- .subcommand(SubCommand::with_name("test")
- .arg(Arg::with_name("files")
- .index(1)
- .required(true)
- .multiple(true))
- .arg(Arg::with_name("target")
- .index(2)
- .required(true)))
- .get_matches_from_safe(vec![
- "lip", "test",
- "file1", "file2",
- "file3", "target"
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
- let sm = m.subcommand_matches("test").unwrap();
-
- assert!(sm.is_present("files"));
- assert_eq!(sm.occurrences_of("files"), 3);
- assert!(sm.is_present("target"));
- assert_eq!(sm.occurrences_of("target"), 1);
- assert_eq!(sm.values_of("files").unwrap().collect::<Vec<_>>(), ["file1", "file2", "file3"]);
- assert_eq!(sm.value_of("target").unwrap(), "target");
-}
-
-#[test]
-fn low_index_positional_with_option() {
- let m = App::new("lip")
- .arg(Arg::with_name("files")
- .required(true)
- .index(1)
- .multiple(true))
- .arg(Arg::with_name("target")
- .index(2)
- .required(true))
- .arg(Arg::with_name("opt")
- .long("option")
- .takes_value(true))
- .get_matches_from_safe(vec![
- "lip",
- "file1", "file2",
- "file3", "target",
- "--option", "test"
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
-
- assert!(m.is_present("files"));
- assert_eq!(m.occurrences_of("files"), 3);
- assert!(m.is_present("target"));
- assert_eq!(m.occurrences_of("target"), 1);
- assert_eq!(m.values_of("files").unwrap().collect::<Vec<_>>(), ["file1", "file2", "file3"]);
- assert_eq!(m.value_of("target").unwrap(), "target");
- assert_eq!(m.value_of("opt").unwrap(), "test");
-}
-
-#[test]
-fn low_index_positional_with_flag() {
- let m = App::new("lip")
- .arg(Arg::with_name("files")
- .index(1)
- .required(true)
- .multiple(true))
- .arg(Arg::with_name("target")
- .index(2)
- .required(true))
- .arg(Arg::with_name("flg")
- .long("flag"))
- .get_matches_from_safe(vec![
- "lip",
- "file1", "file2",
- "file3", "target",
- "--flag"
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
-
- assert!(m.is_present("files"));
- assert_eq!(m.occurrences_of("files"), 3);
- assert!(m.is_present("target"));
- assert_eq!(m.occurrences_of("target"), 1);
- assert_eq!(m.values_of("files").unwrap().collect::<Vec<_>>(), ["file1", "file2", "file3"]);
- assert_eq!(m.value_of("target").unwrap(), "target");
- assert!(m.is_present("flg"));
-}
-
-#[test]
-fn multiple_value_terminator_option() {
- let m = App::new("lip")
- .arg(Arg::with_name("files")
- .short("f")
- .value_terminator(";")
- .multiple(true))
- .arg(Arg::with_name("other"))
- .get_matches_from_safe(vec![
- "lip",
- "-f", "val1", "val2", ";",
- "otherval"
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
-
- assert!(m.is_present("other"));
- assert_eq!(m.occurrences_of("other"), 1);
- assert!(m.is_present("files"));
- assert_eq!(m.values_of("files").unwrap().collect::<Vec<_>>(), ["val1", "val2"]);
- assert_eq!(m.value_of("other"), Some("otherval"));
-}
-
-#[test]
-fn multiple_value_terminator_option_other_arg() {
- let m = App::new("lip")
- .arg(Arg::with_name("files")
- .short("f")
- .value_terminator(";")
- .multiple(true))
- .arg(Arg::with_name("other"))
- .arg(Arg::with_name("flag")
- .short("-F"))
- .get_matches_from_safe(vec![
- "lip",
- "-f", "val1", "val2",
- "-F",
- "otherval"
- ]);
-
- assert!(m.is_ok(), "{:?}", m.unwrap_err().kind);
- let m = m.unwrap();
-
- assert!(m.is_present("other"));
- assert!(m.is_present("files"));
- assert_eq!(m.values_of("files").unwrap().collect::<Vec<_>>(), ["val1", "val2"]);
- assert_eq!(m.value_of("other"), Some("otherval"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn multiple_vals_with_hyphen() {
- let res = App::new("do")
- .arg(Arg::with_name("cmds")
- .multiple(true)
- .allow_hyphen_values(true)
- .value_terminator(";"))
- .arg(Arg::with_name("location"))
- .get_matches_from_safe(vec!["do", "find", "-type", "f", "-name", "special", ";", "/home/clap"]);
- assert!(res.is_ok(), "{:?}", res.unwrap_err().kind);
-
- let m = res.unwrap();
- let cmds: Vec<_> = m.values_of("cmds").unwrap().collect();
- assert_eq!(&cmds, &["find", "-type", "f", "-name", "special"]);
- assert_eq!(m.value_of("location"), Some("/home/clap"));
-}
diff --git a/clap/tests/opts.rs b/clap/tests/opts.rs
deleted file mode 100644
index a9029ac..0000000
--- a/clap/tests/opts.rs
+++ /dev/null
@@ -1,461 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, ArgMatches, Arg, ErrorKind};
-
-#[cfg(feature = "suggestions")]
-static DYM: &'static str = "error: Found argument '--optio' which wasn't expected, or isn't valid in this context
-\tDid you mean --option?
-
-USAGE:
- clap-test --option <opt>...
-
-For more information try --help";
-
-#[test]
-fn require_equals_fail() {
- let res = App::new("prog")
- .arg(Arg::with_name("cfg")
- .require_equals(true)
- .takes_value(true)
- .long("config"))
- .get_matches_from_safe(vec![
- "prog", "--config", "file.conf"
- ]);
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
-}
-
-#[test]
-fn require_equals_min_values_zero() {
- let res = App::new("prog")
- .arg(Arg::with_name("cfg")
- .require_equals(true)
- .takes_value(true)
- .min_values(0)
- .long("config"))
- .arg(Arg::with_name("cmd"))
- .get_matches_from_safe(vec![
- "prog", "--config", "cmd"
- ]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("cfg"));
- assert_eq!(m.value_of("cmd"), Some("cmd"));
-}
-
-#[test]
-fn double_hyphen_as_value() {
- let res = App::new("prog")
- .arg(Arg::with_name("cfg")
- .takes_value(true)
- .allow_hyphen_values(true)
- .long("config"))
- .get_matches_from_safe(vec![
- "prog", "--config", "--"
- ]);
- assert!(res.is_ok(), "{:?}", res);
- assert_eq!(res.unwrap().value_of("cfg"), Some("--"));
-}
-
-#[test]
-fn require_equals_no_empty_values_fail() {
- let res = App::new("prog")
- .arg(Arg::with_name("cfg")
- .require_equals(true)
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("some"))
- .get_matches_from_safe(vec![
- "prog", "--config=", "file.conf"
- ]);
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
-}
-
-#[test]
-fn require_equals_empty_vals_pass() {
- let res = App::new("prog")
- .arg(Arg::with_name("cfg")
- .require_equals(true)
- .takes_value(true)
- .empty_values(true)
- .long("config"))
- .get_matches_from_safe(vec![
- "prog", "--config="
- ]);
- assert!(res.is_ok());
-}
-
-#[test]
-fn require_equals_pass() {
- let res = App::new("prog")
- .arg(Arg::with_name("cfg")
- .require_equals(true)
- .takes_value(true)
- .long("config"))
- .get_matches_from_safe(vec![
- "prog", "--config=file.conf"
- ]);
- assert!(res.is_ok());
-}
-
-#[test]
-fn stdin_char() {
- let r = App::new("opts")
- .arg(Arg::from_usage("-f [flag] 'some flag'"))
- .get_matches_from_safe(vec!["", "-f", "-"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("f"));
- assert_eq!(m.value_of("f").unwrap(), "-");
-}
-
-#[test]
-fn opts_using_short() {
- let r = App::new("opts")
- .args(&[Arg::from_usage("-f [flag] 'some flag'"),
- Arg::from_usage("-c [color] 'some other flag'")])
- .get_matches_from_safe(vec!["", "-f", "some", "-c", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("f"));
- assert_eq!(m.value_of("f").unwrap(), "some");
- assert!(m.is_present("c"));
- assert_eq!(m.value_of("c").unwrap(), "other");
-}
-
-#[test]
-fn lots_o_vals() {
- let r = App::new("opts")
- .arg(Arg::from_usage("-o [opt]... 'some opt'"))
- .get_matches_from_safe(vec!["", "-o", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>().len(), 297); // i.e. more than u8
-}
-
-#[test]
-fn opts_using_long_space() {
- let r = App::new("opts")
- .args(&[Arg::from_usage("--flag [flag] 'some flag'"),
- Arg::from_usage("--color [color] 'some other flag'")])
- .get_matches_from_safe(vec!["", "--flag", "some", "--color", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "some");
- assert!(m.is_present("color"));
- assert_eq!(m.value_of("color").unwrap(), "other");
-}
-
-#[test]
-fn opts_using_long_equals() {
- let r = App::new("opts")
- .args(&[Arg::from_usage("--flag [flag] 'some flag'"),
- Arg::from_usage("--color [color] 'some other flag'")])
- .get_matches_from_safe(vec!["", "--flag=some", "--color=other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "some");
- assert!(m.is_present("color"));
- assert_eq!(m.value_of("color").unwrap(), "other");
-}
-
-#[test]
-fn opts_using_mixed() {
- let r = App::new("opts")
- .args(&[Arg::from_usage("-f, --flag [flag] 'some flag'"),
- Arg::from_usage("-c, --color [color] 'some other flag'")])
- .get_matches_from_safe(vec!["", "-f", "some", "--color", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "some");
- assert!(m.is_present("color"));
- assert_eq!(m.value_of("color").unwrap(), "other");
-}
-
-#[test]
-fn opts_using_mixed2() {
- let r = App::new("opts")
- .args(&[Arg::from_usage("-f, --flag [flag] 'some flag'"),
- Arg::from_usage("-c, --color [color] 'some other flag'")])
- .get_matches_from_safe(vec!["", "--flag=some", "-c", "other"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "some");
- assert!(m.is_present("color"));
- assert_eq!(m.value_of("color").unwrap(), "other");
-}
-
-#[test]
-fn default_values_user_value() {
- let r = App::new("df")
- .arg(Arg::from_usage("-o [opt] 'some opt'").default_value("default"))
- .get_matches_from_safe(vec!["", "-o", "value"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.value_of("o").unwrap(), "value");
-}
-
-#[test]
-fn multiple_vals_pos_arg_equals() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'"))
- .arg(Arg::from_usage("[file] 'some file'"))
- .get_matches_from_safe(vec!["", "-o=1", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.value_of("o").unwrap(), "1");
- assert!(m.is_present("file"));
- assert_eq!(m.value_of("file").unwrap(), "some");
-}
-
-#[test]
-fn multiple_vals_pos_arg_delim() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'"))
- .arg(Arg::from_usage("[file] 'some file'"))
- .get_matches_from_safe(vec!["", "-o", "1,2", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>(), &["1", "2"]);
- assert!(m.is_present("file"));
- assert_eq!(m.value_of("file").unwrap(), "some");
-}
-
-#[test]
-fn require_delims_no_delim() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'").require_delimiter(true))
- .arg(Arg::from_usage("[file] 'some file'"))
- .get_matches_from_safe(vec!["mvae", "-o", "1", "2", "some"]);
- assert!(r.is_err());
- let err = r.unwrap_err();
- assert_eq!(err.kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn require_delims() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'").require_delimiter(true))
- .arg(Arg::from_usage("[file] 'some file'"))
- .get_matches_from_safe(vec!["", "-o", "1,2", "some"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>(), &["1", "2"]);
- assert!(m.is_present("file"));
- assert_eq!(m.value_of("file").unwrap(), "some");
-}
-
-#[test]
-fn leading_hyphen_pass() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'").allow_hyphen_values(true))
- .get_matches_from_safe(vec!["", "-o", "-2", "3"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>(), &["-2", "3"]);
-}
-
-#[test]
-fn leading_hyphen_fail() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt] 'some opt'"))
- .get_matches_from_safe(vec!["", "-o", "-2"]);
- assert!(r.is_err());
- let m = r.unwrap_err();
- assert_eq!(m.kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn leading_hyphen_with_flag_after() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'").allow_hyphen_values(true))
- .arg_from_usage("-f 'some flag'")
- .get_matches_from_safe(vec!["", "-o", "-2", "-f"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>(), &["-2", "-f"]);
- assert!(!m.is_present("f"));
-}
-
-#[test]
-fn leading_hyphen_with_flag_before() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'").allow_hyphen_values(true))
- .arg_from_usage("-f 'some flag'")
- .get_matches_from_safe(vec!["", "-f", "-o", "-2"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>(), &["-2"]);
- assert!(m.is_present("f"));
-}
-
-#[test]
-fn leading_hyphen_with_only_pos_follows() {
- let r = App::new("mvae")
- .arg(Arg::from_usage("-o [opt]... 'some opt'").number_of_values(1).allow_hyphen_values(true))
- .arg_from_usage("[arg] 'some arg'")
- .get_matches_from_safe(vec!["", "-o", "-2", "--", "val"]);
- assert!(r.is_ok(), "{:?}", r);
- let m = r.unwrap();
- assert!(m.is_present("o"));
- assert_eq!(m.values_of("o").unwrap().collect::<Vec<_>>(), &["-2"]);
- assert_eq!(m.value_of("arg"), Some("val"));
-}
-
-#[test]
-#[cfg(feature="suggestions")]
-fn did_you_mean() {
- assert!(test::compare_output(test::complex_app(),
- "clap-test --optio=foo",
- DYM,
- true));
-}
-
-#[test]
-fn issue_665() {
- let res = App::new("tester")
- .arg_from_usage("-v, --reroll-count=[N] 'Mark the patch series as PATCH vN'")
- .arg(Arg::from_usage(
-"--subject-prefix [Subject-Prefix] 'Use [Subject-Prefix] instead of the standard [PATCH] prefix'")
- .empty_values(false))
- .get_matches_from_safe(vec!["test", "--subject-prefix", "-v", "2"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
-}
-
-#[test]
-fn issue_1047_min_zero_vals_default_val() {
- let m = App::new("foo")
- .arg(
- Arg::with_name("del")
- .short("d")
- .long("del")
- .takes_value(true)
- .require_equals(true)
- .min_values(0)
- .default_value("default"),
- )
- .get_matches_from(vec!["foo", "-d"]);
- assert_eq!(m.occurrences_of("del"), 1);
- assert_eq!(m.value_of("del"), Some("default"));
-}
-
-fn issue_1105_setup(argv: Vec<&'static str>) -> Result<ArgMatches<'static>, clap::Error> {
- App::new("opts")
- .arg_from_usage("-o, --option [opt] 'some option'")
- .arg_from_usage("--flag 'some flag'")
- .get_matches_from_safe(argv)
-}
-
-#[test]
-fn issue_1105_empty_value_long_fail() {
- let r = issue_1105_setup(vec!["app", "--option", "--flag"]);
- assert!(r.is_err());
- assert_eq!(r.unwrap_err().kind, ErrorKind::EmptyValue);
-}
-
-#[test]
-fn issue_1105_empty_value_long_explicit() {
- let r = issue_1105_setup(vec!["app", "--option", ""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert_eq!(m.value_of("option"), Some(""));
-}
-
-#[test]
-fn issue_1105_empty_value_long_equals() {
- let r = issue_1105_setup(vec!["app", "--option="]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert_eq!(m.value_of("option"), Some(""));
-}
-
-#[test]
-fn issue_1105_empty_value_short_fail() {
- let r = issue_1105_setup(vec!["app", "-o", "--flag"]);
- assert!(r.is_err());
- assert_eq!(r.unwrap_err().kind, ErrorKind::EmptyValue);
-}
-
-#[test]
-fn issue_1105_empty_value_short_explicit() {
- let r = issue_1105_setup(vec!["app", "-o", ""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert_eq!(m.value_of("option"), Some(""));
-}
-
-#[test]
-fn issue_1105_empty_value_short_equals() {
- let r = issue_1105_setup(vec!["app", "-o="]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert_eq!(m.value_of("option"), Some(""));
-}
-
-#[test]
-fn issue_1105_empty_value_short_explicit_no_space() {
- let r = issue_1105_setup(vec!["app", "-o", ""]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert_eq!(m.value_of("option"), Some(""));
-}
diff --git a/clap/tests/positionals.rs b/clap/tests/positionals.rs
deleted file mode 100644
index bf0f79f..0000000
--- a/clap/tests/positionals.rs
+++ /dev/null
@@ -1,274 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, ErrorKind};
-
-#[test]
-fn only_pos_follow() {
- let r = App::new("onlypos")
- .args(&[Arg::from_usage("-f [flag] 'some opt'"),
- Arg::from_usage("[arg] 'some arg'")])
- .get_matches_from_safe(vec!["", "--", "-f"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert!(!m.is_present("f"));
- assert_eq!(m.value_of("arg").unwrap(), "-f");
-}
-
-#[test]
-fn issue_946() {
- let r = App::new("compiletest")
- .setting(clap::AppSettings::AllowLeadingHyphen)
- .args_from_usage("--exact 'filters match exactly'")
- .arg(clap::Arg::with_name("filter")
- .index(1)
- .takes_value(true)
- .help("filters to apply to output"))
- .get_matches_from_safe(vec!["compiletest", "--exact"]);
- assert!(r.is_ok(), "{:#?}", r);
- let matches = r.unwrap();
-
- assert!(matches.is_present("exact"));
- assert!(matches.value_of("filter").is_none());
-}
-
-#[test]
-fn positional() {
- let r = App::new("positional")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::with_name("positional")
- .index(1)
- ])
- .get_matches_from_safe(vec!["", "-f", "test"]);
- assert!(r.is_ok(), "{:#?}", r);
- let m = r.unwrap();
- assert!(m.is_present("positional"));
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("positional").unwrap(), "test");
-
- let m = App::new("positional")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::with_name("positional")
- .index(1)
- ])
- .get_matches_from(vec!["", "test", "--flag"]);
- assert!(m.is_present("positional"));
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("positional").unwrap(), "test");
-}
-
-#[test]
-fn lots_o_vals() {
- let r = App::new("opts")
- .arg(
- Arg::from_usage("[opt]... 'some pos'"),
- )
- .get_matches_from_safe(vec!["",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some",
- ]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>().len(), 297); // i.e. more than u8
-}
-
-#[test]
-fn positional_multiple() {
- let r = App::new("positional_multiple")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::with_name("positional")
- .index(1)
- .multiple(true)
- ])
- .get_matches_from_safe(vec!["", "-f", "test1", "test2", "test3"]);
- assert!(r.is_ok(), "{:#?}", r);
- let m = r.unwrap();
- assert!(m.is_present("positional"));
- assert!(m.is_present("flag"));
- assert_eq!(&*m.values_of("positional").unwrap().collect::<Vec<_>>(), &["test1", "test2", "test3"]);
-}
-
-#[test]
-fn positional_multiple_3() {
- let r = App::new("positional_multiple")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::with_name("positional")
- .index(1)
- .multiple(true)
- ])
- .get_matches_from_safe(vec!["", "test1", "test2", "test3", "--flag"]);
- assert!(r.is_ok(), "{:#?}", r);
- let m = r.unwrap();
- assert!(m.is_present("positional"));
- assert!(m.is_present("flag"));
- assert_eq!(&*m.values_of("positional").unwrap().collect::<Vec<_>>(), &["test1", "test2", "test3"]);
-}
-
-#[test]
-fn positional_multiple_2() {
- let result = App::new("positional_multiple")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::with_name("positional")
- .index(1)
- ])
- .get_matches_from_safe(vec!["", "-f", "test1", "test2", "test3"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn positional_possible_values() {
- let r = App::new("positional_possible_values")
- .args(&[
- Arg::from_usage("-f, --flag 'some flag'"),
- Arg::with_name("positional")
- .index(1)
- .possible_value("test123")
- ])
- .get_matches_from_safe(vec!["", "-f", "test123"]);
- assert!(r.is_ok(), "{:#?}", r);
- let m = r.unwrap();
- assert!(m.is_present("positional"));
- assert!(m.is_present("flag"));
- assert_eq!(&*m.values_of("positional").unwrap().collect::<Vec<_>>(), &["test123"]);
-}
-
-#[test]
-fn create_positional() {
- let _ = App::new("test")
- .arg(Arg::with_name("test")
- .index(1)
- .help("testing testing"))
- .get_matches_from(vec![""]);
-}
-
-#[test]
-fn positional_hyphen_does_not_panic() {
- let _ = App::new("test")
- .arg(Arg::with_name("dummy"))
- .get_matches_from(vec!["test", "-"]);
-}
-
-#[test]
-fn single_positional_usage_string() {
- let m = App::new("test").arg_from_usage("[FILE] 'some file'").get_matches_from(vec!["test"]);
- assert_eq!(m.usage(), "USAGE:\n test [FILE]");
-}
-
-#[test]
-fn single_positional_multiple_usage_string() {
- let m = App::new("test").arg_from_usage("[FILE]... 'some file'").get_matches_from(vec!["test"]);
- assert_eq!(m.usage(), "USAGE:\n test [FILE]...");
-}
-
-#[test]
-fn multiple_positional_usage_string() {
- let m = App::new("test")
- .arg_from_usage("[FILE] 'some file'")
- .arg_from_usage("[FILES]... 'some file'")
- .get_matches_from(vec!["test"]);
- assert_eq!(m.usage(), "USAGE:\n test [ARGS]");
-}
-
-#[test]
-fn multiple_positional_one_required_usage_string() {
- let m = App::new("test")
- .arg_from_usage("<FILE> 'some file'")
- .arg_from_usage("[FILES]... 'some file'")
- .get_matches_from(vec!["test", "file"]);
- assert_eq!(m.usage(), "USAGE:\n test <FILE> [FILES]...");
-}
-
-#[test]
-fn single_positional_required_usage_string() {
- let m = App::new("test")
- .arg_from_usage("<FILE> 'some file'")
- .get_matches_from(vec!["test", "file"]);
- assert_eq!(m.usage(), "USAGE:\n test <FILE>");
-}
-
-#[test]
-#[should_panic]
-fn missing_required() {
- let r = App::new("test")
- .arg_from_usage("[FILE1] 'some file'")
- .arg_from_usage("<FILE2> 'some file'")
- .get_matches_from_safe(vec!["test", "file"]);
- assert!(r.is_err());
- assert_eq!(r.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn missing_required_2() {
- let r = App::new("test")
- .arg_from_usage("<FILE1> 'some file'")
- .arg_from_usage("<FILE2> 'some file'")
- .get_matches_from_safe(vec!["test", "file"]);
- assert!(r.is_err());
- assert_eq!(r.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn last_positional() {
- let r = App::new("test")
- .arg_from_usage("<TARGET> 'some target'")
- .arg_from_usage("[CORPUS] 'some corpus'")
- .arg(Arg::from_usage("[ARGS]... 'some file'").last(true))
- .get_matches_from_safe(vec!["test", "tgt", "--", "arg"]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert_eq!(m.values_of("ARGS").unwrap().collect::<Vec<_>>(), &["arg"]);
-}
-
-#[test]
-fn last_positional_no_double_dash() {
- let r = App::new("test")
- .arg_from_usage("<TARGET> 'some target'")
- .arg_from_usage("[CORPUS] 'some corpus'")
- .arg(Arg::from_usage("[ARGS]... 'some file'").last(true))
- .get_matches_from_safe(vec!["test", "tgt", "crp", "arg"]);
- assert!(r.is_err());
- assert_eq!(r.unwrap_err().kind, ErrorKind::UnknownArgument);
-}
-
-#[test]
-fn last_positional_second_to_last_mult() {
- let r = App::new("test")
- .arg_from_usage("<TARGET> 'some target'")
- .arg_from_usage("[CORPUS]... 'some corpus'")
- .arg(Arg::from_usage("[ARGS]... 'some file'").last(true))
- .get_matches_from_safe(vec!["test", "tgt", "crp1", "crp2", "--", "arg"]);
- assert!(r.is_ok(), "{:?}", r.unwrap_err().kind);
-}
diff --git a/clap/tests/posix_compatible.rs b/clap/tests/posix_compatible.rs
deleted file mode 100644
index 26d9f71..0000000
--- a/clap/tests/posix_compatible.rs
+++ /dev/null
@@ -1,292 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg, ErrorKind};
-
-#[test]
-fn flag_overrides_itself() {
- let res = App::new("posix")
- .arg(Arg::from_usage("--flag 'some flag'").overrides_with("flag"))
- .get_matches_from_safe(vec!["", "--flag", "--flag"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 1);
-}
-
-#[test]
-fn mult_flag_overrides_itself() {
- let res = App::new("posix")
- .arg(Arg::from_usage("--flag... 'some flag'").overrides_with("flag"))
- .get_matches_from_safe(vec!["", "--flag", "--flag", "--flag", "--flag"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("flag"));
- assert_eq!(m.occurrences_of("flag"), 4);
-}
-
-#[test]
-fn option_overrides_itself() {
- let res = App::new("posix")
- .arg(Arg::from_usage("--opt [val] 'some option'").overrides_with("opt"))
- .get_matches_from_safe(vec!["", "--opt=some", "--opt=other"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 1);
- assert_eq!(m.value_of("opt"), Some("other"));
-}
-
-#[test]
-fn mult_option_require_delim_overrides_itself() {
- let res = App::new("posix")
- .arg(Arg::from_usage("--opt [val]... 'some option'")
- .overrides_with("opt")
- .number_of_values(1)
- .require_delimiter(true))
- .get_matches_from_safe(vec!["", "--opt=some", "--opt=other", "--opt=one,two"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 3);
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["some", "other", "one", "two"]);
-}
-
-#[test]
-fn mult_option_overrides_itself() {
- let res = App::new("posix")
- .arg(Arg::from_usage("--opt [val]... 'some option'")
- .overrides_with("opt"))
- .get_matches_from_safe(vec!["", "--opt", "first", "overides", "--opt", "some", "other", "val"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 2);
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["first", "overides", "some", "other", "val"]);
-}
-
-#[test]
-fn option_use_delim_false_override_itself() {
-
- let m = App::new("posix")
- .arg(Arg::from_usage("--opt [val] 'some option'")
- .overrides_with("opt")
- .use_delimiter(false))
- .get_matches_from(vec!["", "--opt=some,other", "--opt=one,two"]);
- assert!(m.is_present("opt"));
- assert_eq!(m.occurrences_of("opt"), 1);
- assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["one,two"]);
-}
-
-#[test]
-fn pos_mult_overrides_itself() {
- // opts with multiple
- let res = App::new("posix")
- .arg(Arg::from_usage("[val]... 'some pos'").overrides_with("val"))
- .get_matches_from_safe(vec!["", "some", "other", "value"]);
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("val"));
- assert_eq!(m.occurrences_of("val"), 3);
- assert_eq!(m.values_of("val").unwrap().collect::<Vec<_>>(), &["some", "other", "value"]);
-}
-
-#[test]
-fn posix_compatible_flags_long() {
- let m = App::new("posix")
- .arg(Arg::from_usage("--flag 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("--color 'some other flag'"))
- .get_matches_from(vec!["", "--flag", "--color"]);
- assert!(m.is_present("color"));
- assert!(!m.is_present("flag"));
-
- let m = App::new("posix")
- .arg(Arg::from_usage("--flag 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("--color 'some other flag'"))
- .get_matches_from(vec!["", "--color", "--flag"]);
- assert!(!m.is_present("color"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn posix_compatible_flags_short() {
- let m = App::new("posix")
- .arg(Arg::from_usage("-f, --flag 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("-c, --color 'some other flag'"))
- .get_matches_from(vec!["", "-f", "-c"]);
- assert!(m.is_present("color"));
- assert!(!m.is_present("flag"));
-
- let m = App::new("posix")
- .arg(Arg::from_usage("-f, --flag 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("-c, --color 'some other flag'"))
- .get_matches_from(vec!["", "-c", "-f"]);
- assert!(!m.is_present("color"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn posix_compatible_opts_long() {
- let m = App::new("posix")
- .arg(Arg::from_usage("--flag [flag] 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("--color [color] 'some other flag'"))
- .get_matches_from(vec!["", "--flag", "some" ,"--color", "other"]);
- assert!(m.is_present("color"));
- assert_eq!(m.value_of("color").unwrap(), "other");
- assert!(!m.is_present("flag"));
-
- let m = App::new("posix")
- .arg(Arg::from_usage("--flag [flag] 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("--color [color] 'some other flag'"))
- .get_matches_from(vec!["", "--color", "some" ,"--flag", "other"]);
- assert!(!m.is_present("color"));
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "other");
-}
-
-#[test]
-fn posix_compatible_opts_long_equals() {
- let m = App::new("posix")
- .arg(Arg::from_usage("--flag [flag] 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("--color [color] 'some other flag'"))
- .get_matches_from(vec!["", "--flag=some" ,"--color=other"]);
- assert!(m.is_present("color"));
- assert_eq!(m.value_of("color").unwrap(), "other");
- assert!(!m.is_present("flag"));
-
- let m = App::new("posix")
- .arg(Arg::from_usage("--flag [flag] 'some flag'").overrides_with("color"))
- .arg(Arg::from_usage("--color [color] 'some other flag'"))
- .get_matches_from(vec!["", "--color=some" ,"--flag=other"]);
- assert!(!m.is_present("color"));
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "other");
-}
-
-#[test]
-fn posix_compatible_opts_short() {
- let m = App::new("posix")
- .arg(Arg::from_usage("-f [flag] 'some flag'").overrides_with("c"))
- .arg(Arg::from_usage("-c [color] 'some other flag'"))
- .get_matches_from(vec!["", "-f", "some", "-c", "other"]);
- assert!(m.is_present("c"));
- assert_eq!(m.value_of("c").unwrap(), "other");
- assert!(!m.is_present("f"));
-
- let m = App::new("posix")
- .arg(Arg::from_usage("-f [flag] 'some flag'").overrides_with("c"))
- .arg(Arg::from_usage("-c [color] 'some other flag'"))
- .get_matches_from(vec!["", "-c", "some", "-f", "other"]);
- assert!(!m.is_present("c"));
- assert!(m.is_present("f"));
- assert_eq!(m.value_of("f").unwrap(), "other");
-}
-
-#[test]
-fn conflict_overriden() {
- let m = App::new("conflict_overriden")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("debug"))
- .arg(Arg::from_usage("-d, --debug 'other flag'"))
- .arg(Arg::from_usage("-c, --color 'third flag'")
- .overrides_with("flag"))
- .get_matches_from(vec!["", "-f", "-c", "-d"]);
- assert!(m.is_present("color"));
- assert!(!m.is_present("flag"));
- assert!(m.is_present("debug"));
-}
-
-#[test]
-fn conflict_overriden_2() {
- let result = App::new("conflict_overriden")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("debug"))
- .arg(Arg::from_usage("-d, --debug 'other flag'"))
- .arg(Arg::from_usage("-c, --color 'third flag'")
- .overrides_with("flag"))
- .get_matches_from_safe(vec!["", "-f", "-d", "-c"]);
- assert!(result.is_ok());
- let m = result.unwrap();
- assert!(m.is_present("color"));
- assert!(m.is_present("debug"));
- assert!(!m.is_present("flag"));
-}
-
-#[test]
-fn conflict_overriden_3() {
- let result = App::new("conflict_overriden")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("debug"))
- .arg(Arg::from_usage("-d, --debug 'other flag'"))
- .arg(Arg::from_usage("-c, --color 'third flag'")
- .overrides_with("flag"))
- .get_matches_from_safe(vec!["", "-d", "-c", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::ArgumentConflict);
-}
-
-#[test]
-fn conflict_overriden_4() {
- let m = App::new("conflict_overriden")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .conflicts_with("debug"))
- .arg(Arg::from_usage("-d, --debug 'other flag'"))
- .arg(Arg::from_usage("-c, --color 'third flag'")
- .overrides_with("flag"))
- .get_matches_from(vec!["", "-d", "-f", "-c"]);
- assert!(m.is_present("color"));
- assert!(!m.is_present("flag"));
- assert!(m.is_present("debug"));
-}
-
-#[test]
-fn pos_required_overridden_by_flag() {
- let result = App::new("require_overriden")
- .arg(Arg::with_name("pos")
- .index(1)
- .required(true))
- .arg(Arg::from_usage("-c, --color 'some flag'")
- .overrides_with("pos"))
- .get_matches_from_safe(vec!["", "test", "-c"]);
- assert!(result.is_ok(), "{:?}", result.unwrap_err());
-}
-
-#[test]
-fn require_overriden_2() {
- let m = App::new("require_overriden")
- .arg(Arg::with_name("req_pos")
- .required(true))
- .arg(Arg::from_usage("-c, --color 'other flag'")
- .overrides_with("req_pos"))
- .get_matches_from(vec!["", "-c", "req_pos"]);
- assert!(!m.is_present("color"));
- assert!(m.is_present("req_pos"));
-}
-
-#[test]
-fn require_overriden_3() {
- let m = App::new("require_overriden")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .requires("debug"))
- .arg(Arg::from_usage("-d, --debug 'other flag'"))
- .arg(Arg::from_usage("-c, --color 'third flag'")
- .overrides_with("flag"))
- .get_matches_from(vec!["", "-f", "-c"]);
- assert!(m.is_present("color"));
- assert!(!m.is_present("flag"));
- assert!(!m.is_present("debug"));
-}
-
-#[test]
-fn require_overriden_4() {
- let result = App::new("require_overriden")
- .arg(Arg::from_usage("-f, --flag 'some flag'")
- .requires("debug"))
- .arg(Arg::from_usage("-d, --debug 'other flag'"))
- .arg(Arg::from_usage("-c, --color 'third flag'")
- .overrides_with("flag"))
- .get_matches_from_safe(vec!["", "-c", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
diff --git a/clap/tests/possible_values.rs b/clap/tests/possible_values.rs
deleted file mode 100644
index 80772bd..0000000
--- a/clap/tests/possible_values.rs
+++ /dev/null
@@ -1,266 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-#[allow(deprecated, unused_imports)]
-use std::ascii::AsciiExt;
-
-use clap::{App, Arg, ErrorKind};
-
-#[cfg(feature = "suggestions")]
-static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option <option3>'
-\t[possible values: fast, slow]
-
-\tDid you mean 'slow'?
-
-USAGE:
- clap-test --Option <option3>
-
-For more information try --help";
-
-#[cfg(not(feature = "suggestions"))]
-static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option <option3>'
-\t[possible values: fast, slow]
-
-
-USAGE:
- clap-test --Option <option3>
-
-For more information try --help";
-
-#[test]
-fn possible_values_of_positional() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("positional")
- .index(1)
- .possible_value("test123"),
- )
- .get_matches_from_safe(vec!["myprog", "test123"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("positional"));
- assert_eq!(m.value_of("positional"), Some("test123"));
-}
-
-#[test]
-fn possible_values_of_positional_fail() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("positional")
- .index(1)
- .possible_value("test123"),
- )
- .get_matches_from_safe(vec!["myprog", "notest"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidValue);
-}
-
-#[test]
-fn possible_values_of_positional_multiple() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("positional")
- .index(1)
- .possible_value("test123")
- .possible_value("test321")
- .multiple(true),
- )
- .get_matches_from_safe(vec!["myprog", "test123", "test321"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("positional"));
- assert_eq!(
- m.values_of("positional").unwrap().collect::<Vec<_>>(),
- vec!["test123", "test321"]
- );
-}
-
-#[test]
-fn possible_values_of_positional_multiple_fail() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("positional")
- .index(1)
- .possible_value("test123")
- .possible_value("test321")
- .multiple(true),
- )
- .get_matches_from_safe(vec!["myprog", "test123", "notest"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidValue);
-}
-
-#[test]
-fn possible_values_of_option() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123"),
- )
- .get_matches_from_safe(vec!["myprog", "--option", "test123"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(m.value_of("option"), Some("test123"));
-}
-
-#[test]
-fn possible_values_of_option_fail() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123"),
- )
- .get_matches_from_safe(vec!["myprog", "--option", "notest"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidValue);
-}
-
-#[test]
-fn possible_values_of_option_multiple() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123")
- .possible_value("test321")
- .multiple(true),
- )
- .get_matches_from_safe(vec!["", "--option", "test123", "--option", "test321"]);
-
- assert!(m.is_ok());
- let m = m.unwrap();
-
- assert!(m.is_present("option"));
- assert_eq!(
- m.values_of("option").unwrap().collect::<Vec<_>>(),
- vec!["test123", "test321"]
- );
-}
-
-#[test]
-fn possible_values_of_option_multiple_fail() {
- let m = App::new("possible_values")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123")
- .possible_value("test321")
- .multiple(true),
- )
- .get_matches_from_safe(vec!["", "--option", "test123", "--option", "notest"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidValue);
-}
-
-#[test]
-fn possible_values_output() {
- assert!(test::compare_output(
- test::complex_app(),
- "clap-test -O slo",
- PV_ERROR,
- true
- ));
-}
-
-#[test]
-fn case_insensitive() {
- let m = App::new("pv")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123")
- .possible_value("test321")
- .case_insensitive(true),
- )
- .get_matches_from_safe(vec!["pv", "--option", "TeSt123"]);
-
- assert!(m.is_ok());
- assert!(
- m.unwrap()
- .value_of("option")
- .unwrap()
- .eq_ignore_ascii_case("test123")
- );
-}
-
-#[test]
-fn case_insensitive_faili() {
- let m = App::new("pv")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123")
- .possible_value("test321"),
- )
- .get_matches_from_safe(vec!["pv", "--option", "TeSt123"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidValue);
-}
-
-#[test]
-fn case_insensitive_multiple() {
- let m = App::new("pv")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123")
- .possible_value("test321")
- .multiple(true)
- .case_insensitive(true),
- )
- .get_matches_from_safe(vec!["pv", "--option", "TeSt123", "teST123", "tESt321"]);
-
- assert!(m.is_ok());
- assert_eq!(
- m.unwrap().values_of("option").unwrap().collect::<Vec<_>>(),
- &["TeSt123", "teST123", "tESt321"]
- );
-}
-
-#[test]
-fn case_insensitive_multiple_fail() {
- let m = App::new("pv")
- .arg(
- Arg::with_name("option")
- .short("-o")
- .long("--option")
- .takes_value(true)
- .possible_value("test123")
- .possible_value("test321")
- .multiple(true),
- )
- .get_matches_from_safe(vec!["pv", "--option", "test123", "teST123", "test321"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidValue);
-}
diff --git a/clap/tests/propagate_globals.rs b/clap/tests/propagate_globals.rs
deleted file mode 100644
index ee77ce0..0000000
--- a/clap/tests/propagate_globals.rs
+++ /dev/null
@@ -1,148 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-#[cfg(test)]
-mod tests {
- include!("../clap-test.rs");
- use clap::{App, Arg, SubCommand, ArgMatches};
-
- fn get_app() -> App<'static, 'static> {
- App::new("myprog")
- .arg(Arg::with_name("GLOBAL_ARG")
- .long("global-arg")
- .help(
- "Specifies something needed by the subcommands",
- )
- .global(true)
- .takes_value(true)
- .default_value("default_value"))
- .arg(Arg::with_name("GLOBAL_FLAG")
- .long("global-flag")
- .help(
- "Specifies something needed by the subcommands",
- )
- .multiple(true)
- .global(true))
- .subcommand(SubCommand::with_name("outer")
- .subcommand(SubCommand::with_name("inner")))
- }
-
- fn get_matches(app: App<'static, 'static>, argv: &'static str) -> ArgMatches<'static> {
- app.get_matches_from(argv.split(' ').collect::<Vec<_>>())
- }
-
- fn get_outer_matches<'a>(m: &'a ArgMatches<'static>) -> &'a ArgMatches<'static> {
- m.subcommand_matches("outer").expect("could not access outer subcommand")
- }
-
- fn get_inner_matches<'a>(m: &'a ArgMatches<'static>) -> &'a ArgMatches<'static> {
- get_outer_matches(m).subcommand_matches("inner").expect("could not access inner subcommand")
- }
-
- fn top_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches<'static>, val: T) -> bool {
- m.value_of("GLOBAL_ARG") == val.into()
- }
-
- fn inner_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches<'static>, val: T) -> bool {
- get_inner_matches(m).value_of("GLOBAL_ARG") == val.into()
- }
-
- fn outer_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches<'static>, val: T) -> bool {
- get_outer_matches(m).value_of("GLOBAL_ARG") == val.into()
- }
-
- fn top_can_access_flag(m: &ArgMatches<'static>, present: bool, occurrences: u64) -> bool {
- (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
- }
-
- fn inner_can_access_flag(m: &ArgMatches<'static>, present: bool, occurrences: u64) -> bool {
- let m = get_inner_matches(m);
- (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
- }
-
- fn outer_can_access_flag(m: &ArgMatches<'static>, present: bool, occurrences: u64) -> bool {
- let m = get_outer_matches(m);
- (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
- }
-
- #[test]
- fn global_arg_used_top_level() {
- let m = get_matches(get_app(), "myprog --global-arg=some_value outer inner");
-
- assert!(top_can_access_arg(&m, "some_value"));
- assert!(inner_can_access_arg(&m, "some_value"));
- assert!(outer_can_access_arg(&m, "some_value"));
- }
-
- #[test]
- fn global_arg_used_outer() {
- let m = get_matches(get_app(), "myprog outer --global-arg=some_value inner");
-
- assert!(top_can_access_arg(&m, "some_value"));
- assert!(inner_can_access_arg(&m, "some_value"));
- assert!(outer_can_access_arg(&m, "some_value"));
- }
-
- #[test]
- fn global_arg_used_inner() {
- let m = get_matches(get_app(), "myprog outer inner --global-arg=some_value");
-
- assert!(top_can_access_arg(&m, "some_value"));
- assert!(inner_can_access_arg(&m, "some_value"));
- assert!(outer_can_access_arg(&m, "some_value"));
- }
-
- #[test]
- fn global_arg_default_value() {
- let m = get_matches(get_app(), "myprog outer inner");
-
- assert!(top_can_access_arg(&m, "default_value"));
- assert!(inner_can_access_arg(&m, "default_value"));
- assert!(outer_can_access_arg(&m, "default_value"));
- }
-
- #[test]
- fn global_flag_used_top_level() {
- let m = get_matches(get_app(), "myprog --global-flag outer inner");
-
- assert!(top_can_access_flag(&m, true, 1));
- assert!(inner_can_access_flag(&m, true, 1));
- assert!(outer_can_access_flag(&m, true, 1));
- }
-
- #[test]
- fn global_flag_used_outer() {
- let m = get_matches(get_app(), "myprog outer --global-flag inner");
-
- assert!(top_can_access_flag(&m, true, 1));
- assert!(inner_can_access_flag(&m, true, 1));
- assert!(outer_can_access_flag(&m, true, 1));
- }
-
- #[test]
- fn global_flag_used_inner() {
- let m = get_matches(get_app(), "myprog outer inner --global-flag");
-
- assert!(top_can_access_flag(&m, true, 1));
- assert!(inner_can_access_flag(&m, true, 1));
- assert!(outer_can_access_flag(&m, true, 1));
- }
-
- #[test]
- fn global_flag_2x_used_top_level() {
- let m = get_matches(get_app(), "myprog --global-flag --global-flag outer inner");
-
- assert!(top_can_access_flag(&m, true, 2));
- assert!(inner_can_access_flag(&m, true, 2));
- assert!(outer_can_access_flag(&m, true, 2));
- }
-
- #[test]
- fn global_flag_2x_used_inner() {
- let m = get_matches(get_app(), "myprog outer inner --global-flag --global-flag");
-
- assert!(top_can_access_flag(&m, true, 2));
- assert!(inner_can_access_flag(&m, true, 2));
- assert!(outer_can_access_flag(&m, true, 2));
- }
-}
diff --git a/clap/tests/require.rs b/clap/tests/require.rs
deleted file mode 100644
index 7121aa5..0000000
--- a/clap/tests/require.rs
+++ /dev/null
@@ -1,688 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg, ErrorKind, ArgGroup};
-
-static REQUIRE_EQUALS: &'static str = "error: The following required arguments were not provided:
- --opt=<FILE>
-
-USAGE:
- clap-test --opt=<FILE>
-
-For more information try --help";
-
-static MISSING_REQ: &'static str = "error: The following required arguments were not provided:
- <positional2>
- --long-option-2 <option2>
-
-USAGE:
- clap-test <positional2> -F --long-option-2 <option2>
-
-For more information try --help";
-
-static COND_REQ_IN_USAGE: &'static str = "error: The following required arguments were not provided:
- --output <output>
-
-USAGE:
- test --input <input> --output <output> --target <target>
-
-For more information try --help";
-
-static ISSUE_1158: &'static str = "error: The following required arguments were not provided:
- -x <X>
- -y <Y>
- -z <Z>
-
-USAGE:
- example [OPTIONS] <ID> -x <X> -y <Y> -z <Z>
-
-For more information try --help";
-
-#[test]
-fn issue_1158_conflicting_requirements() {
- let app = App::new("example")
- .arg(Arg::from_usage("-c, --config [FILE] 'Custom config file.'")
- .required_unless("ID")
- .conflicts_with("ID"))
- .arg(Arg::from_usage("[ID] 'ID'")
- .required_unless("config")
- .conflicts_with("config")
- .requires_all(&["x", "y", "z"]))
- .arg(Arg::from_usage("-x [X] 'X'"))
- .arg(Arg::from_usage("-y [Y] 'Y'"))
- .arg(Arg::from_usage("-z [Z] 'Z'"));
-
- assert!(test::compare_output(app, "example id", ISSUE_1158, true));
-}
-
-#[test]
-fn issue_1158_conflicting_requirements_rev() {
- let res = App::new("example")
- .arg(Arg::from_usage("-c, --config [FILE] 'Custom config file.'")
- .required_unless("ID")
- .conflicts_with("ID"))
- .arg(Arg::from_usage("[ID] 'ID'")
- .required_unless("config")
- .conflicts_with("config")
- .requires_all(&["x", "y", "z"]))
- .arg(Arg::from_usage("-x [X] 'X'"))
- .arg(Arg::from_usage("-y [Y] 'Y'"))
- .arg(Arg::from_usage("-z [Z] 'Z'"))
- .get_matches_from_safe(vec!["example", "--config", "some"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn flag_required() {
- let result = App::new("flag_required")
- .arg(Arg::from_usage("-f, --flag 'some flag'").requires("color"))
- .arg(Arg::from_usage("-c, --color 'third flag'"))
- .get_matches_from_safe(vec!["", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn flag_required_2() {
- let m = App::new("flag_required")
- .arg(Arg::from_usage("-f, --flag 'some flag'").requires("color"))
- .arg(Arg::from_usage("-c, --color 'third flag'"))
- .get_matches_from(vec!["", "-f", "-c"]);
- assert!(m.is_present("color"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn option_required() {
- let result = App::new("option_required")
- .arg(Arg::from_usage("-f [flag] 'some flag'").requires("c"))
- .arg(Arg::from_usage("-c [color] 'third flag'"))
- .get_matches_from_safe(vec!["", "-f", "val"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn option_required_2() {
- let m = App::new("option_required")
- .arg(Arg::from_usage("-f [flag] 'some flag'").requires("c"))
- .arg(Arg::from_usage("-c [color] 'third flag'"))
- .get_matches_from(vec!["", "-f", "val", "-c", "other_val"]);
- assert!(m.is_present("c"));
- assert_eq!(m.value_of("c").unwrap(), "other_val");
- assert!(m.is_present("f"));
- assert_eq!(m.value_of("f").unwrap(), "val");
-}
-
-#[test]
-fn positional_required() {
- let result = App::new("positional_required")
- .arg(Arg::with_name("flag")
- .index(1)
- .required(true))
- .get_matches_from_safe(vec![""]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn positional_required_2() {
- let m = App::new("positional_required")
- .arg(Arg::with_name("flag")
- .index(1)
- .required(true))
- .get_matches_from(vec!["", "someval"]);
- assert!(m.is_present("flag"));
- assert_eq!(m.value_of("flag").unwrap(), "someval");
-}
-
-#[test]
-fn group_required() {
- let result = App::new("group_required")
- .arg(Arg::from_usage("-f, --flag 'some flag'"))
- .group(ArgGroup::with_name("gr")
- .required(true)
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from_safe(vec!["", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn group_required_2() {
- let m = App::new("group_required")
- .arg(Arg::from_usage("-f, --flag 'some flag'"))
- .group(ArgGroup::with_name("gr")
- .required(true)
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from(vec!["", "-f", "--some"]);
- assert!(m.is_present("some"));
- assert!(!m.is_present("other"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn group_required_3() {
- let m = App::new("group_required")
- .arg(Arg::from_usage("-f, --flag 'some flag'"))
- .group(ArgGroup::with_name("gr")
- .required(true)
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from(vec!["", "-f", "--other"]);
- assert!(!m.is_present("some"));
- assert!(m.is_present("other"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn arg_require_group() {
- let result = App::new("arg_require_group")
- .arg(Arg::from_usage("-f, --flag 'some flag'").requires("gr"))
- .group(ArgGroup::with_name("gr")
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from_safe(vec!["", "-f"]);
- assert!(result.is_err());
- let err = result.err().unwrap();
- assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn arg_require_group_2() {
- let m = App::new("arg_require_group")
- .arg(Arg::from_usage("-f, --flag 'some flag'").requires("gr"))
- .group(ArgGroup::with_name("gr")
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from(vec!["", "-f", "--some"]);
- assert!(m.is_present("some"));
- assert!(!m.is_present("other"));
- assert!(m.is_present("flag"));
-}
-
-#[test]
-fn arg_require_group_3() {
- let m = App::new("arg_require_group")
- .arg(Arg::from_usage("-f, --flag 'some flag'").requires("gr"))
- .group(ArgGroup::with_name("gr")
- .arg("some")
- .arg("other"))
- .arg(Arg::from_usage("--some 'some arg'"))
- .arg(Arg::from_usage("--other 'other arg'"))
- .get_matches_from(vec!["", "-f", "--other"]);
- assert!(!m.is_present("some"));
- assert!(m.is_present("other"));
- assert!(m.is_present("flag"));
-}
-
-// REQUIRED_UNLESS
-
-#[test]
-fn issue_753() {
- let m = App::new("test")
- .arg(Arg::from_usage("-l, --list 'List available interfaces (and stop there)'"))
- .arg(Arg::from_usage("-i, --iface=[INTERFACE] 'Ethernet interface for fetching NTP packets'")
- .required_unless("list"))
- .arg(Arg::from_usage("-f, --file=[TESTFILE] 'Fetch NTP packets from pcap file'")
- .conflicts_with("iface")
- .required_unless("list"))
- .arg(Arg::from_usage("-s, --server=[SERVER_IP] 'NTP server IP address'")
- .required_unless("list"))
- .arg(Arg::from_usage("-p, --port=[SERVER_PORT] 'NTP server port'")
- .default_value("123"))
- .get_matches_from_safe(vec!["test", "--list"]);
- assert!(m.is_ok());
-}
-
-#[test]
-fn required_unless() {
- let res = App::new("unlesstest")
- .arg(Arg::with_name("cfg")
- .required_unless("dbg")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .get_matches_from_safe(vec!["unlesstest", "--debug"]);
-
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("dbg"));
- assert!(!m.is_present("cfg"));
-}
-
-#[test]
-fn required_unless_err() {
- let res = App::new("unlesstest")
- .arg(Arg::with_name("cfg")
- .required_unless("dbg")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .get_matches_from_safe(vec!["unlesstest"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-// REQUIRED_UNLESS_ALL
-
-#[test]
-fn required_unless_all() {
- let res = App::new("unlessall")
- .arg(Arg::with_name("cfg")
- .required_unless_all(&["dbg", "infile"])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .arg(Arg::with_name("infile")
- .short("i")
- .takes_value(true))
- .get_matches_from_safe(vec!["unlessall", "--debug", "-i", "file"]);
-
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("dbg"));
- assert!(m.is_present("infile"));
- assert!(!m.is_present("cfg"));
-}
-
-#[test]
-fn required_unless_all_err() {
- let res = App::new("unlessall")
- .arg(Arg::with_name("cfg")
- .required_unless_all(&["dbg", "infile"])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .arg(Arg::with_name("infile")
- .short("i")
- .takes_value(true))
- .get_matches_from_safe(vec!["unlessall", "--debug"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-// REQUIRED_UNLESS_ONE
-
-#[test]
-fn required_unless_one() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .required_unless_one(&["dbg", "infile"])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .arg(Arg::with_name("infile")
- .short("i")
- .takes_value(true))
- .get_matches_from_safe(vec!["unlessone", "--debug"]);
-
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("dbg"));
- assert!(!m.is_present("cfg"));
-}
-
-#[test]
-fn required_unless_one_2() {
- // This tests that the required_unless_one works when the second arg in the array is used
- // instead of the first.
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .required_unless_one(&["dbg", "infile"])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .arg(Arg::with_name("infile")
- .short("i")
- .takes_value(true))
- .get_matches_from_safe(vec!["unlessone", "-i", "file"]);
-
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(m.is_present("infile"));
- assert!(!m.is_present("cfg"));
-}
-
-#[test]
-fn required_unless_one_works_with_short() {
- // GitHub issue: https://github.com/clap-rs/clap/issues/1135
- let res = App::new("unlessone")
- .arg(Arg::with_name("a").conflicts_with("b").short("a"))
- .arg(Arg::with_name("b").short("b"))
- .arg(
- Arg::with_name("x")
- .short("x")
- .required_unless_one(&["a", "b"])
- ).get_matches_from_safe(vec!["unlessone", "-a"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn required_unless_one_works_with_short_err() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("a").conflicts_with("b").short("a"))
- .arg(Arg::with_name("b").short("b"))
- .arg(
- Arg::with_name("x")
- .short("x")
- .required_unless_one(&["a", "b"])
- ).get_matches_from_safe(vec!["unlessone"]);
-
- assert!(!res.is_ok());
-}
-
-#[test]
-fn required_unless_one_works_without() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("a").conflicts_with("b").short("a"))
- .arg(Arg::with_name("b").short("b"))
- .arg(
- Arg::with_name("x")
- .required_unless_one(&["a", "b"])
- ).get_matches_from_safe(vec!["unlessone", "-a"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn required_unless_one_works_with_long() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("a").conflicts_with("b").short("a"))
- .arg(Arg::with_name("b").short("b"))
- .arg(
- Arg::with_name("x")
- .long("x_is_the_option")
- .required_unless_one(&["a", "b"])
- ).get_matches_from_safe(vec!["unlessone", "-a"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn required_unless_one_1() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .required_unless_one(&["dbg", "infile"])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .arg(Arg::with_name("infile")
- .short("i")
- .takes_value(true))
- .get_matches_from_safe(vec!["unlessone", "--debug"]);
-
- assert!(res.is_ok());
- let m = res.unwrap();
- assert!(!m.is_present("infile"));
- assert!(!m.is_present("cfg"));
- assert!(m.is_present("dbg"));
-}
-
-#[test]
-fn required_unless_one_err() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .required_unless_one(&["dbg", "infile"])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("dbg").long("debug"))
- .arg(Arg::with_name("infile")
- .short("i")
- .takes_value(true))
- .get_matches_from_safe(vec!["unlessone"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn missing_required_output() {
- assert!(test::compare_output(test::complex_app(), "clap-test -F", MISSING_REQ, true));
-}
-
-// Conditional external requirements
-
-#[test]
-fn requires_if_present_val() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .requires_if("my.cfg", "extra")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra").long("extra"))
- .get_matches_from_safe(vec!["unlessone", "--config=my.cfg"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn requires_if_present_mult() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .requires_ifs(&[("my.cfg", "extra"), ("other.cfg", "other")])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra").long("extra"))
- .arg(Arg::with_name("other").long("other"))
- .get_matches_from_safe(vec!["unlessone", "--config=other.cfg"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn requires_if_present_mult_pass() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .requires_ifs(&[("my.cfg", "extra"), ("other.cfg", "other")])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra").long("extra"))
- .arg(Arg::with_name("other").long("other"))
- .get_matches_from_safe(vec!["unlessone", "--config=some.cfg"]);
-
- assert!(res.is_ok());
- // assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn requires_if_present_val_no_present_pass() {
- let res = App::new("unlessone")
- .arg(Arg::with_name("cfg")
- .requires_if("my.cfg", "extra")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra").long("extra"))
- .get_matches_from_safe(vec!["unlessone"]);
-
- assert!(res.is_ok());
-}
-
-// Conditionally required
-
-#[test]
-fn required_if_val_present_pass() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_if("extra", "val")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .get_matches_from_safe(vec!["ri", "--extra", "val", "--config", "my.cfg"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn required_if_val_present_fail() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_if("extra", "val")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .get_matches_from_safe(vec!["ri", "--extra", "val"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn required_if_val_present_fail_error_output() {
- let app = App::new("Test app")
- .version("1.0")
- .author("F0x06")
- .about("Arg test")
- .arg(Arg::with_name("target")
- .takes_value(true)
- .required(true)
- .possible_values(&["file", "stdout"])
- .long("target"))
- .arg(Arg::with_name("input")
- .takes_value(true)
- .required(true)
- .long("input"))
- .arg(Arg::with_name("output")
- .takes_value(true)
- .required_if("target", "file")
- .long("output"));
-
- assert!(test::compare_output(app,
- "test --input somepath --target file",
- COND_REQ_IN_USAGE,
- true));
-}
-
-#[test]
-fn required_if_wrong_val() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_if("extra", "val")
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .get_matches_from_safe(vec!["ri", "--extra", "other"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn required_ifs_val_present_pass() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_ifs(&[("extra", "val"), ("option", "spec")])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("option")
- .takes_value(true)
- .long("option"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .get_matches_from_safe(vec!["ri", "--option", "spec", "--config", "my.cfg"]);
-
- assert!(res.is_ok());
- // assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn required_ifs_val_present_fail() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_ifs(&[("extra", "val"), ("option", "spec")])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .arg(Arg::with_name("option")
- .takes_value(true)
- .long("option"))
- .get_matches_from_safe(vec!["ri", "--option", "spec"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn required_ifs_wrong_val() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_ifs(&[("extra", "val"), ("option", "spec")])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .arg(Arg::with_name("option")
- .takes_value(true)
- .long("option"))
- .get_matches_from_safe(vec!["ri", "--option", "other"]);
-
- assert!(res.is_ok());
-}
-
-#[test]
-fn required_ifs_wrong_val_mult_fail() {
- let res = App::new("ri")
- .arg(Arg::with_name("cfg")
- .required_ifs(&[("extra", "val"), ("option", "spec")])
- .takes_value(true)
- .long("config"))
- .arg(Arg::with_name("extra")
- .takes_value(true)
- .long("extra"))
- .arg(Arg::with_name("option")
- .takes_value(true)
- .long("option"))
- .get_matches_from_safe(vec!["ri", "--extra", "other", "--option", "spec"]);
-
- assert!(res.is_err());
- assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
-}
-
-#[test]
-fn require_eq() {
- let app = App::new("clap-test")
- .version("v1.4.8")
- .arg(
- Arg::with_name("opt")
- .long("opt")
- .short("o")
- .required(true)
- .require_equals(true)
- .value_name("FILE")
- .help("some")
- );
- assert!(test::compare_output(app, "clap-test", REQUIRE_EQUALS, true));
-}
diff --git a/clap/tests/subcommands.rs b/clap/tests/subcommands.rs
deleted file mode 100644
index 6257aaf..0000000
--- a/clap/tests/subcommands.rs
+++ /dev/null
@@ -1,216 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg, SubCommand, ErrorKind};
-
-static VISIBLE_ALIAS_HELP: &'static str = "clap-test 2.6
-
-USAGE:
- clap-test [SUBCOMMAND]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test Some help [aliases: dongle, done]";
-
-static INVISIBLE_ALIAS_HELP: &'static str = "clap-test 2.6
-
-USAGE:
- clap-test [SUBCOMMAND]
-
-FLAGS:
- -h, --help Prints help information
- -V, --version Prints version information
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test Some help";
-
-#[cfg(feature = "suggestions")]
-static DYM_SUBCMD: &'static str = "error: The subcommand 'subcm' wasn't recognized
- Did you mean 'subcmd'?
-
-If you believe you received this message in error, try re-running with 'dym -- subcm'
-
-USAGE:
- dym [SUBCOMMAND]
-
-For more information try --help";
-
-#[test]
-fn subcommand() {
- let m = App::new("test")
- .subcommand(SubCommand::with_name("some")
- .arg(Arg::with_name("test")
- .short("t")
- .long("test")
- .takes_value(true)
- .help("testing testing")))
- .arg(Arg::with_name("other").long("other"))
- .get_matches_from(vec!["myprog", "some", "--test", "testing"]);
-
- assert_eq!(m.subcommand_name().unwrap(), "some");
- let sub_m = m.subcommand_matches("some").unwrap();
- assert!(sub_m.is_present("test"));
- assert_eq!(sub_m.value_of("test").unwrap(), "testing");
-}
-
-#[test]
-fn subcommand_none_given() {
- let m = App::new("test")
- .subcommand(SubCommand::with_name("some")
- .arg(Arg::with_name("test")
- .short("t")
- .long("test")
- .takes_value(true)
- .help("testing testing")))
- .arg(Arg::with_name("other").long("other"))
- .get_matches_from(vec![""]);
-
- assert!(m.subcommand_name().is_none());
-}
-
-#[test]
-fn subcommand_multiple() {
- let m = App::new("test")
- .subcommands(vec![
- SubCommand::with_name("some")
- .arg(Arg::with_name("test")
- .short("t")
- .long("test")
- .takes_value(true)
- .help("testing testing")),
- SubCommand::with_name("add")
- .arg(Arg::with_name("roster").short("r"))
- ])
- .arg(Arg::with_name("other").long("other"))
- .get_matches_from(vec!["myprog", "some", "--test", "testing"]);
-
- assert!(m.subcommand_matches("some").is_some());
- assert!(m.subcommand_matches("add").is_none());
- assert_eq!(m.subcommand_name().unwrap(), "some");
- let sub_m = m.subcommand_matches("some").unwrap();
- assert!(sub_m.is_present("test"));
- assert_eq!(sub_m.value_of("test").unwrap(), "testing");
-}
-
-#[test]
-fn single_alias() {
- let m = App::new("myprog")
- .subcommand(SubCommand::with_name("test")
- .alias("do-stuff"))
- .get_matches_from(vec!["myprog", "do-stuff"]);
- assert_eq!(m.subcommand_name(), Some("test"));
-}
-
-#[test]
-fn multiple_aliases() {
- let m = App::new("myprog")
- .subcommand(SubCommand::with_name("test")
- .aliases(&["do-stuff", "test-stuff"]))
- .get_matches_from(vec!["myprog", "test-stuff"]);
- assert_eq!(m.subcommand_name(), Some("test"));
-}
-
-#[test]
-#[cfg(feature="suggestions")]
-fn subcmd_did_you_mean_output() {
- let app = App::new("dym")
- .subcommand(SubCommand::with_name("subcmd"));
- assert!(test::compare_output(app, "dym subcm", DYM_SUBCMD, true));
-}
-
-#[test]
-#[cfg(feature="suggestions")]
-fn subcmd_did_you_mean_output_arg() {
- static EXPECTED: &'static str = "error: Found argument '--subcmarg' which wasn't expected, or isn't valid in this context
-\tDid you mean to put '--subcmdarg' after the subcommand 'subcmd'?
-
-USAGE:
- dym [SUBCOMMAND]
-
-For more information try --help";
-
- let app = App::new("dym")
- .subcommand(SubCommand::with_name("subcmd")
- .arg_from_usage("-s --subcmdarg [subcmdarg] 'tests'") );
- assert!(test::compare_output(app, "dym --subcmarg subcmd", EXPECTED, true));
-}
-
-#[test]
-#[cfg(feature="suggestions")]
-fn subcmd_did_you_mean_output_arg_false_positives() {
- static EXPECTED: &'static str = "error: Found argument '--subcmarg' which wasn't expected, or isn't valid in this context
-
-USAGE:
- dym [SUBCOMMAND]
-
-For more information try --help";
-
- let app = App::new("dym")
- .subcommand(SubCommand::with_name("subcmd")
- .arg_from_usage("-s --subcmdarg [subcmdarg] 'tests'") );
- assert!(test::compare_output(app, "dym --subcmarg foo", EXPECTED, true));
-}
-
-#[test]
-fn alias_help() {
- let m = App::new("myprog")
- .subcommand(SubCommand::with_name("test")
- .alias("do-stuff"))
- .get_matches_from_safe(vec!["myprog", "help", "do-stuff"]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
-}
-
-#[test]
-fn visible_aliases_help_output() {
- let app = App::new("clap-test")
- .version("2.6")
- .subcommand(SubCommand::with_name("test")
- .about("Some help")
- .alias("invisible")
- .visible_alias("dongle")
- .visible_alias("done"));
- assert!(test::compare_output(app, "clap-test --help", VISIBLE_ALIAS_HELP, false));
-}
-
-#[test]
-fn invisible_aliases_help_output() {
- let app = App::new("clap-test")
- .version("2.6")
- .subcommand(SubCommand::with_name("test")
- .about("Some help")
- .alias("invisible"));
- assert!(test::compare_output(app, "clap-test --help", INVISIBLE_ALIAS_HELP, false));
-}
-
-#[test]
-fn issue_1031_args_with_same_name() {
- let res = App::new("prog")
- .arg(Arg::from_usage("--ui-path=<PATH>"))
- .subcommand(SubCommand::with_name("signer"))
- .get_matches_from_safe(vec!["prog", "--ui-path", "signer"]);
-
- assert!(res.is_ok(), "{:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert_eq!(m.value_of("ui-path"), Some("signer"));
-}
-
-#[test]
-fn issue_1031_args_with_same_name_no_more_vals() {
- let res = App::new("prog")
- .arg(Arg::from_usage("--ui-path=<PATH>"))
- .subcommand(SubCommand::with_name("signer"))
- .get_matches_from_safe(vec!["prog", "--ui-path", "value", "signer"]);
-
- assert!(res.is_ok(), "{:?}", res.unwrap_err().kind);
- let m = res.unwrap();
- assert_eq!(m.value_of("ui-path"), Some("value"));
- assert_eq!(m.subcommand_name(), Some("signer"));
-}
diff --git a/clap/tests/template_help.rs b/clap/tests/template_help.rs
deleted file mode 100644
index b1a546a..0000000
--- a/clap/tests/template_help.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-use clap::{App, SubCommand};
-
-include!("../clap-test.rs");
-
-static EXAMPLE1_TMPL_S : &'static str = include_str!("example1_tmpl_simple.txt");
-static EXAMPLE1_TMPS_F : &'static str = include_str!("example1_tmpl_full.txt");
-
-static CUSTOM_TEMPL_HELP: &'static str = "MyApp 1.0
-Kevin K. <kbknapp@gmail.com>
-Does awesome things
-
-USAGE:
- MyApp [FLAGS] [OPTIONS] <output> [SUBCOMMAND]
-
-FLAGS:
- -d Turn debugging information on
- -h, --help Prints help information
- -V, --version Prints version information
-OPTIONS:
- -c, --config <FILE> Sets a custom config file
-ARGS:
- <output> Sets an optional output file
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test does testing things";
-
-static SIMPLE_TEMPLATE: &'static str = "MyApp 1.0
-Kevin K. <kbknapp@gmail.com>
-Does awesome things
-
-USAGE:
- MyApp [FLAGS] [OPTIONS] <output> [SUBCOMMAND]
-
-FLAGS:
- -d Turn debugging information on
- -h, --help Prints help information
- -V, --version Prints version information
-
-OPTIONS:
- -c, --config <FILE> Sets a custom config file
-
-ARGS:
- <output> Sets an optional output file
-
-SUBCOMMANDS:
- help Prints this message or the help of the given subcommand(s)
- test does testing things";
-
-#[test]
-fn with_template() {
- let app = app_example1().template(EXAMPLE1_TMPL_S);
- assert!(test::compare_output(app, "MyApp --help", SIMPLE_TEMPLATE, false));
-}
-
-#[test]
-fn custom_template() {
- let app = app_example1().template(EXAMPLE1_TMPS_F);
- assert!(test::compare_output(app, "MyApp --help", CUSTOM_TEMPL_HELP, false));
-}
-
-#[test]
-fn template_empty() {
- let app = App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .template("");
- assert!(test::compare_output(app, "MyApp --help", "", false));
-}
-
-#[test]
-fn template_notag() {
- let app = App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .template("test no tag test");
- assert!(test::compare_output(app, "MyApp --help", "test no tag test", false));
-}
-
-#[test]
-fn template_unknowntag() {
- let app = App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .template("test {unknown_tag} test");
- assert!(test::compare_output(app, "MyApp --help", "test {unknown_tag} test", false));
-}
-
-#[test]
-fn template_author_version() {
- let app = App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .template("{author}\n{version}\n{about}\n{bin}");
- assert!(test::compare_output(app, "MyApp --help", "Kevin K. <kbknapp@gmail.com>\n1.0\nDoes awesome things\nMyApp", false));
-}
-
-// ----------
-
-fn app_example1<'b, 'c>() -> App<'b, 'c> {
- App::new("MyApp")
- .version("1.0")
- .author("Kevin K. <kbknapp@gmail.com>")
- .about("Does awesome things")
- .args_from_usage("-c, --config=[FILE] 'Sets a custom config file'
- <output> 'Sets an optional output file'
- -d... 'Turn debugging information on'")
- .subcommand(SubCommand::with_name("test")
- .about("does testing things")
- .arg_from_usage("-l, --list 'lists test values'"))
-}
diff --git a/clap/tests/tests.rs b/clap/tests/tests.rs
deleted file mode 100644
index 0ad825a..0000000
--- a/clap/tests/tests.rs
+++ /dev/null
@@ -1,435 +0,0 @@
-#[macro_use]
-extern crate clap;
-extern crate regex;
-
-use std::io::Write;
-use std::str;
-
-include!("../clap-test.rs");
-
-use clap::{App, Arg};
-
-static SCF2OP: &'static str = "flag present 2 times
-option NOT present
-positional NOT present
-flag2 NOT present
-option2 maybe present with value of: Nothing
-positional2 maybe present with value of: Nothing
-option3 NOT present
-positional3 NOT present
-option NOT present
-positional NOT present
-subcmd present
-flag present 2 times
-scoption present with value: some
-An scoption: some
-scpositional present with value: value
-";
-
-static SCFOP: &'static str = "flag present 1 times
-option NOT present
-positional NOT present
-flag2 NOT present
-option2 maybe present with value of: Nothing
-positional2 maybe present with value of: Nothing
-option3 NOT present
-positional3 NOT present
-option NOT present
-positional NOT present
-subcmd present
-flag present 1 times
-scoption present with value: some
-An scoption: some
-scpositional present with value: value
-";
-
-static O2P: &'static str = "flag NOT present
-option present 2 times with value: some
-An option: some
-An option: other
-positional present with value: value
-flag2 NOT present
-option2 maybe present with value of: Nothing
-positional2 maybe present with value of: Nothing
-option3 NOT present
-positional3 NOT present
-option present 2 times with value: some
-An option: some
-An option: other
-positional present with value: value
-subcmd NOT present
-";
-
-static F2OP: &'static str = "flag present 2 times
-option present 1 times with value: some
-An option: some
-positional present with value: value
-flag2 NOT present
-option2 maybe present with value of: Nothing
-positional2 maybe present with value of: Nothing
-option3 NOT present
-positional3 NOT present
-option present 1 times with value: some
-An option: some
-positional present with value: value
-subcmd NOT present
-";
-
-static FOP: &'static str = "flag present 1 times
-option present 1 times with value: some
-An option: some
-positional present with value: value
-flag2 NOT present
-option2 maybe present with value of: Nothing
-positional2 maybe present with value of: Nothing
-option3 NOT present
-positional3 NOT present
-option present 1 times with value: some
-An option: some
-positional present with value: value
-subcmd NOT present
-";
-
-pub fn check_complex_output(args: &str, out: &str) {
- let mut w = vec![];
- let matches = test::complex_app().get_matches_from(args.split(' ').collect::<Vec<_>>());
- if matches.is_present("flag") {
- writeln!(w, "flag present {} times", matches.occurrences_of("flag")).unwrap();
- } else {
- writeln!(w, "flag NOT present").unwrap();
- }
-
- if matches.is_present("option") {
- if let Some(v) = matches.value_of("option") {
- writeln!(w, "option present {} times with value: {}",matches.occurrences_of("option"), v).unwrap();
- }
- if let Some(ov) = matches.values_of("option") {
- for o in ov {
- writeln!(w, "An option: {}", o).unwrap();
- }
- }
- } else {
- writeln!(w, "option NOT present").unwrap();
- }
-
- if let Some(p) = matches.value_of("positional") {
- writeln!(w, "positional present with value: {}", p).unwrap();
- } else {
- writeln!(w, "positional NOT present").unwrap();
- }
-
- if matches.is_present("flag2") {
- writeln!(w, "flag2 present").unwrap();
- writeln!(w, "option2 present with value of: {}", matches.value_of("long-option-2").unwrap()).unwrap();
- writeln!(w, "positional2 present with value of: {}", matches.value_of("positional2").unwrap()).unwrap();
- } else {
- writeln!(w, "flag2 NOT present").unwrap();
- writeln!(w, "option2 maybe present with value of: {}", matches.value_of("long-option-2").unwrap_or("Nothing")).unwrap();
- writeln!(w, "positional2 maybe present with value of: {}", matches.value_of("positional2").unwrap_or("Nothing")).unwrap();
- }
-
- let _ = match matches.value_of("Option3").unwrap_or("") {
- "fast" => writeln!(w, "option3 present quickly"),
- "slow" => writeln!(w, "option3 present slowly"),
- _ => writeln!(w, "option3 NOT present")
- };
-
- let _ = match matches.value_of("positional3").unwrap_or("") {
- "vi" => writeln!(w, "positional3 present in vi mode"),
- "emacs" => writeln!(w, "positional3 present in emacs mode"),
- _ => writeln!(w, "positional3 NOT present")
- };
-
- if matches.is_present("option") {
- if let Some(v) = matches.value_of("option") {
- writeln!(w, "option present {} times with value: {}",matches.occurrences_of("option"), v).unwrap();
- }
- if let Some(ov) = matches.values_of("option") {
- for o in ov {
- writeln!(w, "An option: {}", o).unwrap();
- }
- }
- } else {
- writeln!(w, "option NOT present").unwrap();
- }
-
- if let Some(p) = matches.value_of("positional") {
- writeln!(w, "positional present with value: {}", p).unwrap();
- } else {
- writeln!(w, "positional NOT present").unwrap();
- }
- if matches.is_present("subcmd") {
- writeln!(w, "subcmd present").unwrap();
- if let Some(matches) = matches.subcommand_matches("subcmd") {
- if matches.is_present("flag") {
- writeln!(w, "flag present {} times", matches.occurrences_of("flag")).unwrap();
- } else {
- writeln!(w, "flag NOT present").unwrap();
- }
-
- if matches.is_present("option") {
- if let Some(v) = matches.value_of("option") {
- writeln!(w, "scoption present with value: {}", v).unwrap();
- }
- if let Some(ov) = matches.values_of("option") {
- for o in ov {
- writeln!(w, "An scoption: {}", o).unwrap();
- }
- }
- } else {
- writeln!(w, "scoption NOT present").unwrap();
- }
-
- if let Some(p) = matches.value_of("scpositional") {
- writeln!(w, "scpositional present with value: {}", p).unwrap();
- }
- }
- } else {
- writeln!(w, "subcmd NOT present").unwrap();
- }
-
- let res = str::from_utf8(&w).unwrap();
- assert_eq!(res, out);
-}
-
-arg_enum!{
- #[derive(Debug)]
- enum Val1 {
- ValOne,
- ValTwo
- }
-}
-arg_enum!{
- #[derive(Debug)]
- pub enum Val2 {
- ValOne,
- ValTwo
- }
-}
-arg_enum!{
- enum Val3 {
- ValOne,
- ValTwo
- }
-}
-arg_enum!{
- pub enum Val4 {
- ValOne,
- ValTwo
- }
-}
-
-#[test]
-fn test_enums() {
- let v1_lower = "valone";
- let v1_camel = "ValOne";
-
- let v1_lp = v1_lower.parse::<Val1>().unwrap();
- let v1_cp = v1_camel.parse::<Val1>().unwrap();
- match v1_lp {
- Val1::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- match v1_cp {
- Val1::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- let v1_lp = v1_lower.parse::<Val2>().unwrap();
- let v1_cp = v1_camel.parse::<Val2>().unwrap();
- match v1_lp {
- Val2::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- match v1_cp {
- Val2::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- let v1_lp = v1_lower.parse::<Val3>().unwrap();
- let v1_cp = v1_camel.parse::<Val3>().unwrap();
- match v1_lp {
- Val3::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- match v1_cp {
- Val3::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- let v1_lp = v1_lower.parse::<Val4>().unwrap();
- let v1_cp = v1_camel.parse::<Val4>().unwrap();
- match v1_lp {
- Val4::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
- match v1_cp {
- Val4::ValOne => (),
- _ => panic!("Val1 didn't parse correctly"),
- }
-}
-
-#[test]
-fn create_app() {
- let _ =
- App::new("test").version("1.0").author("kevin").about("does awesome things").get_matches_from(vec![""]);
-}
-
-#[test]
-fn add_multiple_arg() {
- let _ = App::new("test")
- .args(&[
- Arg::with_name("test").short("s"),
- Arg::with_name("test2").short("l")])
- .get_matches_from(vec![""]);
-}
-#[test]
-fn flag_x2_opt() {
- check_complex_output("clap-test value -f -f -o some",
-"flag present 2 times
-option present 1 times with value: some
-An option: some
-positional present with value: value
-flag2 NOT present
-option2 maybe present with value of: Nothing
-positional2 maybe present with value of: Nothing
-option3 NOT present
-positional3 NOT present
-option present 1 times with value: some
-An option: some
-positional present with value: value
-subcmd NOT present
-");
-}
-
-#[test]
-fn long_opt_x2_pos() {
- check_complex_output("clap-test value --option some --option other", O2P);
-}
-
-#[test]
-fn long_opt_eq_x2_pos() {
- check_complex_output("clap-test value --option=some --option=other", O2P);
-}
-
-#[test]
-fn short_opt_x2_pos() {
- check_complex_output("clap-test value -o some -o other", O2P);
-}
-
-#[test]
-fn short_opt_eq_x2_pos() {
- check_complex_output("clap-test value -o=some -o=other", O2P);
-}
-
-#[test]
-fn short_flag_x2_comb_short_opt_pos() {
- check_complex_output("clap-test value -ff -o some", F2OP);
-}
-
-#[test]
-fn short_flag_short_opt_pos() {
- check_complex_output("clap-test value -f -o some", FOP);
-}
-
-#[test]
-fn long_flag_long_opt_pos() {
- check_complex_output("clap-test value --flag --option some", FOP);
-}
-
-#[test]
-fn long_flag_long_opt_eq_pos() {
- check_complex_output("clap-test value --flag --option=some", FOP);
-}
-
-#[test]
-fn sc_long_flag_long_opt() {
- check_complex_output("clap-test subcmd value --flag --option some", SCFOP);
-}
-
-#[test]
-fn sc_long_flag_short_opt_pos() {
- check_complex_output("clap-test subcmd value --flag -o some", SCFOP);
-}
-
-#[test]
-fn sc_long_flag_long_opt_eq_pos() {
- check_complex_output("clap-test subcmd value --flag --option=some", SCFOP);
-}
-
-#[test]
-fn sc_short_flag_long_opt_pos() {
- check_complex_output("clap-test subcmd value -f --option some", SCFOP);
-}
-
-#[test]
-fn sc_short_flag_short_opt_pos() {
- check_complex_output("clap-test subcmd value -f -o some", SCFOP);
-}
-
-#[test]
-fn sc_short_flag_short_opt_eq_pos() {
- check_complex_output("clap-test subcmd value -f -o=some", SCFOP);
-}
-
-#[test]
-fn sc_short_flag_long_opt_eq_pos() {
- check_complex_output("clap-test subcmd value -f --option=some", SCFOP);
-}
-
-#[test]
-fn sc_short_flag_x2_comb_long_opt_pos() {
- check_complex_output("clap-test subcmd value -ff --option some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_comb_short_opt_pos() {
- check_complex_output("clap-test subcmd value -ff -o some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_comb_long_opt_eq_pos() {
- check_complex_output("clap-test subcmd value -ff --option=some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_comb_short_opt_eq_pos() {
- check_complex_output("clap-test subcmd value -ff -o=some", SCF2OP);
-}
-
-#[test]
-fn sc_long_flag_x2_long_opt_pos() {
- check_complex_output("clap-test subcmd value --flag --flag --option some", SCF2OP);
-}
-
-#[test]
-fn sc_long_flag_x2_short_opt_pos() {
- check_complex_output("clap-test subcmd value --flag --flag -o some", SCF2OP);
-}
-
-#[test]
-fn sc_long_flag_x2_short_opt_eq_pos() {
- check_complex_output("clap-test subcmd value --flag --flag -o=some", SCF2OP);
-}
-
-#[test]
-fn sc_long_flag_x2_long_opt_eq_pos() {
- check_complex_output("clap-test subcmd value --flag --flag --option=some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_long_opt_pos() {
- check_complex_output("clap-test subcmd value -f -f --option some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_short_opt_pos() {
- check_complex_output("clap-test subcmd value -f -f -o some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_short_opt_eq_pos() {
- check_complex_output("clap-test subcmd value -f -f -o=some", SCF2OP);
-}
-
-#[test]
-fn sc_short_flag_x2_long_opt_eq_pos() {
- check_complex_output("clap-test subcmd value -f -f --option=some", SCF2OP);
-}
diff --git a/clap/tests/unique_args.rs b/clap/tests/unique_args.rs
deleted file mode 100644
index 8710248..0000000
--- a/clap/tests/unique_args.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-extern crate clap;
-
-use clap::{App, Arg};
-
-#[test]
-#[should_panic]
-fn unique_arg_names() {
- App::new("some").args(&[Arg::with_name("arg").short("a"), Arg::with_name("arg").short("b")]);
-}
-
-#[test]
-#[should_panic]
-fn unique_arg_shorts() {
- App::new("some").args(&[Arg::with_name("arg1").short("a"), Arg::with_name("arg2").short("a")]);
-}
-
-#[test]
-#[should_panic]
-fn unique_arg_longs() {
- App::new("some")
- .args(&[Arg::with_name("arg1").long("long"), Arg::with_name("arg2").long("long")]);
-}
diff --git a/clap/tests/utf8.rs b/clap/tests/utf8.rs
deleted file mode 100644
index dfa382e..0000000
--- a/clap/tests/utf8.rs
+++ /dev/null
@@ -1,223 +0,0 @@
-#![cfg(not(windows))]
-
-extern crate clap;
-
-use std::ffi::OsString;
-use std::os::unix::ffi::OsStringExt;
-use clap::{App, Arg, AppSettings, ErrorKind};
-
-#[test]
-fn invalid_utf8_strict_positional() {
- let m = App::new("bad_utf8")
- .arg(Arg::from_usage("<arg> 'some arg'"))
- .setting(AppSettings::StrictUtf8)
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0xe9])]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
-}
-
-#[test]
-fn invalid_utf8_strict_option_short_space() {
- let m = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .setting(AppSettings::StrictUtf8)
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from("-a"),
- OsString::from_vec(vec![0xe9])]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
-}
-
-#[test]
-fn invalid_utf8_strict_option_short_equals() {
- let m = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .setting(AppSettings::StrictUtf8)
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x61, 0x3d, 0xe9])]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
-}
-
-#[test]
-fn invalid_utf8_strict_option_short_no_space() {
- let m = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .setting(AppSettings::StrictUtf8)
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x61, 0xe9])]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
-}
-
-#[test]
-fn invalid_utf8_strict_option_long_space() {
- let m = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .setting(AppSettings::StrictUtf8)
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from("--arg"),
- OsString::from_vec(vec![0xe9])]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
-}
-
-#[test]
-fn invalid_utf8_strict_option_long_equals() {
- let m = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .setting(AppSettings::StrictUtf8)
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x2d, 0x61, 0x72, 0x67, 0x3d, 0xe9])]);
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
-}
-
-#[test]
-fn invalid_utf8_lossy_positional() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("<arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_lossy("arg").unwrap(), "\u{FFFD}");
-}
-
-#[test]
-fn invalid_utf8_lossy_option_short_space() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from("-a"),
- OsString::from_vec(vec![0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_lossy("arg").unwrap(), "\u{FFFD}");
-}
-
-#[test]
-fn invalid_utf8_lossy_option_short_equals() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x61, 0x3d, 0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_lossy("arg").unwrap(), "\u{FFFD}");
-}
-
-#[test]
-fn invalid_utf8_lossy_option_short_no_space() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x61, 0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_lossy("arg").unwrap(), "\u{FFFD}");
-}
-
-#[test]
-fn invalid_utf8_lossy_option_long_space() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from("--arg"),
- OsString::from_vec(vec![0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_lossy("arg").unwrap(), "\u{FFFD}");
-}
-
-#[test]
-fn invalid_utf8_lossy_option_long_equals() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x2d, 0x61, 0x72, 0x67, 0x3d, 0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_lossy("arg").unwrap(), "\u{FFFD}");
-}
-
-#[test]
-fn invalid_utf8_positional() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("<arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_os("arg").unwrap(), &*OsString::from_vec(vec![0xe9]));
-}
-
-#[test]
-fn invalid_utf8_option_short_space() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from("-a"),
- OsString::from_vec(vec![0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_os("arg").unwrap(), &*OsString::from_vec(vec![0xe9]));
-}
-
-#[test]
-fn invalid_utf8_option_short_equals() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x61, 0x3d, 0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_os("arg").unwrap(), &*OsString::from_vec(vec![0xe9]));
-}
-
-#[test]
-fn invalid_utf8_option_short_no_space() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x61, 0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_os("arg").unwrap(), &*OsString::from_vec(vec![0xe9]));
-}
-
-#[test]
-fn invalid_utf8_option_long_space() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from("--arg"),
- OsString::from_vec(vec![0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_os("arg").unwrap(), &*OsString::from_vec(vec![0xe9]));
-}
-
-#[test]
-fn invalid_utf8_option_long_equals() {
- let r = App::new("bad_utf8")
- .arg(Arg::from_usage("-a, --arg <arg> 'some arg'"))
- .get_matches_from_safe(vec![OsString::from(""),
- OsString::from_vec(vec![0x2d, 0x2d, 0x61, 0x72, 0x67, 0x3d, 0xe9])]);
- assert!(r.is_ok());
- let m = r.unwrap();
- assert!(m.is_present("arg"));
- assert_eq!(&*m.value_of_os("arg").unwrap(), &*OsString::from_vec(vec![0xe9]));
-}
diff --git a/clap/tests/version-numbers.rs b/clap/tests/version-numbers.rs
deleted file mode 100644
index 411eea5..0000000
--- a/clap/tests/version-numbers.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#[macro_use]
-extern crate version_sync;
-
-#[test]
-fn test_readme_deps() {
- assert_markdown_deps_updated!("README.md");
-}
-
-#[test]
-fn test_html_root_url() {
- assert_html_root_url_updated!("src/lib.rs");
-}
diff --git a/clap/tests/version.rs b/clap/tests/version.rs
deleted file mode 100644
index 8bbd474..0000000
--- a/clap/tests/version.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-extern crate clap;
-extern crate regex;
-
-use std::str;
-
-use clap::{App, Arg, ErrorKind};
-
-include!("../clap-test.rs");
-
-static VERSION: &'static str = "clap-test v1.4.8";
-
-#[test]
-fn version_short() {
- let m = App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .get_matches_from_safe(vec!["myprog", "-V"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::VersionDisplayed);
-}
-
-#[test]
-fn version_long() {
- let m = App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .get_matches_from_safe(vec!["myprog", "--version"]);
-
- assert!(m.is_err());
- assert_eq!(m.unwrap_err().kind, ErrorKind::VersionDisplayed);
-}
-
-#[test]
-fn complex_version_output() {
- let mut a = App::new("clap-test").version("v1.4.8");
- let _ = a.get_matches_from_safe_borrow(vec![""]);
-
- // Now we check the output of print_version()
- let mut ver = vec![];
- a.write_version(&mut ver).unwrap();
- assert_eq!(str::from_utf8(&ver).unwrap(), VERSION);
-}
-
-#[test]
-fn override_ver() {
- let m = App::new("test")
- .author("Kevin K.")
- .about("tests stuff")
- .version("1.3")
- .arg(Arg::from_usage("-v, --version 'some version'"))
- .get_matches_from_safe(vec!["test", "--version"]);
-
- assert!(m.is_ok());
- assert!(m.unwrap().is_present("version"));
-}
diff --git a/clap/tests/yaml.rs b/clap/tests/yaml.rs
deleted file mode 100644
index 279b987..0000000
--- a/clap/tests/yaml.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-#![cfg(feature="yaml")]
-
-#[macro_use]
-extern crate clap;
-
-use clap::App;
-
-#[test]
-fn create_app_from_yaml() {
- let yml = load_yaml!("app.yml");
- App::from_yaml(yml);
-}
-
-#[test]
-fn help_message() {
- let yml = load_yaml!("app.yml");
- let mut app = App::from_yaml(yml);
- // Generate the full help message!
- let _ = app.get_matches_from_safe_borrow(Vec::<String>::new());
-
- let mut help_buffer = Vec::new();
- app.write_help(&mut help_buffer).unwrap();
- let help_string = String::from_utf8(help_buffer).unwrap();
- assert!(help_string.contains(
- "-h, --help prints help with a nonstandard description\n"));
-}
-
-#[test]
-fn author() {
- let yml = load_yaml!("app.yml");
- let mut app = App::from_yaml(yml);
- // Generate the full help message!
- let _ = app.get_matches_from_safe_borrow(Vec::<String>::new());
-
- let mut help_buffer = Vec::new();
- app.write_help(&mut help_buffer).unwrap();
- let help_string = String::from_utf8(help_buffer).unwrap();
- assert!(help_string.contains(
- "Kevin K. <kbknapp@gmail.com>"));
-}
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 04bfe61..04bfe61 100644
--- a/nitrocli/doc/nitrocli.1
+++ b/doc/nitrocli.1
diff --git a/nitrocli/doc/nitrocli.1.pdf b/doc/nitrocli.1.pdf
index 596e794..596e794 100644
--- a/nitrocli/doc/nitrocli.1.pdf
+++ b/doc/nitrocli.1.pdf
Binary files differ
diff --git a/nitrocli/doc/packaging.md b/doc/packaging.md
index 5ff4089..5ff4089 100644
--- a/nitrocli/doc/packaging.md
+++ b/doc/packaging.md
diff --git a/getrandom/.cargo/config b/getrandom/.cargo/config
deleted file mode 100644
index 291ce5e..0000000
--- a/getrandom/.cargo/config
+++ /dev/null
@@ -1,5 +0,0 @@
-[target.wasm32-unknown-unknown]
-runner = 'wasm-bindgen-test-runner'
-
-[target.wasm32-wasi]
-runner = 'wasmtime'
diff --git a/getrandom/.gitignore b/getrandom/.gitignore
deleted file mode 100644
index 435eeee..0000000
--- a/getrandom/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-/target
-**/*.rs.bk
-Cargo.lock
-*.ts
-*.js
-*.wasm
diff --git a/getrandom/.travis.yml b/getrandom/.travis.yml
deleted file mode 100644
index bdd9e72..0000000
--- a/getrandom/.travis.yml
+++ /dev/null
@@ -1,221 +0,0 @@
-language: rust
-sudo: false
-
-matrix:
- include:
- - name: "Linux, 1.32.0"
- rust: 1.32.0
- os: linux
-
- - name: "OSX, 1.32.0"
- rust: 1.32.0
- os: osx
-
- - name: "Linux, stable"
- rust: stable
-
- - name: "OSX+iOS, stable"
- rust: stable
- os: osx
- install:
- - rustup target add aarch64-apple-ios
- script:
- - cargo test
- - cargo test --examples
- - cargo build --target aarch64-apple-ios
-
- - name: "Linux, beta"
- rust: beta
-
- - name: "WASM via emscripten, stdweb, wasm-bindgen and WASI"
- rust: nightly
- addons:
- firefox: latest
- chrome: stable
- install:
- - rustup target add wasm32-unknown-unknown
- - rustup target add wasm32-unknown-emscripten
- - rustup target add asmjs-unknown-emscripten
- - rustup target add wasm32-wasi
- # Get latest geckodriver
- - export VERSION=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ".tag_name")
- - wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/$VERSION/geckodriver-$VERSION-linux64.tar.gz
- - tar -xzf geckodriver.tar.gz
- # Get latest chromedirver
- - export VERSION=$(wget -q -O - https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
- - wget -O chromedriver.zip https://chromedriver.storage.googleapis.com/$VERSION/chromedriver_linux64.zip
- - unzip chromedriver.zip
- # Get cargo-web
- - export VERSION=0.6.26 # Pin version for stability
- - wget -O cargo-web.gz https://github.com/koute/cargo-web/releases/download/$VERSION/cargo-web-x86_64-unknown-linux-gnu.gz
- - gunzip cargo-web.gz
- - chmod +x cargo-web
- # Get wasmtime
- - export VERSION=v0.3.0 # Pin version for stability
- - wget -O wasmtime.tar.xz https://github.com/CraneStation/wasmtime/releases/download/$VERSION/wasmtime-$VERSION-x86_64-linux.tar.xz
- - tar -xf wasmtime.tar.xz --strip-components=1
- # Get wasm-bindgen-test-runner which matches our wasm-bindgen version
- - export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version')
- - wget -O wasm-bindgen.tar.gz https://github.com/rustwasm/wasm-bindgen/releases/download/$VERSION/wasm-bindgen-$VERSION-x86_64-unknown-linux-musl.tar.gz
- - tar -xzf wasm-bindgen.tar.gz --strip-components=1
- # Place the runner binaries in our PATH
- - mv cargo-web wasmtime wasm-bindgen-test-runner $HOME/.cargo/bin
- # Download and setup emscripten
- - cargo web prepare-emscripten
- env: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0"
- script:
- # We cannot run emscripten test binaries (see rust-lang/rust#63649).
- # 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
- - cargo web test --target wasm32-unknown-emscripten --no-run
- - cargo web test --target asmjs-unknown-emscripten --no-run
- # wasi tests
- - cargo test --target wasm32-wasi
- # stdweb tests (Node, Chrome)
- - cargo web test --nodejs --target=wasm32-unknown-unknown --features=stdweb
- - cargo web test --target=wasm32-unknown-unknown --features=stdweb
- # wasm-bindgen tests (Node, Firefox, Chrome)
- - cargo test --target wasm32-unknown-unknown --features=wasm-bindgen
- - GECKODRIVER=$PWD/geckodriver cargo test --target wasm32-unknown-unknown --features=test-in-browser
- - CHROMEDRIVER=$PWD/chromedriver cargo test --target wasm32-unknown-unknown --features=test-in-browser
-
- - name: "Linux, nightly, docs"
- rust: nightly
- os: linux
- install:
- - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
- - cargo deadlinks -V
- script:
- - cargo test
- - cargo test --benches
- - cargo test --examples
- # remove cached documentation, otherwise files from previous PRs can get included
- - rm -rf target/doc
- - cargo doc --no-deps --all --features=std,log
- - cargo deadlinks --dir target/doc
- # also test minimum dependency versions are usable
- - cargo generate-lockfile -Z minimal-versions
- - cargo test
-
- - name: "OSX, nightly, docs"
- rust: nightly
- os: osx
- install:
- - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
- - cargo deadlinks -V
- script:
- - cargo test
- - cargo test --benches
- - cargo test --examples
- # remove cached documentation, otherwise files from previous PRs can get included
- - rm -rf target/doc
- - cargo doc --no-deps --all --features=std,log
- - cargo deadlinks --dir target/doc
- # also test minimum dependency versions are usable
- - cargo generate-lockfile -Z minimal-versions
- - cargo test
-
- - name: "cross-platform build only"
- rust: nightly
- 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-fuchsia
- - rustup target add x86_64-unknown-netbsd
- - rustup target add x86_64-unknown-redox
- - rustup target add x86_64-fortanix-unknown-sgx
- # For no_std targets
- - rustup component add rust-src
- - cargo install cargo-xbuild || true
- script:
- - cargo build --target=x86_64-sun-solaris
- - cargo build --target=x86_64-unknown-cloudabi
- - cargo build --target=x86_64-unknown-freebsd
- - cargo build --target=x86_64-fuchsia
- - cargo build --target=x86_64-unknown-netbsd
- - cargo build --target=x86_64-unknown-redox
- - cargo build --target=x86_64-fortanix-unknown-sgx
- - cargo xbuild --target=x86_64-unknown-uefi
- - cargo xbuild --target=x86_64-unknown-hermit
- - cargo xbuild --target=x86_64-unknown-l4re-uclibc
- - cargo xbuild --target=x86_64-wrs-vxworks
- # also test minimum dependency versions are usable
- - cargo generate-lockfile -Z minimal-versions
- - cargo build --target=x86_64-sun-solaris
- - cargo build --target=x86_64-unknown-cloudabi
- - cargo build --target=x86_64-unknown-freebsd
- - cargo build --target=x86_64-fuchsia
- - cargo build --target=x86_64-unknown-netbsd
- - cargo build --target=x86_64-unknown-redox
- - cargo build --target=x86_64-fortanix-unknown-sgx
- - cargo xbuild --target=x86_64-unknown-uefi
- - cargo xbuild --target=x86_64-unknown-hermit
- - cargo xbuild --target=x86_64-unknown-l4re-uclibc
- - cargo xbuild --target=x86_64-uwp-windows-gnu
-
- # Trust cross-built/emulated targets. We must repeat all non-default values.
- - name: "Linux (MIPS, big-endian)"
- env: TARGET=mips-unknown-linux-gnu
- rust: stable
- sudo: required
- dist: trusty
- services: docker
- install:
- - sh utils/ci/install.sh
- - source ~/.cargo/env || true
- script:
- - bash utils/ci/script.sh
-
- - name: "Android (ARMv7)"
- env: TARGET=armv7-linux-androideabi
- rust: stable
- sudo: required
- dist: trusty
- services: docker
- install:
- - sh utils/ci/install.sh
- - source ~/.cargo/env || true
- script:
- - bash utils/ci/script.sh
-
- - name: "rustfmt"
- rust: stable
- install:
- - rustup component add rustfmt
- script:
- - cargo fmt --all -- */*.rs --check
-
- allow_failures:
- # Formatting errors should appear in Travis, but not break the build.
- - name: "rustfmt"
-
-before_install:
- - set -e
- - rustup self update
-
-before_script:
- - export RUSTFLAGS="-D warnings"
-
-script:
- - cargo test
- - cargo test --examples
-
-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
-
-notifications:
- email:
- on_success: never
-
-branches:
- only:
- - master
diff --git a/getrandom/CHANGELOG.md b/getrandom/CHANGELOG.md
deleted file mode 100644
index 2f6e9f4..0000000
--- a/getrandom/CHANGELOG.md
+++ /dev/null
@@ -1,158 +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.13] - 2019-08-25
-### Added
-- VxWorks targets support. [#86]
-
-### Changed
-- If zero-length slice is passed to the `getrandom` function, always return
-`Ok(())` immediately without doing any calls to the underlying operating
-system. [#104]
-- Use the `kern.arandom` sysctl on NetBSD. [#115]
-
-### Fixed
-- Bump `cfg-if` minimum version from 0.1.0 to 0.1.2. [#112]
-- Typos and bad doc links. [#117]
-
-[#86]: https://github.com/rust-random/getrandom/pull/86
-[#104]: https://github.com/rust-random/getrandom/pull/104
-[#112]: https://github.com/rust-random/getrandom/pull/112
-[#115]: https://github.com/rust-random/getrandom/pull/115
-[#117]: https://github.com/rust-random/getrandom/pull/117
-
-## [0.1.12] - 2019-08-18
-### Changed
-- Update wasi dependency from v0.5 to v0.7. [#100]
-
-[#100]: https://github.com/rust-random/getrandom/pull/100
-
-## [0.1.11] - 2019-08-25
-### Fixed
-- Implement `std`-dependent traits for selected targets even if `std`
-feature is disabled. (backward compatibility with v0.1.8) [#96]
-
-[#96]: https://github.com/rust-random/getrandom/pull/96
-
-## [0.1.10] - 2019-08-18 [YANKED]
-### Changed
-- Use the dummy implementation on `wasm32-unknown-unknown` even with the
-disabled `dummy` feature. [#90]
-
-### Fixed
-- Fix CSP error for `wasm-bindgen`. [#92]
-
-[#90]: https://github.com/rust-random/getrandom/pull/90
-[#92]: https://github.com/rust-random/getrandom/pull/92
-
-## [0.1.9] - 2019-08-14 [YANKED]
-### Changed
-- Remove `std` dependency for opening and reading files. [#58]
-- Use `wasi` isntead of `libc` on WASI target. [#64]
-- By default emit a compile-time error when built for an unsupported target.
-This behaviour can be disabled by using the `dummy` feature. [#71]
-
-### Added
-- Add support for UWP targets. [#69]
-- Add unstable `rustc-dep-of-std` feature. [#78]
-
-[#58]: https://github.com/rust-random/getrandom/pull/58
-[#64]: https://github.com/rust-random/getrandom/pull/64
-[#69]: https://github.com/rust-random/getrandom/pull/69
-[#71]: https://github.com/rust-random/getrandom/pull/71
-[#78]: https://github.com/rust-random/getrandom/pull/78
-
-## [0.1.8] - 2019-07-29
-### Changed
-- Explicitly specify types to arguments of 'libc::syscall'. [#74]
-
-[#74]: https://github.com/rust-random/getrandom/pull/74
-
-## [0.1.7] - 2019-07-29
-### Added
-- Support for hermit and l4re. [#61]
-- `Error::raw_os_error` method, `Error::INTERNAL_START` and
-`Error::CUSTOM_START` constants. Use `libc` for retrieving OS error descriptions. [#54]
-
-### Changed
-- Remove `lazy_static` dependency and use custom structures for lock-free
-initialization. [#51] [#52]
-- Try `getrandom()` first on FreeBSD. [#57]
-
-### Removed
-- Bitrig support. [#56]
-
-### Deprecated
-- `Error::UNKNOWN`, `Error::UNAVAILABLE`. [#54]
-
-[#51]: https://github.com/rust-random/getrandom/pull/51
-[#52]: https://github.com/rust-random/getrandom/pull/52
-[#54]: https://github.com/rust-random/getrandom/pull/54
-[#56]: https://github.com/rust-random/getrandom/pull/56
-[#57]: https://github.com/rust-random/getrandom/pull/57
-[#61]: https://github.com/rust-random/getrandom/pull/61
-
-## [0.1.6] - 2019-06-30
-### Changed
-- Minor change of RDRAND AMD bug handling. [#48]
-
-[#48]: https://github.com/rust-random/getrandom/pull/48
-
-## [0.1.5] - 2019-06-29
-### Fixed
-- Use shared `File` instead of shared file descriptor. [#44]
-- Workaround for RDRAND hardware bug present on some AMD CPUs. [#43]
-
-### Changed
-- Try `getentropy` and then fallback to `/dev/random` on macOS. [#38]
-
-[#38]: https://github.com/rust-random/getrandom/issues/38
-[#43]: https://github.com/rust-random/getrandom/pull/43
-[#44]: https://github.com/rust-random/getrandom/issues/44
-
-## [0.1.4] - 2019-06-28
-### Added
-- Add support for `x86_64-unknown-uefi` target by using RDRAND with CPUID
-feature detection. [#30]
-
-### Fixed
-- Fix long buffer issues on Windows and Linux. [#31] [#32]
-- Check `EPERM` in addition to `ENOSYS` on Linux. [#37]
-
-### Changed
-- Improve efficiency by sharing file descriptor across threads. [#13]
-- Remove `cloudabi`, `winapi`, and `fuchsia-cprng` dependencies. [#40]
-- Improve RDRAND implementation. [#24]
-- Don't block during syscall detection on Linux. [#26]
-- Increase consistency with libc implementation on FreeBSD. [#36]
-- Apply `rustfmt`. [#39]
-
-[#30]: https://github.com/rust-random/getrandom/pull/30
-[#13]: https://github.com/rust-random/getrandom/issues/13
-[#40]: https://github.com/rust-random/getrandom/pull/40
-[#26]: https://github.com/rust-random/getrandom/pull/26
-[#24]: https://github.com/rust-random/getrandom/pull/24
-[#39]: https://github.com/rust-random/getrandom/pull/39
-[#36]: https://github.com/rust-random/getrandom/pull/36
-[#31]: https://github.com/rust-random/getrandom/issues/31
-[#32]: https://github.com/rust-random/getrandom/issues/32
-[#37]: https://github.com/rust-random/getrandom/issues/37
-
-## [0.1.3] - 2019-05-15
-- Update for `wasm32-unknown-wasi` being renamed to `wasm32-wasi`, and for
- WASI being categorized as an OS.
-
-## [0.1.2] - 2019-04-06
-- Add support for `wasm32-unknown-wasi` target.
-
-## [0.1.1] - 2019-04-05
-- Enable std functionality for CloudABI by default.
-
-## [0.1.0] - 2019-03-23
-Publish initial implementation.
-
-## [0.0.0] - 2019-01-19
-Publish an empty template library.
diff --git a/getrandom/Cargo.toml b/getrandom/Cargo.toml
deleted file mode 100644
index b159674..0000000
--- a/getrandom/Cargo.toml
+++ /dev/null
@@ -1,45 +0,0 @@
-[package]
-name = "getrandom"
-version = "0.1.13"
-edition = "2018"
-authors = ["The Rand Project Developers"]
-license = "MIT OR Apache-2.0"
-description = "A small cross-platform library for retrieving random data from system source"
-documentation = "https://docs.rs/getrandom"
-repository = "https://github.com/rust-random/getrandom"
-categories = ["os", "no-std"]
-exclude = ["utils/*", ".*", "appveyor.yml"]
-
-[badges]
-travis-ci = { repository = "rust-random/getrandom" }
-appveyor = { repository = "rust-random/getrandom" }
-
-[dependencies]
-log = { version = "0.4", optional = true }
-cfg-if = "0.1.2"
-
-# When built as part of libstd
-compiler_builtins = { version = "0.1", optional = true }
-core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" }
-
-[target.'cfg(unix)'.dependencies]
-libc = { version = "0.2.64", default-features = false }
-
-[target.'cfg(target_os = "wasi")'.dependencies]
-wasi = "0.7"
-
-[target.wasm32-unknown-unknown.dependencies]
-wasm-bindgen = { version = "0.2.29", optional = true }
-stdweb = { version = "0.4.18", optional = true }
-
-[target.wasm32-unknown-unknown.dev-dependencies]
-wasm-bindgen-test = "0.2"
-
-[features]
-std = []
-# Enables dummy implementation for unsupported targets
-dummy = []
-# Unstable feature to support being a libstd dependency
-rustc-dep-of-std = ["compiler_builtins", "core"]
-# Unstable feature for testing
-test-in-browser = ["wasm-bindgen"]
diff --git a/getrandom/LICENSE-APACHE b/getrandom/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/getrandom/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/getrandom/LICENSE-MIT b/getrandom/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/getrandom/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/getrandom/README.md b/getrandom/README.md
deleted file mode 100644
index 01bbfb5..0000000
--- a/getrandom/README.md
+++ /dev/null
@@ -1,78 +0,0 @@
-# getrandom
-
-[![Build Status](https://travis-ci.org/rust-random/getrandom.svg?branch=master)](https://travis-ci.org/rust-random/getrandom)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/getrandom?svg=true)](https://ci.appveyor.com/project/rust-random/getrandom)
-[![Crate](https://img.shields.io/crates/v/getrandom.svg)](https://crates.io/crates/getrandom)
-[![Documentation](https://docs.rs/getrandom/badge.svg)](https://docs.rs/getrandom)
-[![Dependency status](https://deps.rs/repo/github/rust-random/getrandom/status.svg)](https://deps.rs/repo/github/rust-random/getrandom)
-
-
-A Rust library for retrieving random data from (operating) system source. It is
-assumed that system always provides high-quality cryptographically secure random
-data, ideally backed by hardware entropy sources. This crate derives its name
-from Linux's `getrandom` function, but is cross platform, roughly supporting
-the same set of platforms as Rust's `std` lib.
-
-This is a low-level API. Most users should prefer using high-level random-number
-library like [`rand`].
-
-[`rand`]: https://crates.io/crates/rand
-
-## Usage
-
-Add this to your `Cargo.toml`:
-
-```toml
-[dependencies]
-getrandom = "0.1"
-```
-
-Then invoke the `getrandom` function:
-
-```rust
-fn get_random_buf() -> Result<[u8; 32], getrandom::Error> {
- let mut buf = [0u8; 32];
- getrandom::getrandom(&mut buf)?;
- Ok(buf)
-}
-```
-
-## Features
-
-This library is `no_std` for every supported target. However, getting randomness
-usually requires calling some external system API. This means most platforms
-will require linking against system libraries (i.e. `libc` for Unix,
-`Advapi32.dll` for Windows, Security framework on iOS, etc...).
-
-The `log` library is supported as an optional dependency. If enabled, error
-reporting will be improved on some platforms.
-
-For the `wasm32-unknown-unknown` target, one of the following features should be
-enabled:
-
-- [`wasm-bindgen`](https://crates.io/crates/wasm_bindgen)
-- [`stdweb`](https://crates.io/crates/stdweb)
-
-By default, compiling `getrandom` for an unsupported target will result in
-a compilation error. If you want to build an application which uses `getrandom`
-for such target, you can either:
-- Use [`[replace]`][replace] or [`[patch]`][patch] section in your `Cargo.toml`
-to switch to a custom implementation with a support of your target.
-- Enable the `dummy` feature to have getrandom use an implementation that always
-fails at run-time on unsupported targets.
-
-[replace]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-replace-section
-[patch]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-patch-section
-
-## Minimum Supported Rust Version
-
-This crate requires Rust 1.32.0 or later.
-
-# License
-
-The `getrandom` library is distributed under either of
-
- * [Apache License, Version 2.0](LICENSE-APACHE)
- * [MIT license](LICENSE-MIT)
-
-at your option.
diff --git a/getrandom/appveyor.yml b/getrandom/appveyor.yml
deleted file mode 100644
index 7a34e32..0000000
--- a/getrandom/appveyor.yml
+++ /dev/null
@@ -1,52 +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
- CHANNEL: 1.32.0
- - TARGET: x86_64-pc-windows-msvc
- CHANNEL: stable
- - TARGET: x86_64-pc-windows-msvc
- CHANNEL: nightly
- - TARGET: i686-pc-windows-msvc
- CHANNEL: nightly
- - TARGET: x86_64-pc-windows-gnu
- CHANNEL: nightly
- - TARGET: i686-pc-windows-gnu
- CHANNEL: nightly
-
-install:
- - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- - rustup-init.exe -y --default-host %TARGET% --default-toolchain %CHANNEL%
- - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- - rustc -V
- - cargo -V
-
-build: false
-
-test_script:
- - set RUSTFLAGS=-D warnings
- - cargo test
- - cargo test --examples
-
-branches:
- only:
- - master
diff --git a/getrandom/benches/mod.rs b/getrandom/benches/mod.rs
deleted file mode 100644
index 07953f1..0000000
--- a/getrandom/benches/mod.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-#![feature(test)]
-extern crate getrandom;
-extern crate test;
-
-#[bench]
-fn bench_64(b: &mut test::Bencher) {
- let mut buf = [0u8; 64];
- b.iter(|| {
- getrandom::getrandom(&mut buf[..]).unwrap();
- test::black_box(&buf);
- });
- b.bytes = buf.len() as u64;
-}
-
-#[bench]
-fn bench_65536(b: &mut test::Bencher) {
- let mut buf = [0u8; 65536];
- b.iter(|| {
- getrandom::getrandom(&mut buf[..]).unwrap();
- test::black_box(&buf);
- });
- b.bytes = buf.len() as u64;
-}
diff --git a/getrandom/build.rs b/getrandom/build.rs
deleted file mode 100644
index 1beb4ed..0000000
--- a/getrandom/build.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#![deny(warnings)]
-
-use std::env;
-
-fn main() {
- let target = env::var("TARGET").expect("TARGET was not set");
- if target.contains("-uwp-windows-") {
- // for BCryptGenRandom
- println!("cargo:rustc-link-lib=bcrypt");
- // to work around unavailability of `target_vendor` on Rust 1.33
- println!("cargo:rustc-cfg=getrandom_uwp");
- } else if target.contains("windows") {
- // for RtlGenRandom (aka SystemFunction036)
- println!("cargo:rustc-link-lib=advapi32");
- } else if target.contains("apple-ios") {
- // for SecRandomCopyBytes and kSecRandomDefault
- println!("cargo:rustc-link-lib=framework=Security");
- }
-}
diff --git a/getrandom/src/bsd_arandom.rs b/getrandom/src/bsd_arandom.rs
deleted file mode 100644
index eb564ff..0000000
--- a/getrandom/src/bsd_arandom.rs
+++ /dev/null
@@ -1,49 +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 and NetBSD
-use crate::util_libc::sys_fill_exact;
-use crate::Error;
-use core::ptr;
-
-fn kern_arnd(buf: &mut [u8]) -> libc::ssize_t {
- static MIB: [libc::c_int; 2] = [libc::CTL_KERN, libc::KERN_ARND];
- let mut len = buf.len();
- let ret = unsafe {
- libc::sysctl(
- MIB.as_ptr(),
- MIB.len() as libc::c_uint,
- buf.as_mut_ptr() as *mut _,
- &mut len,
- ptr::null(),
- 0,
- )
- };
- if ret == -1 {
- error!("sysctl kern.arandom: syscall failed");
- -1
- } else {
- len as libc::ssize_t
- }
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- #[cfg(target_os = "freebsd")]
- {
- use crate::util_libc::Weak;
- static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") };
- type GetRandomFn =
- unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t;
-
- if let Some(fptr) = GETRANDOM.ptr() {
- let func: GetRandomFn = unsafe { core::mem::transmute(fptr) };
- return sys_fill_exact(dest, |buf| unsafe { func(buf.as_mut_ptr(), buf.len(), 0) });
- }
- }
- sys_fill_exact(dest, kern_arnd)
-}
diff --git a/getrandom/src/cloudabi.rs b/getrandom/src/cloudabi.rs
deleted file mode 100644
index d3d0928..0000000
--- a/getrandom/src/cloudabi.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.
-
-//! Implementation for CloudABI
-use crate::Error;
-use core::num::NonZeroU32;
-
-extern "C" {
- fn cloudabi_sys_random_get(buf: *mut u8, buf_len: usize) -> u16;
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- let errno = unsafe { cloudabi_sys_random_get(dest.as_mut_ptr(), dest.len()) };
- if let Some(code) = NonZeroU32::new(errno as u32) {
- error!("cloudabi_sys_random_get: failed with {}", errno);
- Err(Error::from(code))
- } else {
- Ok(()) // Zero means success for CloudABI
- }
-}
diff --git a/getrandom/src/dummy.rs b/getrandom/src/dummy.rs
deleted file mode 100644
index 0c24ba0..0000000
--- a/getrandom/src/dummy.rs
+++ /dev/null
@@ -1,14 +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 dummy implementation for unsupported targets which always fails
-use crate::{error::UNSUPPORTED, Error};
-
-pub fn getrandom_inner(_: &mut [u8]) -> Result<(), Error> {
- Err(UNSUPPORTED)
-}
diff --git a/getrandom/src/error.rs b/getrandom/src/error.rs
deleted file mode 100644
index b2cb9a8..0000000
--- a/getrandom/src/error.rs
+++ /dev/null
@@ -1,178 +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 core::fmt;
-use core::num::NonZeroU32;
-
-/// A small and `no_std` compatible error type.
-///
-/// The [`Error::raw_os_error()`] will indicate if the error is from the OS, and
-/// if so, which error code the OS gave the application. If such an error is
-/// encountered, please consult with your system documentation.
-///
-/// Internally this type is a NonZeroU32, with certain values reserved for
-/// certain purposes, see [`Error::INTERNAL_START`] and [`Error::CUSTOM_START`].
-#[derive(Copy, Clone, Eq, PartialEq)]
-pub struct Error(NonZeroU32);
-
-impl Error {
- #[deprecated(since = "0.1.7")]
- /// Unknown error.
- pub const UNKNOWN: Error = UNSUPPORTED;
- #[deprecated(since = "0.1.7")]
- /// System entropy source is unavailable.
- pub const UNAVAILABLE: Error = UNSUPPORTED;
-
- /// Codes below this point represent OS Errors (i.e. positive i32 values).
- /// Codes at or above this point, but below [`Error::CUSTOM_START`] are
- /// reserved for use by the `rand` and `getrandom` crates.
- pub const INTERNAL_START: u32 = 1 << 31;
-
- /// Codes at or above this point can be used by users to define their own
- /// custom errors.
- pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30);
-
- /// Extract the raw OS error code (if this error came from the OS)
- ///
- /// This method is identical to `std::io::Error::raw_os_error()`, except
- /// that it works in `no_std` contexts. If this method returns `None`, the
- /// error value can still be formatted via the `Display` implementation.
- #[inline]
- pub fn raw_os_error(self) -> Option<i32> {
- if self.0.get() < Self::INTERNAL_START {
- Some(self.0.get() as i32)
- } else {
- None
- }
- }
-
- /// Extract the bare error code.
- ///
- /// This code can either come from the underlying OS, or be a custom error.
- /// Use [`Error::raw_os_error()`] to disambiguate.
- #[inline]
- pub fn code(self) -> NonZeroU32 {
- self.0
- }
-}
-
-cfg_if! {
- if #[cfg(unix)] {
- fn os_err_desc(errno: i32, buf: &mut [u8]) -> Option<&str> {
- let buf_ptr = buf.as_mut_ptr() as *mut libc::c_char;
- if unsafe { libc::strerror_r(errno, buf_ptr, buf.len()) } != 0 {
- return None;
- }
-
- // Take up to trailing null byte
- let n = buf.len();
- let idx = buf.iter().position(|&b| b == 0).unwrap_or(n);
- core::str::from_utf8(&buf[..idx]).ok()
- }
- } else if #[cfg(target_os = "wasi")] {
- fn os_err_desc(errno: i32, _buf: &mut [u8]) -> Option<&str> {
- core::num::NonZeroU16::new(errno as u16)
- .and_then(wasi::wasi_unstable::error_str)
- }
- } else {
- fn os_err_desc(_errno: i32, _buf: &mut [u8]) -> Option<&str> {
- None
- }
- }
-}
-
-impl fmt::Debug for Error {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- let mut dbg = f.debug_struct("Error");
- if let Some(errno) = self.raw_os_error() {
- dbg.field("os_error", &errno);
- let mut buf = [0u8; 128];
- if let Some(desc) = os_err_desc(errno, &mut buf) {
- dbg.field("description", &desc);
- }
- } else if let Some(desc) = internal_desc(*self) {
- dbg.field("internal_code", &self.0.get());
- dbg.field("description", &desc);
- } else {
- dbg.field("unknown_code", &self.0.get());
- }
- dbg.finish()
- }
-}
-
-impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- if let Some(errno) = self.raw_os_error() {
- let mut buf = [0u8; 128];
- match os_err_desc(errno, &mut buf) {
- Some(desc) => f.write_str(desc),
- None => write!(f, "OS Error: {}", errno),
- }
- } else if let Some(desc) = internal_desc(*self) {
- f.write_str(desc)
- } else {
- write!(f, "Unknown Error: {}", self.0.get())
- }
- }
-}
-
-impl From<NonZeroU32> for Error {
- fn from(code: NonZeroU32) -> Self {
- Self(code)
- }
-}
-
-// TODO: Convert to a function when min_version >= 1.33
-macro_rules! internal_error {
- ($n:expr) => {
- Error(unsafe { NonZeroU32::new_unchecked(Error::INTERNAL_START + $n as u16 as u32) })
- };
-}
-
-/// Internal Error constants
-pub(crate) const UNSUPPORTED: Error = internal_error!(0);
-pub(crate) const ERRNO_NOT_POSITIVE: Error = internal_error!(1);
-pub(crate) const UNKNOWN_IO_ERROR: Error = internal_error!(2);
-pub(crate) const SEC_RANDOM_FAILED: Error = internal_error!(3);
-pub(crate) const RTL_GEN_RANDOM_FAILED: Error = internal_error!(4);
-pub(crate) const FAILED_RDRAND: Error = internal_error!(5);
-pub(crate) const NO_RDRAND: Error = internal_error!(6);
-pub(crate) const BINDGEN_CRYPTO_UNDEF: Error = internal_error!(7);
-pub(crate) const BINDGEN_GRV_UNDEF: Error = internal_error!(8);
-pub(crate) const STDWEB_NO_RNG: Error = internal_error!(9);
-pub(crate) const STDWEB_RNG_FAILED: Error = internal_error!(10);
-pub(crate) const RAND_SECURE_FATAL: Error = internal_error!(11);
-
-fn internal_desc(error: Error) -> Option<&'static str> {
- match error {
- UNSUPPORTED => Some("getrandom: this target is not supported"),
- ERRNO_NOT_POSITIVE => Some("errno: did not return a positive value"),
- UNKNOWN_IO_ERROR => Some("Unknown std::io::Error"),
- SEC_RANDOM_FAILED => Some("SecRandomCopyBytes: call failed"),
- RTL_GEN_RANDOM_FAILED => Some("RtlGenRandom: call failed"),
- FAILED_RDRAND => Some("RDRAND: failed multiple times: CPU issue likely"),
- NO_RDRAND => Some("RDRAND: instruction not supported"),
- BINDGEN_CRYPTO_UNDEF => Some("wasm-bindgen: self.crypto is undefined"),
- BINDGEN_GRV_UNDEF => Some("wasm-bindgen: crypto.getRandomValues is undefined"),
- STDWEB_NO_RNG => Some("stdweb: no randomness source available"),
- STDWEB_RNG_FAILED => Some("stdweb: failed to get randomness"),
- RAND_SECURE_FATAL => Some("randSecure: random number generator module is not initialized"),
- _ => None,
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::Error;
- use core::mem::size_of;
-
- #[test]
- fn test_size() {
- assert_eq!(size_of::<Error>(), 4);
- assert_eq!(size_of::<Result<(), Error>>(), 4);
- }
-}
diff --git a/getrandom/src/error_impls.rs b/getrandom/src/error_impls.rs
deleted file mode 100644
index 007472e..0000000
--- a/getrandom/src/error_impls.rs
+++ /dev/null
@@ -1,35 +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.
-extern crate std;
-
-use crate::{error::UNKNOWN_IO_ERROR, Error};
-use core::convert::From;
-use core::num::NonZeroU32;
-use std::io;
-
-impl From<io::Error> for Error {
- fn from(err: io::Error) -> Self {
- if let Some(errno) = err.raw_os_error() {
- if let Some(code) = NonZeroU32::new(errno as u32) {
- return Error::from(code);
- }
- }
- UNKNOWN_IO_ERROR
- }
-}
-
-impl From<Error> for io::Error {
- fn from(err: Error) -> Self {
- match err.raw_os_error() {
- Some(errno) => io::Error::from_raw_os_error(errno),
- None => io::Error::new(io::ErrorKind::Other, err),
- }
- }
-}
-
-impl std::error::Error for Error {}
diff --git a/getrandom/src/fuchsia.rs b/getrandom/src/fuchsia.rs
deleted file mode 100644
index 572ff53..0000000
--- a/getrandom/src/fuchsia.rs
+++ /dev/null
@@ -1,20 +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
-use crate::Error;
-
-#[link(name = "zircon")]
-extern "C" {
- fn zx_cprng_draw(buffer: *mut u8, length: usize);
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- unsafe { zx_cprng_draw(dest.as_mut_ptr(), dest.len()) }
- Ok(())
-}
diff --git a/getrandom/src/ios.rs b/getrandom/src/ios.rs
deleted file mode 100644
index 30c008c..0000000
--- a/getrandom/src/ios.rs
+++ /dev/null
@@ -1,31 +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 iOS
-use crate::{error::SEC_RANDOM_FAILED, Error};
-
-// TODO: Make extern once extern_types feature is stabilized. See:
-// https://github.com/rust-lang/rust/issues/43467
-#[repr(C)]
-struct SecRandom([u8; 0]);
-
-#[link(name = "Security", kind = "framework")]
-extern "C" {
- static kSecRandomDefault: *const SecRandom;
-
- fn SecRandomCopyBytes(rnd: *const SecRandom, count: usize, bytes: *mut u8) -> i32;
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- let ret = unsafe { SecRandomCopyBytes(kSecRandomDefault, dest.len(), dest.as_mut_ptr()) };
- if ret == -1 {
- Err(SEC_RANDOM_FAILED)
- } else {
- Ok(())
- }
-}
diff --git a/getrandom/src/lib.rs b/getrandom/src/lib.rs
deleted file mode 100644
index c305406..0000000
--- a/getrandom/src/lib.rs
+++ /dev/null
@@ -1,282 +0,0 @@
-// Copyright 2019 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.
-
-//! Interface to the random number generator of the operating system.
-//!
-//! # Platform sources
-//!
-//! | OS | interface
-//! |------------------|---------------------------------------------------------
-//! | Linux, Android | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random`
-//! | Windows | [`RtlGenRandom`][3]
-//! | macOS | [`getentropy()`][19] if available, otherwise [`/dev/random`][20] (identical to `/dev/urandom`)
-//! | iOS | [`SecRandomCopyBytes`][4]
-//! | FreeBSD | [`getrandom()`][21] if available, otherwise [`kern.arandom`][5]
-//! | OpenBSD | [`getentropy`][6]
-//! | NetBSD | [`kern.arandom`][7]
-//! | 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 | [`cloudabi_sys_random_get`][13]
-//! | Haiku | `/dev/random` (identical to `/dev/urandom`)
-//! | L4RE, SGX, UEFI | [RDRAND][18]
-//! | Hermit | [RDRAND][18] as [`sys_rand`][22] is currently broken.
-//! | VxWorks | `randABytes` after checking entropy pool initialization with `randSecure`
-//! | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and asm.js][16])
-//! | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and asm.js][16])
-//! | WASI | [`__wasi_random_get`][17]
-//!
-//! Getrandom 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.
-//!
-//! ## Unsupported targets
-//!
-//! By default, compiling `getrandom` for an unsupported target will result in
-//! a compilation error. If you want to build an application which uses `getrandom`
-//! for such target, you can either:
-//! - Use [`[replace]`][replace] or [`[patch]`][patch] section in your `Cargo.toml`
-//! to switch to a custom implementation with a support of your target.
-//! - Enable the `dummy` feature to have getrandom use an implementation that always
-//! fails at run-time on unsupported targets.
-//!
-//! [replace]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-replace-section
-//! [patch]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-patch-section
-//!
-//! ## Support for WebAssembly and asm.js
-//!
-//! Getrandom supports all of Rust's current `wasm32` targets, and it works with
-//! both Node.js and web browsers. The three Emscripten targets
-//! `asmjs-unknown-emscripten`, `wasm32-unknown-emscripten`, and
-//! `wasm32-experimental-emscripten` use Emscripten's `/dev/random` emulation.
-//! The WASI target `wasm32-wasi` uses the [`__wasi_random_get`][17] function
-//! defined by the WASI standard.
-//!
-//! Getrandom also supports `wasm32-unknown-unknown` by directly calling
-//! JavaScript methods. Rust currently has two ways to do this: [bindgen] and
-//! [stdweb]. Getrandom supports using either one by enabling the
-//! `wasm-bindgen` or `stdweb` crate features. Note that if both features are
-//! enabled, `wasm-bindgen` will be used. If neither feature is enabled, calls
-//! to `getrandom` will always fail at runtime.
-//!
-//! [bindgen]: https://github.com/rust-lang/rust-bindgen
-//! [stdweb]: https://github.com/koute/stdweb
-//!
-//! ## 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; in these cases we always choose to block.
-//!
-//! On Linux (when the `getrandom` system call is not available) and on NetBSD
-//! reading from `/dev/urandom` never blocks, even when the OS hasn't collected
-//! enough entropy yet. To avoid returning low-entropy bytes, we first read from
-//! `/dev/random` and only switch to `/dev/urandom` once this has succeeded.
-//!
-//! # Error handling
-//!
-//! We always choose failure over returning insecure "random" bytes. In general,
-//! on supported platforms, failure is highly unlikely, though not impossible.
-//! If an error does occur, then it is likely that it will occur on every call to
-//! `getrandom`, hence after the first successful call one can be reasonably
-//! confident that no errors will occur.
-//!
-//! On unsupported platforms, `getrandom` always fails. See the [`Error`] type
-//! for more information on what data is returned on failure.
-//!
-//! [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html
-//! [2]: http://man7.org/linux/man-pages/man4/urandom.4.html
-//! [3]: https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/nf-ntsecapi-rtlgenrandom
-//! [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]: https://netbsd.gw.com/cgi-bin/man-cgi?sysctl+7+NetBSD-8.0
-//! [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.dev/fuchsia-src/zircon/syscalls/cprng_draw
-//! [12]: https://github.com/redox-os/randd/blob/master/src/main.rs
-//! [13]: https://github.com/nuxinl/cloudabi#random_get
-//! [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-asmjs
-//! [17]: https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md#__wasi_random_get
-//! [18]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
-//! [19]: https://www.unix.com/man-page/mojave/2/getentropy/
-//! [20]: https://www.unix.com/man-page/mojave/4/random/
-//! [21]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable
-//! [22]: https://github.com/hermitcore/libhermit-rs/blob/09c38b0371cee6f56a541400ba453e319e43db53/src/syscalls/random.rs#L21
-
-#![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/"
-)]
-#![no_std]
-#![cfg_attr(feature = "stdweb", recursion_limit = "128")]
-#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
-
-#[macro_use]
-extern crate cfg_if;
-
-cfg_if! {
- if #[cfg(feature = "log")] {
- #[allow(unused)]
- #[macro_use]
- extern crate log;
- } else {
- #[allow(unused)]
- macro_rules! error {
- ($($x:tt)*) => {};
- }
- #[allow(unused)]
- macro_rules! warn {
- ($($x:tt)*) => {};
- }
- #[allow(unused)]
- macro_rules! info {
- ($($x:tt)*) => {};
- }
- }
-}
-
-mod error;
-pub use crate::error::Error;
-
-#[allow(dead_code)]
-mod util;
-
-#[cfg(target_os = "vxworks")]
-#[allow(dead_code)]
-mod util_libc;
-
-cfg_if! {
- // Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls.
- if #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "emscripten",
- target_os = "freebsd", target_os = "haiku", target_os = "illumos",
- target_os = "linux", target_os = "macos", target_os = "netbsd",
- target_os = "openbsd", target_os = "redox", target_os = "solaris"))] {
- #[allow(dead_code)]
- mod util_libc;
- // Keep std-only trait definitions for backwards compatibility
- mod error_impls;
- } else if #[cfg(feature = "std")] {
- mod error_impls;
- }
-}
-
-// These targets read from a file as a fallback method.
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "macos",
- target_os = "solaris",
- target_os = "illumos",
-))]
-mod use_file;
-
-// System-specific implementations.
-//
-// These should all provide getrandom_inner with the same signature as getrandom.
-cfg_if! {
- if #[cfg(target_os = "android")] {
- #[path = "linux_android.rs"] mod imp;
- } else if #[cfg(target_os = "cloudabi")] {
- #[path = "cloudabi.rs"] mod imp;
- } else if #[cfg(target_os = "dragonfly")] {
- #[path = "use_file.rs"] mod imp;
- } else if #[cfg(target_os = "emscripten")] {
- #[path = "use_file.rs"] mod imp;
- } else if #[cfg(target_os = "freebsd")] {
- #[path = "bsd_arandom.rs"] mod imp;
- } else if #[cfg(target_os = "fuchsia")] {
- #[path = "fuchsia.rs"] mod imp;
- } else if #[cfg(target_os = "haiku")] {
- #[path = "use_file.rs"] mod imp;
- } else if #[cfg(target_os = "illumos")] {
- #[path = "solaris_illumos.rs"] mod imp;
- } else if #[cfg(target_os = "ios")] {
- #[path = "ios.rs"] mod imp;
- } else if #[cfg(target_os = "linux")] {
- #[path = "linux_android.rs"] mod imp;
- } else if #[cfg(target_os = "macos")] {
- #[path = "macos.rs"] mod imp;
- } else if #[cfg(target_os = "netbsd")] {
- #[path = "bsd_arandom.rs"] mod imp;
- } else if #[cfg(target_os = "openbsd")] {
- #[path = "openbsd.rs"] mod imp;
- } else if #[cfg(target_os = "redox")] {
- #[path = "use_file.rs"] mod imp;
- } else if #[cfg(target_os = "solaris")] {
- #[path = "solaris_illumos.rs"] mod imp;
- } else if #[cfg(target_os = "wasi")] {
- #[path = "wasi.rs"] mod imp;
- } else if #[cfg(target_os = "vxworks")] {
- #[path = "vxworks.rs"] mod imp;
- } else if #[cfg(all(windows, getrandom_uwp))] {
- #[path = "windows_uwp.rs"] mod imp;
- } else if #[cfg(windows)] {
- #[path = "windows.rs"] mod imp;
- } else if #[cfg(all(target_arch = "x86_64", any(
- target_os = "hermit",
- target_os = "l4re",
- target_os = "uefi",
- target_env = "sgx",
- )))] {
- #[path = "rdrand.rs"] mod imp;
- } else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
- cfg_if! {
- if #[cfg(feature = "wasm-bindgen")] {
- #[path = "wasm32_bindgen.rs"] mod imp;
- } else if #[cfg(feature = "stdweb")] {
- #[path = "wasm32_stdweb.rs"] mod imp;
- } else {
- // Always have an implementation for wasm32-unknown-unknown.
- // See https://github.com/rust-random/getrandom/issues/87
- #[path = "dummy.rs"] mod imp;
- }
- }
- } else if #[cfg(feature = "dummy")] {
- #[path = "dummy.rs"] mod imp;
- } else {
- compile_error!("\
- target is not supported, for more information see: \
- https://docs.rs/getrandom/#unsupported-targets\
- ");
- }
-}
-
-/// Fill `dest` with random bytes from the system's preferred random number
-/// source.
-///
-/// This function returns an error on any failure, including partial reads. We
-/// make no guarantees regarding the contents of `dest` on error. If `dest` is
-/// empty, `getrandom` immediately returns success, making no calls to the
-/// underlying operating system.
-///
-/// Blocking is possible, at least during early boot; see module documentation.
-///
-/// In general, `getrandom` will be fast enough for interactive usage, though
-/// significantly slower than a user-space CSPRNG; for the latter consider
-/// [`rand::thread_rng`](https://docs.rs/rand/*/rand/fn.thread_rng.html).
-pub fn getrandom(dest: &mut [u8]) -> Result<(), error::Error> {
- if dest.is_empty() {
- return Ok(());
- }
- imp::getrandom_inner(dest)
-}
diff --git a/getrandom/src/linux_android.rs b/getrandom/src/linux_android.rs
deleted file mode 100644
index a29feb5..0000000
--- a/getrandom/src/linux_android.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 Linux / Android
-use crate::util::LazyBool;
-use crate::util_libc::{last_os_error, sys_fill_exact};
-use crate::{use_file, Error};
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- static HAS_GETRANDOM: LazyBool = LazyBool::new();
- if HAS_GETRANDOM.unsync_init(is_getrandom_available) {
- sys_fill_exact(dest, |buf| unsafe {
- getrandom(buf.as_mut_ptr() as *mut libc::c_void, buf.len(), 0)
- })
- } else {
- use_file::getrandom_inner(dest)
- }
-}
-
-fn is_getrandom_available() -> bool {
- let res = unsafe { getrandom(core::ptr::null_mut(), 0, libc::GRND_NONBLOCK) };
- if res < 0 {
- match last_os_error().raw_os_error() {
- Some(libc::ENOSYS) => false, // No kernel support
- Some(libc::EPERM) => false, // Blocked by seccomp
- _ => true,
- }
- } else {
- true
- }
-}
-
-unsafe fn getrandom(
- buf: *mut libc::c_void,
- buflen: libc::size_t,
- flags: libc::c_uint,
-) -> libc::ssize_t {
- libc::syscall(libc::SYS_getrandom, buf, buflen, flags) as libc::ssize_t
-}
diff --git a/getrandom/src/macos.rs b/getrandom/src/macos.rs
deleted file mode 100644
index c3bc533..0000000
--- a/getrandom/src/macos.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2019 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
-use crate::util_libc::{last_os_error, Weak};
-use crate::{use_file, Error};
-use core::mem;
-
-type GetEntropyFn = unsafe extern "C" fn(*mut u8, libc::size_t) -> libc::c_int;
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- static GETENTROPY: Weak = unsafe { Weak::new("getentropy\0") };
- if let Some(fptr) = GETENTROPY.ptr() {
- let func: GetEntropyFn = unsafe { mem::transmute(fptr) };
- for chunk in dest.chunks_mut(256) {
- let ret = unsafe { func(chunk.as_mut_ptr(), chunk.len()) };
- if ret != 0 {
- let err = last_os_error();
- error!("getentropy syscall failed");
- return Err(err);
- }
- }
- Ok(())
- } else {
- // We fallback to reading from /dev/random instead of SecRandomCopyBytes
- // to avoid high startup costs and linking the Security framework.
- use_file::getrandom_inner(dest)
- }
-}
diff --git a/getrandom/src/openbsd.rs b/getrandom/src/openbsd.rs
deleted file mode 100644
index e1ac179..0000000
--- a/getrandom/src/openbsd.rs
+++ /dev/null
@@ -1,23 +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
-use crate::util_libc::last_os_error;
-use crate::Error;
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- for chunk in dest.chunks_mut(256) {
- let ret = unsafe { libc::getentropy(chunk.as_mut_ptr() as *mut libc::c_void, chunk.len()) };
- if ret == -1 {
- let err = last_os_error();
- error!("libc::getentropy call failed");
- return Err(err);
- }
- }
- Ok(())
-}
diff --git a/getrandom/src/rdrand.rs b/getrandom/src/rdrand.rs
deleted file mode 100644
index e441682..0000000
--- a/getrandom/src/rdrand.rs
+++ /dev/null
@@ -1,90 +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 SGX using RDRAND instruction
-use crate::error::{FAILED_RDRAND, NO_RDRAND};
-#[cfg(not(target_feature = "rdrand"))]
-use crate::util::LazyBool;
-use crate::Error;
-use core::arch::x86_64::_rdrand64_step;
-use core::mem;
-
-// Recommendation from "Intel® Digital Random Number Generator (DRNG) Software
-// Implementation Guide" - Section 5.2.1 and "Intel® 64 and IA-32 Architectures
-// Software Developer’s Manual" - Volume 1 - Section 7.3.17.1.
-const RETRY_LIMIT: usize = 10;
-const WORD_SIZE: usize = mem::size_of::<u64>();
-
-#[target_feature(enable = "rdrand")]
-unsafe fn rdrand() -> Result<[u8; WORD_SIZE], Error> {
- for _ in 0..RETRY_LIMIT {
- let mut el = mem::zeroed();
- if _rdrand64_step(&mut el) == 1 {
- // AMD CPUs from families 14h to 16h (pre Ryzen) sometimes fail to
- // set CF on bogus random data, so we check these values explicitly.
- // See https://github.com/systemd/systemd/issues/11810#issuecomment-489727505
- // We perform this check regardless of target to guard against
- // any implementation that incorrectly fails to set CF.
- if el != 0 && el != !0 {
- return Ok(el.to_ne_bytes());
- }
- error!("RDRAND returned {:X}, CPU RNG may be broken", el);
- // Keep looping in case this was a false positive.
- }
- }
- Err(FAILED_RDRAND)
-}
-
-// "rdrand" target feature requires "+rdrnd" flag, see https://github.com/rust-lang/rust/issues/49653.
-#[cfg(all(target_env = "sgx", not(target_feature = "rdrand")))]
-compile_error!(
- "SGX targets require 'rdrand' target feature. Enable by using -C target-feature=+rdrnd."
-);
-
-#[cfg(target_feature = "rdrand")]
-fn is_rdrand_supported() -> bool {
- true
-}
-
-// TODO use is_x86_feature_detected!("rdrand") when that works in core. See:
-// https://github.com/rust-lang-nursery/stdsimd/issues/464
-#[cfg(not(target_feature = "rdrand"))]
-fn is_rdrand_supported() -> bool {
- use core::arch::x86_64::__cpuid;
- // SAFETY: All x86_64 CPUs support CPUID leaf 1
- const FLAG: u32 = 1 << 30;
- static HAS_RDRAND: LazyBool = LazyBool::new();
- HAS_RDRAND.unsync_init(|| unsafe { (__cpuid(1).ecx & FLAG) != 0 })
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- if !is_rdrand_supported() {
- return Err(NO_RDRAND);
- }
-
- // SAFETY: After this point, rdrand is supported, so calling the rdrand
- // functions is not undefined behavior.
- unsafe { rdrand_exact(dest) }
-}
-
-#[target_feature(enable = "rdrand")]
-unsafe fn rdrand_exact(dest: &mut [u8]) -> Result<(), Error> {
- // We use chunks_exact_mut instead of chunks_mut as it allows almost all
- // calls to memcpy to be elided by the compiler.
- let mut chunks = dest.chunks_exact_mut(WORD_SIZE);
- for chunk in chunks.by_ref() {
- chunk.copy_from_slice(&rdrand()?);
- }
-
- let tail = chunks.into_remainder();
- let n = tail.len();
- if n > 0 {
- tail.copy_from_slice(&rdrand()?[..n]);
- }
- Ok(())
-}
diff --git a/getrandom/src/solaris_illumos.rs b/getrandom/src/solaris_illumos.rs
deleted file mode 100644
index 9473123..0000000
--- a/getrandom/src/solaris_illumos.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 the Solaris family
-//!
-//! Read from `/dev/random`, with chunks of limited size (256 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 and mid-2015 illumos, the `getrandom` syscall is available.
-//! To make sure we can compile on both Solaris and its derivatives, as well as
-//! function, we check for the existence of getrandom(2) in libc by calling
-//! libc::dlsym.
-use crate::util_libc::{sys_fill_exact, Weak};
-use crate::{use_file, Error};
-use core::mem;
-
-#[cfg(target_os = "illumos")]
-type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t;
-#[cfg(target_os = "solaris")]
-type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::c_int;
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") };
- if let Some(fptr) = GETRANDOM.ptr() {
- let func: GetRandomFn = unsafe { mem::transmute(fptr) };
- // 256 bytes is the lowest common denominator across all the Solaris
- // derived platforms for atomically obtaining random data.
- for chunk in dest.chunks_mut(256) {
- sys_fill_exact(chunk, |buf| unsafe {
- func(buf.as_mut_ptr(), buf.len(), 0) as libc::ssize_t
- })?
- }
- Ok(())
- } else {
- use_file::getrandom_inner(dest)
- }
-}
diff --git a/getrandom/src/use_file.rs b/getrandom/src/use_file.rs
deleted file mode 100644
index d3adaf2..0000000
--- a/getrandom/src/use_file.rs
+++ /dev/null
@@ -1,73 +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.
-
-//! Implementations that just need to read from a file
-use crate::util_libc::{last_os_error, open_readonly, sys_fill_exact, LazyFd};
-use crate::Error;
-
-#[cfg(target_os = "redox")]
-const FILE_PATH: &str = "rand:\0";
-#[cfg(any(
- target_os = "dragonfly",
- target_os = "emscripten",
- target_os = "haiku",
- target_os = "macos",
- target_os = "solaris",
- target_os = "illumos"
-))]
-const FILE_PATH: &str = "/dev/random\0";
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- static FD: LazyFd = LazyFd::new();
- let fd = FD.init(init_file).ok_or_else(last_os_error)?;
- let read = |buf: &mut [u8]| unsafe { libc::read(fd, buf.as_mut_ptr() as *mut _, buf.len()) };
-
- if cfg!(target_os = "emscripten") {
- // `Crypto.getRandomValues` documents `dest` should be at most 65536 bytes.
- for chunk in dest.chunks_mut(65536) {
- sys_fill_exact(chunk, read)?;
- }
- } else {
- sys_fill_exact(dest, read)?;
- }
- Ok(())
-}
-
-cfg_if! {
- if #[cfg(any(target_os = "android", target_os = "linux"))] {
- fn init_file() -> Option<libc::c_int> {
- // Poll /dev/random to make sure it is ok to read from /dev/urandom.
- let mut pfd = libc::pollfd {
- fd: unsafe { open_readonly("/dev/random\0")? },
- events: libc::POLLIN,
- revents: 0,
- };
-
- let ret = loop {
- // A negative timeout means an infinite timeout.
- let res = unsafe { libc::poll(&mut pfd, 1, -1) };
- if res == 1 {
- break unsafe { open_readonly("/dev/urandom\0") };
- } else if res < 0 {
- let e = last_os_error().raw_os_error();
- if e == Some(libc::EINTR) || e == Some(libc::EAGAIN) {
- continue;
- }
- }
- // We either hard failed, or poll() returned the wrong pfd.
- break None;
- };
- unsafe { libc::close(pfd.fd) };
- ret
- }
- } else {
- fn init_file() -> Option<libc::c_int> {
- unsafe { open_readonly(FILE_PATH) }
- }
- }
-}
diff --git a/getrandom/src/util.rs b/getrandom/src/util.rs
deleted file mode 100644
index e0e9307..0000000
--- a/getrandom/src/util.rs
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2019 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 core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
-
-// This structure represents a lazily initialized static usize value. Useful
-// when it is preferable to just rerun initialization instead of locking.
-// Both unsync_init and sync_init will invoke an init() function until it
-// succeeds, then return the cached value for future calls.
-//
-// Both methods support init() "failing". If the init() method returns UNINIT,
-// that value will be returned as normal, but will not be cached.
-//
-// Users should only depend on the _value_ returned by init() functions.
-// Specifically, for the following init() function:
-// fn init() -> usize {
-// a();
-// let v = b();
-// c();
-// v
-// }
-// the effects of c() or writes to shared memory will not necessarily be
-// observed and additional synchronization methods with be needed.
-pub struct LazyUsize(AtomicUsize);
-
-impl LazyUsize {
- pub const fn new() -> Self {
- Self(AtomicUsize::new(Self::UNINIT))
- }
-
- // The initialization is not completed.
- pub const UNINIT: usize = usize::max_value();
- // The initialization is currently running.
- pub const ACTIVE: usize = usize::max_value() - 1;
-
- // Runs the init() function at least once, returning the value of some run
- // of init(). Multiple callers can run their init() functions in parallel.
- // init() should always return the same value, if it succeeds.
- pub fn unsync_init(&self, init: impl FnOnce() -> usize) -> usize {
- // Relaxed ordering is fine, as we only have a single atomic variable.
- let mut val = self.0.load(Relaxed);
- if val == Self::UNINIT {
- val = init();
- self.0.store(val, Relaxed);
- }
- val
- }
-
- // Synchronously runs the init() function. Only one caller will have their
- // init() function running at a time, and exactly one successful call will
- // be run. init() returning UNINIT or ACTIVE will be considered a failure,
- // and future calls to sync_init will rerun their init() function.
- pub fn sync_init(&self, init: impl FnOnce() -> usize, mut wait: impl FnMut()) -> usize {
- // Common and fast path with no contention. Don't wast time on CAS.
- match self.0.load(Relaxed) {
- Self::UNINIT | Self::ACTIVE => {}
- val => return val,
- }
- // Relaxed ordering is fine, as we only have a single atomic variable.
- loop {
- match self.0.compare_and_swap(Self::UNINIT, Self::ACTIVE, Relaxed) {
- Self::UNINIT => {
- let val = init();
- self.0.store(
- match val {
- Self::UNINIT | Self::ACTIVE => Self::UNINIT,
- val => val,
- },
- Relaxed,
- );
- return val;
- }
- Self::ACTIVE => wait(),
- val => return val,
- }
- }
- }
-}
-
-// Identical to LazyUsize except with bool instead of usize.
-pub struct LazyBool(LazyUsize);
-
-impl LazyBool {
- pub const fn new() -> Self {
- Self(LazyUsize::new())
- }
-
- pub fn unsync_init(&self, init: impl FnOnce() -> bool) -> bool {
- self.0.unsync_init(|| init() as usize) != 0
- }
-}
diff --git a/getrandom/src/util_libc.rs b/getrandom/src/util_libc.rs
deleted file mode 100644
index 5a05170..0000000
--- a/getrandom/src/util_libc.rs
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2019 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 crate::error::ERRNO_NOT_POSITIVE;
-use crate::util::LazyUsize;
-use crate::Error;
-use core::num::NonZeroU32;
-use core::ptr::NonNull;
-
-cfg_if! {
- if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] {
- use libc::__errno as errno_location;
- } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox"))] {
- use libc::__errno_location as errno_location;
- } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
- use libc::___errno as errno_location;
- } else if #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))] {
- use libc::__error as errno_location;
- } else if #[cfg(target_os = "haiku")] {
- use libc::_errnop as errno_location;
- }
-}
-
-pub fn last_os_error() -> Error {
- #[cfg(not(target_os = "vxworks"))]
- let errno = unsafe { *errno_location() };
- #[cfg(target_os = "vxworks")]
- let errno = unsafe { libc::errnoGet() };
- if errno > 0 {
- Error::from(NonZeroU32::new(errno as u32).unwrap())
- } else {
- ERRNO_NOT_POSITIVE
- }
-}
-
-// Fill a buffer by repeatedly invoking a system call. The `sys_fill` function:
-// - should return -1 and set errno on failure
-// - should return the number of bytes written on success
-pub fn sys_fill_exact(
- mut buf: &mut [u8],
- sys_fill: impl Fn(&mut [u8]) -> libc::ssize_t,
-) -> Result<(), Error> {
- while !buf.is_empty() {
- let res = sys_fill(buf);
- if res < 0 {
- let err = last_os_error();
- // We should try again if the call was interrupted.
- if err.raw_os_error() != Some(libc::EINTR) {
- return Err(err);
- }
- } else {
- // We don't check for EOF (ret = 0) as the data we are reading
- // should be an infinite stream of random bytes.
- buf = &mut buf[(res as usize)..];
- }
- }
- Ok(())
-}
-
-// A "weak" binding to a C function that may or may not be present at runtime.
-// Used for supporting newer OS features while still building on older systems.
-// F must be a function pointer of type `unsafe extern "C" fn`. Based off of the
-// weak! macro in libstd.
-pub struct Weak {
- name: &'static str,
- addr: LazyUsize,
-}
-
-impl Weak {
- // Construct a binding to a C function with a given name. This function is
- // unsafe because `name` _must_ be null terminated.
- pub const unsafe fn new(name: &'static str) -> Self {
- Self {
- name,
- addr: LazyUsize::new(),
- }
- }
-
- // Return a function pointer if present at runtime. Otherwise, return null.
- pub fn ptr(&self) -> Option<NonNull<libc::c_void>> {
- let addr = self.addr.unsync_init(|| unsafe {
- libc::dlsym(libc::RTLD_DEFAULT, self.name.as_ptr() as *const _) as usize
- });
- NonNull::new(addr as *mut _)
- }
-}
-
-pub struct LazyFd(LazyUsize);
-
-impl LazyFd {
- pub const fn new() -> Self {
- Self(LazyUsize::new())
- }
-
- // If init() returns Some(x), x should be nonnegative.
- pub fn init(&self, init: impl FnOnce() -> Option<libc::c_int>) -> Option<libc::c_int> {
- let fd = self.0.sync_init(
- || match init() {
- // OK as val >= 0 and val <= c_int::MAX < usize::MAX
- Some(val) => val as usize,
- None => LazyUsize::UNINIT,
- },
- || unsafe {
- // We are usually waiting on an open(2) syscall to complete,
- // which typically takes < 10us if the file is a device.
- // However, we might end up waiting much longer if the entropy
- // pool isn't initialized, but even in that case, this loop will
- // consume a negligible amount of CPU on most platforms.
- libc::usleep(10);
- },
- );
- match fd {
- LazyUsize::UNINIT => None,
- val => Some(val as libc::c_int),
- }
- }
-}
-
-cfg_if! {
- if #[cfg(any(target_os = "linux", target_os = "emscripten"))] {
- use libc::open64 as open;
- } else {
- use libc::open;
- }
-}
-
-// SAFETY: path must be null terminated, FD must be manually closed.
-pub unsafe fn open_readonly(path: &str) -> Option<libc::c_int> {
- debug_assert!(path.as_bytes().last() == Some(&0));
- let fd = open(path.as_ptr() as *mut _, libc::O_RDONLY | libc::O_CLOEXEC);
- if fd < 0 {
- return None;
- }
- // O_CLOEXEC works on all Unix targets except for older Linux kernels (pre
- // 2.6.23), so we also use an ioctl to make sure FD_CLOEXEC is set.
- #[cfg(target_os = "linux")]
- libc::ioctl(fd, libc::FIOCLEX);
- Some(fd)
-}
diff --git a/getrandom/src/vxworks.rs b/getrandom/src/vxworks.rs
deleted file mode 100644
index a2fe52a..0000000
--- a/getrandom/src/vxworks.rs
+++ /dev/null
@@ -1,35 +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 VxWorks
-use crate::error::{Error, RAND_SECURE_FATAL};
-use crate::util_libc::last_os_error;
-use core::sync::atomic::{AtomicBool, Ordering::Relaxed};
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- static RNG_INIT: AtomicBool = AtomicBool::new(false);
- while !RNG_INIT.load(Relaxed) {
- let ret = unsafe { libc::randSecure() };
- if ret < 0 {
- return Err(RAND_SECURE_FATAL);
- } else if ret > 0 {
- RNG_INIT.store(true, Relaxed);
- break;
- }
- unsafe { libc::usleep(10) };
- }
-
- // Prevent overflow of i32
- for chunk in dest.chunks_mut(i32::max_value() as usize) {
- let ret = unsafe { libc::randABytes(chunk.as_mut_ptr(), chunk.len() as i32) };
- if ret != 0 {
- return Err(last_os_error());
- }
- }
- Ok(())
-}
diff --git a/getrandom/src/wasi.rs b/getrandom/src/wasi.rs
deleted file mode 100644
index 713c1ab..0000000
--- a/getrandom/src/wasi.rs
+++ /dev/null
@@ -1,19 +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 WASI
-use crate::Error;
-use core::num;
-use wasi::wasi_unstable::random_get;
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- random_get(dest).map_err(|e: num::NonZeroU16| {
- // convert wasi's NonZeroU16 error into getrandom's NonZeroU32 error
- num::NonZeroU32::new(e.get() as u32).unwrap().into()
- })
-}
diff --git a/getrandom/src/wasm32_bindgen.rs b/getrandom/src/wasm32_bindgen.rs
deleted file mode 100644
index 86839a0..0000000
--- a/getrandom/src/wasm32_bindgen.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.
-
-//! Implementation for WASM via wasm-bindgen
-extern crate std;
-
-use core::cell::RefCell;
-use core::mem;
-use std::thread_local;
-
-use wasm_bindgen::prelude::*;
-
-use crate::error::{BINDGEN_CRYPTO_UNDEF, BINDGEN_GRV_UNDEF};
-use crate::Error;
-
-#[derive(Clone, Debug)]
-enum RngSource {
- Node(NodeCrypto),
- Browser(BrowserCrypto),
-}
-
-// JsValues are always per-thread, so we initialize RngSource for each thread.
-// See: https://github.com/rustwasm/wasm-bindgen/pull/955
-thread_local!(
- static RNG_SOURCE: RefCell<Option<RngSource>> = RefCell::new(None);
-);
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- assert_eq!(mem::size_of::<usize>(), 4);
-
- RNG_SOURCE.with(|f| {
- let mut source = f.borrow_mut();
- if source.is_none() {
- *source = Some(getrandom_init()?);
- }
-
- match source.as_ref().unwrap() {
- RngSource::Node(n) => n.random_fill_sync(dest),
- RngSource::Browser(n) => {
- // 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.
- for chunk in dest.chunks_mut(65536) {
- n.get_random_values(chunk)
- }
- }
- };
- Ok(())
- })
-}
-
-fn getrandom_init() -> Result<RngSource, Error> {
- if let Ok(self_) = Global::get_self() {
- // 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 = self_.crypto();
- if crypto.is_undefined() {
- return Err(BINDGEN_CRYPTO_UNDEF);
- }
-
- // Test if `crypto.getRandomValues` is undefined as well
- let crypto: BrowserCrypto = crypto.into();
- if crypto.get_random_values_fn().is_undefined() {
- return Err(BINDGEN_GRV_UNDEF);
- }
-
- return Ok(RngSource::Browser(crypto));
- }
-
- return Ok(RngSource::Node(node_require("crypto")));
-}
-
-#[wasm_bindgen]
-extern "C" {
- type Global;
- #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = self, js_name = self)]
- fn get_self() -> Result<Self_, JsValue>;
-
- type Self_;
- #[wasm_bindgen(method, getter, structural)]
- fn crypto(me: &Self_) -> JsValue;
-
- #[derive(Clone, Debug)]
- 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)]
- fn get_random_values_fn(me: &BrowserCrypto) -> JsValue;
- #[wasm_bindgen(method, js_name = getRandomValues, structural)]
- fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]);
-
- #[wasm_bindgen(js_name = require)]
- fn node_require(s: &str) -> NodeCrypto;
-
- #[derive(Clone, Debug)]
- type NodeCrypto;
-
- #[wasm_bindgen(method, js_name = randomFillSync, structural)]
- fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]);
-}
diff --git a/getrandom/src/wasm32_stdweb.rs b/getrandom/src/wasm32_stdweb.rs
deleted file mode 100644
index 6e5e78a..0000000
--- a/getrandom/src/wasm32_stdweb.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.
-
-//! Implementation for WASM via stdweb
-extern crate std;
-
-use core::mem;
-
-use stdweb::js;
-use stdweb::unstable::TryInto;
-use stdweb::web::error::Error as WebError;
-
-use crate::error::{STDWEB_NO_RNG, STDWEB_RNG_FAILED};
-use crate::Error;
-use std::sync::Once;
-
-#[derive(Clone, Copy, Debug)]
-enum RngSource {
- Browser,
- Node,
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- assert_eq!(mem::size_of::<usize>(), 4);
- static ONCE: Once = Once::new();
- static mut RNG_SOURCE: Result<RngSource, Error> = Ok(RngSource::Node);
-
- // SAFETY: RNG_SOURCE is only written once, before being read.
- ONCE.call_once(|| unsafe {
- RNG_SOURCE = getrandom_init();
- });
- getrandom_fill(unsafe { RNG_SOURCE }?, dest)
-}
-
-fn getrandom_init() -> Result<RngSource, 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(RngSource::Browser)
- } else if ty == 2 {
- Ok(RngSource::Node)
- } else {
- unreachable!()
- }
- } else {
- let _err: WebError = js! { return @{ result }.error }.try_into().unwrap();
- error!("getrandom unavailable: {}", _err);
- Err(STDWEB_NO_RNG)
- }
-}
-
-fn getrandom_fill(source: RngSource, dest: &mut [u8]) -> Result<(), Error> {
- for chunk in dest.chunks_mut(65536) {
- let len = chunk.len() as u32;
- let ptr = chunk.as_mut_ptr() as i32;
-
- let result = match source {
- RngSource::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 };
- }
- },
- RngSource::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 {
- let _err: WebError = js! { return @{ result }.error }.try_into().unwrap();
- error!("getrandom failed: {}", _err);
- return Err(STDWEB_RNG_FAILED);
- }
- }
- Ok(())
-}
diff --git a/getrandom/src/windows.rs b/getrandom/src/windows.rs
deleted file mode 100644
index e1b8df6..0000000
--- a/getrandom/src/windows.rs
+++ /dev/null
@@ -1,26 +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
-use crate::{error::RTL_GEN_RANDOM_FAILED, Error};
-
-extern "system" {
- #[link_name = "SystemFunction036"]
- fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: u32) -> u8;
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- // Prevent overflow of u32
- for chunk in dest.chunks_mut(u32::max_value() as usize) {
- let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr(), chunk.len() as u32) };
- if ret == 0 {
- return Err(RTL_GEN_RANDOM_FAILED);
- }
- }
- Ok(())
-}
diff --git a/getrandom/src/windows_uwp.rs b/getrandom/src/windows_uwp.rs
deleted file mode 100644
index 586c6f6..0000000
--- a/getrandom/src/windows_uwp.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.
-
-//! Implementation for Windows UWP targets. After deprecation of Windows XP
-//! and Vista, this can supersede the `RtlGenRandom`-based implementation.
-use crate::Error;
-use core::{ffi::c_void, num::NonZeroU32, ptr};
-
-const BCRYPT_USE_SYSTEM_PREFERRED_RNG: u32 = 0x00000002;
-
-extern "system" {
- fn BCryptGenRandom(
- hAlgorithm: *mut c_void,
- pBuffer: *mut u8,
- cbBuffer: u32,
- dwFlags: u32,
- ) -> u32;
-}
-
-pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
- // Prevent overflow of u32
- for chunk in dest.chunks_mut(u32::max_value() as usize) {
- let ret = unsafe {
- BCryptGenRandom(
- ptr::null_mut(),
- chunk.as_mut_ptr(),
- chunk.len() as u32,
- BCRYPT_USE_SYSTEM_PREFERRED_RNG,
- )
- };
- // NTSTATUS codes use two highest bits for severity status
- match ret >> 30 {
- 0b01 => {
- info!("BCryptGenRandom: information code 0x{:08X}", ret);
- }
- 0b10 => {
- warn!("BCryptGenRandom: warning code 0x{:08X}", ret);
- }
- 0b11 => {
- error!("BCryptGenRandom: failed with 0x{:08X}", ret);
- // We zeroize the highest bit, so the error code will reside
- // inside the range of designated for OS codes.
- let code = ret ^ (1 << 31);
- // SAFETY: the second highest bit is always equal to one,
- // so it's impossible to get zero. Unfortunately compiler
- // is not smart enough to figure out it yet.
- let code = unsafe { NonZeroU32::new_unchecked(code) };
- return Err(Error::from(code));
- }
- _ => (),
- }
- }
- Ok(())
-}
diff --git a/getrandom/tests/common.rs b/getrandom/tests/common.rs
deleted file mode 100644
index afefa03..0000000
--- a/getrandom/tests/common.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-#[cfg(feature = "wasm-bindgen")]
-use wasm_bindgen_test::*;
-
-use getrandom::getrandom;
-
-#[cfg(feature = "test-in-browser")]
-wasm_bindgen_test_configure!(run_in_browser);
-
-#[cfg_attr(feature = "wasm-bindgen", wasm_bindgen_test)]
-#[test]
-fn test_zero() {
- // Test that APIs are happy with zero-length requests
- getrandom(&mut [0u8; 0]).unwrap();
-}
-
-#[cfg_attr(feature = "wasm-bindgen", wasm_bindgen_test)]
-#[test]
-fn test_diff() {
- let mut v1 = [0u8; 1000];
- getrandom(&mut v1).unwrap();
-
- let mut v2 = [0u8; 1000];
- getrandom(&mut v2).unwrap();
-
- 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);
-}
-
-#[cfg_attr(feature = "wasm-bindgen", wasm_bindgen_test)]
-#[test]
-fn test_huge() {
- let mut huge = [0u8; 100_000];
- getrandom(&mut huge).unwrap();
-}
-
-#[cfg(any(unix, windows, target_os = "redox", target_os = "fuchsia"))]
-#[test]
-fn test_multithreading() {
- 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();
- let mut v = [0u8; 1000];
-
- for _ in 0..100 {
- getrandom(&mut v).unwrap();
- thread::yield_now();
- }
- });
- }
-
- // start all the tasks
- for tx in txs.iter() {
- tx.send(()).unwrap();
- }
-}
diff --git a/getrandom/utils/ci/install.sh b/getrandom/utils/ci/install.sh
deleted file mode 100644
index 8e636e1..0000000
--- a/getrandom/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/getrandom/utils/ci/script.sh b/getrandom/utils/ci/script.sh
deleted file mode 100644
index b3e80d4..0000000
--- a/getrandom/utils/ci/script.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-# Derived from https://github.com/japaric/trust
-
-set -ex
-
-main() {
- cross test --target $TARGET
- cross test --target $TARGET --examples
-}
-
-# we don't run the "test phase" when doing deploys
-if [ -z $TRAVIS_TAG ]; then
- main
-fi
diff --git a/heck/.gitignore b/heck/.gitignore
deleted file mode 100644
index a9d37c5..0000000
--- a/heck/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-target
-Cargo.lock
diff --git a/heck/Cargo.toml b/heck/Cargo.toml
deleted file mode 100644
index 93b64e8..0000000
--- a/heck/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-authors = ["Without Boats <woboats@gmail.com>"]
-name = "heck"
-version = "0.3.1"
-license = "MIT OR Apache-2.0"
-description = "heck is a case conversion library."
-homepage = "https://github.com/withoutboats/heck"
-repository = "https://github.com/withoutboats/heck"
-documentation = "https://docs.rs/heck"
-keywords = ["string", "case", "camel", "snake", "unicode"]
-readme = "README.md"
-
-[dependencies]
-unicode-segmentation = "1.2.0"
diff --git a/heck/LICENSE-APACHE b/heck/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/heck/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/heck/LICENSE-MIT b/heck/LICENSE-MIT
deleted file mode 100644
index e69282e..0000000
--- a/heck/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2015 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/heck/README.md b/heck/README.md
deleted file mode 100644
index cf32337..0000000
--- a/heck/README.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# **heck** is a case conversion library
-
-!["I specifically requested the opposite of this."](https://github.com/withoutboats/heck/blob/master/no_step_on_snek.png)
-
-This library exists to provide case conversion between common cases like
-CamelCase and snake_case. It is intended to be unicode aware, internally
-consistent, and reasonably well performing.
-
-## Definition of a word boundary
-
-Word boundaries are defined as the "unicode words" defined in the
-`unicode_segmentation` library, as well as within those words in this manner:
-
-1. All underscore characters are considered word boundaries.
-2. If an uppercase character is followed by lowercase letters, a word boundary
-is considered to be just prior to that uppercase character.
-3. If multiple uppercase characters are consecutive, they are considered to be
-within a single word, except that the last will be part of the next word if it
-is followed by lowercase characters (see rule 2).
-
-That is, "HelloWorld" is segmented `Hello|World` whereas "XMLHttpRequest" is
-segmented `XML|Http|Request`.
-
-Characters not within words (such as spaces, punctuations, and underscores)
-are not included in the output string except as they are a part of the case
-being converted to. Multiple adjacent word boundaries (such as a series of
-underscores) are folded into one. ("hello__world" in snake case is therefore
-"hello_world", not the exact same string). Leading or trailing word boundary
-indicators are dropped, except insofar as CamelCase capitalizes the first word.
-
-### Cases contained in this library:
-
-1. CamelCase
-2. snake_case
-3. kebab-case
-4. SHOUTY_SNAKE_CASE
-5. mixedCase
-6. Title Case
-
-
-### Contributing
-
-PRs of additional well-established cases welcome.
-
-This library is a little bit opinionated (dropping punctuation, for example).
-If that doesn't fit your use case, I hope there is another crate that does. I
-would prefer **not** to receive PRs to make this behavior more configurable.
-
-Bug reports & fixes always welcome. :-)
-
-### License
-
-heck is distributed under the terms of both the MIT license and the
-Apache License (Version 2.0).
-
-See LICENSE-APACHE and LICENSE-MIT for details.
diff --git a/heck/no_step_on_snek.png b/heck/no_step_on_snek.png
deleted file mode 100644
index 8aff445..0000000
--- a/heck/no_step_on_snek.png
+++ /dev/null
Binary files differ
diff --git a/heck/src/camel.rs b/heck/src/camel.rs
deleted file mode 100644
index 74bd741..0000000
--- a/heck/src/camel.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-/// This trait defines a camel case conversion.
-///
-/// In CamelCase, word boundaries are indicated by capital letters, including
-/// the first word.
-///
-/// ## Example:
-///
-/// ```rust
-/// extern crate heck;
-/// fn main() {
-///
-/// use heck::CamelCase;
-///
-/// let sentence = "We are not in the least afraid of ruins.";
-/// assert_eq!(sentence.to_camel_case(), "WeAreNotInTheLeastAfraidOfRuins");
-/// }
-/// ```
-pub trait CamelCase: ToOwned {
- /// Convert this type to camel case.
- fn to_camel_case(&self) -> Self::Owned;
-}
-
-impl CamelCase for str {
- fn to_camel_case(&self) -> String {
- ::transform(self, ::capitalize, |_| {})
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::CamelCase;
-
- macro_rules! t {
- ($t:ident : $s1:expr => $s2:expr) => {
- #[test]
- fn $t() {
- assert_eq!($s1.to_camel_case(), $s2)
- }
- }
- }
-
- t!(test1: "CamelCase" => "CamelCase");
- t!(test2: "This is Human case." => "ThisIsHumanCase");
- t!(test3: "MixedUP_CamelCase, with some Spaces" => "MixedUpCamelCaseWithSomeSpaces");
- t!(test4: "mixed_up_ snake_case, with some _spaces" => "MixedUpSnakeCaseWithSomeSpaces");
- t!(test5: "kebab-case" => "KebabCase");
- t!(test6: "SHOUTY_SNAKE_CASE" => "ShoutySnakeCase");
- t!(test7: "snake_case" => "SnakeCase");
- t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "ThisContainsAllKindsOfWordBoundaries");
- t!(test9: "XΣXΣ baffle" => "XσxςBaffle");
- t!(test10: "XMLHttpRequest" => "XmlHttpRequest");
-}
diff --git a/heck/src/kebab.rs b/heck/src/kebab.rs
deleted file mode 100644
index f81ba92..0000000
--- a/heck/src/kebab.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-/// This trait defines a kebab case conversion.
-///
-/// In kebab-case, word boundaries are indicated by hyphens.
-///
-/// ## Example:
-///
-/// ```rust
-/// extern crate heck;
-/// fn main() {
-///
-/// use heck::KebabCase;
-///
-/// let sentence = "We are going to inherit the earth.";
-/// assert_eq!(sentence.to_kebab_case(), "we-are-going-to-inherit-the-earth");
-/// }
-/// ```
-pub trait KebabCase: ToOwned {
- /// Convert this type to kebab case.
- fn to_kebab_case(&self) -> Self::Owned;
-}
-
-impl KebabCase for str {
- fn to_kebab_case(&self) -> Self::Owned {
- ::transform(self, ::lowercase, |s| s.push('-'))
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::KebabCase;
-
- macro_rules! t {
- ($t:ident : $s1:expr => $s2:expr) => {
- #[test]
- fn $t() {
- assert_eq!($s1.to_kebab_case(), $s2)
- }
- }
- }
-
- t!(test1: "CamelCase" => "camel-case");
- t!(test2: "This is Human case." => "this-is-human-case");
- t!(test3: "MixedUP CamelCase, with some Spaces" => "mixed-up-camel-case-with-some-spaces");
- t!(test4: "mixed_up_ snake_case with some _spaces" => "mixed-up-snake-case-with-some-spaces");
- t!(test5: "kebab-case" => "kebab-case");
- t!(test6: "SHOUTY_SNAKE_CASE" => "shouty-snake-case");
- t!(test7: "snake_case" => "snake-case");
- t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "this-contains-all-kinds-of-word-boundaries");
- t!(test9: "XΣXΣ baffle" => "xσxς-baffle");
- t!(test10: "XMLHttpRequest" => "xml-http-request");
-}
diff --git a/heck/src/lib.rs b/heck/src/lib.rs
deleted file mode 100644
index c35ba34..0000000
--- a/heck/src/lib.rs
+++ /dev/null
@@ -1,165 +0,0 @@
-//! **heck** is a case conversion library.
-//!
-//! This library exists to provide case conversion between common cases like
-//! CamelCase and snake_case. It is intended to be unicode aware, internally,
-//! consistent, and reasonably well performing.
-//!
-//! ## Definition of a word boundary
-//!
-//! Word boundaries are defined as the "unicode words" defined in the
-//! `unicode_segmentation` library, as well as within those words in this manner:
-//!
-//! 1. All underscore characters are considered word boundaries.
-//! 2. If an uppercase character is followed by lowercase letters, a word boundary
-//! is considered to be just prior to that uppercase character.
-//! 3. If multiple uppercase characters are consecutive, they are considered to be
-//! within a single word, except that the last will be part of the next word if it
-//! is followed by lowercase characters (see rule 2).
-//!
-//! That is, "HelloWorld" is segmented `Hello|World` whereas "XMLHttpRequest" is
-//! segmented `XML|Http|Request`.
-//!
-//! Characters not within words (such as spaces, punctuations, and underscores)
-//! are not included in the output string except as they are a part of the case
-//! being converted to. Multiple adjacent word boundaries (such as a series of
-//! underscores) are folded into one. ("hello__world" in snake case is therefore
-//! "hello_world", not the exact same string). Leading or trailing word boundary
-//! indicators are dropped, except insofar as CamelCase capitalizes the first word.
-//!
-//! ### Cases contained in this library:
-//!
-//! 1. CamelCase
-//! 2. snake_case
-//! 3. kebab-case
-//! 4. SHOUTY_SNAKE_CASE
-//! 5. mixedCase
-//! 6. Title Case
-#![deny(missing_docs)]
-extern crate unicode_segmentation;
-
-mod camel;
-mod kebab;
-mod mixed;
-mod shouty_snake;
-mod snake;
-mod title;
-
-pub use camel::CamelCase;
-pub use kebab::KebabCase;
-pub use mixed::MixedCase;
-pub use shouty_snake::{ShoutySnakeCase, ShoutySnekCase};
-pub use snake::{SnakeCase, SnekCase};
-pub use title::TitleCase;
-
-use unicode_segmentation::UnicodeSegmentation;
-
-fn transform<F, G>(s: &str, with_word: F, boundary: G) -> String
-where
- F: Fn(&str, &mut String),
- G: Fn(&mut String)
-{
-
- /// Tracks the current 'mode' of the transformation algorithm as it scans the input string.
- ///
- /// The mode is a tri-state which tracks the case of the last cased character of the current
- /// word. If there is no cased character (either lowercase or uppercase) since the previous
- /// word boundary, than the mode is `Boundary`. If the last cased character is lowercase, then
- /// the mode is `Lowercase`. Othertherwise, the mode is `Uppercase`.
- #[derive(Clone, Copy, PartialEq)]
- enum WordMode {
- /// There have been no lowercase or uppercase characters in the current word.
- Boundary,
- /// The previous cased character in the current word is lowercase.
- Lowercase,
- /// The previous cased character in the current word is uppercase.
- Uppercase,
- }
-
- let mut out = String::new();
- let mut first_word = true;
-
- for word in s.unicode_words() {
- let mut char_indices = word.char_indices().peekable();
- let mut init = 0;
- let mut mode = WordMode::Boundary;
-
- while let Some((i, c)) = char_indices.next() {
- // Skip underscore characters
- if c == '_' {
- if init == i { init += 1; }
- continue
- }
-
- if let Some(&(next_i, next)) = char_indices.peek() {
-
- // The mode including the current character, assuming the current character does
- // not result in a word boundary.
- let next_mode = if c.is_lowercase() {
- WordMode::Lowercase
- } else if c.is_uppercase() {
- WordMode::Uppercase
- } else {
- mode
- };
-
- // Word boundary after if next is underscore or current is
- // not uppercase and next is uppercase
- if next == '_' || (next_mode == WordMode::Lowercase && next.is_uppercase()) {
- if !first_word { boundary(&mut out); }
- with_word(&word[init..next_i], &mut out);
- first_word = false;
- init = next_i;
- mode = WordMode::Boundary;
-
- // Otherwise if current and previous are uppercase and next
- // is lowercase, word boundary before
- } else if mode == WordMode::Uppercase && c.is_uppercase() && next.is_lowercase() {
- if !first_word { boundary(&mut out); }
- else { first_word = false; }
- with_word(&word[init..i], &mut out);
- init = i;
- mode = WordMode::Boundary;
-
- // Otherwise no word boundary, just update the mode
- } else {
- mode = next_mode;
- }
- } else {
- // Collect trailing characters as a word
- if !first_word { boundary(&mut out); }
- else { first_word = false; }
- with_word(&word[init..], &mut out);
- break;
- }
- }
- }
-
- out
-}
-
-fn lowercase(s: &str, out: &mut String) {
- let mut chars = s.chars().peekable();
- while let Some(c) = chars.next() {
- if c == 'Σ' && chars.peek().is_none() {
- out.push('ς');
- } else {
- out.extend(c.to_lowercase());
- }
- }
-}
-
-fn uppercase(s: &str, out: &mut String ) {
- for c in s.chars() {
- out.extend(c.to_uppercase())
- }
-}
-
-fn capitalize(s: &str, out: &mut String) {
- let mut char_indices = s.char_indices();
- if let Some((_, c)) = char_indices.next() {
- out.extend(c.to_uppercase());
- if let Some((i, _)) = char_indices.next() {
- lowercase(&s[i..], out);
- }
- }
-}
diff --git a/heck/src/mixed.rs b/heck/src/mixed.rs
deleted file mode 100644
index 7736684..0000000
--- a/heck/src/mixed.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-/// This trait defines a mixed case conversion.
-///
-/// In mixedCase, word boundaries are indicated by capital letters, excepting
-/// the first word.
-///
-/// ## Example:
-///
-/// ```rust
-/// extern crate heck;
-/// fn main() {
-///
-/// use heck::MixedCase;
-///
-/// let sentence = "It is we who built these palaces and cities.";
-/// assert_eq!(sentence.to_mixed_case(), "itIsWeWhoBuiltThesePalacesAndCities");
-/// }
-/// ```
-pub trait MixedCase: ToOwned {
- /// Convert this type to mixed case.
- fn to_mixed_case(&self) -> Self::Owned;
-}
-
-impl MixedCase for str {
- fn to_mixed_case(&self) -> String {
- ::transform(self, |s, out| {
- if out.is_empty() { ::lowercase(s, out); }
- else { ::capitalize(s, out) }
- }, |_| {})
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::MixedCase;
-
- macro_rules! t {
- ($t:ident : $s1:expr => $s2:expr) => {
- #[test]
- fn $t() {
- assert_eq!($s1.to_mixed_case(), $s2)
- }
- }
- }
-
- t!(test1: "CamelCase" => "camelCase");
- t!(test2: "This is Human case." => "thisIsHumanCase");
- t!(test3: "MixedUP CamelCase, with some Spaces" => "mixedUpCamelCaseWithSomeSpaces");
- t!(test4: "mixed_up_ snake_case, with some _spaces" => "mixedUpSnakeCaseWithSomeSpaces");
- t!(test5: "kebab-case" => "kebabCase");
- t!(test6: "SHOUTY_SNAKE_CASE" => "shoutySnakeCase");
- t!(test7: "snake_case" => "snakeCase");
- t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "thisContainsAllKindsOfWordBoundaries");
- t!(test9: "XΣXΣ baffle" => "xσxςBaffle");
- t!(test10: "XMLHttpRequest" => "xmlHttpRequest");
- // TODO unicode tests
-}
diff --git a/heck/src/shouty_snake.rs b/heck/src/shouty_snake.rs
deleted file mode 100644
index 0f846c3..0000000
--- a/heck/src/shouty_snake.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-/// This trait defines a shouty snake case conversion.
-///
-/// In SHOUTY_SNAKE_CASE, word boundaries are indicated by underscores and all
-/// words are in uppercase.
-///
-/// ## Example:
-///
-/// ```rust
-/// extern crate heck;
-/// fn main() {
-///
-/// use heck::ShoutySnakeCase;
-///
-/// let sentence = "That world is growing in this minute.";
-/// assert_eq!(sentence.to_shouty_snake_case(), "THAT_WORLD_IS_GROWING_IN_THIS_MINUTE");
-/// }
-/// ```
-pub trait ShoutySnakeCase: ToOwned {
- /// Convert this type to shouty snake case.
- fn to_shouty_snake_case(&self) -> Self::Owned;
-}
-
-/// Oh heck, ShoutySnekCase is an alias for ShoutySnakeCase. See ShoutySnakeCase for
-/// more documentation.
-pub trait ShoutySnekCase: ToOwned {
- /// CONVERT THIS TYPE TO SNEK CASE.
- #[allow(non_snake_case)]
- fn TO_SHOUTY_SNEK_CASE(&self) -> Self::Owned;
-}
-
-impl<T: ?Sized + ShoutySnakeCase> ShoutySnekCase for T {
- fn TO_SHOUTY_SNEK_CASE(&self) -> Self::Owned {
- self.to_shouty_snake_case()
- }
-}
-
-
-impl ShoutySnakeCase for str {
- fn to_shouty_snake_case(&self) -> Self::Owned {
- ::transform(self, ::uppercase, |s| s.push('_'))
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::ShoutySnakeCase;
-
- macro_rules! t {
- ($t:ident : $s1:expr => $s2:expr) => {
- #[test]
- fn $t() {
- assert_eq!($s1.to_shouty_snake_case(), $s2)
- }
- }
- }
-
- t!(test1: "CamelCase" => "CAMEL_CASE");
- t!(test2: "This is Human case." => "THIS_IS_HUMAN_CASE");
- t!(test3: "MixedUP CamelCase, with some Spaces" => "MIXED_UP_CAMEL_CASE_WITH_SOME_SPACES");
- t!(test4: "mixed_up_snake_case with some _spaces" => "MIXED_UP_SNAKE_CASE_WITH_SOME_SPACES");
- t!(test5: "kebab-case" => "KEBAB_CASE");
- t!(test6: "SHOUTY_SNAKE_CASE" => "SHOUTY_SNAKE_CASE");
- t!(test7: "snake_case" => "SNAKE_CASE");
- t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "THIS_CONTAINS_ALL_KINDS_OF_WORD_BOUNDARIES");
- t!(test9: "XΣXΣ baffle" => "XΣXΣ_BAFFLE");
- t!(test10: "XMLHttpRequest" => "XML_HTTP_REQUEST");
-}
diff --git a/heck/src/snake.rs b/heck/src/snake.rs
deleted file mode 100644
index 86c3756..0000000
--- a/heck/src/snake.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-/// This trait defines a camel case conversion.
-///
-/// In snake_case, word boundaries are indicated by underscores.
-///
-/// ## Example:
-///
-/// ```rust
-/// extern crate heck;
-/// fn main() {
-///
-/// use heck::SnakeCase;
-///
-/// let sentence = "We carry a new world here, in our hearts.";
-/// assert_eq!(sentence.to_snake_case(), "we_carry_a_new_world_here_in_our_hearts");
-/// }
-/// ```
-pub trait SnakeCase: ToOwned {
- /// Convert this type to snake case.
- fn to_snake_case(&self) -> Self::Owned;
-}
-
-/// Oh heck, SnekCase is an alias for SnakeCase. See SnakeCase for
-/// more documentation.
-pub trait SnekCase: ToOwned {
- /// Convert this type to snek case.
- fn to_snek_case(&self) -> Self::Owned;
-}
-
-impl<T: ?Sized + SnakeCase> SnekCase for T {
- fn to_snek_case(&self) -> Self::Owned {
- self.to_snake_case()
- }
-}
-
-impl SnakeCase for str {
- fn to_snake_case(&self) -> String {
- ::transform(self, ::lowercase, |s| s.push('_'))
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::SnakeCase;
-
- macro_rules! t {
- ($t:ident : $s1:expr => $s2:expr) => {
- #[test]
- fn $t() {
- assert_eq!($s1.to_snake_case(), $s2)
- }
- }
- }
-
- t!(test1: "CamelCase" => "camel_case");
- t!(test2: "This is Human case." => "this_is_human_case");
- t!(test3: "MixedUP CamelCase, with some Spaces" => "mixed_up_camel_case_with_some_spaces");
- t!(test4: "mixed_up_ snake_case with some _spaces" => "mixed_up_snake_case_with_some_spaces");
- t!(test5: "kebab-case" => "kebab_case");
- t!(test6: "SHOUTY_SNAKE_CASE" => "shouty_snake_case");
- t!(test7: "snake_case" => "snake_case");
- t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "this_contains_all_kinds_of_word_boundaries");
- t!(test9: "XΣXΣ baffle" => "xσxς_baffle");
- t!(test10: "XMLHttpRequest" => "xml_http_request");
- t!(test11: "FIELD_NAME11" => "field_name11");
- t!(test12: "99BOTTLES" => "99bottles");
- t!(test13: "FieldNamE11" => "field_nam_e11");
-
- t!(test14: "abc123def456" => "abc123def456");
- t!(test16: "abc123DEF456" => "abc123_def456");
- t!(test17: "abc123Def456" => "abc123_def456");
- t!(test18: "abc123DEf456" => "abc123_d_ef456");
- t!(test19: "ABC123def456" => "abc123def456");
- t!(test20: "ABC123DEF456" => "abc123def456");
- t!(test21: "ABC123Def456" => "abc123_def456");
- t!(test22: "ABC123DEf456" => "abc123d_ef456");
- t!(test23: "ABC123dEEf456FOO" => "abc123d_e_ef456_foo");
- t!(test24: "abcDEF" => "abc_def");
- t!(test25: "ABcDE" => "a_bc_de");
-}
diff --git a/heck/src/title.rs b/heck/src/title.rs
deleted file mode 100644
index cb48302..0000000
--- a/heck/src/title.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-/// This trait defines a title case conversion.
-///
-/// In Title Case, word boundaries are indicated by spaces, and every word is
-/// capitalized.
-///
-/// ## Example:
-///
-/// ```rust
-/// extern crate heck;
-/// fn main() {
-///
-/// use heck::TitleCase;
-///
-/// let sentence = "We have always lived in slums and holes in the wall.";
-/// assert_eq!(sentence.to_title_case(), "We Have Always Lived In Slums And Holes In The Wall");
-/// }
-/// ```
-pub trait TitleCase: ToOwned {
- /// Convert this type to title case.
- fn to_title_case(&self) -> Self::Owned;
-}
-
-impl TitleCase for str {
- fn to_title_case(&self) -> String {
- ::transform(self, ::capitalize, |s| s.push(' '))
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::TitleCase;
-
- macro_rules! t {
- ($t:ident : $s1:expr => $s2:expr) => {
- #[test]
- fn $t() {
- assert_eq!($s1.to_title_case(), $s2)
- }
- }
- }
-
- t!(test1: "CamelCase" => "Camel Case");
- t!(test2: "This is Human case." => "This Is Human Case");
- t!(test3: "MixedUP CamelCase, with some Spaces" => "Mixed Up Camel Case With Some Spaces");
- t!(test4: "mixed_up_ snake_case, with some _spaces" => "Mixed Up Snake Case With Some Spaces");
- t!(test5: "kebab-case" => "Kebab Case");
- t!(test6: "SHOUTY_SNAKE_CASE" => "Shouty Snake Case");
- t!(test7: "snake_case" => "Snake Case");
- t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "This Contains All Kinds Of Word Boundaries");
- t!(test9: "XΣXΣ baffle" => "Xσxς Baffle");
- t!(test10: "XMLHttpRequest" => "Xml Http Request");
-}
diff --git a/lazy-static/.gitignore b/lazy-static/.gitignore
deleted file mode 100644
index bde55ce..0000000
--- a/lazy-static/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-target
-doc
-Cargo.lock
-.cargo
diff --git a/lazy-static/.travis.yml b/lazy-static/.travis.yml
deleted file mode 100644
index e4a0da3..0000000
--- a/lazy-static/.travis.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-language: rust
-matrix:
- include:
- - rust: 1.27.2
- - rust: stable
- script:
- - cargo test
- - cargo test --features spin_no_std
- - os: osx
- - rust: beta
- - rust: nightly
- script:
- - cargo test
- - cargo bench
- - cargo test --features spin_no_std
- - cargo bench --features spin_no_std
- - cd compiletest
- - cargo clean
- - cargo test
- - cd ../
-
- - rust: nightly
- before_script:
- - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
- script:
- - cargo doc --no-deps --all-features
- after_success:
- - travis-cargo --only nightly doc-upload
-script:
- - cargo test
-
-env:
- global:
- - secure: YXu24LptjeYirjWYjWGsMT2m3mB7LvQATE6TVo7VEUXv8GYoy2ORIHD83PeImxC93MmZ01QeUezRzuCW51ZcK92VnNSBttlF60SvIX18VsJrV92tsAhievFstqYQ+fB8DIuQ8noU0jPz7GpI+R9dlTRSImAqWOnVIghA+Wzz7Js=
diff --git a/lazy-static/Cargo.toml b/lazy-static/Cargo.toml
deleted file mode 100644
index 9c0a177..0000000
--- a/lazy-static/Cargo.toml
+++ /dev/null
@@ -1,34 +0,0 @@
-[package]
-name = "lazy_static"
-# NB: When modifying, also modify html_root_url in lib.rs
-version = "1.4.0"
-authors = ["Marvin Löbel <loebel.marvin@gmail.com>"]
-license = "MIT/Apache-2.0"
-
-description = "A macro for declaring lazily evaluated statics in Rust."
-readme = "README.md"
-documentation = "https://docs.rs/lazy_static"
-
-repository = "https://github.com/rust-lang-nursery/lazy-static.rs"
-keywords = ["macro", "lazy", "static"]
-categories = [ "no-std", "rust-patterns", "memory-management" ]
-exclude = ["/.travis.yml", "/appveyor.yml"]
-
-[dependencies.spin]
-version = "0.5.0"
-optional = true
-
-[features]
-spin_no_std = ["spin"]
-
-[dev-dependencies]
-doc-comment = "0.3.1"
-
-[badges]
-appveyor = { repository = "rust-lang-nursery/lazy-static.rs" }
-travis-ci = { repository = "rust-lang-nursery/lazy-static.rs" }
-
-is-it-maintained-issue-resolution = { repository = "rust-lang-nursery/lazy-static.rs" }
-is-it-maintained-open-issues = { repository = "rust-lang-nursery/lazy-static.rs" }
-
-maintenance = { status = "passively-maintained" }
diff --git a/lazy-static/LICENSE-APACHE b/lazy-static/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/lazy-static/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/lazy-static/LICENSE-MIT b/lazy-static/LICENSE-MIT
deleted file mode 100644
index 25597d5..0000000
--- a/lazy-static/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2010 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/lazy-static/README.md b/lazy-static/README.md
deleted file mode 100644
index aa9f828..0000000
--- a/lazy-static/README.md
+++ /dev/null
@@ -1,79 +0,0 @@
-lazy-static.rs
-==============
-
-A macro for declaring lazily evaluated statics in Rust.
-
-Using this macro, it is possible to have `static`s that require code to be
-executed at runtime in order to be initialized.
-This includes anything requiring heap allocations, like vectors or hash maps,
-as well as anything that requires non-const function calls to be computed.
-
-[![Travis-CI Status](https://travis-ci.com/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/lazy-static.rs)
-[![Latest version](https://img.shields.io/crates/v/lazy_static.svg)](https://crates.io/crates/lazy_static)
-[![Documentation](https://docs.rs/lazy_static/badge.svg)](https://docs.rs/lazy_static)
-[![License](https://img.shields.io/crates/l/lazy_static.svg)](https://github.com/rust-lang-nursery/lazy-static.rs#license)
-
-## Minimum supported `rustc`
-
-`1.27.2+`
-
-This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes.
-
-
-# Getting Started
-
-[lazy-static.rs is available on crates.io](https://crates.io/crates/lazy_static).
-It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
-
-At the point of the last update of this README, the latest published version could be used like this:
-
-Add the following dependency to your Cargo manifest...
-
-```toml
-[dependencies]
-lazy_static = "1.4.0"
-```
-
-...and see the [docs](https://docs.rs/lazy_static) for how to use it.
-
-# Example
-
-```rust
-#[macro_use]
-extern crate lazy_static;
-
-use std::collections::HashMap;
-
-lazy_static! {
- static ref HASHMAP: HashMap<u32, &'static str> = {
- let mut m = HashMap::new();
- m.insert(0, "foo");
- m.insert(1, "bar");
- m.insert(2, "baz");
- m
- };
-}
-
-fn main() {
- // First access to `HASHMAP` initializes it
- println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap());
-
- // Any further access to `HASHMAP` just returns the computed value
- println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap());
-}
-```
-
-## 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/lazy-static/appveyor.yml b/lazy-static/appveyor.yml
deleted file mode 100644
index b138452..0000000
--- a/lazy-static/appveyor.yml
+++ /dev/null
@@ -1,61 +0,0 @@
-environment:
- global:
- PROJECT_NAME: lazy_static
- # When this was added there were revocation check failures when using the
- # libcurl backend as libcurl checks by default, but rustup doesn't provide the
- # switch to turn this off. Switch to Hyper which looks to not check for
- # revocation by default like libcurl does.
- RUSTUP_USE_REQWEST: 1
- CARGO_HTTP_CHECK_REVOKE: false
- matrix:
- # Stable channel
- - TARGET: i686-pc-windows-gnu
- CHANNEL: stable
- - TARGET: i686-pc-windows-msvc
- CHANNEL: stable
- - TARGET: x86_64-pc-windows-gnu
- CHANNEL: stable
- - TARGET: x86_64-pc-windows-msvc
- CHANNEL: stable
- # Beta channel
- - TARGET: i686-pc-windows-gnu
- CHANNEL: beta
- - TARGET: i686-pc-windows-msvc
- CHANNEL: beta
- - TARGET: x86_64-pc-windows-gnu
- CHANNEL: beta
- - TARGET: x86_64-pc-windows-msvc
- CHANNEL: beta
- # Nightly channel
- - TARGET: i686-pc-windows-gnu
- CHANNEL: nightly
- - TARGET: i686-pc-windows-msvc
- CHANNEL: nightly
- - TARGET: x86_64-pc-windows-gnu
- CHANNEL: nightly
- - TARGET: x86_64-pc-windows-msvc
- CHANNEL: nightly
-
-# Install Rust and Cargo
-# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
-install:
- - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- - rustup-init.exe -y --default-toolchain %CHANNEL% --default-host %TARGET%
- - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- - if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin
- - if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin
- - rustc -V
- - cargo -V
-
-build: false
-
-test_script:
- - cargo build --verbose
- - cargo test
- - if [%CHANNEL%]==[nightly] (
- cd compiletest &&
- cargo clean &&
- cargo build --verbose &&
- cargo test &&
- cd ../
- )
diff --git a/lazy-static/compiletest/Cargo.toml b/lazy-static/compiletest/Cargo.toml
deleted file mode 100644
index e25d5a7..0000000
--- a/lazy-static/compiletest/Cargo.toml
+++ /dev/null
@@ -1,11 +0,0 @@
-[package]
-name = "lazy_static_compiletest"
-version = "0.0.1"
-publish = false
-authors = ["lazy_static contributors"]
-
-[dependencies.lazy_static]
-path = "../"
-
-[dependencies.compiletest_rs]
-version = "0.3"
diff --git a/lazy-static/compiletest/src/lib.rs b/lazy-static/compiletest/src/lib.rs
deleted file mode 100644
index 0452765..0000000
--- a/lazy-static/compiletest/src/lib.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-This library is a shim around `lazy_static` that disambiguates it with the `lazy_static`
-that's shipped with the Rust toolchain. We re-export the entire public API of `lazy_static`
-under a different crate name so that can be imported in the compile tests.
-
-This currently appears to use the right local build of `lazy_static`.
-*/
-
-extern crate lazy_static;
-
-pub use self::lazy_static::*;
diff --git a/lazy-static/compiletest/tests/compile-fail/README.md b/lazy-static/compiletest/tests/compile-fail/README.md
deleted file mode 100644
index 58dbc3b..0000000
--- a/lazy-static/compiletest/tests/compile-fail/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-This directory contains snippets of code that should yield a
-warning/note/help/error at compilation. Syntax of annotations is described in
-[rust documentation](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md).
-For more information check out [`compiletest` crate](https://github.com/laumann/compiletest-rs).
-
-To run compile tests issue `cargo +nightly --test`.
-
-## Notes on working with `compiletest` crate
-
-* Currently code that is inside macro should not be annotated, as `compiletest`
- crate cannot deal with the fact that macro invocations effectively changes
- line numbering. To prevent this add a `// error-pattern:<your error message here>`
- on the top of the file and make sure that you set `deny` lint level
- if you want to test compiler message different than error.
-* `compiletest` crate by default sets `allow(dead_code)` lint level so make sure
- that you change it to something suiting your needs even if the warning is
- issued prior to any macro invocation.
-* If you get a message `error: 0 unexpected errors found, 1 expected errors not found`
- despite the fact that some error was bound to occur don't worry - it's a known
- issue in the `compiletest` crate and your error was probably not registered -
- make sure that your annotations are correct and that you are setting correct
- lint levels.
diff --git a/lazy-static/compiletest/tests/compile-fail/incorrect_visibility_restriction.rs b/lazy-static/compiletest/tests/compile-fail/incorrect_visibility_restriction.rs
deleted file mode 100644
index 360e23d..0000000
--- a/lazy-static/compiletest/tests/compile-fail/incorrect_visibility_restriction.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// incorrect visibility restriction
-#[macro_use]
-extern crate lazy_static_compiletest as lazy_static;
-
-lazy_static! {
- pub(nonsense) static ref WRONG: () = ();
- //~^ ERROR incorrect visibility restriction
-}
-
-fn main() { }
diff --git a/lazy-static/compiletest/tests/compile-fail/static_is_private.rs b/lazy-static/compiletest/tests/compile-fail/static_is_private.rs
deleted file mode 100644
index 6ebc8f5..0000000
--- a/lazy-static/compiletest/tests/compile-fail/static_is_private.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-#[macro_use]
-extern crate lazy_static_compiletest as lazy_static;
-
-mod outer {
- pub mod inner {
- lazy_static! {
- pub(in outer) static ref FOO: () = ();
- }
- }
-}
-
-fn main() {
- assert_eq!(*outer::inner::FOO, ()); //~ ERROR static `FOO` is private
-}
diff --git a/lazy-static/compiletest/tests/compile-fail/static_is_sized.rs b/lazy-static/compiletest/tests/compile-fail/static_is_sized.rs
deleted file mode 100644
index ac1cad4..0000000
--- a/lazy-static/compiletest/tests/compile-fail/static_is_sized.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// error-pattern:the size for values of type `str` cannot be known at compilation time
-#[macro_use]
-extern crate lazy_static_compiletest as lazy_static;
-
-lazy_static! {
- pub static ref FOO: str = panic!();
-}
-
-
-fn main() {
-}
diff --git a/lazy-static/compiletest/tests/compile_tests.rs b/lazy-static/compiletest/tests/compile_tests.rs
deleted file mode 100644
index d908077..0000000
--- a/lazy-static/compiletest/tests/compile_tests.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-extern crate compiletest_rs as compiletest;
-
-fn run_mode(mode: &'static str) {
- let mut config = compiletest::Config::default();
- config.mode = mode.parse().expect("Invalid mode");
- config.src_base = ["tests", mode].iter().collect();
-
- config.verbose = true;
-
- config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned());
- config.clean_rmeta();
-
- compiletest::run_tests(&config);
-}
-
-#[test]
-fn compile_test() {
- run_mode("compile-fail");
-}
diff --git a/lazy-static/src/core_lazy.rs b/lazy-static/src/core_lazy.rs
deleted file mode 100644
index b66c3e0..0000000
--- a/lazy-static/src/core_lazy.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2016 lazy-static.rs Developers
-//
-// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
-// http://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.
-
-extern crate spin;
-
-use self::spin::Once;
-
-pub struct Lazy<T: Sync>(Once<T>);
-
-impl<T: Sync> Lazy<T> {
- pub const INIT: Self = Lazy(Once::INIT);
-
- #[inline(always)]
- pub fn get<F>(&'static self, builder: F) -> &T
- where F: FnOnce() -> T
- {
- self.0.call_once(builder)
- }
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! __lazy_static_create {
- ($NAME:ident, $T:ty) => {
- static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT;
- }
-}
diff --git a/lazy-static/src/inline_lazy.rs b/lazy-static/src/inline_lazy.rs
deleted file mode 100644
index 219ce9c..0000000
--- a/lazy-static/src/inline_lazy.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2016 lazy-static.rs Developers
-//
-// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
-// http://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.
-
-extern crate core;
-extern crate std;
-
-use self::std::prelude::v1::*;
-use self::std::cell::Cell;
-use self::std::hint::unreachable_unchecked;
-use self::std::sync::Once;
-#[allow(deprecated)]
-pub use self::std::sync::ONCE_INIT;
-
-// FIXME: Replace Option<T> with MaybeUninit<T> (stable since 1.36.0)
-pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
-
-impl<T: Sync> Lazy<T> {
- #[allow(deprecated)]
- pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT);
-
- #[inline(always)]
- pub fn get<F>(&'static self, f: F) -> &T
- where
- F: FnOnce() -> T,
- {
- self.1.call_once(|| {
- self.0.set(Some(f()));
- });
-
- // `self.0` is guaranteed to be `Some` by this point
- // The `Once` will catch and propagate panics
- unsafe {
- match *self.0.as_ptr() {
- Some(ref x) => x,
- None => {
- debug_assert!(false, "attempted to derefence an uninitialized lazy static. This is a bug");
-
- unreachable_unchecked()
- },
- }
- }
- }
-}
-
-unsafe impl<T: Sync> Sync for Lazy<T> {}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! __lazy_static_create {
- ($NAME:ident, $T:ty) => {
- static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT;
- };
-}
diff --git a/lazy-static/src/lib.rs b/lazy-static/src/lib.rs
deleted file mode 100644
index cada0dc..0000000
--- a/lazy-static/src/lib.rs
+++ /dev/null
@@ -1,215 +0,0 @@
-// Copyright 2016 lazy-static.rs Developers
-//
-// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
-// http://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 macro for declaring lazily evaluated statics.
-
-Using this macro, it is possible to have `static`s that require code to be
-executed at runtime in order to be initialized.
-This includes anything requiring heap allocations, like vectors or hash maps,
-as well as anything that requires function calls to be computed.
-
-# Syntax
-
-```ignore
-lazy_static! {
- [pub] static ref NAME_1: TYPE_1 = EXPR_1;
- [pub] static ref NAME_2: TYPE_2 = EXPR_2;
- ...
- [pub] static ref NAME_N: TYPE_N = EXPR_N;
-}
-```
-
-Attributes (including doc comments) are supported as well:
-
-```rust
-# #[macro_use]
-# extern crate lazy_static;
-# fn main() {
-lazy_static! {
- /// This is an example for using doc comment attributes
- static ref EXAMPLE: u8 = 42;
-}
-# }
-```
-
-# Semantics
-
-For a given `static ref NAME: TYPE = EXPR;`, the macro generates a unique type that
-implements `Deref<TYPE>` and stores it in a static with name `NAME`. (Attributes end up
-attaching to this type.)
-
-On first deref, `EXPR` gets evaluated and stored internally, such that all further derefs
-can return a reference to the same object. Note that this can lead to deadlocks
-if you have multiple lazy statics that depend on each other in their initialization.
-
-Apart from the lazy initialization, the resulting "static ref" variables
-have generally the same properties as regular "static" variables:
-
-- Any type in them needs to fulfill the `Sync` trait.
-- If the type has a destructor, then it will not run when the process exits.
-
-# Example
-
-Using the macro:
-
-```rust
-#[macro_use]
-extern crate lazy_static;
-
-use std::collections::HashMap;
-
-lazy_static! {
- static ref HASHMAP: HashMap<u32, &'static str> = {
- let mut m = HashMap::new();
- m.insert(0, "foo");
- m.insert(1, "bar");
- m.insert(2, "baz");
- m
- };
- static ref COUNT: usize = HASHMAP.len();
- static ref NUMBER: u32 = times_two(21);
-}
-
-fn times_two(n: u32) -> u32 { n * 2 }
-
-fn main() {
- println!("The map has {} entries.", *COUNT);
- println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap());
- println!("A expensive calculation on a static results in: {}.", *NUMBER);
-}
-```
-
-# Implementation details
-
-The `Deref` implementation uses a hidden static variable that is guarded by an atomic check on each access.
-
-# Cargo features
-
-This crate provides one cargo feature:
-
-- `spin_no_std`: This allows using this crate in a no-std environment, by depending on the standalone `spin` crate.
-
-*/
-
-#![doc(html_root_url = "https://docs.rs/lazy_static/1.4.0")]
-#![no_std]
-
-#[cfg(not(feature = "spin_no_std"))]
-#[path="inline_lazy.rs"]
-#[doc(hidden)]
-pub mod lazy;
-
-#[cfg(test)]
-#[macro_use]
-extern crate doc_comment;
-
-#[cfg(test)]
-doctest!("../README.md");
-
-#[cfg(feature = "spin_no_std")]
-#[path="core_lazy.rs"]
-#[doc(hidden)]
-pub mod lazy;
-
-#[doc(hidden)]
-pub use core::ops::Deref as __Deref;
-
-#[macro_export(local_inner_macros)]
-#[doc(hidden)]
-macro_rules! __lazy_static_internal {
- // optional visibility restrictions are wrapped in `()` to allow for
- // explicitly passing otherwise implicit information about private items
- ($(#[$attr:meta])* ($($vis:tt)*) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
- __lazy_static_internal!(@MAKE TY, $(#[$attr])*, ($($vis)*), $N);
- __lazy_static_internal!(@TAIL, $N : $T = $e);
- lazy_static!($($t)*);
- };
- (@TAIL, $N:ident : $T:ty = $e:expr) => {
- impl $crate::__Deref for $N {
- type Target = $T;
- fn deref(&self) -> &$T {
- #[inline(always)]
- fn __static_ref_initialize() -> $T { $e }
-
- #[inline(always)]
- fn __stability() -> &'static $T {
- __lazy_static_create!(LAZY, $T);
- LAZY.get(__static_ref_initialize)
- }
- __stability()
- }
- }
- impl $crate::LazyStatic for $N {
- fn initialize(lazy: &Self) {
- let _ = &**lazy;
- }
- }
- };
- // `vis` is wrapped in `()` to prevent parsing ambiguity
- (@MAKE TY, $(#[$attr:meta])*, ($($vis:tt)*), $N:ident) => {
- #[allow(missing_copy_implementations)]
- #[allow(non_camel_case_types)]
- #[allow(dead_code)]
- $(#[$attr])*
- $($vis)* struct $N {__private_field: ()}
- #[doc(hidden)]
- $($vis)* static $N: $N = $N {__private_field: ()};
- };
- () => ()
-}
-
-#[macro_export(local_inner_macros)]
-macro_rules! lazy_static {
- ($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
- // use `()` to explicitly forward the information about private items
- __lazy_static_internal!($(#[$attr])* () static ref $N : $T = $e; $($t)*);
- };
- ($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
- __lazy_static_internal!($(#[$attr])* (pub) static ref $N : $T = $e; $($t)*);
- };
- ($(#[$attr:meta])* pub ($($vis:tt)+) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
- __lazy_static_internal!($(#[$attr])* (pub ($($vis)+)) static ref $N : $T = $e; $($t)*);
- };
- () => ()
-}
-
-/// Support trait for enabling a few common operation on lazy static values.
-///
-/// This is implemented by each defined lazy static, and
-/// used by the free functions in this crate.
-pub trait LazyStatic {
- #[doc(hidden)]
- fn initialize(lazy: &Self);
-}
-
-/// Takes a shared reference to a lazy static and initializes
-/// it if it has not been already.
-///
-/// This can be used to control the initialization point of a lazy static.
-///
-/// Example:
-///
-/// ```rust
-/// #[macro_use]
-/// extern crate lazy_static;
-///
-/// lazy_static! {
-/// static ref BUFFER: Vec<u8> = (0..255).collect();
-/// }
-///
-/// fn main() {
-/// lazy_static::initialize(&BUFFER);
-///
-/// // ...
-/// work_with_initialized_data(&BUFFER);
-/// }
-/// # fn work_with_initialized_data(_: &[u8]) {}
-/// ```
-pub fn initialize<T: LazyStatic>(lazy: &T) {
- LazyStatic::initialize(lazy);
-}
diff --git a/lazy-static/tests/no_std.rs b/lazy-static/tests/no_std.rs
deleted file mode 100644
index f94a1aa..0000000
--- a/lazy-static/tests/no_std.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-#![cfg(feature="spin_no_std")]
-
-#![no_std]
-
-#[macro_use]
-extern crate lazy_static;
-
-lazy_static! {
- /// Documentation!
- pub static ref NUMBER: u32 = times_two(3);
-}
-
-fn times_two(n: u32) -> u32 {
- n * 2
-}
-
-#[test]
-fn test_basic() {
- assert_eq!(*NUMBER, 6);
-}
diff --git a/lazy-static/tests/test.rs b/lazy-static/tests/test.rs
deleted file mode 100644
index 03d0ab6..0000000
--- a/lazy-static/tests/test.rs
+++ /dev/null
@@ -1,164 +0,0 @@
-#[macro_use]
-extern crate lazy_static;
-use std::collections::HashMap;
-
-lazy_static! {
- /// Documentation!
- pub static ref NUMBER: u32 = times_two(3);
-
- static ref ARRAY_BOXES: [Box<u32>; 3] = [Box::new(1), Box::new(2), Box::new(3)];
-
- /// More documentation!
- #[allow(unused_variables)]
- #[derive(Copy, Clone, Debug)]
- pub static ref STRING: String = "hello".to_string();
-
- static ref HASHMAP: HashMap<u32, &'static str> = {
- let mut m = HashMap::new();
- m.insert(0, "abc");
- m.insert(1, "def");
- m.insert(2, "ghi");
- m
- };
-
- // This should not compile if the unsafe is removed.
- static ref UNSAFE: u32 = unsafe {
- std::mem::transmute::<i32, u32>(-1)
- };
-}
-
-lazy_static! {
- static ref S1: &'static str = "a";
- static ref S2: &'static str = "b";
-}
-lazy_static! {
- static ref S3: String = [*S1, *S2].join("");
-}
-
-#[test]
-fn s3() {
- assert_eq!(&*S3, "ab");
-}
-
-fn times_two(n: u32) -> u32 {
- n * 2
-}
-
-#[test]
-fn test_basic() {
- assert_eq!(&**STRING, "hello");
- assert_eq!(*NUMBER, 6);
- assert!(HASHMAP.get(&1).is_some());
- assert!(HASHMAP.get(&3).is_none());
- assert_eq!(&*ARRAY_BOXES, &[Box::new(1), Box::new(2), Box::new(3)]);
- assert_eq!(*UNSAFE, std::u32::MAX);
-}
-
-#[test]
-fn test_repeat() {
- assert_eq!(*NUMBER, 6);
- assert_eq!(*NUMBER, 6);
- assert_eq!(*NUMBER, 6);
-}
-
-#[test]
-fn test_meta() {
- // this would not compile if STRING were not marked #[derive(Copy, Clone)]
- let copy_of_string = STRING;
- // just to make sure it was copied
- assert!(&STRING as *const _ != &copy_of_string as *const _);
-
- // this would not compile if STRING were not marked #[derive(Debug)]
- assert_eq!(format!("{:?}", STRING), "STRING { __private_field: () }".to_string());
-}
-
-mod visibility {
- lazy_static! {
- pub static ref FOO: Box<u32> = Box::new(0);
- static ref BAR: Box<u32> = Box::new(98);
- }
-
- pub mod inner {
- lazy_static! {
- pub(in visibility) static ref BAZ: Box<u32> = Box::new(42);
- pub(crate) static ref BAG: Box<u32> = Box::new(37);
- }
- }
-
- #[test]
- fn sub_test() {
- assert_eq!(**FOO, 0);
- assert_eq!(**BAR, 98);
- assert_eq!(**inner::BAZ, 42);
- assert_eq!(**inner::BAG, 37);
- }
-}
-
-#[test]
-fn test_visibility() {
- assert_eq!(*visibility::FOO, Box::new(0));
- assert_eq!(*visibility::inner::BAG, Box::new(37));
-}
-
-// This should not cause a warning about a missing Copy implementation
-lazy_static! {
- pub static ref VAR: i32 = { 0 };
-}
-
-#[derive(Copy, Clone, Debug, PartialEq)]
-struct X;
-struct Once(X);
-const ONCE_INIT: Once = Once(X);
-static DATA: X = X;
-static ONCE: X = X;
-fn require_sync() -> X { X }
-fn transmute() -> X { X }
-fn __static_ref_initialize() -> X { X }
-fn test(_: Vec<X>) -> X { X }
-
-// All these names should not be shadowed
-lazy_static! {
- static ref ITEM_NAME_TEST: X = {
- test(vec![X, Once(X).0, ONCE_INIT.0, DATA, ONCE,
- require_sync(), transmute(),
- // Except this, which will sadly be shadowed by internals:
- // __static_ref_initialize()
- ])
- };
-}
-
-#[test]
-fn item_name_shadowing() {
- assert_eq!(*ITEM_NAME_TEST, X);
-}
-
-use std::sync::atomic::AtomicBool;
-#[allow(deprecated)]
-use std::sync::atomic::ATOMIC_BOOL_INIT;
-use std::sync::atomic::Ordering::SeqCst;
-
-#[allow(deprecated)]
-static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT;
-
-lazy_static! {
- static ref PRE_INIT: () = {
- PRE_INIT_FLAG.store(true, SeqCst);
- ()
- };
-}
-
-#[test]
-fn pre_init() {
- assert_eq!(PRE_INIT_FLAG.load(SeqCst), false);
- lazy_static::initialize(&PRE_INIT);
- assert_eq!(PRE_INIT_FLAG.load(SeqCst), true);
-}
-
-lazy_static! {
- static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f };
-}
-
-#[test]
-fn lifetime_name() {
- let _ = LIFETIME_NAME;
-}
diff --git a/libc/.cirrus.yml b/libc/.cirrus.yml
deleted file mode 100644
index 2883043..0000000
--- a/libc/.cirrus.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-task:
- name: nightly x86_64-unknown-freebsd-10
- freebsd_instance:
- image: freebsd-10-4-release-amd64
- setup_script:
- - pkg install -y curl
- - curl https://sh.rustup.rs -sSf --output rustup.sh
- - sh rustup.sh --default-toolchain nightly -y --profile=minimal
- - . $HOME/.cargo/env
- - rustup default nightly
- test_script:
- - . $HOME/.cargo/env
- - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
-
-task:
- name: stable x86_64-unknown-freebsd-11
- freebsd_instance:
- image: freebsd-11-3-stable-amd64-v20190801
- setup_script:
- - pkg install -y curl
- - curl https://sh.rustup.rs -sSf --output rustup.sh
- - sh rustup.sh -y --profile=minimal
- - . $HOME/.cargo/env
- - rustup default stable
- test_script:
- - . $HOME/.cargo/env
- - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
- - 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 --profile=minimal
- - . $HOME/.cargo/env
- - rustup default nightly
- test_script:
- - . $HOME/.cargo/env
- - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
- - 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/CONTRIBUTING.md b/libc/CONTRIBUTING.md
deleted file mode 100644
index 052777f..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/linux_like/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 [Azure Pipelines](https://dev.azure.com/rust-lang2/libc/_build?definitionId=1&_a=summary):
-
-1. [`libc-test`](https://github.com/gnzlbg/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 c701f41..0000000
--- a/libc/Cargo.toml
+++ /dev/null
@@ -1,36 +0,0 @@
-[package]
-name = "libc"
-version = "0.2.66"
-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/*", "/azure-pipelines.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 = []
-const-extern-fn = []
-# 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 8a36881..0000000
--- a/libc/README.md
+++ /dev/null
@@ -1,106 +0,0 @@
-[![Azure Status]][Azure] [![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`.
-
-* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s.
- This features requires a nightly rustc
-
-* **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/ci/build.sh)
-for the platforms on which `libc` is guaranteed to build for each Rust
-toolchain. The test-matrix at [Azure] 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](https://www.apache.org/licenses/LICENSE-2.0)
- ([LICENSE-APACHE](LICENSE-APACHE))
-
-* [MIT License](https://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/policies/code-of-conduct
-
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be
-dual licensed as above, without any additional terms or conditions.
-
-[Azure Status]: https://dev.azure.com/rust-lang2/libc/_apis/build/status/rust-lang.libc?branchName=master
-[Azure]: https://dev.azure.com/rust-lang2/libc/_build/latest?definitionId=1&branchName=master
-[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/build.rs b/libc/build.rs
deleted file mode 100644
index f447c0e..0000000
--- a/libc/build.rs
+++ /dev/null
@@ -1,144 +0,0 @@
-use std::env;
-use std::process::Command;
-use std::str;
-
-fn main() {
- let (rustc_minor_ver, is_nightly) =
- rustc_minor_nightly().expect("Failed to get rustc version");
- let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
- let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
- let const_extern_fn_cargo_feature =
- env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
- let libc_ci = env::var("LIBC_CI").is_ok();
-
- if 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\""
- );
- }
-
- // The ABI of libc used by libstd is backward compatible with FreeBSD 10.
- // The ABI of libc from crates.io is backward compatible with FreeBSD 11.
- //
- // On CI, we detect the actual FreeBSD version and match its ABI exactly,
- // running tests to ensure that the ABI is correct.
- match which_freebsd() {
- Some(10) if libc_ci || rustc_dep_of_std => {
- println!("cargo:rustc-cfg=freebsd10")
- }
- Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
- Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
- Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
- Some(_) | None => println!("cargo:rustc-cfg=freebsd11"),
- }
-
- // On CI: deny all warnings
- if libc_ci {
- println!("cargo:rustc-cfg=libc_deny_warnings");
- }
-
- // 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");
- }
-
- // #[thread_local] is currently unstable
- if rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_thread_local");
- }
-
- if const_extern_fn_cargo_feature {
- if !is_nightly || rustc_minor_ver < 40 {
- panic!("const-extern-fn requires a nightly compiler >= 1.40")
- }
- println!("cargo:rustc-cfg=libc_const_extern_fn");
- }
-}
-
-fn rustc_minor_nightly() -> Option<(u32, bool)> {
- 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;
- }
-
- let minor = pieces.next();
-
- // If `rustc` was built from a tarball, its version string
- // will have neither a git hash nor a commit date
- // (e.g. "rustc 1.39.0"). Treat this case as non-nightly,
- // since a nightly build should either come from CI
- // or a git checkout
- let nightly_raw = otry!(pieces.next()).split('-').nth(1);
- let nightly = nightly_raw
- .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly"))
- .unwrap_or(false);
- let minor = otry!(otry!(minor).parse().ok());
-
- Some((minor, nightly))
-}
-
-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("10") => Some(10),
- s if s.starts_with("11") => Some(11),
- s if s.starts_with("12") => Some(12),
- s if s.starts_with("13") => Some(13),
- _ => None,
- }
-}
diff --git a/libc/ci/README.md b/libc/ci/README.md
deleted file mode 100644
index 3123553..0000000
--- a/libc/ci/README.md
+++ /dev/null
@@ -1,236 +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-docker.sh` - a shell script run by most builders, it will execute
- `run.sh` inside a Docker container configured for the target.
-
-* `run.sh` - the actual script which runs tests for a particular architecture.
-
-* `dox.sh` - build the documentation of the crate and publish it to gh-pages.
-
-* `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/azure-install-rust.yml b/libc/ci/azure-install-rust.yml
deleted file mode 100644
index 31b0714..0000000
--- a/libc/ci/azure-install-rust.yml
+++ /dev/null
@@ -1,82 +0,0 @@
-steps:
- - bash: |
- set -ex
- toolchain=$TOOLCHAIN
- if [ "$toolchain" = "" ]; then
- toolchain=nightly
- fi
- if command -v rustup; then
- # Uncomment when rustup on Azure is updated
- #rustup set profile minimal
- rustup update --force $toolchain
- rustup default $toolchain
- else
- curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain --profile=minimal
- echo "##vso[task.prependpath]$HOME/.cargo/bin"
- fi
- displayName: Install rust (unix)
- condition: ne( variables['Agent.OS'], 'Windows_NT' )
- - script: |
- @echo on
- if not defined TOOLCHAIN set TOOLCHAIN=nightly
- :: Uncomment when rustup on Azure is updated
- ::rustup set profile minimal
- rustup update --no-self-update %TOOLCHAIN%-%TARGET%
- rustup default %TOOLCHAIN%-%TARGET%
- displayName: Install rust (windows)
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- - script: |
- set -ex
- if [ -n "${TARGET}" ]; then
- rustup target add $TARGET
- fi
- condition: ne( variables['Agent.OS'], 'Windows_NT' )
- displayName: Install target (unix)
- - script: |
- @echo on
- if defined TARGET rustup target add %TARGET%
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- displayName: Install target (windows)
- - script: |
- @echo on
- if "%ARCH%" == "i686" choco install mingw --x86 --force
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- displayName: Install MinGW32 (windows)
- - bash: |
- set -ex
- gcc -print-search-dirs
- find "C:\ProgramData\Chocolatey" -name "crt2*"
- find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
- find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- displayName: Find GCC libraries (windows)
- - bash: |
- set -ex
- if [[ -n ${ARCH_BITS} ]]; then
- for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
- cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw${ARCH_BITS}/${ARCH}-w64-mingw32/lib/$i" "`rustc --print sysroot`/lib/rustlib/${TARGET}/lib"
- done
- fi
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- displayName: Fix MinGW (windows)
- - bash: |
- set -ex
- rustc -Vv
- cargo -V
- rustup -Vv
- rustup show
- which rustc
- which cargo
- which rustup
- displayName: Query rust and cargo versions
- - script: |
- @echo on
- where gcc
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- displayName: Query gcc path
- - bash: |
- set -ex
- cargo generate-lockfile
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
- displayName: Generate lockfiles
-
diff --git a/libc/ci/azure-master.yml b/libc/ci/azure-master.yml
deleted file mode 100644
index d7bcb7c..0000000
--- a/libc/ci/azure-master.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-variables:
- - group: secrets
-resources:
- repositories:
- - repository: rustinfra
- type: github
- name: rust-lang/simpleinfra
- endpoint: gnzlbg
-trigger: ["master"]
-pr: ["master"]
-
-jobs:
- - job: StyleAndDocs
- pool:
- vmImage: ubuntu-16.04
- steps:
- - template: azure-install-rust.yml
- - script: LIBC_CI=1 sh ci/dox.sh
- displayName: Generate documentation
- - template: azure-configs/static-websites.yml@rustinfra
- parameters:
- deploy_dir: target/doc
diff --git a/libc/ci/azure.yml b/libc/ci/azure.yml
deleted file mode 100644
index da25a26..0000000
--- a/libc/ci/azure.yml
+++ /dev/null
@@ -1,228 +0,0 @@
-variables:
- - group: secrets
-resources:
- repositories:
- - repository: rustinfra
- type: github
- name: rust-lang/simpleinfra
- endpoint: gnzlbg
-trigger: ["auto-libc","try"]
-pr: ["master"]
-
-jobs:
- - job: DockerLinuxTier1
- pool:
- vmImage: ubuntu-16.04
- steps:
- - template: azure-install-rust.yml
- - bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET
- displayName: Execute run-docker.sh
- strategy:
- matrix:
- i686-unknown-linux-gnu:
- TARGET: i686-unknown-linux-gnu
- x86_64-unknown-linux-gnu:
- TARGET: x86_64-unknown-linux-gnu
-
- - job: DockerLinuxTier2
- #dependsOn: DockerLinuxTier1
- pool:
- vmImage: ubuntu-16.04
- steps:
- - template: azure-install-rust.yml
- - bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET
- displayName: Execute run-docker.sh
- strategy:
- matrix:
- aarch64-unknown-linux-android:
- TARGET: aarch64-linux-android
- aarch64-unknown-linux-gnu:
- TARGET: aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl:
- TARGET: aarch64-unknown-linux-musl
- arm-linux-androideabi:
- TARGET: arm-linux-androideabi
- arm-unknown-linux-gnueabihf:
- TARGET: arm-unknown-linux-gnueabihf
- arm-unknown-linux-musleabihf:
- TARGET: arm-unknown-linux-musleabihf
- # Disabled because currently broken, see:
- # https://github.com/rust-lang/libc/issues/1591
- # asmjs-unknown-emscripten:
- # TARGET: asmjs-unknown-emscripten
- i686-linux-android:
- TARGET: i686-linux-android
- i686-unknown-linux-musl:
- TARGET: i686-unknown-linux-musl
- mips-unknown-linux-gnu:
- TARGET: mips-unknown-linux-gnu
- mips-unknown-linux-musl:
- TARGET: mips-unknown-linux-musl
- mips64-unknown-linux-gnuabi64:
- TARGET: mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64:
- TARGET: mips64el-unknown-linux-gnuabi64
- mipsel-unknown-linux-musl:
- TARGET: mipsel-unknown-linux-musl
- #powerpc-unknown-linux-gnu:
- # TARGET: powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu:
- TARGET: powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu:
- TARGET: powerpc64le-unknown-linux-gnu
- #s390x-unknown-linux-gnu:
- # TARGET: s390x-unknown-linux-gnu
- #wasm32-wasi
- # TARGET: wasm32-wasi
- sparc64-unknown-linux-gnu:
- TARGET: sparc64-unknown-linux-gnu
- # Disabled because currently broken, see:
- # https://github.com/rust-lang/libc/issues/1591
- # wasm32-unknown-emscripten:
- # TARGET: wasm32-unknown-emscripten
- x86_64-linux-android:
- TARGET: x86_64-linux-android
- x86_64-unknown-linux-gnux32:
- TARGET: x86_64-unknown-linux-gnux32
- x86_64-unknown-linux-musl:
- TARGET: x86_64-unknown-linux-musl
-
- - job: DockerOSX64
- pool:
- vmImage: macos-10.14
- steps:
- - template: azure-install-rust.yml
- - bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
- displayName: Execute run.sh
- strategy:
- matrix:
- x86_64-apple-darwin:
- TARGET: x86_64-apple-darwin
-
- - job: DockerOSX32
- pool:
- vmImage: macos-10.13
- steps:
- - template: azure-install-rust.yml
- - bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
- displayName: Execute run.sh
- strategy:
- matrix:
- i686-apple-darwin:
- TARGET: i686-apple-darwin
-
- - job: Windows
- pool:
- vmImage: vs2017-win2016
- steps:
- - template: azure-install-rust.yml
- - bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
- displayName: Execute run.sh
- strategy:
- matrix:
- x86_64-pc-windows-gnu:
- TARGET: x86_64-pc-windows-gnu
- ARCH_BITS: 64
- ARCH: x86_64
- x86_64-pc-windows-msvc:
- TARGET: x86_64-pc-windows-msvc
- # Disabled because broken:
- # https://github.com/rust-lang/libc/issues/1592
- #i686-pc-windows-gnu:
- # TARGET: i686-pc-windows-gnu
- # ARCH_BITS: 32
- # ARCH: i686
- i686-pc-windows-msvc:
- TARGET: i686-pc-windows-msvc
-
- - job: StyleAndDocs
- pool:
- vmImage: ubuntu-16.04
- steps:
- - template: azure-install-rust.yml
- - script: sh ci/style.sh
- displayName: Check style
- - script: LIBC_CI=1 sh ci/dox.sh
- displayName: Generate documentation
- - template: azure-configs/static-websites.yml@rustinfra
- parameters:
- deploy_dir: target/doc
-
- # FIXME: re-enable these after the next release
- #- job: SemverLinux
- # dependsOn: BuildChannelsLinux
- # continueOnError: true
- # pool:
- # vmImage: ubuntu-16.04
- # steps:
- # - template: azure-install-rust.yml
- # - script: sh ci/semver.sh linux
- # displayName: Check breaking changes
-
- #- job: SemverOSX
- # dependsOn: BuildChannelsOSX
- # continueOnError: true
- # pool:
- # vmImage: macos-10.14
- # steps:
- # - template: azure-install-rust.yml
- # - script: sh ci/semver.sh osx
- # displayName: Check breaking changes
-
- - job: BuildChannelsLinux
- dependsOn: StyleAndDocs
- pool:
- vmImage: ubuntu-16.04
- steps:
- - template: azure-install-rust.yml
- - script: LIBC_CI=1 sh ./ci/build.sh
- displayName: Execute build.sh
- strategy:
- matrix:
- stable:
- TOOLCHAIN: stable
- beta:
- TOOLCHAIN: beta
- nightly:
- TOOLCHAIN: nightly
- 1.13.0:
- TOOLCHAIN: 1.13.0
- 1.19.0:
- TOOLCHAIN: 1.19.0
- 1.24.0:
- TOOLCHAIN: 1.24.0
- 1.25.0:
- TOOLCHAIN: 1.25.0
- 1.30.0:
- TOOLCHAIN: 1.30.0
- variables:
- OS: linux
-
- - job: BuildChannelsOSX
- dependsOn: StyleAndDocs
- pool:
- vmImage: macos-10.13
- steps:
- - template: azure-install-rust.yml
- - script: LIBC_CI=1 sh ./ci/build.sh
- displayName: Execute build.sh
- strategy:
- matrix:
- stable:
- TOOLCHAIN: stable
- beta:
- TOOLCHAIN: beta
- nightly:
- TOOLCHAIN: nightly
- 1.13.0:
- TOOLCHAIN: 1.13.0
- 1.19.0:
- TOOLCHAIN: 1.19.0
- 1.24.0:
- TOOLCHAIN: 1.24.0
- 1.25.0:
- TOOLCHAIN: 1.25.0
- 1.30.0:
- TOOLCHAIN: 1.30.0
- variables:
- OS: osx
diff --git a/libc/ci/build.sh b/libc/ci/build.sh
deleted file mode 100644
index 082f0dc..0000000
--- a/libc/ci/build.sh
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/usr/bin/env sh
-
-# Checks that libc builds properly for all supported targets on a particular
-# Rust version:
-# The FILTER environment variable can be used to select which target(s) to build.
-# For example: set FILTER to vxworks to select the targets that has vxworks in name
-
-set -ex
-
-: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}"
-: "${OS?The OS environment variable must be set.}"
-
-RUST=${TOOLCHAIN}
-
-echo "Testing Rust ${RUST} on ${OS}"
-
-if [ "${TOOLCHAIN}" = "nightly" ] ; then
- cargo +nightly install cargo-xbuild
- rustup component add rust-src
-fi
-
-test_target() {
- BUILD_CMD="${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_CMD}" -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_CMD}" -vv $opt --target "${TARGET}"
- fi
-
- # Test that libc builds with the `extra_traits` feature
- cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --no-default-features --target "${TARGET}" \
- --features extra_traits
-
- # Test the 'const-extern-fn' feature on nightly
- if [ "${RUST}" = "nightly" ]; then
- cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --no-default-features --target "${TARGET}" \
- --features const-extern-fn
- fi
-
-
- # Also test that it builds with `extra_traits` and default features:
- if [ "$NO_STD" != "1" ]; then
- cargo "+${RUST}" "${BUILD_CMD}" -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-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 \
-"
-
-# FIXME: temporarirly disable the redox target
-# https://github.com/rust-lang/libc/issues/1457
-# x86_64-unknown-redox
-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 \
-"
-
-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
- if echo "$TARGET"|grep -q "$FILTER";then
- test_target build "$TARGET"
- fi
-done
-
-# FIXME: https://github.com/rust-lang/rust/issues/58564
-# sparc-unknown-linux-gnu
-# FIXME: https://github.com/rust-lang/rust/issues/62932
-# thumbv6m-none-eabi
-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 \
-hexagon-unknown-linux-musl \
-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 \
-mips64-unknown-linux-muslabi64 \
-mips64el-unknown-linux-muslabi64 \
-nvptx64-nvidia-cuda \
-powerpc-unknown-linux-gnuspe \
-powerpc-unknown-netbsd \
-powerpc64-unknown-freebsd \
-riscv64gc-unknown-linux-gnu \
-riscv32imac-unknown-none-elf \
-riscv32imc-unknown-none-elf \
-sparc64-unknown-netbsd \
-
-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 \
-armv7-wrs-vxworks-eabihf \
-aarch64-wrs-vxworks \
-i686-wrs-vxworks \
-x86_64-wrs-vxworks \
-powerpc-wrs-vxworks \
-powerpc-wrs-vxworks-spe \
-powerpc64-wrs-vxworks \
-"
-
-if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
- for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
- if echo "$TARGET"|grep -q "$FILTER";then
- test_target xbuild "$TARGET" 1
- fi
- done
-
- # Nintendo switch
- cargo clean
- 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
- )
- cp ci/switch.json switch.json
- PATH="$PATH:/opt/devkitpro/devkitA64/bin"
- PATH="$PATH:/opt/devkitpro/tools/bin"
- cargo xbuild --target switch.json
-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 64f73aa..0000000
--- a/libc/ci/docker/asmjs-unknown-emscripten/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM ubuntu:19.04
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- ca-certificates \
- curl \
- gcc \
- git \
- libc6-dev \
- libxml2 \
- 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 a1ec7ff..0000000
--- a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,24 +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 \
- xz-utils patch
-
-RUN mkdir /toolchain
-
-# Linux kernel version: 4.14.151
-# See build_dir/target-mips_24kc_musl/linux-ar71xx_generic/linux-4.14.151
-# Musl version: 1.1.24
-# See staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/info.mk
-RUN curl --retry 5 -L https://downloads.openwrt.org/releases/19.07.0-rc1/targets/ar71xx/generic/openwrt-sdk-19.07.0-rc1-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz | \
- tar xJf - -C /toolchain --strip-components=1
-
-# See https://lkml.org/lkml/2014/3/14/269
-COPY sysinfo_guard.patch /toolchain
-RUN patch /toolchain/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include/linux/kernel.h </toolchain/sysinfo_guard.patch
-
-ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin \
- STAGING_DIR=/toolchain/staging_dir \
- CC_mips_unknown_linux_musl=mips-openwrt-linux-musl-gcc \
- CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-musl-gcc \
- CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl"
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/mips64-unknown-linux-muslabi64/Dockerfile b/libc/ci/docker/mips64-unknown-linux-muslabi64/Dockerfile
deleted file mode 100644
index 8f63ade..0000000
--- a/libc/ci/docker/mips64-unknown-linux-muslabi64/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-mips64-linux-gnuabi64 qemu-user
-
-COPY install-musl.sh /
-RUN sh /install-musl.sh mips64
-
-# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
-ENV PATH=$PATH:/musl-mips64/bin:/rust/bin \
- CC_mips64_unknown_linux_muslabi64=musl-gcc \
- RUSTFLAGS='-Clink-args=-lgcc' \
- CARGO_TARGET_MIPS64_UNKNOWN_LINUX_MUSLABI64_LINKER=musl-gcc \
- CARGO_TARGET_MIPS64_UNKNOWN_LINUX_MUSLABI64_RUNNER="qemu-mips64 -L /musl-mips64"
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/mips64el-unknown-linux-muslabi64/Dockerfile b/libc/ci/docker/mips64el-unknown-linux-muslabi64/Dockerfile
deleted file mode 100644
index c42c2ba..0000000
--- a/libc/ci/docker/mips64el-unknown-linux-muslabi64/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-mips64el-linux-gnuabi64 qemu-user
-
-COPY install-musl.sh /
-RUN sh /install-musl.sh mips64el
-
-# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
-ENV PATH=$PATH:/musl-mips64el/bin:/rust/bin \
- CC_mips64el_unknown_linux_muslabi64=musl-gcc \
- RUSTFLAGS='-Clink-args=-lgcc' \
- CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER=musl-gcc \
- CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_RUNNER="qemu-mips64el -L /musl-mips64el"
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 87399ec..0000000
--- a/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile
+++ /dev/null
@@ -1,24 +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-mipsel curl \
- xz-utils patch
-
-RUN mkdir /toolchain
-
-# Linux kernel version: 4.14.151
-# See build_dir/target-mipsel_mips32_musl/linux-brcm47xx_generic/linux-4.14.151
-# Musl version: 1.1.24
-# See staging_dir/toolchain-mipsel_mips32_gcc-7.4.0_musl/info.mk
-RUN curl --retry 5 -L https://downloads.openwrt.org/releases/19.07.0-rc1/targets/brcm47xx/generic/openwrt-sdk-19.07.0-rc1-brcm47xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz | \
- tar xJf - -C /toolchain --strip-components=1
-
-# See https://lkml.org/lkml/2014/3/14/269
-COPY sysinfo_guard.patch /toolchain
-RUN patch /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-7.4.0_musl/include/linux/kernel.h </toolchain/sysinfo_guard.patch
-
-ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mipsel_mips32_gcc-7.4.0_musl/bin \
- STAGING_DIR=/toolchain/staging_dir \
- CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-musl-gcc \
- CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-musl-gcc \
- CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-7.4.0_musl"
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 4de9e74..0000000
--- a/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile
+++ /dev/null
@@ -1,28 +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 \
- libxml2 \
- 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 eb3b5ff..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 a2647878977726935c3d04c05cabad9607ec7606
-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 271b54b..0000000
--- a/libc/ci/dox.sh
+++ /dev/null
@@ -1,74 +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
-
-if ! rustc --version | grep -E "nightly" ; then
- echo "Building the documentation requires a nightly Rust toolchain"
- exit 1
-fi
-
-rustup component add rust-src
-cargo +nightly install cargo-xbuild
-
-# 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 | sort > 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
-
- # Enable extra configuration flags:
- export RUSTDOCFLAGS="--cfg freebsd11"
-
- # If cargo doc fails, then try xargo:
- if ! cargo doc --target "${target}" \
- --no-default-features --features extra_traits ; then
- cargo xdoc --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/
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 acec4ca..0000000
--- a/libc/ci/emscripten.sh
+++ /dev/null
@@ -1,52 +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
-}
-
-git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
-cd /emsdk-portable
-# TODO: switch to an upstream install once
-# https://github.com/rust-lang/rust/pull/63649 lands
-hide_output ./emsdk install 1.38.42
-./emsdk activate 1.38.42
-
-# Compile and cache libc
-# shellcheck disable=SC1091
-source ./emsdk_env.sh
-echo "main(){}" > a.c
-HOME=/emsdk-portable/ emcc 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 88cb4f0..0000000
--- a/libc/ci/install-musl.sh
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env sh
-#
-# Install musl and musl-sanitized linux kernel headers
-# to musl-{$1} directory
-
-set -ex
-
-MUSL_VERSION=1.1.24
-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
- ;;
- mips64)
- musl_arch=mips64
- kernel_arch=mips
- CC=mips64-linux-gnuabi64-gcc CFLAGS="-march=mips64r2 -mabi=64" \
- ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
- make install -j4
- ;;
- mips64el)
- musl_arch=mips64el
- kernel_arch=mips
- CC=mips64el-linux-gnuabi64-gcc CFLAGS="-march=mips64r2 -mabi=64" \
- ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
- 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 3c0736a..0000000
--- a/libc/ci/run-docker.sh
+++ /dev/null
@@ -1,46 +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
-
-echo "${HOME}"
-pwd
-
-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 \
- --rm \
- --user "$(id -u)":"$(id -g)" \
- --env LIBC_CI \
- --env CARGO_HOME=/cargo \
- --env CARGO_TARGET_DIR=/checkout/target \
- --volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \
- --volume "$(rustc --print sysroot)":/rust:ro \
- --volume "$(pwd)":/checkout:ro \
- --volume "$(pwd)"/target:/checkout/target \
- $kvm \
- --init \
- --workdir /checkout \
- libc \
- sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec 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 b435122..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
-
-MIRRORS_URL="https://ci-mirrors.rust-lang.org/libc"
-
-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 "${MIRRORS_URL}/${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 "${MIRRORS_URL}/${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 "${MIRRORS_URL}/${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
-
-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 7e6ea66..0000000
--- a/libc/ci/semver.sh
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env sh
-
-# Checks that libc does not contain breaking changes for the following targets.
-
-set -ex
-
-OS=${1}
-
-echo "Testing Semver on ${OS}"
-
-if ! rustc --version | grep -E "nightly" ; then
- echo "Building semverver requires a nightly Rust toolchain"
- exit 1
-fi
-
-cargo +nightly install semverver
-
-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 dcb3536..0000000
--- a/libc/ci/style.rs
+++ /dev/null
@@ -1,208 +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
-//! * 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_end() {
- 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("#[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_start();
- 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/style.sh b/libc/ci/style.sh
deleted file mode 100644
index a6a0017..0000000
--- a/libc/ci/style.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env sh
-
-set -ex
-
-rustc ci/style.rs && ./style src
-
-if rustup component add rustfmt-preview ; then
- which rustfmt
- rustfmt -V
- cargo fmt --all -- --check
-fi
-
-if shellcheck --version ; then
- shellcheck -e SC2103 ci/*.sh
-else
- echo "shellcheck not found"
- exit 1
-fi
-
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/sysinfo_guard.patch b/libc/ci/sysinfo_guard.patch
deleted file mode 100644
index 69fb795..0000000
--- a/libc/ci/sysinfo_guard.patch
+++ /dev/null
@@ -1,10 +0,0 @@
-@@ -2,7 +2,9 @@
- #ifndef _LINUX_KERNEL_H
- #define _LINUX_KERNEL_H
-
-+#ifdef __GLIBC__
- #include <linux/sysinfo.h>
-+#endif
-
- /*
- * 'kernel.h' contains some often-used function prototypes etc
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 977ff51..0000000
--- a/libc/libc-test/build.rs
+++ /dev/null
@@ -1,2658 +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 if t.contains("vxworks") => return test_vxworks(t),
- t => panic!("unknown target {}", t),
- }
-}
-
-fn ctest_cfg() -> ctest::TestGenerator {
- let mut cfg = ctest::TestGenerator::new();
- let libc_cfgs = [
- "libc_priv_mod_use",
- "libc_union",
- "libc_const_size_of",
- "libc_align",
- "libc_core_cvoid",
- "libc_packedN",
- "libc_thread_local",
- ];
- for f in &libc_cfgs {
- cfg.cfg(f, None);
- }
- cfg
-}
-
-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 i686 = target.contains("i686");
-
- let mut cfg = ctest_cfg();
- 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.skip_roundtrip(move |s| match s {
- // FIXME: this type has the wrong ABI
- "max_align_t" if i686 => true,
- _ => false,
- });
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_openbsd(target: &str) {
- assert!(target.contains("openbsd"));
-
- let mut cfg = ctest_cfg();
- 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",
- "net/bpf.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",
- "sys/shm.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_cfg();
- 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_cfg();
- 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_cfg();
- 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_cfg();
- 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_cfg();
-
- 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",
- "sys/shm.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_cfg();
- 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,
-
- _ => 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_cfg();
- 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_cfg();
- 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/nfnetlink.h",
- "linux/netfilter/nfnetlink_log.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_cfg();
-
- let freebsd_ver = which_freebsd();
-
- match freebsd_ver {
- Some(10) => cfg.cfg("freebsd10", None),
- Some(11) => cfg.cfg("freebsd11", None),
- Some(12) => cfg.cfg("freebsd12", None),
- Some(13) => cfg.cfg("freebsd13", None),
- _ => &mut cfg,
- };
-
- // Required for `getline`:
- cfg.define("_WITH_GETLINE", None);
- // Required for making freebsd11_stat available in the headers
- match freebsd_ver {
- Some(10) => &mut cfg,
- _ => 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(11) == freebsd_ver =>
- {
- true
- }
-
- // These constants were introduced in FreeBSD 11:
- "SF_USER_READAHEAD"
- | "SF_NOCACHE"
- | "RLIMIT_KQUEUES"
- | "RLIMIT_UMTXP"
- | "EVFILT_PROCDESC"
- | "EVFILT_SENDFILE"
- | "EVFILT_EMPTY"
- | "SO_REUSEPORT_LB"
- | "TCP_CCALGOOPT"
- | "TCP_PCAP_OUT"
- | "TCP_PCAP_IN"
- | "IP_BINDMULTI"
- | "IP_ORIGDSTADDR"
- | "IP_RECVORIGDSTADDR"
- | "IPV6_ORIGDSTADDR"
- | "IPV6_RECVORIGDSTADDR"
- | "PD_CLOEXEC"
- | "PD_ALLOWED_AT_FORK"
- | "IP_RSS_LISTEN_BUCKET"
- if Some(10) == freebsd_ver =>
- {
- true
- }
-
- // FIXME: This constant has a different value in FreeBSD 10:
- "RLIM_NLIMITS" if Some(10) == 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" | "USER_MAXID" => true,
-
- _ => false,
- }
- });
-
- cfg.skip_struct(move |ty| {
- match ty {
- // `mmsghdr` is not available in FreeBSD 10
- "mmsghdr" if Some(10) == freebsd_ver => true,
-
- // `max_align_t` is not available in FreeBSD 10
- "max_align_t" if Some(10) == freebsd_ver => 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,
-
- // These functions were added in FreeBSD 11:
- "fdatasync" | "mq_getfd_np" | "sendmmsg" | "recvmmsg"
- if Some(10) == freebsd_ver =>
- {
- true
- }
-
- // This function changed its return type from `int` in FreeBSD10 to
- // `ssize_t` in FreeBSD11:
- "aio_waitcomplete" if Some(10) == freebsd_ver => 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.skip_signededness(move |c| {
- match c {
- // FIXME: has a different sign in FreeBSD10
- "blksize_t" if Some(10) == freebsd_ver => 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| {
- match (struct_, field) {
- // FIXME: `sa_sigaction` has type `sighandler_t` but that type is
- // incorrect, see: https://github.com/rust-lang/libc/issues/1359
- ("sigaction", "sa_sigaction") => true,
-
- // FIXME: in FreeBSD10 this field has type `char*` instead of
- // `void*`:
- ("stack_t", "ss_sp") if Some(10) == freebsd_ver => true,
-
- _ => false,
- }
- });
-
- cfg.generate("../src/lib.rs", "main.rs");
-}
-
-fn test_emscripten(target: &str) {
- assert!(target.contains("emscripten"));
-
- let mut cfg = ctest_cfg();
- 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_vxworks(target: &str) {
- assert!(target.contains("vxworks"));
-
- let mut cfg = ctest::TestGenerator::new();
- headers! { cfg:
- "vxWorks.h",
- "yvals.h",
- "nfs/nfsCommon.h",
- "rtpLibCommon.h",
- "randomNumGen.h",
- "taskLib.h",
- "sysLib.h",
- "ioLib.h",
- "inetLib.h",
- "socket.h",
- "errnoLib.h",
- "ctype.h",
- "dirent.h",
- "dlfcn.h",
- "elf.h",
- "fcntl.h",
- "grp.h",
- "sys/poll.h",
- "ifaddrs.h",
- "langinfo.h",
- "limits.h",
- "link.h",
- "locale.h",
- "sys/stat.h",
- "netdb.h",
- "pthread.h",
- "pwd.h",
- "sched.h",
- "semaphore.h",
- "signal.h",
- "stddef.h",
- "stdint.h",
- "stdio.h",
- "stdlib.h",
- "string.h",
- "sys/file.h",
- "sys/ioctl.h",
- "sys/socket.h",
- "sys/time.h",
- "sys/times.h",
- "sys/types.h",
- "sys/uio.h",
- "sys/un.h",
- "sys/utsname.h",
- "sys/wait.h",
- "netinet/tcp.h",
- "syslog.h",
- "termios.h",
- "time.h",
- "ucontext.h",
- "unistd.h",
- "utime.h",
- "wchar.h",
- "errno.h",
- "sys/mman.h",
- "pathLib.h",
- }
- /* Fix me */
- cfg.skip_const(move |name| match name {
- // sighandler_t weirdness
- "SIG_DFL" | "SIG_ERR" | "SIG_IGN"
- // This is not defined in vxWorks
- | "RTLD_DEFAULT" => true,
- _ => false,
- });
- /* Fix me */
- cfg.skip_type(move |ty| match ty {
- "stat64" | "sighandler_t" | "off64_t" => true,
- _ => false,
- });
-
- cfg.skip_field_type(move |struct_, field| match (struct_, field) {
- ("siginfo_t", "si_value")
- | ("stat", "st_size")
- | ("sigaction", "sa_u") => true,
- _ => false,
- });
-
- cfg.skip_roundtrip(move |s| match s {
- _ => false,
- });
-
- cfg.type_name(move |ty, is_struct, is_union| match ty {
- "DIR" | "FILE" | "Dl_info" | "RTP_DESC" => ty.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(),
- });
-
- /* Fix me */
- cfg.skip_fn(move |name| match name {
- /* sigval */
- "sigqueue" | "_sigqueue"
- /* sighandler_t*/
- | "signal"
- /* not used in static linking by default */
- | "dlerror" => true,
- _ => false,
- });
-
- 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 i686 = target.contains("i686");
- let mips = target.contains("mips");
- let mips32 = mips && !target.contains("64");
- let mips64 = mips && target.contains("64");
- let ppc64 = target.contains("powerpc64");
- let s390x = target.contains("s390x");
- let sparc64 = target.contains("sparc64");
- let x32 = target.contains("x32");
- let x86_32 = target.contains("i686");
- let x86_64 = target.contains("x86_64");
- let aarch64_musl = target.contains("aarch64") && musl;
-
- let mut cfg = ctest_cfg();
- 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",
- "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",
- "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/nfnetlink.h",
- "linux/netfilter/nfnetlink_log.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",
- "linux/vm_sockets.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(),
-
- // In MUSL `flock64` is a typedef to `flock`.
- "flock64" if musl => format!("struct {}", ty),
-
- // 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: remove once Ubuntu 20.04 LTS is released, somewhere in 2020.
- // ucontext_t added a new field as of glibc 2.28; our struct definition is
- // conservative and omits the field, but that means the size doesn't match for newer
- // glibcs (see https://github.com/rust-lang/libc/issues/1410)
- "ucontext_t" if gnu => 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.1.24 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,
-
- _ => 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")) ||
- // FIXME: After musl 1.1.24, it have only one field `sched_priority`,
- // while other fields become reserved.
- (struct_ == "sched_param" && [
- "sched_ss_low_priority",
- "sched_ss_repl_period",
- "sched_ss_init_budget",
- "sched_ss_max_repl",
- ].contains(&field) && musl) ||
- // FIXME: After musl 1.1.24, the type becomes `int` instead of `unsigned short`.
- (struct_ == "ipc_perm" && field == "__seq" && aarch64_musl)
- });
-
- cfg.skip_roundtrip(move |s| match s {
- // FIXME:
- "utsname" if mips32 || mips64 => true,
- // FIXME:
- "mcontext_t" if s390x => true,
-
- "sockaddr_un" | "sembuf" | "ff_constant_effect"
- if mips32 && (gnu || musl) =>
- {
- true
- }
- "ipv6_mreq"
- | "ip_mreq_source"
- | "sockaddr_in6"
- | "sockaddr_ll"
- | "in_pktinfo"
- | "arpreq"
- | "arpreq_old"
- | "sockaddr_un"
- | "ff_constant_effect"
- | "ff_ramp_effect"
- | "ff_condition_effect"
- | "Elf32_Ehdr"
- | "Elf32_Chdr"
- | "ucred"
- | "in6_pktinfo"
- | "sockaddr_nl"
- | "termios"
- | "nlmsgerr"
- if (mips64 || sparc64) && gnu =>
- {
- true
- }
-
- // FIXME: the call ABI of max_align_t is incorrect on these platforms:
- "max_align_t" if i686 || mips64 || ppc64 => true,
-
- _ => false,
- });
-
- 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_cfg();
- 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_cfg();
-
- 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_cfg();
- 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_cfg();
- 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_cfg();
- 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("10") => Some(10),
- s if s.starts_with("11") => Some(11),
- s if s.starts_with("12") => Some(12),
- s if s.starts_with("13") => Some(13),
- _ => 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 38a8ce1..0000000
--- a/libc/libc-test/test/cmsg.rs
+++ /dev/null
@@ -1,100 +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 b3065d7..0000000
--- a/libc/src/cloudabi/mod.rs
+++ /dev/null
@@ -1,374 +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 "C" {
- 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 isblank(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 "C" 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 "C" 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 "C" 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 0146408..0000000
--- a/libc/src/fixed_width_ints.rs
+++ /dev/null
@@ -1,20 +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 259893c..0000000
--- a/libc/src/fuchsia/aarch64.rs
+++ /dev/null
@@ -1,66 +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;
diff --git a/libc/src/fuchsia/align.rs b/libc/src/fuchsia/align.rs
deleted file mode 100644
index 3409bf0..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 7d23e67..0000000
--- a/libc/src/fuchsia/mod.rs
+++ /dev/null
@@ -1,4571 +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 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
- }
-
- 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) */],
- }
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_value == other.sigev_value
- && self.sigev_signo == other.sigev_signo
- && self.sigev_notify == other.sigev_notify
- && self.sigev_notify_function
- == other.sigev_notify_function
- && self.sigev_notify_attributes
- == other.sigev_notify_attributes
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_value", &self.sigev_value)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_notify_function", &self.sigev_notify_function)
- .field("sigev_notify_attributes",
- &self.sigev_notify_attributes)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_value.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_notify.hash(state);
- self.sigev_notify_function.hash(state);
- self.sigev_notify_attributes.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 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 "C" {}
-
-#[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 "C" {
- 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 isblank(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 "C" 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 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 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 "C" 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 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 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 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 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 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 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 accept4(
- fd: ::c_int,
- addr: *mut ::sockaddr,
- len: *mut ::socklen_t,
- flg: ::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 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 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 lutimes(file: *const ::c_char, times: *const ::timeval) -> ::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;
-
- // 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 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 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 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 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 glob(
- pattern: *const c_char,
- flags: ::c_int,
- errfunc: ::Option<
- extern "C" 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 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 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 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 "C" 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 umount2(target: *const ::c_char, flags: ::c_int) -> ::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 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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 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 "C" fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void,
- ) -> ::c_int;
- pub fn dl_iterate_phdr(
- callback: ::Option<
- unsafe extern "C" 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 7ca90e0..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 dca3c24..0000000
--- a/libc/src/fuchsia/x86_64.rs
+++ /dev/null
@@ -1,152 +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);
- }
- }
- }
-}
-
-// 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;
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 0b1496a..0000000
--- a/libc/src/lib.rs
+++ /dev/null
@@ -1,157 +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(libc_deny_warnings, deny(warnings))]
-#![allow(
- bad_style,
- overflowing_literals,
- improper_ctypes,
- unknown_lints,
- redundant_semicolon
-)]
-// 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)
-)]
-#![cfg_attr(libc_thread_local, feature(thread_local))]
-// 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))]
-#![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))]
-
-#[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(target_os = "vxworks")] {
- mod fixed_width_ints;
- pub use fixed_width_ints::*;
-
- mod vxworks;
- pub use vxworks::*;
- } 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 f14bbf5..0000000
--- a/libc/src/macros.rs
+++ /dev/null
@@ -1,275 +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 }
- }
- );
-}
-
-// This is a pretty horrible hack to allow us to conditionally mark
-// some functions as 'const', without requiring users of this macro
-// to care about the "const-extern-fn" feature.
-//
-// When 'const-extern-fn' is enabled, we emit the captured 'const' keyword
-// in the expanded function.
-//
-// When 'const-extern-fn' is disabled, we always emit a plain 'pub unsafe extern fn'.
-// Note that the expression matched by the macro is exactly the same - this allows
-// users of this macro to work whether or not 'const-extern-fn' is enabled
-//
-// Unfortunately, we need to duplicate most of this macro between the 'cfg_if' blocks.
-// This is because 'const unsafe extern fn' won't even parse on older compilers,
-// so we need to avoid emitting it at all of 'const-extern-fn'.
-//
-// Specifically, moving the 'cfg_if' into the macro body will *not* work.
-// Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emiited
-// into user code. The 'cfg' gate will not stop Rust from trying to parse the
-// 'pub const unsafe extern fn', so users would get a compiler error even when
-// the 'const-extern-fn' feature is disabled
-//
-// Note that users of this macro need to place 'const' in a weird position
-// (after the closing ')' for the arguments, but before the return type).
-// This was the only way I could satisfy the following two requirements:
-// 1. Avoid ambuguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn'
-// 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same
-// 'f!' block
-cfg_if! {
- if #[cfg(libc_const_extern_fn)] {
- #[allow(unused_macros)]
- macro_rules! f {
- ($(pub $({$constness:ident})* fn $i:ident(
- $($arg:ident: $argty:ty),*
- ) -> $ret:ty {
- $($body:stmt);*
- })*) => ($(
- #[inline]
- pub $($constness)* unsafe extern fn $i($($arg: $argty),*
- ) -> $ret {
- $($body);*
- }
- )*)
- }
-
- #[allow(unused_macros)]
- macro_rules! const_fn {
- ($($({$constness:ident})* fn $i:ident(
- $($arg:ident: $argty:ty),*
- ) -> $ret:ty {
- $($body:stmt);*
- })*) => ($(
- #[inline]
- $($constness)* fn $i($($arg: $argty),*
- ) -> $ret {
- $($body);*
- }
- )*)
- }
-
- } else {
- #[allow(unused_macros)]
- macro_rules! f {
- ($(pub $({$constness:ident})* 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! const_fn {
- ($($({$constness:ident})* fn $i:ident(
- $($arg:ident: $argty:ty),*
- ) -> $ret:ty {
- $($body:stmt);*
- })*) => ($(
- #[inline]
- 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 030ab20..0000000
--- a/libc/src/switch.rs
+++ /dev/null
@@ -1,49 +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/align.rs b/libc/src/unix/bsd/apple/b32/align.rs
deleted file mode 100644
index ca1fe1c..0000000
--- a/libc/src/unix/bsd/apple/b32/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 2]
- }
-}
diff --git a/libc/src/unix/bsd/apple/b32/mod.rs b/libc/src/unix/bsd/apple/b32/mod.rs
deleted file mode 100644
index 9248e3a..0000000
--- a/libc/src/unix/bsd/apple/b32/mod.rs
+++ /dev/null
@@ -1,115 +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);
- }
- }
- }
-}
-
-#[doc(hidden)]
-#[deprecated(since = "0.2.55")]
-pub const NET_RT_MAXID: ::c_int = 10;
-
-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;
-
-pub const BIOCSETF: ::c_ulong = 0x80084267;
-pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d;
-pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e;
-pub const BIOCSETFNR: ::c_ulong = 0x8008427e;
-
-extern "C" {
- pub fn exchangedata(
- path1: *const ::c_char,
- path2: *const ::c_char,
- options: ::c_ulong,
- ) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/bsd/apple/b64/align.rs b/libc/src/unix/bsd/apple/b64/align.rs
deleted file mode 100644
index ca1fe1c..0000000
--- a/libc/src/unix/bsd/apple/b64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 2]
- }
-}
diff --git a/libc/src/unix/bsd/apple/b64/mod.rs b/libc/src/unix/bsd/apple/b64/mod.rs
deleted file mode 100644
index 7f70083..0000000
--- a/libc/src/unix/bsd/apple/b64/mod.rs
+++ /dev/null
@@ -1,120 +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);
- }
- }
- }
-}
-
-#[doc(hidden)]
-#[deprecated(since = "0.2.55")]
-pub const NET_RT_MAXID: ::c_int = 11;
-
-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;
-
-pub const BIOCSETF: ::c_ulong = 0x80104267;
-pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
-pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
-pub const BIOCSETFNR: ::c_ulong = 0x8010427e;
-
-extern "C" {
- pub fn exchangedata(
- path1: *const ::c_char,
- path2: *const ::c_char,
- options: ::c_uint,
- ) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/bsd/apple/mod.rs b/libc/src/unix/bsd/apple/mod.rs
deleted file mode 100644
index aa3cc1c..0000000
--- a/libc/src/unix/bsd/apple/mod.rs
+++ /dev/null
@@ -1,3543 +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,
- //Requires it to be union for tests
- //pub si_value: ::sigval,
- _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 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],
- }
-
- 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
- }
-}
-
-impl siginfo_t {
- pub unsafe fn si_addr(&self) -> *mut ::c_void {
- self.si_addr
- }
-
- pub unsafe fn si_value(&self) -> ::sigval {
- #[repr(C)]
- struct siginfo_timer {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- _si_pid: ::pid_t,
- _si_uid: ::uid_t,
- _si_status: ::c_int,
- _si_addr: *mut ::c_void,
- si_value: ::sigval,
- }
-
- (*(self as *const siginfo_t as *const siginfo_timer)).si_value
- }
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_notify == other.sigev_notify
- && self.sigev_signo == other.sigev_signo
- && self.sigev_value == other.sigev_value
- && self.sigev_notify_attributes
- == other.sigev_notify_attributes
- }
- }
-
- impl Eq for sigevent {}
-
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_value", &self.sigev_value)
- .field("sigev_notify_attributes",
- &self.sigev_notify_attributes)
- .finish()
- }
- }
-
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_notify.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_value.hash(state);
- self.sigev_notify_attributes.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 BIOCGRSIG: ::c_ulong = 0x40044272;
-pub const BIOCSRSIG: ::c_ulong = 0x80044273;
-pub const BIOCSDLT: ::c_ulong = 0x80044278;
-pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
-pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
-pub const BIOCGDLTLIST: ::c_ulong = 0xc00c4279;
-
-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;
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-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;
-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;
-
-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 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;
-#[deprecated(
- since = "0.2.64",
- note = "Can vary at runtime. Use sysconf(3) instead"
-)]
-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 UTIME_OMIT: c_long = -2;
-pub const UTIME_NOW: c_long = -1;
-
-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 "C" {
- 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_getname_np(
- thread: ::pthread_t,
- name: *mut ::c_char,
- len: ::size_t,
- ) -> ::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/errno.rs b/libc/src/unix/bsd/freebsdlike/dragonfly/errno.rs
deleted file mode 100644
index e9ad63b..0000000
--- a/libc/src/unix/bsd/freebsdlike/dragonfly/errno.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// DragonFlyBSD's __error function is declared with "static inline", so it must
-// be implemented in the libc crate, as a pointer to a static thread_local.
-f! {
- pub fn __error() -> *mut ::c_int {
- &mut errno
- }
-}
-
-extern "C" {
- #[thread_local]
- pub static mut errno: ::c_int;
-}
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 63ca4db..0000000
--- a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ /dev/null
@@ -1,1096 +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 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],
- }
-
- 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
- }
-
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_notify == other.sigev_notify
- && self.sigev_signo == other.sigev_signo
- && self.sigev_value == other.sigev_value
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_value", &self.sigev_value)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_notify.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_value.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;
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-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;
-
-pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
-
-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;
-
-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;
-
-// utmpx entry types
-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 DOWNTIME: ::c_short = 11;
-// utmpx database types
-pub const UTX_DB_UTMPX: ::c_uint = 0;
-pub const UTX_DB_WTMPX: ::c_uint = 1;
-pub const UTX_DB_LASTLOG: ::c_uint = 2;
-
-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;
-
-// timespec constants
-pub const UTIME_OMIT: c_long = -2;
-pub const UTIME_NOW: c_long = -1;
-
-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 "C" {
- 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;
-}
-
-cfg_if! {
- if #[cfg(libc_thread_local)] {
- mod errno;
- pub use self::errno::*;
- }
-}
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 79a152f..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
+++ /dev/null
@@ -1,224 +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);
- }
- }
- }
-}
-
-pub const ELAST: ::c_int = 96;
-
-extern "C" {
- // 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 f32128f..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/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_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 6bf7f95..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
+++ /dev/null
@@ -1,224 +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);
- }
- }
- }
-}
-
-cfg_if! {
- if #[cfg(not(freebsd13))] {
- pub const ELAST: ::c_int = 96;
- } else {
- pub const EINTEGRITY: ::c_int = 97;
- pub const ELAST: ::c_int = 97;
- }
-}
-
-extern "C" {
- 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 80c6fa1..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs
+++ /dev/null
@@ -1,34 +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 980caf2..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ /dev/null
@@ -1,1486 +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 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]
- }
-
- 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]
- }
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_notify == other.sigev_notify
- && self.sigev_signo == other.sigev_signo
- && self.sigev_value == other.sigev_value
- && self.sigev_notify_thread_id
- == other.sigev_notify_thread_id
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_value", &self.sigev_value)
- .field("sigev_notify_thread_id",
- &self.sigev_notify_thread_id)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_notify.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_value.hash(state);
- self.sigev_notify_thread_id.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 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;
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-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 BIOCSETFNR: ::c_ulong = 0x80104282;
-
-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;
-
-// 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;
-
-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")]
-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;
-
-// utmpx entry types
-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;
-// utmp database types
-pub const UTXDB_ACTIVE: ::c_int = 0;
-pub const UTXDB_LASTLOGIN: ::c_int = 1;
-pub const UTXDB_LOG: ::c_int = 2;
-
-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 UTIME_OMIT: c_long = -2;
-pub const UTIME_NOW: c_long = -1;
-
-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 "C" {
- 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;
-
- #[cfg_attr(
- all(target_os = "freebsd", freebsd11),
- link_name = "statfs@FBSD_1.0"
- )]
- pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
- #[cfg_attr(
- all(target_os = "freebsd", freebsd11),
- link_name = "fstatfs@FBSD_1.0"
- )]
- 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 "C" {
- 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 if #[cfg(freebsd13)] {
- mod freebsd12;
- pub use self::freebsd12::*;
- } else if #[cfg(any(freebsd10, freebsd11))] {
- mod freebsd11;
- pub use self::freebsd11::*;
- } else {
- // Unknown freebsd version
- }
-}
-
-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/align.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
deleted file mode 100644
index 7ca870f..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 4]
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
deleted file mode 100644
index 0769a22..0000000
--- a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
+++ /dev/null
@@ -1,24 +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;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/bsd/freebsdlike/mod.rs b/libc/src/unix/bsd/freebsdlike/mod.rs
deleted file mode 100644
index 1b7804c..0000000
--- a/libc/src/unix/bsd/freebsdlike/mod.rs
+++ /dev/null
@@ -1,1466 +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
- }
-}
-
-impl siginfo_t {
- pub unsafe fn si_addr(&self) -> *mut ::c_void {
- self.si_addr
- }
-
- pub unsafe fn si_value(&self) -> ::sigval {
- self.si_value
- }
-}
-
-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,
- pub si_value: ::sigval,
- _pad1: ::c_long,
- _pad2: [::c_int; 7],
- }
-
- 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);
- }
- }
- }
-}
-
-#[deprecated(
- since = "0.2.64",
- note = "Can vary at runtime. Use sysconf(3) instead"
-)]
-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 BIOCGRSIG: ::c_ulong = 0x40044272;
-pub const BIOCSRSIG: ::c_ulong = 0x80044273;
-pub const BIOCSDLT: ::c_ulong = 0x80044278;
-pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
-pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
-pub const BIOCSETF: ::c_ulong = 0x80104267;
-pub const BIOCGDLTLIST: ::c_ulong = 0xc0104279;
-pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
-pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
-
-pub const FIODTYPE: ::c_ulong = 0x4004667a;
-pub const FIOGETLBA: ::c_ulong = 0x40046679;
-pub const FIODGNAME: ::c_ulong = 0x80106678;
-
-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 "C" {
- 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", any(freebsd11, freebsd10)),
- 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", any(freebsd11, freebsd10)),
- 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,
- msg_prio: *mut ::c_uint,
- ) -> ::ssize_t;
- pub fn mq_send(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_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,
- msg_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,
- msg_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_main_np() -> ::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 "C" {
- 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 cf9f59e..0000000
--- a/libc/src/unix/bsd/mod.rs
+++ /dev/null
@@ -1,794 +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 FIONCLEX: ::c_ulong = 0x20006602;
-pub const FIONREAD: ::c_ulong = 0x4004667f;
-pub const FIONBIO: ::c_ulong = 0x8004667e;
-pub const FIOASYNC: ::c_ulong = 0x8004667d;
-pub const FIOSETOWN: ::c_ulong = 0x8004667c;
-pub const FIOGETOWN: ::c_ulong = 0x4004667b;
-
-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;
-
-pub const BIOCGBLEN: ::c_ulong = 0x40044266;
-pub const BIOCSBLEN: ::c_ulong = 0xc0044266;
-pub const BIOCFLUSH: ::c_uint = 0x20004268;
-pub const BIOCPROMISC: ::c_uint = 0x20004269;
-pub const BIOCGDLT: ::c_ulong = 0x4004426a;
-pub const BIOCGETIF: ::c_ulong = 0x4020426b;
-pub const BIOCSETIF: ::c_ulong = 0x8020426c;
-pub const BIOCGSTATS: ::c_ulong = 0x4008426f;
-pub const BIOCIMMEDIATE: ::c_ulong = 0x80044270;
-pub const BIOCVERSION: ::c_ulong = 0x40044271;
-pub const BIOCGHDRCMPLT: ::c_ulong = 0x40044274;
-pub const BIOCSHDRCMPLT: ::c_ulong = 0x80044275;
-pub const SIOCGIFADDR: ::c_ulong = 0xc0206921;
-
-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 "C" {
- #[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", any(freebsd11, freebsd10)),
- link_name = "glob@FBSD_1.0"
- )]
- pub fn glob(
- pattern: *const ::c_char,
- flags: ::c_int,
- errfunc: ::Option<
- extern "C" 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", any(freebsd11, freebsd10)),
- 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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 "C" 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 970cb23..0000000
--- a/libc/src/unix/bsd/netbsdlike/mod.rs
+++ /dev/null
@@ -1,765 +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;
-pub type key_t = c_long;
-
-#[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 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 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_ANONYMOUS: ::c_int = MAP_ANON;
-
-pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
-
-pub const IPC_CREAT: ::c_int = 0o001000;
-pub const IPC_EXCL: ::c_int = 0o002000;
-pub const IPC_NOWAIT: ::c_int = 0o004000;
-
-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 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 "C" {
- 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;
-
- 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;
-}
-
-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 422539a..0000000
--- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ /dev/null
@@ -1,1965 +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;
-pub type lwpid_t = ::c_uint;
-pub type shmatt_t = ::c_uint;
-
-impl siginfo_t {
- pub unsafe fn si_value(&self) -> ::sigval {
- #[repr(C)]
- struct siginfo_timer {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- __pad1: ::c_int,
- _pid: ::pid_t,
- _uid: ::uid_t,
- value: ::sigval,
- }
- (*(self as *const siginfo_t as *const siginfo_timer)).value
- }
-}
-
-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 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,
- }
-
- pub struct __exit_status {
- pub e_termination: u16,
- pub e_exit: u16,
- }
-
- 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,
- _shm_internal: *mut ::c_void,
- }
-
- 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 struct lastlog {
- pub ll_line: [::c_char; UT_LINESIZE],
- pub ll_host: [::c_char; UT_HOSTSIZE],
- pub ll_time: ::time_t
- }
-}
-
-s_no_extra_traits! {
-
- pub struct utmpx {
- pub ut_name: [::c_char; _UTX_USERSIZE],
- pub ut_id: [::c_char; _UTX_IDSIZE],
- pub ut_line: [::c_char; _UTX_LINESIZE],
- pub ut_host: [::c_char; _UTX_HOSTSIZE],
- pub ut_session: u16,
- pub ut_type: u16,
- pub ut_pid: ::pid_t,
- pub ut_exit: __exit_status,
- pub ut_ss: sockaddr_storage,
- pub ut_tv: ::timeval,
- pub ut_pad: [u8; _UTX_PADSIZE],
- }
-
- pub struct lastlogx {
- pub ll_tv: ::timeval,
- pub ll_line: [::c_char; _UTX_LINESIZE],
- pub ll_host: [::c_char; _UTX_HOSTSIZE],
- pub ll_ss: sockaddr_storage,
- }
-
- 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],
- }
-
- 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
- }
-}
-
-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_name == other.ut_name
- && self.ut_line == other.ut_line
- && self.ut_id == other.ut_id
- && self.ut_exit == other.ut_exit
- && self.ut_session == other.ut_session
- && self.ut_tv == other.ut_tv
- && self.ut_ss == other.ut_ss
- && self
- .ut_pad
- .iter()
- .zip(other.ut_pad.iter())
- .all(|(a,b)| a == b)
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.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_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_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)
- // FIXME .field("ut_pad", &self.ut_pad)
- .finish()
- }
- }
-
- impl ::hash::Hash for utmpx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_name.hash(state);
- self.ut_type.hash(state);
- self.ut_pid.hash(state);
- self.ut_line.hash(state);
- self.ut_id.hash(state);
- self.ut_host.hash(state);
- self.ut_exit.hash(state);
- self.ut_session.hash(state);
- self.ut_tv.hash(state);
- self.ut_ss.hash(state);
- self.ut_pad.hash(state);
- }
- }
-
- impl PartialEq for lastlogx {
- fn eq(&self, other: &lastlogx) -> bool {
- self.ll_tv == other.ll_tv
- && self.ll_line == other.ll_line
- && self.ll_ss == other.ll_ss
- && self
- .ll_host
- .iter()
- .zip(other.ll_host.iter())
- .all(|(a,b)| a == b)
- }
- }
-
- impl Eq for lastlogx {}
-
- impl ::fmt::Debug for lastlogx {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("lastlogx")
- .field("ll_tv", &self.ll_tv)
- .field("ll_line", &self.ll_line)
- // FIXME.field("ll_host", &self.ll_host)
- .field("ll_ss", &self.ll_ss)
- .finish()
- }
- }
-
- impl ::hash::Hash for lastlogx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ll_tv.hash(state);
- self.ll_line.hash(state);
- self.ll_host.hash(state);
- self.ll_ss.hash(state);
- }
- }
-
- 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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_notify == other.sigev_notify
- && self.sigev_signo == other.sigev_signo
- && self.sigev_value == other.sigev_value
- && self.sigev_notify_attributes
- == other.sigev_notify_attributes
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_value", &self.sigev_value)
- .field("sigev_notify_attributes",
- &self.sigev_notify_attributes)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_notify.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_value.hash(state);
- self.sigev_notify_attributes.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;
-
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-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;
-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;
-
-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;
-
-pub const BIOCGRSIG: ::c_ulong = 0x40044272;
-pub const BIOCSRSIG: ::c_ulong = 0x80044273;
-pub const BIOCSDLT: ::c_ulong = 0x80044278;
-pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
-pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
-
-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 UTIME_OMIT: c_long = 1073741822;
-pub const UTIME_NOW: c_long = 1073741823;
-
-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 _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx";
-// pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx";
-// pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx";
-// pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update";
-pub const UT_NAMESIZE: usize = 8;
-pub const UT_LINESIZE: usize = 8;
-pub const UT_HOSTSIZE: usize = 16;
-pub const _UTX_USERSIZE: usize = 32;
-pub const _UTX_LINESIZE: usize = 32;
-pub const _UTX_PADSIZE: usize = 40;
-pub const _UTX_IDSIZE: usize = 4;
-pub const _UTX_HOSTSIZE: usize = 256;
-pub const EMPTY: u16 = 0;
-pub const RUN_LVL: u16 = 1;
-pub const BOOT_TIME: u16 = 2;
-pub const OLD_TIME: u16 = 3;
-pub const NEW_TIME: u16 = 4;
-pub const INIT_PROCESS: u16 = 5;
-pub const LOGIN_PROCESS: u16 = 6;
-pub const USER_PROCESS: u16 = 7;
-pub const DEAD_PROCESS: u16 = 8;
-pub const ACCOUNTING: u16 = 9;
-pub const SIGNATURE: u16 = 10;
-pub const DOWN_TIME: u16 = 11;
-
-pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
-pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
-
-// Uncomment on next NetBSD release
-// pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
-// pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
-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 "C" {
- pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
- pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
- pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
- pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
- pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
- #[link_name = "__aio_suspend50"]
- pub fn aio_suspend(
- aiocb_list: *const *const aiocb,
- nitems: ::c_int,
- timeout: *const ::timespec,
- ) -> ::c_int;
- pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
- pub fn lio_listio(
- mode: ::c_int,
- aiocb_list: *const *mut aiocb,
- nitems: ::c_int,
- sevp: *mut sigevent,
- ) -> ::c_int;
-}
-
-extern "C" {
- pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
- pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
- pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
-
- 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,
- msg_prio: *mut ::c_uint,
- ) -> ::ssize_t;
- pub fn mq_send(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_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,
- msg_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,
- msg_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: *const ::c_void,
- ) -> ::c_int;
- pub fn pthread_attr_get_np(
- thread: ::pthread_t,
- attr: *mut ::pthread_attr_t,
- ) -> ::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;
-
- pub fn _lwp_self() -> lwpid_t;
-}
-
-#[link(name = "util")]
-extern "C" {
- #[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;
-
- pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int;
- pub fn getlastlogx(
- fname: *const ::c_char,
- uid: ::uid_t,
- ll: *mut lastlogx,
- ) -> *mut lastlogx;
- pub fn updlastlogx(
- fname: *const ::c_char,
- uid: ::uid_t,
- ll: *mut lastlogx,
- ) -> ::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 getutmp(ux: *const utmpx, u: *mut utmp);
- pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
-
- pub fn utpname(file: *const ::c_char) -> ::c_int;
- pub fn setutent();
- pub fn endutent();
- pub fn getutent() -> *mut utmp;
-}
-
-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 99350ec..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs
+++ /dev/null
@@ -1,16 +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;
- }
-}
-
-pub const _MAX_PAGE_SHIFT: u32 = 12;
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 89a3354..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs
+++ /dev/null
@@ -1,1509 +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,
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::c_int,
- pub shm_lpid: ::pid_t,
- pub shm_cpid: ::pid_t,
- pub shm_nattch: ::c_short,
- pub shm_atime: ::time_t,
- __shm_atimensec: c_long,
- pub shm_dtime: ::time_t,
- __shm_dtimensec: c_long,
- pub shm_ctime: ::time_t,
- __shm_ctimensec: c_long,
- pub shm_internal: *mut ::c_void,
- }
-}
-
-impl siginfo_t {
- pub unsafe fn si_value(&self) -> ::sigval {
- #[repr(C)]
- struct siginfo_timer {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- _pid: ::pid_t,
- _uid: ::uid_t,
- value: ::sigval,
- }
- (*(self as *const siginfo_t as *const siginfo_timer)).value
- }
-}
-
-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 UTIME_OMIT: c_long = -1;
-pub const UTIME_NOW: c_long = -2;
-
-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;
-
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-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
-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;
-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;
-
-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_TIMEOUT_STATS: ::c_int = 87;
-pub const KERN_MAXID: ::c_int = 88;
-
-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 = (1_usize << _MAX_PAGE_SHIFT);
-pub const MINSIGSTKSZ: ::size_t = (3_usize << _MAX_PAGE_SHIFT);
-pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4;
-
-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 BIOCGRSIG: ::c_ulong = 0x40044273;
-pub const BIOCSRSIG: ::c_ulong = 0x80044272;
-pub const BIOCSDLT: ::c_ulong = 0x8004427a;
-
-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 "C" {
- pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
- pub fn settimeofday(
- tp: *const ::timeval,
- tz: *const ::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_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_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 if #[cfg(target_arch = "sparc64")] {
- mod sparc64;
- pub use self::sparc64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs b/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs
deleted file mode 100644
index 070fc93..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type c_char = i8;
-
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = 0xf;
-
-pub const _MAX_PAGE_SHIFT: u32 = 13;
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 e87d0ff..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs
+++ /dev/null
@@ -1,16 +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;
- }
-}
-
-pub const _MAX_PAGE_SHIFT: u32 = 12;
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 263b6e1..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs
+++ /dev/null
@@ -1,24 +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 _MAX_PAGE_SHIFT: u32 = 12;
-
-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 d704a0b..0000000
--- a/libc/src/unix/haiku/mod.rs
+++ /dev/null
@@ -1,1531 +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 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
- }
-
- 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,
- }
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_notify == other.sigev_notify
- && self.sigev_signo == other.sigev_signo
- && self.sigev_value == other.sigev_value
- && self.sigev_notify_attributes
- == other.sigev_notify_attributes
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_value", &self.sigev_value)
- .field("sigev_notify_attributes",
- &self.sigev_notify_attributes)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_notify.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_value.hash(state);
- self.sigev_notify_attributes.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 = 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 = 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;
-
-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 UTIME_OMIT: c_long = 1000000001;
-pub const UTIME_NOW: c_long = 1000000000;
-
-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;
-
-pub const TCGETA: ::c_int = 0x8000;
-pub const TCSETA: ::c_int = TCGETA + 1;
-pub const TCSETAF: ::c_int = TCGETA + 2;
-pub const TCSETAW: ::c_int = TCGETA + 3;
-pub const TCWAITEVENT: ::c_int = TCGETA + 4;
-pub const TCSBRK: ::c_int = TCGETA + 5;
-pub const TCFLSH: ::c_int = TCGETA + 6;
-pub const TCXONC: ::c_int = TCGETA + 7;
-pub const TCQUERYCONNECTED: ::c_int = TCGETA + 8;
-pub const TCGETBITS: ::c_int = TCGETA + 9;
-pub const TCSETDTR: ::c_int = TCGETA + 10;
-pub const TCSETRTS: ::c_int = TCGETA + 11;
-pub const TIOCGWINSZ: ::c_int = TCGETA + 12;
-pub const TIOCSWINSZ: ::c_int = TCGETA + 13;
-pub const TCVTIME: ::c_int = TCGETA + 14;
-pub const TIOCGPGRP: ::c_int = TCGETA + 15;
-pub const TIOCSPGRP: ::c_int = TCGETA + 16;
-pub const TIOCSCTTY: ::c_int = TCGETA + 17;
-pub const TIOCMGET: ::c_int = TCGETA + 18;
-pub const TIOCMSET: ::c_int = TCGETA + 19;
-pub const TIOCSBRK: ::c_int = TCGETA + 20;
-pub const TIOCCBRK: ::c_int = TCGETA + 21;
-pub const TIOCMBIS: ::c_int = TCGETA + 22;
-pub const TIOCMBIC: ::c_int = TCGETA + 23;
-
-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 "C" {
- 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 _errnop() -> *mut ::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 "C" {
- 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 "C" 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 "C" 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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 83e064e..0000000
--- a/libc/src/unix/hermit/mod.rs
+++ /dev/null
@@ -1,1049 +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 "C" {
- 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 "C" 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/linux_like/android/b32/arm.rs b/libc/src/unix/linux_like/android/b32/arm.rs
deleted file mode 100644
index 1320b16..0000000
--- a/libc/src/unix/linux_like/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/linux_like/android/b32/mod.rs b/libc/src/unix/linux_like/android/b32/mod.rs
deleted file mode 100644
index e5c97e9..0000000
--- a/libc/src/unix/linux_like/android/b32/mod.rs
+++ /dev/null
@@ -1,221 +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 "C" {
- 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/linux_like/android/b32/x86/align.rs b/libc/src/unix/linux_like/android/b32/x86/align.rs
deleted file mode 100644
index 04df4a0..0000000
--- a/libc/src/unix/linux_like/android/b32/x86/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [f64; 2]
- }
-}
diff --git a/libc/src/unix/linux_like/android/b32/x86/mod.rs b/libc/src/unix/linux_like/android/b32/x86/mod.rs
deleted file mode 100644
index 101bf2d..0000000
--- a/libc/src/unix/linux_like/android/b32/x86/mod.rs
+++ /dev/null
@@ -1,422 +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;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/android/b64/aarch64/align.rs b/libc/src/unix/linux_like/android/b64/aarch64/align.rs
deleted file mode 100644
index 8e94996..0000000
--- a/libc/src/unix/linux_like/android/b64/aarch64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f32; 8]
- }
-}
diff --git a/libc/src/unix/linux_like/android/b64/aarch64/mod.rs b/libc/src/unix/linux_like/android/b64/aarch64/mod.rs
deleted file mode 100644
index b2b9188..0000000
--- a/libc/src/unix/linux_like/android/b64/aarch64/mod.rs
+++ /dev/null
@@ -1,332 +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;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/android/b64/mod.rs b/libc/src/unix/linux_like/android/b64/mod.rs
deleted file mode 100644
index 9826bb9..0000000
--- a/libc/src/unix/linux_like/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/linux_like/android/b64/x86_64/align.rs b/libc/src/unix/linux_like/android/b64/x86_64/align.rs
deleted file mode 100644
index 7ca870f..0000000
--- a/libc/src/unix/linux_like/android/b64/x86_64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/android/b64/x86_64/mod.rs b/libc/src/unix/linux_like/android/b64/x86_64/mod.rs
deleted file mode 100644
index f5b8b16..0000000
--- a/libc/src/unix/linux_like/android/b64/x86_64/mod.rs
+++ /dev/null
@@ -1,427 +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;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/android/mod.rs b/libc/src/unix/linux_like/android/mod.rs
deleted file mode 100644
index a40b77e..0000000
--- a/libc/src/unix/linux_like/android/mod.rs
+++ /dev/null
@@ -1,2409 +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;
-pub type __kernel_loff_t = ::c_longlong;
-pub type __kernel_pid_t = ::c_int;
-
-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 flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::__kernel_loff_t,
- pub l_len: ::__kernel_loff_t,
- pub l_pid: ::__kernel_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 FIONCLEX: ::c_int = 0x5450;
-
-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;
-
-/* 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 RLIM_INFINITY: ::rlim_t = !0;
-
-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;
-
-// linux/netfilter/nfnetlink.h
-pub const NFNLGRP_NONE: ::c_int = 0;
-pub const NFNLGRP_CONNTRACK_NEW: ::c_int = 1;
-pub const NFNLGRP_CONNTRACK_UPDATE: ::c_int = 2;
-pub const NFNLGRP_CONNTRACK_DESTROY: ::c_int = 3;
-pub const NFNLGRP_CONNTRACK_EXP_NEW: ::c_int = 4;
-pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5;
-pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6;
-pub const NFNLGRP_NFTABLES: ::c_int = 7;
-pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8;
-
-pub const NFNETLINK_V0: ::c_int = 0;
-
-pub const NFNL_SUBSYS_NONE: ::c_int = 0;
-pub const NFNL_SUBSYS_CTNETLINK: ::c_int = 1;
-pub const NFNL_SUBSYS_CTNETLINK_EXP: ::c_int = 2;
-pub const NFNL_SUBSYS_QUEUE: ::c_int = 3;
-pub const NFNL_SUBSYS_ULOG: ::c_int = 4;
-pub const NFNL_SUBSYS_OSF: ::c_int = 5;
-pub const NFNL_SUBSYS_IPSET: ::c_int = 6;
-pub const NFNL_SUBSYS_ACCT: ::c_int = 7;
-pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8;
-pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9;
-pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10;
-pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11;
-pub const NFNL_SUBSYS_COUNT: ::c_int = 12;
-
-pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE;
-pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1;
-
-// linux/netfilter/nfnetlink_log.h
-pub const NFULNL_MSG_PACKET: ::c_int = 0;
-pub const NFULNL_MSG_CONFIG: ::c_int = 1;
-
-pub const NFULA_UNSPEC: ::c_int = 0;
-pub const NFULA_PACKET_HDR: ::c_int = 1;
-pub const NFULA_MARK: ::c_int = 2;
-pub const NFULA_TIMESTAMP: ::c_int = 3;
-pub const NFULA_IFINDEX_INDEV: ::c_int = 4;
-pub const NFULA_IFINDEX_OUTDEV: ::c_int = 5;
-pub const NFULA_IFINDEX_PHYSINDEV: ::c_int = 6;
-pub const NFULA_IFINDEX_PHYSOUTDEV: ::c_int = 7;
-pub const NFULA_HWADDR: ::c_int = 8;
-pub const NFULA_PAYLOAD: ::c_int = 9;
-pub const NFULA_PREFIX: ::c_int = 10;
-pub const NFULA_UID: ::c_int = 11;
-pub const NFULA_SEQ: ::c_int = 12;
-pub const NFULA_SEQ_GLOBAL: ::c_int = 13;
-pub const NFULA_GID: ::c_int = 14;
-pub const NFULA_HWTYPE: ::c_int = 15;
-pub const NFULA_HWHEADER: ::c_int = 16;
-pub const NFULA_HWLEN: ::c_int = 17;
-pub const NFULA_CT: ::c_int = 18;
-pub const NFULA_CT_INFO: ::c_int = 19;
-
-pub const NFULNL_CFG_CMD_NONE: ::c_int = 0;
-pub const NFULNL_CFG_CMD_BIND: ::c_int = 1;
-pub const NFULNL_CFG_CMD_UNBIND: ::c_int = 2;
-pub const NFULNL_CFG_CMD_PF_BIND: ::c_int = 3;
-pub const NFULNL_CFG_CMD_PF_UNBIND: ::c_int = 4;
-
-pub const NFULA_CFG_UNSPEC: ::c_int = 0;
-pub const NFULA_CFG_CMD: ::c_int = 1;
-pub const NFULA_CFG_MODE: ::c_int = 2;
-pub const NFULA_CFG_NLBUFSIZ: ::c_int = 3;
-pub const NFULA_CFG_TIMEOUT: ::c_int = 4;
-pub const NFULA_CFG_QTHRESH: ::c_int = 5;
-pub const NFULA_CFG_FLAGS: ::c_int = 6;
-
-pub const NFULNL_COPY_NONE: ::c_int = 0x00;
-pub const NFULNL_COPY_META: ::c_int = 0x01;
-pub const NFULNL_COPY_PACKET: ::c_int = 0x02;
-
-pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001;
-pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002;
-pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004;
-
-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_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 "C" {
- 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 "C" 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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 "C" 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
- }
-}
-
-impl siginfo_t {
- pub unsafe fn si_value(&self) -> ::sigval {
- #[repr(C)]
- struct siginfo_timer {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- _si_tid: ::c_int,
- _si_overrun: ::c_int,
- si_sigval: ::sigval,
- }
- (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval
- }
-}
diff --git a/libc/src/unix/linux_like/emscripten/align.rs b/libc/src/unix/linux_like/emscripten/align.rs
deleted file mode 100644
index 141570f..0000000
--- a/libc/src/unix/linux_like/emscripten/align.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-macro_rules! expand_align {
- () => {
- s! {
- #[allow(missing_debug_implementations)]
- #[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],
- }
-
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [f64; 2]
- }
-
- }
-
- 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/linux_like/emscripten/mod.rs b/libc/src/unix/linux_like/emscripten/mod.rs
deleted file mode 100644
index 3fc47bb..0000000
--- a/libc/src/unix/linux_like/emscripten/mod.rs
+++ /dev/null
@@ -1,1917 +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 = u64;
-pub type off64_t = i64;
-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 = i64;
-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 = u64;
-pub type off_t = i64;
-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 flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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;
-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 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 linux_like/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 "C" {
- 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 "C" 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 "C" 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/linux_like/emscripten/no_align.rs b/libc/src/unix/linux_like/emscripten/no_align.rs
deleted file mode 100644
index 768dc73..0000000
--- a/libc/src/unix/linux_like/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/linux_like/linux/align.rs b/libc/src/unix/linux_like/linux/align.rs
deleted file mode 100644
index 6000b41..0000000
--- a/libc/src/unix/linux_like/linux/align.rs
+++ /dev/null
@@ -1,106 +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 = "hexagon",
- target_arch = "powerpc",
- target_arch = "sparc",
- target_arch = "x86_64",
- target_arch = "x86")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "hexagon",
- target_arch = "powerpc",
- target_arch = "sparc",
- 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 = "hexagon",
- target_arch = "powerpc",
- target_arch = "sparc",
- target_arch = "x86_64",
- target_arch = "x86")),
- repr(align(4)))]
- #[cfg_attr(any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "hexagon",
- target_arch = "powerpc",
- target_arch = "sparc",
- 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/linux_like/linux/gnu/align.rs b/libc/src/unix/linux_like/linux/gnu/align.rs
deleted file mode 100644
index 4a0e074..0000000
--- a/libc/src/unix/linux_like/linux/gnu/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/linux_like/linux/gnu/b32/arm/align.rs b/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs
deleted file mode 100644
index 825546b..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [i64; 2]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs
deleted file mode 100644
index 0a5fc85..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs
+++ /dev/null
@@ -1,876 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-s! {
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- pub mode: ::c_ushort,
- __pad1: ::c_ushort,
- pub __seq: ::c_ushort,
- __pad2: ::c_ushort,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __pad1: ::c_uint,
- __st_ino: ::ino_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- __pad2: ::c_uint,
- pub st_size: ::off64_t,
- pub st_blksize: ::blksize_t,
- pub st_blocks: ::blkcnt64_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- pub st_ino: ::ino64_t,
- }
-
- pub struct statfs64 {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- pub f_flags: ::__fsword_t,
- pub f_spare: [::__fsword_t; 4],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: u64,
- pub f_bfree: u64,
- pub f_bavail: u64,
- pub f_files: u64,
- pub f_ffree: u64,
- pub f_favail: u64,
- pub f_fsid: ::c_ulong,
- __f_unused: ::c_int,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- __f_spare: [::c_int; 6],
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_atime: ::time_t,
- __unused1: ::c_ulong,
- pub shm_dtime: ::time_t,
- __unused2: ::c_ulong,
- pub shm_ctime: ::time_t,
- __unused3: ::c_ulong,
- pub shm_cpid: ::pid_t,
- pub shm_lpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- __unused4: ::c_ulong,
- __unused5: ::c_ulong
- }
-
- pub struct msqid_ds {
- pub msg_perm: ::ipc_perm,
- pub msg_stime: ::time_t,
- __glibc_reserved1: ::c_ulong,
- pub msg_rtime: ::time_t,
- __glibc_reserved2: ::c_ulong,
- pub msg_ctime: ::time_t,
- __glibc_reserved3: ::c_ulong,
- __msg_cbytes: ::c_ulong,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved4: ::c_ulong,
- __glibc_reserved5: ::c_ulong,
- }
-
- pub struct 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 siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-}
-
-pub const RLIM_INFINITY: ::rlim_t = !0;
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const O_DIRECT: ::c_int = 0x10000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_LARGEFILE: ::c_int = 0o400000;
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6;
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-pub const EDEADLOCK: ::c_int = 35;
-pub const EUCLEAN: ::c_int = 117;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENAVAIL: ::c_int = 119;
-pub const EISNAM: ::c_int = 120;
-pub const EREMOTEIO: ::c_int = 121;
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const 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_ACCEPTCONN: ::c_int = 30;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-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 SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONCLEX: ::c_ulong = 0x5450;
-pub const FIONBIO: ::c_ulong = 0x5421;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_SETOWN: ::c_int = 8;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-pub const SFD_NONBLOCK: ::c_int = 0x0800;
-
-pub const SIGCHLD: ::c_int = 17;
-pub const SIGBUS: ::c_int = 7;
-pub const SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-pub const SIGTTIN: ::c_int = 21;
-pub const SIGTTOU: ::c_int = 22;
-pub const SIGXCPU: ::c_int = 24;
-pub const SIGXFSZ: ::c_int = 25;
-pub const SIGVTALRM: ::c_int = 26;
-pub const SIGPROF: ::c_int = 27;
-pub const SIGWINCH: ::c_int = 28;
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const B0: ::speed_t = 0o000000;
-pub const B50: ::speed_t = 0o000001;
-pub const B75: ::speed_t = 0o000002;
-pub const B110: ::speed_t = 0o000003;
-pub const B134: ::speed_t = 0o000004;
-pub const B150: ::speed_t = 0o000005;
-pub const B200: ::speed_t = 0o000006;
-pub const B300: ::speed_t = 0o000007;
-pub const B600: ::speed_t = 0o000010;
-pub const B1200: ::speed_t = 0o000011;
-pub const B1800: ::speed_t = 0o000012;
-pub const B2400: ::speed_t = 0o000013;
-pub const B4800: ::speed_t = 0o000014;
-pub const B9600: ::speed_t = 0o000015;
-pub const B19200: ::speed_t = 0o000016;
-pub const B38400: ::speed_t = 0o000017;
-pub const EXTA: ::speed_t = B19200;
-pub const EXTB: ::speed_t = B38400;
-pub const 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;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-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 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 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;
-
-// 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;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/mips/align.rs b/libc/src/unix/linux_like/linux/gnu/b32/mips/align.rs
deleted file mode 100644
index 8c228eb..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/mips/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [f32; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs
deleted file mode 100644
index 4a3b600..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs
+++ /dev/null
@@ -1,901 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-
-s! {
- 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 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 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 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 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 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 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 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 const O_LARGEFILE: ::c_int = 0x2000;
-
-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;
-pub const SYS_statx: ::c_long = 4000 + 366;
-
-pub const O_DIRECT: ::c_int = 0x8000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-
-pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 6;
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9;
-
-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 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 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 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_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_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_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_WIFI_STATUS: ::c_int = 41;
-pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS;
-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_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 FIOCLEX: ::c_ulong = 0x6601;
-pub const FIONCLEX: ::c_ulong = 0x6602;
-pub const FIONBIO: ::c_ulong = 0x667e;
-
-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 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 PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-
-pub const MAP_HUGETLB: ::c_int = 0x080000;
-
-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 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 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_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_RNG: ::c_int = 0x200;
-pub const TIOCM_DSR: ::c_int = 0x400;
-
-pub const EHWPOISON: ::c_int = 168;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/mod.rs b/libc/src/unix/linux_like/linux/gnu/b32/mod.rs
deleted file mode 100644
index cc6b636..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/mod.rs
+++ /dev/null
@@ -1,271 +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 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;
-pub type __fsword_t = i32;
-
-s! {
- pub struct stat {
- #[cfg(not(target_arch = "mips"))]
- pub st_dev: ::dev_t,
- #[cfg(target_arch = "mips")]
- pub st_dev: ::c_ulong,
-
- #[cfg(not(target_arch = "mips"))]
- __pad1: ::c_short,
- #[cfg(target_arch = "mips")]
- st_pad1: [::c_long; 3],
- pub st_ino: ::ino_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- #[cfg(not(target_arch = "mips"))]
- pub st_rdev: ::dev_t,
- #[cfg(target_arch = "mips")]
- pub st_rdev: ::c_ulong,
- #[cfg(not(target_arch = "mips"))]
- __pad2: ::c_short,
- #[cfg(target_arch = "mips")]
- st_pad2: [::c_long; 2],
- pub st_size: ::off_t,
- #[cfg(target_arch = "mips")]
- st_pad3: ::c_long,
- #[cfg(not(target_arch = "mips"))]
- pub st_blksize: ::blksize_t,
- #[cfg(not(target_arch = "mips"))]
- 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,
- #[cfg(not(target_arch = "mips"))]
- __unused4: ::c_long,
- #[cfg(not(target_arch = "mips"))]
- __unused5: ::c_long,
- #[cfg(target_arch = "mips")]
- pub st_blksize: ::blksize_t,
- #[cfg(target_arch = "mips")]
- pub st_blocks: ::blkcnt_t,
- #[cfg(target_arch = "mips")]
- st_pad5: [::c_long; 14],
- }
-
- 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,
- #[deprecated(
- since = "0.2.58",
- note = "This padding field might become private in the future"
- )]
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub _f: [::c_char; 8],
- }
-}
-
-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 SO_PRIORITY: ::c_int = 12;
-pub const SO_BSDCOMPAT: ::c_int = 14;
-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 SA_ONSTACK: ::c_int = 0x08000000;
-
-pub const PTRACE_DETACH: ::c_uint = 17;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-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_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 "C" {
- 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 = "mips")] {
- mod mips;
- pub use self::mips::*;
- } else if #[cfg(target_arch = "powerpc")] {
- mod powerpc;
- pub use self::powerpc::*;
- } else if #[cfg(target_arch = "sparc")] {
- mod sparc;
- pub use self::sparc::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs
deleted file mode 100644
index 7644428..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs
+++ /dev/null
@@ -1,873 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = i32;
-
-s! {
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct ipc_perm {
- __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 struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-}
-
-pub const RLIM_INFINITY: ::rlim_t = !0;
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const O_DIRECT: ::c_int = 0x20000;
-pub const O_DIRECTORY: ::c_int = 0x4000;
-pub const O_NOFOLLOW: ::c_int = 0x8000;
-pub const O_LARGEFILE: ::c_int = 0o200000;
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6;
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-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 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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_LOCKED: ::c_int = 0x00080;
-pub const MAP_NORESERVE: ::c_int = 0x00040;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-pub const EDEADLOCK: ::c_int = 58;
-pub const EUCLEAN: ::c_int = 117;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENAVAIL: ::c_int = 119;
-pub const EISNAM: ::c_int = 120;
-pub const EREMOTEIO: ::c_int = 121;
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const 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_ACCEPTCONN: ::c_int = 30;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-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 SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const FIOCLEX: ::c_ulong = 0x20006601;
-pub const FIONCLEX: ::c_ulong = 0x20006602;
-pub const FIONBIO: ::c_ulong = 0x8004667e;
-
-pub const MCL_CURRENT: ::c_int = 0x2000;
-pub const MCL_FUTURE: ::c_int = 0x4000;
-
-pub const POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_SETOWN: ::c_int = 8;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-pub const SFD_NONBLOCK: ::c_int = 0x0800;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-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 SIGCHLD: ::c_int = 17;
-pub const SIGBUS: ::c_int = 7;
-pub const SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-pub const SIGTTIN: ::c_int = 21;
-pub const SIGTTOU: ::c_int = 22;
-pub const SIGXCPU: ::c_int = 24;
-pub const SIGXFSZ: ::c_int = 25;
-pub const SIGVTALRM: ::c_int = 26;
-pub const SIGPROF: ::c_int = 27;
-pub const SIGWINCH: ::c_int = 28;
-pub const SIGSTKSZ: ::size_t = 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/linux_like/linux/gnu/b32/sparc/align.rs b/libc/src/unix/linux_like/linux/gnu/b32/sparc/align.rs
deleted file mode 100644
index 98fda88..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/sparc/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [i64; 3]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
deleted file mode 100644
index f670b34..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
+++ /dev/null
@@ -1,978 +0,0 @@
-//! SPARC-specific definitions for 32-bit linux-like values
-
-pub type c_char = u8;
-pub type wchar_t = i32;
-
-s! {
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- __reserved: ::c_short,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- pub struct stat {
- 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,
- __unused: [::c_long; 2],
- }
-
- 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,
- __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 ipc_perm {
- pub __key: ::key_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- pub cuid: ::uid_t,
- pub cgid: ::gid_t,
- __pad1: ::c_ushort,
- pub mode: ::c_ushort,
- __pad2: ::c_ushort,
- pub __seq: ::c_ushort,
- __unused1: ::c_ulonglong,
- __unused2: ::c_ulonglong,
- }
-
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- __pad1: ::c_uint,
- pub shm_atime: ::time_t,
- __pad2: ::c_uint,
- pub shm_dtime: ::time_t,
- __pad3: ::c_uint,
- 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 msqid_ds {
- pub msg_perm: ::ipc_perm,
- __pad1: ::c_uint,
- pub msg_stime: ::time_t,
- __pad2: ::c_uint,
- pub msg_rtime: ::time_t,
- __pad3: ::c_uint,
- pub msg_ctime: ::time_t,
- __msg_cbytes: ::c_ushort,
- pub msg_qnum: ::msgqnum_t,
- pub msg_qbytes: ::msglen_t,
- pub msg_lspid: ::pid_t,
- pub msg_lrpid: ::pid_t,
- __glibc_reserved1: ::c_ulong,
- __glibc_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 POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const RLIM_INFINITY: ::rlim_t = !0;
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465;
-
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_GROWSDOWN: ::c_int = 0x0200;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const 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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const SA_ONSTACK: ::c_int = 1;
-pub const SA_SIGINFO: ::c_int = 0x200;
-pub const SA_NOCLDWAIT: ::c_int = 0x100;
-
-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 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 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 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 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 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 O_DIRECTORY: ::c_int = 0o200000;
-pub const O_NOFOLLOW: ::c_int = 0o400000;
-pub const O_LARGEFILE: ::c_int = 0x40000;
-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 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 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 FIONCLEX: ::c_ulong = 0x20006602;
-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_lchown32: ::c_long = 31;
-pub const SYS_fchown32: ::c_long = 32;
-pub const SYS_access: ::c_long = 33;
-pub const SYS_nice: ::c_long = 34;
-pub const SYS_chown32: ::c_long = 35;
-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_getuid32: ::c_long = 44;
-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_getgid32: ::c_long = 53;
-pub const SYS_ioctl: ::c_long = 54;
-pub const SYS_reboot: ::c_long = 55;
-pub const SYS_mmap2: ::c_long = 56;
-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_geteuid32: ::c_long = 69;
-pub const SYS_getegid32: ::c_long = 70;
-pub const SYS_mmap: ::c_long = 71;
-pub const SYS_setreuid32: ::c_long = 72;
-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_truncate64: ::c_long = 77;
-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_setgroups32: ::c_long = 82;
-pub const SYS_setitimer: ::c_long = 83;
-pub const SYS_ftruncate64: ::c_long = 84;
-pub const SYS_swapon: ::c_long = 85;
-pub const SYS_getitimer: ::c_long = 86;
-pub const SYS_setuid32: ::c_long = 87;
-pub const SYS_sethostname: ::c_long = 88;
-pub const SYS_setgid32: ::c_long = 89;
-pub const SYS_dup2: ::c_long = 90;
-pub const SYS_setfsuid32: ::c_long = 91;
-pub const SYS_fcntl: ::c_long = 92;
-pub const SYS_select: ::c_long = 93;
-pub const SYS_setfsgid32: ::c_long = 94;
-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_setresuid32: ::c_long = 108;
-pub const SYS_getresuid32: ::c_long = 109;
-pub const SYS_setresgid32: ::c_long = 110;
-pub const SYS_getresgid32: ::c_long = 111;
-pub const SYS_setregid32: ::c_long = 112;
-pub const SYS_recvmsg: ::c_long = 113;
-pub const SYS_sendmsg: ::c_long = 114;
-pub const SYS_getgroups32: ::c_long = 115;
-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_fcntl64: ::c_long = 155;
-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_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_time: ::c_long = 231;
-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 "C" {
- 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(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/x86/align.rs b/libc/src/unix/linux_like/linux/gnu/b32/x86/align.rs
deleted file mode 100644
index 9663474..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/x86/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 6]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs
deleted file mode 100644
index f5f7cac..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs
+++ /dev/null
@@ -1,1164 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type greg_t = i32;
-
-s! {
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<extern fn()>,
- }
-
- pub struct statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct _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,
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-}
-
-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 RLIM_INFINITY: ::rlim_t = !0;
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const O_LARGEFILE: ::c_int = 0o0100000;
-pub const O_APPEND: ::c_int = 1024;
-pub const O_CREAT: ::c_int = 64;
-pub const O_EXCL: ::c_int = 128;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const O_RSYNC: ::c_int = 1052672;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_FSYNC: ::c_int = 0x101000;
-pub const O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6;
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-
-pub const SOL_SOCKET: ::c_int = 1;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_32BIT: ::c_int = 0x0040;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const EDEADLOCK: ::c_int = 35;
-pub const EUCLEAN: ::c_int = 117;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENAVAIL: ::c_int = 119;
-pub const EISNAM: ::c_int = 120;
-pub const EREMOTEIO: ::c_int = 121;
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const 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_ACCEPTCONN: ::c_int = 30;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_DOMAIN: ::c_int = 39;
-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 SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const F_GETLK: ::c_int = 5;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_SETOWN: ::c_int = 8;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONCLEX: ::c_ulong = 0x5450;
-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 POLLWRNORM: ::c_short = 0x100;
-pub const POLLWRBAND: ::c_short = 0x200;
-
-pub const EFD_NONBLOCK: ::c_int = 0x800;
-pub const SFD_NONBLOCK: ::c_int = 0x0800;
-
-pub const SIGCHLD: ::c_int = 17;
-pub const SIGBUS: ::c_int = 7;
-pub const SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGTSTP: ::c_int = 20;
-pub const SIGURG: ::c_int = 23;
-pub const SIGIO: ::c_int = 29;
-pub const SIGSYS: ::c_int = 31;
-pub const SIGSTKFLT: ::c_int = 16;
-#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
-pub const SIGUNUSED: ::c_int = 31;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPWR: ::c_int = 30;
-pub const SIG_SETMASK: ::c_int = 2;
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-pub const SIGTTIN: ::c_int = 21;
-pub const SIGTTOU: ::c_int = 22;
-pub const SIGXCPU: ::c_int = 24;
-pub const SIGXFSZ: ::c_int = 25;
-pub const SIGVTALRM: ::c_int = 26;
-pub const SIGPROF: ::c_int = 27;
-pub const SIGWINCH: ::c_int = 28;
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 0o0010017;
-pub const TAB1: ::tcflag_t = 0x00000800;
-pub const TAB2: ::tcflag_t = 0x00001000;
-pub const TAB3: ::tcflag_t = 0x00001800;
-pub const CR1: ::tcflag_t = 0x00000200;
-pub const CR2: ::tcflag_t = 0x00000400;
-pub const CR3: ::tcflag_t = 0x00000600;
-pub const FF1: ::tcflag_t = 0x00008000;
-pub const BS1: ::tcflag_t = 0x00002000;
-pub const VT1: ::tcflag_t = 0x00004000;
-pub const VWERASE: usize = 14;
-pub const VREPRINT: usize = 12;
-pub const VSUSP: usize = 10;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VDISCARD: usize = 13;
-pub const VTIME: usize = 5;
-pub const IXON: ::tcflag_t = 0x00000400;
-pub const IXOFF: ::tcflag_t = 0x00001000;
-pub const ONLCR: ::tcflag_t = 0x4;
-pub const CSIZE: ::tcflag_t = 0x00000030;
-pub const CS6: ::tcflag_t = 0x00000010;
-pub const CS7: ::tcflag_t = 0x00000020;
-pub const CS8: ::tcflag_t = 0x00000030;
-pub const CSTOPB: ::tcflag_t = 0x00000040;
-pub const CREAD: ::tcflag_t = 0x00000080;
-pub const PARENB: ::tcflag_t = 0x00000100;
-pub const PARODD: ::tcflag_t = 0x00000200;
-pub const HUPCL: ::tcflag_t = 0x00000400;
-pub const CLOCAL: ::tcflag_t = 0x00000800;
-pub const ECHOKE: ::tcflag_t = 0x00000800;
-pub const ECHOE: ::tcflag_t = 0x00000010;
-pub const ECHOK: ::tcflag_t = 0x00000020;
-pub const ECHONL: ::tcflag_t = 0x00000040;
-pub const ECHOPRT: ::tcflag_t = 0x00000400;
-pub const ECHOCTL: ::tcflag_t = 0x00000200;
-pub const ISIG: ::tcflag_t = 0x00000001;
-pub const ICANON: ::tcflag_t = 0x00000002;
-pub const PENDIN: ::tcflag_t = 0x00004000;
-pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CIBAUD: ::tcflag_t = 0o02003600000;
-pub const CBAUDEX: ::tcflag_t = 0o010000;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 0o000002;
-pub const NLDLY: ::tcflag_t = 0o000400;
-pub const CRDLY: ::tcflag_t = 0o003000;
-pub const TABDLY: ::tcflag_t = 0o014000;
-pub const BSDLY: ::tcflag_t = 0o020000;
-pub const FFDLY: ::tcflag_t = 0o100000;
-pub const VTDLY: ::tcflag_t = 0o040000;
-pub const XTABS: ::tcflag_t = 0o014000;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-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 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;
-
-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 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;
-
-// 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 "C" {
- 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 "C" 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::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs b/libc/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs
deleted file mode 100644
index 8e94996..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f32; 8]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
deleted file mode 100644
index 93f0f2b..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
+++ /dev/null
@@ -1,954 +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 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 statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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 struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-}
-
-pub const VEOF: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-
-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_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-
-pub const EUCLEAN: ::c_int = 117;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENAVAIL: ::c_int = 119;
-pub const EISNAM: ::c_int = 120;
-pub const EREMOTEIO: ::c_int = 121;
-pub const EDEADLK: ::c_int = 35;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ELOOP: ::c_int = 40;
-pub const ENOMSG: ::c_int = 42;
-pub const EIDRM: ::c_int = 43;
-pub const ECHRNG: ::c_int = 44;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELNRNG: ::c_int = 48;
-pub const EUNATCH: ::c_int = 49;
-pub const ENOCSI: ::c_int = 50;
-pub const EL2HLT: ::c_int = 51;
-pub const EBADE: ::c_int = 52;
-pub const EBADR: ::c_int = 53;
-pub const EXFULL: ::c_int = 54;
-pub const ENOANO: ::c_int = 55;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const EMULTIHOP: ::c_int = 72;
-pub const EOVERFLOW: ::c_int = 75;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EBADFD: ::c_int = 77;
-pub const EBADMSG: ::c_int = 74;
-pub const EREMCHG: ::c_int = 78;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83;
-pub const EILSEQ: ::c_int = 84;
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86;
-pub const EUSERS: ::c_int = 87;
-pub const ENOTSOCK: ::c_int = 88;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EPROTOTYPE: ::c_int = 91;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const EPROTONOSUPPORT: ::c_int = 93;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103;
-pub const ECONNRESET: ::c_int = 104;
-pub const ENOBUFS: ::c_int = 105;
-pub const EISCONN: ::c_int = 106;
-pub const ENOTCONN: ::c_int = 107;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const ETIMEDOUT: ::c_int = 110;
-pub const ECONNREFUSED: ::c_int = 111;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EALREADY: ::c_int = 114;
-pub const EINPROGRESS: ::c_int = 115;
-pub const ESTALE: ::c_int = 116;
-pub const EDQUOT: ::c_int = 122;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const ECANCELED: ::c_int = 125;
-pub const ENOKEY: ::c_int = 126;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const EHWPOISON: ::c_int = 133;
-pub const ERFKILL: ::c_int = 132;
-
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-
-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 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 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 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 MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const EDEADLOCK: ::c_int = 35;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONCLEX: ::c_ulong = 0x5450;
-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;
-
-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;
-
-// 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;
-pub const SYS_statx: ::c_long = 291;
-
-#[link(name = "util")]
-extern "C" {
- 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(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/mips64/align.rs b/libc/src/unix/linux_like/linux/gnu/b64/mips64/align.rs
deleted file mode 100644
index 7ca870f..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/mips64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs
deleted file mode 100644
index a59554b..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs
+++ /dev/null
@@ -1,1017 +0,0 @@
-use pthread_mutex_t;
-
-pub type blksize_t = i64;
-pub type c_char = i8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type nlink_t = u64;
-pub type suseconds_t = i64;
-pub type wchar_t = i32;
-pub type __u64 = ::c_ulong;
-
-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 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 flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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 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 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 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;
-
-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 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;
-pub const SYS_statx: ::c_long = 5000 + 326;
-
-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 POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
-
-pub const EFD_CLOEXEC: ::c_int = 0x80000;
-
-pub const O_DIRECT: ::c_int = 0x8000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 6;
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9;
-
-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 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 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 MAP_HUGETLB: ::c_int = 0x080000;
-
-pub const SOCK_STREAM: ::c_int = 2;
-pub const SOCK_DGRAM: ::c_int = 1;
-
-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;
-
-pub const FIOCLEX: ::c_ulong = 0x6601;
-pub const FIONCLEX: ::c_ulong = 0x6602;
-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 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 PTRACE_GETFPREGS: ::c_uint = 14;
-pub const PTRACE_SETFPREGS: ::c_uint = 15;
-pub const PTRACE_DETACH: ::c_uint = 17;
-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_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 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_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_RNG: ::c_int = 0x200;
-pub const TIOCM_DSR: ::c_int = 0x400;
-
-pub const EHWPOISON: ::c_int = 168;
-
-#[link(name = "util")]
-extern "C" {
- 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(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/mod.rs
deleted file mode 100644
index 40ce844..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/mod.rs
+++ /dev/null
@@ -1,87 +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 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;
-pub type __fsword_t = i64;
-
-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 RLIM_INFINITY: ::rlim_t = !0;
-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 = "mips64"))] {
- mod mips64;
- pub use self::mips64::*;
- } else if #[cfg(any(target_arch = "s390x"))] {
- mod s390x;
- pub use self::s390x::*;
- } else if #[cfg(any(target_arch = "x86_64"))] {
- mod x86_64;
- pub use self::x86_64::*;
- } else if #[cfg(any(target_arch = "riscv64"))] {
- mod riscv64;
- pub use self::riscv64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs
deleted file mode 100644
index 29d1e1c..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [i64; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs
deleted file mode 100644
index 22507d7..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs
+++ /dev/null
@@ -1,1052 +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 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 statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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 struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-}
-
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const VEOF: usize = 4;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
-
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const 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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-
-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 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 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 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 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 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 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 FIOCLEX: ::c_ulong = 0x20006601;
-pub const FIONCLEX: ::c_ulong = 0x20006602;
-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 "C" {
- 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(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
deleted file mode 100644
index c45c5b2..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
+++ /dev/null
@@ -1,861 +0,0 @@
-//! RISC-V-specific definitions for 64-bit linux-like values
-
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type wchar_t = ::c_int;
-pub type time_t = ::c_long;
-
-pub type dev_t = ::c_ulong;
-pub type uid_t = ::c_uint;
-pub type gid_t = ::c_uint;
-pub type ino_t = ::c_ulong;
-pub type ino64_t = ::c_ulong;
-pub type mode_t = ::c_uint;
-pub type nlink_t = ::c_uint;
-pub type off_t = ::c_long;
-pub type off64_t = ::c_long;
-pub type pid_t = ::c_int;
-pub type blksize_t = ::c_int;
-pub type blkcnt_t = ::c_long;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsblkcnt64_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type fsfilcnt64_t = ::c_ulong;
-pub type suseconds_t = i64;
-pub type __u64 = ::c_ulonglong;
-
-s! {
- pub struct pthread_attr_t {
- __size: [::c_ulong; 7],
- }
-
- pub struct timespec {
- pub tv_sec: time_t,
- pub tv_nsec: ::c_long,
- }
-
- 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 __pad1: dev_t,
- pub st_size: off_t,
- pub st_blksize: blksize_t,
- pub __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,
- pub __unused: [::c_int; 2usize],
- }
-
- 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,
- pub __pad1: dev_t,
- pub st_size: off64_t,
- pub st_blksize: blksize_t,
- pub __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,
- pub __unused: [::c_int; 2],
- }
-
- pub struct statfs {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- 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_long,
- pub f_frsize: ::c_long,
- pub f_flags: ::c_long,
- pub f_spare: [::c_long; 4],
- }
-
- pub struct statfs64 {
- pub f_type: ::c_long,
- pub f_bsize: ::c_long,
- pub f_blocks: fsblkcnt64_t,
- pub f_bfree: fsblkcnt64_t,
- pub f_bavail: fsblkcnt64_t,
- pub f_files: fsfilcnt64_t,
- pub f_ffree: fsfilcnt64_t,
- pub f_fsid: ::fsid_t,
- pub f_namelen: ::c_long,
- pub f_frsize: ::c_long,
- pub f_flags: ::c_long,
- pub f_spare: [::c_long; 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,
- pub __f_spare: [::c_int; 6],
- }
-
- pub struct statvfs64 {
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_blocks: fsblkcnt64_t,
- pub f_bfree: fsblkcnt64_t,
- pub f_bavail: fsblkcnt64_t,
- pub f_files: fsfilcnt64_t,
- pub f_ffree: fsfilcnt64_t,
- pub f_favail: fsfilcnt64_t,
- pub f_fsid: ::c_ulong,
- pub f_flag: ::c_ulong,
- pub f_namemax: ::c_ulong,
- pub __f_spare: [::c_int; 6],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [u64; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t,
- }
-
- pub struct sigaction {
- pub sa_sigaction: ::sighandler_t,
- pub sa_mask: ::sigset_t,
- pub sa_flags: ::c_int,
- pub sa_restorer: ::Option<unsafe extern "C" fn()>,
- }
-
- pub struct sigset_t {
- pub __val: [::c_ulong; 16],
- }
-
- 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 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,
- pub __unused5: ::c_ulong,
- pub __unused6: ::c_ulong,
- }
-
- 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 const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-pub const VEOF: usize = 4;
-pub const TIOCGSOFTCAR: ::c_ulong = 21529;
-pub const TIOCSSOFTCAR: ::c_ulong = 21530;
-pub const TIOCGRS485: ::c_int = 21550;
-pub const TIOCSRS485: ::c_int = 21551;
-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 = 1052672;
-pub const O_NOATIME: ::c_int = 262144;
-pub const O_PATH: ::c_int = 2097152;
-pub const O_TMPFILE: ::c_int = 4259840;
-pub const MAP_GROWSDOWN: ::c_int = 256;
-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 = 26;
-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 = 35;
-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 = 41;
-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 = 27;
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SA_ONSTACK: ::c_int = 134217728;
-pub const SA_SIGINFO: ::c_int = 4;
-pub const SA_NOCLDWAIT: ::c_int = 2;
-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 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;
-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 = 0;
-pub const SIG_UNBLOCK: ::c_int = 1;
-pub const POLLWRNORM: ::c_short = 256;
-pub const POLLWRBAND: ::c_short = 512;
-pub const O_ASYNC: ::c_int = 8192;
-pub const O_NDELAY: ::c_int = 2048;
-pub const PTRACE_DETACH: ::c_uint = 17;
-pub const EFD_NONBLOCK: ::c_int = 2048;
-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 = 2048;
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 1;
-pub const TCSAFLUSH: ::c_int = 2;
-pub const TIOCLINUX: ::c_ulong = 21532;
-pub const TIOCGSERIAL: ::c_ulong = 21534;
-pub const TIOCEXCL: ::c_ulong = 21516;
-pub const TIOCNXCL: ::c_ulong = 21517;
-pub const TIOCSCTTY: ::c_ulong = 21518;
-pub const TIOCSTI: ::c_ulong = 21522;
-pub const TIOCMGET: ::c_ulong = 21525;
-pub const TIOCMBIS: ::c_ulong = 21526;
-pub const TIOCMBIC: ::c_ulong = 21527;
-pub const TIOCMSET: ::c_ulong = 21528;
-pub const TIOCCONS: ::c_ulong = 21533;
-pub const TIOCM_ST: ::c_int = 8;
-pub const TIOCM_SR: ::c_int = 16;
-pub const TIOCM_CTS: ::c_int = 32;
-pub const TIOCM_CAR: ::c_int = 64;
-pub const TIOCM_RNG: ::c_int = 128;
-pub const TIOCM_DSR: ::c_int = 256;
-pub const SFD_CLOEXEC: ::c_int = 524288;
-pub const NCCS: usize = 32;
-pub const O_TRUNC: ::c_int = 512;
-pub const O_CLOEXEC: ::c_int = 524288;
-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 = 1073741824;
-pub const SA_RESETHAND: ::c_int = -2147483648;
-pub const SA_RESTART: ::c_int = 268435456;
-pub const SA_NOCLDSTOP: ::c_int = 1;
-pub const EPOLL_CLOEXEC: ::c_int = 524288;
-pub const EFD_CLOEXEC: ::c_int = 524288;
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-pub const O_DIRECT: ::c_int = 16384;
-pub const O_DIRECTORY: ::c_int = 65536;
-pub const O_NOFOLLOW: ::c_int = 131072;
-pub const MAP_HUGETLB: ::c_int = 262144;
-pub const MAP_LOCKED: ::c_int = 8192;
-pub const MAP_NORESERVE: ::c_int = 16384;
-pub const MAP_ANON: ::c_int = 32;
-pub const MAP_ANONYMOUS: ::c_int = 32;
-pub const MAP_DENYWRITE: ::c_int = 2048;
-pub const MAP_EXECUTABLE: ::c_int = 4096;
-pub const MAP_POPULATE: ::c_int = 32768;
-pub const MAP_NONBLOCK: ::c_int = 65536;
-pub const MAP_STACK: ::c_int = 131072;
-pub const EDEADLOCK: ::c_int = 35;
-pub const EUCLEAN: ::c_int = 117;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENAVAIL: ::c_int = 119;
-pub const EISNAM: ::c_int = 120;
-pub const EREMOTEIO: ::c_int = 121;
-pub const FIOCLEX: ::c_ulong = 21585;
-pub const FIONCLEX: ::c_ulong = 21584;
-pub const FIONBIO: ::c_ulong = 21537;
-pub const MCL_CURRENT: ::c_int = 1;
-pub const MCL_FUTURE: ::c_int = 2;
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-pub const CBAUD: ::tcflag_t = 4111;
-pub const TAB1: ::tcflag_t = 2048;
-pub const TAB2: ::tcflag_t = 4096;
-pub const TAB3: ::tcflag_t = 6144;
-pub const CR1: ::tcflag_t = 512;
-pub const CR2: ::tcflag_t = 1024;
-pub const CR3: ::tcflag_t = 1536;
-pub const FF1: ::tcflag_t = 32768;
-pub const BS1: ::tcflag_t = 8192;
-pub const VT1: ::tcflag_t = 16384;
-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 = 1024;
-pub const IXOFF: ::tcflag_t = 4096;
-pub const ONLCR: ::tcflag_t = 4;
-pub const CSIZE: ::tcflag_t = 48;
-pub const CS6: ::tcflag_t = 16;
-pub const CS7: ::tcflag_t = 32;
-pub const CS8: ::tcflag_t = 48;
-pub const CSTOPB: ::tcflag_t = 64;
-pub const CREAD: ::tcflag_t = 128;
-pub const PARENB: ::tcflag_t = 256;
-pub const PARODD: ::tcflag_t = 512;
-pub const HUPCL: ::tcflag_t = 1024;
-pub const CLOCAL: ::tcflag_t = 2048;
-pub const ECHOKE: ::tcflag_t = 2048;
-pub const ECHOE: ::tcflag_t = 16;
-pub const ECHOK: ::tcflag_t = 32;
-pub const ECHONL: ::tcflag_t = 64;
-pub const ECHOPRT: ::tcflag_t = 1024;
-pub const ECHOCTL: ::tcflag_t = 512;
-pub const ISIG: ::tcflag_t = 1;
-pub const ICANON: ::tcflag_t = 2;
-pub const PENDIN: ::tcflag_t = 16384;
-pub const NOFLSH: ::tcflag_t = 128;
-pub const CIBAUD: ::tcflag_t = 269418496;
-pub const CBAUDEX: ::tcflag_t = 4096;
-pub const VSWTC: usize = 7;
-pub const OLCUC: ::tcflag_t = 2;
-pub const NLDLY: ::tcflag_t = 256;
-pub const CRDLY: ::tcflag_t = 1536;
-pub const TABDLY: ::tcflag_t = 6144;
-pub const BSDLY: ::tcflag_t = 8192;
-pub const FFDLY: ::tcflag_t = 32768;
-pub const VTDLY: ::tcflag_t = 16384;
-pub const XTABS: ::tcflag_t = 6144;
-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 EXTA: ::speed_t = 14;
-pub const EXTB: ::speed_t = 15;
-pub const B57600: ::speed_t = 4097;
-pub const B115200: ::speed_t = 4098;
-pub const B230400: ::speed_t = 4099;
-pub const B460800: ::speed_t = 4100;
-pub const B500000: ::speed_t = 4101;
-pub const B576000: ::speed_t = 4102;
-pub const B921600: ::speed_t = 4103;
-pub const B1000000: ::speed_t = 4104;
-pub const B1152000: ::speed_t = 4105;
-pub const B1500000: ::speed_t = 4106;
-pub const B2000000: ::speed_t = 4107;
-pub const B2500000: ::speed_t = 4108;
-pub const B3000000: ::speed_t = 4109;
-pub const B3500000: ::speed_t = 4110;
-pub const B4000000: ::speed_t = 4111;
-pub const VEOL: usize = 11;
-pub const VEOL2: usize = 16;
-pub const VMIN: usize = 6;
-pub const IEXTEN: ::tcflag_t = 32768;
-pub const TOSTOP: ::tcflag_t = 256;
-pub const FLUSHO: ::tcflag_t = 4096;
-pub const EXTPROC: ::tcflag_t = 65536;
-pub const TCGETS: ::c_ulong = 21505;
-pub const TCSETS: ::c_ulong = 21506;
-pub const TCSETSW: ::c_ulong = 21507;
-pub const TCSETSF: ::c_ulong = 21508;
-pub const TCGETA: ::c_ulong = 21509;
-pub const TCSETA: ::c_ulong = 21510;
-pub const TCSETAW: ::c_ulong = 21511;
-pub const TCSETAF: ::c_ulong = 21512;
-pub const TCSBRK: ::c_ulong = 21513;
-pub const TCXONC: ::c_ulong = 21514;
-pub const TCFLSH: ::c_ulong = 21515;
-pub const TIOCINQ: ::c_ulong = 21531;
-pub const TIOCGPGRP: ::c_ulong = 21519;
-pub const TIOCSPGRP: ::c_ulong = 21520;
-pub const TIOCOUTQ: ::c_ulong = 21521;
-pub const TIOCGWINSZ: ::c_ulong = 21523;
-pub const TIOCSWINSZ: ::c_ulong = 21524;
-pub const FIONREAD: ::c_ulong = 21531;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-pub const SYS_read: ::c_long = 63;
-pub const SYS_write: ::c_long = 64;
-pub const SYS_close: ::c_long = 57;
-pub const SYS_fstat: ::c_long = 80;
-pub const SYS_lseek: ::c_long = 62;
-pub const SYS_mmap: ::c_long = 222;
-pub const SYS_mprotect: ::c_long = 226;
-pub const SYS_munmap: ::c_long = 215;
-pub const SYS_brk: ::c_long = 214;
-pub const SYS_rt_sigaction: ::c_long = 134;
-pub const SYS_rt_sigprocmask: ::c_long = 135;
-pub const SYS_rt_sigreturn: ::c_long = 139;
-pub const SYS_ioctl: ::c_long = 29;
-pub const SYS_pread64: ::c_long = 67;
-pub const SYS_pwrite64: ::c_long = 68;
-pub const SYS_readv: ::c_long = 65;
-pub const SYS_writev: ::c_long = 66;
-pub const SYS_sched_yield: ::c_long = 124;
-pub const SYS_mremap: ::c_long = 216;
-pub const SYS_msync: ::c_long = 227;
-pub const SYS_mincore: ::c_long = 232;
-pub const SYS_madvise: ::c_long = 233;
-pub const SYS_shmget: ::c_long = 194;
-pub const SYS_shmat: ::c_long = 196;
-pub const SYS_shmctl: ::c_long = 195;
-pub const SYS_dup: ::c_long = 23;
-pub const SYS_nanosleep: ::c_long = 101;
-pub const SYS_getitimer: ::c_long = 102;
-pub const SYS_setitimer: ::c_long = 103;
-pub const SYS_getpid: ::c_long = 172;
-pub const SYS_sendfile: ::c_long = 71;
-pub const SYS_socket: ::c_long = 198;
-pub const SYS_connect: ::c_long = 203;
-pub const SYS_accept: ::c_long = 202;
-pub const SYS_sendto: ::c_long = 206;
-pub const SYS_recvfrom: ::c_long = 207;
-pub const SYS_sendmsg: ::c_long = 211;
-pub const SYS_recvmsg: ::c_long = 212;
-pub const SYS_shutdown: ::c_long = 210;
-pub const SYS_bind: ::c_long = 200;
-pub const SYS_listen: ::c_long = 201;
-pub const SYS_getsockname: ::c_long = 204;
-pub const SYS_getpeername: ::c_long = 205;
-pub const SYS_socketpair: ::c_long = 199;
-pub const SYS_setsockopt: ::c_long = 208;
-pub const SYS_getsockopt: ::c_long = 209;
-pub const SYS_clone: ::c_long = 220;
-pub const SYS_execve: ::c_long = 221;
-pub const SYS_exit: ::c_long = 93;
-pub const SYS_wait4: ::c_long = 260;
-pub const SYS_kill: ::c_long = 129;
-pub const SYS_uname: ::c_long = 160;
-pub const SYS_semget: ::c_long = 190;
-pub const SYS_semop: ::c_long = 193;
-pub const SYS_semctl: ::c_long = 191;
-pub const SYS_shmdt: ::c_long = 197;
-pub const SYS_msgget: ::c_long = 186;
-pub const SYS_msgsnd: ::c_long = 189;
-pub const SYS_msgrcv: ::c_long = 188;
-pub const SYS_msgctl: ::c_long = 187;
-pub const SYS_fcntl: ::c_long = 25;
-pub const SYS_flock: ::c_long = 32;
-pub const SYS_fsync: ::c_long = 82;
-pub const SYS_fdatasync: ::c_long = 83;
-pub const SYS_truncate: ::c_long = 45;
-pub const SYS_ftruncate: ::c_long = 46;
-pub const SYS_getcwd: ::c_long = 17;
-pub const SYS_chdir: ::c_long = 49;
-pub const SYS_fchdir: ::c_long = 50;
-pub const SYS_fchmod: ::c_long = 52;
-pub const SYS_fchown: ::c_long = 55;
-pub const SYS_umask: ::c_long = 166;
-pub const SYS_gettimeofday: ::c_long = 169;
-pub const SYS_getrlimit: ::c_long = 163;
-pub const SYS_getrusage: ::c_long = 165;
-pub const SYS_sysinfo: ::c_long = 179;
-pub const SYS_times: ::c_long = 153;
-pub const SYS_ptrace: ::c_long = 117;
-pub const SYS_getuid: ::c_long = 174;
-pub const SYS_syslog: ::c_long = 116;
-pub const SYS_getgid: ::c_long = 176;
-pub const SYS_setuid: ::c_long = 146;
-pub const SYS_setgid: ::c_long = 144;
-pub const SYS_geteuid: ::c_long = 175;
-pub const SYS_getegid: ::c_long = 177;
-pub const SYS_setpgid: ::c_long = 154;
-pub const SYS_getppid: ::c_long = 173;
-pub const SYS_setsid: ::c_long = 157;
-pub const SYS_setreuid: ::c_long = 145;
-pub const SYS_setregid: ::c_long = 143;
-pub const SYS_getgroups: ::c_long = 158;
-pub const SYS_setgroups: ::c_long = 159;
-pub const SYS_setresuid: ::c_long = 147;
-pub const SYS_getresuid: ::c_long = 148;
-pub const SYS_setresgid: ::c_long = 149;
-pub const SYS_getresgid: ::c_long = 150;
-pub const SYS_getpgid: ::c_long = 155;
-pub const SYS_setfsuid: ::c_long = 151;
-pub const SYS_setfsgid: ::c_long = 152;
-pub const SYS_getsid: ::c_long = 156;
-pub const SYS_capget: ::c_long = 90;
-pub const SYS_capset: ::c_long = 91;
-pub const SYS_rt_sigpending: ::c_long = 136;
-pub const SYS_rt_sigtimedwait: ::c_long = 137;
-pub const SYS_rt_sigqueueinfo: ::c_long = 138;
-pub const SYS_rt_sigsuspend: ::c_long = 133;
-pub const SYS_sigaltstack: ::c_long = 132;
-pub const SYS_personality: ::c_long = 92;
-pub const SYS_statfs: ::c_long = 43;
-pub const SYS_fstatfs: ::c_long = 44;
-pub const SYS_getpriority: ::c_long = 141;
-pub const SYS_setpriority: ::c_long = 140;
-pub const SYS_sched_setparam: ::c_long = 118;
-pub const SYS_sched_getparam: ::c_long = 121;
-pub const SYS_sched_setscheduler: ::c_long = 119;
-pub const SYS_sched_getscheduler: ::c_long = 120;
-pub const SYS_sched_get_priority_max: ::c_long = 125;
-pub const SYS_sched_get_priority_min: ::c_long = 126;
-pub const SYS_sched_rr_get_interval: ::c_long = 127;
-pub const SYS_mlock: ::c_long = 228;
-pub const SYS_munlock: ::c_long = 229;
-pub const SYS_mlockall: ::c_long = 230;
-pub const SYS_munlockall: ::c_long = 231;
-pub const SYS_vhangup: ::c_long = 58;
-pub const SYS_pivot_root: ::c_long = 41;
-pub const SYS_prctl: ::c_long = 167;
-pub const SYS_adjtimex: ::c_long = 171;
-pub const SYS_setrlimit: ::c_long = 164;
-pub const SYS_chroot: ::c_long = 51;
-pub const SYS_sync: ::c_long = 81;
-pub const SYS_acct: ::c_long = 89;
-pub const SYS_settimeofday: ::c_long = 170;
-pub const SYS_mount: ::c_long = 40;
-pub const SYS_umount2: ::c_long = 39;
-pub const SYS_swapon: ::c_long = 224;
-pub const SYS_swapoff: ::c_long = 225;
-pub const SYS_reboot: ::c_long = 142;
-pub const SYS_sethostname: ::c_long = 161;
-pub const SYS_setdomainname: ::c_long = 162;
-pub const SYS_init_module: ::c_long = 105;
-pub const SYS_delete_module: ::c_long = 106;
-pub const SYS_quotactl: ::c_long = 60;
-pub const SYS_nfsservctl: ::c_long = 42;
-pub const SYS_gettid: ::c_long = 178;
-pub const SYS_readahead: ::c_long = 213;
-pub const SYS_setxattr: ::c_long = 5;
-pub const SYS_lsetxattr: ::c_long = 6;
-pub const SYS_fsetxattr: ::c_long = 7;
-pub const SYS_getxattr: ::c_long = 8;
-pub const SYS_lgetxattr: ::c_long = 9;
-pub const SYS_fgetxattr: ::c_long = 10;
-pub const SYS_listxattr: ::c_long = 11;
-pub const SYS_llistxattr: ::c_long = 12;
-pub const SYS_flistxattr: ::c_long = 13;
-pub const SYS_removexattr: ::c_long = 14;
-pub const SYS_lremovexattr: ::c_long = 15;
-pub const SYS_fremovexattr: ::c_long = 16;
-pub const SYS_tkill: ::c_long = 130;
-pub const SYS_futex: ::c_long = 98;
-pub const SYS_sched_setaffinity: ::c_long = 122;
-pub const SYS_sched_getaffinity: ::c_long = 123;
-pub const SYS_io_setup: ::c_long = 0;
-pub const SYS_io_destroy: ::c_long = 1;
-pub const SYS_io_getevents: ::c_long = 4;
-pub const SYS_io_submit: ::c_long = 2;
-pub const SYS_io_cancel: ::c_long = 3;
-pub const SYS_lookup_dcookie: ::c_long = 18;
-pub const SYS_remap_file_pages: ::c_long = 234;
-pub const SYS_getdents64: ::c_long = 61;
-pub const SYS_set_tid_address: ::c_long = 96;
-pub const SYS_restart_syscall: ::c_long = 128;
-pub const SYS_semtimedop: ::c_long = 192;
-pub const SYS_fadvise64: ::c_long = 223;
-pub const SYS_timer_create: ::c_long = 107;
-pub const SYS_timer_settime: ::c_long = 110;
-pub const SYS_timer_gettime: ::c_long = 108;
-pub const SYS_timer_getoverrun: ::c_long = 109;
-pub const SYS_timer_delete: ::c_long = 111;
-pub const SYS_clock_settime: ::c_long = 112;
-pub const SYS_clock_gettime: ::c_long = 113;
-pub const SYS_clock_getres: ::c_long = 114;
-pub const SYS_clock_nanosleep: ::c_long = 115;
-pub const SYS_exit_group: ::c_long = 94;
-pub const SYS_epoll_ctl: ::c_long = 21;
-pub const SYS_tgkill: ::c_long = 131;
-pub const SYS_mbind: ::c_long = 235;
-pub const SYS_set_mempolicy: ::c_long = 237;
-pub const SYS_get_mempolicy: ::c_long = 236;
-pub const SYS_mq_open: ::c_long = 180;
-pub const SYS_mq_unlink: ::c_long = 181;
-pub const SYS_mq_timedsend: ::c_long = 182;
-pub const SYS_mq_timedreceive: ::c_long = 183;
-pub const SYS_mq_notify: ::c_long = 184;
-pub const SYS_mq_getsetattr: ::c_long = 185;
-pub const SYS_kexec_load: ::c_long = 104;
-pub const SYS_waitid: ::c_long = 95;
-pub const SYS_add_key: ::c_long = 217;
-pub const SYS_request_key: ::c_long = 218;
-pub const SYS_keyctl: ::c_long = 219;
-pub const SYS_ioprio_set: ::c_long = 30;
-pub const SYS_ioprio_get: ::c_long = 31;
-pub const SYS_inotify_add_watch: ::c_long = 27;
-pub const SYS_inotify_rm_watch: ::c_long = 28;
-pub const SYS_migrate_pages: ::c_long = 238;
-pub const SYS_openat: ::c_long = 56;
-pub const SYS_mkdirat: ::c_long = 34;
-pub const SYS_mknodat: ::c_long = 33;
-pub const SYS_fchownat: ::c_long = 54;
-pub const SYS_newfstatat: ::c_long = 79;
-pub const SYS_unlinkat: ::c_long = 35;
-pub const SYS_linkat: ::c_long = 37;
-pub const SYS_symlinkat: ::c_long = 36;
-pub const SYS_readlinkat: ::c_long = 78;
-pub const SYS_fchmodat: ::c_long = 53;
-pub const SYS_faccessat: ::c_long = 48;
-pub const SYS_pselect6: ::c_long = 72;
-pub const SYS_ppoll: ::c_long = 73;
-pub const SYS_unshare: ::c_long = 97;
-pub const SYS_set_robust_list: ::c_long = 99;
-pub const SYS_get_robust_list: ::c_long = 100;
-pub const SYS_splice: ::c_long = 76;
-pub const SYS_tee: ::c_long = 77;
-pub const SYS_sync_file_range: ::c_long = 84;
-pub const SYS_vmsplice: ::c_long = 75;
-pub const SYS_move_pages: ::c_long = 239;
-pub const SYS_utimensat: ::c_long = 88;
-pub const SYS_epoll_pwait: ::c_long = 22;
-pub const SYS_timerfd_create: ::c_long = 85;
-pub const SYS_fallocate: ::c_long = 47;
-pub const SYS_timerfd_settime: ::c_long = 86;
-pub const SYS_timerfd_gettime: ::c_long = 87;
-pub const SYS_accept4: ::c_long = 242;
-pub const SYS_signalfd4: ::c_long = 74;
-pub const SYS_eventfd2: ::c_long = 19;
-pub const SYS_epoll_create1: ::c_long = 20;
-pub const SYS_dup3: ::c_long = 24;
-pub const SYS_pipe2: ::c_long = 59;
-pub const SYS_inotify_init1: ::c_long = 26;
-pub const SYS_preadv: ::c_long = 69;
-pub const SYS_pwritev: ::c_long = 70;
-pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
-pub const SYS_perf_event_open: ::c_long = 241;
-pub const SYS_recvmmsg: ::c_long = 243;
-pub const SYS_fanotify_init: ::c_long = 262;
-pub const SYS_fanotify_mark: ::c_long = 263;
-pub const SYS_prlimit64: ::c_long = 261;
-pub const SYS_name_to_handle_at: ::c_long = 264;
-pub const SYS_open_by_handle_at: ::c_long = 265;
-pub const SYS_clock_adjtime: ::c_long = 266;
-pub const SYS_syncfs: ::c_long = 267;
-pub const SYS_sendmmsg: ::c_long = 269;
-pub const SYS_setns: ::c_long = 268;
-pub const SYS_getcpu: ::c_long = 168;
-pub const SYS_process_vm_readv: ::c_long = 270;
-pub const SYS_process_vm_writev: ::c_long = 271;
-pub const SYS_kcmp: ::c_long = 272;
-pub const SYS_finit_module: ::c_long = 273;
-pub const SYS_sched_setattr: ::c_long = 274;
-pub const SYS_sched_getattr: ::c_long = 275;
-pub const SYS_renameat2: ::c_long = 276;
-pub const SYS_seccomp: ::c_long = 277;
-pub const SYS_getrandom: ::c_long = 278;
-pub const SYS_memfd_create: ::c_long = 279;
-pub const SYS_bpf: ::c_long = 280;
-pub const SYS_execveat: ::c_long = 281;
-pub const SYS_userfaultfd: ::c_long = 282;
-pub const SYS_membarrier: ::c_long = 283;
-pub const SYS_mlock2: ::c_long = 284;
-pub const SYS_copy_file_range: ::c_long = 285;
-pub const SYS_preadv2: ::c_long = 286;
-pub const SYS_pwritev2: ::c_long = 287;
-pub const SYS_pkey_mprotect: ::c_long = 288;
-pub const SYS_pkey_alloc: ::c_long = 289;
-pub const SYS_pkey_free: ::c_long = 290;
-pub const SYS_statx: ::c_long = 291;
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs b/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs
deleted file mode 100644
index cf0612a..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs
+++ /dev/null
@@ -1,1029 +0,0 @@
-//! s390x
-
-use pthread_mutex_t;
-
-pub type blksize_t = i64;
-pub type c_char = u8;
-pub type c_long = i64;
-pub type c_ulong = u64;
-pub type nlink_t = u64;
-pub type suseconds_t = i64;
-pub type wchar_t = i32;
-pub type greg_t = u64;
-pub type __u64 = u64;
-
-s! {
- 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 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 flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct 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 stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- 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 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 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 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 __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 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 POSIX_FADV_DONTNEED: ::c_int = 6;
-pub const POSIX_FADV_NOREUSE: ::c_int = 7;
-
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const 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 __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;
-
-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 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 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 FIONCLEX: ::c_ulong = 0x5450;
-pub const FIONBIO: ::c_ulong = 0x5421;
-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 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 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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6;
-
-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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_GROWSDOWN: ::c_int = 0x0100;
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const 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 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 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 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 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 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 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 O_ASYNC: ::c_int = 0x2000;
-pub const O_NDELAY: ::c_int = 0x800;
-
-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 PTRACE_DETACH: ::c_uint = 17;
-
-pub const MCL_CURRENT: ::c_int = 0x0001;
-pub const MCL_FUTURE: ::c_int = 0x0002;
-
-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 SFD_NONBLOCK: ::c_int = 0x0800;
-
-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 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 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 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 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 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 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;
-pub const SYS_statx: ::c_long = 379;
-
-#[link(name = "util")]
-extern "C" {
-
- 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 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 "C" fn(),
- argc: ::c_int,
- ...
- );
- pub fn swapcontext(
- uocp: *mut ::ucontext_t,
- ucp: *const ::ucontext_t,
- ) -> ::c_int;
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs b/libc/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs
deleted file mode 100644
index 29d1e1c..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [i64; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs
deleted file mode 100644
index 651ada3..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs
+++ /dev/null
@@ -1,988 +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 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 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 siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- __reserved: ::c_short,
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- 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 POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
-
-pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464;
-pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465;
-
-pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 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 MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_GROWSDOWN: ::c_int = 0x0200;
-pub const MAP_ANON: ::c_int = 0x0020;
-pub const MAP_ANONYMOUS: ::c_int = 0x0020;
-pub const MAP_DENYWRITE: ::c_int = 0x0800;
-pub const MAP_EXECUTABLE: ::c_int = 0x01000;
-pub const MAP_POPULATE: ::c_int = 0x08000;
-pub const MAP_NONBLOCK: ::c_int = 0x010000;
-pub const MAP_STACK: ::c_int = 0x020000;
-pub const MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const 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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const SA_ONSTACK: ::c_int = 1;
-pub const SA_SIGINFO: ::c_int = 0x200;
-pub const SA_NOCLDWAIT: ::c_int = 0x100;
-
-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 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 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 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 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 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 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 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 FIONCLEX: ::c_ulong = 0x20006602;
-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 "C" {
- 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(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs b/libc/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs
deleted file mode 100644
index 7ca870f..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
deleted file mode 100644
index 34e4da8..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
+++ /dev/null
@@ -1,929 +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 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 statfs {
- pub f_type: ::__fsword_t,
- pub f_bsize: ::__fsword_t,
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_fsid: ::fsid_t,
-
- pub f_namelen: ::__fsword_t,
- pub f_frsize: ::__fsword_t,
- f_spare: [::__fsword_t; 5],
- }
-
- pub struct flock {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off_t,
- pub l_len: ::off_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct flock64 {
- pub l_type: ::c_short,
- pub l_whence: ::c_short,
- pub l_start: ::off64_t,
- pub l_len: ::off64_t,
- pub l_pid: ::pid_t,
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- #[doc(hidden)]
- #[deprecated(
- since="0.2.54",
- note="Please leave a comment on \
- https://github.com/rust-lang/libc/pull/1316 if you're using \
- this field"
- )]
- pub _pad: [::c_int; 29],
- _align: [u64; 0],
- }
-
- pub struct stack_t {
- pub ss_sp: *mut ::c_void,
- pub ss_flags: ::c_int,
- pub ss_size: ::size_t
- }
-
- 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,
- }
-
- pub struct ip_mreqn {
- pub imr_multiaddr: ::in_addr,
- pub imr_address: ::in_addr,
- pub imr_ifindex: ::c_int,
- }
-}
-
-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],
- // FIXME: the shadow stack field requires glibc >= 2.28.
- // Re-add once we drop compatibility with glibc versions older than
- // 2.28.
- //
- // __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 POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-
-pub const VEOF: usize = 4;
-pub const RTLD_DEEPBIND: ::c_int = 0x8;
-pub const RTLD_GLOBAL: ::c_int = 0x100;
-pub const RTLD_NOLOAD: ::c_int = 0x4;
-pub const 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_RSS: ::__rlimit_resource_t = 5;
-pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
-pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
-pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
-pub const RLIMIT_NPROC: ::__rlimit_resource_t = 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 MADV_SOFT_OFFLINE: ::c_int = 101;
-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 SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-
-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 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 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 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 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 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_HUGETLB: ::c_int = 0x040000;
-pub const MAP_LOCKED: ::c_int = 0x02000;
-pub const MAP_NORESERVE: ::c_int = 0x04000;
-pub const MAP_32BIT: ::c_int = 0x0040;
-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 EDEADLOCK: ::c_int = 35;
-pub const EUCLEAN: ::c_int = 117;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENAVAIL: ::c_int = 119;
-pub const EISNAM: ::c_int = 120;
-pub const EREMOTEIO: ::c_int = 121;
-
-pub const FIOCLEX: ::c_ulong = 0x5451;
-pub const FIONCLEX: ::c_ulong = 0x5450;
-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 "C" {
- 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 "C" 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;
-}
-
-cfg_if! {
- if #[cfg(target_pointer_width = "32")] {
- mod x32;
- pub use self::x32::*;
- } else {
- mod not_x32;
- pub use self::not_x32::*;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs
deleted file mode 100644
index 64a6de9..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs
+++ /dev/null
@@ -1,423 +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 "C" {
- 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/linux_like/linux/gnu/b64/x86_64/x32.rs b/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs
deleted file mode 100644
index 3746881..0000000
--- a/libc/src/unix/linux_like/linux/gnu/b64/x86_64/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/linux_like/linux/gnu/mod.rs b/libc/src/unix/linux_like/linux/gnu/mod.rs
deleted file mode 100644
index 1d3e0ab..0000000
--- a/libc/src/unix/linux_like/linux/gnu/mod.rs
+++ /dev/null
@@ -1,1057 +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 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 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(any(
- target_arch = "sparc",
- target_arch = "sparc64",
- target_arch = "mips",
- target_arch = "mips64")))]
- pub c_ispeed: ::speed_t,
- #[cfg(not(any(
- target_arch = "sparc",
- target_arch = "sparc64",
- target_arch = "mips",
- target_arch = "mips64")))]
- pub c_ospeed: ::speed_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
- }
-
- pub unsafe fn si_value(&self) -> ::sigval {
- #[repr(C)]
- struct siginfo_timer {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- _si_tid: ::c_int,
- _si_overrun: ::c_int,
- si_sigval: ::sigval,
- }
- (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval
- }
-}
-
-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",
- target_arch = "s390x",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- pub ut_session: ::c_long,
- #[cfg(any(target_arch = "aarch64",
- target_arch = "s390x",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- pub ut_tv: ::timeval,
-
- #[cfg(not(any(target_arch = "aarch64",
- target_arch = "s390x",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64")))))]
- pub ut_session: i32,
- #[cfg(not(any(target_arch = "aarch64",
- target_arch = "s390x",
- 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 RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
-pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = 16;
-
-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 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_SHARED_VALIDATE: ::c_int = 0x3;
-pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000;
-
-pub const ENOTSUP: ::c_int = EOPNOTSUPP;
-
-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 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_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 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 SEEK_DATA: ::c_int = 3;
-pub const SEEK_HOLE: ::c_int = 4;
-
-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_DELNETCONF: u16 = 81;
-pub const RTM_NEWSTATS: u16 = 92;
-pub const RTM_GETSTATS: u16 = 94;
-pub const RTM_NEWCACHEREPORT: u16 = 96;
-
-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 MAX_LINKS: ::c_int = 32;
-
-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_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;
-
-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",
- target_arch = "s390x"
- ))] {
- pub const PTHREAD_STACK_MIN: ::size_t = 16384;
- } else if #[cfg(any(
- target_arch = "sparc",
- 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;
-
-extern "C" {
- 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 utmpname(file: *const ::c_char) -> ::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;
- pub fn getrandom(
- buf: *mut ::c_void,
- buflen: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
-}
-
-#[link(name = "util")]
-extern "C" {
- 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 "C" 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 ::passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut ::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;
- pub fn pthread_getname_np(
- thread: ::pthread_t,
- name: *mut ::c_char,
- len: ::size_t,
- ) -> ::c_int;
- pub fn pthread_setname_np(
- thread: ::pthread_t,
- name: *const ::c_char,
- ) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(any(target_arch = "x86",
- target_arch = "arm",
- target_arch = "mips",
- target_arch = "powerpc",
- target_arch = "sparc"))] {
- mod b32;
- pub use self::b32::*;
- } else if #[cfg(any(target_arch = "x86_64",
- target_arch = "aarch64",
- target_arch = "powerpc64",
- target_arch = "mips64",
- target_arch = "s390x",
- target_arch = "sparc64",
- target_arch = "riscv64"))] {
- 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/linux_like/linux/gnu/no_align.rs b/libc/src/unix/linux_like/linux/gnu/no_align.rs
deleted file mode 100644
index e32bf67..0000000
--- a/libc/src/unix/linux_like/linux/gnu/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/linux_like/linux/mod.rs b/libc/src/unix/linux_like/linux/mod.rs
deleted file mode 100644
index 80505ff..0000000
--- a/libc/src/unix/linux_like/linux/mod.rs
+++ /dev/null
@@ -1,3194 +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
- }
-
- pub struct sockaddr_vm {
- pub svm_family: ::sa_family_t,
- pub svm_reserved1: ::c_ushort,
- pub svm_port: ::c_uint,
- pub svm_cid: ::c_uint,
- pub svm_zero: [u8; 4]
- }
-}
-
-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;
-pub const IFLA_COST: ::c_ushort = 8;
-pub const IFLA_PRIORITY: ::c_ushort = 9;
-pub const IFLA_MASTER: ::c_ushort = 10;
-pub const IFLA_WIRELESS: ::c_ushort = 11;
-pub const IFLA_PROTINFO: ::c_ushort = 12;
-pub const IFLA_TXQLEN: ::c_ushort = 13;
-pub const IFLA_MAP: ::c_ushort = 14;
-pub const IFLA_WEIGHT: ::c_ushort = 15;
-pub const IFLA_OPERSTATE: ::c_ushort = 16;
-pub const IFLA_LINKMODE: ::c_ushort = 17;
-pub const IFLA_LINKINFO: ::c_ushort = 18;
-pub const IFLA_NET_NS_PID: ::c_ushort = 19;
-pub const IFLA_IFALIAS: ::c_ushort = 20;
-pub const IFLA_NUM_VF: ::c_ushort = 21;
-pub const IFLA_VFINFO_LIST: ::c_ushort = 22;
-pub const IFLA_STATS64: ::c_ushort = 23;
-pub const IFLA_VF_PORTS: ::c_ushort = 24;
-pub const IFLA_PORT_SELF: ::c_ushort = 25;
-pub const IFLA_AF_SPEC: ::c_ushort = 26;
-pub const IFLA_GROUP: ::c_ushort = 27;
-pub const IFLA_NET_NS_FD: ::c_ushort = 28;
-pub const IFLA_EXT_MASK: ::c_ushort = 29;
-pub const IFLA_PROMISCUITY: ::c_ushort = 30;
-pub const IFLA_NUM_TX_QUEUES: ::c_ushort = 31;
-pub const IFLA_NUM_RX_QUEUES: ::c_ushort = 32;
-pub const IFLA_CARRIER: ::c_ushort = 33;
-pub const IFLA_PHYS_PORT_ID: ::c_ushort = 34;
-pub const IFLA_CARRIER_CHANGES: ::c_ushort = 35;
-pub const IFLA_PHYS_SWITCH_ID: ::c_ushort = 36;
-pub const IFLA_LINK_NETNSID: ::c_ushort = 37;
-pub const IFLA_PHYS_PORT_NAME: ::c_ushort = 38;
-pub const IFLA_PROTO_DOWN: ::c_ushort = 39;
-
-pub const IFLA_INFO_UNSPEC: ::c_ushort = 0;
-pub const IFLA_INFO_KIND: ::c_ushort = 1;
-pub const IFLA_INFO_DATA: ::c_ushort = 2;
-pub const IFLA_INFO_XSTATS: ::c_ushort = 3;
-pub const IFLA_INFO_SLAVE_KIND: ::c_ushort = 4;
-pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5;
-
-// 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;
-
-pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
-
-// 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_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;
-
-// linux/netfilter/nfnetlink.h
-pub const NFNLGRP_NONE: ::c_int = 0;
-pub const NFNLGRP_CONNTRACK_NEW: ::c_int = 1;
-pub const NFNLGRP_CONNTRACK_UPDATE: ::c_int = 2;
-pub const NFNLGRP_CONNTRACK_DESTROY: ::c_int = 3;
-pub const NFNLGRP_CONNTRACK_EXP_NEW: ::c_int = 4;
-pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5;
-pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6;
-pub const NFNLGRP_NFTABLES: ::c_int = 7;
-pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8;
-
-pub const NFNETLINK_V0: ::c_int = 0;
-
-pub const NFNL_SUBSYS_NONE: ::c_int = 0;
-pub const NFNL_SUBSYS_CTNETLINK: ::c_int = 1;
-pub const NFNL_SUBSYS_CTNETLINK_EXP: ::c_int = 2;
-pub const NFNL_SUBSYS_QUEUE: ::c_int = 3;
-pub const NFNL_SUBSYS_ULOG: ::c_int = 4;
-pub const NFNL_SUBSYS_OSF: ::c_int = 5;
-pub const NFNL_SUBSYS_IPSET: ::c_int = 6;
-pub const NFNL_SUBSYS_ACCT: ::c_int = 7;
-pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8;
-pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9;
-pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10;
-pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11;
-pub const NFNL_SUBSYS_COUNT: ::c_int = 12;
-
-pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE;
-pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1;
-
-// linux/netfilter/nfnetlink_log.h
-pub const NFULNL_MSG_PACKET: ::c_int = 0;
-pub const NFULNL_MSG_CONFIG: ::c_int = 1;
-
-pub const NFULA_UNSPEC: ::c_int = 0;
-pub const NFULA_PACKET_HDR: ::c_int = 1;
-pub const NFULA_MARK: ::c_int = 2;
-pub const NFULA_TIMESTAMP: ::c_int = 3;
-pub const NFULA_IFINDEX_INDEV: ::c_int = 4;
-pub const NFULA_IFINDEX_OUTDEV: ::c_int = 5;
-pub const NFULA_IFINDEX_PHYSINDEV: ::c_int = 6;
-pub const NFULA_IFINDEX_PHYSOUTDEV: ::c_int = 7;
-pub const NFULA_HWADDR: ::c_int = 8;
-pub const NFULA_PAYLOAD: ::c_int = 9;
-pub const NFULA_PREFIX: ::c_int = 10;
-pub const NFULA_UID: ::c_int = 11;
-pub const NFULA_SEQ: ::c_int = 12;
-pub const NFULA_SEQ_GLOBAL: ::c_int = 13;
-pub const NFULA_GID: ::c_int = 14;
-pub const NFULA_HWTYPE: ::c_int = 15;
-pub const NFULA_HWHEADER: ::c_int = 16;
-pub const NFULA_HWLEN: ::c_int = 17;
-pub const NFULA_CT: ::c_int = 18;
-pub const NFULA_CT_INFO: ::c_int = 19;
-
-pub const NFULNL_CFG_CMD_NONE: ::c_int = 0;
-pub const NFULNL_CFG_CMD_BIND: ::c_int = 1;
-pub const NFULNL_CFG_CMD_UNBIND: ::c_int = 2;
-pub const NFULNL_CFG_CMD_PF_BIND: ::c_int = 3;
-pub const NFULNL_CFG_CMD_PF_UNBIND: ::c_int = 4;
-
-pub const NFULA_CFG_UNSPEC: ::c_int = 0;
-pub const NFULA_CFG_CMD: ::c_int = 1;
-pub const NFULA_CFG_MODE: ::c_int = 2;
-pub const NFULA_CFG_NLBUFSIZ: ::c_int = 3;
-pub const NFULA_CFG_TIMEOUT: ::c_int = 4;
-pub const NFULA_CFG_QTHRESH: ::c_int = 5;
-pub const NFULA_CFG_FLAGS: ::c_int = 6;
-
-pub const NFULNL_COPY_NONE: ::c_int = 0x00;
-pub const NFULNL_COPY_META: ::c_int = 0x01;
-pub const NFULNL_COPY_PACKET: ::c_int = 0x02;
-
-pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001;
-pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002;
-pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004;
-
-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/netlink.h
-pub const NLA_ALIGNTO: ::c_int = 4;
-
-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 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);
-
-// 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_NEWLINK: u16 = 16;
-pub const RTM_DELLINK: u16 = 17;
-pub const RTM_GETLINK: u16 = 18;
-pub const RTM_SETLINK: u16 = 19;
-pub const RTM_NEWADDR: u16 = 20;
-pub const RTM_DELADDR: u16 = 21;
-pub const RTM_GETADDR: u16 = 22;
-pub const RTM_NEWROUTE: u16 = 24;
-pub const RTM_DELROUTE: u16 = 25;
-pub const RTM_GETROUTE: u16 = 26;
-pub const RTM_NEWNEIGH: u16 = 28;
-pub const RTM_DELNEIGH: u16 = 29;
-pub const RTM_GETNEIGH: u16 = 30;
-pub const RTM_NEWRULE: u16 = 32;
-pub const RTM_DELRULE: u16 = 33;
-pub const RTM_GETRULE: u16 = 34;
-pub const RTM_NEWQDISC: u16 = 36;
-pub const RTM_DELQDISC: u16 = 37;
-pub const RTM_GETQDISC: u16 = 38;
-pub const RTM_NEWTCLASS: u16 = 40;
-pub const RTM_DELTCLASS: u16 = 41;
-pub const RTM_GETTCLASS: u16 = 42;
-pub const RTM_NEWTFILTER: u16 = 44;
-pub const RTM_DELTFILTER: u16 = 45;
-pub const RTM_GETTFILTER: u16 = 46;
-pub const RTM_NEWACTION: u16 = 48;
-pub const RTM_DELACTION: u16 = 49;
-pub const RTM_GETACTION: u16 = 50;
-pub const RTM_NEWPREFIX: u16 = 52;
-pub const RTM_GETMULTICAST: u16 = 58;
-pub const RTM_GETANYCAST: u16 = 62;
-pub const RTM_NEWNEIGHTBL: u16 = 64;
-pub const RTM_GETNEIGHTBL: u16 = 66;
-pub const RTM_SETNEIGHTBL: u16 = 67;
-pub const RTM_NEWNDUSEROPT: u16 = 68;
-pub const RTM_NEWADDRLABEL: u16 = 72;
-pub const RTM_DELADDRLABEL: u16 = 73;
-pub const RTM_GETADDRLABEL: u16 = 74;
-pub const RTM_GETDCB: u16 = 78;
-pub const RTM_SETDCB: u16 = 79;
-pub const RTM_NEWNETCONF: u16 = 80;
-pub const RTM_GETNETCONF: u16 = 82;
-pub const RTM_NEWMDB: u16 = 84;
-pub const RTM_DELMDB: u16 = 85;
-pub const RTM_GETMDB: u16 = 86;
-pub const RTM_NEWNSID: u16 = 88;
-pub const RTM_DELNSID: u16 = 89;
-pub const RTM_GETNSID: u16 = 90;
-
-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/vm_sockets.h
-pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF;
-pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0;
-pub const VMADDR_CID_RESERVED: ::c_uint = 1;
-pub const VMADDR_CID_HOST: ::c_uint = 2;
-pub const VMADDR_PORT_ANY: ::c_uint = 0xFFFFFFFF;
-
-// 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 NLA_ALIGN(len: ::c_int) -> ::c_int {
- return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
- }
-
- 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 "C" {
- #[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,
- msg_prio: *mut ::c_uint,
- ) -> ::ssize_t;
- pub fn mq_timedreceive(
- mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msg_prio: *mut ::c_uint,
- abs_timeout: *const ::timespec,
- ) -> ::ssize_t;
- pub fn mq_send(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_prio: ::c_uint,
- ) -> ::c_int;
- pub fn mq_timedsend(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_prio: ::c_uint,
- abs_timeout: *const ::timespec,
- ) -> ::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 "C" 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 "C" 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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 "C" fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void,
- ) -> ::c_int;
- pub fn dl_iterate_phdr(
- callback: ::Option<
- unsafe extern "C" 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(target_env = "gnu")] {
- mod gnu;
- pub use self::gnu::*;
- }
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- #[macro_use]
- mod align;
- } else {
- #[macro_use]
- mod no_align;
- }
-}
-expand_align!();
diff --git a/libc/src/unix/linux_like/linux/musl/b32/arm/align.rs b/libc/src/unix/linux_like/linux/musl/b32/arm/align.rs
deleted file mode 100644
index aedbf7a..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/arm/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: (i64, i64)
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs
deleted file mode 100644
index ff23688..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs
+++ /dev/null
@@ -1,845 +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 FIONCLEX: ::c_int = 0x5450;
-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;
-pub const SYS_statx: ::c_long = 397;
-
-extern "C" {
- pub fn getrandom(
- buf: *mut ::c_void,
- buflen: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs b/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs
deleted file mode 100644
index 2340695..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs
+++ /dev/null
@@ -1,797 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-pub type stat64 = ::stat;
-
-s! {
-
- pub struct stat {
- pub st_dev: ::dev_t,
- pub st_ino: ::c_ulonglong,
- pub st_mode: ::c_uint,
- pub st_nlink: ::c_uint,
- pub st_uid: ::c_uint,
- pub st_gid: ::c_uint,
- pub st_rdev: ::c_ulonglong,
- __st_rdev_padding: ::c_ulong,
- pub st_size: ::c_longlong,
- pub st_blksize: ::blksize_t,
- __st_blksize_padding: ::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 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_ushort,
- }
-
- 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 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 AF_FILE: ::c_int = 1;
-pub const AF_KCM: ::c_int = 41;
-pub const AF_MAX: ::c_int = 43;
-pub const AF_QIPCRTR: ::c_int = 42;
-pub const EADDRINUSE: ::c_int = 98;
-pub const EADDRNOTAVAIL: ::c_int = 99;
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EALREADY: ::c_int = 114;
-pub const EBADE: ::c_int = 52;
-pub const EBADMSG: ::c_int = 74;
-pub const EBADR: ::c_int = 53;
-pub const EBADRQC: ::c_int = 56;
-pub const EBADSLT: ::c_int = 57;
-pub const ECANCELED: ::c_int = 125;
-pub const ECHRNG: ::c_int = 44;
-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 EDEADLOCK: ::c_int = 35;
-pub const EDESTADDRREQ: ::c_int = 89;
-pub const EDQUOT: ::c_int = 122;
-pub const EHOSTDOWN: ::c_int = 112;
-pub const EHOSTUNREACH: ::c_int = 113;
-pub const EHWPOISON: ::c_int = 133;
-pub const EIDRM: ::c_int = 43;
-pub const EILSEQ: ::c_int = 84;
-pub const EINPROGRESS: ::c_int = 115;
-pub const EISCONN: ::c_int = 106;
-pub const EISNAM: ::c_int = 120;
-pub const EKEYEXPIRED: ::c_int = 127;
-pub const EKEYREJECTED: ::c_int = 129;
-pub const EKEYREVOKED: ::c_int = 128;
-pub const EL2HLT: ::c_int = 51;
-pub const EL2NSYNC: ::c_int = 45;
-pub const EL3HLT: ::c_int = 46;
-pub const EL3RST: ::c_int = 47;
-pub const ELIBACC: ::c_int = 79;
-pub const ELIBBAD: ::c_int = 80;
-pub const ELIBEXEC: ::c_int = 83;
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBSCN: ::c_int = 81;
-pub const ELNRNG: ::c_int = 48;
-pub const ELOOP: ::c_int = 40;
-pub const EMEDIUMTYPE: ::c_int = 124;
-pub const EMSGSIZE: ::c_int = 90;
-pub const EMULTIHOP: ::c_int = 72;
-pub const ENAMETOOLONG: ::c_int = 36;
-pub const ENAVAIL: ::c_int = 119;
-pub const ENETDOWN: ::c_int = 100;
-pub const ENETRESET: ::c_int = 102;
-pub const ENETUNREACH: ::c_int = 101;
-pub const ENOANO: ::c_int = 55;
-pub const ENOBUFS: ::c_int = 105;
-pub const ENOCSI: ::c_int = 50;
-pub const ENOKEY: ::c_int = 126;
-pub const ENOLCK: ::c_int = 37;
-pub const ENOMEDIUM: ::c_int = 123;
-pub const ENOMSG: ::c_int = 42;
-pub const ENOPROTOOPT: ::c_int = 92;
-pub const ENOSYS: ::c_int = 38;
-pub const ENOTCONN: ::c_int = 107;
-pub const ENOTEMPTY: ::c_int = 39;
-pub const ENOTNAM: ::c_int = 118;
-pub const ENOTRECOVERABLE: ::c_int = 131;
-pub const ENOTSOCK: ::c_int = 88;
-pub const ENOTSUP: ::c_int = 95;
-pub const ENOTUNIQ: ::c_int = 76;
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EOVERFLOW: ::c_int = 75;
-pub const EOWNERDEAD: ::c_int = 130;
-pub const EPFNOSUPPORT: ::c_int = 96;
-pub const EREMCHG: ::c_int = 78;
-pub const ERESTART: ::c_int = 85;
-pub const ERFKILL: ::c_int = 132;
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ESOCKTNOSUPPORT: ::c_int = 94;
-pub const ESTALE: ::c_int = 116;
-pub const ESTRPIPE: ::c_int = 86;
-pub const ETOOMANYREFS: ::c_int = 109;
-pub const EUCLEAN: ::c_int = 117;
-pub const EUNATCH: ::c_int = 49;
-pub const EUSERS: ::c_int = 87;
-pub const EXFULL: ::c_int = 54;
-pub const EXTPROC: ::c_int = 65536;
-pub const F_EXLCK: ::c_int = 4;
-pub const F_GETLK: ::c_int = 12;
-pub const F_GETOWN: ::c_int = 9;
-pub const F_GETOWNER_UIDS: ::c_int = 17;
-pub const F_GETOWN_EX: ::c_int = 16;
-pub const F_GETSIG: ::c_int = 11;
-pub const FIOASYNC: ::c_int = 21586;
-pub const FIOCLEX: ::c_int = 21585;
-pub const FIONBIO: ::c_int = 21537;
-pub const FIONCLEX: ::c_int = 21584;
-pub const FIONREAD: ::c_int = 21531;
-pub const FIOQSIZE: ::c_int = 21600;
-pub const F_LINUX_SPECIFIC_BASE: ::c_int = 1024;
-pub const FLUSHO: ::c_int = 4096;
-pub const F_OFD_GETLK: ::c_int = 36;
-pub const F_OFD_SETLK: ::c_int = 37;
-pub const F_OFD_SETLKW: ::c_int = 38;
-pub const F_OWNER_PGRP: ::c_int = 2;
-pub const F_OWNER_PID: ::c_int = 1;
-pub const F_OWNER_TID: ::c_int = 0;
-pub const F_SETLK: ::c_int = 13;
-pub const F_SETLKW: ::c_int = 14;
-pub const F_SETOWN: ::c_int = 8;
-pub const F_SETOWN_EX: ::c_int = 15;
-pub const F_SETSIG: ::c_int = 10;
-pub const F_SHLCK: ::c_int = 8;
-pub const IEXTEN: ::c_int = 32768;
-pub const MAP_ANON: ::c_int = 32;
-pub const MAP_DENYWRITE: ::c_int = 2048;
-pub const MAP_EXECUTABLE: ::c_int = 4096;
-pub const MAP_GROWSDOWN: ::c_int = 256;
-pub const MAP_HUGE_MASK: ::c_int = 63;
-pub const MAP_HUGE_SHIFT: ::c_int = 26;
-pub const MAP_HUGETLB: ::c_int = 262144;
-pub const MAP_LOCKED: ::c_int = 8192;
-pub const MAP_NONBLOCK: ::c_int = 65536;
-pub const MAP_NORESERVE: ::c_int = 16384;
-pub const MAP_POPULATE: ::c_int = 32768;
-pub const MAP_STACK: ::c_int = 131072;
-pub const MAP_UNINITIALIZED: ::c_int = 0;
-pub const O_APPEND: ::c_int = 1024;
-pub const O_ASYNC: ::c_int = 8192;
-pub const O_CREAT: ::c_int = 64;
-pub const O_DIRECT: ::c_int = 16384;
-pub const O_DIRECTORY: ::c_int = 65536;
-pub const O_DSYNC: ::c_int = 4096;
-pub const O_EXCL: ::c_int = 128;
-pub const O_LARGEFILE: ::c_int = 32768;
-pub const O_NOCTTY: ::c_int = 256;
-pub const O_NOFOLLOW: ::c_int = 131072;
-pub const O_NONBLOCK: ::c_int = 2048;
-pub const O_SYNC: ::c_int = 1052672;
-pub const PF_FILE: ::c_int = 1;
-pub const PF_KCM: ::c_int = 41;
-pub const PF_MAX: ::c_int = 43;
-pub const PF_QIPCRTR: ::c_int = 42;
-pub const RLIMIT_AS: ::c_int = 9;
-pub const RLIMIT_MEMLOCK: ::c_int = 8;
-pub const RLIMIT_NOFILE: ::c_int = 7;
-pub const RLIMIT_NPROC: ::c_int = 6;
-pub const RLIMIT_RSS: ::c_int = 5;
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-pub const RLIM_NLIMITS: ::c_int = 16;
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_SIGINFO: ::c_int = 0x00000004;
-pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
-pub const SIGBUS: ::c_int = 7;
-pub const SIGCHLD: ::c_int = 17;
-pub const SIGCONT: ::c_int = 18;
-pub const SIGIO: ::c_int = 29;
-pub const SIGPOLL: ::c_int = 29;
-pub const SIGPROF: ::c_int = 27;
-pub const SIGPWR: ::c_int = 30;
-pub const SIGSTKFLT: ::c_int = 16;
-pub const SIGSTOP: ::c_int = 19;
-pub const SIGSYS: ::c_int = 31;
-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 SIGUSR1: ::c_int = 10;
-pub const SIGUSR2: ::c_int = 12;
-pub const SIGVTALRM: ::c_int = 26;
-pub const SIGWINCH: ::c_int = 28;
-pub const SIGXCPU: ::c_int = 24;
-pub const SIGXFSZ: ::c_int = 25;
-pub const SIG_SETMASK: ::c_int = 2; // FIXME check these
-pub const SIG_BLOCK: ::c_int = 0x000000;
-pub const SIG_UNBLOCK: ::c_int = 0x01;
-pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const SO_ATTACH_BPF: ::c_int = 50;
-pub const SO_ATTACH_FILTER: ::c_int = 26;
-pub const SO_ATTACH_REUSEPORT_CBPF: ::c_int = 51;
-pub const SO_ATTACH_REUSEPORT_EBPF: ::c_int = 52;
-pub const SO_BPF_EXTENSIONS: ::c_int = 48;
-pub const SO_BROADCAST: ::c_int = 6;
-pub const SO_BSDCOMPAT: ::c_int = 14;
-pub const SOCK_DGRAM: ::c_int = 2;
-pub const SOCK_NONBLOCK: ::c_int = 2048;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SO_CNX_ADVICE: ::c_int = 53;
-pub const SO_DETACH_BPF: ::c_int = 27;
-pub const SO_DETACH_FILTER: ::c_int = 27;
-pub const SO_DOMAIN: ::c_int = 39;
-pub const SO_DONTROUTE: ::c_int = 5;
-pub const SO_ERROR: ::c_int = 4;
-pub const SO_GET_FILTER: ::c_int = 26;
-pub const SO_INCOMING_CPU: ::c_int = 49;
-pub const SO_KEEPALIVE: ::c_int = 9;
-pub const SOL_CAIF: ::c_int = 278;
-pub const SO_LINGER: ::c_int = 13;
-pub const SOL_IUCV: ::c_int = 277;
-pub const SOL_KCM: ::c_int = 281;
-pub const SOL_NFC: ::c_int = 280;
-pub const SO_LOCK_FILTER: ::c_int = 44;
-pub const SOL_PNPIPE: ::c_int = 275;
-pub const SOL_PPPOL2TP: ::c_int = 273;
-pub const SOL_RDS: ::c_int = 276;
-pub const SOL_RXRPC: ::c_int = 272;
-pub const SOL_SOCKET: ::c_int = 1;
-pub const SO_MAX_PACING_RATE: ::c_int = 47;
-pub const SO_NO_CHECK: ::c_int = 11;
-pub const SO_NOFCS: ::c_int = 43;
-pub const SO_OOBINLINE: ::c_int = 10;
-pub const SO_PASSCRED: ::c_int = 16;
-pub const SO_PASSSEC: ::c_int = 34;
-pub const SO_PEERCRED: ::c_int = 17;
-pub const SO_PEERNAME: ::c_int = 28;
-pub const SO_PEERSEC: ::c_int = 31;
-pub const SO_PRIORITY: ::c_int = 12;
-pub const SO_PROTOCOL: ::c_int = 38;
-pub const SO_RCVBUF: ::c_int = 8;
-pub const SO_RCVBUFFORCE: ::c_int = 33;
-pub const SO_RCVLOWAT: ::c_int = 18;
-pub const SO_RCVTIMEO: ::c_int = 20;
-pub const SO_REUSEADDR: ::c_int = 2;
-pub const SO_REUSEPORT: ::c_int = 15;
-pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22;
-pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23;
-pub const SO_SELECT_ERR_QUEUE: ::c_int = 45;
-pub const SO_SNDBUF: ::c_int = 7;
-pub const SO_SNDBUFFORCE: ::c_int = 32;
-pub const SO_SNDLOWAT: ::c_int = 19;
-pub const SO_SNDTIMEO: ::c_int = 21;
-pub const SO_TYPE: ::c_int = 3;
-pub const SO_WIFI_STATUS: ::c_int = 41;
-pub const SYS3264_fadvise64: ::c_int = 223;
-pub const SYS3264_fcntl: ::c_int = 25;
-pub const SYS3264_fstatat: ::c_int = 79;
-pub const SYS3264_fstat: ::c_int = 80;
-pub const SYS3264_fstatfs: ::c_int = 44;
-pub const SYS3264_ftruncate: ::c_int = 46;
-pub const SYS3264_lseek: ::c_int = 62;
-pub const SYS3264_lstat: ::c_int = 1039;
-pub const SYS3264_mmap: ::c_int = 222;
-pub const SYS3264_sendfile: ::c_int = 71;
-pub const SYS3264_stat: ::c_int = 1038;
-pub const SYS3264_statfs: ::c_int = 43;
-pub const SYS3264_truncate: ::c_int = 45;
-pub const SYS_accept4: ::c_int = 242;
-pub const SYS_accept: ::c_int = 202;
-pub const SYS_access: ::c_int = 1033;
-pub const SYS_acct: ::c_int = 89;
-pub const SYS_add_key: ::c_int = 217;
-pub const SYS_adjtimex: ::c_int = 171;
-pub const SYS_alarm: ::c_int = 1059;
-pub const SYS_arch_specific_syscall: ::c_int = 244;
-pub const SYS_bdflush: ::c_int = 1075;
-pub const SYS_bind: ::c_int = 200;
-pub const SYS_bpf: ::c_int = 280;
-pub const SYS_brk: ::c_int = 214;
-pub const SYS_capget: ::c_int = 90;
-pub const SYS_capset: ::c_int = 91;
-pub const SYS_chdir: ::c_int = 49;
-pub const SYS_chmod: ::c_int = 1028;
-pub const SYS_chown: ::c_int = 1029;
-pub const SYS_chroot: ::c_int = 51;
-pub const SYS_clock_adjtime: ::c_int = 266;
-pub const SYS_clock_getres: ::c_int = 114;
-pub const SYS_clock_gettime: ::c_int = 113;
-pub const SYS_clock_nanosleep: ::c_int = 115;
-pub const SYS_clock_settime: ::c_int = 112;
-pub const SYS_clone: ::c_int = 220;
-pub const SYS_close: ::c_int = 57;
-pub const SYS_connect: ::c_int = 203;
-pub const SYS_copy_file_range: ::c_int = -1; // FIXME
-pub const SYS_creat: ::c_int = 1064;
-pub const SYS_delete_module: ::c_int = 106;
-pub const SYS_dup2: ::c_int = 1041;
-pub const SYS_dup3: ::c_int = 24;
-pub const SYS_dup: ::c_int = 23;
-pub const SYS_epoll_create1: ::c_int = 20;
-pub const SYS_epoll_create: ::c_int = 1042;
-pub const SYS_epoll_ctl: ::c_int = 21;
-pub const SYS_epoll_pwait: ::c_int = 22;
-pub const SYS_epoll_wait: ::c_int = 1069;
-pub const SYS_eventfd2: ::c_int = 19;
-pub const SYS_eventfd: ::c_int = 1044;
-pub const SYS_execveat: ::c_int = 281;
-pub const SYS_execve: ::c_int = 221;
-pub const SYS_exit: ::c_int = 93;
-pub const SYS_exit_group: ::c_int = 94;
-pub const SYS_faccessat: ::c_int = 48;
-pub const SYS_fadvise64_64: ::c_int = 223;
-pub const SYS_fallocate: ::c_int = 47;
-pub const SYS_fanotify_init: ::c_int = 262;
-pub const SYS_fanotify_mark: ::c_int = 263;
-pub const SYS_fchdir: ::c_int = 50;
-pub const SYS_fchmodat: ::c_int = 53;
-pub const SYS_fchmod: ::c_int = 52;
-pub const SYS_fchownat: ::c_int = 54;
-pub const SYS_fchown: ::c_int = 55;
-pub const SYS_fcntl64: ::c_int = 25;
-pub const SYS_fcntl: ::c_int = 25;
-pub const SYS_fdatasync: ::c_int = 83;
-pub const SYS_fgetxattr: ::c_int = 10;
-pub const SYS_finit_module: ::c_int = 273;
-pub const SYS_flistxattr: ::c_int = 13;
-pub const SYS_flock: ::c_int = 32;
-pub const SYS_fork: ::c_int = 1079;
-pub const SYS_fremovexattr: ::c_int = 16;
-pub const SYS_fsetxattr: ::c_int = 7;
-pub const SYS_fstat64: ::c_int = 80;
-pub const SYS_fstatat64: ::c_int = 79;
-pub const SYS_fstatfs64: ::c_int = 44;
-pub const SYS_fstatfs: ::c_int = 44;
-pub const SYS_fsync: ::c_int = 82;
-pub const SYS_ftruncate64: ::c_int = 46;
-pub const SYS_ftruncate: ::c_int = 46;
-pub const SYS_futex: ::c_int = 98;
-pub const SYS_futimesat: ::c_int = 1066;
-pub const SYS_getcpu: ::c_int = 168;
-pub const SYS_getcwd: ::c_int = 17;
-pub const SYS_getdents64: ::c_int = 61;
-pub const SYS_getdents: ::c_int = 1065;
-pub const SYS_getegid: ::c_int = 177;
-pub const SYS_geteuid: ::c_int = 175;
-pub const SYS_getgid: ::c_int = 176;
-pub const SYS_getgroups: ::c_int = 158;
-pub const SYS_getitimer: ::c_int = 102;
-pub const SYS_get_mempolicy: ::c_int = 236;
-pub const SYS_getpeername: ::c_int = 205;
-pub const SYS_getpgid: ::c_int = 155;
-pub const SYS_getpgrp: ::c_int = 1060;
-pub const SYS_getpid: ::c_int = 172;
-pub const SYS_getppid: ::c_int = 173;
-pub const SYS_getpriority: ::c_int = 141;
-pub const SYS_getrandom: ::c_int = 278;
-pub const SYS_getresgid: ::c_int = 150;
-pub const SYS_getresuid: ::c_int = 148;
-pub const SYS_getrlimit: ::c_int = 163;
-pub const SYS_get_robust_list: ::c_int = 100;
-pub const SYS_getrusage: ::c_int = 165;
-pub const SYS_getsid: ::c_int = 156;
-pub const SYS_getsockname: ::c_int = 204;
-pub const SYS_getsockopt: ::c_int = 209;
-pub const SYS_gettid: ::c_int = 178;
-pub const SYS_gettimeofday: ::c_int = 169;
-pub const SYS_getuid: ::c_int = 174;
-pub const SYS_getxattr: ::c_int = 8;
-pub const SYS_init_module: ::c_int = 105;
-pub const SYS_inotify_add_watch: ::c_int = 27;
-pub const SYS_inotify_init1: ::c_int = 26;
-pub const SYS_inotify_init: ::c_int = 1043;
-pub const SYS_inotify_rm_watch: ::c_int = 28;
-pub const SYS_io_cancel: ::c_int = 3;
-pub const SYS_ioctl: ::c_int = 29;
-pub const SYS_io_destroy: ::c_int = 1;
-pub const SYS_io_getevents: ::c_int = 4;
-pub const SYS_ioprio_get: ::c_int = 31;
-pub const SYS_ioprio_set: ::c_int = 30;
-pub const SYS_io_setup: ::c_int = 0;
-pub const SYS_io_submit: ::c_int = 2;
-pub const SYS_kcmp: ::c_int = 272;
-pub const SYS_kexec_load: ::c_int = 104;
-pub const SYS_keyctl: ::c_int = 219;
-pub const SYS_kill: ::c_int = 129;
-pub const SYS_lchown: ::c_int = 1032;
-pub const SYS_lgetxattr: ::c_int = 9;
-pub const SYS_linkat: ::c_int = 37;
-pub const SYS_link: ::c_int = 1025;
-pub const SYS_listen: ::c_int = 201;
-pub const SYS_listxattr: ::c_int = 11;
-pub const SYS_llistxattr: ::c_int = 12;
-pub const SYS__llseek: ::c_int = 62;
-pub const SYS_lookup_dcookie: ::c_int = 18;
-pub const SYS_lremovexattr: ::c_int = 15;
-pub const SYS_lseek: ::c_int = 62;
-pub const SYS_lsetxattr: ::c_int = 6;
-pub const SYS_lstat64: ::c_int = 1039;
-pub const SYS_lstat: ::c_int = 1039;
-pub const SYS_madvise: ::c_int = 233;
-pub const SYS_mbind: ::c_int = 235;
-pub const SYS_memfd_create: ::c_int = 279;
-pub const SYS_migrate_pages: ::c_int = 238;
-pub const SYS_mincore: ::c_int = 232;
-pub const SYS_mkdirat: ::c_int = 34;
-pub const SYS_mkdir: ::c_int = 1030;
-pub const SYS_mknodat: ::c_int = 33;
-pub const SYS_mknod: ::c_int = 1027;
-pub const SYS_mlockall: ::c_int = 230;
-pub const SYS_mlock: ::c_int = 228;
-pub const SYS_mmap2: ::c_int = 222;
-pub const SYS_mount: ::c_int = 40;
-pub const SYS_move_pages: ::c_int = 239;
-pub const SYS_mprotect: ::c_int = 226;
-pub const SYS_mq_getsetattr: ::c_int = 185;
-pub const SYS_mq_notify: ::c_int = 184;
-pub const SYS_mq_open: ::c_int = 180;
-pub const SYS_mq_timedreceive: ::c_int = 183;
-pub const SYS_mq_timedsend: ::c_int = 182;
-pub const SYS_mq_unlink: ::c_int = 181;
-pub const SYS_mremap: ::c_int = 216;
-pub const SYS_msgctl: ::c_int = 187;
-pub const SYS_msgget: ::c_int = 186;
-pub const SYS_msgrcv: ::c_int = 188;
-pub const SYS_msgsnd: ::c_int = 189;
-pub const SYS_msync: ::c_int = 227;
-pub const SYS_munlockall: ::c_int = 231;
-pub const SYS_munlock: ::c_int = 229;
-pub const SYS_munmap: ::c_int = 215;
-pub const SYS_name_to_handle_at: ::c_int = 264;
-pub const SYS_nanosleep: ::c_int = 101;
-pub const SYS_newfstatat: ::c_int = 79;
-pub const SYS_nfsservctl: ::c_int = 42;
-pub const SYS_oldwait4: ::c_int = 1072;
-pub const SYS_openat: ::c_int = 56;
-pub const SYS_open_by_handle_at: ::c_int = 265;
-pub const SYS_open: ::c_int = 1024;
-pub const SYS_pause: ::c_int = 1061;
-pub const SYS_perf_event_open: ::c_int = 241;
-pub const SYS_personality: ::c_int = 92;
-pub const SYS_pipe2: ::c_int = 59;
-pub const SYS_pipe: ::c_int = 1040;
-pub const SYS_pivot_root: ::c_int = 41;
-pub const SYS_poll: ::c_int = 1068;
-pub const SYS_ppoll: ::c_int = 73;
-pub const SYS_prctl: ::c_int = 167;
-pub const SYS_pread64: ::c_int = 67;
-pub const SYS_preadv: ::c_int = 69;
-pub const SYS_prlimit64: ::c_int = 261;
-pub const SYS_process_vm_readv: ::c_int = 270;
-pub const SYS_process_vm_writev: ::c_int = 271;
-pub const SYS_pselect6: ::c_int = 72;
-pub const SYS_ptrace: ::c_int = 117;
-pub const SYS_pwrite64: ::c_int = 68;
-pub const SYS_pwritev: ::c_int = 70;
-pub const SYS_quotactl: ::c_int = 60;
-pub const SYS_readahead: ::c_int = 213;
-pub const SYS_read: ::c_int = 63;
-pub const SYS_readlinkat: ::c_int = 78;
-pub const SYS_readlink: ::c_int = 1035;
-pub const SYS_readv: ::c_int = 65;
-pub const SYS_reboot: ::c_int = 142;
-pub const SYS_recv: ::c_int = 1073;
-pub const SYS_recvfrom: ::c_int = 207;
-pub const SYS_recvmmsg: ::c_int = 243;
-pub const SYS_recvmsg: ::c_int = 212;
-pub const SYS_remap_file_pages: ::c_int = 234;
-pub const SYS_removexattr: ::c_int = 14;
-pub const SYS_renameat2: ::c_int = 276;
-pub const SYS_renameat: ::c_int = 38;
-pub const SYS_rename: ::c_int = 1034;
-pub const SYS_request_key: ::c_int = 218;
-pub const SYS_restart_syscall: ::c_int = 128;
-pub const SYS_rmdir: ::c_int = 1031;
-pub const SYS_rt_sigaction: ::c_int = 134;
-pub const SYS_rt_sigpending: ::c_int = 136;
-pub const SYS_rt_sigprocmask: ::c_int = 135;
-pub const SYS_rt_sigqueueinfo: ::c_int = 138;
-pub const SYS_rt_sigreturn: ::c_int = 139;
-pub const SYS_rt_sigsuspend: ::c_int = 133;
-pub const SYS_rt_sigtimedwait: ::c_int = 137;
-pub const SYS_rt_tgsigqueueinfo: ::c_int = 240;
-pub const SYS_sched_getaffinity: ::c_int = 123;
-pub const SYS_sched_getattr: ::c_int = 275;
-pub const SYS_sched_getparam: ::c_int = 121;
-pub const SYS_sched_get_priority_max: ::c_int = 125;
-pub const SYS_sched_get_priority_min: ::c_int = 126;
-pub const SYS_sched_getscheduler: ::c_int = 120;
-pub const SYS_sched_rr_get_interval: ::c_int = 127;
-pub const SYS_sched_setaffinity: ::c_int = 122;
-pub const SYS_sched_setattr: ::c_int = 274;
-pub const SYS_sched_setparam: ::c_int = 118;
-pub const SYS_sched_setscheduler: ::c_int = 119;
-pub const SYS_sched_yield: ::c_int = 124;
-pub const SYS_seccomp: ::c_int = 277;
-pub const SYS_select: ::c_int = 1067;
-pub const SYS_semctl: ::c_int = 191;
-pub const SYS_semget: ::c_int = 190;
-pub const SYS_semop: ::c_int = 193;
-pub const SYS_semtimedop: ::c_int = 192;
-pub const SYS_send: ::c_int = 1074;
-pub const SYS_sendfile64: ::c_int = 71;
-pub const SYS_sendfile: ::c_int = 71;
-pub const SYS_sendmmsg: ::c_int = 269;
-pub const SYS_sendmsg: ::c_int = 211;
-pub const SYS_sendto: ::c_int = 206;
-pub const SYS_setdomainname: ::c_int = 162;
-pub const SYS_setfsgid: ::c_int = 152;
-pub const SYS_setfsuid: ::c_int = 151;
-pub const SYS_setgid: ::c_int = 144;
-pub const SYS_setgroups: ::c_int = 159;
-pub const SYS_sethostname: ::c_int = 161;
-pub const SYS_setitimer: ::c_int = 103;
-pub const SYS_set_mempolicy: ::c_int = 237;
-pub const SYS_setns: ::c_int = 268;
-pub const SYS_setpgid: ::c_int = 154;
-pub const SYS_setpriority: ::c_int = 140;
-pub const SYS_setregid: ::c_int = 143;
-pub const SYS_setresgid: ::c_int = 149;
-pub const SYS_setresuid: ::c_int = 147;
-pub const SYS_setreuid: ::c_int = 145;
-pub const SYS_setrlimit: ::c_int = 164;
-pub const SYS_set_robust_list: ::c_int = 99;
-pub const SYS_setsid: ::c_int = 157;
-pub const SYS_setsockopt: ::c_int = 208;
-pub const SYS_set_tid_address: ::c_int = 96;
-pub const SYS_settimeofday: ::c_int = 170;
-pub const SYS_setuid: ::c_int = 146;
-pub const SYS_setxattr: ::c_int = 5;
-pub const SYS_shmat: ::c_int = 196;
-pub const SYS_shmctl: ::c_int = 195;
-pub const SYS_shmdt: ::c_int = 197;
-pub const SYS_shmget: ::c_int = 194;
-pub const SYS_shutdown: ::c_int = 210;
-pub const SYS_sigaltstack: ::c_int = 132;
-pub const SYS_signalfd4: ::c_int = 74;
-pub const SYS_signalfd: ::c_int = 1045;
-pub const SYS_socket: ::c_int = 198;
-pub const SYS_socketpair: ::c_int = 199;
-pub const SYS_splice: ::c_int = 76;
-pub const SYS_stat64: ::c_int = 1038;
-pub const SYS_stat: ::c_int = 1038;
-pub const SYS_statfs64: ::c_int = 43;
-pub const SYS_swapoff: ::c_int = 225;
-pub const SYS_swapon: ::c_int = 224;
-pub const SYS_symlinkat: ::c_int = 36;
-pub const SYS_symlink: ::c_int = 1036;
-pub const SYS_sync: ::c_int = 81;
-pub const SYS_sync_file_range2: ::c_int = 84;
-pub const SYS_sync_file_range: ::c_int = 84;
-pub const SYS_syncfs: ::c_int = 267;
-pub const SYS_syscalls: ::c_int = 1080;
-pub const SYS__sysctl: ::c_int = 1078;
-pub const SYS_sysinfo: ::c_int = 179;
-pub const SYS_syslog: ::c_int = 116;
-pub const SYS_tee: ::c_int = 77;
-pub const SYS_tgkill: ::c_int = 131;
-pub const SYS_time: ::c_int = 1062;
-pub const SYS_timer_create: ::c_int = 107;
-pub const SYS_timer_delete: ::c_int = 111;
-pub const SYS_timerfd_create: ::c_int = 85;
-pub const SYS_timerfd_gettime: ::c_int = 87;
-pub const SYS_timerfd_settime: ::c_int = 86;
-pub const SYS_timer_getoverrun: ::c_int = 109;
-pub const SYS_timer_gettime: ::c_int = 108;
-pub const SYS_timer_settime: ::c_int = 110;
-pub const SYS_times: ::c_int = 153;
-pub const SYS_tkill: ::c_int = 130;
-pub const SYS_truncate64: ::c_int = 45;
-pub const SYS_truncate: ::c_int = 45;
-pub const SYS_umask: ::c_int = 166;
-pub const SYS_umount2: ::c_int = 39;
-pub const SYS_umount: ::c_int = 1076;
-pub const SYS_uname: ::c_int = 160;
-pub const SYS_unlinkat: ::c_int = 35;
-pub const SYS_unlink: ::c_int = 1026;
-pub const SYS_unshare: ::c_int = 97;
-pub const SYS_uselib: ::c_int = 1077;
-pub const SYS_ustat: ::c_int = 1070;
-pub const SYS_utime: ::c_int = 1063;
-pub const SYS_utimensat: ::c_int = 88;
-pub const SYS_utimes: ::c_int = 1037;
-pub const SYS_vfork: ::c_int = 1071;
-pub const SYS_vhangup: ::c_int = 58;
-pub const SYS_vmsplice: ::c_int = 75;
-pub const SYS_wait4: ::c_int = 260;
-pub const SYS_waitid: ::c_int = 95;
-pub const SYS_write: ::c_int = 64;
-pub const SYS_writev: ::c_int = 66;
-pub const SYS_statx: ::c_int = 291;
-pub const TCFLSH: ::c_int = 21515;
-pub const TCGETA: ::c_int = 21509;
-pub const TCGETS: ::c_int = 21505;
-pub const TCGETX: ::c_int = 21554;
-pub const TCSBRK: ::c_int = 21513;
-pub const TCSBRKP: ::c_int = 21541;
-pub const TCSETA: ::c_int = 21510;
-pub const TCSETAF: ::c_int = 21512;
-pub const TCSETAW: ::c_int = 21511;
-pub const TCSETS: ::c_int = 21506;
-pub const TCSETSF: ::c_int = 21508;
-pub const TCSETSW: ::c_int = 21507;
-pub const TCSETX: ::c_int = 21555;
-pub const TCSETXF: ::c_int = 21556;
-pub const TCSETXW: ::c_int = 21557;
-pub const TCXONC: ::c_int = 21514;
-pub const TIOCCBRK: ::c_int = 21544;
-pub const TIOCCONS: ::c_int = 21533;
-pub const TIOCEXCL: ::c_int = 21516;
-pub const TIOCGETD: ::c_int = 21540;
-pub const TIOCGICOUNT: ::c_int = 21597;
-pub const TIOCGLCKTRMIOS: ::c_int = 21590;
-pub const TIOCGPGRP: ::c_int = 21519;
-pub const TIOCGRS485: ::c_int = 21550;
-pub const TIOCGSERIAL: ::c_int = 21534;
-pub const TIOCGSID: ::c_int = 21545;
-pub const TIOCGSOFTCAR: ::c_int = 21529;
-pub const TIOCGWINSZ: ::c_int = 21523;
-pub const TIOCLINUX: ::c_int = 21532;
-pub const TIOCMBIC: ::c_int = 21527;
-pub const TIOCMBIS: ::c_int = 21526;
-pub const TIOCM_CAR: ::c_int = 64;
-pub const TIOCM_CD: ::c_int = 64;
-pub const TIOCM_CTS: ::c_int = 32;
-pub const TIOCM_DSR: ::c_int = 256;
-pub const TIOCM_DTR: ::c_int = 2;
-pub const TIOCMGET: ::c_int = 21525;
-pub const TIOCMIWAIT: ::c_int = 21596;
-pub const TIOCM_LE: ::c_int = 1;
-pub const TIOCM_LOOP: ::c_int = 32768;
-pub const TIOCM_OUT1: ::c_int = 8192;
-pub const TIOCM_OUT2: ::c_int = 16384;
-pub const TIOCM_RI: ::c_int = 128;
-pub const TIOCM_RNG: ::c_int = 128;
-pub const TIOCM_RTS: ::c_int = 4;
-pub const TIOCMSET: ::c_int = 21528;
-pub const TIOCM_SR: ::c_int = 16;
-pub const TIOCM_ST: ::c_int = 8;
-pub const TIOCNOTTY: ::c_int = 21538;
-pub const TIOCNXCL: ::c_int = 21517;
-pub const TIOCOUTQ: ::c_int = 21521;
-pub const TIOCPKT: ::c_int = 21536;
-pub const TIOCPKT_DATA: ::c_int = 0;
-pub const TIOCPKT_DOSTOP: ::c_int = 32;
-pub const TIOCPKT_FLUSHREAD: ::c_int = 1;
-pub const TIOCPKT_FLUSHWRITE: ::c_int = 2;
-pub const TIOCPKT_IOCTL: ::c_int = 64;
-pub const TIOCPKT_NOSTOP: ::c_int = 16;
-pub const TIOCPKT_START: ::c_int = 8;
-pub const TIOCPKT_STOP: ::c_int = 4;
-pub const TIOCSBRK: ::c_int = 21543;
-pub const TIOCSCTTY: ::c_int = 21518;
-pub const TIOCSERCONFIG: ::c_int = 21587;
-pub const TIOCSERGETLSR: ::c_int = 21593;
-pub const TIOCSERGETMULTI: ::c_int = 21594;
-pub const TIOCSERGSTRUCT: ::c_int = 21592;
-pub const TIOCSERGWILD: ::c_int = 21588;
-pub const TIOCSERSETMULTI: ::c_int = 21595;
-pub const TIOCSERSWILD: ::c_int = 21589;
-pub const TIOCSER_TEMT: ::c_int = 1;
-pub const TIOCSETD: ::c_int = 21539;
-pub const TIOCSLCKTRMIOS: ::c_int = 21591;
-pub const TIOCSPGRP: ::c_int = 21520;
-pub const TIOCSRS485: ::c_int = 21551;
-pub const TIOCSSERIAL: ::c_int = 21535;
-pub const TIOCSSOFTCAR: ::c_int = 21530;
-pub const TIOCSTI: ::c_int = 21522;
-pub const TIOCSWINSZ: ::c_int = 21524;
-pub const TIOCVHANGUP: ::c_int = 21559;
-pub const TOSTOP: ::c_int = 256;
-pub const VEOF: ::c_int = 4;
-pub const VEOL2: ::c_int = 16;
-pub const VEOL: ::c_int = 11;
-pub const VMIN: ::c_int = 6;
diff --git a/libc/src/unix/linux_like/linux/musl/b32/mips/align.rs b/libc/src/unix/linux_like/linux/musl/b32/mips/align.rs
deleted file mode 100644
index 8c228eb..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/mips/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [f32; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs
deleted file mode 100644
index be11341..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs
+++ /dev/null
@@ -1,849 +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 FIONCLEX: ::c_int = 0x6602;
-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;
-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;
-pub const SYS_statx: ::c_long = 4000 + 366;
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/mod.rs b/libc/src/unix/linux_like/linux/musl/b32/mod.rs
deleted file mode 100644
index 7cf6da9..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/mod.rs
+++ /dev/null
@@ -1,65 +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 "C" {
- 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 if #[cfg(any(target_arch = "hexagon"))] {
- mod hexagon;
- pub use self::hexagon::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs b/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs
deleted file mode 100644
index 6181b1c..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs
+++ /dev/null
@@ -1,863 +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 FIONCLEX: ::c_int = 0x20006602;
-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;
-
-extern "C" {
- pub fn getrandom(
- buf: *mut ::c_void,
- buflen: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/x86/align.rs b/libc/src/unix/linux_like/linux/musl/b32/x86/align.rs
deleted file mode 100644
index 7954417..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/x86/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(8))]
- pub struct max_align_t {
- priv_: [f64; 3]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs
deleted file mode 100644
index fcd8ae4..0000000
--- a/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs
+++ /dev/null
@@ -1,954 +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 FIONCLEX: ::c_int = 0x5450;
-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;
-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;
-
-extern "C" {
- pub fn getrandom(
- buf: *mut ::c_void,
- buflen: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b64/aarch64/align.rs b/libc/src/unix/linux_like/linux/musl/b64/aarch64/align.rs
deleted file mode 100644
index 8e94996..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/aarch64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f32; 8]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs
deleted file mode 100644
index 876ff3c..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs
+++ /dev/null
@@ -1,655 +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_APPEND: ::c_int = 1024;
-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 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_ASYNC: ::c_int = 0x2000;
-
-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 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 MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-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_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 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;
-
-pub const MINSIGSTKSZ: ::size_t = 6144;
-pub const SIGSTKSZ: ::size_t = 12288;
-
-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_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;
-pub const SYS_statx: ::c_long = 291;
-
-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 FIONCLEX: ::c_int = 0x5450;
-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 "C" {
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b64/mips64.rs b/libc/src/unix/linux_like/linux/musl/b64/mips64.rs
deleted file mode 100644
index 2c41050..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/mips64.rs
+++ /dev/null
@@ -1,754 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type __u64 = ::c_ulong;
-pub type nlink_t = u64;
-pub type blksize_t = i64;
-
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- __pad1: [::c_int; 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: ::dev_t,
- __pad2: [::c_uint; 2],
- pub st_size: ::off_t,
- __pad3: ::c_int,
- 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,
- __pad4: ::c_uint,
- pub st_blocks: ::blkcnt_t,
- __pad5: [::c_int; 14],
- }
-
- pub struct stat64 {
- pub st_dev: ::dev_t,
- __pad1: [::c_int; 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: ::dev_t,
- __pad2: [::c_uint; 2],
- pub st_size: ::off_t,
- __pad3: ::c_int,
- 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,
- __pad4: ::c_uint,
- pub st_blocks: ::blkcnt_t,
- __pad5: [::c_int; 14],
- }
-
- 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; 5],
- }
-
- 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; 5],
- }
-
- 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,
- __unused1: ::c_ulong,
- __unused2: ::c_ulong
- }
-}
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-
-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;
-pub const SYS_statx: ::c_long = 5000 + 326;
-
-pub const O_DIRECT: ::c_int = 0x8000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-
-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_ASYNC: ::c_int = 0x1000;
-
-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 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_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 = 0x400;
-pub const MAP_POPULATE: ::c_int = 0x10000;
-pub const MAP_NONBLOCK: ::c_int = 0x20000;
-pub const MAP_STACK: ::c_int = 0x40000;
-pub const MAP_HUGETLB: ::c_int = 0x080000;
-
-pub const SOCK_STREAM: ::c_int = 2;
-pub const SOCK_DGRAM: ::c_int = 1;
-
-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_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_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_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_WIFI_STATUS: ::c_int = 41;
-pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS;
-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_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 FIOCLEX: ::c_int = 0x6601;
-pub const FIONCLEX: ::c_int = 0x6602;
-pub const FIONBIO: ::c_int = 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 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 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 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 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 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 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_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_RNG: ::c_int = 0x200;
-pub const TIOCM_DSR: ::c_int = 0x400;
-
-pub const EHWPOISON: ::c_int = 168;
-
-extern "C" {
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b64/mod.rs b/libc/src/unix/linux_like/linux/musl/b64/mod.rs
deleted file mode 100644
index e6a8fc8..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/mod.rs
+++ /dev/null
@@ -1,169 +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 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 SOCK_NONBLOCK: ::c_int = 2048;
-
-pub const SOCK_SEQPACKET: ::c_int = 5;
-
-extern "C" {
- pub fn getrandom(
- buf: *mut ::c_void,
- buflen: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "aarch64")] {
- mod aarch64;
- pub use self::aarch64::*;
- } else if #[cfg(target_arch = "mips64")] {
- mod mips64;
- pub use self::mips64::*;
- } 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/linux_like/linux/musl/b64/powerpc64.rs b/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs
deleted file mode 100644
index d27d703..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs
+++ /dev/null
@@ -1,739 +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_APPEND: ::c_int = 1024;
-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 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_ASYNC: ::c_int = 0x2000;
-
-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 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 MAP_HUGETLB: ::c_int = 0x040000;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-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_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 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;
-
-pub const SIGSTKSZ: ::size_t = 10240;
-pub const MINSIGSTKSZ: ::size_t = 4096;
-
-// 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;
-
-pub const FIOCLEX: ::c_int = 0x20006601;
-pub const FIONCLEX: ::c_int = 0x20006602;
-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 "C" {
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b64/x86_64/align.rs b/libc/src/unix/linux_like/linux/musl/b64/x86_64/align.rs
deleted file mode 100644
index 7ca870f..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/x86_64/align.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 4]
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs
deleted file mode 100644
index ff9300c..0000000
--- a/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs
+++ /dev/null
@@ -1,961 +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;
-pub type greg_t = i64;
-
-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 user_regs_struct {
- pub r15: ::c_ulong,
- pub r14: ::c_ulong,
- pub r13: ::c_ulong,
- pub r12: ::c_ulong,
- pub rbp: ::c_ulong,
- pub rbx: ::c_ulong,
- pub r11: ::c_ulong,
- pub r10: ::c_ulong,
- pub r9: ::c_ulong,
- pub r8: ::c_ulong,
- pub rax: ::c_ulong,
- pub rcx: ::c_ulong,
- pub rdx: ::c_ulong,
- pub rsi: ::c_ulong,
- pub rdi: ::c_ulong,
- pub orig_rax: ::c_ulong,
- pub rip: ::c_ulong,
- pub cs: ::c_ulong,
- pub eflags: ::c_ulong,
- pub rsp: ::c_ulong,
- pub ss: ::c_ulong,
- pub fs_base: ::c_ulong,
- pub gs_base: ::c_ulong,
- pub ds: ::c_ulong,
- pub es: ::c_ulong,
- pub fs: ::c_ulong,
- pub gs: ::c_ulong,
- }
-
- 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,
- #[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_ulong,
- pub u_comm: [::c_char; 32],
- pub u_debugreg: [::c_ulong; 8],
- }
-
- // GitHub repo: ifduyue/musl/
- // commit: b4b1e10364c8737a632be61582e05a8d3acf5690
- // file: arch/x86_64/bits/signal.h#L80-L84
- pub struct mcontext_t {
- pub gregs: [greg_t; 23],
- __private: [u64; 9],
- }
-
- 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 user_fpregs_struct {
- pub cwd: ::c_ushort,
- pub swd: ::c_ushort,
- pub ftw: ::c_ushort,
- pub fop: ::c_ushort,
- pub rip: ::c_ulong,
- pub rdp: ::c_ulong,
- 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],
- }
-}
-
-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
- && 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;
-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;
-
-// 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 bits/signal.h
-// GitHub repo: ifduyue/musl/
-// commit: b4b1e10364c8737a632be61582e05a8d3acf5690
-// file: arch/x86_64/bits/signal.h#L9-L56
-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;
-
-pub const MADV_SOFT_OFFLINE: ::c_int = 101;
-pub const MAP_32BIT: ::c_int = 0x0040;
-pub const O_APPEND: ::c_int = 1024;
-pub const O_DIRECT: ::c_int = 0x4000;
-pub const O_DIRECTORY: ::c_int = 0x10000;
-pub const O_LARGEFILE: ::c_int = 0;
-pub const O_NOFOLLOW: ::c_int = 0x20000;
-pub const O_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_ASYNC: ::c_int = 0x2000;
-
-pub const TIOCGRS485: ::c_int = 0x542E;
-pub const TIOCSRS485: ::c_int = 0x542F;
-
-pub const SIGSTKSZ: ::size_t = 8192;
-pub const MINSIGSTKSZ: ::size_t = 2048;
-
-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 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 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;
-
-pub const SOCK_STREAM: ::c_int = 1;
-pub const SOCK_DGRAM: ::c_int = 2;
-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_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 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 MAP_HUGETLB: ::c_int = 0x040000;
-
-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 FIONCLEX: ::c_int = 0x5450;
-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 "C" {
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/unix/linux_like/linux/musl/mod.rs b/libc/src/unix/linux_like/linux/musl/mod.rs
deleted file mode 100644
index 2c5d375..0000000
--- a/libc/src/unix/linux_like/linux/musl/mod.rs
+++ /dev/null
@@ -1,436 +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;
-
-pub type flock64 = flock;
-
-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
- }
-
- pub unsafe fn si_value(&self) -> ::sigval {
- #[repr(C)]
- struct siginfo_si_value {
- _si_signo: ::c_int,
- _si_errno: ::c_int,
- _si_code: ::c_int,
- _si_timerid: ::c_int,
- _si_overrun: ::c_int,
- si_value: ::sigval,
- }
-
- (*(self as *const siginfo_t as *const siginfo_si_value)).si_value
- }
-}
-
-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 linux_like/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 "C" {
- 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 = "mips64",
- target_arch = "powerpc64"))] {
- mod b64;
- pub use self::b64::*;
- } else if #[cfg(any(target_arch = "x86",
- target_arch = "mips",
- target_arch = "powerpc",
- target_arch = "hexagon",
- target_arch = "arm"))] {
- mod b32;
- pub use self::b32::*;
- } else { }
-}
diff --git a/libc/src/unix/linux_like/linux/no_align.rs b/libc/src/unix/linux_like/linux/no_align.rs
deleted file mode 100644
index 13c2b71..0000000
--- a/libc/src/unix/linux_like/linux/no_align.rs
+++ /dev/null
@@ -1,84 +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",
- target_arch = "sparc",
- 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",
- target_arch = "sparc",
- 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",
- target_arch = "sparc",
- 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",
- target_arch = "sparc",
- 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/linux_like/mod.rs b/libc/src/unix/linux_like/mod.rs
deleted file mode 100644
index 792548f..0000000
--- a/libc/src/unix/linux_like/mod.rs
+++ /dev/null
@@ -1,1569 +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 ip_mreq_source {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- pub imr_sourceaddr: 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 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]
- }
-
- 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]
- }
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_value == other.sigev_value
- && self.sigev_signo == other.sigev_signo
- && self.sigev_notify == other.sigev_notify
- && self.sigev_notify_thread_id
- == other.sigev_notify_thread_id
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_value", &self.sigev_value)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_notify_thread_id",
- &self.sigev_notify_thread_id)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_value.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_notify.hash(state);
- self.sigev_notify_thread_id.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_RECVERR: ::c_int = 11;
-pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
-pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
-pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39;
-pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40;
-pub const IP_TRANSPARENT: ::c_int = 19;
-pub const IPV6_ADDRFORM: ::c_int = 1;
-pub const IPV6_2292PKTINFO: ::c_int = 2;
-pub const IPV6_2292HOPOPTS: ::c_int = 3;
-pub const IPV6_2292DSTOPTS: ::c_int = 4;
-pub const IPV6_2292RTHDR: ::c_int = 5;
-pub const IPV6_2292PKTOPTIONS: ::c_int = 6;
-pub const IPV6_CHECKSUM: ::c_int = 7;
-pub const IPV6_2292HOPLIMIT: ::c_int = 8;
-pub const IPV6_NEXTHOP: ::c_int = 9;
-pub const IPV6_FLOWINFO: ::c_int = 11;
-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_ROUTER_ALERT: ::c_int = 22;
-pub const IPV6_MTU_DISCOVER: ::c_int = 23;
-pub const IPV6_MTU: ::c_int = 24;
-pub const IPV6_RECVERR: ::c_int = 25;
-pub const IPV6_V6ONLY: ::c_int = 26;
-pub const IPV6_JOIN_ANYCAST: ::c_int = 27;
-pub const IPV6_LEAVE_ANYCAST: ::c_int = 28;
-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;
-
-const_fn! {
- {const} 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 {const} 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 "C" {
- 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;
- #[deprecated(
- since = "0.2.66",
- note = "causes memory corruption, see rust-lang/libc#1596"
- )]
- 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/mod.rs b/libc/src/unix/mod.rs
deleted file mode 100644
index 238da24..0000000
--- a/libc/src/unix/mod.rs
+++ /dev/null
@@ -1,1552 +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 "C" {
- 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 isblank(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 "C" 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 "C" {
- #[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", any(freebsd11, freebsd10)),
- 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", any(freebsd11, freebsd10)),
- 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(target_os = "macos", link_name = "readdir$INODE64")]
- #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
- #[cfg_attr(
- all(target_os = "freebsd", any(freebsd11, freebsd10)),
- link_name = "readdir@FBSD_1.0"
- )]
- pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
- #[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 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", any(freebsd11, freebsd10)),
- 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 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;
- 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;
- #[cfg_attr(
- all(target_os = "macos", target_arch = "x86"),
- link_name = "ttyname_r$UNIX2003"
- )]
- pub fn ttyname_r(
- fd: ::c_int,
- buf: *mut c_char,
- buflen: ::size_t,
- ) -> ::c_int;
- 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", any(freebsd11, freebsd10)),
- 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 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 "C" 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", any(freebsd11, freebsd10)),
- 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 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(target_os = "redox"))] {
- extern {
- pub fn getsid(pid: pid_t) -> pid_t;
- pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pause$UNIX2003")]
- pub fn pause() -> ::c_int;
-
- pub fn readlinkat(dirfd: ::c_int,
- pathname: *const ::c_char,
- buf: *mut ::c_char,
- bufsiz: ::size_t) -> ::ssize_t;
- pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::mode_t) -> ::c_int;
- pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
- flags: ::c_int, ...) -> ::c_int;
-
- #[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_r$INODE64")]
- #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
- #[cfg_attr(
- all(target_os = "freebsd", any(freebsd11, freebsd10)),
- 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_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 linux_like;
- pub use self::linux_like::*;
- } 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 7e1b2bb..0000000
--- a/libc/src/unix/newlib/aarch64/mod.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-
-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 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 const POLLOUT: ::c_short = 0x4;
-pub const POLLHUP: ::c_short = 0x10;
diff --git a/libc/src/unix/newlib/align.rs b/libc/src/unix/newlib/align.rs
deleted file mode 100644
index db9beb8..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 39cb425..0000000
--- a/libc/src/unix/newlib/arm/mod.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-pub type c_char = u8;
-pub type wchar_t = u32;
-
-pub type c_long = i32;
-pub type c_ulong = u32;
-
-s! {
- pub struct sockaddr {
- pub sa_family: ::sa_family_t,
- pub sa_data: [::c_char; 14],
- }
-
- 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_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_storage {
- pub ss_family: ::sa_family_t,
- pub __ss_padding: [u8; 26],
- }
-}
-
-pub const POLLOUT: ::c_short = 0x10;
-pub const POLLHUP: ::c_short = 0x4;
diff --git a/libc/src/unix/newlib/mod.rs b/libc/src/unix/newlib/mod.rs
deleted file mode 100644
index bd9a107..0000000
--- a/libc/src/unix/newlib/mod.rs
+++ /dev/null
@@ -1,725 +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 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 POLLERR: ::c_short = 0x8;
-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 FIONCLEX: ::c_ulong = 0x20006602;
-
-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 "C" {
- 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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/redox/mod.rs b/libc/src/unix/redox/mod.rs
deleted file mode 100644
index b00a191..0000000
--- a/libc/src/unix/redox/mod.rs
+++ /dev/null
@@ -1,1114 +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;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum timezone {}
-impl ::Copy for timezone {}
-impl ::Clone for timezone {
- fn clone(&self) -> timezone {
- *self
- }
-}
-
-s_no_extra_traits! {
- #[repr(C)]
- pub struct utsname {
- pub sysname: [::c_char; UTSLENGTH],
- pub nodename: [::c_char; UTSLENGTH],
- pub release: [::c_char; UTSLENGTH],
- pub version: [::c_char; UTSLENGTH],
- pub machine: [::c_char; UTSLENGTH],
- pub domainname: [::c_char; UTSLENGTH],
- }
-
- 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 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_padding: [
- u8;
- 128 -
- ::core::mem::size_of::<sa_family_t>() -
- ::core::mem::size_of::<c_ulong>()
- ],
- __ss_align: ::c_ulong,
- }
-}
-
-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 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 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,
- }
-}
-
-pub const UTSLENGTH: usize = 65;
-
-// 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
- }
-}
-
-// limits.h
-pub const PATH_MAX: ::c_int = 4096;
-
-// fcntl.h
-pub const F_GETLK: ::c_int = 5;
-pub const F_SETLK: ::c_int = 6;
-pub const F_SETLKW: ::c_int = 7;
-
-// 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; /* Operation not permitted */
-pub const ENOENT: ::c_int = 2; /* No such file or directory */
-pub const ESRCH: ::c_int = 3; /* No such process */
-pub const EINTR: ::c_int = 4; /* Interrupted system call */
-pub const EIO: ::c_int = 5; /* I/O error */
-pub const ENXIO: ::c_int = 6; /* No such device or address */
-pub const E2BIG: ::c_int = 7; /* Argument list too long */
-pub const ENOEXEC: ::c_int = 8; /* Exec format error */
-pub const EBADF: ::c_int = 9; /* Bad file number */
-pub const ECHILD: ::c_int = 10; /* No child processes */
-pub const EAGAIN: ::c_int = 11; /* Try again */
-pub const ENOMEM: ::c_int = 12; /* Out of memory */
-pub const EACCES: ::c_int = 13; /* Permission denied */
-pub const EFAULT: ::c_int = 14; /* Bad address */
-pub const ENOTBLK: ::c_int = 15; /* Block device required */
-pub const EBUSY: ::c_int = 16; /* Device or resource busy */
-pub const EEXIST: ::c_int = 17; /* File exists */
-pub const EXDEV: ::c_int = 18; /* Cross-device link */
-pub const ENODEV: ::c_int = 19; /* No such device */
-pub const ENOTDIR: ::c_int = 20; /* Not a directory */
-pub const EISDIR: ::c_int = 21; /* Is a directory */
-pub const EINVAL: ::c_int = 22; /* Invalid argument */
-pub const ENFILE: ::c_int = 23; /* File table overflow */
-pub const EMFILE: ::c_int = 24; /* Too many open files */
-pub const ENOTTY: ::c_int = 25; /* Not a typewriter */
-pub const ETXTBSY: ::c_int = 26; /* Text file busy */
-pub const EFBIG: ::c_int = 27; /* File too large */
-pub const ENOSPC: ::c_int = 28; /* No space left on device */
-pub const ESPIPE: ::c_int = 29; /* Illegal seek */
-pub const EROFS: ::c_int = 30; /* Read-only file system */
-pub const EMLINK: ::c_int = 31; /* Too many links */
-pub const EPIPE: ::c_int = 32; /* Broken pipe */
-pub const EDOM: ::c_int = 33; /* Math argument out of domain of func */
-pub const ERANGE: ::c_int = 34; /* Math result not representable */
-pub const EDEADLK: ::c_int = 35; /* Resource deadlock would occur */
-pub const ENAMETOOLONG: ::c_int = 36; /* File name too long */
-pub const ENOLCK: ::c_int = 37; /* No record locks available */
-pub const ENOSYS: ::c_int = 38; /* Function not implemented */
-pub const ENOTEMPTY: ::c_int = 39; /* Directory not empty */
-pub const ELOOP: ::c_int = 40; /* Too many symbolic links encountered */
-pub const EWOULDBLOCK: ::c_int = 41; /* Operation would block */
-pub const ENOMSG: ::c_int = 42; /* No message of desired type */
-pub const EIDRM: ::c_int = 43; /* Identifier removed */
-pub const ECHRNG: ::c_int = 44; /* Channel number out of range */
-pub const EL2NSYNC: ::c_int = 45; /* Level 2 not synchronized */
-pub const EL3HLT: ::c_int = 46; /* Level 3 halted */
-pub const EL3RST: ::c_int = 47; /* Level 3 reset */
-pub const ELNRNG: ::c_int = 48; /* Link number out of range */
-pub const EUNATCH: ::c_int = 49; /* Protocol driver not attached */
-pub const ENOCSI: ::c_int = 50; /* No CSI structure available */
-pub const EL2HLT: ::c_int = 51; /* Level 2 halted */
-pub const EBADE: ::c_int = 52; /* Invalid exchange */
-pub const EBADR: ::c_int = 53; /* Invalid request descriptor */
-pub const EXFULL: ::c_int = 54; /* Exchange full */
-pub const ENOANO: ::c_int = 55; /* No anode */
-pub const EBADRQC: ::c_int = 56; /* Invalid request code */
-pub const EBADSLT: ::c_int = 57; /* Invalid slot */
-pub const EDEADLOCK: ::c_int = 58; /* Resource deadlock would occur */
-pub const EBFONT: ::c_int = 59; /* Bad font file format */
-pub const ENOSTR: ::c_int = 60; /* Device not a stream */
-pub const ENODATA: ::c_int = 61; /* No data available */
-pub const ETIME: ::c_int = 62; /* Timer expired */
-pub const ENOSR: ::c_int = 63; /* Out of streams resources */
-pub const ENONET: ::c_int = 64; /* Machine is not on the network */
-pub const ENOPKG: ::c_int = 65; /* Package not installed */
-pub const EREMOTE: ::c_int = 66; /* Object is remote */
-pub const ENOLINK: ::c_int = 67; /* Link has been severed */
-pub const EADV: ::c_int = 68; /* Advertise error */
-pub const ESRMNT: ::c_int = 69; /* Srmount error */
-pub const ECOMM: ::c_int = 70; /* Communication error on send */
-pub const EPROTO: ::c_int = 71; /* Protocol error */
-pub const EMULTIHOP: ::c_int = 72; /* Multihop attempted */
-pub const EDOTDOT: ::c_int = 73; /* RFS specific error */
-pub const EBADMSG: ::c_int = 74; /* Not a data message */
-pub const EOVERFLOW: ::c_int = 75; /* Value too large for defined data type */
-pub const ENOTUNIQ: ::c_int = 76; /* Name not unique on network */
-pub const EBADFD: ::c_int = 77; /* File descriptor in bad state */
-pub const EREMCHG: ::c_int = 78; /* Remote address changed */
-pub const ELIBACC: ::c_int = 79; /* Can not access a needed shared library */
-pub const ELIBBAD: ::c_int = 80; /* Accessing a corrupted shared library */
-pub const ELIBSCN: ::c_int = 81; /* .lib section in a.out corrupted */
-/* Attempting to link in too many shared libraries */
-pub const ELIBMAX: ::c_int = 82;
-pub const ELIBEXEC: ::c_int = 83; /* Cannot exec a shared library directly */
-pub const EILSEQ: ::c_int = 84; /* Illegal byte sequence */
-/* Interrupted system call should be restarted */
-pub const ERESTART: ::c_int = 85;
-pub const ESTRPIPE: ::c_int = 86; /* Streams pipe error */
-pub const EUSERS: ::c_int = 87; /* Too many users */
-pub const ENOTSOCK: ::c_int = 88; /* Socket operation on non-socket */
-pub const EDESTADDRREQ: ::c_int = 89; /* Destination address required */
-pub const EMSGSIZE: ::c_int = 90; /* Message too long */
-pub const EPROTOTYPE: ::c_int = 91; /* Protocol wrong type for socket */
-pub const ENOPROTOOPT: ::c_int = 92; /* Protocol not available */
-pub const EPROTONOSUPPORT: ::c_int = 93; /* Protocol not supported */
-pub const ESOCKTNOSUPPORT: ::c_int = 94; /* Socket type not supported */
-/* Operation not supported on transport endpoint */
-pub const EOPNOTSUPP: ::c_int = 95;
-pub const EPFNOSUPPORT: ::c_int = 96; /* Protocol family not supported */
-/* Address family not supported by protocol */
-pub const EAFNOSUPPORT: ::c_int = 97;
-pub const EADDRINUSE: ::c_int = 98; /* Address already in use */
-pub const EADDRNOTAVAIL: ::c_int = 99; /* Cannot assign requested address */
-pub const ENETDOWN: ::c_int = 100; /* Network is down */
-pub const ENETUNREACH: ::c_int = 101; /* Network is unreachable */
-/* Network dropped connection because of reset */
-pub const ENETRESET: ::c_int = 102;
-pub const ECONNABORTED: ::c_int = 103; /* Software caused connection abort */
-pub const ECONNRESET: ::c_int = 104; /* Connection reset by peer */
-pub const ENOBUFS: ::c_int = 105; /* No buffer space available */
-pub const EISCONN: ::c_int = 106; /* Transport endpoint is already connected */
-pub const ENOTCONN: ::c_int = 107; /* Transport endpoint is not connected */
-/* Cannot send after transport endpoint shutdown */
-pub const ESHUTDOWN: ::c_int = 108;
-pub const ETOOMANYREFS: ::c_int = 109; /* Too many references: cannot splice */
-pub const ETIMEDOUT: ::c_int = 110; /* Connection timed out */
-pub const ECONNREFUSED: ::c_int = 111; /* Connection refused */
-pub const EHOSTDOWN: ::c_int = 112; /* Host is down */
-pub const EHOSTUNREACH: ::c_int = 113; /* No route to host */
-pub const EALREADY: ::c_int = 114; /* Operation already in progress */
-pub const EINPROGRESS: ::c_int = 115; /* Operation now in progress */
-pub const ESTALE: ::c_int = 116; /* Stale NFS file handle */
-pub const EUCLEAN: ::c_int = 117; /* Structure needs cleaning */
-pub const ENOTNAM: ::c_int = 118; /* Not a XENIX named type file */
-pub const ENAVAIL: ::c_int = 119; /* No XENIX semaphores available */
-pub const EISNAM: ::c_int = 120; /* Is a named type file */
-pub const EREMOTEIO: ::c_int = 121; /* Remote I/O error */
-pub const EDQUOT: ::c_int = 122; /* Quota exceeded */
-pub const ENOMEDIUM: ::c_int = 123; /* No medium found */
-pub const EMEDIUMTYPE: ::c_int = 124; /* Wrong medium type */
-pub const ECANCELED: ::c_int = 125; /* Operation Canceled */
-pub const ENOKEY: ::c_int = 126; /* Required key not available */
-pub const EKEYEXPIRED: ::c_int = 127; /* Key has expired */
-pub const EKEYREVOKED: ::c_int = 128; /* Key has been revoked */
-pub const EKEYREJECTED: ::c_int = 129; /* Key was rejected by service */
-pub const EOWNERDEAD: ::c_int = 130; /* Owner died */
-pub const ENOTRECOVERABLE: ::c_int = 131; /* State not recoverable */
-
-// 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;
-
-pub const SA_NOCLDSTOP: ::c_ulong = 0x00000001;
-pub const SA_NOCLDWAIT: ::c_ulong = 0x00000002;
-pub const SA_SIGINFO: ::c_ulong = 0x00000004;
-pub const SA_RESTORER: ::c_ulong = 0x04000000;
-pub const SA_ONSTACK: ::c_ulong = 0x08000000;
-pub const SA_RESTART: ::c_ulong = 0x10000000;
-pub const SA_NODEFER: ::c_ulong = 0x40000000;
-pub const SA_RESETHAND: ::c_ulong = 0x80000000;
-
-// 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/termios.h
-pub const NCCS: usize = 32;
-
-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 VTIME: usize = 5;
-pub const VMIN: usize = 6;
-pub const VSWTC: usize = 7;
-pub const VSTART: usize = 8;
-pub const VSTOP: usize = 9;
-pub const VSUSP: usize = 10;
-pub const VEOL: usize = 11;
-pub const VREPRINT: usize = 12;
-pub const VDISCARD: usize = 13;
-pub const VWERASE: usize = 14;
-pub const VLNEXT: usize = 15;
-pub const VEOL2: usize = 16;
-
-pub const IGNBRK: ::tcflag_t = 0o000_001;
-pub const BRKINT: ::tcflag_t = 0o000_002;
-pub const IGNPAR: ::tcflag_t = 0o000_004;
-pub const PARMRK: ::tcflag_t = 0o000_010;
-pub const INPCK: ::tcflag_t = 0o000_020;
-pub const ISTRIP: ::tcflag_t = 0o000_040;
-pub const INLCR: ::tcflag_t = 0o000_100;
-pub const IGNCR: ::tcflag_t = 0o000_200;
-pub const ICRNL: ::tcflag_t = 0o000_400;
-pub const IUCLC: ::tcflag_t = 0o001_000;
-pub const IXON: ::tcflag_t = 0o002_000;
-pub const IXANY: ::tcflag_t = 0o004_000;
-pub const IXOFF: ::tcflag_t = 0o010_000;
-pub const IMAXBEL: ::tcflag_t = 0o020_000;
-pub const IUTF8: ::tcflag_t = 0o040_000;
-
-pub const OPOST: ::tcflag_t = 0o000_001;
-pub const OLCUC: ::tcflag_t = 0o000_002;
-pub const ONLCR: ::tcflag_t = 0o000_004;
-pub const OCRNL: ::tcflag_t = 0o000_010;
-pub const ONOCR: ::tcflag_t = 0o000_020;
-pub const ONLRET: ::tcflag_t = 0o00_0040;
-pub const OFILL: ::tcflag_t = 0o000_100;
-pub const OFDEL: ::tcflag_t = 0o000_200;
-
-pub const VTDLY: usize = 0o040_000;
-pub const VT0: usize = 0o000_000;
-pub const VT1: usize = 0o040_000;
-
-pub const B0: speed_t = 0o000_000;
-pub const B50: speed_t = 0o000_001;
-pub const B75: speed_t = 0o000_002;
-pub const B110: speed_t = 0o000_003;
-pub const B134: speed_t = 0o000_004;
-pub const B150: speed_t = 0o000_005;
-pub const B200: speed_t = 0o000_006;
-pub const B300: speed_t = 0o000_007;
-pub const B600: speed_t = 0o000_010;
-pub const B1200: speed_t = 0o000_011;
-pub const B1800: speed_t = 0o000_012;
-pub const B2400: speed_t = 0o000_013;
-pub const B4800: speed_t = 0o000_014;
-pub const B9600: speed_t = 0o000_015;
-pub const B19200: speed_t = 0o000_016;
-pub const B38400: speed_t = 0o000_017;
-
-pub const B57600: speed_t = 0o010_001;
-pub const B115200: speed_t = 0o010_002;
-pub const B230400: speed_t = 0o010_003;
-pub const B460800: speed_t = 0o010_004;
-pub const B500000: speed_t = 0o010_005;
-pub const B576000: speed_t = 0o010_006;
-pub const B921600: speed_t = 0o010_007;
-pub const B1000000: speed_t = 0o010_010;
-pub const B1152000: speed_t = 0o010_011;
-pub const B1500000: speed_t = 0o010_012;
-pub const B2000000: speed_t = 0o010_013;
-pub const B2500000: speed_t = 0o010_014;
-pub const B3000000: speed_t = 0o010_015;
-pub const B3500000: speed_t = 0o010_016;
-pub const B4000000: speed_t = 0o010_017;
-
-pub const CSIZE: ::tcflag_t = 0o000_060;
-pub const CS5: ::tcflag_t = 0o000_000;
-pub const CS6: ::tcflag_t = 0o000_020;
-pub const CS7: ::tcflag_t = 0o000_040;
-pub const CS8: ::tcflag_t = 0o000_060;
-pub const CSTOPB: ::tcflag_t = 0o000_100;
-pub const CREAD: ::tcflag_t = 0o000_200;
-pub const PARENB: ::tcflag_t = 0o000_400;
-pub const PARODD: ::tcflag_t = 0o001_000;
-pub const HUPCL: ::tcflag_t = 0o002_000;
-pub const CLOCAL: ::tcflag_t = 0o004_000;
-
-pub const ISIG: ::tcflag_t = 0o000_001;
-pub const ICANON: ::tcflag_t = 0o000_002;
-pub const ECHO: ::tcflag_t = 0o000_010;
-pub const ECHOE: ::tcflag_t = 0o000_020;
-pub const ECHOK: ::tcflag_t = 0o000_040;
-pub const ECHONL: ::tcflag_t = 0o000_100;
-pub const NOFLSH: ::tcflag_t = 0o000_200;
-pub const TOSTOP: ::tcflag_t = 0o000_400;
-pub const IEXTEN: ::tcflag_t = 0o100_000;
-
-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 TCIFLUSH: ::c_int = 0;
-pub const TCOFLUSH: ::c_int = 1;
-pub const TCIOFLUSH: ::c_int = 2;
-
-pub const TCSANOW: ::c_int = 0;
-pub const TCSADRAIN: ::c_int = 1;
-pub const TCSAFLUSH: ::c_int = 2;
-
-// sys/wait.h
-pub const WNOHANG: ::c_int = 1;
-pub const WUNTRACED: ::c_int = 2;
-
-pub const WSTOPPED: ::c_int = 2;
-pub const WEXITED: ::c_int = 4;
-pub const WCONTINUED: ::c_int = 8;
-pub const WNOWAIT: ::c_int = 0x0100_0000;
-
-pub const __WNOTHREAD: ::c_int = 0x2000_0000;
-pub const __WALL: ::c_int = 0x4000_0000;
-#[allow(overflowing_literals)]
-pub const __WCLONE: ::c_int = 0x8000_0000;
-
-// time.h
-pub const CLOCK_REALTIME: ::c_int = 1;
-pub const CLOCK_MONOTONIC: ::c_int = 4;
-
-// unistd.h
-// POSIX.1 {
-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_VERSION: ::c_int = 29;
-pub const _SC_PAGESIZE: ::c_int = 30;
-pub const _SC_PAGE_SIZE: ::c_int = 30;
-// ...
-pub const _SC_RE_DUP_MAX: ::c_int = 44;
-// ...
-pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
-pub const _SC_TTY_NAME_MAX: ::c_int = 72;
-// ...
-pub const _SC_SYMLOOP_MAX: ::c_int = 173;
-// ...
-pub const _SC_HOST_NAME_MAX: ::c_int = 180;
-// } POSIX.1
-
-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 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;
-
-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;
-
-// wait.h
-f! {
- 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
- }
-}
-
-extern "C" {
- // errno.h
- pub fn __errno_location() -> *mut ::c_int;
- pub fn strerror_r(
- errnum: ::c_int,
- buf: *mut c_char,
- buflen: ::size_t,
- ) -> ::c_int;
-
- // unistd.h
- pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" fn()>,
- ) -> ::c_int;
- pub fn pthread_create(
- tid: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- start: extern "C" 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;
-
- // pwd.h
- pub fn getpwuid_r(
- uid: ::uid_t,
- pwd: *mut passwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- result: *mut *mut passwd,
- ) -> ::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/resource.h
- pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
- pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::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/stat.h
- pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
-
- // 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;
-
- // sys/utsname.h
- pub fn uname(utsname: *mut utsname) -> ::c_int;
-
- // 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;
-}
-
-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 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 == self.__ss_align
- && self
- .__ss_padding
- .iter()
- .zip(other.__ss_padding.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_padding", &self.__ss_padding)
- .finish()
- }
- }
-
- impl ::hash::Hash for sockaddr_storage {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ss_family.hash(state);
- self.__ss_padding.hash(state);
- self.__ss_align.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);
- }
- }
- }
-}
diff --git a/libc/src/unix/solarish/compat.rs b/libc/src/unix/solarish/compat.rs
deleted file mode 100644
index a336452..0000000
--- a/libc/src/unix/solarish/compat.rs
+++ /dev/null
@@ -1,32 +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 06c1a20..0000000
--- a/libc/src/unix/solarish/mod.rs
+++ /dev/null
@@ -1,2499 +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 mqd_t = *mut ::c_void;
-pub type id_t = ::c_int;
-pub type idtype_t = ::c_uint;
-pub type shmatt_t = ::c_ulong;
-
-pub type door_attr_t = ::c_uint;
-pub type door_id_t = ::c_ulonglong;
-
-#[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 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_uint,
- pub key: ::key_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 __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 shmid_ds {
- pub shm_perm: ipc_perm,
- pub shm_segsz: ::size_t,
- #[cfg(target_os = "illumos")]
- pub shm_amp: *mut ::c_void,
- #[cfg(target_os = "solaris")]
- pub shm_flags: ::uintptr_t,
- pub shm_lkcnt: ::c_ushort,
- pub shm_lpid: ::pid_t,
- pub shm_cpid: ::pid_t,
- pub shm_nattch: ::shmatt_t,
- pub shm_cnattch: ::c_ulong,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- #[cfg(target_os = "illumos")]
- pub shm_pad4: [i64; 4],
- #[cfg(target_os = "solaris")]
- pub shm_amp: *mut ::c_void,
- #[cfg(target_os = "solaris")]
- pub shm_gransize: u64,
- #[cfg(target_os = "solaris")]
- pub shm_allocated: u64,
- #[cfg(target_os = "solaris")]
- pub shm_pad4: [i64; 1],
- }
-
- 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 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 mq_attr {
- pub mq_flags: ::c_long,
- pub mq_maxmsg: ::c_long,
- pub mq_msgsize: ::c_long,
- pub mq_curmsgs: ::c_long,
- _pad: [::c_int; 4]
- }
-
- 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,
- }
-
- pub struct door_desc_t__d_data__d_desc {
- pub d_descriptor: ::c_int,
- pub d_id: ::door_id_t
- }
-
- pub struct exit_status {
- e_termination: ::c_short,
- e_exit: ::c_short,
- }
-
- pub struct utmp {
- pub ut_user: [::c_char; 8],
- pub ut_id: [::c_char; 4],
- pub ut_line: [::c_char; 12],
- pub ut_pid: ::c_short,
- pub ut_type: ::c_short,
- pub ut_exit: exit_status,
- pub ut_time: ::time_t,
- }
-}
-
-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 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_exit: exit_status,
- pub ut_tv: ::timeval,
- pub ut_session: ::c_int,
- pub ut_pad: [::c_int; _UTX_PADSIZE],
- pub ut_syslen: ::c_short,
- pub ut_host: [::c_char; _UTX_HOSTSIZE],
- }
-
- 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],
- }
-
- 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 union door_desc_t__d_data {
- pub d_desc: door_desc_t__d_data__d_desc,
- d_resv: [::c_int; 5], /* Check out /usr/include/sys/door.h */
- }
-
- pub struct door_desc_t {
- pub d_attributes: door_attr_t,
- pub d_data: door_desc_t__d_data,
- }
-
- pub struct door_arg_t {
- pub data_ptr: *const ::c_char,
- pub data_size: ::size_t,
- pub desc_ptr: *const door_desc_t,
- pub dec_num: ::c_uint,
- pub rbuf: *const ::c_char,
- pub rsize: ::size_t,
- }
-}
-
-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_user == other.ut_user
- && self.ut_line == other.ut_line
- && self.ut_id == other.ut_id
- && self.ut_exit == other.ut_exit
- && self.ut_session == other.ut_session
- && self.ut_tv == other.ut_tv
- && self.ut_syslen == other.ut_syslen
- && self.ut_pad == other.ut_pad
- && self
- .ut_host
- .iter()
- .zip(other.ut_host.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_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_exit", &self.ut_exit)
- .field("ut_tv", &self.ut_tv)
- .field("ut_session", &self.ut_session)
- .field("ut_pad", &self.ut_pad)
- .field("ut_syslen", &self.ut_syslen)
- .field("ut_host", &self.ut_host)
- .finish()
- }
- }
-
- impl ::hash::Hash for utmpx {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.ut_user.hash(state);
- self.ut_type.hash(state);
- self.ut_pid.hash(state);
- self.ut_line.hash(state);
- self.ut_id.hash(state);
- self.ut_host.hash(state);
- self.ut_exit.hash(state);
- self.ut_session.hash(state);
- self.ut_tv.hash(state);
- self.ut_syslen.hash(state);
- self.ut_pad.hash(state);
- }
- }
-
- 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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_notify == other.sigev_notify
- && self.sigev_signo == other.sigev_signo
- && self.sigev_value == other.sigev_value
- && self.ss_sp == other.ss_sp
- && self.sigev_notify_attributes
- == other.sigev_notify_attributes
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_value", &self.sigev_value)
- .field("ss_sp", &self.ss_sp)
- .field("sigev_notify_attributes",
- &self.sigev_notify_attributes)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_notify.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_value.hash(state);
- self.ss_sp.hash(state);
- self.sigev_notify_attributes.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 UTIME_OMIT: c_long = -2;
-pub const UTIME_NOW: c_long = -1;
-
-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_ANONYMOUS: ::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;
-
-#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
-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;
-
-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
-
-// sys/ipc.h:
-pub const IPC_ALLOC: ::c_int = 0x8000;
-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 = 10;
-pub const IPC_SET: ::c_int = 11;
-pub const IPC_SEAT: ::c_int = 12;
-
-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;
-
-pub const NONROOT_USR: ::c_short = 2;
-pub const _UTX_USERSIZE: usize = 32;
-pub const _UTX_LINESIZE: usize = 32;
-pub const _UTX_PADSIZE: usize = 5;
-pub const _UTX_IDSIZE: usize = 4;
-pub const _UTX_HOSTSIZE: usize = 257;
-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 DOWN_TIME: ::c_short = 10;
-
-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;
-
-// 3SOCKET flags
-pub const SOCK_CLOEXEC: ::c_int = 0x080000;
-pub const SOCK_NONBLOCK: ::c_int = 0x100000;
-pub const SOCK_NDELAY: ::c_int = 0x200000;
-
-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 "C" {
- 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 settimeofday(tp: *const ::timeval, tz: *const ::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 "C" 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 "C" 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 shmat(
- shmid: ::c_int,
- shmaddr: *const ::c_void,
- shmflg: ::c_int,
- ) -> *mut ::c_void;
-
- pub fn shmctl(
- shmid: ::c_int,
- cmd: ::c_int,
- buf: *mut ::shmid_ds,
- ) -> ::c_int;
-
- pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
-
- pub fn shmget(key: key_t, size: ::size_t, shmflg: ::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 futimens(dirfd: ::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 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 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,
- msg_prio: *mut ::c_uint,
- ) -> ::ssize_t;
- pub fn mq_timedreceive(
- mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msg_prio: *mut ::c_uint,
- abs_timeout: *const ::timespec,
- ) -> ::ssize_t;
- pub fn mq_send(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_prio: ::c_uint,
- ) -> ::c_int;
- pub fn mq_timedsend(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_prio: ::c_uint,
- abs_timeout: *const ::timespec,
- ) -> ::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 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" 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;
- pub fn door_call(d: ::c_int, params: *const door_arg_t) -> ::c_int;
- pub fn door_return(
- data_ptr: *const ::c_char,
- data_size: ::size_t,
- desc_ptr: *const door_desc_t,
- num_desc: ::c_uint,
- );
- pub fn door_create(
- server_procedure: extern "C" fn(
- cookie: *const ::c_void,
- argp: *const ::c_char,
- arg_size: ::size_t,
- dp: *const door_desc_t,
- n_desc: ::c_uint,
- ),
- cookie: *const ::c_void,
- attributes: door_attr_t,
- ) -> ::c_int;
- pub fn fattach(fildes: ::c_int, path: *const ::c_char) -> ::c_int;
-
- pub fn makeutx(ux: *const utmpx) -> *mut utmpx;
- pub fn modutx(ux: *const utmpx) -> *mut utmpx;
- pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::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 endutent();
- pub fn getutent() -> *mut utmp;
- pub fn getutid(u: *const utmp) -> *mut utmp;
- pub fn getutline(u: *const utmp) -> *mut utmp;
- pub fn pututline(u: *const utmp) -> *mut utmp;
- pub fn setutent();
- pub fn utmpname(file: *const ::c_char) -> ::c_int;
-
- pub fn getutmp(ux: *const utmpx, u: *mut utmp);
- pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
- pub fn updwtmp(file: *const ::c_char, u: *mut utmp);
-}
-
-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 76b524d..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 613a11f..0000000
--- a/libc/src/unix/uclibc/arm/mod.rs
+++ /dev/null
@@ -1,1049 +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_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,
- 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_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,
- 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,
- pub ss_flags: ::c_int,
- pub 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 linux_like/mod.rs
-pub const F_SETPIPE_SZ: ::c_int = 1031; // from linux_like/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/linux_like/mod.rs
-pub const SO_PEEK_OFF: ::c_int = 42; // from src/unix/linux_like/mod.rs
-pub const SO_REUSEPORT: ::c_int = 15; // from src/unix/linux_like/mod.rs
-pub const SOL_NETLINK: ::c_int = 270; // from src/unix/linux_like/mod.rs
-pub const _POSIX_VDISABLE: ::cc_t = 0; // from linux/mod.rs
-pub const AT_EMPTY_PATH: ::c_int = 0x1000; // from linux_like/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 FIONCLEX: ::c_ulong = 0x5450;
-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 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 PTHREAD_STACK_MIN: ::size_t = 16384;
-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 SIGSTKSZ: ::size_t = 8192;
-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 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;
-
-// Syscall table is copied from src/unix/notbsd/linux/musl/b32/arm.rs
-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;
-
-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 "C" {
- 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 31bca58..0000000
--- a/libc/src/unix/uclibc/mips/mips32/mod.rs
+++ /dev/null
@@ -1,633 +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 "C" {
- 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 "C" 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 735eb85..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 "C" {
- 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 8909114..0000000
--- a/libc/src/unix/uclibc/mips/mips64/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/uclibc/mips/mod.rs b/libc/src/unix/uclibc/mips/mod.rs
deleted file mode 100644
index 6a9b41c..0000000
--- a/libc/src/unix/uclibc/mips/mod.rs
+++ /dev/null
@@ -1,479 +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 FIONCLEX: ::c_ulong = 0x6602;
-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 b4fe036..0000000
--- a/libc/src/unix/uclibc/mod.rs
+++ /dev/null
@@ -1,2295 +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 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,
- }
-
- pub struct ucred {
- pub pid: ::pid_t,
- pub uid: ::uid_t,
- pub gid: ::gid_t,
- }
-}
-
-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
- }
-
- 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]
- }
-}
-
-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);
- }
- }
-
- impl PartialEq for sigevent {
- fn eq(&self, other: &sigevent) -> bool {
- self.sigev_value == other.sigev_value
- && self.sigev_signo == other.sigev_signo
- && self.sigev_notify == other.sigev_notify
- && self.sigev_notify_thread_id
- == other.sigev_notify_thread_id
- }
- }
- impl Eq for sigevent {}
- impl ::fmt::Debug for sigevent {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigevent")
- .field("sigev_value", &self.sigev_value)
- .field("sigev_signo", &self.sigev_signo)
- .field("sigev_notify", &self.sigev_notify)
- .field("sigev_notify_thread_id",
- &self.sigev_notify_thread_id)
- .finish()
- }
- }
- impl ::hash::Hash for sigevent {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.sigev_value.hash(state);
- self.sigev_signo.hash(state);
- self.sigev_notify.hash(state);
- self.sigev_notify_thread_id.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;
-
-// Source:
-// https://github.com/kraj/uClibc/blob/ca1c74d67dd115d059a875150e10b8560a9c35a8
-// /libc/sysdeps/linux/common/bits/in.h
-// Same for all architectures
-pub const IPV6_MULTICAST_HOPS: ::c_int = 18;
-pub const IP_MULTICAST_IF: ::c_int = 32;
-pub const IPV6_MULTICAST_IF: ::c_int = 17;
-pub const IPV6_UNICAST_HOPS: ::c_int = 16;
-
-// Source:
-// https://github.com/kraj/uClibc/tree/ca1c74d67dd115d059a875150e10b8560a9c35a8
-// Same for all architectures
-pub const FUTEX_WAIT: ::c_int = 0;
-pub const FUTEX_PRIVATE_FLAG: ::c_int = 128;
-pub const FUTEX_WAKE: ::c_int = 1;
-
-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;
-
-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 "C" {
- #[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 "C" 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,
- msg_prio: *mut ::c_uint,
- ) -> ::ssize_t;
- pub fn mq_send(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_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 "C" 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 "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" fn()>,
- ) -> ::c_int;
- pub fn pthread_create(
- native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern "C" 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 583a278..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/vxworks/aarch64.rs b/libc/src/vxworks/aarch64.rs
deleted file mode 100644
index 4032488..0000000
--- a/libc/src/vxworks/aarch64.rs
+++ /dev/null
@@ -1,4 +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/vxworks/arm.rs b/libc/src/vxworks/arm.rs
deleted file mode 100644
index 5524006..0000000
--- a/libc/src/vxworks/arm.rs
+++ /dev/null
@@ -1,4 +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/vxworks/mod.rs b/libc/src/vxworks/mod.rs
deleted file mode 100755
index a086ded..0000000
--- a/libc/src/vxworks/mod.rs
+++ /dev/null
@@ -1,2086 +0,0 @@
-//! Interface to VxWorks C library
-
-use core::mem::size_of;
-use core::ptr::null_mut;
-
-#[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 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 uintptr_t = usize;
-pub type intptr_t = isize;
-pub type ptrdiff_t = isize;
-pub type size_t = ::uintptr_t;
-pub type ssize_t = ::intptr_t;
-
-pub type pid_t = ::c_int;
-pub type in_addr_t = u32;
-pub type sighandler_t = ::size_t;
-pub type cpuset_t = u32;
-
-pub type blkcnt_t = ::c_long;
-pub type blksize_t = ::c_long;
-pub type ino_t = ::c_ulong;
-
-pub type rlim_t = ::c_ulong;
-pub type suseconds_t = ::c_long;
-pub type time_t = ::c_long;
-
-pub type errno_t = ::c_int;
-
-pub type useconds_t = ::c_ulong;
-
-pub type socklen_t = ::c_uint;
-
-pub type pthread_t = ::c_ulong;
-
-pub type clockid_t = ::c_int;
-
-//defined for the structs
-pub type dev_t = ::c_ulong;
-pub type mode_t = ::c_int;
-pub type nlink_t = ::c_ulong;
-pub type uid_t = ::c_ushort;
-pub type gid_t = ::c_ushort;
-pub type sigset_t = ::c_ulonglong;
-pub type key_t = ::c_long;
-
-pub type nfds_t = ::c_uint;
-pub type stat64 = ::stat;
-
-pub type pthread_key_t = ::c_ulong;
-
-// From b_off_t.h
-pub type off_t = ::c_longlong;
-pub type off64_t = off_t;
-
-// From b_BOOL.h
-pub type BOOL = ::c_int;
-
-// From vxWind.h ..
-pub type _Vx_OBJ_HANDLE = ::c_int;
-pub type _Vx_TASK_ID = ::_Vx_OBJ_HANDLE;
-pub type _Vx_MSG_Q_ID = ::_Vx_OBJ_HANDLE;
-pub type _Vx_SEM_ID_KERNEL = ::_Vx_OBJ_HANDLE;
-pub type _Vx_RTP_ID = ::_Vx_OBJ_HANDLE;
-pub type _Vx_SD_ID = ::_Vx_OBJ_HANDLE;
-pub type _Vx_CONDVAR_ID = ::_Vx_OBJ_HANDLE;
-pub type _Vx_SEM_ID = *mut ::_Vx_semaphore;
-pub type OBJ_HANDLE = ::_Vx_OBJ_HANDLE;
-pub type TASK_ID = ::OBJ_HANDLE;
-pub type MSG_Q_ID = ::OBJ_HANDLE;
-pub type SEM_ID_KERNEL = ::OBJ_HANDLE;
-pub type RTP_ID = ::OBJ_HANDLE;
-pub type SD_ID = ::OBJ_HANDLE;
-pub type CONDVAR_ID = ::OBJ_HANDLE;
-
-// From vxTypes.h
-pub type _Vx_usr_arg_t = isize;
-pub type _Vx_exit_code_t = isize;
-pub type _Vx_ticks_t = ::c_uint;
-pub type _Vx_ticks64_t = ::c_ulonglong;
-
-pub type sa_family_t = ::c_uchar;
-
-#[cfg_attr(feature = "extra_traits", derive(Debug))]
-pub enum _Vx_semaphore {}
-impl ::Copy for _Vx_semaphore {}
-impl ::Clone for _Vx_semaphore {
- fn clone(&self) -> _Vx_semaphore {
- *self
- }
-}
-
-s! {
- // b_pthread_condattr_t.h
- pub struct pthread_condattr_t {
- pub condAttrStatus: ::c_int,
- pub condAttrPshared: ::c_int,
- pub condAttrClockId: ::clockid_t,
- }
-
- // b_pthread_cond_t.h
- pub struct pthread_cond_t{
- pub condSemId: ::_Vx_SEM_ID,
- pub condValid: ::c_int,
- pub condInitted: ::c_int,
- pub condRefCount: ::c_int,
- pub condMutex: *mut ::pthread_mutex_t,
- pub condAttr: ::pthread_condattr_t,
- pub condSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX]
- }
-
- // b_pthread_rwlockattr_t.h
- pub struct pthread_rwlockattr_t {
- pub rwlockAttrStatus: ::c_int,
- pub rwlockAttrPshared: ::c_int,
- pub rwlockAttrMaxReaders: ::c_uint,
- pub rwlockAttrConformOpt: ::c_uint,
- }
-
- // b_pthread_rwlock_t.h
- pub struct pthread_rwlock_t {
- pub rwlockSemId: :: _Vx_SEM_ID,
- pub rwlockReadersRefCount: ::c_uint,
- pub rwlockValid: ::c_int,
- pub rwlockInitted: ::c_int,
- pub rwlockAttr: ::pthread_rwlockattr_t,
- pub rwlockSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX]
- }
-
- // b_struct_timeval.h
- pub struct timeval {
- pub tv_sec: ::time_t,
- pub tv_usec: ::suseconds_t,
- }
-
- // socket.h
- pub struct linger {
- pub l_onoff: ::c_int,
- pub l_linger: ::c_int,
- }
-
- pub struct sockaddr {
- pub sa_len : ::c_uchar,
- pub sa_family : sa_family_t,
- pub sa_data : [::c_char; 14],
- }
-
- pub struct iovec {
- pub iov_base: *mut ::c_void,
- pub iov_len: ::size_t,
- }
-
- 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,
- }
-
- // poll.h
- pub struct pollfd {
- pub fd : ::c_int,
- pub events : ::c_short,
- pub revents : ::c_short,
- }
-
- // resource.h
- pub struct rlimit {
- pub rlim_cur : ::rlim_t,
- pub rlim_max : ::rlim_t,
- }
-
- // stat.h
- 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_mtime : ::time_t,
- pub st_ctime : ::time_t,
- pub st_blksize : ::blksize_t,
- pub st_blocks : ::blkcnt_t,
- pub st_attrib : ::c_uchar,
- pub st_reserved1 : ::c_int,
- pub st_reserved2 : ::c_int,
- pub st_reserved3 : ::c_int,
- pub st_reserved4 : ::c_int,
- }
-
- //b_struct__Timespec.h
- pub struct _Timespec {
- pub tv_sec : ::time_t,
- pub tv_nsec : ::c_long,
- }
-
- // b_struct__Sched_param.h
- pub struct _Sched_param {
- pub sched_priority: ::c_int, /* scheduling priority */
- pub sched_ss_low_priority: ::c_int, /* low scheduling priority */
- pub sched_ss_repl_period: ::_Timespec, /* replenishment period */
- pub sched_ss_init_budget: ::_Timespec, /* initial budget */
- pub sched_ss_max_repl: ::c_int, /* max pending replenishment */
-
- }
-
- // b_pthread_attr_t.h
- pub struct pthread_attr_t {
- pub threadAttrStatus : ::c_int,
- pub threadAttrStacksize : ::size_t,
- pub threadAttrStackaddr : *mut ::c_void,
- pub threadAttrGuardsize : ::size_t,
- pub threadAttrDetachstate : ::c_int,
- pub threadAttrContentionscope : ::c_int,
- pub threadAttrInheritsched : ::c_int,
- pub threadAttrSchedpolicy : ::c_int,
- pub threadAttrName : *mut ::c_char,
- pub threadAttrOptions : ::c_int,
- pub threadAttrSchedparam : ::_Sched_param,
- }
-
- // signal.h
-
- pub struct sigaction {
- pub sa_u : ::sa_u_t,
- pub sa_mask : ::sigset_t,
- pub sa_flags : ::c_int,
- }
-
- // b_stack_t.h
- pub struct stack_t {
- pub ss_sp : *mut ::c_void,
- pub ss_size : ::size_t,
- pub ss_flags : ::c_int,
- }
-
- // signal.h
- pub struct siginfo_t {
- pub si_signo : ::c_int,
- pub si_code : ::c_int,
- pub si_value : ::sigval,
- pub si_errno : ::c_int,
- pub si_status: ::c_int,
- pub si_addr: *mut ::c_void,
- pub si_uid: ::uid_t,
- pub si_pid: ::pid_t,
- }
-
- // pthread.h (krnl)
- // b_pthread_mutexattr_t.h (usr)
- pub struct pthread_mutexattr_t {
- mutexAttrStatus : ::c_int,
- mutexAttrPshared : ::c_int,
- mutexAttrProtocol : ::c_int,
- mutexAttrPrioceiling : ::c_int,
- mutexAttrType : ::c_int,
- }
-
- // pthread.h (krnl)
- // b_pthread_mutex_t.h (usr)
- pub struct pthread_mutex_t {
- pub mutexSemId: ::_Vx_SEM_ID, /*_Vx_SEM_ID ..*/
- pub mutexValid: ::c_int,
- pub mutexInitted: ::c_int,
- pub mutexCondRefCount: ::c_int,
- pub mutexSavPriority: ::c_int,
- pub mutexAttr: ::pthread_mutexattr_t,
- pub mutexSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX],
- }
-
- // b_struct_timespec.h
- pub struct timespec {
- pub tv_sec: ::time_t,
- pub tv_nsec: ::c_long,
- }
-
- // time.h
- 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,
- }
-
- // in.h
- pub struct in_addr {
- pub s_addr: in_addr_t,
- }
-
- // in.h
- pub struct ip_mreq {
- pub imr_multiaddr: in_addr,
- pub imr_interface: in_addr,
- }
-
- // in6.h
- #[repr(align(4))]
- pub struct in6_addr {
- pub s6_addr: [u8; 16],
- }
-
- // in6.h
- pub struct ipv6_mreq {
- pub ipv6mr_multiaddr: in6_addr,
- pub ipv6mr_interface: ::c_uint,
- }
-
- // netdb.h
- 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,
- }
-
- // in.h
- pub struct sockaddr_in {
- pub sin_len : u8,
- pub sin_family: u8,
- pub sin_port : u16,
- pub sin_addr : ::in_addr,
- pub sin_zero : [::c_char; 8],
- }
-
- // in6.h
- pub struct sockaddr_in6 {
- pub sin6_len : u8,
- pub sin6_family : u8,
- pub sin6_port : u16,
- pub sin6_flowinfo: u32,
- pub sin6_addr : ::in6_addr,
- pub sin6_scope_id: u32,
- }
-
- 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,
- }
-}
-
-s_no_extra_traits! {
- // dirent.h
- pub struct dirent {
- pub d_ino : ::ino_t,
- pub d_name : [::c_char; _PARM_NAME_MAX as usize + 1],
- }
-
- pub struct sockaddr_un {
- pub sun_len: u8,
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 104]
- }
-
- // rtpLibCommon.h
- pub struct RTP_DESC {
- pub status : ::c_int,
- pub options : u32,
- pub entrAddr : *mut ::c_void,
- pub initTaskId: ::TASK_ID,
- pub parentId : ::RTP_ID,
- pub pathName : [::c_char; VX_RTP_NAME_LENGTH as usize + 1],
- pub taskCnt : ::c_int,
- pub textStart : *mut ::c_void,
- pub textEnd : *mut ::c_void,
- }
- // socket.h
- pub struct sockaddr_storage {
- pub ss_len : ::c_uchar,
- pub ss_family : ::sa_family_t,
- pub __ss_pad1 : [::c_char; _SS_PAD1SIZE],
- pub __ss_align : i32,
- pub __ss_pad2 : [::c_char; _SS_PAD2SIZE],
- }
-
- pub union sa_u_t {
- pub sa_handler : ::Option<unsafe extern "C" fn(::c_int) -> !>,
- pub sa_sigaction: ::Option<unsafe extern "C" fn(::c_int,
- *mut ::siginfo_t,
- *mut ::c_void) -> !>,
- }
-
- pub union sigval {
- pub sival_int : ::c_int,
- pub sival_ptr : *mut ::c_void,
- }
-}
-
-cfg_if! {
- if #[cfg(feature = "extra_traits")] {
- 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_name", &&self.d_name[..])
- .finish()
- }
- }
-
- 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)
- .field("sun_path", &&self.sun_path[..])
- .finish()
- }
- }
-
- impl ::fmt::Debug for RTP_DESC {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("RTP_DESC")
- .field("status", &self.status)
- .field("options", &self.options)
- .field("entrAddr", &self.entrAddr)
- .field("initTaskId", &self.initTaskId)
- .field("parentId", &self.parentId)
- .field("pathName", &&self.pathName[..])
- .field("taskCnt", &self.taskCnt)
- .field("textStart", &self.textStart)
- .field("textEnd", &self.textEnd)
- .finish()
- }
- }
- 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)
- .field("__ss_pad2", &&self.__ss_pad2[..])
- .finish()
- }
- }
-
- impl PartialEq for sa_u_t {
- fn eq(&self, other: &sa_u_t) -> bool {
- unsafe {
- let h1 = match self.sa_handler {
- Some(handler) => handler as usize,
- None => 0 as usize,
- };
- let h2 = match other.sa_handler {
- Some(handler) => handler as usize,
- None => 0 as usize,
- };
- h1 == h2
- }
- }
- }
- impl Eq for sa_u_t {}
- impl ::fmt::Debug for sa_u_t {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- unsafe {
- let h = match self.sa_handler {
- Some(handler) => handler as usize,
- None => 0 as usize,
- };
-
- f.debug_struct("sa_u_t")
- .field("sa_handler", &h)
- .finish()
- }
- }
- }
- impl ::hash::Hash for sa_u_t {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- unsafe {
- let h = match self.sa_handler {
- Some(handler) => handler as usize,
- None => 0 as usize,
- };
- h.hash(state)
- }
- }
- }
-
- impl PartialEq for sigval {
- fn eq(&self, other: &sigval) -> bool {
- unsafe { self.sival_ptr as usize == other.sival_ptr as usize }
- }
- }
- impl Eq for sigval {}
- impl ::fmt::Debug for sigval {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("sigval")
- .field("sival_ptr", unsafe { &(self.sival_ptr as usize) })
- .finish()
- }
- }
- impl ::hash::Hash for sigval {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- unsafe { (self.sival_ptr as usize).hash(state) };
- }
- }
- }
-}
-
-pub const STDIN_FILENO: ::c_int = 0;
-pub const STDOUT_FILENO: ::c_int = 1;
-pub const STDERR_FILENO: ::c_int = 2;
-
-pub const EXIT_SUCCESS: ::c_int = 0;
-pub const EXIT_FAILURE: ::c_int = 1;
-
-pub const EAI_SERVICE: ::c_int = 9;
-pub const EAI_SOCKTYPE: ::c_int = 10;
-pub const EAI_SYSTEM: ::c_int = 11;
-
-// This is not defined in vxWorks, but we have to define it here
-// to make the building pass for getrandom and libstd, FIXME
-pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
-
-//Clock Lib Stuff
-pub const CLOCK_REALTIME: ::c_int = 0x0;
-pub const CLOCK_MONOTONIC: ::c_int = 0x1;
-pub const CLOCK_PROCESS_CPUTIME_ID: ::c_int = 0x2;
-pub const CLOCK_THREAD_CPUTIME_ID: ::c_int = 0x3;
-pub const TIMER_ABSTIME: ::c_int = 0x1;
-pub const TIMER_RELTIME: ::c_int = 0x0;
-
-// PTHREAD STUFF
-pub const PTHREAD_INITIALIZED_OBJ: ::c_int = 0xF70990EF;
-pub const PTHREAD_DESTROYED_OBJ: ::c_int = -1;
-pub const PTHREAD_VALID_OBJ: ::c_int = 0xEC542A37;
-pub const PTHREAD_INVALID_OBJ: ::c_int = -1;
-pub const PTHREAD_UNUSED_YET_OBJ: ::c_int = -1;
-
-pub const PTHREAD_PRIO_NONE: ::c_int = 0;
-pub const PTHREAD_PRIO_INHERIT: ::c_int = 1;
-pub const PTHREAD_PRIO_PROTECT: ::c_int = 2;
-
-pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
-pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
-pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
-pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const PTHREAD_STACK_MIN: usize = 4096;
-pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30;
-
-// ERRNO STUFF
-pub const OK: ::c_int = 0;
-pub const EPERM: ::c_int = 1; /* Not owner */
-pub const ENOENT: ::c_int = 2; /* No such file or directory */
-pub const ESRCH: ::c_int = 3; /* No such process */
-pub const EINTR: ::c_int = 4; /* Interrupted system call */
-pub const EIO: ::c_int = 5; /* I/O error */
-pub const ENXIO: ::c_int = 6; /* No such device or address */
-pub const E2BIG: ::c_int = 7; /* Arg list too long */
-pub const ENOEXEC: ::c_int = 8; /* Exec format error */
-pub const EBADF: ::c_int = 9; /* Bad file number */
-pub const ECHILD: ::c_int = 10; /* No children */
-pub const EAGAIN: ::c_int = 11; /* No more processes */
-pub const ENOMEM: ::c_int = 12; /* Not enough core */
-pub const EACCES: ::c_int = 13; /* Permission denied */
-pub const EFAULT: ::c_int = 14;
-pub const ENOTEMPTY: ::c_int = 15;
-pub const EBUSY: ::c_int = 16;
-pub const EEXIST: ::c_int = 17;
-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 ENAMETOOLONG: ::c_int = 26;
-pub const EFBIG: ::c_int = 27;
-pub const ENOSPC: ::c_int = 28;
-pub const EROFS: ::c_int = 30;
-pub const EPIPE: ::c_int = 32;
-pub const EDEADLK: ::c_int = 33;
-pub const ERANGE: ::c_int = 38;
-pub const EDESTADDRREQ: ::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 ENOTSOCK: ::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 EINPROGRESS: ::c_int = 68;
-pub const EALREADY: ::c_int = 69;
-pub const EWOULDBLOCK: ::c_int = 70;
-pub const ENOSYS: ::c_int = 71;
-pub const EDQUOT: ::c_int = 83;
-pub const ESTALE: ::c_int = 88;
-
-// NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h
-const M_nfsStat: ::c_int = 48 << 16;
-enum nfsstat {
- NFSERR_REMOTE = 71,
- NFSERR_WFLUSH = 99,
- NFSERR_BADHANDLE = 10001,
- NFSERR_NOT_SYNC = 10002,
- NFSERR_BAD_COOKIE = 10003,
- NFSERR_TOOSMALL = 10005,
- NFSERR_BADTYPE = 10007,
- NFSERR_JUKEBOX = 10008,
-}
-
-pub const S_nfsLib_NFS_OK: ::c_int = OK;
-pub const S_nfsLib_NFSERR_PERM: ::c_int = EPERM;
-pub const S_nfsLib_NFSERR_NOENT: ::c_int = ENOENT;
-pub const S_nfsLib_NFSERR_IO: ::c_int = EIO;
-pub const S_nfsLib_NFSERR_NXIO: ::c_int = ENXIO;
-pub const S_nfsLib_NFSERR_ACCESS: ::c_int = EACCES;
-pub const S_nfsLib_NFSERR_EXIST: ::c_int = EEXIST;
-pub const S_nfsLib_NFSERR_ENODEV: ::c_int = ENODEV;
-pub const S_nfsLib_NFSERR_NOTDIR: ::c_int = ENOTDIR;
-pub const S_nfsLib_NFSERR_ISDIR: ::c_int = EISDIR;
-pub const S_nfsLib_NFSERR_INVAL: ::c_int = EINVAL;
-pub const S_nfsLib_NFSERR_FBIG: ::c_int = EFBIG;
-pub const S_nfsLib_NFSERR_NOSPC: ::c_int = ENOSPC;
-pub const S_nfsLib_NFSERR_ROFS: ::c_int = EROFS;
-pub const S_nfsLib_NFSERR_NAMETOOLONG: ::c_int = ENAMETOOLONG;
-pub const S_nfsLib_NFSERR_NOTEMPTY: ::c_int = ENOTEMPTY;
-pub const S_nfsLib_NFSERR_DQUOT: ::c_int = EDQUOT;
-pub const S_nfsLib_NFSERR_STALE: ::c_int = ESTALE;
-pub const S_nfsLib_NFSERR_WFLUSH: ::c_int =
- M_nfsStat | nfsstat::NFSERR_WFLUSH as ::c_int;
-pub const S_nfsLib_NFSERR_REMOTE: ::c_int =
- M_nfsStat | nfsstat::NFSERR_REMOTE as ::c_int;
-pub const S_nfsLib_NFSERR_BADHANDLE: ::c_int =
- M_nfsStat | nfsstat::NFSERR_BADHANDLE as ::c_int;
-pub const S_nfsLib_NFSERR_NOT_SYNC: ::c_int =
- M_nfsStat | nfsstat::NFSERR_NOT_SYNC as ::c_int;
-pub const S_nfsLib_NFSERR_BAD_COOKIE: ::c_int =
- M_nfsStat | nfsstat::NFSERR_BAD_COOKIE as ::c_int;
-pub const S_nfsLib_NFSERR_NOTSUPP: ::c_int = EOPNOTSUPP;
-pub const S_nfsLib_NFSERR_TOOSMALL: ::c_int =
- M_nfsStat | nfsstat::NFSERR_TOOSMALL as ::c_int;
-pub const S_nfsLib_NFSERR_SERVERFAULT: ::c_int = EIO;
-pub const S_nfsLib_NFSERR_BADTYPE: ::c_int =
- M_nfsStat | nfsstat::NFSERR_BADTYPE as ::c_int;
-pub const S_nfsLib_NFSERR_JUKEBOX: ::c_int =
- M_nfsStat | nfsstat::NFSERR_JUKEBOX as ::c_int;
-
-// in.h
-pub const IPPROTO_IP: ::c_int = 0;
-pub const IPPROTO_IPV6: ::c_int = 41;
-
-pub const IP_TTL: ::c_int = 4;
-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;
-
-// in6.h
-pub const IPV6_V6ONLY: ::c_int = 1;
-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_ADD_MEMBERSHIP: ::c_int = 12;
-pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
-
-// STAT Stuff
-pub const S_IFMT: ::c_int = 0xf000;
-pub const S_IFIFO: ::c_int = 0x1000;
-pub const S_IFCHR: ::c_int = 0x2000;
-pub const S_IFDIR: ::c_int = 0x4000;
-pub const S_IFBLK: ::c_int = 0x6000;
-pub const S_IFREG: ::c_int = 0x8000;
-pub const S_IFLNK: ::c_int = 0xa000;
-pub const S_IFSHM: ::c_int = 0xb000;
-pub const S_IFSOCK: ::c_int = 0xc000;
-pub const S_ISUID: ::c_int = 0x0800;
-pub const S_ISGID: ::c_int = 0x0400;
-pub const S_ISTXT: ::c_int = 0x0200;
-pub const S_IRUSR: ::c_int = 0x0100;
-pub const S_IWUSR: ::c_int = 0x0080;
-pub const S_IXUSR: ::c_int = 0x0040;
-pub const S_IRWXU: ::c_int = 0x01c0;
-pub const S_IRGRP: ::c_int = 0x0020;
-pub const S_IWGRP: ::c_int = 0x0010;
-pub const S_IXGRP: ::c_int = 0x0008;
-pub const S_IRWXG: ::c_int = 0x0038;
-pub const S_IROTH: ::c_int = 0x0004;
-pub const S_IWOTH: ::c_int = 0x0002;
-pub const S_IXOTH: ::c_int = 0x0001;
-pub const S_IRWXO: ::c_int = 0x0007;
-
-// socket.h
-pub const SOL_SOCKET: ::c_int = 0xffff;
-
-pub const SO_DEBUG: ::c_int = 0x0001;
-pub const SO_REUSEADDR: ::c_int = 0x0004;
-pub const SO_KEEPALIVE: ::c_int = 0x0008;
-pub const SO_DONTROUTE: ::c_int = 0x0010;
-pub const SO_RCVLOWAT: ::c_int = 0x0012;
-pub const SO_SNDLOWAT: ::c_int = 0x0013;
-pub const SO_SNDTIMEO: ::c_int = 0x1005;
-pub const SO_ACCEPTCONN: ::c_int = 0x001e;
-pub const SO_BROADCAST: ::c_int = 0x0020;
-pub const SO_USELOOPBACK: ::c_int = 0x0040;
-pub const SO_LINGER: ::c_int = 0x0080;
-pub const SO_REUSEPORT: ::c_int = 0x0200;
-
-pub const SO_VLAN: ::c_int = 0x8000;
-
-pub const SO_SNDBUF: ::c_int = 0x1001;
-pub const SO_RCVBUF: ::c_int = 0x1002;
-pub const SO_RCVTIMEO: ::c_int = 0x1006;
-pub const SO_ERROR: ::c_int = 0x1007;
-pub const SO_TYPE: ::c_int = 0x1008;
-pub const SO_BINDTODEVICE: ::c_int = 0x1010;
-pub const SO_OOBINLINE: ::c_int = 0x1011;
-pub const SO_CONNTIMEO: ::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 SOCK_RDM: ::c_int = 4;
-pub const SOCK_SEQPACKET: ::c_int = 5;
-pub const SOCK_PACKET: ::c_int = 10;
-
-pub const _SS_MAXSIZE: usize = 128;
-pub const _SS_ALIGNSIZE: usize = size_of::<u32>();
-pub const _SS_PAD1SIZE: usize =
- (_SS_ALIGNSIZE - size_of::<::c_uchar>() - size_of::<::sa_family_t>());
-pub const _SS_PAD2SIZE: usize = (_SS_MAXSIZE
- - size_of::<::c_uchar>()
- - size_of::<::sa_family_t>()
- - _SS_PAD1SIZE
- - _SS_ALIGNSIZE);
-
-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_EOF: ::c_int = 0x0100;
-pub const MSG_EXP: ::c_int = 0x0200;
-pub const MSG_MBUF: ::c_int = 0x0400;
-pub const MSG_NOTIFICATION: ::c_int = 0x0800;
-pub const MSG_COMPAT: ::c_int = 0x8000;
-
-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_NETLINK: ::c_int = 16;
-pub const AF_ROUTE: ::c_int = 17;
-pub const AF_LINK: ::c_int = 18;
-pub const AF_PACKET: ::c_int = 19;
-pub const pseudo_AF_KEY: ::c_int = 27;
-pub const AF_KEY: ::c_int = pseudo_AF_KEY;
-pub const AF_INET6: ::c_int = 28;
-pub const AF_SOCKDEV: ::c_int = 31;
-pub const AF_TIPC: ::c_int = 33;
-pub const AF_MIPC: ::c_int = 34;
-pub const AF_MIPC_SAFE: ::c_int = 35;
-pub const AF_MAX: ::c_int = 37;
-
-pub const SHUT_RD: ::c_int = 0;
-pub const SHUT_WR: ::c_int = 1;
-pub const SHUT_RDWR: ::c_int = 2;
-
-pub const IPPROTO_TCP: ::c_int = 6;
-pub const TCP_NODELAY: ::c_int = 1;
-pub const TCP_MAXSEG: ::c_int = 2;
-pub const TCP_NOPUSH: ::c_int = 3;
-pub const TCP_KEEPIDLE: ::c_int = 4;
-pub const TCP_KEEPINTVL: ::c_int = 5;
-pub const TCP_KEEPCNT: ::c_int = 6;
-
-// ioLib.h
-pub const FIONREAD: ::c_int = 0x40040001;
-pub const FIOFLUSH: ::c_int = 2;
-pub const FIOOPTIONS: ::c_int = 3;
-pub const FIOBAUDRATE: ::c_int = 4;
-pub const FIODISKFORMAT: ::c_int = 5;
-pub const FIODISKINIT: ::c_int = 6;
-pub const FIOSEEK: ::c_int = 7;
-pub const FIOWHERE: ::c_int = 8;
-pub const FIODIRENTRY: ::c_int = 9;
-pub const FIORENAME: ::c_int = 10;
-pub const FIOREADYCHANGE: ::c_int = 11;
-pub const FIODISKCHANGE: ::c_int = 13;
-pub const FIOCANCEL: ::c_int = 14;
-pub const FIOSQUEEZE: ::c_int = 15;
-pub const FIOGETNAME: ::c_int = 18;
-pub const FIONBIO: ::c_int = 0x90040010;
-
-// limits.h
-pub const PATH_MAX: ::c_int = _PARM_PATH_MAX;
-pub const _POSIX_PATH_MAX: ::c_int = 256;
-
-// Some poll stuff
-pub const POLLIN: ::c_short = 0x0001;
-pub const POLLPRI: ::c_short = 0x0002;
-pub const POLLOUT: ::c_short = 0x0004;
-pub const POLLRDNORM: ::c_short = 0x0040;
-pub const POLLWRNORM: ::c_short = POLLOUT;
-pub const POLLRDBAND: ::c_short = 0x0080;
-pub const POLLWRBAND: ::c_short = 0x0100;
-pub const POLLERR: ::c_short = 0x0008;
-pub const POLLHUP: ::c_short = 0x0010;
-pub const POLLNVAL: ::c_short = 0x0020;
-
-// fnctlcom.h
-pub const FD_CLOEXEC: ::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;
-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_DUPFD_CLOEXEC: ::c_int = 14;
-
-// signal.h
-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 = -1 as isize as sighandler_t;
-
-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 SIGEMT: ::c_int = 7;
-pub const SIGFPE: ::c_int = 8;
-pub const SIGKILL: ::c_int = 9;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGSEGV: ::c_int = 11;
-pub const SIGFMT: ::c_int = 12;
-pub const SIGPIPE: ::c_int = 13;
-pub const SIGALRM: ::c_int = 14;
-pub const SIGTERM: ::c_int = 15;
-pub const SIGCNCL: ::c_int = 16;
-pub const SIGSTOP: ::c_int = 17;
-pub const SIGTSTP: ::c_int = 18;
-pub const SIGCONT: ::c_int = 19;
-pub const SIGCHLD: ::c_int = 20;
-pub const SIGTTIN: ::c_int = 21;
-pub const SIGTTOU: ::c_int = 22;
-
-pub const SIG_BLOCK: ::c_int = 1;
-pub const SIG_UNBLOCK: ::c_int = 2;
-pub const SIG_SETMASK: ::c_int = 3;
-
-pub const SI_SYNC: ::c_int = 0;
-pub const SI_USER: ::c_int = -1;
-pub const SI_QUEUE: ::c_int = -2;
-pub const SI_TIMER: ::c_int = -3;
-pub const SI_ASYNCIO: ::c_int = -4;
-pub const SI_MESGQ: ::c_int = -5;
-pub const SI_CHILD: ::c_int = -6;
-pub const SI_KILL: ::c_int = SI_USER;
-
-// vxParams.h definitions
-pub const _PARM_NAME_MAX: ::c_int = 255;
-pub const _PARM_PATH_MAX: ::c_int = 1024;
-
-// WAIT STUFF
-pub const WNOHANG: ::c_int = 0x01;
-pub const WUNTRACED: ::c_int = 0x02;
-
-const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t =
- pthread_mutexattr_t {
- mutexAttrStatus: PTHREAD_INITIALIZED_OBJ,
- mutexAttrProtocol: PTHREAD_PRIO_NONE,
- mutexAttrPrioceiling: 0,
- mutexAttrType: PTHREAD_MUTEX_DEFAULT,
- mutexAttrPshared: 1,
- };
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- mutexSemId: null_mut(),
- mutexValid: PTHREAD_VALID_OBJ,
- mutexInitted: PTHREAD_UNUSED_YET_OBJ,
- mutexCondRefCount: 0,
- mutexSavPriority: -1,
- mutexAttr: PTHREAD_MUTEXATTR_INITIALIZER,
- mutexSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
-};
-
-const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t {
- condAttrStatus: 0xf70990ef,
- condAttrPshared: 1,
- condAttrClockId: CLOCK_REALTIME,
-};
-pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- condSemId: null_mut(),
- condValid: PTHREAD_VALID_OBJ,
- condInitted: PTHREAD_UNUSED_YET_OBJ,
- condRefCount: 0,
- condMutex: null_mut(),
- condAttr: PTHREAD_CONDATTR_INITIALIZER,
- condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
-};
-
-const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t =
- pthread_rwlockattr_t {
- rwlockAttrStatus: PTHREAD_INITIALIZED_OBJ,
- rwlockAttrPshared: 1,
- rwlockAttrMaxReaders: 0,
- rwlockAttrConformOpt: 1,
- };
-pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- rwlockSemId: null_mut(),
- rwlockReadersRefCount: 0,
- rwlockValid: PTHREAD_VALID_OBJ,
- rwlockInitted: PTHREAD_UNUSED_YET_OBJ,
- rwlockAttr: PTHREAD_RWLOCKATTR_INITIALIZER,
- rwlockSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
-};
-
-pub const SEEK_SET: ::c_int = 0;
-pub const SEEK_CUR: ::c_int = 1;
-pub const SEEK_END: ::c_int = 2;
-
-// rtpLibCommon.h
-pub const VX_RTP_NAME_LENGTH: ::c_int = 255;
-pub const RTP_ID_ERROR: ::RTP_ID = -1;
-
-// h/public/unistd.h
-pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 21; // Via unistd.h
-pub const _SC_PAGESIZE: ::c_int = 39;
-pub const O_ACCMODE: ::c_int = 3;
-pub const O_CLOEXEC: ::c_int = 0x100000; // fcntlcom
-pub const O_EXCL: ::c_int = 0x0800;
-pub const O_CREAT: ::c_int = 0x0200;
-pub const O_TRUNC: ::c_int = 0x0400;
-pub const O_APPEND: ::c_int = 0x0008;
-pub const O_RDWR: ::c_int = 0x0002;
-pub const O_WRONLY: ::c_int = 0x0001;
-pub const O_RDONLY: ::c_int = 0;
-pub const O_NONBLOCK: ::c_int = 0x4000;
-
-#[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
- }
-}
-
-f! {
- pub fn CMSG_ALIGN(len: usize) -> usize {
- len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
- }
-
- 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_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
- if (*mhdr).msg_controllen as usize > 0 {
- (*mhdr).msg_control as *mut cmsghdr
- } else {
- 0 as *mut cmsghdr
- }
- }
-
- 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_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
- }
-}
-
-extern "C" {
- 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 isblank(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 atexit(cb: extern "C" 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 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 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 "C" {
- 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 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 creat(path: *const c_char, mode: mode_t) -> ::c_int;
- pub fn rewinddir(dirp: *mut ::DIR);
- pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int;
- pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
- pub fn alarm(seconds: ::c_uint) -> ::c_uint;
- 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 fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
- pub fn getegid() -> gid_t;
- pub fn geteuid() -> uid_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 pathconf(path: *const c_char, name: ::c_int) -> c_long;
- pub fn pause() -> ::c_int;
- pub fn seteuid(uid: uid_t) -> ::c_int;
- pub fn setegid(gid: gid_t) -> ::c_int;
- pub fn sleep(secs: ::c_uint) -> ::c_uint;
- pub fn ttyname(fd: ::c_int) -> *mut c_char;
- pub fn wait(status: *mut ::c_int) -> pid_t;
- pub fn umask(mask: mode_t) -> mode_t;
- pub fn mlock(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 truncate(path: *const c_char, length: off_t) -> ::c_int;
-
- pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
- pub fn pthread_exit(value: *mut ::c_void) -> !;
- pub fn pthread_attr_setdetachstate(
- attr: *mut ::pthread_attr_t,
- state: ::c_int,
- ) -> ::c_int;
-
- pub fn strerror_r(
- errnum: ::c_int,
- buf: *mut c_char,
- buflen: ::size_t,
- ) -> ::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;
-
- #[link_name = "_rtld_dlopen"]
- pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void;
-
- #[link_name = "_rtld_dlerror"]
- pub fn dlerror() -> *mut ::c_char;
-
- #[link_name = "_rtld_dlsym"]
- pub fn dlsym(
- handle: *mut ::c_void,
- symbol: *const ::c_char,
- ) -> *mut ::c_void;
-
- #[link_name = "_rtld_dlclose"]
- pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
-
- #[link_name = "_rtld_dladdr"]
- pub fn dladdr(addr: *mut ::c_void, info: *mut Dl_info) -> ::c_int;
-
- // time.h
- 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 timegm(tm: *mut tm) -> time_t;
- pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
- pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
- pub fn usleep(secs: ::useconds_t) -> ::c_int;
- pub fn putenv(string: *mut c_char) -> ::c_int;
- pub fn setlocale(
- category: ::c_int,
- locale: *const ::c_char,
- ) -> *mut ::c_char;
-
- 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 mkfifo(path: *const c_char, mode: mode_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 mkstemp(template: *mut ::c_char) -> ::c_int;
-
- 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 getline(
- lineptr: *mut *mut c_char,
- n: *mut size_t,
- stream: *mut FILE,
- ) -> ssize_t;
-
-}
-
-extern "C" {
- // stdlib.h
- pub fn memalign(block_size: ::size_t, size_arg: ::size_t)
- -> *mut ::c_void;
-
- // ioLib.h
- pub fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char;
-
- // ioLib.h
- pub fn chdir(attr: *const ::c_char) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutexattr_destroy(
- attr: *mut pthread_mutexattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutexattr_settype(
- pAttr: *mut ::pthread_mutexattr_t,
- pType: ::c_int,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutex_init(
- mutex: *mut pthread_mutex_t,
- attr: *const pthread_mutexattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutex_timedlock(
- attr: *mut pthread_mutex_t,
- spec: *const timespec,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_attr_setname(
- pAttr: *mut ::pthread_attr_t,
- name: *mut ::c_char,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_attr_setstacksize(
- attr: *mut ::pthread_attr_t,
- stacksize: ::size_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_attr_getstacksize(
- attr: *const ::pthread_attr_t,
- size: *mut ::size_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_create(
- pThread: *mut ::pthread_t,
- pAttr: *const ::pthread_attr_t,
- start_routine: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
-
- // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void));
- pub fn pthread_atfork(
- prepare: ::Option<unsafe extern "C" fn()>,
- parent: ::Option<unsafe extern "C" fn()>,
- child: ::Option<unsafe extern "C" fn()>,
- ) -> ::c_int;
- // stat.h
- pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
-
- // stat.h
- pub fn lstat(path: *const ::c_char, buf: *mut stat) -> ::c_int;
-
- // unistd.h
- pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
-
- // dirent.h
- pub fn readdir_r(
- pDir: *mut ::DIR,
- entry: *mut ::dirent,
- result: *mut *mut ::dirent,
- ) -> ::c_int;
-
- // dirent.h
- pub fn readdir(pDir: *mut ::DIR) -> *mut ::dirent;
-
- // fcntl.h or
- // ioLib.h
- pub fn open(path: *const ::c_char, oflag: ::c_int, ...) -> ::c_int;
-
- // poll.h
- pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
-
- // pthread.h
- pub fn pthread_condattr_init(attr: *mut ::pthread_condattr_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_condattr_destroy(
- attr: *mut ::pthread_condattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_condattr_getclock(
- pAttr: *const ::pthread_condattr_t,
- pClockId: *mut ::clockid_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_condattr_setclock(
- pAttr: *mut ::pthread_condattr_t,
- clockId: ::clockid_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_cond_init(
- cond: *mut ::pthread_cond_t,
- attr: *const ::pthread_condattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_cond_signal(cond: *mut ::pthread_cond_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_cond_broadcast(cond: *mut ::pthread_cond_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_cond_wait(
- cond: *mut ::pthread_cond_t,
- mutex: *mut ::pthread_mutex_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlockattr_init(
- attr: *mut ::pthread_rwlockattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlockattr_destroy(
- attr: *mut ::pthread_rwlockattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlockattr_setmaxreaders(
- attr: *mut ::pthread_rwlockattr_t,
- attr2: ::c_uint,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_init(
- attr: *mut ::pthread_rwlock_t,
- host: *const ::pthread_rwlockattr_t,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_destroy(attr: *mut ::pthread_rwlock_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_rdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_tryrdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_timedrdlock(
- attr: *mut ::pthread_rwlock_t,
- host: *const ::timespec,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_wrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_trywrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_timedwrlock(
- attr: *mut ::pthread_rwlock_t,
- host: *const ::timespec,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_rwlock_unlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_key_create(
- key: *mut ::pthread_key_t,
- dtor: ::Option<unsafe extern "C" fn(*mut ::c_void)>,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_key_delete(key: ::pthread_key_t) -> ::c_int;
-
- // pthread.h
- pub fn pthread_setspecific(
- key: ::pthread_key_t,
- value: *const ::c_void,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_getspecific(key: ::pthread_key_t) -> *mut ::c_void;
-
- // pthread.h
- pub fn pthread_cond_timedwait(
- cond: *mut ::pthread_cond_t,
- mutex: *mut ::pthread_mutex_t,
- abstime: *const ::timespec,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_attr_getname(
- attr: *mut ::pthread_attr_t,
- name: *mut *mut ::c_char,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_join(
- thread: ::pthread_t,
- status: *mut *mut ::c_void,
- ) -> ::c_int;
-
- // pthread.h
- pub fn pthread_self() -> ::pthread_t;
-
- // clockLib.h
- pub fn clock_gettime(
- clock_id: ::clockid_t,
- tp: *mut ::timespec,
- ) -> ::c_int;
-
- // clockLib.h
- pub fn clock_settime(
- clock_id: ::clockid_t,
- tp: *const ::timespec,
- ) -> ::c_int;
-
- // clockLib.h
- pub fn clock_getres(
- clock_id: ::clockid_t,
- res: *mut ::timespec,
- ) -> ::c_int;
-
- // clockLib.h
- pub fn clock_nanosleep(
- clock_id: ::clockid_t,
- flags: ::c_int,
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec,
- ) -> ::c_int;
-
- // timerLib.h
- pub fn nanosleep(
- rqtp: *const ::timespec,
- rmtp: *mut ::timespec,
- ) -> ::c_int;
-
- // socket.h
- pub fn accept(
- s: ::c_int,
- addr: *mut ::sockaddr,
- addrlen: *mut ::socklen_t,
- ) -> ::c_int;
-
- // socket.h
- pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t)
- -> ::c_int;
-
- // socket.h
- pub fn connect(
- s: ::c_int,
- name: *const ::sockaddr,
- namelen: ::socklen_t,
- ) -> ::c_int;
-
- // socket.h
- pub fn getpeername(
- s: ::c_int,
- name: *mut ::sockaddr,
- namelen: *mut ::socklen_t,
- ) -> ::c_int;
-
- // socket.h
- pub fn getsockname(
- socket: ::c_int,
- address: *mut sockaddr,
- address_len: *mut socklen_t,
- ) -> ::c_int;
-
- // socket.h
- pub fn getsockopt(
- sockfd: ::c_int,
- level: ::c_int,
- optname: ::c_int,
- optval: *mut ::c_void,
- optlen: *mut ::socklen_t,
- ) -> ::c_int;
-
- // socket.h
- pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
-
- // socket.h
- pub fn recv(
- s: ::c_int,
- buf: *mut ::c_void,
- bufLen: ::size_t,
- flags: ::c_int,
- ) -> ::ssize_t;
-
- // socket.h
- pub fn recvfrom(
- s: ::c_int,
- buf: *mut ::c_void,
- bufLen: ::size_t,
- flags: ::c_int,
- from: *mut ::sockaddr,
- pFromLen: *mut ::socklen_t,
- ) -> ::ssize_t;
-
- pub fn recvmsg(
- socket: ::c_int,
- mp: *mut ::msghdr,
- flags: ::c_int,
- ) -> ::ssize_t;
-
- // socket.h
- pub fn send(
- socket: ::c_int,
- buf: *const ::c_void,
- len: ::size_t,
- flags: ::c_int,
- ) -> ::ssize_t;
-
- pub fn sendmsg(
- socket: ::c_int,
- mp: *const ::msghdr,
- flags: ::c_int,
- ) -> ::ssize_t;
-
- // socket.h
- pub fn sendto(
- socket: ::c_int,
- buf: *const ::c_void,
- len: ::size_t,
- flags: ::c_int,
- addr: *const sockaddr,
- addrlen: socklen_t,
- ) -> ::ssize_t;
-
- // socket.h
- pub fn setsockopt(
- socket: ::c_int,
- level: ::c_int,
- name: ::c_int,
- value: *const ::c_void,
- option_len: socklen_t,
- ) -> ::c_int;
-
- // socket.h
- pub fn shutdown(s: ::c_int, how: ::c_int) -> ::c_int;
-
- // socket.h
- pub fn socket(
- domain: ::c_int,
- _type: ::c_int,
- protocol: ::c_int,
- ) -> ::c_int;
-
- // icotl.h
- pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
-
- // fcntl.h
- pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
-
- // ntp_rfc2553.h for kernel
- // netdb.h for user
- pub fn gai_strerror(errcode: ::c_int) -> *mut ::c_char;
-
- // ioLib.h or
- // unistd.h
- pub fn close(fd: ::c_int) -> ::c_int;
-
- // ioLib.h or
- // unistd.h
- pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
- -> ::ssize_t;
-
- // ioLib.h or
- // unistd.h
- pub fn write(
- fd: ::c_int,
- buf: *const ::c_void,
- count: ::size_t,
- ) -> ::ssize_t;
-
- // ioLib.h or
- // unistd.h
- pub fn isatty(fd: ::c_int) -> ::c_int;
-
- // ioLib.h or
- // unistd.h
- pub fn dup(src: ::c_int) -> ::c_int;
-
- // ioLib.h or
- // unistd.h
- pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
-
- // ioLib.h or
- // unistd.h
- pub fn pipe(fds: *mut ::c_int) -> ::c_int;
-
- // ioLib.h or
- // unistd.h
- pub fn unlink(pathname: *const ::c_char) -> ::c_int;
-
- // unistd.h and
- // ioLib.h
- pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
-
- // netdb.h
- pub fn getaddrinfo(
- node: *const ::c_char,
- service: *const ::c_char,
- hints: *const addrinfo,
- res: *mut *mut addrinfo,
- ) -> ::c_int;
-
- // netdb.h
- pub fn freeaddrinfo(res: *mut addrinfo);
-
- // signal.h
- pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
-
- // unistd.h
- pub fn getpid() -> pid_t;
-
- // unistd.h
- pub fn getppid() -> pid_t;
-
- // wait.h
- pub fn waitpid(pid: pid_t, status: *mut ::c_int, optons: ::c_int)
- -> pid_t;
-
- // unistd.h
- pub fn sysconf(attr: ::c_int) -> ::c_long;
-
- // stdlib.h
- pub fn setenv(
- // setenv.c
- envVarName: *const ::c_char,
- envVarValue: *const ::c_char,
- overwrite: ::c_int,
- ) -> ::c_int;
-
- // stdlib.h
- pub fn unsetenv(
- // setenv.c
- envVarName: *const ::c_char,
- ) -> ::c_int;
-
- // stdlib.h
- pub fn realpath(
- fileName: *const ::c_char,
- resolvedName: *mut ::c_char,
- ) -> *mut ::c_char;
-
- // unistd.h
- pub fn link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int;
-
- // unistd.h
- pub fn readlink(
- path: *const ::c_char,
- buf: *mut ::c_char,
- bufsize: ::size_t,
- ) -> ::ssize_t;
-
- // unistd.h
- pub fn symlink(path1: *const ::c_char, path2: *const ::c_char) -> ::c_int;
-
- // dirent.h
- pub fn opendir(name: *const ::c_char) -> *mut ::DIR;
-
- // unistd.h
- pub fn rmdir(path: *const ::c_char) -> ::c_int;
-
- // stat.h
- pub fn mkdir(dirName: *const ::c_char, mode: ::mode_t) -> ::c_int;
-
- // stat.h
- pub fn chmod(path: *const ::c_char, mode: ::mode_t) -> ::c_int;
-
- // stat.h
- pub fn fchmod(attr1: ::c_int, attr2: ::mode_t) -> ::c_int;
-
- // unistd.h
- pub fn fsync(fd: ::c_int) -> ::c_int;
-
- // dirent.h
- pub fn closedir(ptr: *mut ::DIR) -> ::c_int;
-
- // sched.h
- pub fn sched_yield() -> ::c_int;
-
- // errnoLib.h
- pub fn errnoSet(err: ::c_int) -> ::c_int;
-
- // errnoLib.h
- pub fn errnoGet() -> ::c_int;
-
- // unistd.h
- pub fn _exit(status: ::c_int) -> !;
-
- // unistd.h
- pub fn setgid(gid: ::gid_t) -> ::c_int;
-
- // unistd.h
- pub fn getgid() -> ::gid_t;
-
- // unistd.h
- pub fn setuid(uid: ::uid_t) -> ::c_int;
-
- // unistd.h
- pub fn getuid() -> ::uid_t;
-
- // signal.h
- pub fn sigemptyset(__set: *mut sigset_t) -> ::c_int;
-
- // pthread.h for kernel
- // signal.h for user
- pub fn pthread_sigmask(
- __how: ::c_int,
- __set: *const sigset_t,
- __oset: *mut sigset_t,
- ) -> ::c_int;
-
- // signal.h for user
- pub fn kill(__pid: pid_t, __signo: ::c_int) -> ::c_int;
-
- // signal.h for user
- pub fn sigqueue(
- __pid: pid_t,
- __signo: ::c_int,
- __value: ::sigval,
- ) -> ::c_int;
-
- // signal.h for user
- pub fn _sigqueue(
- rtpId: ::RTP_ID,
- signo: ::c_int,
- pValue: *const ::sigval,
- sigCode: ::c_int,
- ) -> ::c_int;
-
- // signal.h
- pub fn taskKill(taskId: ::TASK_ID, signo: ::c_int) -> ::c_int;
-
- // signal.h
- pub fn raise(__signo: ::c_int) -> ::c_int;
-
- // taskLibCommon.h
- pub fn taskIdSelf() -> ::TASK_ID;
- pub fn taskDelay(ticks: ::_Vx_ticks_t) -> ::c_int;
-
- // rtpLibCommon.h
- pub fn rtpInfoGet(rtpId: ::RTP_ID, rtpStruct: *mut ::RTP_DESC) -> ::c_int;
- pub fn rtpSpawn(
- pubrtpFileName: *const ::c_char,
- argv: *mut *const ::c_char,
- envp: *mut *const ::c_char,
- priority: ::c_int,
- uStackSize: ::size_t,
- options: ::c_int,
- taskOptions: ::c_int,
- ) -> RTP_ID;
-
- // ioLib.h
- pub fn _realpath(
- fileName: *const ::c_char,
- resolvedName: *mut ::c_char,
- ) -> *mut ::c_char;
-
- // pathLib.h
- pub fn _pathIsAbsolute(
- filepath: *const ::c_char,
- pNameTail: *mut *const ::c_char,
- ) -> BOOL;
-
- 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;
-
- // randomNumGen.h
- pub fn randBytes(buf: *mut c_uchar, length: c_int) -> c_int;
- pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int;
- pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int;
- pub fn randSecure() -> c_int;
-}
-
-//Dummy functions, these don't really exist in VxWorks.
-
-// wait.h macros
-pub fn WIFEXITED(status: ::c_int) -> bool {
- (status & 0xFF00) == 0
-}
-pub fn WIFSIGNALED(status: ::c_int) -> bool {
- (status & 0xFF00) != 0
-}
-pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0xFF0000) != 0
-}
-pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
- status & 0xFF
-}
-pub fn WTERMSIG(status: ::c_int) -> ::c_int {
- (status >> 8) & 0xFF
-}
-pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
- (status >> 16) & 0xFF
-}
-
-pub fn pread(
- _fd: ::c_int,
- _buf: *mut ::c_void,
- _count: ::size_t,
- _offset: off64_t,
-) -> ::ssize_t {
- -1
-}
-
-pub fn pwrite(
- _fd: ::c_int,
- _buf: *const ::c_void,
- _count: ::size_t,
- _offset: off64_t,
-) -> ::ssize_t {
- -1
-}
-pub fn posix_memalign(
- memptr: *mut *mut ::c_void,
- align: ::size_t,
- size: ::size_t,
-) -> ::c_int {
- // check to see if align is a power of 2 and if align is a multiple
- // of sizeof(void *)
- if (align & align - 1 != 0)
- || (align as usize % size_of::<::size_t>() != 0)
- {
- return ::EINVAL;
- }
-
- unsafe {
- // posix_memalign should not set errno
- let e = ::errnoGet();
-
- let temp = memalign(align, size);
- ::errnoSet(e as ::c_int);
-
- if temp.is_null() {
- ::ENOMEM
- } else {
- *memptr = temp;
- 0
- }
- }
-}
-
-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(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 if #[cfg(any(target_arch = "powerpc"))] {
- mod powerpc;
- pub use self::powerpc::*;
- } else if #[cfg(any(target_arch = "powerpc64"))] {
- mod powerpc64;
- pub use self::powerpc64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/vxworks/powerpc.rs b/libc/src/vxworks/powerpc.rs
deleted file mode 100644
index 5524006..0000000
--- a/libc/src/vxworks/powerpc.rs
+++ /dev/null
@@ -1,4 +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/vxworks/powerpc64.rs b/libc/src/vxworks/powerpc64.rs
deleted file mode 100644
index 4032488..0000000
--- a/libc/src/vxworks/powerpc64.rs
+++ /dev/null
@@ -1,4 +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/vxworks/x86.rs b/libc/src/vxworks/x86.rs
deleted file mode 100644
index e617bb8..0000000
--- a/libc/src/vxworks/x86.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type c_long = i32;
-pub type c_ulong = u32;
diff --git a/libc/src/vxworks/x86_64.rs b/libc/src/vxworks/x86_64.rs
deleted file mode 100644
index 5e95ea2..0000000
--- a/libc/src/vxworks/x86_64.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-pub type c_char = i8;
-pub type wchar_t = i32;
-pub type c_long = i64;
-pub type c_ulong = u64;
diff --git a/libc/src/wasi.rs b/libc/src/wasi.rs
deleted file mode 100644
index 2e0914d..0000000
--- a/libc/src/wasi.rs
+++ /dev/null
@@ -1,743 +0,0 @@
-pub use ffi::c_void;
-
-pub type c_char = i8;
-pub type c_uchar = u8;
-pub type c_schar = i8;
-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_rights_t = u64;
-
-#[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],
- }
-}
-
-// 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 = 0x0001;
-pub const O_DSYNC: c_int = 0x0002;
-pub const O_NONBLOCK: c_int = 0x0004;
-pub const O_RSYNC: c_int = 0x0008;
-pub const O_SYNC: c_int = 0x0010;
-pub const O_CREAT: c_int = 0x0001 << 12;
-pub const O_DIRECTORY: c_int = 0x0002 << 12;
-pub const O_EXCL: c_int = 0x0004 << 12;
-pub const O_TRUNC: c_int = 0x0008 << 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 = 4;
-pub const POSIX_FADV_NOREUSE: c_int = 5;
-pub const POSIX_FADV_NORMAL: c_int = 0;
-pub const POSIX_FADV_RANDOM: c_int = 2;
-pub const POSIX_FADV_SEQUENTIAL: c_int = 1;
-pub const POSIX_FADV_WILLNEED: c_int = 3;
-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 UTIME_OMIT: c_long = 1073741822;
-pub const UTIME_NOW: c_long = 1073741823;
-
-pub const E2BIG: c_int = 1;
-pub const EACCES: c_int = 2;
-pub const EADDRINUSE: c_int = 3;
-pub const EADDRNOTAVAIL: c_int = 4;
-pub const EAFNOSUPPORT: c_int = 5;
-pub const EAGAIN: c_int = 6;
-pub const EALREADY: c_int = 7;
-pub const EBADF: c_int = 8;
-pub const EBADMSG: c_int = 9;
-pub const EBUSY: c_int = 10;
-pub const ECANCELED: c_int = 11;
-pub const ECHILD: c_int = 12;
-pub const ECONNABORTED: c_int = 13;
-pub const ECONNREFUSED: c_int = 14;
-pub const ECONNRESET: c_int = 15;
-pub const EDEADLK: c_int = 16;
-pub const EDESTADDRREQ: c_int = 17;
-pub const EDOM: c_int = 18;
-pub const EDQUOT: c_int = 19;
-pub const EEXIST: c_int = 20;
-pub const EFAULT: c_int = 21;
-pub const EFBIG: c_int = 22;
-pub const EHOSTUNREACH: c_int = 23;
-pub const EIDRM: c_int = 24;
-pub const EILSEQ: c_int = 25;
-pub const EINPROGRESS: c_int = 26;
-pub const EINTR: c_int = 27;
-pub const EINVAL: c_int = 28;
-pub const EIO: c_int = 29;
-pub const EISCONN: c_int = 30;
-pub const EISDIR: c_int = 31;
-pub const ELOOP: c_int = 32;
-pub const EMFILE: c_int = 33;
-pub const EMLINK: c_int = 34;
-pub const EMSGSIZE: c_int = 35;
-pub const EMULTIHOP: c_int = 36;
-pub const ENAMETOOLONG: c_int = 37;
-pub const ENETDOWN: c_int = 38;
-pub const ENETRESET: c_int = 39;
-pub const ENETUNREACH: c_int = 40;
-pub const ENFILE: c_int = 41;
-pub const ENOBUFS: c_int = 42;
-pub const ENODEV: c_int = 43;
-pub const ENOENT: c_int = 44;
-pub const ENOEXEC: c_int = 45;
-pub const ENOLCK: c_int = 46;
-pub const ENOLINK: c_int = 47;
-pub const ENOMEM: c_int = 48;
-pub const ENOMSG: c_int = 49;
-pub const ENOPROTOOPT: c_int = 50;
-pub const ENOSPC: c_int = 51;
-pub const ENOSYS: c_int = 52;
-pub const ENOTCONN: c_int = 53;
-pub const ENOTDIR: c_int = 54;
-pub const ENOTEMPTY: c_int = 55;
-pub const ENOTRECOVERABLE: c_int = 56;
-pub const ENOTSOCK: c_int = 57;
-pub const ENOTSUP: c_int = 58;
-pub const ENOTTY: c_int = 59;
-pub const ENXIO: c_int = 60;
-pub const EOVERFLOW: c_int = 61;
-pub const EOWNERDEAD: c_int = 62;
-pub const EPERM: c_int = 63;
-pub const EPIPE: c_int = 64;
-pub const EPROTO: c_int = 65;
-pub const EPROTONOSUPPORT: c_int = 66;
-pub const EPROTOTYPE: c_int = 67;
-pub const ERANGE: c_int = 68;
-pub const EROFS: c_int = 69;
-pub const ESPIPE: c_int = 70;
-pub const ESRCH: c_int = 71;
-pub const ESTALE: c_int = 72;
-pub const ETIMEDOUT: c_int = 73;
-pub const ETXTBSY: c_int = 74;
-pub const EXDEV: c_int = 75;
-pub const ENOTCAPABLE: c_int = 76;
-pub const EOPNOTSUPP: c_int = ENOTSUP;
-pub const EWOULDBLOCK: c_int = EAGAIN;
-
-#[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 "C" {
- 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 "C" fn()) -> c_int;
- pub fn at_quick_exit(a: extern "C" 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;
-}
diff --git a/libc/src/windows/gnu/align.rs b/libc/src/windows/gnu/align.rs
deleted file mode 100644
index 3af99e3..0000000
--- a/libc/src/windows/gnu/align.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-cfg_if! {
- if #[cfg(target_pointer_width = "64")] {
- s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [f64; 4]
- }
- }
- } else if #[cfg(target_pointer_width = "32")] {
- s_no_extra_traits! {
- #[allow(missing_debug_implementations)]
- #[repr(align(16))]
- pub struct max_align_t {
- priv_: [i64; 6]
- }
- }
- }
-}
diff --git a/libc/src/windows/gnu/mod.rs b/libc/src/windows/gnu/mod.rs
deleted file mode 100644
index e74628b..0000000
--- a/libc/src/windows/gnu/mod.rs
+++ /dev/null
@@ -1,23 +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 "C" {
- 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;
-}
-
-cfg_if! {
- if #[cfg(libc_align)] {
- mod align;
- pub use self::align::*;
- }
-}
diff --git a/libc/src/windows/mod.rs b/libc/src/windows/mod.rs
deleted file mode 100644
index a83baba..0000000
--- a/libc/src/windows/mod.rs
+++ /dev/null
@@ -1,604 +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;
-
-// POSIX Supplement (from errno.h)
-pub const EADDRINUSE: ::c_int = 100;
-pub const EADDRNOTAVAIL: ::c_int = 101;
-pub const EAFNOSUPPORT: ::c_int = 102;
-pub const EALREADY: ::c_int = 103;
-pub const EBADMSG: ::c_int = 104;
-pub const ECANCELED: ::c_int = 105;
-pub const ECONNABORTED: ::c_int = 106;
-pub const ECONNREFUSED: ::c_int = 107;
-pub const ECONNRESET: ::c_int = 108;
-pub const EDESTADDRREQ: ::c_int = 109;
-pub const EHOSTUNREACH: ::c_int = 110;
-pub const EIDRM: ::c_int = 111;
-pub const EINPROGRESS: ::c_int = 112;
-pub const EISCONN: ::c_int = 113;
-pub const ELOOP: ::c_int = 114;
-pub const EMSGSIZE: ::c_int = 115;
-pub const ENETDOWN: ::c_int = 116;
-pub const ENETRESET: ::c_int = 117;
-pub const ENETUNREACH: ::c_int = 118;
-pub const ENOBUFS: ::c_int = 119;
-pub const ENODATA: ::c_int = 120;
-pub const ENOLINK: ::c_int = 121;
-pub const ENOMSG: ::c_int = 122;
-pub const ENOPROTOOPT: ::c_int = 123;
-pub const ENOSR: ::c_int = 124;
-pub const ENOSTR: ::c_int = 125;
-pub const ENOTCONN: ::c_int = 126;
-pub const ENOTRECOVERABLE: ::c_int = 127;
-pub const ENOTSOCK: ::c_int = 128;
-pub const ENOTSUP: ::c_int = 129;
-pub const EOPNOTSUPP: ::c_int = 130;
-pub const EOVERFLOW: ::c_int = 132;
-pub const EOWNERDEAD: ::c_int = 133;
-pub const EPROTO: ::c_int = 134;
-pub const EPROTONOSUPPORT: ::c_int = 135;
-pub const EPROTOTYPE: ::c_int = 136;
-pub const ETIME: ::c_int = 137;
-pub const ETIMEDOUT: ::c_int = 138;
-pub const ETXTBSY: ::c_int = 139;
-pub const EWOULDBLOCK: ::c_int = 140;
-
-// 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 "C" {}
-
-#[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 "C" {
- 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 isblank(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 "C" 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 = "_time64"]
- pub fn time(destTime: *mut time_t) -> time_t;
- #[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 = "_lseeki64"]
- pub fn lseek64(
- fd: ::c_int,
- offset: c_longlong,
- origin: ::c_int,
- ) -> c_longlong;
- #[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 8f20deb..0000000
--- a/libc/src/windows/msvc.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-pub const L_tmpnam: ::c_uint = 260;
-pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
-
-// POSIX Supplement (from errno.h)
-// This particular error code is only currently available in msvc toolchain
-pub const EOTHER: ::c_int = 131;
-
-extern "C" {
- #[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/libc/tests/const_fn.rs b/libc/tests/const_fn.rs
deleted file mode 100644
index 0e7e186..0000000
--- a/libc/tests/const_fn.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-#![cfg(libc_const_extern_fn)] // If this does not hold, the file is empty
-
-#[cfg(target_os = "linux")]
-const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) };
-//^ if CMSG_SPACE is not const, this will fail to compile
diff --git a/nitrocli/Cargo.lock b/nitrocli/Cargo.lock
deleted file mode 100644
index 5f9eacf..0000000
--- a/nitrocli/Cargo.lock
+++ /dev/null
@@ -1,255 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-[[package]]
-name = "aho-corasick"
-version = "0.7.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "base32"
-version = "0.4.0"
-
-[[package]]
-name = "bitflags"
-version = "1.2.1"
-
-[[package]]
-name = "cc"
-version = "1.0.48"
-
-[[package]]
-name = "cfg-if"
-version = "0.1.10"
-
-[[package]]
-name = "clap"
-version = "2.33.0"
-dependencies = [
- "bitflags 1.2.1",
- "textwrap 0.11.0",
- "unicode-width 0.1.7",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.1.13"
-dependencies = [
- "cfg-if 0.1.10",
- "libc 0.2.66",
- "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "heck"
-version = "0.3.1"
-dependencies = [
- "unicode-segmentation 1.6.0",
-]
-
-[[package]]
-name = "lazy_static"
-version = "1.4.0"
-
-[[package]]
-name = "libc"
-version = "0.2.66"
-
-[[package]]
-name = "memchr"
-version = "2.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "nitrocli"
-version = "0.3.1"
-dependencies = [
- "base32 0.4.0",
- "libc 0.2.66",
- "nitrokey 0.5.1",
- "nitrokey-test 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "nitrokey-test-state 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "structopt 0.3.7",
-]
-
-[[package]]
-name = "nitrokey"
-version = "0.5.1"
-dependencies = [
- "lazy_static 1.4.0",
- "libc 0.2.66",
- "nitrokey-sys 3.5.0",
- "rand_core 0.5.1",
-]
-
-[[package]]
-name = "nitrokey-sys"
-version = "3.5.0"
-dependencies = [
- "cc 1.0.48",
-]
-
-[[package]]
-name = "nitrokey-test"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "syn 1.0.12",
-]
-
-[[package]]
-name = "nitrokey-test-state"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "proc-macro-error"
-version = "0.4.4"
-dependencies = [
- "proc-macro-error-attr 0.4.3",
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "rustversion 1.0.1",
- "syn 1.0.12",
-]
-
-[[package]]
-name = "proc-macro-error-attr"
-version = "0.4.3"
-dependencies = [
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "rustversion 1.0.1",
- "syn 1.0.12",
- "syn-mid 0.4.0",
-]
-
-[[package]]
-name = "proc-macro2"
-version = "1.0.7"
-dependencies = [
- "unicode-xid 0.2.0",
-]
-
-[[package]]
-name = "quote"
-version = "1.0.2"
-dependencies = [
- "proc-macro2 1.0.7",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.5.1"
-dependencies = [
- "getrandom 0.1.13",
-]
-
-[[package]]
-name = "regex"
-version = "1.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "regex-syntax"
-version = "0.6.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "rustversion"
-version = "1.0.1"
-dependencies = [
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "syn 1.0.12",
-]
-
-[[package]]
-name = "structopt"
-version = "0.3.7"
-dependencies = [
- "clap 2.33.0",
- "structopt-derive 0.4.0",
-]
-
-[[package]]
-name = "structopt-derive"
-version = "0.4.0"
-dependencies = [
- "heck 0.3.1",
- "proc-macro-error 0.4.4",
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "syn 1.0.12",
-]
-
-[[package]]
-name = "syn"
-version = "1.0.12"
-dependencies = [
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "unicode-xid 0.2.0",
-]
-
-[[package]]
-name = "syn-mid"
-version = "0.4.0"
-dependencies = [
- "proc-macro2 1.0.7",
- "quote 1.0.2",
- "syn 1.0.12",
-]
-
-[[package]]
-name = "textwrap"
-version = "0.11.0"
-dependencies = [
- "unicode-width 0.1.7",
-]
-
-[[package]]
-name = "thread_local"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "lazy_static 1.4.0",
-]
-
-[[package]]
-name = "unicode-segmentation"
-version = "1.6.0"
-
-[[package]]
-name = "unicode-width"
-version = "0.1.7"
-
-[[package]]
-name = "unicode-xid"
-version = "0.2.0"
-
-[[package]]
-name = "wasi"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[metadata]
-"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
-"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
-"checksum nitrokey-test 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f3da0c2cedaa512f79fbc3ed45143a52c76c5edcca88d0823b967ff11d05fe37"
-"checksum nitrokey-test-state 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a59b732ed6d5212424ed31ec9649f05652bcbc38f45f2292b27a6044e7098803"
-"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
-"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
-"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
-"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
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 a440ca1..0000000
--- a/nitrokey-sys/CHANGELOG.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# v3.5.0 (2019-07-04)
-- Mark deprecated functions using the `deprecated` attribute.
-- Update to libnitrokey 3.5, causing all following changes.
-- New constant `NK_PWS_SLOT_COUNT`.
-- New structures:
- - `NK_device_info`
- - `NK_status`
- - `NK_SD_usage_data`
- - `ReadSlot_t`
-- New functions:
- - `NK_get_SD_usage_data`
- - `NK_get_status`
- - `NK_get_status_as_string`
- - `NK_list_devices`
- - `NK_free_device_info`
- - `NK_connect_with_path`
- - `NK_enable_firmware_update_pro`
- - `NK_change_firmware_password_pro`
- - `NK_read_HOTP_slot`
-- Deprecated functions:
- - `NK_status`
-- Changed the return type for `NK_get_major_firmware_version` and
- `NK_get_minor_firmware_version` to `u8`.
-- Changed `NK_get_progress_bar_value` to return -2 instead of 0 if an error
- occurs.
-
-# 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 068670b..0000000
--- a/nitrokey-sys/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "nitrokey-sys"
-version = "3.5.0"
-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 a9d0778..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: 5,
- patch: None,
-};
-
-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.5/DeviceCommunicationExceptions.cpp b/nitrokey-sys/libnitrokey-v3.5/DeviceCommunicationExceptions.cpp
deleted file mode 100644
index 4d62aad..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/LICENSE b/nitrokey-sys/libnitrokey-v3.5/LICENSE
deleted file mode 100644
index 341c30b..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/NK_C_API.cc b/nitrokey-sys/libnitrokey-v3.5/NK_C_API.cc
deleted file mode 100644
index 1d3fa3a..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/NK_C_API.cc
+++ /dev/null
@@ -1,910 +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 "libnitrokey/device_proto.h"
-#include "libnitrokey/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;
-
-const uint8_t NK_PWS_SLOT_COUNT = PWS_SLOT_COUNT;
-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() {
- return NK_get_status_as_string();
- }
-
- NK_C_API char * NK_get_status_as_string() {
- 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 int NK_get_status(struct NK_status* out) {
- if (out == nullptr) {
- return -1;
- }
- auto m = NitrokeyManager::instance();
- auto result = get_with_status([&]() {
- return m->get_status();
- }, proto::stick10::GetStatus::ResponsePayload());
- auto error_code = std::get<0>(result);
- if (error_code != 0) {
- return error_code;
- }
-
- auto status = std::get<1>(result);
- out->firmware_version_major = status.firmware_version_st.major;
- out->firmware_version_minor = status.firmware_version_st.minor;
- out->serial_number_smart_card = status.card_serial_u32;
- out->config_numlock = status.numlock;
- out->config_capslock = status.capslock;
- out->config_scrolllock = status.scrolllock;
- out->otp_user_password = status.enable_user_password != 0;
- return 0;
- }
-
- 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 int NK_get_SD_usage_data(struct NK_SD_usage_data* out) {
- if (out == nullptr)
- return -1;
- auto m = NitrokeyManager::instance();
- auto result = get_with_status([&]() {
- return m->get_SD_usage_data();
- }, std::make_pair<uint8_t, uint8_t>(0, 0));
- auto error_code = std::get<0>(result);
- if (error_code != 0)
- return error_code;
-
- auto data = std::get<1>(result);
- out->write_level_min = std::get<0>(data);
- out->write_level_max = std::get<1>(data);
-
- 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 std::get<1>(get_with_status([&]() {
- return m->get_progress_bar_value();
- }, -2));
- }
-
- NK_C_API uint8_t NK_get_major_firmware_version() {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->get_major_firmware_version();
- });
- }
-
- NK_C_API uint8_t 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);
- });
- }
-
- bool copy_device_info(const DeviceInfo& source, NK_device_info* target) {
- switch (source.m_deviceModel) {
- case DeviceModel::PRO:
- target->model = NK_PRO;
- break;
- case DeviceModel::STORAGE:
- target->model = NK_STORAGE;
- break;
- default:
- return false;
- }
-
- target->path = strndup(source.m_path.c_str(), MAXIMUM_STR_REPLY_LENGTH);
- target->serial_number = strndup(source.m_serialNumber.c_str(), MAXIMUM_STR_REPLY_LENGTH);
- target->next = nullptr;
-
- return target->path && target->serial_number;
- }
-
- NK_C_API struct NK_device_info* NK_list_devices() {
- auto nm = NitrokeyManager::instance();
- return get_with_result([&]() -> NK_device_info* {
- auto v = nm->list_devices();
- if (v.empty())
- return nullptr;
-
- auto result = new NK_device_info();
- auto ptr = result;
- auto first = v.begin();
- if (!copy_device_info(*first, ptr)) {
- NK_free_device_info(result);
- return nullptr;
- }
- v.erase(first);
-
- for (auto& info : v) {
- ptr->next = new NK_device_info();
- ptr = ptr->next;
-
- if (!copy_device_info(info, ptr)) {
- NK_free_device_info(result);
- return nullptr;
- }
- }
- return result;
- });
- }
-
- NK_C_API void NK_free_device_info(struct NK_device_info* device_info) {
- if (!device_info)
- return;
-
- if (device_info->next)
- NK_free_device_info(device_info->next);
-
- free(device_info->path);
- free(device_info->serial_number);
- delete device_info;
- }
-
- 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_connect_with_path(const char* path) {
- auto m = NitrokeyManager::instance();
- return get_with_result([&]() {
- return m->connect_with_path(path) ? 1 : 0;
- });
- }
-
-
- NK_C_API int NK_wink() {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- return m->wink();
- });
- }
-
- NK_C_API int NK_enable_firmware_update_pro(const char* update_password){
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->enable_firmware_update_pro(update_password);
- });
-}
-
- NK_C_API int NK_change_firmware_password_pro(const char *current_firmware_password, const char *new_firmware_password) {
- auto m = NitrokeyManager::instance();
- return get_without_result([&]() {
- m->change_firmware_update_password_pro(current_firmware_password,
- new_firmware_password);
- });
- }
-
-
- NK_C_API int NK_read_HOTP_slot(const uint8_t slot_num, struct ReadSlot_t* out){
- if (out == nullptr)
- return -1;
- auto m = NitrokeyManager::instance();
- auto result = get_with_status([&]() {
- return m->get_HOTP_slot_data(slot_num);
- }, stick10::ReadSlot::ResponsePayload() );
- auto error_code = std::get<0>(result);
- if (error_code != 0) {
- return error_code;
- }
-#define a(x) out->x = read_slot.x
- stick10::ReadSlot::ResponsePayload read_slot = std::get<1>(result);
- a(_slot_config);
- a(slot_counter);
-#undef a
-#define m(x) memmove(out->x, read_slot.x, sizeof(read_slot.x))
- m(slot_name);
- m(slot_token_id);
-#undef m
- return 0;
-}
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.5/NK_C_API.h b/nitrokey-sys/libnitrokey-v3.5/NK_C_API.h
deleted file mode 100644
index d5c54a3..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/NK_C_API.h
+++ /dev/null
@@ -1,1014 +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
-
-/**
- * \file
- *
- * C API for libnitrokey
- *
- * \mainpage
- *
- * **libnitrokey** provides access to Nitrokey Pro and Nitrokey Storage devices.
- * This documentation describes libnitrokey’s C API. For a list of the
- * available functions, see the NK_C_API.h file.
- *
- * \section getting_started Example
- *
- * \code{.c}
- * #include <stdio.h>
- * #include <stdlib.h>
- * #include <libnitrokey/NK_C_API.h>
- *
- * int main(void)
- * {
- * if (NK_login_auto() != 1) {
- * fprintf(stderr, "No Nitrokey found.\n");
- * return 1;
- * }
- *
- * NK_device_model model = NK_get_device_model();
- * printf("Connected to ");
- * switch (model) {
- * case NK_PRO:
- * printf("a Nitrokey Pro");
- * break;
- * case NK_STORAGE:
- * printf("a Nitrokey Storage");
- * break;
- * default:
- * printf("an unsupported Nitrokey");
- * break;
- * }
- *
- * char* serial_number = NK_device_serial_number();
- * if (serial_number)
- * printf(" with serial number %s\n", serial_number);
- * else
- * printf(" -- could not query serial number!\n");
- * free(serial_number);
- *
- * NK_logout();
- * return 0;
- * }
- * \endcode
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /**
- * The number of slots in the password safe.
- */
- extern const uint8_t NK_PWS_SLOT_COUNT;
-
- 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
- };
-
- /**
- * The connection info for a Nitrokey device as a linked list.
- */
- struct NK_device_info {
- /**
- * The model of the Nitrokey device.
- */
- enum NK_device_model model;
- /**
- * The USB device path for NK_connect_with_path.
- */
- char* path;
- /**
- * The serial number.
- */
- char* serial_number;
- /**
- * The pointer to the next element of the linked list or null
- * if this is the last element in the list.
- */
- struct NK_device_info* next;
- };
-
- /**
- * Stores the common device status for all Nitrokey devices.
- */
- struct NK_status {
- /**
- * 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;
- /**
- * The serial number of the smart card.
- */
- uint32_t serial_number_smart_card;
- /**
- * The HOTP slot to generate a password from if the numlock
- * key is pressed twice (slot 0-1, or any other value to
- * disable the function).
- */
- uint8_t config_numlock;
- /**
- * The HOTP slot to generate a password from if the capslock
- * key is pressed twice (slot 0-1, or any other value to
- * disable the function).
- */
- uint8_t config_capslock;
- /**
- * The HOTP slot to generate a password from if the scrolllock
- * key is pressed twice (slot 0-1, or any other value to
- * disable the function).
- */
- uint8_t config_scrolllock;
- /**
- * Indicates whether the user password is required to generate
- * an OTP value.
- */
- bool otp_user_password;
- };
-
- /**
- * 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;
- };
-
- /**
- * Data about the usage of the SD card.
- */
- struct NK_SD_usage_data {
- /**
- * The minimum write level, as a percentage of the total card
- * size.
- */
- uint8_t write_level_min;
- /**
- * The maximum write level, as a percentage of the total card
- * size.
- */
- uint8_t write_level_max;
- };
-
-
- 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. This function is
- * deprecated in favor of NK_get_status_as_string.
- * @return string representation of the status or an empty string
- * if the command failed
- */
- DEPRECATED
- NK_C_API char * NK_status();
-
- /**
- * Return the debug status string. Debug purposes.
- * @return string representation of the status or an empty string
- * if the command failed
- */
- NK_C_API char * NK_get_status_as_string();
-
- /**
- * Get the stick status common to all Nitrokey devices 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 status
- * @return command processing error code
- */
- NK_C_API int NK_get_status(struct NK_status* out);
-
- /**
- * 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 uint8_t 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 uint8_t 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. Usable during hidden volumes creation.
- * If the command was successful (return value 0), the usage data is
- * written to the output pointer’s target. The output pointer must
- * not be null.
- * Storage only
- * @param out the output pointer for the usage data
- * @return command processing error code
- */
- NK_C_API int NK_get_SD_usage_data(struct NK_SD_usage_data* 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 or -2 if an
- * error occured
- */
- 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();
-
- /**
- * Returns a linked list of all connected devices, or null if no devices
- * are connected or an error occured. The linked list must be freed by
- * calling NK_free_device_info.
- * @return a linked list of all connected devices
- */
- NK_C_API struct NK_device_info* NK_list_devices();
-
- /**
- * Free a linked list returned by NK_list_devices.
- * @param the linked list to free or null
- */
- NK_C_API void NK_free_device_info(struct NK_device_info* device_info);
-
-/**
- * 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);
-
- /**
- * Connects to a device with the given path. The path is a USB device
- * path as returned by hidapi.
- * @param path the device path
- * @return 1 on successful connection, 0 otherwise
- */
- NK_C_API int NK_connect_with_path(const char* path);
-
- /**
- * Blink red and green LED alternatively and infinitely (until device is reconnected).
- * @return command processing error code
- */
- NK_C_API int NK_wink();
-
-
- /**
- * Enable update mode on Nitrokey Pro.
- * Supported from v0.11.
- * @param update_password 20 bytes update password
- * @return command processing error code
- */
- NK_C_API int NK_enable_firmware_update_pro(const char* update_password);
-
- /**
- * Change update-mode password on Nitrokey Pro.
- * Supported from v0.11.
- * @param current_firmware_password 20 bytes update password
- * @param new_firmware_password 20 bytes update password
- * @return command processing error code
- */
- NK_C_API int NK_change_firmware_password_pro(const char *current_firmware_password, const char *new_firmware_password);
-
-
-// as in ReadSlot::ResponsePayload
-struct ReadSlot_t {
- uint8_t slot_name[15];
- uint8_t _slot_config;
- uint8_t slot_token_id[13];
- uint64_t slot_counter;
-};
-
-
-NK_C_API int NK_read_HOTP_slot(const uint8_t slot_num, struct ReadSlot_t* out);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //LIBNITROKEY_NK_C_API_H
diff --git a/nitrokey-sys/libnitrokey-v3.5/NitrokeyManager.cc b/nitrokey-sys/libnitrokey-v3.5/NitrokeyManager.cc
deleted file mode 100644
index 6c26a43..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/NitrokeyManager.cc
+++ /dev/null
@@ -1,1199 +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 "libnitrokey/misc.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<DeviceInfo> NitrokeyManager::list_devices(){
- std::lock_guard<std::mutex> lock(mex_dev_com_manager);
-
- return Device::enumerate();
- }
-
- 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;
- const auto v = Device::enumerate();
- LOGD1("Discovering IDs");
- for (auto & i: v){
- if (i.m_deviceModel != DeviceModel::STORAGE)
- continue;
- auto p = i.m_path;
- auto 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 info_ptr = hid_enumerate(NITROKEY_VID, 0);
- auto first_info_ptr = info_ptr;
- if (!info_ptr)
- return false;
-
- misc::Option<DeviceModel> model;
- while (info_ptr && !model.has_value()) {
- if (path == std::string(info_ptr->path)) {
- model = product_id_to_model(info_ptr->product_id);
- }
- info_ptr = info_ptr->next;
- }
- hid_free_enumeration(first_info_ptr);
-
- if (!model.has_value())
- return false;
-
- auto p = Device::create(model.value());
- if (!p)
- return false;
- 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_internal_hotp_slot_number(uint8_t slot_number) const { return slot_number < 0x20; }
- 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, 53},
- });
- return get_minor_firmware_version() <= m[device->get_device_model()];
- }
-
- bool NitrokeyManager::is_320_OTP_secret_supported(){
- // 320 bit OTP secret is supported by version bigger or equal to:
- auto m = std::unordered_map<DeviceModel , int, EnumClassHash>({
- {DeviceModel::PRO, 8},
- {DeviceModel::STORAGE, 54},
- });
- 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;
- }
-
- uint8_t 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;
- }
- uint8_t 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);
- }
-
- /**
- * Returns ReadSlot structure, describing OTP slot configuration. Always return binary counter -
- * does the necessary conversion, if needed, to unify the behavior across Pro and Storage.
- * @private For internal use only
- * @param slot_number which OTP slot to use (usual format)
- * @return ReadSlot structure
- */
- stick10::ReadSlot::ResponsePayload NitrokeyManager::get_OTP_slot_data(const uint8_t slot_number) {
- auto p = get_payload<stick10::ReadSlot>();
- p.slot_number = slot_number;
- p.data_format = stick10::ReadSlot::CounterFormat::BINARY; // ignored for devices other than Storage v0.54+
- auto data = stick10::ReadSlot::CommandTransaction::run(device, p);
-
- auto &payload = data.data();
-
- // if fw <=v0.53 and asked binary - do the conversion from ASCII
- if (device->get_device_model() == DeviceModel::STORAGE && get_minor_firmware_version() <= 53
- && is_internal_hotp_slot_number(slot_number))
- {
- //convert counter from string to ull
- auto counter_s = std::string(payload.slot_counter_s, payload.slot_counter_s + sizeof(payload.slot_counter_s));
- payload.slot_counter = std::stoull(counter_s);
- }
-
- return payload;
- }
-
- 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) {
- return get_OTP_slot_data(get_internal_slot_number_for_hotp(slot_number));
- }
-
- 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();
- };
-
- void NitrokeyManager::enable_firmware_update_pro(const char *firmware_pin) {
- auto p = get_payload<FirmwareUpdate>();
- strcpyT(p.firmware_password, firmware_pin);
- FirmwareUpdate::CommandTransaction::run(device, p);
- }
-
- void
- NitrokeyManager::change_firmware_update_password_pro(const char *firmware_pin_current, const char *firmware_pin_new) {
- auto p = get_payload<FirmwarePasswordChange>();
- strcpyT(p.firmware_password_current, firmware_pin_current);
- strcpyT(p.firmware_password_new, firmware_pin_new);
- FirmwarePasswordChange::CommandTransaction::run(device, p);
- }
-
-}
diff --git a/nitrokey-sys/libnitrokey-v3.5/README.md b/nitrokey-sys/libnitrokey-v3.5/README.md
deleted file mode 100644
index a3683c0..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/README.md
+++ /dev/null
@@ -1,291 +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](libnitrokey/stick10_commands.h), [Pro v0.8](libnitrokey/stick10_commands_0.8.h), [Storage](libnitrokey/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 and 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
-
-
-### Meson
-It is possible to use Meson and Ninja to build the project as well (currently available only `master` branch).
-Please run:
-```
-meson builddir <OPTIONS>
-meson configure builddir # to show available build flags
-ninja -C builddir
-```
-
-# 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 (can be generated with `make doc` if Doxygen is installed).
-Please check [NK_C_API.h](NK_C_API.h) (C API) for high level commands and [libnitrokey/NitrokeyManager.h](libnitrokey/NitrokeyManager.h) (C++ API). All devices' commands are listed along with packet format in [libnitrokey/stick10_commands.h](libnitrokey/stick10_commands.h) and [libnitrokey/stick20_commands.h](libnitrokey/stick20_commands.h) respectively for Nitrokey Pro and Nitrokey Storage products.
-
-# Tests
-**Warning!** Most of the tests will overwrite user data. The only user-data safe tests are specified in `unittest/test_safe.cpp` (see *C++ tests* chapter).
-
-**Warning!** Before you run unittests please 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 temporarily. If it's too late already, 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](https://github.com/Nitrokey/libnitrokey/tree/master/unittest):
-* `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
-```
-or use Python's environment managing tool like [pipenv](https://pipenv.readthedocs.io/en/latest/) or `virtualenv`.
-
-
-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. The only user-data safe online test set here is [test_safe.cpp](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test_safe.cpp), which tries to connect to the device, and collect its status data. Example run for Storage:
-```text
-# Storage device inserted, firmware version v0.53
-$ ./test_safe
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_DEVICE_STATUS
-..
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_PASSWORD_RETRY_COUNT
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] <= GET_PASSWORD_RETRY_COUNT 0 0
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_DEVICE_STATUS
-..
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_USER_PASSWORD_RETRY_COUNT
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] <= GET_USER_PASSWORD_RETRY_COUNT 0 0
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_DEVICE_STATUS
-...
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
- transmission_data.dissect(): _padding:
-0000 00 00 00 00 00 00 00 00 00 00 00 00 00 05 2e 01 ................
-0010 00 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- ..
- (int) SendCounter_u8: 0
- (int) SendDataType_u8: 3
- (int) FollowBytesFlag_u8: 0
- (int) SendSize_u8: 28
-
- MagicNumber_StickConfig_u16: 13080
- (int) ReadWriteFlagUncryptedVolume_u8: 1
- (int) ReadWriteFlagCryptedVolume_u8: 0
- (int) ReadWriteFlagHiddenVolume_u8: 0
- (int) versionInfo.major: 0
- (int) versionInfo.minor: 53
- (int) versionInfo.build_iteration: 0
- (int) FirmwareLocked_u8: 0
- (int) NewSDCardFound_u8: 1
- (int) NewSDCardFound_st.NewCard: 1
- (int) NewSDCardFound_st.Counter: 0
- (int) SDFillWithRandomChars_u8: 1
- ActiveSD_CardID_u32: 3670817656
- (int) VolumeActiceFlag_u8: 1
- (int) VolumeActiceFlag_st.unencrypted: 1
- (int) VolumeActiceFlag_st.encrypted: 0
- (int) VolumeActiceFlag_st.hidden: 0
- (int) NewSmartCardFound_u8: 0
- (int) UserPwRetryCount: 3
- (int) AdminPwRetryCount: 3
- ActiveSmartCardID_u32: 24122
- (int) StickKeysNotInitiated: 0
-
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_DEVICE_STATUS
-..
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
-00005e3a
-[Wed Jan 2 13:31:17 2019][DEBUG_L1] => GET_DEVICE_STATUS
-....
-[Wed Jan 2 13:31:18 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
-[Wed Jan 2 13:31:18 2019][DEBUG_L1] => GET_DEVICE_STATUS
-...
-[Wed Jan 2 13:31:18 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
-===============================================================================
-All tests passed (18 assertions in 6 test cases)
-```
-Test's execution configuration and verbosity could be manipulated - please see `./test_safe --help` for details.
-
-The other tests sets are not written as extensively as Python tests and are rather more a C++ low level interface check used during the library development, using either low-level components, C API from `NK_C_API.cc`, or C++ API from `NitrokeyManager.cc`. Some of them are: [test_HOTP.cc](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test_HOTP.cc),
-[test1.cc](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test1.cc). See more in [unittest](https://github.com/Nitrokey/libnitrokey/tree/master/unittest) directory.
-
-**Note: these are not device model agnostic, and will most probably destroy your data on the device.**
-
-
-Unit tests were checked 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 to `cmake` - e.g.: `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 byte 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.5/command_id.cc b/nitrokey-sys/libnitrokey-v3.5/command_id.cc
deleted file mode 100644
index 9a329bc..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/command_id.cc
+++ /dev/null
@@ -1,188 +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::FIRMWARE_UPDATE:
- return "FIRMWARE_UPDATE";
- case CommandID::FIRMWARE_PASSWORD_CHANGE:
- return "FIRMWARE_PASSWORD_CHANGE";
-
- 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.5/device.cc b/nitrokey-sys/libnitrokey-v3.5/device.cc
deleted file mode 100644
index bc42965..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/device.cc
+++ /dev/null
@@ -1,345 +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 <codecvt>
-#include <iostream>
-#include <locale>
-#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 nitrokey::misc;
-using namespace std::chrono;
-
-const uint16_t nitrokey::device::NITROKEY_VID = 0x20a0;
-const uint16_t nitrokey::device::NITROKEY_PRO_PID = 0x4108;
-const uint16_t nitrokey::device::NITROKEY_STORAGE_PID = 0x4109;
-
-Option<DeviceModel> nitrokey::device::product_id_to_model(uint16_t product_id) {
- switch (product_id) {
- case NITROKEY_PRO_PID:
- return DeviceModel::PRO;
- case NITROKEY_STORAGE_PID:
- return DeviceModel::STORAGE;
- default:
- return {};
- }
-}
-
-std::atomic_int Device::instances_count{0};
-std::chrono::milliseconds Device::default_delay {0} ;
-
-std::ostream& nitrokey::device::operator<<(std::ostream& stream, DeviceModel model) {
- switch (model) {
- case DeviceModel::PRO:
- stream << "Pro";
- break;
- case DeviceModel::STORAGE:
- stream << "Storage";
- break;
- default:
- stream << "Unknown";
- break;
- }
- return stream;
-}
-
-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<DeviceInfo> Device::enumerate(){
- auto pInfo = hid_enumerate(NITROKEY_VID, 0);
- auto pInfo_ = pInfo;
- std::vector<DeviceInfo> res;
- while (pInfo != nullptr){
- auto deviceModel = product_id_to_model(pInfo->product_id);
- if (deviceModel.has_value()) {
- std::string path(pInfo->path);
- std::wstring serialNumberW(pInfo->serial_number);
- std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
- std::string serialNumber = converter.to_bytes(serialNumberW);
- DeviceInfo info = { deviceModel.value(), path, serialNumber };
- res.push_back(info);
- }
- pInfo = pInfo->next;
- }
-
- if (pInfo_ != nullptr){
- hid_free_enumeration(pInfo_);
- }
-
- return res;
-}
-
-std::shared_ptr<Device> Device::create(DeviceModel model) {
- switch (model) {
- case DeviceModel::PRO:
- return std::make_shared<Stick10>();
- case DeviceModel::STORAGE:
- return std::make_shared<Stick20>();
- default:
- return {};
- }
-}
-
-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(NITROKEY_VID, NITROKEY_PRO_PID, DeviceModel::PRO, 100ms, 5, 100ms)
- {
- setDefaultDelay();
- }
-
-
-Stick20::Stick20():
- Device(NITROKEY_VID, NITROKEY_STORAGE_PID, 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.5/libnitrokey/CommandFailedException.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/CommandFailedException.h
deleted file mode 100644
index 32bd6b7..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/DeviceCommunicationExceptions.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/DeviceCommunicationExceptions.h
deleted file mode 100644
index f710d0b..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/LibraryException.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/LibraryException.h
deleted file mode 100644
index 3b9d177..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/LongOperationInProgressException.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/LongOperationInProgressException.h
deleted file mode 100644
index 865d6b5..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/NitrokeyManager.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/NitrokeyManager.h
deleted file mode 100644
index 33ede1b..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/NitrokeyManager.h
+++ /dev/null
@@ -1,308 +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<DeviceInfo> 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);
- uint8_t 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);
-
- uint8_t 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();
-
- void enable_firmware_update_pro(const char *firmware_pin);
-
- void change_firmware_update_password_pro(const char *firmware_pin_current, const char *firmware_pin_new);
- bool is_internal_hotp_slot_number(uint8_t slot_number) const;
- };
-}
-
-
-
-#endif //LIBNITROKEY_NITROKEYMANAGER_H
diff --git a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/command.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/command.h
deleted file mode 100644
index 6852bf0..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/command_id.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/command_id.h
deleted file mode 100644
index ee6726c..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/command_id.h
+++ /dev/null
@@ -1,156 +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,
- FIRMWARE_UPDATE = 0x19,
- FIRMWARE_PASSWORD_CHANGE = 0x1A,
-
- 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.5/libnitrokey/cxx_semantics.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/cxx_semantics.h
deleted file mode 100644
index 36ed142..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/deprecated.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/deprecated.h
deleted file mode 100644
index 5a83288..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/device.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/device.h
deleted file mode 100644
index d50080d..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/device.h
+++ /dev/null
@@ -1,224 +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 <memory>
-#include <string>
-#include <ostream>
-#include <vector>
-#include "misc.h"
-
-#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
-};
-
-std::ostream& operator<<(std::ostream& stream, DeviceModel model);
-
-/**
- * The USB vendor ID for Nitrokey devices.
- */
-extern const uint16_t NITROKEY_VID;
-/**
- * The USB product ID for the Nitrokey Pro.
- */
-extern const uint16_t NITROKEY_PRO_PID;
-/**
- * The USB product ID for the Nitrokey Storage.
- */
-extern const uint16_t NITROKEY_STORAGE_PID;
-
-/**
- * Convert the given USB product ID to a Nitrokey model. If there is no model
- * with that ID, return an absent value.
- */
-misc::Option<DeviceModel> product_id_to_model(uint16_t product_id);
-
-/**
- * Information about a connected device.
- *
- * This struct contains the information about a connected device returned by
- * hidapi when enumerating the connected devices.
- */
-struct DeviceInfo {
- /**
- * The model of the connected device.
- */
- DeviceModel m_deviceModel;
- /**
- * The USB connection path for the device.
- */
- std::string m_path;
- /**
- * The serial number of the device.
- */
- std::string m_serialNumber;
-};
-
-#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();
- /**
- * Returns a vector with all connected Nitrokey devices.
- *
- * @return information about all connected devices
- */
- static std::vector<DeviceInfo> enumerate();
-
- /**
- * Create a Device of the given model.
- */
- static std::shared_ptr<Device> create(DeviceModel model);
-
-
- 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.5/libnitrokey/device_proto.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/device_proto.h
deleted file mode 100644
index 45a6c16..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/dissect.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/dissect.h
deleted file mode 100644
index 690b5b7..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/hidapi/hidapi.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/hidapi/hidapi.h
deleted file mode 100644
index e5bc2dc..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/log.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/log.h
deleted file mode 100644
index 278b49c..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/log.h
+++ /dev/null
@@ -1,109 +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;
- virtual ~LogHandler() = default;
- 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.5/libnitrokey/misc.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/misc.h
deleted file mode 100644
index a9c4672..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/misc.h
+++ /dev/null
@@ -1,121 +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 <stdexcept>
-#include <iomanip>
-
-
-namespace nitrokey {
-namespace misc {
-
-/**
- * Simple replacement for std::optional (C++17).
- */
-template<typename T>
-class Option {
-public:
- Option() : m_hasValue(false), m_value() {}
- Option(T value) : m_hasValue(true), m_value(value) {}
-
- bool has_value() const {
- return m_hasValue;
- }
- T value() const {
- if (!m_hasValue) {
- throw std::logic_error("Called Option::value without value");
- }
- return m_value;
- }
-
-private:
- bool m_hasValue;
- T m_value;
-};
-
- 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();
- }
-
-#define FIELD_WIDTH_MAX (100)
- /**
- * 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;
- const size_t src_strlen = strnlen(src, FIELD_WIDTH_MAX);
- LOG(std::string("strcpyT sizes dest src ")
- + std::to_string(s_dest) + " "
- + std::to_string(src_strlen) + " "
- , nitrokey::log::Loglevel::DEBUG_L2);
- if (src_strlen > s_dest){
- throw TooLongStringException(src_strlen, 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.5/libnitrokey/stick10_commands.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick10_commands.h
deleted file mode 100644
index 5e8a5aa..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick10_commands.h
+++ /dev/null
@@ -1,929 +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:
- enum class CounterFormat {
- ASCII = 0,
- BINARY = 1,
- };
- struct CommandPayload {
- uint8_t slot_number;
- CounterFormat data_format; //Storage v0.54+ only: slot_counter value format: 0 - in ascii, 1 - binary
-
- 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;
-
-};
-
-class FirmwareUpdate : Command<CommandID::FIRMWARE_UPDATE> {
-public:
- struct CommandPayload {
- uint8_t firmware_password[20];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(firmware_password);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-
-};
-
-class FirmwarePasswordChange : Command<CommandID::FIRMWARE_PASSWORD_CHANGE> {
-public:
- struct CommandPayload {
- uint8_t firmware_password_current[20];
- uint8_t firmware_password_new[20];
- std::string dissect() const {
- std::stringstream ss;
- print_to_ss_volatile(firmware_password_current);
- print_to_ss_volatile(firmware_password_new);
- return ss.str();
- }
- } __packed;
-
- typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
- CommandTransaction;
-
-};
-
-
-}
-}
-}
-#pragma pack (pop)
-#endif
diff --git a/nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick10_commands_0.8.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick10_commands_0.8.h
deleted file mode 100644
index 9477890..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/stick20_commands.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/stick20_commands.h
deleted file mode 100644
index 7efa1b6..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/libnitrokey/version.h b/nitrokey-sys/libnitrokey-v3.5/libnitrokey/version.h
deleted file mode 100644
index 6547af0..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/log.cc b/nitrokey-sys/libnitrokey-v3.5/log.cc
deleted file mode 100644
index 06acee7..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/misc.cc b/nitrokey-sys/libnitrokey-v3.5/misc.cc
deleted file mode 100644
index 59185f3..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/version.cc b/nitrokey-sys/libnitrokey-v3.5/version.cc
deleted file mode 100644
index dfdc802..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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.5/version.cc.in b/nitrokey-sys/libnitrokey-v3.5/version.cc.in
deleted file mode 100644
index 0eae647..0000000
--- a/nitrokey-sys/libnitrokey-v3.5/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 a01eae8..0000000
--- a/nitrokey-sys/src/ffi.rs
+++ /dev/null
@@ -1,1481 +0,0 @@
-/* automatically generated by rust-bindgen, manually modified */
-
-extern "C" {
- #[link_name = "\u{1}NK_PWS_SLOT_COUNT"]
- pub static mut NK_PWS_SLOT_COUNT: u8;
-}
-pub const MAXIMUM_STR_REPLY_LENGTH: ::std::os::raw::c_int = 8192;
-/// 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;
-/// The connection info for a Nitrokey device as a linked list.
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct NK_device_info {
- /// The model of the Nitrokey device.
- pub model: NK_device_model,
- /// The USB device path for NK_connect_with_path.
- pub path: *mut ::std::os::raw::c_char,
- /// The serial number.
- pub serial_number: *mut ::std::os::raw::c_char,
- /// The pointer to the next element of the linked list or null
- /// if this is the last element in the list.
- pub next: *mut NK_device_info,
-}
-#[test]
-fn bindgen_test_layout_NK_device_info() {
- assert_eq!(
- ::std::mem::size_of::<NK_device_info>(),
- 32usize,
- concat!("Size of: ", stringify!(NK_device_info))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_device_info>(),
- 8usize,
- concat!("Alignment of ", stringify!(NK_device_info))
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).model as *const _ as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(model)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).path as *const _ as usize },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(path)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).serial_number as *const _ as usize },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(serial_number)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).next as *const _ as usize },
- 24usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(next)
- )
- );
-}
-/// Stores the common device status for all Nitrokey devices.
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct NK_status {
- /// 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 serial number of the smart card.
- pub serial_number_smart_card: u32,
- /// The HOTP slot to generate a password from if the numlock
- /// key is pressed twice (slot 0-1, or any other value to
- /// disable the function).
- pub config_numlock: u8,
- /// The HOTP slot to generate a password from if the capslock
- /// key is pressed twice (slot 0-1, or any other value to
- /// disable the function).
- pub config_capslock: u8,
- /// The HOTP slot to generate a password from if the scrolllock
- /// key is pressed twice (slot 0-1, or any other value to
- /// disable the function).
- pub config_scrolllock: u8,
- /// Indicates whether the user password is required to generate
- /// an OTP value.
- pub otp_user_password: bool,
-}
-#[test]
-fn bindgen_test_layout_NK_status() {
- assert_eq!(
- ::std::mem::size_of::<NK_status>(),
- 12usize,
- concat!("Size of: ", stringify!(NK_status))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_status>(),
- 4usize,
- concat!("Alignment of ", stringify!(NK_status))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_status>())).firmware_version_major as *const _ as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(firmware_version_major)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_status>())).firmware_version_minor as *const _ as usize
- },
- 1usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(firmware_version_minor)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_status>())).serial_number_smart_card as *const _ as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(serial_number_smart_card)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).config_numlock as *const _ as usize },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(config_numlock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).config_capslock as *const _ as usize },
- 9usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(config_capslock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).config_scrolllock as *const _ as usize },
- 10usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(config_scrolllock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).otp_user_password as *const _ as usize },
- 11usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(otp_user_password)
- )
- );
-}
-/// 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)
- )
- );
-}
-/// Data about the usage of the SD card.
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct NK_SD_usage_data {
- /// The minimum write level, as a percentage of the total card
- /// size.
- pub write_level_min: u8,
- /// The maximum write level, as a percentage of the total card
- /// size.
- pub write_level_max: u8,
-}
-#[test]
-fn bindgen_test_layout_NK_SD_usage_data() {
- assert_eq!(
- ::std::mem::size_of::<NK_SD_usage_data>(),
- 2usize,
- concat!("Size of: ", stringify!(NK_SD_usage_data))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_SD_usage_data>(),
- 1usize,
- concat!("Alignment of ", stringify!(NK_SD_usage_data))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_SD_usage_data>())).write_level_min as *const _ as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_SD_usage_data),
- "::",
- stringify!(write_level_min)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_SD_usage_data>())).write_level_max as *const _ as usize
- },
- 1usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_SD_usage_data),
- "::",
- stringify!(write_level_max)
- )
- );
-}
-#[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. This function is
- /// deprecated in favor of NK_get_status_as_string.
- /// @return string representation of the status or an empty string
- /// if the command failed
- #[deprecated(since = "3.5.0", note="use `NK_get_status_as_string` instead")]
- pub fn NK_status() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Return the debug status string. Debug purposes.
- /// @return string representation of the status or an empty string
- /// if the command failed
- pub fn NK_get_status_as_string() -> *mut ::std::os::raw::c_char;
-}
-extern "C" {
- /// Get the stick status common to all Nitrokey devices 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 status
- /// @return command processing error code
- pub fn NK_get_status(out: *mut NK_status) -> ::std::os::raw::c_int;
-}
-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" {
- #[deprecated(since = "3.4.0", note="use `NK_totp_set_time_soft` instead")]
- 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() -> u8;
-}
-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() -> u8;
-}
-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. Usable during hidden volumes creation.
- /// If the command was successful (return value 0), the usage data is
- /// written to the output pointer’s target. The output pointer must
- /// not be null.
- /// Storage only
- /// @param out the output pointer for the usage data
- /// @return command processing error code
- pub fn NK_get_SD_usage_data(out: *mut NK_SD_usage_data) -> ::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 or -2 if an
- /// error occured
- 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" {
- /// Returns a linked list of all connected devices, or null if no devices
- /// are connected or an error occured. The linked list must be freed by
- /// calling NK_free_device_info.
- /// @return a linked list of all connected devices
- pub fn NK_list_devices() -> *mut NK_device_info;
-}
-extern "C" {
- /// Free a linked list returned by NK_list_devices.
- /// @param the linked list to free or null
- pub fn NK_free_device_info(device_info: *mut NK_device_info);
-}
-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" {
- /// Connects to a device with the given path. The path is a USB device
- /// path as returned by hidapi.
- /// @param path the device path
- /// @return 1 on successful connection, 0 otherwise
- pub fn NK_connect_with_path(path: *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;
-}
-extern "C" {
- /// Enable update mode on Nitrokey Pro.
- /// Supported from v0.11.
- /// @param update_password 20 bytes update password
- /// @return command processing error code
- pub fn NK_enable_firmware_update_pro(
- update_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-extern "C" {
- /// Change update-mode password on Nitrokey Pro.
- /// Supported from v0.11.
- /// @param current_firmware_password 20 bytes update password
- /// @param new_firmware_password 20 bytes update password
- /// @return command processing error code
- pub fn NK_change_firmware_password_pro(
- current_firmware_password: *const ::std::os::raw::c_char,
- new_firmware_password: *const ::std::os::raw::c_char,
- ) -> ::std::os::raw::c_int;
-}
-#[repr(C)]
-#[derive(Debug, Copy, Clone)]
-pub struct ReadSlot_t {
- pub slot_name: [u8; 15usize],
- pub _slot_config: u8,
- pub slot_token_id: [u8; 13usize],
- pub slot_counter: u64,
-}
-#[test]
-fn bindgen_test_layout_ReadSlot_t() {
- assert_eq!(
- ::std::mem::size_of::<ReadSlot_t>(),
- 40usize,
- concat!("Size of: ", stringify!(ReadSlot_t))
- );
- assert_eq!(
- ::std::mem::align_of::<ReadSlot_t>(),
- 8usize,
- concat!("Alignment of ", stringify!(ReadSlot_t))
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>())).slot_name as *const _ as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(ReadSlot_t),
- "::",
- stringify!(slot_name)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>()))._slot_config as *const _ as usize },
- 15usize,
- concat!(
- "Offset of field: ",
- stringify!(ReadSlot_t),
- "::",
- stringify!(_slot_config)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>())).slot_token_id as *const _ as usize },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(ReadSlot_t),
- "::",
- stringify!(slot_token_id)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>())).slot_counter as *const _ as usize },
- 32usize,
- concat!(
- "Offset of field: ",
- stringify!(ReadSlot_t),
- "::",
- stringify!(slot_counter)
- )
- );
-}
-extern "C" {
- pub fn NK_read_HOTP_slot(slot_num: u8, out: *mut ReadSlot_t) -> ::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-msrv.yml b/nitrokey/.builds/archlinux-msrv.yml
deleted file mode 100644
index 66c0390..0000000
--- a/nitrokey/.builds/archlinux-msrv.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-# SPDX-License-Identifier: CC0-1.0
-image: archlinux
-packages:
- - rustup
- - libnitrokey
-environment:
- USE_SYSTEM_LIBNITROKEY: "1"
-sources:
- - https://git.ireas.org/nitrokey-rs
-tasks:
- - setup: |
- rustup set profile minimal
- rustup default 1.34.2
- - version: |
- rustc -V
- - build: |
- cd nitrokey-rs
- cargo build --release
- - test: |
- cd nitrokey-rs
- cargo test
diff --git a/nitrokey/.builds/archlinux-use-system-lib.yml b/nitrokey/.builds/archlinux-use-system-lib.yml
deleted file mode 100644
index 29bda19..0000000
--- a/nitrokey/.builds/archlinux-use-system-lib.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-# SPDX-License-Identifier: CC0-1.0
-image: archlinux
-packages:
- - rust
- - libnitrokey
-environment:
- USE_SYSTEM_LIBNITROKEY: "1"
-sources:
- - https://git.ireas.org/nitrokey-rs
-tasks:
- - version: |
- rustc -V
- - build: |
- cd nitrokey-rs
- cargo build --release
- - test: |
- cd nitrokey-rs
- cargo test
- - format: |
- cd nitrokey-rs
- cargo fmt -- --check
- - clippy: |
- cd nitrokey-rs
- cargo clippy -- -D warnings
diff --git a/nitrokey/.builds/archlinux.yml b/nitrokey/.builds/archlinux.yml
deleted file mode 100644
index 151eb66..0000000
--- a/nitrokey/.builds/archlinux.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-# SPDX-License-Identifier: CC0-1.0
-image: archlinux
-packages:
- - rust
- - hidapi
- - gcc
-sources:
- - https://git.ireas.org/nitrokey-rs
-tasks:
- - build: |
- cd nitrokey-rs
- cargo build --release
- - test: |
- cd nitrokey-rs
- cargo test
diff --git a/nitrokey/.builds/lint.yml b/nitrokey/.builds/lint.yml
deleted file mode 100644
index 678cde8..0000000
--- a/nitrokey/.builds/lint.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-# SPDX-License-Identifier: CC0-1.0
-image: archlinux
-packages:
- - gnupg
- - reuse
-sources:
- - https://git.ireas.org/nitrokey-rs
-tasks:
- - verify: |
- cd nitrokey-rs
- curl -s "https://pgp.ireas.org/0x6D533958F070C57C.txt" | gpg --import
- git verify-commit HEAD
- - reuse: |
- cd nitrokey-rs
- reuse lint
diff --git a/nitrokey/.gitignore b/nitrokey/.gitignore
deleted file mode 100644
index 7ea18df..0000000
--- a/nitrokey/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-# SPDX-License-Identifier: CC0-1.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 cba0e83..0000000
--- a/nitrokey/CHANGELOG.md
+++ /dev/null
@@ -1,158 +0,0 @@
-<!---
-Copyright (C) 2019-2020 Robin Krahl <robin.krahl@ireas.org>
-SPDX-License-Identifier: CC0-1.0
--->
-
-# v0.5.1 (2020-01-15)
-- Fix serial number formatting for Nitrokey Pro devices with firmware 0.8 or
- older in the `list_devices` function.
-
-# v0.5.0 (2020-01-14)
-- List these libnitrokey functions as unsupported:
- - `NK_change_firmware_password_pro`
- - `NK_connect_with_ID`
- - `NK_enable_firmware_update_pro`
- - `NK_list_devices_by_cpuID`
- - `NK_send_startup`
-- Implement connection by path:
- - Add the `Error::UnsupportedDeviceError` variant.
- - Add the `DeviceInfo` struct.
- - Add the `list_devices` function.
- - Add the `connect_path` function to the `Manager` struct.
-- Add the `get_status` function to the `Device` trait.
-- Rename `Status::get_status` to `get_storage_status`.
-- Add the `get_sd_card_usage` function to the `Storage` struct.
-- Add the `OperationStatus` enum and the `get_operation_status` function for
- the `Storage` struct.
-- Add the `fill_sd_card` function to the `Storage` struct.
-
-# v0.4.0 (2020-01-02)
-- Remove the `test-pro` and `test-storage` features.
-- Implement `Display` for `Version`.
-- Introduce `DEFAULT_ADMIN_PIN` and `DEFAULT_USER_PIN` constants.
-- Refactor the error handling code:
- - Implement `std::error::Error` for `CommandError`.
- - Add the `Error` enum.
- - Add the `LibraryError` enum and move the library error variants from
- `CommandError` to `LibraryError`.
- - Add the `CommunicationError` enum and move the communication error variants
- from `CommandError` to `CommunicationError`.
- - Return `Error` instead of `CommandError` in all public functions.
- - Move the `CommandError::RngError` variant to `Error::RandError` and the
- `CommandError::Unknown` variant to `Error::UnknownError`.
- - Return `CommunicationError::NotConnected` instead of
- `CommandError::Undefined` from the connect functions.
- - Remove the `CommandError::Undefined` variant.
-- Add a private `PhantomData` field to `Pro` and `Storage` to make direct
- instantiation impossible.
-- Refactor and clean up internal code:
- - Prefer using the `Into` trait over numeric casting.
- - Add `Pro::new` and `Storage::new` functions.
-- Implement `From<Pro>` and `From<Storage>` for `DeviceWrapper`.
-- Add `Error::Utf8Error` variant.
- - Return `Result<Version>` instead of `Version` from `get_library_version`.
- - Return `Error::Utf8Error` if libnitrokey returns an invalid UTF-8 string.
-- Implement `From<(T: Device, Error)>` for `Error`.
-- Fix timing issues with the `totp_no_pin` and `totp_pin` test cases.
-- Always return a `Result` in functions that communicate with a device.
-- Combine `get_{major,minor}_firmware_version` into `get_firmware_version`.
-- Add `set_encrypted_volume_mode` to `Storage`.
-- Use mutability to represent changes to the device status:
- - Implement `DerefMut` for `User<T>` and `Admin<T>`.
- - Add `device_mut` method to `DeviceWrapper`.
- - Require a mutable `Device` reference if a method changes the device state.
-- Update dependencies:
- - `nitrokey-sys` to 3.5
- - `nitrokey-test` to 0.3
- - `rand_core` to 0.5
- - `rand_os` to 0.2
-- Add `nitrokey-test-state` dependency in version 0.1.
-- Refactor connection management:
- - Add `ConcurrentAccessError` and `PoisonError` `Error` variants.
- - Add the `Manager` struct that manages connections to Nitrokey devices.
- - Remove `connect`, `connect_model`, `Pro::connect` and `Storage::connect`.
- - Add the `into_manager` function to the `Device` trait.
- - Add the `force_take` function that ignores a `PoisonError` when accessing
- the manager instance.
-- Internally refactor the `device` module into submodules.
-
-# v0.3.5 (2019-12-16)
-- Update the nitrokey-sys dependency version specification to ~3.4.
-
-# 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 59af067..0000000
--- a/nitrokey/Cargo.toml
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2019-2020 Robin Krahl <robin.krahl@ireas.org>
-# SPDX-License-Identifier: CC0-1.0
-
-[package]
-name = "nitrokey"
-version = "0.5.1"
-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"
-exclude = [".builds/*"]
-
-[dependencies]
-lazy_static = "1.2"
-libc = "0.2"
-nitrokey-sys = "3.5"
-rand_core = {version = "0.5.1", features = ["getrandom"] }
-
-[dev-dependencies]
-nitrokey-test = "0.3"
-nitrokey-test-state = "0.1"
diff --git a/nitrokey/LICENSES/CC0-1.0.txt b/nitrokey/LICENSES/CC0-1.0.txt
deleted file mode 100644
index 0e259d4..0000000
--- a/nitrokey/LICENSES/CC0-1.0.txt
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/nitrokey/LICENSES/MIT.txt b/nitrokey/LICENSES/MIT.txt
deleted file mode 100644
index 6c67cd5..0000000
--- a/nitrokey/LICENSES/MIT.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-Valid-License-Identifier: MIT
-License-Text:
-
-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 9001193..0000000
--- a/nitrokey/README.md
+++ /dev/null
@@ -1,114 +0,0 @@
-<!---
-Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-SPDX-License-Identifier: CC0-1.0
--->
-
-# nitrokey-rs
-
-A libnitrokey wrapper for Rust providing access to Nitrokey devices.
-
-## Usage
-
-For usage information, have a look at the [API reference][API reference] and at
-the [examples][] in the `examples` directory. You can also have a look at the
-[`nitrocli`][] crate, a command-line interface for Nitrokey devices that uses
-this crate.
-
-## Compatibility
-
-This crate provides access to all features of the [`libnitrokey`][] C API for
-both the Nitrokey Pro and the Nitrokey Storage: general configuration, one-time
-password generation, the password safe and the secure storage on the Nitrokey
-Storage.
-
-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][].
-
-If you want to use a precompiled version of `libnitrokey`, you can set the
-`USE_SYSTEM_LIBNITROKEY` environment variable during build. In this case,
-`libnitrokey` must be available in the library search path.
-
-### Unsupported Functions
-
-The following functions provided by `libnitrokey` are deliberately not
-supported by `nitrokey-rs`:
-
-- `NK_connect_with_ID`, `NK_list_devices_by_cpuID`. These functions can be
- replaced by calls to `NK_connect_with_path` and `NK_list_devices`, which
- also have a cleaner API.
-- `NK_enable_firmware_update_pro`, `NK_change_firmware_password_pro`. These
- functions execute commands that are not yet supported by the Nitrokey Pro
- firmware.
-- `NK_get_device_model`. We know which model we connected to, so we can
- provide this information without calling `libnitrokey`.
-- `NK_is_AES_supported`. This function is no longer needed for Nitrokey
- devices with a recent firmware version.
-- `NK_send_startup`. Currently, this function is redundant to `NK_get_time`.
-- `NK_set_unencrypted_volume_rorw_pin_type_user`,
- `NK_set_unencrypted_read_only`, `NK_set_unencrypted_read_write`. These
- functions 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.
-- `NK_totp_get_time`, `NK_status`. These functions are deprecated.
-- `NK_read_HOTP_slot`. This function is only available for HOTP slots, not for
- TOTP. We will support it once both types are supported by `libnitrokey`.
-- All `*_as_string` functions that return string representations of data
- returned by other functions.
-
-## 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
-don’t want to destroy all data on any connected Nitrokey device!
-
-The test suite contains some test that take very long to execute, for example
-filling the SD card of a Nitrokey Storage with random data. These tests are
-ignored per default. Use `cargo test -- --ignored` to execute the tests.
-
-## Acknowledgments
-
-Thanks to Nitrokey UG for providing two Nitrokey devices to support the
-development of this crate. Thanks to Daniel Mueller for contributions to
-`nitrokey-rs` and for the `nitrokey-test` crate.
-
-## Minimum Supported Rust Version
-
-This crate supports Rust 1.34.2 or later.
-
-## 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. The documentation and
-configuration files contained in this repository are licensed under the
-[Creative Commons Zero][CC0] license. You can find a copy of the license texts
-in the `LICENSES` directory. `libnitrokey` is licensed under the [LGPL-3.0][].
-
-`nitrokey-rs` complies with [version 3.0 of the REUSE specification][reuse].
-
-[API reference]: https://docs.rs/nitrokey
-[examples]: https://git.ireas.org/nitrokey-rs/tree/examples
-[`nitrocli`]: https://github.com/d-e-s-o/nitrocli/tree/master/nitrocli
-[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
-[MIT]: https://opensource.org/licenses/MIT
-[CC0]: https://creativecommons.org/publicdomain/zero/1.0/
-[LGPL-3.0]: https://opensource.org/licenses/lgpl-3.0.html
-[reuse]: https://reuse.software/practices/3.0/
diff --git a/nitrokey/TODO.md b/nitrokey/TODO.md
deleted file mode 100644
index 92d4b04..0000000
--- a/nitrokey/TODO.md
+++ /dev/null
@@ -1,10 +0,0 @@
-<!---
-Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-SPDX-License-Identifier: CC0-1.0
--->
-
-- Clear passwords from memory.
-- Lock password safe in `PasswordSafe::drop()` (see [nitrokey-storage-firmware
- issue 65][]).
-
-[nitrokey-storage-firmware issue 65]: https://github.com/Nitrokey/nitrokey-storage-firmware/issues/65
diff --git a/nitrokey/examples/list-devices.rs b/nitrokey/examples/list-devices.rs
deleted file mode 100644
index 47fa054..0000000
--- a/nitrokey/examples/list-devices.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (C) 2020 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: CC0-1.0
-
-//! Enumerates all connected Nitrokey devices and prints some information about them.
-
-use nitrokey::Device as _;
-
-fn main() -> Result<(), nitrokey::Error> {
- let mut manager = nitrokey::take()?;
- let device_infos = nitrokey::list_devices()?;
- if device_infos.is_empty() {
- println!("No Nitrokey device found");
- } else {
- println!("path\t\tmodel\tfirmware version\tserial number");
- for device_info in device_infos {
- let device = manager.connect_path(device_info.path.clone())?;
- let model = device.get_model();
- let status = device.get_status()?;
- println!(
- "{}\t{}\t{}\t\t\t{:08x}",
- device_info.path, model, status.firmware_version, status.serial_number
- );
- }
- }
- Ok(())
-}
diff --git a/nitrokey/examples/otp.rs b/nitrokey/examples/otp.rs
deleted file mode 100644
index f2c6f3c..0000000
--- a/nitrokey/examples/otp.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2020 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: CC0-1.0
-
-//! Connects to a Nitrokey device, configures an TOTP slot and generates a one-time password from
-//! it.
-
-use std::time;
-
-use nitrokey::{Authenticate, ConfigureOtp, Device, GenerateOtp};
-
-fn main() -> Result<(), nitrokey::Error> {
- let mut manager = nitrokey::take()?;
- let device = manager.connect()?;
-
- // Configure the OTP slot (requires admin PIN)
- let data = nitrokey::OtpSlotData::new(
- 1,
- "test",
- "3132333435363738393031323334353637383930",
- nitrokey::OtpMode::SixDigits,
- );
- let mut admin = device.authenticate_admin("12345678")?;
- admin.write_totp_slot(data, 30)?;
- let mut device = admin.device();
-
- // Set the time for the OTP generation
- let time = time::SystemTime::now()
- .duration_since(time::UNIX_EPOCH)
- .expect("Invalid system time");
- device.set_time(time.as_secs(), true)?;
-
- // Generate a one-time password -- depending on the configuration, we have to set the user PIN
- let config = device.get_config()?;
- let otp = if config.user_password {
- let user = device.authenticate_user("123456")?;
- user.get_totp_code(1)
- } else {
- device.get_totp_code(1)
- }?;
- println!("Generated OTP code: {}", otp);
-
- Ok(())
-}
diff --git a/nitrokey/src/auth.rs b/nitrokey/src/auth.rs
deleted file mode 100644
index cab1021..0000000
--- a/nitrokey/src/auth.rs
+++ /dev/null
@@ -1,437 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use std::convert::TryFrom as _;
-use std::marker;
-use std::ops;
-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::error::Error;
-use crate::otp::{ConfigureOtp, GenerateOtp, OtpMode, OtpSlotData, RawOtpSlotData};
-use crate::util::{generate_password, get_command_result, get_cstring, result_from_string};
-
-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<'a> {
- /// 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::Error;
- ///
- /// fn perform_user_task<'a>(device: &User<'a, DeviceWrapper<'a>>) {}
- /// fn perform_other_task(device: &DeviceWrapper) {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let device = match device.authenticate_user("123456") {
- /// Ok(user) => {
- /// perform_user_task(&user);
- /// user.device()
- /// },
- /// Err((device, err)) => {
- /// eprintln!("Could not authenticate as user: {}", err);
- /// device
- /// },
- /// };
- /// perform_other_task(&device);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`RngError`]: enum.CommandError.html#variant.RngError
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn authenticate_user(self, password: &str) -> Result<User<'a, Self>, (Self, Error)>
- where
- Self: Device<'a> + 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::Error;
- ///
- /// fn perform_admin_task<'a>(device: &Admin<'a, DeviceWrapper<'a>>) {}
- /// fn perform_other_task(device: &DeviceWrapper) {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let device = match device.authenticate_admin("123456") {
- /// Ok(admin) => {
- /// perform_admin_task(&admin);
- /// admin.device()
- /// },
- /// Err((device, err)) => {
- /// eprintln!("Could not authenticate as admin: {}", err);
- /// device
- /// },
- /// };
- /// perform_other_task(&device);
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`RngError`]: enum.CommandError.html#variant.RngError
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn authenticate_admin(self, password: &str) -> Result<Admin<'a, Self>, (Self, Error)>
- where
- Self: Device<'a> + Sized;
-}
-
-trait AuthenticatedDevice<T> {
- fn new(device: T, temp_password: Vec<u8>) -> Self;
-
- fn temp_password_ptr(&self) -> *const c_char;
-}
-
-/// 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<'a, T: Device<'a>> {
- device: T,
- temp_password: Vec<u8>,
- marker: marker::PhantomData<&'a T>,
-}
-
-/// 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<'a, T: Device<'a>> {
- device: T,
- temp_password: Vec<u8>,
- marker: marker::PhantomData<&'a T>,
-}
-
-fn authenticate<'a, D, A, T>(device: D, password: &str, callback: T) -> Result<A, (D, Error)>
-where
- D: Device<'a>,
- 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;
- match callback(password_ptr, temp_password_ptr) {
- 0 => Ok(A::new(device, temp_password)),
- rv => Err((device, Error::from(rv))),
- }
-}
-
-fn authenticate_user_wrapper<'a, T, C>(
- device: T,
- constructor: C,
- password: &str,
-) -> Result<User<'a, DeviceWrapper<'a>>, (DeviceWrapper<'a>, Error)>
-where
- T: Device<'a> + 'a,
- C: Fn(T) -> DeviceWrapper<'a>,
-{
- 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<'a, T, C>(
- device: T,
- constructor: C,
- password: &str,
-) -> Result<Admin<'a, DeviceWrapper<'a>>, (DeviceWrapper<'a>, Error)>
-where
- T: Device<'a> + 'a,
- C: Fn(T) -> DeviceWrapper<'a>,
-{
- 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<'a, T: Device<'a>> User<'a, 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<'a, T: Device<'a>> ops::Deref for User<'a, T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- &self.device
- }
-}
-
-impl<'a, T: Device<'a>> ops::DerefMut for User<'a, T> {
- fn deref_mut(&mut self) -> &mut T {
- &mut self.device
- }
-}
-
-impl<'a, T: Device<'a>> GenerateOtp for User<'a, T> {
- fn get_hotp_code(&mut self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe {
- nitrokey_sys::NK_get_hotp_code_PIN(slot, self.temp_password_ptr())
- })
- }
-
- fn get_totp_code(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe {
- nitrokey_sys::NK_get_totp_code_PIN(slot, 0, 0, 0, self.temp_password_ptr())
- })
- }
-}
-
-impl<'a, T: Device<'a>> AuthenticatedDevice<T> for User<'a, T> {
- fn new(device: T, temp_password: Vec<u8>) -> Self {
- User {
- device,
- temp_password,
- marker: marker::PhantomData,
- }
- }
-
- fn temp_password_ptr(&self) -> *const c_char {
- self.temp_password.as_ptr() as *const c_char
- }
-}
-
-impl<'a, T: Device<'a>> ops::Deref for Admin<'a, T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- &self.device
- }
-}
-
-impl<'a, T: Device<'a>> ops::DerefMut for Admin<'a, T> {
- fn deref_mut(&mut self) -> &mut T {
- &mut self.device
- }
-}
-
-impl<'a, T: Device<'a>> Admin<'a, 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let config = Config::new(None, None, None, false);
- /// match device.authenticate_admin("12345678") {
- /// Ok(mut admin) => {
- /// admin.write_config(config);
- /// ()
- /// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- pub fn write_config(&mut self, config: Config) -> Result<(), Error> {
- let raw_config = RawConfig::try_from(config)?;
- get_command_result(unsafe {
- nitrokey_sys::NK_write_config(
- raw_config.numlock,
- raw_config.capslock,
- raw_config.scrollock,
- raw_config.user_password,
- false,
- self.temp_password_ptr(),
- )
- })
- }
-}
-
-impl<'a, T: Device<'a>> ConfigureOtp for Admin<'a, T> {
- fn write_hotp_slot(&mut self, data: OtpSlotData, counter: u64) -> Result<(), Error> {
- let raw_data = RawOtpSlotData::new(data)?;
- get_command_result(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(),
- self.temp_password_ptr(),
- )
- })
- }
-
- fn write_totp_slot(&mut self, data: OtpSlotData, time_window: u16) -> Result<(), Error> {
- let raw_data = RawOtpSlotData::new(data)?;
- get_command_result(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(),
- self.temp_password_ptr(),
- )
- })
- }
-
- fn erase_hotp_slot(&mut self, slot: u8) -> Result<(), Error> {
- get_command_result(unsafe {
- nitrokey_sys::NK_erase_hotp_slot(slot, self.temp_password_ptr())
- })
- }
-
- fn erase_totp_slot(&mut self, slot: u8) -> Result<(), Error> {
- get_command_result(unsafe {
- nitrokey_sys::NK_erase_totp_slot(slot, self.temp_password_ptr())
- })
- }
-}
-
-impl<'a, T: Device<'a>> AuthenticatedDevice<T> for Admin<'a, T> {
- fn new(device: T, temp_password: Vec<u8>) -> Self {
- Admin {
- device,
- temp_password,
- marker: marker::PhantomData,
- }
- }
-
- fn temp_password_ptr(&self) -> *const c_char {
- self.temp_password.as_ptr() as *const c_char
- }
-}
-
-impl<'a> Authenticate<'a> for DeviceWrapper<'a> {
- fn authenticate_user(self, password: &str) -> Result<User<'a, Self>, (Self, Error)> {
- 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<'a, Self>, (Self, Error)> {
- match self {
- DeviceWrapper::Storage(storage) => {
- authenticate_admin_wrapper(storage, DeviceWrapper::Storage, password)
- }
- DeviceWrapper::Pro(pro) => {
- authenticate_admin_wrapper(pro, DeviceWrapper::Pro, password)
- }
- }
- }
-}
-
-impl<'a> Authenticate<'a> for Pro<'a> {
- fn authenticate_user(self, password: &str) -> Result<User<'a, Self>, (Self, Error)> {
- 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<'a, Self>, (Self, Error)> {
- authenticate(self, password, |password_ptr, temp_password_ptr| unsafe {
- nitrokey_sys::NK_first_authenticate(password_ptr, temp_password_ptr)
- })
- }
-}
-
-impl<'a> Authenticate<'a> for Storage<'a> {
- fn authenticate_user(self, password: &str) -> Result<User<'a, Self>, (Self, Error)> {
- 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<'a, Self>, (Self, Error)> {
- 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 cb678d7..0000000
--- a/nitrokey/src/config.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use std::convert;
-
-use crate::error::{Error, LibraryError};
-
-/// 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 {
- Some(value)
- } else {
- None
- }
-}
-
-fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, Error> {
- if let Some(value) = value {
- if value < 3 {
- Ok(value)
- } else {
- Err(LibraryError::InvalidSlot.into())
- }
- } else {
- 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 convert::TryFrom<Config> for RawConfig {
- type Error = Error;
-
- fn try_from(config: Config) -> Result<RawConfig, Error> {
- 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/mod.rs b/nitrokey/src/device/mod.rs
deleted file mode 100644
index 0234bf0..0000000
--- a/nitrokey/src/device/mod.rs
+++ /dev/null
@@ -1,668 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-mod pro;
-mod storage;
-mod wrapper;
-
-use std::convert::{TryFrom, TryInto};
-use std::ffi;
-use std::fmt;
-
-use libc;
-use nitrokey_sys;
-
-use crate::auth::Authenticate;
-use crate::config::{Config, RawConfig};
-use crate::error::{CommunicationError, Error};
-use crate::otp::GenerateOtp;
-use crate::pws::GetPasswordSafe;
-use crate::util::{
- get_command_result, get_cstring, get_last_error, owned_str_from_ptr, result_from_string,
- result_or_error,
-};
-
-pub use pro::Pro;
-pub use storage::{
- OperationStatus, SdCardData, Storage, StorageProductionInfo, StorageStatus, VolumeMode,
- VolumeStatus,
-};
-pub use wrapper::DeviceWrapper;
-
-/// 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 {
- f.write_str(match *self {
- Model::Pro => "Pro",
- Model::Storage => "Storage",
- })
- }
-}
-
-impl From<Model> for nitrokey_sys::NK_device_model {
- fn from(model: Model) -> Self {
- match model {
- Model::Storage => nitrokey_sys::NK_device_model_NK_STORAGE,
- Model::Pro => nitrokey_sys::NK_device_model_NK_PRO,
- }
- }
-}
-
-impl TryFrom<nitrokey_sys::NK_device_model> for Model {
- type Error = Error;
-
- fn try_from(model: nitrokey_sys::NK_device_model) -> Result<Self, Error> {
- match model {
- nitrokey_sys::NK_device_model_NK_DISCONNECTED => {
- Err(CommunicationError::NotConnected.into())
- }
- nitrokey_sys::NK_device_model_NK_PRO => Ok(Model::Pro),
- nitrokey_sys::NK_device_model_NK_STORAGE => Ok(Model::Storage),
- _ => Err(Error::UnsupportedModelError),
- }
- }
-}
-
-/// Connection information for a Nitrokey device.
-#[derive(Clone, Debug, PartialEq)]
-pub struct DeviceInfo {
- /// The model of the Nitrokey device, or `None` if the model is not supported by this crate.
- pub model: Option<Model>,
- /// The USB device path.
- pub path: String,
- /// The serial number as a 8-character hex string, or `None` if the device does not expose its
- /// serial number.
- pub serial_number: Option<String>,
-}
-
-impl TryFrom<&nitrokey_sys::NK_device_info> for DeviceInfo {
- type Error = Error;
-
- fn try_from(device_info: &nitrokey_sys::NK_device_info) -> Result<DeviceInfo, Error> {
- let model_result = device_info.model.try_into();
- let model_option = model_result.map(Some).or_else(|err| match err {
- Error::UnsupportedModelError => Ok(None),
- _ => Err(err),
- })?;
- let serial_number = unsafe { ffi::CStr::from_ptr(device_info.serial_number) }
- .to_str()
- .map_err(Error::from)?;
- Ok(DeviceInfo {
- model: model_option,
- path: owned_str_from_ptr(device_info.path)?,
- serial_number: get_hidapi_serial_number(serial_number),
- })
- }
-}
-
-impl fmt::Display for DeviceInfo {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self.model {
- Some(model) => write!(f, "Nitrokey {}", model)?,
- None => write!(f, "Unsupported Nitrokey model")?,
- }
- write!(f, " at {} with ", self.path)?;
- match &self.serial_number {
- Some(ref serial_number) => write!(f, "serial no. {}", serial_number),
- None => write!(f, "an unknown serial number"),
- }
- }
-}
-
-/// Parses a serial number returned by hidapi and transforms it to the Nitrokey format.
-///
-/// If the serial number is all zero, this function returns `None`. Otherwise, it uses the last
-/// eight characters. If these are all zero, the first eight characters are used instead. This
-/// function also makes sure that the returned string is lowercase, consistent with libnitrokey’s
-/// hex string formatting.
-///
-/// The reason for this behavior is that the Nitrokey Storage does not report its serial number at
-/// all (all zero value), while the Nitrokey Pro with firmware 0.9 or later writes its serial
-/// number to the last eight characters. Nitrokey Pro devices with firmware 0.8 or earlier wrote
-/// their serial number to the first eight characters.
-fn get_hidapi_serial_number(serial_number: &str) -> Option<String> {
- let len = serial_number.len();
- if len < 8 {
- // The serial number in the USB descriptor has 12 bytes, we need at least four of them
- return None;
- }
-
- let iter = serial_number.char_indices().rev();
- let first_non_null = iter.skip_while(|(_, c)| *c == '0').next();
- if let Some((i, _)) = first_non_null {
- if len - i < 8 {
- // The last eight characters contain at least one non-zero character --> use them
- let mut serial_number = serial_number.split_at(len - 8).1.to_string();
- serial_number.make_ascii_lowercase();
- Some(serial_number)
- } else {
- // The last eight characters are all zero --> use the first eight
- let mut serial_number = serial_number.split_at(8).0.to_string();
- serial_number.make_ascii_lowercase();
- Some(serial_number)
- }
- } else {
- // The serial number is all zero
- None
- }
-}
-
-/// A firmware version for a Nitrokey device.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub struct FirmwareVersion {
- /// The major firmware version, e. g. 0 in v0.40.
- pub major: u8,
- /// The minor firmware version, e. g. 40 in v0.40.
- pub minor: u8,
-}
-
-impl fmt::Display for FirmwareVersion {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "v{}.{}", self.major, self.minor)
- }
-}
-
-/// The status information common to all Nitrokey devices.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub struct Status {
- /// The firmware version of the device.
- pub firmware_version: FirmwareVersion,
- /// The serial number of the device.
- pub serial_number: u32,
- /// The configuration of the device.
- pub config: Config,
-}
-
-impl From<nitrokey_sys::NK_status> for Status {
- fn from(status: nitrokey_sys::NK_status) -> Self {
- Self {
- firmware_version: FirmwareVersion {
- major: status.firmware_version_major,
- minor: status.firmware_version_minor,
- },
- serial_number: status.serial_number_smart_card,
- config: RawConfig {
- numlock: status.config_numlock,
- capslock: status.config_capslock,
- scrollock: status.config_scrolllock,
- user_password: status.otp_user_password,
- }
- .into(),
- }
- }
-}
-
-/// 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<'a>: Authenticate<'a> + GetPasswordSafe<'a> + GenerateOtp + fmt::Debug {
- /// Returns the [`Manager`][] instance that has been used to connect to this device.
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::{Device, DeviceWrapper};
- ///
- /// fn do_something(device: DeviceWrapper) {
- /// // reconnect to any device
- /// let manager = device.into_manager();
- /// let device = manager.connect();
- /// // do something with the device
- /// // ...
- /// }
- ///
- /// match nitrokey::take()?.connect() {
- /// Ok(device) => do_something(device),
- /// Err(err) => println!("Could not connect to a Nitrokey: {}", err),
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- fn into_manager(self) -> &'a mut crate::Manager;
-
- /// Returns the model of the connected Nitrokey device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// println!("Connected to a Nitrokey {}", device.get_model());
- /// # Ok(())
- /// # }
- fn get_model(&self) -> Model;
-
- /// Returns the status of the Nitrokey device.
- ///
- /// This methods returns the status information common to all Nitrokey devices as a
- /// [`Status`][] struct. Some models may provide more information, for example
- /// [`get_storage_status`][] returns the [`StorageStatus`][] struct.
- ///
- /// # Errors
- ///
- /// - [`NotConnected`][] if the Nitrokey device has been disconnected
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- ///
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let status = device.get_status()?;
- /// println!("Firmware version: {}", status.firmware_version);
- /// println!("Serial number: {:x}", status.serial_number);
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`get_storage_status`]: struct.Storage.html#method.get_storage_status
- /// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
- /// [`Status`]: struct.Status.html
- /// [`StorageStatus`]: struct.StorageStatus.html
- fn get_status(&self) -> Result<Status, Error>;
-
- /// 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// match device.get_serial_number() {
- /// Ok(number) => println!("serial no: {}", number),
- /// Err(err) => eprintln!("Could not get serial number: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- fn get_serial_number(&self) -> Result<String, Error> {
- result_from_string(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let count = device.get_user_retry_count();
- /// match device.get_user_retry_count() {
- /// Ok(count) => println!("{} remaining authentication attempts (user)", count),
- /// Err(err) => eprintln!("Could not get user retry count: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- fn get_user_retry_count(&self) -> Result<u8, Error> {
- result_or_error(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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let count = device.get_admin_retry_count();
- /// match device.get_admin_retry_count() {
- /// Ok(count) => println!("{} remaining authentication attempts (admin)", count),
- /// Err(err) => eprintln!("Could not get admin retry count: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- fn get_admin_retry_count(&self) -> Result<u8, Error> {
- result_or_error(unsafe { nitrokey_sys::NK_get_admin_retry_count() })
- }
-
- /// Returns the firmware version.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// match device.get_firmware_version() {
- /// Ok(version) => println!("Firmware version: {}", version),
- /// Err(err) => eprintln!("Could not access firmware version: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- fn get_firmware_version(&self) -> Result<FirmwareVersion, Error> {
- let major = result_or_error(unsafe { nitrokey_sys::NK_get_major_firmware_version() })?;
- let minor = result_or_error(unsafe { nitrokey_sys::NK_get_minor_firmware_version() })?;
- Ok(FirmwareVersion { major, minor })
- }
-
- /// Returns the current configuration of the Nitrokey device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.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, Error> {
- let config_ptr = unsafe { 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 = unsafe { RawConfig::from(*config_array_ptr) };
- unsafe { libc::free(config_ptr as *mut libc::c_void) };
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.change_admin_pin("12345678", "12345679") {
- /// Ok(()) => println!("Updated admin PIN."),
- /// Err(err) => eprintln!("Failed to update admin PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn change_admin_pin(&mut self, current: &str, new: &str) -> Result<(), Error> {
- let current_string = get_cstring(current)?;
- let new_string = get_cstring(new)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.change_user_pin("123456", "123457") {
- /// Ok(()) => println!("Updated admin PIN."),
- /// Err(err) => eprintln!("Failed to update admin PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn change_user_pin(&mut self, current: &str, new: &str) -> Result<(), Error> {
- let current_string = get_cstring(current)?;
- let new_string = get_cstring(new)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.unlock_user_pin("12345678", "123456") {
- /// Ok(()) => println!("Unlocked user PIN."),
- /// Err(err) => eprintln!("Failed to unlock user PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn unlock_user_pin(&mut self, admin_pin: &str, user_pin: &str) -> Result<(), Error> {
- let admin_pin_string = get_cstring(admin_pin)?;
- let user_pin_string = get_cstring(user_pin)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.lock() {
- /// Ok(()) => println!("Locked the Nitrokey device."),
- /// Err(err) => eprintln!("Could not lock the Nitrokey device: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- fn lock(&mut self) -> Result<(), Error> {
- get_command_result(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.factory_reset("12345678") {
- /// Ok(()) => println!("Performed a factory reset."),
- /// Err(err) => eprintln!("Could not perform a factory reset: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`build_aes_key`]: #method.build_aes_key
- fn factory_reset(&mut self, admin_pin: &str) -> Result<(), Error> {
- let admin_pin_string = get_cstring(admin_pin)?;
- get_command_result(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.build_aes_key("12345678") {
- /// Ok(()) => println!("New AES keys have been built."),
- /// Err(err) => eprintln!("Could not build new AES keys: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`factory_reset`]: #method.factory_reset
- fn build_aes_key(&mut self, admin_pin: &str) -> Result<(), Error> {
- let admin_pin_string = get_cstring(admin_pin)?;
- get_command_result(unsafe { nitrokey_sys::NK_build_aes_key(admin_pin_string.as_ptr()) })
- }
-}
-
-fn get_connected_model() -> Result<Model, Error> {
- Model::try_from(unsafe { nitrokey_sys::NK_get_device_model() })
-}
-
-pub(crate) fn create_device_wrapper(
- manager: &mut crate::Manager,
- model: Model,
-) -> DeviceWrapper<'_> {
- match model {
- Model::Pro => Pro::new(manager).into(),
- Model::Storage => Storage::new(manager).into(),
- }
-}
-
-pub(crate) fn get_connected_device(
- manager: &mut crate::Manager,
-) -> Result<DeviceWrapper<'_>, Error> {
- Ok(create_device_wrapper(manager, get_connected_model()?))
-}
-
-pub(crate) fn connect_enum(model: Model) -> bool {
- unsafe { nitrokey_sys::NK_login_enum(model.into()) == 1 }
-}
-
-#[cfg(test)]
-mod tests {
- use super::get_hidapi_serial_number;
-
- #[test]
- fn hidapi_serial_number() {
- assert_eq!(None, get_hidapi_serial_number(""));
- assert_eq!(None, get_hidapi_serial_number("00000000000000000"));
- assert_eq!(None, get_hidapi_serial_number("1234"));
- assert_eq!(
- Some("00001234".to_string()),
- get_hidapi_serial_number("00001234")
- );
- assert_eq!(
- Some("00001234".to_string()),
- get_hidapi_serial_number("000000001234")
- );
- assert_eq!(
- Some("00001234".to_string()),
- get_hidapi_serial_number("100000001234")
- );
- assert_eq!(
- Some("12340000".to_string()),
- get_hidapi_serial_number("123400000000")
- );
- assert_eq!(
- Some("00005678".to_string()),
- get_hidapi_serial_number("000000000000000000005678")
- );
- assert_eq!(
- Some("00001234".to_string()),
- get_hidapi_serial_number("000012340000000000000000")
- );
- assert_eq!(
- Some("0000ffff".to_string()),
- get_hidapi_serial_number("00000000000000000000FFFF")
- );
- assert_eq!(
- Some("0000ffff".to_string()),
- get_hidapi_serial_number("00000000000000000000ffff")
- );
- }
-}
diff --git a/nitrokey/src/device/pro.rs b/nitrokey/src/device/pro.rs
deleted file mode 100644
index 591b730..0000000
--- a/nitrokey/src/device/pro.rs
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use nitrokey_sys;
-
-use crate::device::{Device, Model, Status};
-use crate::error::Error;
-use crate::otp::GenerateOtp;
-use crate::util::get_command_result;
-
-/// A Nitrokey Pro device without user or admin authentication.
-///
-/// Use the [`connect`][] method to obtain an instance wrapper or the [`connect_pro`] method 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::Error;
-///
-/// fn perform_user_task<'a>(device: &User<'a, Pro<'a>>) {}
-/// fn perform_other_task(device: &Pro) {}
-///
-/// # fn try_main() -> Result<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let device = manager.connect_pro()?;
-/// let device = match device.authenticate_user("123456") {
-/// Ok(user) => {
-/// perform_user_task(&user);
-/// user.device()
-/// },
-/// Err((device, err)) => {
-/// eprintln!("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`]: struct.Manager.html#method.connect
-/// [`connect_pro`]: struct.Manager.html#method.connect_pro
-#[derive(Debug)]
-pub struct Pro<'a> {
- manager: Option<&'a mut crate::Manager>,
-}
-
-impl<'a> Pro<'a> {
- pub(crate) fn new(manager: &'a mut crate::Manager) -> Pro<'a> {
- Pro {
- manager: Some(manager),
- }
- }
-}
-
-impl<'a> Drop for Pro<'a> {
- fn drop(&mut self) {
- unsafe {
- nitrokey_sys::NK_logout();
- }
- }
-}
-
-impl<'a> Device<'a> for Pro<'a> {
- fn into_manager(mut self) -> &'a mut crate::Manager {
- self.manager.take().unwrap()
- }
-
- fn get_model(&self) -> Model {
- Model::Pro
- }
-
- fn get_status(&self) -> Result<Status, Error> {
- let mut raw_status = nitrokey_sys::NK_status {
- firmware_version_major: 0,
- firmware_version_minor: 0,
- serial_number_smart_card: 0,
- config_numlock: 0,
- config_capslock: 0,
- config_scrolllock: 0,
- otp_user_password: false,
- };
- get_command_result(unsafe { nitrokey_sys::NK_get_status(&mut raw_status) })?;
- Ok(raw_status.into())
- }
-}
-
-impl<'a> GenerateOtp for Pro<'a> {}
diff --git a/nitrokey/src/device/storage.rs b/nitrokey/src/device/storage.rs
deleted file mode 100644
index deb2844..0000000
--- a/nitrokey/src/device/storage.rs
+++ /dev/null
@@ -1,884 +0,0 @@
-// Copyright (C) 2019-2020 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use std::convert::TryFrom as _;
-use std::fmt;
-use std::ops;
-
-use nitrokey_sys;
-
-use crate::device::{Device, FirmwareVersion, Model, Status};
-use crate::error::{CommandError, Error};
-use crate::otp::GenerateOtp;
-use crate::util::{get_command_result, get_cstring, get_last_error};
-
-/// A Nitrokey Storage device without user or admin authentication.
-///
-/// Use the [`connect`][] method to obtain an instance wrapper or the [`connect_storage`] method 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::Error;
-///
-/// fn perform_user_task<'a>(device: &User<'a, Storage<'a>>) {}
-/// fn perform_other_task(device: &Storage) {}
-///
-/// # fn try_main() -> Result<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let device = manager.connect_storage()?;
-/// let device = match device.authenticate_user("123456") {
-/// Ok(user) => {
-/// perform_user_task(&user);
-/// user.device()
-/// },
-/// Err((device, err)) => {
-/// eprintln!("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`]: struct.Manager.html#method.connect
-/// [`connect_storage`]: struct.Manager.html#method.connect_storage
-#[derive(Debug)]
-pub struct Storage<'a> {
- manager: Option<&'a mut crate::Manager>,
-}
-
-/// 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 {
- f.write_str(match *self {
- VolumeMode::ReadOnly => "read-only",
- VolumeMode::ReadWrite => "read-write",
- })
- }
-}
-
-/// 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,
-}
-
-/// Production information for a Storage device.
-#[derive(Debug)]
-pub struct StorageProductionInfo {
- /// The firmware version.
- pub firmware_version: FirmwareVersion,
- /// 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 firmware version.
- pub firmware_version: FirmwareVersion,
- /// 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,
-}
-
-/// The progress of a background operation on the Nitrokey.
-///
-/// Some commands may start a background operation during which no other commands can be executed.
-/// This enum stores the status of a background operation: Ongoing with a relative progress (up to
-/// 100), or idle, i. e. no background operation has been started or the last one has been
-/// finished.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum OperationStatus {
- /// A background operation with its progress value (less than or equal to 100).
- Ongoing(u8),
- /// No backgrund operation.
- Idle,
-}
-
-impl<'a> Storage<'a> {
- pub(crate) fn new(manager: &'a mut crate::Manager) -> Storage<'a> {
- Storage {
- manager: Some(manager),
- }
- }
-
- /// 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// match device.change_update_pin("12345678", "87654321") {
- /// Ok(()) => println!("Updated update PIN."),
- /// Err(err) => eprintln!("Failed to update update PIN: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn change_update_pin(&mut self, current: &str, new: &str) -> Result<(), Error> {
- let current_string = get_cstring(current)?;
- let new_string = get_cstring(new)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// match device.enable_firmware_update("12345678") {
- /// Ok(()) => println!("Nitrokey entered update mode."),
- /// Err(err) => eprintln!("Could not enter update mode: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn enable_firmware_update(&mut self, update_pin: &str) -> Result<(), Error> {
- let update_pin_string = get_cstring(update_pin)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// match device.enable_encrypted_volume("123456") {
- /// Ok(()) => println!("Enabled the encrypted volume."),
- /// Err(err) => eprintln!("Could not enable the encrypted volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn enable_encrypted_volume(&mut self, user_pin: &str) -> Result<(), Error> {
- let user_pin = get_cstring(user_pin)?;
- get_command_result(unsafe { 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::Error;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// 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) => {
- /// eprintln!("Could not disable the encrypted volume: {}", err);
- /// },
- /// };
- /// },
- /// Err(err) => eprintln!("Could not enable the encrypted volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn disable_encrypted_volume(&mut self) -> Result<(), Error> {
- get_command_result(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// device.enable_encrypted_volume("123445")?;
- /// match device.enable_hidden_volume("hidden-pw") {
- /// Ok(()) => println!("Enabled a hidden volume."),
- /// Err(err) => eprintln!("Could not enable the hidden volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`enable_encrypted_volume`]: #method.enable_encrypted_volume
- /// [`AesDecryptionFailed`]: enum.CommandError.html#variant.AesDecryptionFailed
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- pub fn enable_hidden_volume(&mut self, volume_password: &str) -> Result<(), Error> {
- let volume_password = get_cstring(volume_password)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// 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) => {
- /// eprintln!("Could not disable the hidden volume: {}", err);
- /// },
- /// };
- /// },
- /// Err(err) => eprintln!("Could not enable the hidden volume: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn disable_hidden_volume(&mut self) -> Result<(), Error> {
- get_command_result(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// device.enable_encrypted_volume("123445")?;
- /// device.create_hidden_volume(0, 0, 100, "hidden-pw")?;
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`AesDecryptionFailed`]: enum.CommandError.html#variant.AesDecryptionFailed
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- pub fn create_hidden_volume(
- &mut self,
- slot: u8,
- start: u8,
- end: u8,
- password: &str,
- ) -> Result<(), Error> {
- let password = get_cstring(password)?;
- get_command_result(unsafe {
- 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::Error;
- /// use nitrokey::VolumeMode;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// match device.set_unencrypted_volume_mode("12345678", VolumeMode::ReadWrite) {
- /// Ok(()) => println!("Set the unencrypted volume to read-write mode."),
- /// Err(err) => eprintln!("Could not set the unencrypted volume to read-write mode: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn set_unencrypted_volume_mode(
- &mut self,
- admin_pin: &str,
- mode: VolumeMode,
- ) -> Result<(), Error> {
- 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)
- }
-
- /// Sets the access mode of the encrypted volume.
- ///
- /// This command will reconnect the encrypted volume so buffers should be flushed before
- /// calling it. It is only available in firmware version 0.49.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the provided password contains a null byte
- /// - [`WrongPassword`][] if the provided admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::Error;
- /// use nitrokey::VolumeMode;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// match device.set_encrypted_volume_mode("12345678", VolumeMode::ReadWrite) {
- /// Ok(()) => println!("Set the encrypted volume to read-write mode."),
- /// Err(err) => eprintln!("Could not set the encrypted volume to read-write mode: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn set_encrypted_volume_mode(
- &mut self,
- admin_pin: &str,
- mode: VolumeMode,
- ) -> Result<(), Error> {
- let admin_pin = get_cstring(admin_pin)?;
- let result = match mode {
- VolumeMode::ReadOnly => unsafe {
- nitrokey_sys::NK_set_encrypted_read_only(admin_pin.as_ptr())
- },
- VolumeMode::ReadWrite => unsafe {
- nitrokey_sys::NK_set_encrypted_read_write(admin_pin.as_ptr())
- },
- };
- get_command_result(result)
- }
-
- /// Returns the status of the connected storage device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::Error;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect_storage()?;
- /// match device.get_storage_status() {
- /// Ok(status) => {
- /// println!("SD card ID: {:#x}", status.serial_number_sd_card);
- /// },
- /// Err(err) => eprintln!("Could not get Storage status: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn get_storage_status(&self) -> Result<StorageStatus, Error> {
- 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) };
- get_command_result(raw_result).map(|_| StorageStatus::from(raw_status))
- }
-
- /// Returns the production information for the connected storage device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// # use nitrokey::Error;
- ///
- /// fn use_volume() {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect_storage()?;
- /// 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) => eprintln!("Could not get Storage production info: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- pub fn get_production_info(&self) -> Result<StorageProductionInfo, Error> {
- 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) };
- get_command_result(raw_result).map(|_| 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect_storage()?;
- /// match device.clear_new_sd_card_warning("12345678") {
- /// Ok(()) => println!("Cleared the new SD card warning."),
- /// Err(err) => eprintln!("Could not set the clear the new SD card warning: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn clear_new_sd_card_warning(&mut self, admin_pin: &str) -> Result<(), Error> {
- let admin_pin = get_cstring(admin_pin)?;
- get_command_result(unsafe {
- nitrokey_sys::NK_clear_new_sd_card_warning(admin_pin.as_ptr())
- })
- }
-
- /// Returns a range of the SD card that has not been used to during this power cycle.
- ///
- /// The Nitrokey Storage tracks read and write access to the SD card during a power cycle.
- /// This method returns a range of the SD card that has not been accessed during this power
- /// cycle. The range is relative to the total size of the SD card, so both values are less
- /// than or equal to 100. This can be used as a guideline when creating a hidden volume.
- ///
- /// # Example
- ///
- /// ```no_run
- /// let mut manager = nitrokey::take()?;
- /// let storage = manager.connect_storage()?;
- /// let usage = storage.get_sd_card_usage()?;
- /// println!("SD card usage: {}..{}", usage.start, usage.end);
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- pub fn get_sd_card_usage(&self) -> Result<ops::Range<u8>, Error> {
- let mut usage_data = nitrokey_sys::NK_SD_usage_data {
- write_level_min: 0,
- write_level_max: 0,
- };
- let result = unsafe { nitrokey_sys::NK_get_SD_usage_data(&mut usage_data) };
- match get_command_result(result) {
- Ok(_) => {
- if usage_data.write_level_min > usage_data.write_level_max
- || usage_data.write_level_max > 100
- {
- Err(Error::UnexpectedError)
- } else {
- Ok(ops::Range {
- start: usage_data.write_level_min,
- end: usage_data.write_level_max,
- })
- }
- }
- Err(err) => Err(err),
- }
- }
-
- /// Blinks the red and green LED alternatively and infinitely until the device is reconnected.
- pub fn wink(&mut self) -> Result<(), Error> {
- get_command_result(unsafe { nitrokey_sys::NK_wink() })
- }
-
- /// Returns the status of an ongoing background operation on the Nitrokey Storage.
- ///
- /// Some commands may start a background operation during which no other commands can be
- /// executed. This method can be used to check whether such an operation is ongoing.
- ///
- /// Currently, this is only used by the [`fill_sd_card`][] method.
- ///
- /// [`fill_sd_card`]: #method.fill_sd_card
- pub fn get_operation_status(&self) -> Result<OperationStatus, Error> {
- let status = unsafe { nitrokey_sys::NK_get_progress_bar_value() };
- match status {
- 0..=100 => u8::try_from(status)
- .map(OperationStatus::Ongoing)
- .map_err(|_| Error::UnexpectedError),
- -1 => Ok(OperationStatus::Idle),
- -2 => Err(get_last_error()),
- _ => Err(Error::UnexpectedError),
- }
- }
-
- /// Overwrites the SD card with random data.
- ///
- /// Ths method starts a background operation that overwrites the SD card with random data.
- /// While this operation is ongoing, no other commands can be executed. Use the
- /// [`get_operation_status`][] function to check the progress of the operation.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if one of the provided passwords contains a null byte
- /// - [`WrongPassword`][] if the admin password is wrong
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::OperationStatus;
- ///
- /// let mut manager = nitrokey::take()?;
- /// let mut storage = manager.connect_storage()?;
- /// storage.fill_sd_card("12345678")?;
- /// loop {
- /// match storage.get_operation_status()? {
- /// OperationStatus::Ongoing(progress) => println!("{}/100", progress),
- /// OperationStatus::Idle => {
- /// println!("Done!");
- /// break;
- /// }
- /// }
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`get_operation_status`]: #method.get_operation_status
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn fill_sd_card(&mut self, admin_pin: &str) -> Result<(), Error> {
- let admin_pin_string = get_cstring(admin_pin)?;
- get_command_result(unsafe {
- nitrokey_sys::NK_fill_SD_card_with_random_data(admin_pin_string.as_ptr())
- })
- .or_else(|err| match err {
- // libnitrokey’s C API returns a LongOperationInProgressException with the same error
- // code as the WrongCrc command error, so we cannot distinguish them.
- Error::CommandError(CommandError::WrongCrc) => Ok(()),
- err => Err(err),
- })
- }
-
- /// 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.LibraryError.html#variant.InvalidString
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- pub fn export_firmware(&mut self, admin_pin: &str) -> Result<(), Error> {
- let admin_pin_string = get_cstring(admin_pin)?;
- get_command_result(unsafe { nitrokey_sys::NK_export_firmware(admin_pin_string.as_ptr()) })
- }
-}
-
-impl<'a> Drop for Storage<'a> {
- fn drop(&mut self) {
- unsafe {
- nitrokey_sys::NK_logout();
- }
- }
-}
-
-impl<'a> Device<'a> for Storage<'a> {
- fn into_manager(mut self) -> &'a mut crate::Manager {
- self.manager.take().unwrap()
- }
-
- fn get_model(&self) -> Model {
- Model::Storage
- }
-
- fn get_status(&self) -> Result<Status, Error> {
- // Currently, the GET_STATUS command does not report the correct firmware version and
- // serial number on the Nitrokey Storage, see [0]. Until this is fixed in libnitrokey, we
- // have to manually execute the GET_DEVICE_STATUS command (get_storage_status) and complete
- // the missing data, see [1].
- // [0] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/96
- // [1] https://github.com/Nitrokey/libnitrokey/issues/166
-
- let mut raw_status = nitrokey_sys::NK_status {
- firmware_version_major: 0,
- firmware_version_minor: 0,
- serial_number_smart_card: 0,
- config_numlock: 0,
- config_capslock: 0,
- config_scrolllock: 0,
- otp_user_password: false,
- };
- get_command_result(unsafe { nitrokey_sys::NK_get_status(&mut raw_status) })?;
- let mut status = Status::from(raw_status);
-
- let storage_status = self.get_storage_status()?;
- status.firmware_version = storage_status.firmware_version;
- status.serial_number = storage_status.serial_number_smart_card;
-
- Ok(status)
- }
-}
-
-impl<'a> GenerateOtp for Storage<'a> {}
-
-impl From<nitrokey_sys::NK_storage_ProductionTest> for StorageProductionInfo {
- fn from(data: nitrokey_sys::NK_storage_ProductionTest) -> Self {
- Self {
- firmware_version: FirmwareVersion {
- major: data.FirmwareVersion_au8[0],
- 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: FirmwareVersion {
- major: status.firmware_version_major,
- 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/device/wrapper.rs b/nitrokey/src/device/wrapper.rs
deleted file mode 100644
index 69291ad..0000000
--- a/nitrokey/src/device/wrapper.rs
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use crate::device::{Device, Model, Pro, Status, Storage};
-use crate::error::Error;
-use crate::otp::GenerateOtp;
-
-/// A wrapper for a Nitrokey device of unknown type.
-///
-/// Use the [`connect`][] method 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::Error;
-///
-/// fn perform_user_task<'a>(device: &User<'a, DeviceWrapper<'a>>) {}
-/// fn perform_other_task(device: &DeviceWrapper) {}
-///
-/// # fn try_main() -> Result<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let device = manager.connect()?;
-/// let device = match device.authenticate_user("123456") {
-/// Ok(user) => {
-/// perform_user_task(&user);
-/// user.device()
-/// },
-/// Err((device, err)) => {
-/// eprintln!("Could not authenticate as user: {}", err);
-/// device
-/// },
-/// };
-/// perform_other_task(&device);
-/// # Ok(())
-/// # }
-/// ```
-///
-/// Device-specific commands:
-///
-/// ```no_run
-/// use nitrokey::{DeviceWrapper, Storage};
-/// # use nitrokey::Error;
-///
-/// fn perform_common_task(device: &DeviceWrapper) {}
-/// fn perform_storage_task(device: &Storage) {}
-///
-/// # fn try_main() -> Result<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let device = manager.connect()?;
-/// perform_common_task(&device);
-/// match device {
-/// DeviceWrapper::Storage(storage) => perform_storage_task(&storage),
-/// _ => (),
-/// };
-/// # Ok(())
-/// # }
-/// ```
-///
-/// [`connect`]: struct.Manager.html#method.connect
-#[derive(Debug)]
-pub enum DeviceWrapper<'a> {
- /// A Nitrokey Storage device.
- Storage(Storage<'a>),
- /// A Nitrokey Pro device.
- Pro(Pro<'a>),
-}
-
-impl<'a> DeviceWrapper<'a> {
- fn device(&self) -> &dyn Device<'a> {
- match *self {
- DeviceWrapper::Storage(ref storage) => storage,
- DeviceWrapper::Pro(ref pro) => pro,
- }
- }
-
- fn device_mut(&mut self) -> &mut dyn Device<'a> {
- match *self {
- DeviceWrapper::Storage(ref mut storage) => storage,
- DeviceWrapper::Pro(ref mut pro) => pro,
- }
- }
-}
-
-impl<'a> From<Pro<'a>> for DeviceWrapper<'a> {
- fn from(device: Pro<'a>) -> Self {
- DeviceWrapper::Pro(device)
- }
-}
-
-impl<'a> From<Storage<'a>> for DeviceWrapper<'a> {
- fn from(device: Storage<'a>) -> Self {
- DeviceWrapper::Storage(device)
- }
-}
-
-impl<'a> GenerateOtp for DeviceWrapper<'a> {
- fn get_hotp_slot_name(&self, slot: u8) -> Result<String, Error> {
- self.device().get_hotp_slot_name(slot)
- }
-
- fn get_totp_slot_name(&self, slot: u8) -> Result<String, Error> {
- self.device().get_totp_slot_name(slot)
- }
-
- fn get_hotp_code(&mut self, slot: u8) -> Result<String, Error> {
- self.device_mut().get_hotp_code(slot)
- }
-
- fn get_totp_code(&self, slot: u8) -> Result<String, Error> {
- self.device().get_totp_code(slot)
- }
-}
-
-impl<'a> Device<'a> for DeviceWrapper<'a> {
- fn into_manager(self) -> &'a mut crate::Manager {
- match self {
- DeviceWrapper::Pro(dev) => dev.into_manager(),
- DeviceWrapper::Storage(dev) => dev.into_manager(),
- }
- }
-
- fn get_model(&self) -> Model {
- match *self {
- DeviceWrapper::Pro(_) => Model::Pro,
- DeviceWrapper::Storage(_) => Model::Storage,
- }
- }
-
- fn get_status(&self) -> Result<Status, Error> {
- match self {
- DeviceWrapper::Pro(dev) => dev.get_status(),
- DeviceWrapper::Storage(dev) => dev.get_status(),
- }
- }
-}
diff --git a/nitrokey/src/error.rs b/nitrokey/src/error.rs
deleted file mode 100644
index f9af594..0000000
--- a/nitrokey/src/error.rs
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use std::error;
-use std::fmt;
-use std::os::raw;
-use std::str;
-use std::sync;
-
-use crate::device;
-
-/// An error returned by the nitrokey crate.
-#[derive(Debug)]
-pub enum Error {
- /// An error reported by the Nitrokey device in the response packet.
- CommandError(CommandError),
- /// A device communication error.
- CommunicationError(CommunicationError),
- /// An error occurred due to concurrent access to the Nitrokey device.
- ConcurrentAccessError,
- /// A library usage error.
- LibraryError(LibraryError),
- /// An error that occurred due to a poisoned lock.
- PoisonError(sync::PoisonError<sync::MutexGuard<'static, crate::Manager>>),
- /// An error that occurred during random number generation.
- RandError(Box<dyn error::Error>),
- /// An error that is caused by an unexpected value returned by libnitrokey.
- UnexpectedError,
- /// An unknown error returned by libnitrokey.
- UnknownError(i64),
- /// An error caused by a Nitrokey model that is not supported by this crate.
- UnsupportedModelError,
- /// An error occurred when interpreting a UTF-8 string.
- Utf8Error(str::Utf8Error),
-}
-
-impl From<raw::c_int> for Error {
- fn from(code: raw::c_int) -> Self {
- if let Some(err) = CommandError::try_from(code) {
- Error::CommandError(err)
- } else if let Some(err) = CommunicationError::try_from(256 - code) {
- Error::CommunicationError(err)
- } else if let Some(err) = LibraryError::try_from(code) {
- Error::LibraryError(err)
- } else {
- Error::UnknownError(code.into())
- }
- }
-}
-
-impl From<CommandError> for Error {
- fn from(err: CommandError) -> Self {
- Error::CommandError(err)
- }
-}
-
-impl From<CommunicationError> for Error {
- fn from(err: CommunicationError) -> Self {
- Error::CommunicationError(err)
- }
-}
-
-impl From<LibraryError> for Error {
- fn from(err: LibraryError) -> Self {
- Error::LibraryError(err)
- }
-}
-
-impl From<str::Utf8Error> for Error {
- fn from(error: str::Utf8Error) -> Self {
- Error::Utf8Error(error)
- }
-}
-
-impl From<sync::PoisonError<sync::MutexGuard<'static, crate::Manager>>> for Error {
- fn from(error: sync::PoisonError<sync::MutexGuard<'static, crate::Manager>>) -> Self {
- Error::PoisonError(error)
- }
-}
-
-impl From<sync::TryLockError<sync::MutexGuard<'static, crate::Manager>>> for Error {
- fn from(error: sync::TryLockError<sync::MutexGuard<'static, crate::Manager>>) -> Self {
- match error {
- sync::TryLockError::Poisoned(err) => err.into(),
- sync::TryLockError::WouldBlock => Error::ConcurrentAccessError,
- }
- }
-}
-
-impl<'a, T: device::Device<'a>> From<(T, Error)> for Error {
- fn from((_, err): (T, Error)) -> Self {
- err
- }
-}
-
-impl error::Error for Error {
- fn source(&self) -> Option<&(dyn error::Error + 'static)> {
- match *self {
- Error::CommandError(ref err) => Some(err),
- Error::CommunicationError(ref err) => Some(err),
- Error::ConcurrentAccessError => None,
- Error::LibraryError(ref err) => Some(err),
- Error::PoisonError(ref err) => Some(err),
- Error::RandError(ref err) => Some(err.as_ref()),
- Error::UnexpectedError => None,
- Error::UnknownError(_) => None,
- Error::UnsupportedModelError => None,
- Error::Utf8Error(ref err) => Some(err),
- }
- }
-}
-
-impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match *self {
- Error::CommandError(ref err) => write!(f, "Command error: {}", err),
- Error::CommunicationError(ref err) => write!(f, "Communication error: {}", err),
- Error::ConcurrentAccessError => write!(f, "Internal error: concurrent access"),
- Error::LibraryError(ref err) => write!(f, "Library error: {}", err),
- Error::PoisonError(_) => write!(f, "Internal error: poisoned lock"),
- Error::RandError(ref err) => write!(f, "RNG error: {}", err),
- Error::UnexpectedError => write!(f, "An unexpected error occurred"),
- Error::UnknownError(ref err) => write!(f, "Unknown error: {}", err),
- Error::UnsupportedModelError => write!(f, "Unsupported Nitrokey model"),
- Error::Utf8Error(ref err) => write!(f, "UTF-8 error: {}", err),
- }
- }
-}
-
-/// An error reported by the Nitrokey device in the response packet.
-#[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,
-}
-
-impl CommandError {
- fn try_from(value: raw::c_int) -> Option<Self> {
- match value {
- 1 => Some(CommandError::WrongCrc),
- 2 => Some(CommandError::WrongSlot),
- 3 => Some(CommandError::SlotNotProgrammed),
- 4 => Some(CommandError::WrongPassword),
- 5 => Some(CommandError::NotAuthorized),
- 6 => Some(CommandError::Timestamp),
- 7 => Some(CommandError::NoName),
- 8 => Some(CommandError::NotSupported),
- 9 => Some(CommandError::UnknownCommand),
- 10 => Some(CommandError::AesDecryptionFailed),
- _ => None,
- }
- }
-}
-
-impl error::Error for CommandError {}
-
-impl fmt::Display for CommandError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_str(match *self {
- CommandError::WrongCrc => "A packet with a wrong checksum has been sent or received",
- CommandError::WrongSlot => "The given slot does not exist",
- CommandError::SlotNotProgrammed => "The given slot is not programmed",
- CommandError::WrongPassword => "The given password is wrong",
- CommandError::NotAuthorized => {
- "You are not authorized for this command or provided a wrong temporary \
- password"
- }
- CommandError::Timestamp => "An error occurred when getting or setting the time",
- CommandError::NoName => "You did not provide a name for the slot",
- CommandError::NotSupported => "This command is not supported by this device",
- CommandError::UnknownCommand => "This command is unknown",
- CommandError::AesDecryptionFailed => "AES decryption failed",
- })
- }
-}
-
-/// A device communication error.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum CommunicationError {
- /// Could not connect to a Nitrokey device.
- NotConnected,
- /// Sending a packet failed.
- SendingFailure,
- /// Receiving a packet failed.
- ReceivingFailure,
- /// A packet with a wrong checksum was received.
- InvalidCrc,
-}
-
-impl CommunicationError {
- fn try_from(value: raw::c_int) -> Option<Self> {
- match value {
- 2 => Some(CommunicationError::NotConnected),
- 3 => Some(CommunicationError::SendingFailure),
- 4 => Some(CommunicationError::ReceivingFailure),
- 5 => Some(CommunicationError::InvalidCrc),
- _ => None,
- }
- }
-}
-
-impl error::Error for CommunicationError {}
-
-impl fmt::Display for CommunicationError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_str(match *self {
- CommunicationError::NotConnected => "Could not connect to a Nitrokey device",
- CommunicationError::SendingFailure => "Sending a packet failed",
- CommunicationError::ReceivingFailure => "Receiving a packet failed",
- CommunicationError::InvalidCrc => "A packet with a wrong checksum was received",
- })
- }
-}
-
-/// A library usage error.
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum LibraryError {
- /// 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,
- /// You passed a string containing a null byte.
- InvalidString,
-}
-
-impl LibraryError {
- fn try_from(value: raw::c_int) -> Option<Self> {
- match value {
- 200 => Some(LibraryError::StringTooLong),
- 201 => Some(LibraryError::InvalidSlot),
- 202 => Some(LibraryError::InvalidHexString),
- 203 => Some(LibraryError::TargetBufferTooSmall),
- _ => None,
- }
- }
-}
-
-impl error::Error for LibraryError {}
-
-impl fmt::Display for LibraryError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_str(match *self {
- LibraryError::StringTooLong => "The supplied string is too long",
- LibraryError::InvalidSlot => "The given slot is invalid",
- LibraryError::InvalidHexString => "The supplied string is not in hexadecimal format",
- LibraryError::TargetBufferTooSmall => "The target buffer is too small",
- LibraryError::InvalidString => "You passed a string containing a null byte",
- })
- }
-}
diff --git a/nitrokey/src/lib.rs b/nitrokey/src/lib.rs
deleted file mode 100644
index 9efad91..0000000
--- a/nitrokey/src/lib.rs
+++ /dev/null
@@ -1,597 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-//! 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`][].
-//!
-//! You can only connect to one Nitrokey at a time. Use the global [`take`][] function to obtain
-//! an reference to the [`Manager`][] singleton that keeps track of the connections. Then use the
-//! [`connect`][] method to connect to any Nitrokey device. The method will return a
-//! [`DeviceWrapper`][] that abstracts over the supported Nitrokey devices. You can also use
-//! [`connect_model`][], [`connect_pro`][] or [`connect_storage`][] to connect to a specific
-//! device.
-//!
-//! To get a list of all connected Nitrokey devices, use the [`list_devices`][] function. You can
-//! then connect to one of the connected devices using the [`connect_path`][] function of the
-//! `Manager` struct.
-//!
-//! You can call [`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.
-//!
-//! # Background operations
-//!
-//! Some commands may start background operations. During such an operation, every new command
-//! will cause a [`WrongCrc`][] error. To check whether a background operation is currently
-//! running, use the [`get_operation_status`][] method.
-//!
-//! Background operations are only available on the Nitrokey Storage. Currently,
-//! [`fill_sd_card`][] is the only command that triggers a background operation.
-//!
-//! # Examples
-//!
-//! Connect to any Nitrokey and print its serial number:
-//!
-//! ```no_run
-//! use nitrokey::Device;
-//! # use nitrokey::Error;
-//!
-//! # fn try_main() -> Result<(), Error> {
-//! let mut manager = nitrokey::take()?;
-//! let device = manager.connect()?;
-//! println!("{}", device.get_serial_number()?);
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! Configure an HOTP slot:
-//!
-//! ```no_run
-//! use nitrokey::{Authenticate, ConfigureOtp, OtpMode, OtpSlotData};
-//! # use nitrokey::Error;
-//!
-//! # fn try_main() -> Result<(), Error> {
-//! let mut manager = nitrokey::take()?;
-//! let device = manager.connect()?;
-//! let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::SixDigits);
-//! match device.authenticate_admin("12345678") {
-//! Ok(mut admin) => {
-//! match admin.write_hotp_slot(slot_data, 0) {
-//! Ok(()) => println!("Successfully wrote slot."),
-//! Err(err) => eprintln!("Could not write slot: {}", err),
-//! }
-//! },
-//! Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
-//! }
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! Generate an HOTP one-time password:
-//!
-//! ```no_run
-//! use nitrokey::{Device, GenerateOtp};
-//! # use nitrokey::Error;
-//!
-//! # fn try_main() -> Result<(), Error> {
-//! let mut manager = nitrokey::take()?;
-//! let mut device = manager.connect()?;
-//! match device.get_hotp_code(1) {
-//! Ok(code) => println!("Generated HOTP code: {}", code),
-//! Err(err) => eprintln!("Could not generate HOTP code: {}", err),
-//! }
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! [`authenticate_admin`]: trait.Authenticate.html#method.authenticate_admin
-//! [`authenticate_user`]: trait.Authenticate.html#method.authenticate_user
-//! [`take`]: fn.take.html
-//! [`connect`]: struct.Manager.html#method.connect
-//! [`connect_model`]: struct.Manager.html#method.connect_model
-//! [`connect_path`]: struct.Manager.html#method.connect_path
-//! [`connect_pro`]: struct.Manager.html#method.connect_pro
-//! [`connect_storage`]: struct.Manager.html#method.connect_storage
-//! [`fill_sd_card`]: struct.Storage.html#method.fill_sd_card
-//! [`get_operation_status`]: struct.Storage.html#method.get_operation_status
-//! [`list_devices`]: fn.list_devices.html
-//! [`manager`]: trait.Device.html#method.manager
-//! [`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
-//! [`WrongCrc`]: enum.CommandError.html#variant.WrongCrc
-
-#![warn(missing_docs, rust_2018_compatibility, rust_2018_idioms, unused)]
-
-#[macro_use(lazy_static)]
-extern crate lazy_static;
-
-mod auth;
-mod config;
-mod device;
-mod error;
-mod otp;
-mod pws;
-mod util;
-
-use std::convert::TryInto as _;
-use std::fmt;
-use std::marker;
-use std::ptr::NonNull;
-use std::sync;
-
-use nitrokey_sys;
-
-pub use crate::auth::{Admin, Authenticate, User};
-pub use crate::config::Config;
-pub use crate::device::{
- Device, DeviceInfo, DeviceWrapper, Model, OperationStatus, Pro, SdCardData, Status, Storage,
- StorageProductionInfo, StorageStatus, VolumeMode, VolumeStatus,
-};
-pub use crate::error::{CommandError, CommunicationError, Error, LibraryError};
-pub use crate::otp::{ConfigureOtp, GenerateOtp, OtpMode, OtpSlotData};
-pub use crate::pws::{GetPasswordSafe, PasswordSafe, SLOT_COUNT};
-pub use crate::util::LogLevel;
-
-use crate::util::{get_cstring, get_last_result};
-
-/// The default admin PIN for all Nitrokey devices.
-pub const DEFAULT_ADMIN_PIN: &str = "12345678";
-/// The default user PIN for all Nitrokey devices.
-pub const DEFAULT_USER_PIN: &str = "123456";
-
-lazy_static! {
- static ref MANAGER: sync::Mutex<Manager> = sync::Mutex::new(Manager::new());
-}
-
-/// 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,
-}
-
-impl fmt::Display for Version {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- if self.git.is_empty() {
- write!(f, "v{}.{}", self.major, self.minor)
- } else {
- f.write_str(&self.git)
- }
- }
-}
-
-/// A manager for connections to Nitrokey devices.
-///
-/// Currently, libnitrokey only provides access to one Nitrokey device at the same time. This
-/// manager struct makes sure that `nitrokey-rs` does not try to connect to two devices at the same
-/// time.
-///
-/// To obtain a reference to an instance of this manager, use the [`take`][] function. Use one of
-/// the connect methods – [`connect`][], [`connect_model`][], [`connect_pro`][] or
-/// [`connect_storage`][] – to retrieve a [`Device`][] instance.
-///
-/// # Examples
-///
-/// Connect to a single device:
-///
-/// ```no_run
-/// use nitrokey::Device;
-/// # use nitrokey::Error;
-///
-/// # fn try_main() -> Result<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let device = manager.connect()?;
-/// println!("{}", device.get_serial_number()?);
-/// # Ok(())
-/// # }
-/// ```
-///
-/// Connect to a Pro and a Storage device:
-///
-/// ```no_run
-/// use nitrokey::{Device, Model};
-/// # use nitrokey::Error;
-///
-/// # fn try_main() -> Result<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let device = manager.connect_model(Model::Pro)?;
-/// println!("Pro: {}", device.get_serial_number()?);
-/// drop(device);
-/// let device = manager.connect_model(Model::Storage)?;
-/// println!("Storage: {}", device.get_serial_number()?);
-/// # Ok(())
-/// # }
-/// ```
-///
-/// [`connect`]: #method.connect
-/// [`connect_model`]: #method.connect_model
-/// [`connect_pro`]: #method.connect_pro
-/// [`connect_storage`]: #method.connect_storage
-/// [`manager`]: trait.Device.html#method.manager
-/// [`take`]: fn.take.html
-/// [`Device`]: trait.Device.html
-#[derive(Debug)]
-pub struct Manager {
- marker: marker::PhantomData<()>,
-}
-
-impl Manager {
- fn new() -> Self {
- Manager {
- marker: marker::PhantomData,
- }
- }
-
- /// 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
- ///
- /// - [`NotConnected`][] if no Nitrokey device is connected
- /// - [`UnsupportedModelError`][] if the Nitrokey device is not supported by this crate
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::DeviceWrapper;
- ///
- /// fn do_something(device: DeviceWrapper) {}
- ///
- /// let mut manager = nitrokey::take()?;
- /// match manager.connect() {
- /// Ok(device) => do_something(device),
- /// Err(err) => println!("Could not connect to a Nitrokey: {}", err),
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
- /// [`UnsupportedModelError`]: enum.Error.html#variant.UnsupportedModelError
- pub fn connect(&mut self) -> Result<DeviceWrapper<'_>, Error> {
- if unsafe { nitrokey_sys::NK_login_auto() } == 1 {
- device::get_connected_device(self)
- } else {
- Err(CommunicationError::NotConnected.into())
- }
- }
-
- /// Connects to a Nitrokey device of the given model.
- ///
- /// # Errors
- ///
- /// - [`NotConnected`][] if no Nitrokey device of the given model is connected
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::DeviceWrapper;
- /// use nitrokey::Model;
- ///
- /// fn do_something(device: DeviceWrapper) {}
- ///
- /// match nitrokey::take()?.connect_model(Model::Pro) {
- /// Ok(device) => do_something(device),
- /// Err(err) => println!("Could not connect to a Nitrokey Pro: {}", err),
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
- pub fn connect_model(&mut self, model: Model) -> Result<DeviceWrapper<'_>, Error> {
- if device::connect_enum(model) {
- Ok(device::create_device_wrapper(self, model))
- } else {
- Err(CommunicationError::NotConnected.into())
- }
- }
-
- /// Connects to a Nitrokey device at the given USB path.
- ///
- /// To get a list of all connected Nitrokey devices, use the [`list_devices`][] function. The
- /// [`DeviceInfo`][] structs returned by that function contain the USB path in the `path`
- /// field.
- ///
- /// # Errors
- ///
- /// - [`InvalidString`][] if the USB path contains a null byte
- /// - [`NotConnected`][] if no Nitrokey device can be found at the given USB path
- /// - [`UnsupportedModelError`][] if the model of the Nitrokey device at the given USB path is
- /// not supported by this crate
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::DeviceWrapper;
- ///
- /// fn use_device(device: DeviceWrapper) {}
- ///
- /// let mut manager = nitrokey::take()?;
- /// let devices = nitrokey::list_devices()?;
- /// for device in devices {
- /// let device = manager.connect_path(device.path)?;
- /// use_device(device);
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`list_devices`]: fn.list_devices.html
- /// [`DeviceInfo`]: struct.DeviceInfo.html
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
- /// [`UnsupportedModelError`]: enum.Error.html#variant.UnsupportedModelError
- pub fn connect_path<S: Into<Vec<u8>>>(&mut self, path: S) -> Result<DeviceWrapper<'_>, Error> {
- let path = get_cstring(path)?;
- if unsafe { nitrokey_sys::NK_connect_with_path(path.as_ptr()) } == 1 {
- device::get_connected_device(self)
- } else {
- Err(CommunicationError::NotConnected.into())
- }
- }
-
- /// Connects to a Nitrokey Pro.
- ///
- /// # Errors
- ///
- /// - [`NotConnected`][] if no Nitrokey device of the given model is connected
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::Pro;
- ///
- /// fn use_pro(device: Pro) {}
- ///
- /// match nitrokey::take()?.connect_pro() {
- /// Ok(device) => use_pro(device),
- /// Err(err) => println!("Could not connect to the Nitrokey Pro: {}", err),
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
- pub fn connect_pro(&mut self) -> Result<Pro<'_>, Error> {
- if device::connect_enum(device::Model::Pro) {
- Ok(device::Pro::new(self))
- } else {
- Err(CommunicationError::NotConnected.into())
- }
- }
-
- /// Connects to a Nitrokey Storage.
- ///
- /// # Errors
- ///
- /// - [`NotConnected`][] if no Nitrokey device of the given model is connected
- ///
- /// # Example
- ///
- /// ```
- /// use nitrokey::Storage;
- ///
- /// fn use_storage(device: Storage) {}
- ///
- /// match nitrokey::take()?.connect_storage() {
- /// Ok(device) => use_storage(device),
- /// Err(err) => println!("Could not connect to the Nitrokey Storage: {}", err),
- /// }
- /// # Ok::<(), nitrokey::Error>(())
- /// ```
- ///
- /// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
- pub fn connect_storage(&mut self) -> Result<Storage<'_>, Error> {
- if device::connect_enum(Model::Storage) {
- Ok(Storage::new(self))
- } else {
- Err(CommunicationError::NotConnected.into())
- }
- }
-}
-
-/// Take an instance of the connection manager, blocking until an instance is available.
-///
-/// There may only be one [`Manager`][] instance at the same time. If there already is an
-/// instance, this method blocks. If you want a non-blocking version, use [`take`][].
-///
-/// # Errors
-///
-/// - [`PoisonError`][] if the lock is poisoned
-///
-/// [`take`]: fn.take.html
-/// [`PoisonError`]: struct.Error.html#variant.PoisonError
-/// [`Manager`]: struct.Manager.html
-pub fn take_blocking() -> Result<sync::MutexGuard<'static, Manager>, Error> {
- MANAGER.lock().map_err(Into::into)
-}
-
-/// Try to take an instance of the connection manager.
-///
-/// There may only be one [`Manager`][] instance at the same time. If there already is an
-/// instance, a [`ConcurrentAccessError`][] is returned. If you want a blocking version, use
-/// [`take_blocking`][]. If you want to access the manager instance even if the cache is poisoned,
-/// use [`force_take`][].
-///
-/// # Errors
-///
-/// - [`ConcurrentAccessError`][] if the token for the `Manager` instance cannot be locked
-/// - [`PoisonError`][] if the lock is poisoned
-///
-/// [`take_blocking`]: fn.take_blocking.html
-/// [`force_take`]: fn.force_take.html
-/// [`ConcurrentAccessError`]: struct.Error.html#variant.ConcurrentAccessError
-/// [`PoisonError`]: struct.Error.html#variant.PoisonError
-/// [`Manager`]: struct.Manager.html
-pub fn take() -> Result<sync::MutexGuard<'static, Manager>, Error> {
- MANAGER.try_lock().map_err(Into::into)
-}
-
-/// Try to take an instance of the connection manager, ignoring a poisoned cache.
-///
-/// There may only be one [`Manager`][] instance at the same time. If there already is an
-/// instance, a [`ConcurrentAccessError`][] is returned. If you want a blocking version, use
-/// [`take_blocking`][].
-///
-/// If a thread has previously panicked while accessing the manager instance, the cache is
-/// poisoned. The default implementation, [`take`][], returns a [`PoisonError`][] on subsequent
-/// calls. This implementation ignores the poisoned cache and returns the manager instance.
-///
-/// # Errors
-///
-/// - [`ConcurrentAccessError`][] if the token for the `Manager` instance cannot be locked
-///
-/// [`take`]: fn.take.html
-/// [`take_blocking`]: fn.take_blocking.html
-/// [`ConcurrentAccessError`]: struct.Error.html#variant.ConcurrentAccessError
-/// [`Manager`]: struct.Manager.html
-pub fn force_take() -> Result<sync::MutexGuard<'static, Manager>, Error> {
- match take() {
- Ok(guard) => Ok(guard),
- Err(err) => match err {
- Error::PoisonError(err) => Ok(err.into_inner()),
- err => Err(err),
- },
- }
-}
-
-/// List all connected Nitrokey devices.
-///
-/// This functions returns a vector with [`DeviceInfo`][] structs that contain information about
-/// all connected Nitrokey devices. It will even list unsupported models, although you cannot
-/// connect to them. To connect to a supported model, call the [`connect_path`][] function.
-///
-/// # Errors
-///
-/// - [`NotConnected`][] if a Nitrokey device has been disconnected during enumeration
-/// - [`Utf8Error`][] if the USB path or the serial number returned by libnitrokey are invalid
-/// UTF-8 strings
-///
-/// # Example
-///
-/// ```
-/// let devices = nitrokey::list_devices()?;
-/// if devices.is_empty() {
-/// println!("No connected Nitrokey devices found.");
-/// } else {
-/// println!("model\tpath\tserial number");
-/// for device in devices {
-/// match device.model {
-/// Some(model) => print!("{}", model),
-/// None => print!("unsupported"),
-/// }
-/// print!("\t{}\t", device.path);
-/// match device.serial_number {
-/// Some(serial_number) => println!("{}", serial_number),
-/// None => println!("unknown"),
-/// }
-/// }
-/// }
-/// # Ok::<(), nitrokey::Error>(())
-/// ```
-///
-/// [`connect_path`]: struct.Manager.html#fn.connect_path
-/// [`DeviceInfo`]: struct.DeviceInfo.html
-/// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
-/// [`Utf8Error`]: enum.Error.html#variant.Utf8Error
-pub fn list_devices() -> Result<Vec<DeviceInfo>, Error> {
- let ptr = NonNull::new(unsafe { nitrokey_sys::NK_list_devices() });
- match ptr {
- Some(mut ptr) => {
- let mut vec: Vec<DeviceInfo> = Vec::new();
- push_device_info(&mut vec, unsafe { ptr.as_ref() })?;
- unsafe {
- nitrokey_sys::NK_free_device_info(ptr.as_mut());
- }
- Ok(vec)
- }
- None => get_last_result().map(|_| Vec::new()),
- }
-}
-
-fn push_device_info(
- vec: &mut Vec<DeviceInfo>,
- info: &nitrokey_sys::NK_device_info,
-) -> Result<(), Error> {
- vec.push(info.try_into()?);
- if let Some(ptr) = NonNull::new(info.next) {
- push_device_info(vec, unsafe { ptr.as_ref() })?;
- }
- Ok(())
-}
-
-/// 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.
-///
-/// # Errors
-///
-/// - [`Utf8Error`][] if libnitrokey returned an invalid UTF-8 string
-///
-/// # Example
-///
-/// ```
-/// let version = nitrokey::get_library_version()?;
-/// println!("Using libnitrokey {}", version.git);
-/// # Ok::<(), nitrokey::Error>(())
-/// ```
-///
-/// [`Utf8Error`]: enum.Error.html#variant.Utf8Error
-pub fn get_library_version() -> Result<Version, Error> {
- // 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() };
- Ok(Version { git, major, minor })
-}
diff --git a/nitrokey/src/otp.rs b/nitrokey/src/otp.rs
deleted file mode 100644
index 4667aff..0000000
--- a/nitrokey/src/otp.rs
+++ /dev/null
@@ -1,423 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use std::ffi::CString;
-
-use nitrokey_sys;
-
-use crate::error::Error;
-use crate::util::{get_command_result, get_cstring, result_from_string};
-
-/// 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::SixDigits);
- /// match device.authenticate_admin("12345678") {
- /// Ok(mut admin) => {
- /// match admin.write_hotp_slot(slot_data, 0) {
- /// Ok(()) => println!("Successfully wrote slot."),
- /// Err(err) => eprintln!("Could not write slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`NoName`]: enum.CommandError.html#variant.NoName
- fn write_hotp_slot(&mut self, data: OtpSlotData, counter: u64) -> Result<(), Error>;
-
- /// 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::EightDigits);
- /// match device.authenticate_admin("12345678") {
- /// Ok(mut admin) => {
- /// match admin.write_totp_slot(slot_data, 30) {
- /// Ok(()) => println!("Successfully wrote slot."),
- /// Err(err) => eprintln!("Could not write slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- /// [`NoName`]: enum.CommandError.html#variant.NoName
- fn write_totp_slot(&mut self, data: OtpSlotData, time_window: u16) -> Result<(), Error>;
-
- /// Erases an HOTP slot.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, ConfigureOtp};
- /// # use nitrokey::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// match device.authenticate_admin("12345678") {
- /// Ok(mut admin) => {
- /// match admin.erase_hotp_slot(1) {
- /// Ok(()) => println!("Successfully erased slot."),
- /// Err(err) => eprintln!("Could not erase slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- fn erase_hotp_slot(&mut self, slot: u8) -> Result<(), Error>;
-
- /// Erases a TOTP slot.
- ///
- /// # Errors
- ///
- /// - [`InvalidSlot`][] if there is no slot with the given number
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::{Authenticate, ConfigureOtp};
- /// # use nitrokey::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// match device.authenticate_admin("12345678") {
- /// Ok(mut admin) => {
- /// match admin.erase_totp_slot(1) {
- /// Ok(()) => println!("Successfully erased slot."),
- /// Err(err) => eprintln!("Could not erase slot: {}", err),
- /// }
- /// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- fn erase_totp_slot(&mut self, slot: u8) -> Result<(), Error>;
-}
-
-/// 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH);
- /// match time {
- /// Ok(time) => device.set_time(time.as_secs(), false)?,
- /// Err(_) => eprintln!("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(&mut self, time: u64, force: bool) -> Result<(), Error> {
- 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, Error, GenerateOtp};
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// match device.get_hotp_slot_name(1) {
- /// Ok(name) => println!("HOTP slot 1: {}", name),
- /// Err(Error::CommandError(CommandError::SlotNotProgrammed)) => eprintln!("HOTP slot 1 not programmed"),
- /// Err(err) => eprintln!("Could not get slot name: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_hotp_slot_name(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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, Error, GenerateOtp};
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let device = manager.connect()?;
- /// match device.get_totp_slot_name(1) {
- /// Ok(name) => println!("TOTP slot 1: {}", name),
- /// Err(Error::CommandError(CommandError::SlotNotProgrammed)) => eprintln!("TOTP slot 1 not programmed"),
- /// Err(err) => eprintln!("Could not get slot name: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_totp_slot_name(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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.LibraryError.html#variant.InvalidSlot
- /// [`NotAuthorized`]: enum.CommandError.html#variant.NotAuthorized
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_hotp_code(&mut self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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(_) => eprintln!("Timestamps before 1970-01-01 are not supported!"),
- /// }
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`set_time`]: #method.set_time
- /// [`get_config`]: trait.Device.html#method.get_config
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- /// [`NotAuthorized`]: enum.CommandError.html#variant.NotAuthorized
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- fn get_totp_code(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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, Error> {
- 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 3398deb..0000000
--- a/nitrokey/src/pws.rs
+++ /dev/null
@@ -1,391 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use libc;
-use nitrokey_sys;
-
-use crate::device::{Device, DeviceWrapper, Pro, Storage};
-use crate::error::{CommandError, Error};
-use crate::util::{get_command_result, get_cstring, get_last_error, result_from_string};
-
-/// 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::Error;
-///
-/// fn use_password_safe(pws: &PasswordSafe) -> Result<(), Error> {
-/// 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<(), Error> {
-/// let mut manager = nitrokey::take()?;
-/// let mut device = manager.connect()?;
-/// let pws = device.get_password_safe("123456")?;
-/// use_password_safe(&pws);
-/// drop(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
-#[derive(Debug)]
-pub struct PasswordSafe<'a, 'b> {
- _device: &'a dyn Device<'b>,
-}
-
-/// 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<'a> {
- /// 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::Error;
- ///
- /// fn use_password_safe(pws: &PasswordSafe) {}
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// match device.get_password_safe("123456") {
- /// Ok(pws) => {
- /// use_password_safe(&pws);
- /// },
- /// Err(err) => eprintln!("Could not open the password safe: {}", err),
- /// };
- /// device.lock()?;
- /// # 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.LibraryError.html#variant.InvalidString
- /// [`Unknown`]: enum.CommandError.html#variant.Unknown
- /// [`WrongPassword`]: enum.CommandError.html#variant.WrongPassword
- fn get_password_safe(&mut self, user_pin: &str) -> Result<PasswordSafe<'_, 'a>, Error>;
-}
-
-fn get_password_safe<'a, 'b>(
- device: &'a dyn Device<'b>,
- user_pin: &str,
-) -> Result<PasswordSafe<'a, 'b>, Error> {
- let user_pin_string = get_cstring(user_pin)?;
- get_command_result(unsafe { nitrokey_sys::NK_enable_password_safe(user_pin_string.as_ptr()) })
- .map(|_| PasswordSafe { _device: device })
-}
-
-fn get_pws_result(s: String) -> Result<String, Error> {
- if s.is_empty() {
- Err(CommandError::SlotNotProgrammed.into())
- } else {
- Ok(s)
- }
-}
-
-impl<'a, 'b> PasswordSafe<'a, 'b> {
- /// 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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], Error> {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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) => eprintln!("Could not open the password safe: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- pub fn get_slot_name(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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.LibraryError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- pub fn get_slot_login(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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.LibraryError.html#variant.InvalidSlot
- /// [`SlotNotProgrammed`]: enum.CommandError.html#variant.SlotNotProgrammed
- pub fn get_slot_password(&self, slot: u8) -> Result<String, Error> {
- result_from_string(unsafe { 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.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.LibraryError.html#variant.InvalidSlot
- /// [`InvalidString`]: enum.LibraryError.html#variant.InvalidString
- pub fn write_slot(
- &mut self,
- slot: u8,
- name: &str,
- login: &str,
- password: &str,
- ) -> Result<(), Error> {
- let name_string = get_cstring(name)?;
- let login_string = get_cstring(login)?;
- let password_string = get_cstring(password)?;
- get_command_result(unsafe {
- 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::Error;
- ///
- /// # fn try_main() -> Result<(), Error> {
- /// let mut manager = nitrokey::take()?;
- /// let mut device = manager.connect()?;
- /// let mut pws = device.get_password_safe("123456")?;
- /// match pws.erase_slot(0) {
- /// Ok(()) => println!("Erased slot 0."),
- /// Err(err) => eprintln!("Could not erase slot 0: {}", err),
- /// };
- /// # Ok(())
- /// # }
- /// ```
- ///
- /// [`InvalidSlot`]: enum.LibraryError.html#variant.InvalidSlot
- pub fn erase_slot(&mut self, slot: u8) -> Result<(), Error> {
- get_command_result(unsafe { nitrokey_sys::NK_erase_password_safe_slot(slot) })
- }
-}
-
-impl<'a, 'b> Drop for PasswordSafe<'a, 'b> {
- 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<'a> GetPasswordSafe<'a> for Pro<'a> {
- fn get_password_safe(&mut self, user_pin: &str) -> Result<PasswordSafe<'_, 'a>, Error> {
- get_password_safe(self, user_pin)
- }
-}
-
-impl<'a> GetPasswordSafe<'a> for Storage<'a> {
- fn get_password_safe(&mut self, user_pin: &str) -> Result<PasswordSafe<'_, 'a>, Error> {
- get_password_safe(self, user_pin)
- }
-}
-
-impl<'a> GetPasswordSafe<'a> for DeviceWrapper<'a> {
- fn get_password_safe(&mut self, user_pin: &str) -> Result<PasswordSafe<'_, 'a>, Error> {
- get_password_safe(self, user_pin)
- }
-}
diff --git a/nitrokey/src/util.rs b/nitrokey/src/util.rs
deleted file mode 100644
index 5a56c55..0000000
--- a/nitrokey/src/util.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-use std::ffi::{CStr, CString};
-use std::os::raw::{c_char, c_int};
-
-use libc::{c_void, free};
-use rand_core::{OsRng, RngCore};
-
-use crate::error::{Error, LibraryError};
-
-/// 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) -> Result<String, Error> {
- unsafe { CStr::from_ptr(ptr) }
- .to_str()
- .map(String::from)
- .map_err(Error::from)
-}
-
-pub fn result_from_string(ptr: *const c_char) -> Result<String, Error> {
- if ptr.is_null() {
- return Err(Error::UnexpectedError);
- }
- let s = owned_str_from_ptr(ptr)?;
- unsafe { 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 result_or_error<T>(value: T) -> Result<T, Error> {
- get_last_result().and(Ok(value))
-}
-
-pub fn get_command_result(value: c_int) -> Result<(), Error> {
- if value == 0 {
- Ok(())
- } else {
- Err(Error::from(value))
- }
-}
-
-pub fn get_last_result() -> Result<(), Error> {
- get_command_result(unsafe { nitrokey_sys::NK_get_last_command_status() }.into())
-}
-
-pub fn get_last_error() -> Error {
- match get_last_result() {
- Ok(()) => Error::UnexpectedError,
- Err(err) => err,
- }
-}
-
-pub fn generate_password(length: usize) -> Result<Vec<u8>, Error> {
- let mut data = vec![0u8; length];
- OsRng.fill_bytes(&mut data[..]);
- Ok(data)
-}
-
-pub fn get_cstring<T: Into<Vec<u8>>>(s: T) -> Result<CString, Error> {
- CString::new(s).or_else(|_| Err(LibraryError::InvalidString.into()))
-}
-
-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 a88c956..0000000
--- a/nitrokey/tests/device.rs
+++ /dev/null
@@ -1,711 +0,0 @@
-// Copyright (C) 2018-2020 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-mod util;
-
-use std::ffi::CStr;
-use std::process::Command;
-use std::{thread, time};
-
-use nitrokey::{
- Authenticate, CommandError, CommunicationError, Config, ConfigureOtp, Device, DeviceInfo,
- Error, GenerateOtp, GetPasswordSafe, LibraryError, OperationStatus, OtpMode, OtpSlotData,
- Storage, VolumeMode, DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN,
-};
-use nitrokey_test::test as test_device;
-
-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 list_no_devices() {
- let devices = nitrokey::list_devices();
- assert_ok!(Vec::<DeviceInfo>::new(), devices);
-}
-
-#[test_device]
-fn list_devices(_device: DeviceWrapper) {
- let devices = unwrap_ok!(nitrokey::list_devices());
- for device in devices {
- assert!(!device.path.is_empty());
- if let Some(model) = device.model {
- match model {
- nitrokey::Model::Pro => {
- assert!(device.serial_number.is_some());
- let serial_number = device.serial_number.unwrap();
- assert!(!serial_number.is_empty());
- assert_valid_serial_number(&serial_number);
- }
- nitrokey::Model::Storage => {
- assert_eq!(None, device.serial_number);
- }
- }
- }
- }
-}
-
-#[test_device]
-fn connect_no_device() {
- let mut manager = unwrap_ok!(nitrokey::take());
-
- assert_cmu_err!(CommunicationError::NotConnected, manager.connect());
- assert_cmu_err!(
- CommunicationError::NotConnected,
- manager.connect_model(nitrokey::Model::Pro)
- );
- assert_cmu_err!(
- CommunicationError::NotConnected,
- manager.connect_model(nitrokey::Model::Storage)
- );
- assert_cmu_err!(CommunicationError::NotConnected, manager.connect_pro());
- assert_cmu_err!(CommunicationError::NotConnected, manager.connect_storage());
-}
-
-#[test_device]
-fn connect_pro(device: Pro) {
- assert_eq!(device.get_model(), nitrokey::Model::Pro);
-
- let manager = device.into_manager();
- assert_any_ok!(manager.connect());
- assert_any_ok!(manager.connect_model(nitrokey::Model::Pro));
- assert_any_ok!(manager.connect_pro());
-}
-
-#[test_device]
-fn connect_storage(device: Storage) {
- assert_eq!(device.get_model(), nitrokey::Model::Storage);
-
- let manager = device.into_manager();
- assert_any_ok!(manager.connect());
- assert_any_ok!(manager.connect_model(nitrokey::Model::Storage));
- assert_any_ok!(manager.connect_storage());
-}
-
-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 connect_path_no_device() {
- let mut manager = unwrap_ok!(nitrokey::take());
-
- assert_cmu_err!(CommunicationError::NotConnected, manager.connect_path(""));
- assert_cmu_err!(
- CommunicationError::NotConnected,
- manager.connect_path("foobar")
- );
- // TODO: add realistic path
-}
-
-#[test_device]
-fn connect_path(device: DeviceWrapper) {
- let manager = device.into_manager();
-
- assert_cmu_err!(CommunicationError::NotConnected, manager.connect_path(""));
- assert_cmu_err!(
- CommunicationError::NotConnected,
- manager.connect_path("foobar")
- );
- // TODO: add realistic path
-
- let devices = unwrap_ok!(nitrokey::list_devices());
- assert!(!devices.is_empty());
- for device in devices {
- let connected_device = unwrap_ok!(manager.connect_path(device.path));
- assert_eq!(device.model, Some(connected_device.get_model()));
- match device.model.unwrap() {
- nitrokey::Model::Pro => {
- assert!(device.serial_number.is_some());
- assert_ok!(
- device.serial_number.unwrap(),
- connected_device.get_serial_number()
- );
- }
- nitrokey::Model::Storage => {
- assert_eq!(None, device.serial_number);
- }
- }
- }
-}
-
-#[test_device]
-fn disconnect(device: DeviceWrapper) {
- drop(device);
- assert_empty_serial_number();
-}
-
-#[test_device]
-fn get_status(device: DeviceWrapper) {
- let status = unwrap_ok!(device.get_status());
- assert_ok!(status.firmware_version, device.get_firmware_version());
- let serial_number = format!("{:08x}", status.serial_number);
- assert_ok!(serial_number, device.get_serial_number());
- assert_ok!(status.config, device.get_config());
-}
-
-fn assert_valid_serial_number(serial_number: &str) {
- assert!(serial_number.is_ascii());
- assert!(serial_number.chars().all(|c| c.is_ascii_hexdigit()));
-}
-
-#[test_device]
-fn get_serial_number(device: DeviceWrapper) {
- let serial_number = unwrap_ok!(device.get_serial_number());
- assert_valid_serial_number(&serial_number);
-}
-
-#[test_device]
-fn get_firmware_version(device: Pro) {
- let version = unwrap_ok!(device.get_firmware_version());
- assert_eq!(0, version.major);
- assert!(version.minor > 0);
-}
-
-fn admin_retry<'a, T>(device: T, suffix: &str, count: u8) -> T
-where
- T: Authenticate<'a> + Device<'a> + 'a,
-{
- let result = device.authenticate_admin(&(DEFAULT_ADMIN_PIN.to_owned() + suffix));
- let device = match result {
- Ok(admin) => admin.device(),
- Err((device, _)) => device,
- };
- assert_ok!(count, device.get_admin_retry_count());
- return device;
-}
-
-fn user_retry<'a, T>(device: T, suffix: &str, count: u8) -> T
-where
- T: Authenticate<'a> + Device<'a> + 'a,
-{
- let result = device.authenticate_user(&(DEFAULT_USER_PIN.to_owned() + suffix));
- let device = match result {
- Ok(admin) => admin.device(),
- Err((device, _)) => device,
- };
- assert_ok!(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 mut admin = unwrap_ok!(device.authenticate_admin(DEFAULT_ADMIN_PIN));
-
- let config = Config::new(None, None, None, true);
- assert_ok!((), admin.write_config(config));
- assert_ok!(config, admin.get_config());
-
- let config = Config::new(None, Some(9), None, true);
- assert_lib_err!(LibraryError::InvalidSlot, admin.write_config(config));
-
- let config = Config::new(Some(1), None, Some(0), false);
- assert_ok!((), admin.write_config(config));
- assert_ok!(config, admin.get_config());
-
- let config = Config::new(None, None, None, false);
- assert_ok!((), admin.write_config(config));
- assert_ok!(config, admin.get_config());
-}
-
-#[test_device]
-fn change_user_pin(device: DeviceWrapper) {
- let device = device.authenticate_user(DEFAULT_USER_PIN).unwrap().device();
- let device = device.authenticate_user(USER_NEW_PASSWORD).unwrap_err().0;
-
- let mut device = device;
- assert_ok!(
- (),
- device.change_user_pin(DEFAULT_USER_PIN, USER_NEW_PASSWORD)
- );
-
- let device = device.authenticate_user(DEFAULT_USER_PIN).unwrap_err().0;
- let device = device
- .authenticate_user(USER_NEW_PASSWORD)
- .unwrap()
- .device();
-
- let mut device = device;
- let result = device.change_user_pin(DEFAULT_USER_PIN, DEFAULT_USER_PIN);
- assert_cmd_err!(CommandError::WrongPassword, result);
-
- assert_ok!(
- (),
- device.change_user_pin(USER_NEW_PASSWORD, DEFAULT_USER_PIN)
- );
-
- let device = device.authenticate_user(DEFAULT_USER_PIN).unwrap().device();
- assert!(device.authenticate_user(USER_NEW_PASSWORD).is_err());
-}
-
-#[test_device]
-fn change_admin_pin(device: DeviceWrapper) {
- let device = device
- .authenticate_admin(DEFAULT_ADMIN_PIN)
- .unwrap()
- .device();
- let mut device = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err().0;
-
- assert_ok!(
- (),
- device.change_admin_pin(DEFAULT_ADMIN_PIN, ADMIN_NEW_PASSWORD)
- );
-
- let device = device.authenticate_admin(DEFAULT_ADMIN_PIN).unwrap_err().0;
- let mut device = device
- .authenticate_admin(ADMIN_NEW_PASSWORD)
- .unwrap()
- .device();
-
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.change_admin_pin(DEFAULT_ADMIN_PIN, DEFAULT_ADMIN_PIN)
- );
-
- assert_ok!(
- (),
- device.change_admin_pin(ADMIN_NEW_PASSWORD, DEFAULT_ADMIN_PIN)
- );
-
- let device = device
- .authenticate_admin(DEFAULT_ADMIN_PIN)
- .unwrap()
- .device();
- device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err();
-}
-
-fn require_failed_user_login<'a, D>(device: D, password: &str, error: CommandError) -> D
-where
- D: Device<'a> + Authenticate<'a> + 'a,
- nitrokey::User<'a, D>: std::fmt::Debug,
-{
- let result = device.authenticate_user(password);
- assert!(result.is_err());
- let err = result.unwrap_err();
- match err.1 {
- Error::CommandError(err) => assert_eq!(error, err),
- _ => assert!(false),
- };
- err.0
-}
-
-#[test_device]
-fn unlock_user_pin(device: DeviceWrapper) {
- let mut device = device.authenticate_user(DEFAULT_USER_PIN).unwrap().device();
- assert_ok!(
- (),
- device.unlock_user_pin(DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN)
- );
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.unlock_user_pin(DEFAULT_USER_PIN, DEFAULT_USER_PIN)
- );
-
- // block user PIN
- let wrong_password = DEFAULT_USER_PIN.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 mut device =
- require_failed_user_login(device, DEFAULT_USER_PIN, CommandError::WrongPassword);
-
- // unblock with current PIN
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.unlock_user_pin(DEFAULT_USER_PIN, DEFAULT_USER_PIN)
- );
- assert_ok!(
- (),
- device.unlock_user_pin(DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN)
- );
- let device = device.authenticate_user(DEFAULT_USER_PIN).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 mut device =
- require_failed_user_login(device, DEFAULT_USER_PIN, CommandError::WrongPassword);
-
- // unblock with new PIN
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.unlock_user_pin(DEFAULT_USER_PIN, DEFAULT_USER_PIN)
- );
- assert_ok!(
- (),
- device.unlock_user_pin(DEFAULT_ADMIN_PIN, USER_NEW_PASSWORD)
- );
-
- // reset user PIN
- assert_ok!(
- (),
- device.change_user_pin(USER_NEW_PASSWORD, DEFAULT_USER_PIN)
- );
-}
-
-fn assert_utf8_err_or_ne(left: &str, right: Result<String, Error>) {
- match right {
- Ok(s) => assert_ne!(left.to_string(), s),
- Err(Error::Utf8Error(_)) => {}
- Err(err) => panic!("Expected Utf8Error, got {}!", err),
- }
-}
-
-#[test_device]
-fn factory_reset(device: DeviceWrapper) {
- let mut admin = unwrap_ok!(device.authenticate_admin(DEFAULT_ADMIN_PIN));
- let otp_data = OtpSlotData::new(1, "test", "0123468790", OtpMode::SixDigits);
- assert_ok!((), admin.write_totp_slot(otp_data, 30));
-
- let mut device = admin.device();
- let mut pws = unwrap_ok!(device.get_password_safe(DEFAULT_USER_PIN));
- assert_ok!((), pws.write_slot(0, "test", "testlogin", "testpw"));
- drop(pws);
-
- assert_ok!(
- (),
- device.change_user_pin(DEFAULT_USER_PIN, USER_NEW_PASSWORD)
- );
- assert_ok!(
- (),
- device.change_admin_pin(DEFAULT_ADMIN_PIN, ADMIN_NEW_PASSWORD)
- );
-
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.factory_reset(USER_NEW_PASSWORD)
- );
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.factory_reset(DEFAULT_ADMIN_PIN)
- );
- assert_ok!((), device.factory_reset(ADMIN_NEW_PASSWORD));
-
- let device = device
- .authenticate_admin(DEFAULT_ADMIN_PIN)
- .unwrap()
- .device();
-
- let user = unwrap_ok!(device.authenticate_user(DEFAULT_USER_PIN));
- assert_cmd_err!(CommandError::SlotNotProgrammed, user.get_totp_slot_name(1));
-
- let mut device = user.device();
- let pws = unwrap_ok!(device.get_password_safe(DEFAULT_USER_PIN));
- assert_utf8_err_or_ne("test", pws.get_slot_name(0));
- assert_utf8_err_or_ne("testlogin", pws.get_slot_login(0));
- assert_utf8_err_or_ne("testpw", pws.get_slot_password(0));
- drop(pws);
-
- assert_ok!(3, device.get_user_retry_count());
- assert_ok!((), device.build_aes_key(DEFAULT_ADMIN_PIN));
-}
-
-#[test_device]
-fn build_aes_key(device: DeviceWrapper) {
- let mut device = device;
- let mut pws = unwrap_ok!(device.get_password_safe(DEFAULT_USER_PIN));
- assert_ok!((), pws.write_slot(0, "test", "testlogin", "testpw"));
- drop(pws);
-
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.build_aes_key(DEFAULT_USER_PIN)
- );
- assert_ok!((), device.build_aes_key(DEFAULT_ADMIN_PIN));
-
- let mut device = device
- .authenticate_admin(DEFAULT_ADMIN_PIN)
- .unwrap()
- .device();
-
- let pws = unwrap_ok!(device.get_password_safe(DEFAULT_USER_PIN));
- assert_utf8_err_or_ne("test", pws.get_slot_name(0));
- assert_utf8_err_or_ne("testlogin", pws.get_slot_login(0));
- assert_utf8_err_or_ne("testpw", pws.get_slot_password(0));
-}
-
-#[test_device]
-fn change_update_pin(device: Storage) {
- let mut device = device;
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.change_update_pin(UPDATE_NEW_PIN, UPDATE_PIN)
- );
- assert_ok!((), device.change_update_pin(UPDATE_PIN, UPDATE_NEW_PIN));
- assert_ok!((), device.change_update_pin(UPDATE_NEW_PIN, UPDATE_PIN));
-}
-
-#[test_device]
-fn encrypted_volume(device: Storage) {
- let mut device = device;
- assert_ok!((), device.lock());
-
- assert_eq!(1, count_nitrokey_block_devices());
- assert_ok!((), device.disable_encrypted_volume());
- assert_eq!(1, count_nitrokey_block_devices());
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.enable_encrypted_volume("123")
- );
- assert_eq!(1, count_nitrokey_block_devices());
- assert_ok!((), device.enable_encrypted_volume(DEFAULT_USER_PIN));
- assert_eq!(2, count_nitrokey_block_devices());
- assert_ok!((), device.disable_encrypted_volume());
- assert_eq!(1, count_nitrokey_block_devices());
-}
-
-#[test_device]
-fn hidden_volume(device: Storage) {
- let mut device = device;
- assert_ok!((), device.lock());
-
- assert_eq!(1, count_nitrokey_block_devices());
- assert_ok!((), device.disable_hidden_volume());
- assert_eq!(1, count_nitrokey_block_devices());
-
- assert_ok!((), device.enable_encrypted_volume(DEFAULT_USER_PIN));
- assert_eq!(2, count_nitrokey_block_devices());
-
- // TODO: why this error code?
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.create_hidden_volume(5, 0, 100, "hiddenpw")
- );
- assert_ok!((), device.create_hidden_volume(0, 20, 21, "hidden-pw"));
- assert_ok!((), device.create_hidden_volume(0, 20, 21, "hiddenpassword"));
- assert_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_cmd_err!(
- CommandError::WrongPassword,
- device.enable_hidden_volume("blubb")
- );
- assert_ok!((), device.enable_hidden_volume("hiddenpassword"));
- assert_eq!(2, count_nitrokey_block_devices());
- assert_ok!((), device.enable_hidden_volume("otherpw"));
- assert_eq!(2, count_nitrokey_block_devices());
-
- assert_ok!((), device.disable_hidden_volume());
- assert_eq!(1, count_nitrokey_block_devices());
-}
-
-#[test_device]
-fn lock(device: Storage) {
- let mut device = device;
- assert_ok!((), device.enable_encrypted_volume(DEFAULT_USER_PIN));
- assert_ok!((), device.lock());
- assert_eq!(1, count_nitrokey_block_devices());
-}
-
-#[test_device]
-fn set_encrypted_volume_mode(device: Storage) {
- // This test case does not check the device status as the command only works with firmware
- // version 0.49. For later versions, it does not do anything and always returns Ok(()).
- let mut device = device;
-
- assert_ok!(
- (),
- device.set_encrypted_volume_mode(DEFAULT_ADMIN_PIN, VolumeMode::ReadOnly)
- );
-
- // TODO: re-enable once the password is checked in the firmware
- // assert_cmd_err!(
- // CommandError::WrongPassword,
- // device.set_encrypted_volume_mode(DEFAULT_USER_PIN, VolumeMode::ReadOnly)
- // );
-
- assert_ok!(
- (),
- device.set_encrypted_volume_mode(DEFAULT_ADMIN_PIN, VolumeMode::ReadOnly)
- );
- assert_ok!(
- (),
- device.set_encrypted_volume_mode(DEFAULT_ADMIN_PIN, VolumeMode::ReadWrite)
- );
- assert_ok!(
- (),
- device.set_encrypted_volume_mode(DEFAULT_ADMIN_PIN, VolumeMode::ReadOnly)
- );
-}
-
-#[test_device]
-fn set_unencrypted_volume_mode(device: Storage) {
- fn assert_mode(device: &Storage, mode: VolumeMode) {
- let status = unwrap_ok!(device.get_storage_status());
- assert_eq!(
- status.unencrypted_volume.read_only,
- mode == VolumeMode::ReadOnly
- );
- }
-
- fn assert_success(device: &mut Storage, mode: VolumeMode) {
- assert_ok!(
- (),
- device.set_unencrypted_volume_mode(DEFAULT_ADMIN_PIN, mode)
- );
- assert_mode(&device, mode);
- }
-
- let mut device = device;
- assert_success(&mut device, VolumeMode::ReadOnly);
-
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.set_unencrypted_volume_mode(DEFAULT_USER_PIN, VolumeMode::ReadOnly)
- );
- assert_mode(&device, VolumeMode::ReadOnly);
-
- assert_success(&mut device, VolumeMode::ReadWrite);
- assert_success(&mut device, VolumeMode::ReadWrite);
- assert_success(&mut device, VolumeMode::ReadOnly);
-}
-
-#[test_device]
-fn get_storage_status(device: Storage) {
- let status = unwrap_ok!(device.get_storage_status());
- assert!(status.serial_number_sd_card > 0);
- assert!(status.serial_number_smart_card > 0);
-}
-
-#[test_device]
-fn get_production_info(device: Storage) {
- let info = unwrap_ok!(device.get_production_info());
- 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 = unwrap_ok!(device.get_storage_status());
- assert_eq!(status.firmware_version, info.firmware_version);
- assert_eq!(status.serial_number_sd_card, info.sd_card.serial_number);
-}
-
-#[test_device]
-fn clear_new_sd_card_warning(device: Storage) {
- let mut device = device;
- assert_ok!((), device.factory_reset(DEFAULT_ADMIN_PIN));
- thread::sleep(time::Duration::from_secs(3));
- assert_ok!((), device.build_aes_key(DEFAULT_ADMIN_PIN));
-
- // We have to perform an SD card operation to reset the new_sd_card_found field
- assert_ok!((), device.lock());
-
- let status = unwrap_ok!(device.get_storage_status());
- assert!(status.new_sd_card_found);
-
- assert_ok!((), device.clear_new_sd_card_warning(DEFAULT_ADMIN_PIN));
-
- let status = unwrap_ok!(device.get_storage_status());
- assert!(!status.new_sd_card_found);
-}
-
-#[test_device]
-fn get_sd_card_usage(device: Storage) {
- let range = unwrap_ok!(device.get_sd_card_usage());
-
- assert!(range.end >= range.start);
- assert!(range.end <= 100);
-}
-
-#[test_device]
-fn get_operation_status(device: Storage) {
- assert_ok!(OperationStatus::Idle, device.get_operation_status());
-}
-
-#[test_device]
-#[ignore]
-fn fill_sd_card(device: Storage) {
- // This test takes up to 60 min to execute and is therefore ignored by default. Use `cargo
- // test -- --ignored fill_sd_card` to run the test.
-
- let mut device = device;
- assert_ok!((), device.factory_reset(DEFAULT_ADMIN_PIN));
- thread::sleep(time::Duration::from_secs(3));
- assert_ok!((), device.build_aes_key(DEFAULT_ADMIN_PIN));
-
- let status = unwrap_ok!(device.get_storage_status());
- assert!(!status.filled_with_random);
-
- assert_ok!((), device.fill_sd_card(DEFAULT_ADMIN_PIN));
- assert_cmd_err!(CommandError::WrongCrc, device.get_status());
-
- let mut status = OperationStatus::Ongoing(0);
- let mut last_progress = 0u8;
- while status != OperationStatus::Idle {
- status = unwrap_ok!(device.get_operation_status());
- if let OperationStatus::Ongoing(progress) = status {
- assert!(progress <= 100, "progress = {}", progress);
- assert!(
- progress >= last_progress,
- "progress = {}, last_progress = {}",
- progress,
- last_progress
- );
- last_progress = progress;
-
- thread::sleep(time::Duration::from_secs(10));
- }
- }
-
- let status = unwrap_ok!(device.get_storage_status());
- assert!(status.filled_with_random);
-}
-
-#[test_device]
-fn export_firmware(device: Storage) {
- let mut device = device;
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.export_firmware("someadminpn")
- );
- assert_ok!((), device.export_firmware(DEFAULT_ADMIN_PIN));
- assert_ok!(
- (),
- device.set_unencrypted_volume_mode(DEFAULT_ADMIN_PIN, VolumeMode::ReadWrite)
- );
- assert_ok!((), device.export_firmware(DEFAULT_ADMIN_PIN));
- assert_ok!(
- (),
- device.set_unencrypted_volume_mode(DEFAULT_ADMIN_PIN, VolumeMode::ReadOnly)
- );
-}
diff --git a/nitrokey/tests/lib.rs b/nitrokey/tests/lib.rs
deleted file mode 100644
index 25aae0f..0000000
--- a/nitrokey/tests/lib.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-mod util;
-
-#[test]
-fn get_library_version() {
- let version = unwrap_ok!(nitrokey::get_library_version());
-
- assert!(version.git.is_empty() || version.git.starts_with("v"));
- assert!(version.major > 0);
-}
-
-#[test]
-fn take_manager() {
- assert!(nitrokey::take().is_ok());
-
- let result = nitrokey::take();
- assert!(result.is_ok());
- let result2 = nitrokey::take();
- match result2 {
- Ok(_) => panic!("Expected error, got Ok(_)!"),
- Err(nitrokey::Error::ConcurrentAccessError) => {}
- Err(err) => panic!("Expected ConcurrentAccessError, got {}", err),
- }
- drop(result);
- assert!(nitrokey::take().is_ok());
-}
diff --git a/nitrokey/tests/otp.rs b/nitrokey/tests/otp.rs
deleted file mode 100644
index 38cd8a9..0000000
--- a/nitrokey/tests/otp.rs
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-mod util;
-
-use std::fmt::Debug;
-use std::ops::DerefMut;
-
-use nitrokey::{
- Admin, Authenticate, CommandError, Config, ConfigureOtp, Device, GenerateOtp, LibraryError,
- OtpMode, OtpSlotData, DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN,
-};
-use nitrokey_test::test as test_device;
-
-// 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", "37359152"]),
- (1111111109, &["07081804"]),
- (1111111111, &["14050471"]),
- (1234567890, &["89005924"]),
- (2000000000, &["69279037"]),
- (20000000000, &["65353130"]),
-];
-
-#[derive(PartialEq)]
-enum TotpTimestampSize {
- U32,
- U64,
-}
-
-fn make_admin_test_device<'a, T>(device: T) -> Admin<'a, T>
-where
- T: Device<'a>,
- (T, nitrokey::Error): Debug,
-{
- unwrap_ok!(device.authenticate_admin(DEFAULT_ADMIN_PIN))
-}
-
-fn configure_hotp(admin: &mut dyn ConfigureOtp, counter: u8) {
- let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits);
- assert_ok!((), admin.write_hotp_slot(slot_data, counter.into()));
-}
-
-fn check_hotp_codes(device: &mut dyn GenerateOtp, offset: u8) {
- HOTP_CODES.iter().enumerate().for_each(|(i, code)| {
- if i >= offset as usize {
- assert_ok!(code.to_string(), device.get_hotp_code(1));
- }
- });
-}
-
-#[test_device]
-fn set_time(device: DeviceWrapper) {
- let mut device = device;
- assert_ok!((), device.set_time(1546385382, true));
- assert_ok!((), device.set_time(1546385392, false));
- assert_cmd_err!(CommandError::Timestamp, device.set_time(1546385292, false));
- assert_ok!((), device.set_time(1546385382, true));
-}
-
-#[test_device]
-fn hotp_no_pin(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_ok!((), admin.write_config(config));
-
- configure_hotp(&mut admin, 0);
- check_hotp_codes(admin.deref_mut(), 0);
-
- configure_hotp(&mut admin, 5);
- check_hotp_codes(admin.deref_mut(), 5);
-
- configure_hotp(&mut admin, 0);
- check_hotp_codes(&mut admin.device(), 0);
-}
-
-#[test_device]
-fn hotp_pin(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, true);
- assert_ok!((), admin.write_config(config));
-
- configure_hotp(&mut admin, 0);
- let mut user = unwrap_ok!(admin.device().authenticate_user(DEFAULT_USER_PIN));
- check_hotp_codes(&mut user, 0);
-
- assert_cmd_err!(CommandError::NotAuthorized, user.device().get_hotp_code(1));
-}
-
-#[test_device]
-fn hotp_slot_name(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits);
- assert_ok!((), admin.write_hotp_slot(slot_data, 0));
-
- let device = admin.device();
- assert_ok!("test-hotp".to_string(), device.get_hotp_slot_name(1));
- assert_lib_err!(LibraryError::InvalidSlot, device.get_hotp_slot_name(4));
-}
-
-#[test_device]
-fn hotp_error(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "", HOTP_SECRET, OtpMode::SixDigits);
- assert_cmd_err!(CommandError::NoName, admin.write_hotp_slot(slot_data, 0));
- let slot_data = OtpSlotData::new(4, "test", HOTP_SECRET, OtpMode::SixDigits);
- assert_lib_err!(
- LibraryError::InvalidSlot,
- admin.write_hotp_slot(slot_data, 0)
- );
- let slot_data = OtpSlotData::new(1, "test", "foobar", OtpMode::SixDigits);
- assert_lib_err!(
- LibraryError::InvalidHexString,
- admin.write_hotp_slot(slot_data, 0)
- );
- let code = admin.get_hotp_code(4);
- assert_lib_err!(LibraryError::InvalidSlot, code);
-}
-
-#[test_device]
-fn hotp_erase(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_ok!((), admin.write_config(config));
- let slot_data = OtpSlotData::new(1, "test1", HOTP_SECRET, OtpMode::SixDigits);
- assert_ok!((), admin.write_hotp_slot(slot_data, 0));
- let slot_data = OtpSlotData::new(2, "test2", HOTP_SECRET, OtpMode::SixDigits);
- assert_ok!((), admin.write_hotp_slot(slot_data, 0));
-
- assert_ok!((), admin.erase_hotp_slot(1));
-
- let mut device = admin.device();
- let result = device.get_hotp_slot_name(1);
- assert_cmd_err!(CommandError::SlotNotProgrammed, result);
- let result = device.get_hotp_code(1);
- assert_cmd_err!(CommandError::SlotNotProgrammed, result);
-
- assert_ok!("test2".to_string(), device.get_hotp_slot_name(2));
-}
-
-fn configure_totp(admin: &mut dyn ConfigureOtp, factor: u64) {
- let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits);
- let time_window = 30u64.checked_mul(factor).unwrap();
- assert_ok!((), admin.write_totp_slot(slot_data, time_window as u16));
-}
-
-fn check_totp_codes(device: &mut dyn GenerateOtp, factor: u64, timestamp_size: TotpTimestampSize) {
- for (base_time, codes) in TOTP_CODES {
- 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_ok!((), device.set_time(time, true));
- let code = unwrap_ok!(device.get_totp_code(1));
- assert!(
- code.contains(&code),
- "Generated TOTP code {} for {}, but expected one of {}",
- code,
- base_time,
- codes.join(", ")
- );
- }
-}
-
-#[test_device]
-fn totp_no_pin(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_ok!((), admin.write_config(config));
-
- configure_totp(&mut admin, 1);
- check_totp_codes(admin.deref_mut(), 1, TotpTimestampSize::U32);
-
- configure_totp(&mut admin, 2);
- check_totp_codes(admin.deref_mut(), 2, TotpTimestampSize::U32);
-
- configure_totp(&mut admin, 1);
- check_totp_codes(&mut 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 mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_ok!((), admin.write_config(config));
-
- configure_totp(&mut admin, 1);
- check_totp_codes(admin.deref_mut(), 1, TotpTimestampSize::U64);
-
- configure_totp(&mut admin, 2);
- check_totp_codes(admin.deref_mut(), 2, TotpTimestampSize::U64);
-
- configure_totp(&mut admin, 1);
- check_totp_codes(&mut admin.device(), 1, TotpTimestampSize::U64);
-}
-
-#[test_device]
-fn totp_pin(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, true);
- assert_ok!((), admin.write_config(config));
-
- configure_totp(&mut admin, 1);
- let mut user = unwrap_ok!(admin.device().authenticate_user(DEFAULT_USER_PIN));
- check_totp_codes(&mut user, 1, TotpTimestampSize::U32);
-
- assert_cmd_err!(CommandError::NotAuthorized, user.device().get_totp_code(1));
-}
-
-#[test_device]
-// See comment for totp_no_pin_64.
-fn totp_pin_64(device: Pro) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, true);
- assert_ok!((), admin.write_config(config));
-
- configure_totp(&mut admin, 1);
- let mut user = unwrap_ok!(admin.device().authenticate_user(DEFAULT_USER_PIN));
- check_totp_codes(&mut user, 1, TotpTimestampSize::U64);
-
- assert_cmd_err!(CommandError::NotAuthorized, user.device().get_totp_code(1));
-}
-
-#[test_device]
-fn totp_slot_name(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits);
- assert_ok!((), admin.write_totp_slot(slot_data, 0));
-
- let device = admin.device();
- let result = device.get_totp_slot_name(1);
- assert_ok!("test-totp", result);
- let result = device.get_totp_slot_name(16);
- assert_lib_err!(LibraryError::InvalidSlot, result);
-}
-
-#[test_device]
-fn totp_error(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let slot_data = OtpSlotData::new(1, "", TOTP_SECRET, OtpMode::SixDigits);
- assert_cmd_err!(CommandError::NoName, admin.write_totp_slot(slot_data, 0));
- let slot_data = OtpSlotData::new(20, "test", TOTP_SECRET, OtpMode::SixDigits);
- assert_lib_err!(
- LibraryError::InvalidSlot,
- admin.write_totp_slot(slot_data, 0)
- );
- let slot_data = OtpSlotData::new(4, "test", "foobar", OtpMode::SixDigits);
- assert_lib_err!(
- LibraryError::InvalidHexString,
- admin.write_totp_slot(slot_data, 0)
- );
- let code = admin.get_totp_code(20);
- assert_lib_err!(LibraryError::InvalidSlot, code);
-}
-
-#[test_device]
-fn totp_erase(device: DeviceWrapper) {
- let mut admin = make_admin_test_device(device);
- let config = Config::new(None, None, None, false);
- assert_ok!((), admin.write_config(config));
- let slot_data = OtpSlotData::new(1, "test1", TOTP_SECRET, OtpMode::SixDigits);
- assert_ok!((), admin.write_totp_slot(slot_data, 0));
- let slot_data = OtpSlotData::new(2, "test2", TOTP_SECRET, OtpMode::SixDigits);
- assert_ok!((), admin.write_totp_slot(slot_data, 0));
-
- assert_ok!((), admin.erase_totp_slot(1));
-
- let device = admin.device();
- let result = device.get_totp_slot_name(1);
- assert_cmd_err!(CommandError::SlotNotProgrammed, result);
- let result = device.get_totp_code(1);
- assert_cmd_err!(CommandError::SlotNotProgrammed, result);
-
- assert_ok!("test2".to_string(), device.get_totp_slot_name(2));
-}
diff --git a/nitrokey/tests/pws.rs b/nitrokey/tests/pws.rs
deleted file mode 100644
index 7169695..0000000
--- a/nitrokey/tests/pws.rs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-mod util;
-
-use std::ffi::CStr;
-
-use libc::{c_int, c_void, free};
-use nitrokey::{
- CommandError, Device, Error, GetPasswordSafe, LibraryError, PasswordSafe, DEFAULT_ADMIN_PIN,
- DEFAULT_USER_PIN, SLOT_COUNT,
-};
-use nitrokey_sys;
-use nitrokey_test::test as test_device;
-
-fn get_slot_name_direct(slot: u8) -> Result<String, Error> {
- let ptr = unsafe { nitrokey_sys::NK_get_password_safe_slot_name(slot) };
- if ptr.is_null() {
- return Err(Error::UnexpectedError);
- }
- 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(Error::from(other)),
- }
- }
- false => Ok(s),
- }
-}
-
-fn get_pws<'a, T>(device: &mut T) -> PasswordSafe<'_, 'a>
-where
- T: Device<'a>,
-{
- unwrap_ok!(device.get_password_safe(DEFAULT_USER_PIN))
-}
-
-#[test_device]
-fn enable(device: DeviceWrapper) {
- let mut device = device;
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.get_password_safe(&(DEFAULT_USER_PIN.to_owned() + "123"))
- );
- assert_any_ok!(device.get_password_safe(DEFAULT_USER_PIN));
- assert_cmd_err!(
- CommandError::WrongPassword,
- device.get_password_safe(DEFAULT_ADMIN_PIN)
- );
- assert_any_ok!(device.get_password_safe(DEFAULT_USER_PIN));
-}
-
-#[test_device]
-fn drop(device: DeviceWrapper) {
- let mut device = device;
- {
- let mut pws = get_pws(&mut device);
- assert_ok!((), pws.write_slot(1, "name", "login", "password"));
- assert_ok!("name".to_string(), pws.get_slot_name(1));
- let result = get_slot_name_direct(1);
- assert_ok!(String::from("name"), result);
- }
- let result = get_slot_name_direct(1);
- assert_ok!(String::from("name"), result);
- assert_ok!((), device.lock());
- let result = get_slot_name_direct(1);
- assert_cmd_err!(CommandError::NotAuthorized, result);
-}
-
-#[test_device]
-fn get_status(device: DeviceWrapper) {
- let mut device = device;
- let mut pws = get_pws(&mut device);
- for i in 0..SLOT_COUNT {
- assert_ok!((), pws.erase_slot(i));
- }
- let status = unwrap_ok!(pws.get_slot_status());
- assert_eq!(status, [false; SLOT_COUNT as usize]);
-
- assert_ok!((), pws.write_slot(1, "name", "login", "password"));
- let status = unwrap_ok!(pws.get_slot_status());
- for i in 0..SLOT_COUNT {
- assert_eq!(i == 1, status[i as usize]);
- }
-
- for i in 0..SLOT_COUNT {
- assert_ok!((), pws.write_slot(i, "name", "login", "password"));
- }
- assert_ok!([true; SLOT_COUNT as usize], pws.get_slot_status());
-}
-
-#[test_device]
-fn get_data(device: DeviceWrapper) {
- let mut device = device;
- let mut pws = get_pws(&mut device);
- assert_ok!((), pws.write_slot(1, "name", "login", "password"));
- assert_ok!("name".to_string(), pws.get_slot_name(1));
- assert_ok!("login".to_string(), pws.get_slot_login(1));
- assert_ok!("password".to_string(), pws.get_slot_password(1));
-
- assert_ok!((), pws.erase_slot(1));
- assert_cmd_err!(CommandError::SlotNotProgrammed, pws.get_slot_name(1));
- assert_cmd_err!(CommandError::SlotNotProgrammed, pws.get_slot_login(1));
- assert_cmd_err!(CommandError::SlotNotProgrammed, pws.get_slot_password(1));
-
- let name = "with å";
- let login = "pär@test.com";
- let password = "'i3lJc[09?I:,[u7dWz9";
- assert_ok!((), pws.write_slot(1, name, login, password));
- assert_ok!(name.to_string(), pws.get_slot_name(1));
- assert_ok!(login.to_string(), pws.get_slot_login(1));
- assert_ok!(password.to_string(), pws.get_slot_password(1));
-
- assert_lib_err!(LibraryError::InvalidSlot, pws.get_slot_name(SLOT_COUNT));
- assert_lib_err!(LibraryError::InvalidSlot, pws.get_slot_login(SLOT_COUNT));
- assert_lib_err!(LibraryError::InvalidSlot, pws.get_slot_password(SLOT_COUNT));
-}
-
-#[test_device]
-fn write(device: DeviceWrapper) {
- let mut device = device;
- let mut pws = get_pws(&mut device);
-
- assert_lib_err!(
- LibraryError::InvalidSlot,
- pws.write_slot(SLOT_COUNT, "name", "login", "password")
- );
-
- assert_ok!((), pws.write_slot(0, "", "login", "password"));
- assert_cmd_err!(CommandError::SlotNotProgrammed, pws.get_slot_name(0));
- assert_ok!(String::from("login"), pws.get_slot_login(0));
- assert_ok!(String::from("password"), pws.get_slot_password(0));
-
- assert_ok!((), pws.write_slot(0, "name", "", "password"));
- assert_ok!(String::from("name"), pws.get_slot_name(0));
- assert_cmd_err!(CommandError::SlotNotProgrammed, pws.get_slot_login(0));
- assert_ok!(String::from("password"), pws.get_slot_password(0));
-
- assert_ok!((), pws.write_slot(0, "name", "login", ""));
- assert_ok!(String::from("name"), pws.get_slot_name(0));
- assert_ok!(String::from("login"), pws.get_slot_login(0));
- assert_cmd_err!(CommandError::SlotNotProgrammed, pws.get_slot_password(0));
-}
-
-#[test_device]
-fn erase(device: DeviceWrapper) {
- let mut device = device;
- let mut pws = get_pws(&mut device);
- assert_lib_err!(LibraryError::InvalidSlot, pws.erase_slot(SLOT_COUNT));
-
- assert_ok!((), pws.write_slot(0, "name", "login", "password"));
- assert_ok!((), pws.erase_slot(0));
- assert_ok!((), pws.erase_slot(0));
- assert_cmd_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 f2b20ec..0000000
--- a/nitrokey/tests/util/mod.rs
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
-// SPDX-License-Identifier: MIT
-
-#[macro_export]
-macro_rules! unwrap_ok {
- ($val:expr) => {{
- match $val {
- Ok(val) => val,
- Err(err) => panic!(
- r#"assertion failed: `(left == right)`
- left: `Ok(_)`,
- right: `Err({:?})`"#,
- err
- ),
- }
- }};
-}
-
-#[macro_export]
-macro_rules! assert_any_ok {
- ($val:expr) => {{
- match &$val {
- Ok(_) => {}
- Err(err) => panic!(
- r#"assertion failed: `(left == right)`
- left: `Ok(_)`,
- right: `Err({:?})`"#,
- err
- ),
- }
- }};
-}
-
-#[macro_export]
-macro_rules! assert_ok {
- ($left:expr, $right:expr) => {{
- match &$right {
- Ok(right) => match &$left {
- left => {
- if !(*left == *right) {
- panic!(
- r#"assertion failed: `(left == right)`
- left: `{:?}`,
- right: `{:?}`"#,
- left, right
- )
- }
- }
- },
- Err(right_err) => panic!(
- r#"assertion failed: `(left == right)`
- left: `Ok({:?})`,
- right: `Err({:?})`"#,
- $left, right_err
- ),
- }
- }};
-}
-
-#[macro_export]
-macro_rules! assert_err {
- ($err:path, $left:expr, $right:expr) => {
- match &$right {
- Err($err(ref right_err)) => match &$left {
- left_err => {
- if !(*left_err == *right_err) {
- panic!(
- r#"assertion failed: `(left == right)`
- left: `{:?}`,
- right: `{:?}`"#,
- left_err, right_err
- )
- }
- }
- },
- Err(ref right_err) => panic!(
- r#"assertion failed: `(left == right)`
- left: `{:?}`,
- right: `{:?}`"#,
- $err($left),
- right_err
- ),
- Ok(right_ok) => panic!(
- r#"assertion failed: `(left == right)`
- left: `Err({:?})`,
- right: `Ok({:?})`"#,
- $err($left),
- right_ok
- ),
- }
- };
-}
-
-#[macro_export]
-macro_rules! assert_cmd_err {
- ($left:expr, $right:expr) => {
- assert_err!(::nitrokey::Error::CommandError, $left, $right);
- };
-}
-
-#[macro_export]
-macro_rules! assert_cmu_err {
- ($left:expr, $right:expr) => {
- assert_err!(::nitrokey::Error::CommunicationError, $left, $right);
- };
-}
-
-#[macro_export]
-macro_rules! assert_lib_err {
- ($left:expr, $right:expr) => {
- assert_err!(::nitrokey::Error::LibraryError, $left, $right);
- };
-}
diff --git a/proc-macro-error/.gitignore b/proc-macro-error/.gitignore
deleted file mode 100644
index 9d538f2..0000000
--- a/proc-macro-error/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-/target
-**/*.rs.bk
-Cargo.lock
-.fuse_hidden* \ No newline at end of file
diff --git a/proc-macro-error/.gitlab-ci.yml b/proc-macro-error/.gitlab-ci.yml
deleted file mode 100644
index e36a714..0000000
--- a/proc-macro-error/.gitlab-ci.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-stages:
- - test
-
-
-.setup_template: &setup_template
- stage: test
- image: debian:stable-slim
- before_script:
- - export CARGO_HOME="$CI_PROJECT_DIR/.cargo"
- - export PATH="$PATH:$CARGO_HOME/bin"
- - export RUST_BACKTRACE=full
- - apt-get update > /dev/null
- - apt-get install -y curl build-essential > /dev/null
- - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_VERSION
- - rustup --version
- - rustc --version
- - cargo --version
-
-.test_all_template: &test_all_template
- <<: *setup_template
- script:
- - cargo test --all
-
-
-test-stable:
- <<: *test_all_template
- variables:
- RUST_VERSION: stable
-
-test-beta:
- <<: *test_all_template
- variables:
- RUST_VERSION: beta
-
-test-nightly:
- <<: *test_all_template
- variables:
- RUST_VERSION: nightly
-
-
-test-1.31.0:
- <<: *setup_template
- script:
- - cargo test --tests # skip doctests
- variables:
- RUST_VERSION: 1.31.0
-
-test-fmt:
- <<: *setup_template
- script:
- - cargo fmt --all -- --check
- - RUTSFLAGS='--cfg nightly_fmt' cargo fmt --all -- --check
- variables:
- RUST_VERSION: stable
diff --git a/proc-macro-error/.travis.yml b/proc-macro-error/.travis.yml
deleted file mode 100644
index 362003f..0000000
--- a/proc-macro-error/.travis.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-language: rust
-rust:
- - stable
- - beta
- - nightly
-script:
- - cargo test --all
-matrix:
- include:
- - rust: 1.31.0
- script: cargo test --tests # skip doctests
- allow_failures:
- - rust: nightly
- fast_finish: true
-
-
-notifications:
- email:
- on_success: never
diff --git a/proc-macro-error/CHANGELOG.md b/proc-macro-error/CHANGELOG.md
deleted file mode 100644
index 29043b5..0000000
--- a/proc-macro-error/CHANGELOG.md
+++ /dev/null
@@ -1,86 +0,0 @@
-# v0.4.4 (2019-11-13)
-* Fix `abort_if_dirty` + warnings bug
-* Allow trailing commas in macros
-
-# v0.4.2 (2019-11-7)
-* FINALLY fixed `__pme__suggestions not found` bug
-
-# v0.4.1 (2019-11-7) YANKED
-* Fixed `__pme__suggestions not found` bug
-* Documentation improvements, links checked
-
-# v0.4.0 (2019-11-6) YANKED
-
-## New features
-* "help" messages that can have their own span on nightly, they
- inherit parent span on stable.
- ```rust
- let cond_help = if condition { Some("some help message") else { None } };
- abort!(
- span, // parent span
- "something's wrong, {} wrongs in total", 10; // main message
- help = "here's a help for you, {}", "take it"; // unconditional help message
- help =? cond_help; // conditional help message, must be Option
- note = note_span => "don't forget the note, {}", "would you?" // notes can have their own span but it's effective only on nightly
- )
- ```
-* Warnings via `emit_warning` and `emit_warning_call_site`. Nightly only, they're ignored on stable.
-* Now `proc-macro-error` delegates to `proc_macro::Diagnostic` on nightly.
-
-## Breaking changes
-* `MacroError` is now replaced by `Diagnostic`. Its API resembles `proc_macro::Diagnostic`.
-* `Diagnostic` does not implement `From<&str/String>` so `Result<T, &str/String>::abort_or_exit()`
- won't work anymore (nobody used it anyway).
-* `macro_error!` macro is replaced with `diagnostic!`.
-
-## Improvements
-* Now `proc-macro-error` renders notes exactly just like rustc does.
-* We don't parse a body of a function annotated with `#[proc_macro_error]` anymore,
- only looking at the signature. This should somewhat decrease expansion time for large functions.
-
-# v0.3.3 (2019-10-16)
-* Now you can use any word instead of "help", undocumented.
-
-# v0.3.2 (2019-10-16)
-* Introduced support for "help" messages, undocumented.
-
-# v0.3.0 (2019-10-8)
-
-## The crate has been completely rewritten from scratch!
-
-## Changes (most are breaking):
-* Renamed macros:
- * `span_error` => `abort`
- * `call_site_error` => `abort_call_site`
-* `filter_macro_errors` was replaced by `#[proc_macro_error]` attribute.
-* `set_dummy` now takes `TokenStream` instead of `Option<TokenStream>`
-* Support for multiple errors via `emit_error` and `emit_call_site_error`
-* New `macro_error` macro for building errors in format=like style.
-* `MacroError` API had been reconsidered. It also now implements `quote::ToTokens`.
-
-# v0.2.6 (2019-09-02)
-* Introduce support for dummy implementations via `dummy::set_dummy`
-* `multi::*` is now deprecated, will be completely rewritten in v0.3
-
-# v0.2.0 (2019-08-15)
-
-## Breaking changes
-* `trigger_error` replaced with `MacroError::trigger` and `filter_macro_error_panics`
- is hidden from docs.
- This is not quite a breaking change since users weren't supposed to use these functions directly anyway.
-* All dependencies are updated to `v1.*`.
-
-## New features
-* Ability to stack multiple errors via `multi::MultiMacroErrors` and emit them at once.
-
-## Improvements
-* Now `MacroError` implements `std::fmt::Display` instead of `std::string::ToString`.
-* `MacroError::span` inherent method.
-* `From<MacroError> for proc_macro/proc_macro2::TokenStream` implementations.
-* `AsRef/AsMut<String> for MacroError` implementations.
-
-# v0.1.x (2019-07-XX)
-
-## New features
-* An easy way to report errors inside within a proc-macro via `span_error`,
- `call_site_error` and `filter_macro_errors`.
diff --git a/proc-macro-error/Cargo.toml b/proc-macro-error/Cargo.toml
deleted file mode 100644
index 6fa600e..0000000
--- a/proc-macro-error/Cargo.toml
+++ /dev/null
@@ -1,7 +0,0 @@
-[workspace]
-
-members = [
- "proc-macro-error",
- "proc-macro-error-attr",
- "test-crate",
-]
diff --git a/proc-macro-error/LICENSE-APACHE b/proc-macro-error/LICENSE-APACHE
deleted file mode 100644
index 52ba334..0000000
--- a/proc-macro-error/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 2019 CreepySkeleton <creepy-skeleton@yandex.ru>
-
-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/proc-macro-error/LICENSE-MIT b/proc-macro-error/LICENSE-MIT
deleted file mode 100644
index d01f775..0000000
--- a/proc-macro-error/LICENSE-MIT
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2019 CreepySkeleton
-
-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/proc-macro-error/README.md b/proc-macro-error/README.md
deleted file mode 100644
index d6d1086..0000000
--- a/proc-macro-error/README.md
+++ /dev/null
@@ -1,206 +0,0 @@
-# proc-macro-error
-
-[![travis ci](https://travis-ci.org/CreepySkeleton/proc-macro-error.svg?branch=master)](https://travis-ci.org/CreepySkeleton/proc-macro-error)
-[![docs.rs](https://docs.rs/proc-macro-error/badge.svg)](https://docs.rs/proc-macro-error)
-
-This crate aims to make error reporting in proc-macros simple and easy to use.
-Migrate from `panic!`-based errors for as little effort as possible!
-
-Also, there's ability to [append a dummy token stream][crate::dummy] to your errors.
-
-```toml
-[dependencies]
-proc-macro-error = "0.4"
-```
-
-*Supports rustc 1.31 and up*
-
-[Documentation and guide][guide]
-
-## What emitted errors look like
-
-```
-error: multiple error part: multi2
-
- = note: help message test
- = help: Option help test
- = note: I see what you did here...
-
- --> $DIR/multi-error.rs:4:18
- |
-4 | make_fn!(multi1, multi2, _, multi3);
- | ^^^^^^
-```
-
-## Examples
-
-### Panic-like usage
-
-```rust
-use proc_macro_error::*;
-use proc_macro::TokenStream;
-use syn::{DeriveInput, parse_macro_input};
-use quote::quote;
-
-// This is your main entry point
-#[proc_macro]
-// this attribute *MUST* be placed on top of the #[proc_macro] function
-#[proc_macro_error]
-pub fn make_answer(input: TokenStream) -> TokenStream {
- let input = parse_macro_input!(input as DeriveInput);
-
- if let Err(err) = some_logic(&input) {
- // we've got a span to blame, let's use it
- // This immediately aborts the proc-macro and shows the error
- abort!(err.span, "You made an error, go fix it: {}", err.msg);
- }
-
- // `Result` has some handy shortcuts if your error type implements
- // `Into<MacroError>`. `Option` has one unconditionally.
- more_logic(&input).expect_or_abort("What a careless user, behave!");
-
- if !more_logic_for_logic_god(&input) {
- // We don't have an exact location this time,
- // so just highlight the proc-macro invocation itself
- abort_call_site!(
- "Bad, bad user! Now go stand in the corner and think about what you did!");
- }
-
- // Now all the processing is done, return `proc_macro::TokenStream`
- quote!(/* stuff */).into()
-}
-```
-
-### `proc_macro::Diagnostic`-like usage
-
-```rust
-use proc_macro_error::*;
-use proc_macro::TokenStream;
-use syn::{spanned::Spanned, DeriveInput, ItemStruct, Fields, Attribute , parse_macro_input};
-use quote::quote;
-
-fn process_attrs(attrs: &[Attribute]) -> Vec<Attribute> {
- attrs
- .iter()
- .filter_map(|attr| match process_attr(attr) {
- Ok(res) => Some(res),
- Err(msg) => {
- emit_error!(attr.span(), "Invalid attribute: {}", msg);
- None
- }
- })
- .collect()
-}
-
-fn process_fields(_attrs: &Fields) -> Vec<TokenStream> {
- // processing fields in pretty much the same way as attributes
- unimplemented!()
-}
-
-#[proc_macro]
-#[proc_macro_error]
-pub fn make_answer(input: TokenStream) -> TokenStream {
- let input = parse_macro_input!(input as ItemStruct);
- let attrs = process_attrs(&input.attrs);
-
- // abort right now if some errors were encountered
- // at the attributes processing stage
- abort_if_dirty();
-
- let fields = process_fields(&input.fields);
-
- // no need to think about emitted errors
- // #[proc_macro_error] will handle them for you
- //
- // just return a TokenStream as you normally would
- quote!(/* stuff */).into()
-}
-```
-
-## Limitations
-
-- Warnings are emitted only on nightly, they're ignored on stable.
-- "help" suggestions cannot have their own span info on stable, (they inherit parent span).
-- If a panic occurs somewhere in your macro no errors will be displayed. This is not a
- technical limitation but intentional design, `panic` is not for error reporting.
-
-## MSRV policy
-
-`proc_macro_error` will always be compatible with proc-macro holy trinity:
-`proc_macro2`, `syn`, `quote` crates. In other words, if the trinity is available
-to you than `proc_macro_error` is available too.
-
-## Motivation
-
-Error handling in proc-macros sucks. There's not much of a choice today:
-you either "bubble up" the error up to the top-level of your macro and convert it to
-a [`compile_error!`][compl_err] invocation or just use a good old panic. Both these ways suck:
-
-- Former sucks because it's quite redundant to unroll a proper error handling
- just for critical errors that will crash the macro anyway so people mostly
- choose not to bother with it at all and use panic. Almost nobody does it,
- simple `.expect` is too tempting.
-
- Also, if you do decide to implement this `Result`-based architecture in your macro
- you're going to have to rewrite it entirely once [`proc_macro::Diagnostic`][] is finally stable.
- Not cool.
-
-- Later sucks because there's no way to carry out span info via `panic!`. `rustc` will highlight
- the whole invocation itself but not some specific token inside it.
-
- Furthermore, panics aren't for error-reporting at all; panics are for bug-detecting
- (like unwrapping on `None` or out-of-range indexing) or for early development stages
- when you need a prototype ASAP and error handling can wait. Mixing these usages only
- messes things up.
-
-- There is [`proc_macro::Diagnostic`][] which is awesome but it has been experimental
- for more than a year and is unlikely to be stabilized any time soon.
-
- This crate's API is intentionally designed to be compatible with `proc_macro::Diagnostic`
- and delegates to it whenever possible. Once `Diagnostics` is stable this crate
- will **always** delegate to it, no code changes will be required on user side.
-
-That said, we need a solution, but this solution must meet these conditions:
-
-- It must be better than `panic!`. The main point: it must offer a way to carry span information
- over to user.
-- It must take as little effort as possible to migrate from `panic!`. Ideally, a new
- macro with the same semantics plus ability to carry out span info. We should also keep
- in mind the existence of [`proc_macro::Diagnostic`][] .
-- **It must be usable on stable**.
-
-This crate aims to provide such a mechanism. All you have to do is annotate your top-level
-`#[proc_macro]` function with `#[proc_macro_errors]` attribute and change panics to
-[`abort!`]/[`abort_call_site!`] where appropriate, see [the Guide][guide].
-
-## Disclaimer
-Please note that **this crate is not intended to be used in any way other
-than proc-macro error reporting**, use `Result` and `?` for anything else.
-
-<br>
-
-#### License
-
-<sup>
-Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
-2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
-</sup>
-
-<br>
-
-<sub>
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
-be dual licensed as above, without any additional terms or conditions.
-</sub>
-
-
-[compl_err]: https://doc.rust-lang.org/std/macro.compile_error.html
-[`proc_macro::Diagnostic`]: https://doc.rust-lang.org/proc_macro/struct.Diagnostic.html
-
-[crate::dummy]: https://docs.rs/proc-macro-error/0.4/proc_macro_error/dummy/index.html
-[crate::multi]: https://docs.rs/proc-macro-error/0.4/proc_macro_error/multi/index.html
-
-[`abort_call_site!`]: https://docs.rs/proc-macro-error/0.4/proc_macro_error/macro.abort_call_site.html
-[`abort!`]: https://docs.rs/proc-macro-error/0.4/proc_macro_error/macro.abort.html
-[guide]: https://docs.rs/proc-macro-error
diff --git a/proc-macro-error/proc-macro-error-attr/Cargo.toml b/proc-macro-error/proc-macro-error-attr/Cargo.toml
deleted file mode 100644
index 6dee68e..0000000
--- a/proc-macro-error/proc-macro-error-attr/Cargo.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-[package]
-name = "proc-macro-error-attr"
-version = "0.4.3"
-authors = ["CreepySkeleton <creepy-skeleton@yandex.ru>"]
-edition = "2018"
-description = "attribute macro for proc-macro-error crate"
-license = "MIT OR Apache-2.0"
-repository = "https://gitlab.com/CreepySkeleton/proc-macro-error"
-
-[lib]
-proc-macro = true
-
-[dependencies]
-quote = "1"
-proc-macro2 = "1"
-syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro"] }
-syn-mid = "0.4"
-rustversion = "1.0"
diff --git a/proc-macro-error/proc-macro-error-attr/src/lib.rs b/proc-macro-error/proc-macro-error-attr/src/lib.rs
deleted file mode 100644
index 3c1013b..0000000
--- a/proc-macro-error/proc-macro-error-attr/src/lib.rs
+++ /dev/null
@@ -1,162 +0,0 @@
-extern crate proc_macro;
-
-use proc_macro::TokenStream;
-use proc_macro2::Ident;
-use quote::quote;
-use std::iter::FromIterator;
-use syn::{
- parse::{Parse, ParseStream},
- parse_macro_input,
- punctuated::Punctuated,
- Attribute, Token,
-};
-use syn_mid::{Block, ItemFn};
-
-use self::Setting::*;
-
-#[proc_macro_attribute]
-pub fn proc_macro_error(attr: TokenStream, input: TokenStream) -> TokenStream {
- let input = parse_macro_input!(input as ItemFn);
- let mut settings = match syn::parse::<Settings>(attr) {
- Ok(settings) => settings,
- Err(err) => {
- let err = err.to_compile_error();
- return quote!(#input #err).into();
- }
- };
-
- let is_proc_macro = is_proc_macro(&input.attrs);
- if is_proc_macro {
- settings.set(AssertUnwindSafe);
- }
-
- if detect_proc_macro_hack(&input.attrs) {
- settings.set(ProcMacroHack);
- }
-
- if !(settings.is_set(AllowNotMacro) || is_proc_macro) {
- return quote!(
- #input
- compile_error!("#[proc_macro_error] attribute can be used only with a proc-macro\n\n \
- hint: if you are really sure that #[proc_macro_error] should be applied \
- to this exact function use #[proc_macro_error(allow_not_macro)]\n");
- )
- .into();
- }
-
- let ItemFn {
- attrs,
- vis,
- constness,
- asyncness,
- unsafety,
- abi,
- fn_token,
- ident,
- generics,
- inputs,
- output,
- block,
- ..
- } = input;
-
- let body = gen_body(block, settings);
-
- quote!(
- #(#attrs)*
- #vis
- #constness
- #asyncness
- #unsafety
- #abi
- #fn_token
- #ident
- #generics
- (#inputs)
- #output
-
- { #body }
- )
- .into()
-}
-
-#[derive(PartialEq)]
-enum Setting {
- AssertUnwindSafe,
- AllowNotMacro,
- ProcMacroHack,
-}
-
-impl Parse for Setting {
- fn parse(input: ParseStream) -> syn::Result<Self> {
- let ident: Ident = input.parse()?;
- match &*ident.to_string() {
- "assert_unwind_safe" => Ok(AssertUnwindSafe),
- "allow_not_macro" => Ok(AllowNotMacro),
- "proc_macro_hack" => Ok(ProcMacroHack),
- _ => Err(syn::Error::new(
- ident.span(),
- format!(
- "unknown setting `{}`, expected one of \
- `assert_unwind_safe`, `allow_not_macro`, `proc_macro_hack`",
- ident
- ),
- )),
- }
- }
-}
-
-struct Settings(Vec<Setting>);
-impl Parse for Settings {
- fn parse(input: ParseStream) -> syn::Result<Self> {
- let punct = Punctuated::<Setting, Token![,]>::parse_terminated(input)?;
- Ok(Settings(Vec::from_iter(punct)))
- }
-}
-
-impl Settings {
- fn is_set(&self, setting: Setting) -> bool {
- self.0.iter().any(|s| *s == setting)
- }
-
- fn set(&mut self, setting: Setting) {
- self.0.push(setting)
- }
-}
-
-#[rustversion::since(1.37)]
-fn gen_body(block: Block, settings: Settings) -> proc_macro2::TokenStream {
- let is_proc_macro_hack = settings.is_set(ProcMacroHack);
- let closure = if settings.is_set(AssertUnwindSafe) {
- quote!(::std::panic::AssertUnwindSafe(|| #block ))
- } else {
- quote!(|| #block)
- };
-
- quote!( ::proc_macro_error::entry_point(#closure, #is_proc_macro_hack) )
-}
-
-// FIXME:
-// proc_macro::TokenStream does not implement UnwindSafe until 1.37.0.
-// Considering this is the closure's return type the unwind safety check would fail
-// for virtually every closure possible, the check is meaningless.
-#[rustversion::before(1.37)]
-fn gen_body(block: Block, settings: Settings) -> proc_macro2::TokenStream {
- let is_proc_macro_hack = settings.is_set(ProcMacroHack);
- let closure = quote!(::std::panic::AssertUnwindSafe(|| #block ));
- quote!( ::proc_macro_error::entry_point(#closure, #is_proc_macro_hack) )
-}
-
-fn detect_proc_macro_hack(attrs: &[Attribute]) -> bool {
- attrs
- .iter()
- .any(|attr| attr.path.is_ident("proc_macro_hack"))
-}
-
-fn is_proc_macro(attrs: &[Attribute]) -> bool {
- attrs.iter().any(|attr| {
- attr.path.is_ident("proc_macro")
- || attr.path.is_ident("proc_macro_derive")
- || attr.path.is_ident("proc_macro_attribute")
- })
-}
diff --git a/proc-macro-error/proc-macro-error/Cargo.toml b/proc-macro-error/proc-macro-error/Cargo.toml
deleted file mode 100644
index 2da213a..0000000
--- a/proc-macro-error/proc-macro-error/Cargo.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-[package]
-name = "proc-macro-error"
-version = "0.4.4"
-authors = ["CreepySkeleton <creepy-skeleton@yandex.ru>"]
-description = "Almost drop-in replacement to panics in proc-macros"
-
-repository = "https://gitlab.com/CreepySkeleton/proc-macro-error"
-readme = "../README.md"
-keywords = ["proc-macro", "error", "errors"]
-categories = ["development-tools::procedural-macro-helpers"]
-license = "MIT OR Apache-2.0"
-
-edition = "2018"
-build = "build.rs"
-
-[badges]
-maintenance = { status = "actively-developed" }
-
-[dependencies]
-quote = "1"
-proc-macro2 = "1"
-syn = { version = "1", default-features = false }
-proc-macro-error-attr = { path = "../proc-macro-error-attr", version = "0.4.3"}
-
-[build-dependencies]
-rustversion = "1.0"
diff --git a/proc-macro-error/proc-macro-error/build.rs b/proc-macro-error/proc-macro-error/build.rs
deleted file mode 100644
index 04ddc11..0000000
--- a/proc-macro-error/proc-macro-error/build.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-#[rustversion::nightly]
-fn nightly() {
- println!("cargo:rustc-cfg=pme_nightly");
-}
-
-#[rustversion::not(nightly)]
-fn nightly() {}
-
-fn main() {
- nightly()
-}
diff --git a/proc-macro-error/proc-macro-error/src/dummy.rs b/proc-macro-error/proc-macro-error/src/dummy.rs
deleted file mode 100644
index f7443b3..0000000
--- a/proc-macro-error/proc-macro-error/src/dummy.rs
+++ /dev/null
@@ -1,136 +0,0 @@
-//! Facility to emit dummy implementations (or whatever) in case
-//! an error happen.
-//!
-//! `compile_error!` does not abort a compilation right away. This means
-//! `rustc` doesn't just show you the error and abort, it carries on the
-//! compilation process looking for other errors to report.
-//!
-//! Let's consider an example:
-//!
-//! ```rust,ignore
-//! use proc_macro::TokenStream;
-//! use proc_macro_error::*;
-//!
-//! trait MyTrait {
-//! fn do_thing();
-//! }
-//!
-//! // this proc macro is supposed to generate MyTrait impl
-//! #[proc_macro_derive(MyTrait)]
-//! #[proc_macro_error]
-//! fn example(input: TokenStream) -> TokenStream {
-//! // somewhere deep inside
-//! abort!(span, "something's wrong");
-//!
-//! // this implementation will be generated if no error happened
-//! quote! {
-//! impl MyTrait for #name {
-//! fn do_thing() {/* whatever */}
-//! }
-//! }
-//! }
-//!
-//! // ================
-//! // in main.rs
-//!
-//! // this derive triggers an error
-//! #[derive(MyTrait)] // first BOOM!
-//! struct Foo;
-//!
-//! fn main() {
-//! Foo::do_thing(); // second BOOM!
-//! }
-//! ```
-//!
-//! The problem is: the generated token stream contains only `compile_error!`
-//! invocation, the impl was not generated. That means user will see two compilation
-//! errors:
-//!
-//! ```text
-//! error: something's wrong
-//! --> $DIR/probe.rs:9:10
-//! |
-//! 9 |#[proc_macro_derive(MyTrait)]
-//! | ^^^^^^^
-//!
-//! error[E0599]: no function or associated item named `do_thing` found for type `Foo` in the current scope
-//! --> src\main.rs:3:10
-//! |
-//! 1 | struct Foo;
-//! | ----------- function or associated item `do_thing` not found for this
-//! 2 | fn main() {
-//! 3 | Foo::do_thing(); // second BOOM!
-//! | ^^^^^^^^ function or associated item not found in `Foo`
-//! ```
-//!
-//! But the second error is meaningless! We definitely need to fix this.
-//!
-//! Most used approach in cases like this is "dummy implementation" -
-//! omit `impl MyTrait for #name` and fill functions bodies with `unimplemented!()`.
-//!
-//! This is how you do it:
-//!
-//! ```rust,ignore
-//! use proc_macro::TokenStream;
-//! use proc_macro_error::*;
-//!
-//! trait MyTrait {
-//! fn do_thing();
-//! }
-//!
-//! // this proc macro is supposed to generate MyTrait impl
-//! #[proc_macro_derive(MyTrait)]
-//! #[proc_macro_error]
-//! fn example(input: TokenStream) -> TokenStream {
-//! // first of all - we set a dummy impl which will be appended to
-//! // `compile_error!` invocations in case a trigger does happen
-//! set_dummy(quote! {
-//! impl MyTrait for #name {
-//! fn do_thing() { unimplemented!() }
-//! }
-//! });
-//!
-//! // somewhere deep inside
-//! abort!(span, "something's wrong");
-//!
-//! // this implementation will be generated if no error happened
-//! quote! {
-//! impl MyTrait for #name {
-//! fn do_thing() {/* whatever */}
-//! }
-//! }
-//! }
-//!
-//! // ================
-//! // in main.rs
-//!
-//! // this derive triggers an error
-//! #[derive(MyTrait)] // first BOOM!
-//! struct Foo;
-//!
-//! fn main() {
-//! Foo::do_thing(); // no more errors!
-//! }
-//! ```
-
-use proc_macro2::TokenStream;
-use std::cell::Cell;
-
-use crate::check_correctness;
-
-thread_local! {
- static DUMMY_IMPL: Cell<Option<TokenStream>> = Cell::new(None);
-}
-
-/// Sets dummy token stream which will be appended to `compile_error!(msg);...`
-/// invocations in case you'll emit any errors.
-///
-/// See [guide](../index.html#guide).
-pub fn set_dummy(dummy: TokenStream) -> Option<TokenStream> {
- check_correctness();
- DUMMY_IMPL.with(|old_dummy| old_dummy.replace(Some(dummy)))
-}
-
-pub(crate) fn cleanup() -> Option<TokenStream> {
- DUMMY_IMPL.with(|old_dummy| old_dummy.replace(None))
-}
diff --git a/proc-macro-error/proc-macro-error/src/lib.rs b/proc-macro-error/proc-macro-error/src/lib.rs
deleted file mode 100644
index 5fb0223..0000000
--- a/proc-macro-error/proc-macro-error/src/lib.rs
+++ /dev/null
@@ -1,514 +0,0 @@
-//! # proc-macro-error
-//!
-//! This crate aims to make error reporting in proc-macros simple and easy to use.
-//! Migrate from `panic!`-based errors for as little effort as possible!
-//!
-//! Also, there's ability to [append a dummy token stream](dummy/index.html) to your errors.
-//!
-//! ## Limitations
-//!
-//! - Warnings are emitted only on nightly, they're ignored on stable.
-//! - "help" suggestions cannot have their own span info on stable, (they inherit parent span).
-//! - If a panic occurs somewhere in your macro no errors will be displayed. This is not a
-//! technical limitation but intentional design, `panic` is not for error reporting.
-//!
-//! ## Guide
-//!
-//! ### Macros
-//!
-//! First of all - **all the emitting-related API must be used within a function
-//! annotated with [`#[proc_macro_error]`](#proc_macro_error-attribute) attribute**. You'll just get a
-//! panic otherwise, no errors will be shown.
-//!
-//! For most of the time you will be using macros.
-//!
-//! - [`abort!`]:
-//!
-//! Very much panic-like usage - abort execution and show the error. Expands to [`!`] (never type).
-//!
-//! - [`abort_call_site!`]:
-//!
-//! Shortcut for `abort!(Span::call_site(), ...)`. Expands to [`!`] (never type).
-//!
-//! - [`emit_error!`]:
-//!
-//! [`proc_macro::Diagnostic`]-like usage - emit the error but do not abort the macro.
-//! The compilation will fail nonetheless. Expands to [`()`] (unit type).
-//!
-//! - [`emit_call_site_error!`]:
-//!
-//! Shortcut for `emit_error!(Span::call_site(), ...)`. Expands to [`()`] (unit type).
-//!
-//! - [`emit_warning!`]:
-//!
-//! Like `emit_error!` but emit a warning instead of error. The compilation won't fail
-//! because of warnings.
-//! Expands to [`()`] (unit type).
-//!
-//! **Beware**: warnings are nightly only, they are completely ignored on stable.
-//!
-//! - [`emit_call_site_warning!`]:
-//!
-//! Shortcut for `emit_warning!(Span::call_site(), ...)`. Expands to `()` (unit type).
-//!
-//! - [`diagnostic`]:
-//!
-//! Build instance of `Diagnostic` in format-like style.
-//!
-//! ### Syntax
-//!
-//! All the macros have pretty much the same syntax:
-//!
-//! 1. ```ignore
-//! abort!(single_expr)
-//! ```
-//! Shortcut for `Diagnostic::from().abort()`
-//!
-//! 2. ```ignore
-//! abort!(span, message)
-//! ```
-//! Shortcut for `Diagnostic::spanned(span, message.to_string()).abort()`
-//!
-//! 3. ```ignore
-//! abort!(span, format_literal, format_args...)
-//! ```
-//! Shortcut for `Diagnostic::spanned(span, format!(format_literal, format_args...)).abort()`
-//!
-//! That's it. `abort!`, `emit_warning`, `emit_error` share this exact syntax.
-//! `abort_call_site!`, `emit_call_site_warning`, `emit_call_site_error` lack 1 form
-//! and do not take span in 2 and 3 forms.
-//!
-//! `diagnostic!` require `Level` instance between `span` and second argument (1 form is the same).
-//!
-//! #### Note attachments
-//!
-//! 3. Every macro can have "note" attachments (only 2 and 3 form).
-//! ```ignore
-//! let opt_help = if have_some_info { Some("did you mean `this`?") } else { None };
-//!
-//! abort!(
-//! span, message; // <--- attachments start with `;` (semicolon)
-//!
-//! help = "format {} {}", "arg1", "arg2"; // <--- every attachment ends with `;`,
-//! // maybe except the last one
-//!
-//! note = "to_string"; // <--- one arg uses `.to_string()` instead of `format!()`
-//!
-//! yay = "I see what {} did here", "you"; // <--- "help =" and "hint =" are mapped to Diagnostic::help
-//! // anything else is Diagnostic::note
-//!
-//! wow = note_span => "custom span"; // <--- attachments can have their own span
-//! // it takes effect only on nightly though
-//!
-//! hint =? opt_help; // <-- "optional" attachment, get displayed only if `Some`
-//! // must be single `Option` expression
-//!
-//! note =? note_span => opt_help // <-- optional attachments can have custom spans too
-//! )
-//! ```
-//!
-//! ### `#[proc_macro_error]` attribute
-//!
-//! **This attribute MUST be present on the top level of your macro.**
-//!
-//! This attribute performs the setup and cleanup necessary to make things work.
-//!
-//! #### Syntax
-//!
-//! `#[proc_macro_error]` or `#[proc_macro_error(settings...)]`, where `settings...`
-//! is a comma-separated list of:
-//!
-//! - `proc_macro_hack`:
-//!
-//! To correctly cooperate with `#[proc_macro_hack]` `#[proc_macro_error]`
-//! attribute must be placed *before* (above) it, like this:
-//!
-//! ```ignore
-//! #[proc_macro_error]
-//! #[proc_macro_hack]
-//! #[proc_macro]
-//! fn my_macro(input: TokenStream) -> TokenStream {
-//! unimplemented!()
-//! }
-//! ```
-//!
-//! If, for some reason, you can't place it like that you can use
-//! `#[proc_macro_error(proc_macro_hack)]` instead.
-//!
-//! - `allow_not_macro`:
-//!
-//! By default, the attribute checks that it's applied to a proc-macro.
-//! If none of `#[proc_macro]`, `#[proc_macro_derive]` nor `#[proc_macro_attribute]` are
-//! present it will panic. It's the intention - this crate is supposed to be used only with
-//! proc-macros. This setting is made to bypass the check, useful in certain
-//! circumstances.
-//!
-//! Please note: the function this attribute is applied to must return `proc_macro::TokenStream`.
-//!
-//! - `assert_unwind_safe`:
-//!
-//! By default, your code must be [unwind safe]. If your code is not unwind safe but you believe
-//! it's correct you can use this setting to bypass the check. This is typically needed
-//! for code that uses `lazy_static` or `thread_local` with `Cell/RefCell` inside.
-//!
-//! This setting is implied if `#[proc_macro_error]` is applied to a function
-//! marked as `#[proc_macro]`, `#[proc_macro_derive]` or `#[proc_macro_attribute]`.
-//!
-//! ### Diagnostic type
-//!
-//! [`Diagnostic`] type is intentionally designed to be API compatible with [`proc_macro::Diagnostic`].
-//! Not all API is implemented, only the part that can be reasonably implemented on stable.
-//!
-//!
-//! [`abort!`]: macro.abort.html
-//! [`emit_warning!`]: macro.emit_warning.html
-//! [`emit_error!`]: macro.emit_error.html
-//! [`abort_call_site!`]: macro.abort_call_site.html
-//! [`emit_call_site_warning!`]: macro.emit_call_site_error.html
-//! [`emit_call_site_error!`]: macro.emit_call_site_warning.html
-//! [`diagnostic!`]: macro.diagnostic.html
-//! [proc_macro_error]: ./../proc_macro_error_attr/attr.proc_macro_error.html
-//! [`Diagnostic`]: struct.Diagnostic.html
-//! [`proc_macro::Diagnostic`]: https://doc.rust-lang.org/proc_macro/struct.Diagnostic.html
-//! [unwind safe]: https://doc.rust-lang.org/std/panic/trait.UnwindSafe.html#what-is-unwind-safety
-//! [`!`]: https://doc.rust-lang.org/std/primitive.never.html
-//! [`()`]: https://doc.rust-lang.org/std/primitive.unit.html
-
-#![cfg_attr(pme_nightly, feature(proc_macro_diagnostic))]
-#![forbid(unsafe_code)]
-
-// reexports for use in macros
-#[doc(hidden)]
-pub extern crate proc_macro;
-#[doc(hidden)]
-pub extern crate proc_macro2;
-
-pub use self::dummy::set_dummy;
-pub use proc_macro_error_attr::proc_macro_error;
-
-use proc_macro2::{Span, TokenStream};
-use quote::quote;
-use quote::{quote_spanned, ToTokens};
-use std::cell::Cell;
-use std::panic::{catch_unwind, resume_unwind, UnwindSafe};
-
-pub mod dummy;
-
-mod macros;
-
-#[cfg(not(any(pme_nightly, nightly_fmt)))]
-#[path = "stable.rs"]
-mod imp;
-
-#[cfg(any(pme_nightly, nightly_fmt))]
-#[path = "nightly.rs"]
-mod imp;
-
-/// Represents a diagnostic level
-///
-/// # Warnings
-///
-/// Warnings are ignored on stable/beta
-#[derive(Debug, PartialEq)]
-pub enum Level {
- Error,
- Warning,
- #[doc(hidden)]
- NonExhaustive,
-}
-
-/// Represents a single diagnostic message
-#[derive(Debug)]
-pub struct Diagnostic {
- level: Level,
- span: Span,
- msg: String,
- suggestions: Vec<(SuggestionKind, String, Option<Span>)>,
-}
-
-/// This traits expands `Result<T, Into<Diagnostic>>` with some handy shortcuts.
-pub trait ResultExt {
- type Ok;
-
- /// Behaves like `Result::unwrap`: if self is `Ok` yield the contained value,
- /// otherwise abort macro execution via `abort!`.
- fn unwrap_or_abort(self) -> Self::Ok;
-
- /// Behaves like `Result::expect`: if self is `Ok` yield the contained value,
- /// otherwise abort macro execution via `abort!`.
- /// If it aborts then resulting error message will be preceded with `message`.
- fn expect_or_abort(self, msg: &str) -> Self::Ok;
-}
-
-/// This traits expands `Option` with some handy shortcuts.
-pub trait OptionExt {
- type Some;
-
- /// Behaves like `Option::expect`: if self is `Some` yield the contained value,
- /// otherwise abort macro execution via `abort_call_site!`.
- /// If it aborts the `message` will be used for [`compile_error!`][compl_err] invocation.
- ///
- /// [compl_err]: https://doc.rust-lang.org/std/macro.compile_error.html
- fn expect_or_abort(self, msg: &str) -> Self::Some;
-}
-
-impl Diagnostic {
- /// Create a new diagnostic message that points to `Span::call_site()`
- pub fn new(level: Level, message: String) -> Self {
- Diagnostic::spanned(Span::call_site(), level, message)
- }
-
- /// Create a new diagnostic message that points to the `span`
- pub fn spanned(span: Span, level: Level, message: String) -> Self {
- Diagnostic {
- level,
- span,
- msg: message,
- suggestions: vec![],
- }
- }
-
- /// Attach a "help" note to your main message, note will have it's own span on nightly.
- ///
- /// # Span
- ///
- /// The span is ignored on stable, the note effectively inherits its parent's (main message) span
- pub fn span_help(mut self, span: Span, msg: String) -> Self {
- self.suggestions
- .push((SuggestionKind::Help, msg, Some(span)));
- self
- }
-
- /// Attach a "help" note to your main message,
- pub fn help(mut self, msg: String) -> Self {
- self.suggestions.push((SuggestionKind::Help, msg, None));
- self
- }
-
- /// Attach a note to your main message, note will have it's own span on nightly.
- ///
- /// # Span
- ///
- /// The span is ignored on stable, the note effectively inherits its parent's (main message) span
- pub fn span_note(mut self, span: Span, msg: String) -> Self {
- self.suggestions
- .push((SuggestionKind::Note, msg, Some(span)));
- self
- }
-
- /// Attach a note to your main message
- pub fn note(mut self, msg: String) -> Self {
- self.suggestions.push((SuggestionKind::Note, msg, None));
- self
- }
-
- /// The message of main warning/error (no notes attached)
- pub fn message(&self) -> &str {
- &self.msg
- }
-
- /// Abort the proc-macro's execution and display the diagnostic.
- ///
- /// # Warnings
- ///
- /// Warnings do not get emitted on stable/beta but this function will abort anyway.
- pub fn abort(self) -> ! {
- self.emit();
- abort_now()
- }
-
- /// Display the diagnostic while not aborting macro execution.
- ///
- /// # Warnings
- ///
- /// Warnings are ignored on stable/beta
- pub fn emit(self) {
- imp::emit_diagnostic(self);
- }
-}
-
-/// Abort macro execution and display all the emitted errors, if any.
-///
-/// Does nothing if no errors were emitted (warnings do not count).
-pub fn abort_if_dirty() {
- imp::abort_if_dirty();
-}
-
-#[doc(hidden)]
-impl Diagnostic {
- pub fn span_suggestion(self, span: Span, suggestion: &str, msg: String) -> Self {
- match suggestion {
- "help" | "hint" => self.span_help(span, msg),
- _ => self.span_note(span, msg),
- }
- }
-
- pub fn suggestion(self, suggestion: &str, msg: String) -> Self {
- match suggestion {
- "help" | "hint" => self.help(msg),
- _ => self.note(msg),
- }
- }
-}
-
-impl ToTokens for Diagnostic {
- fn to_tokens(&self, ts: &mut TokenStream) {
- use std::borrow::Cow;
-
- fn ensure_lf(buf: &mut String, s: &str) {
- if s.ends_with('\n') {
- buf.push_str(s);
- } else {
- buf.push_str(s);
- buf.push('\n');
- }
- }
-
- let Diagnostic {
- ref msg,
- ref suggestions,
- ref level,
- ..
- } = *self;
-
- if *level == Level::Warning {
- return;
- }
-
- let message = if suggestions.is_empty() {
- Cow::Borrowed(msg)
- } else {
- let mut message = String::new();
- ensure_lf(&mut message, msg);
- message.push('\n');
-
- for (kind, note, _span) in suggestions {
- message.push_str(" = ");
- message.push_str(kind.name());
- message.push_str(": ");
- ensure_lf(&mut message, note);
- }
- message.push('\n');
-
- Cow::Owned(message)
- };
-
- let span = &self.span;
- let msg = syn::LitStr::new(&*message, *span);
- ts.extend(quote_spanned!(*span=> compile_error!(#msg); ));
- }
-}
-
-impl<T, E: Into<Diagnostic>> ResultExt for Result<T, E> {
- type Ok = T;
-
- fn unwrap_or_abort(self) -> T {
- match self {
- Ok(res) => res,
- Err(e) => e.into().abort(),
- }
- }
-
- fn expect_or_abort(self, message: &str) -> T {
- match self {
- Ok(res) => res,
- Err(e) => {
- let mut e = e.into();
- e.msg = format!("{}: {}", message, e.msg);
- e.abort()
- }
- }
- }
-}
-
-impl<T> OptionExt for Option<T> {
- type Some = T;
-
- fn expect_or_abort(self, message: &str) -> T {
- match self {
- Some(res) => res,
- None => abort_call_site!(message),
- }
- }
-}
-
-#[derive(Debug)]
-enum SuggestionKind {
- Help,
- Note,
-}
-
-impl SuggestionKind {
- fn name(&self) -> &'static str {
- match self {
- SuggestionKind::Note => "note",
- SuggestionKind::Help => "help",
- }
- }
-}
-
-impl From<syn::Error> for Diagnostic {
- fn from(e: syn::Error) -> Self {
- Diagnostic::spanned(e.span(), Level::Error, e.to_string())
- }
-}
-
-/// This is the entry point for a proc-macro.
-///
-/// **NOT PUBLIC API, SUBJECT TO CHANGE WITHOUT ANY NOTICE**
-#[doc(hidden)]
-pub fn entry_point<F>(f: F, proc_macro_hack: bool) -> proc_macro::TokenStream
-where
- F: FnOnce() -> proc_macro::TokenStream + UnwindSafe,
-{
- ENTERED_ENTRY_POINT.with(|flag| flag.set(true));
- let caught = catch_unwind(f);
- let dummy = dummy::cleanup();
- let err_storage = imp::cleanup();
- ENTERED_ENTRY_POINT.with(|flag| flag.set(false));
-
- let mut appendix = TokenStream::new();
- if proc_macro_hack {
- appendix.extend(quote! {
- #[allow(unused)]
- macro_rules! proc_macro_call {
- () => ( unimplemented!() )
- }
- });
- }
-
- match caught {
- Ok(ts) => {
- if err_storage.is_empty() {
- ts
- } else {
- quote!( #(#err_storage)* #dummy #appendix ).into()
- }
- }
-
- Err(boxed) => match boxed.downcast::<AbortNow>() {
- Ok(_) => quote!( #(#err_storage)* #dummy #appendix ).into(),
- Err(boxed) => resume_unwind(boxed),
- },
- }
-}
-
-fn abort_now() -> ! {
- check_correctness();
- panic!(AbortNow)
-}
-
-thread_local! {
- static ENTERED_ENTRY_POINT: Cell<bool> = Cell::new(false);
-}
-
-struct AbortNow;
-
-fn check_correctness() {
- if !ENTERED_ENTRY_POINT.with(|flag| flag.get()) {
- panic!(
- "proc-macro-error API cannot be used outside of `entry_point` invocation, \
- perhaps you forgot to annotate your #[proc_macro] function with `#[proc_macro_error]"
- );
- }
-}
diff --git a/proc-macro-error/proc-macro-error/src/macros.rs b/proc-macro-error/proc-macro-error/src/macros.rs
deleted file mode 100644
index 117612c..0000000
--- a/proc-macro-error/proc-macro-error/src/macros.rs
+++ /dev/null
@@ -1,257 +0,0 @@
-// FIXME: this can be greatly simplified via $()?
-// as soon as MRSV hits 1.32
-
-/// Build [`Diagnostic`](struct.Diagnostic.html) instance from provided arguments.
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-///
-#[macro_export]
-macro_rules! diagnostic {
- // from alias
- ($err:expr) => { $crate::Diagnostic::from($err) };
-
- // span, message, help
- ($span:expr, $level:expr, $fmt:expr, $($args:expr),+ ; $($rest:tt)+) => {{
- let diag = $crate::Diagnostic::spanned(
- $span.into(),
- $level,
- format!($fmt, $($args),*)
- );
- $crate::__pme__suggestions!(diag $($rest)*);
- diag
- }};
-
- ($span:expr, $level:expr, $msg:expr ; $($rest:tt)+) => {{
- let diag = $crate::Diagnostic::spanned($span.into(), $level, $msg.to_string());
- $crate::__pme__suggestions!(diag $($rest)*);
- diag
- }};
-
- // span, message, no help
- ($span:expr, $level:expr, $fmt:expr, $($args:expr),+) => {{
- $crate::Diagnostic::spanned(
- $span.into(),
- $level,
- format!($fmt, $($args),*)
- )
- }};
-
- ($span:expr, $level:expr, $msg:expr) => {{
- $crate::Diagnostic::spanned($span.into(), $level, $msg.to_string())
- }};
-
-
- // trailing commas
-
- ($span:expr, $level:expr, $fmt:expr, $($args:expr),+, ; $($rest:tt)+) => {
- $crate::diagnostic!($span, $level, $fmt, $($args),* ; $($rest)*)
- };
- ($span:expr, $level:expr, $msg:expr, ; $($rest:tt)+) => {
- $crate::diagnostic!($span, $level, $msg ; $($rest)*)
- };
- ($span:expr, $level:expr, $fmt:expr, $($args:expr),+,) => {
- $crate::diagnostic!($span, $level, $fmt, $($args),*)
- };
- ($span:expr, $level:expr, $msg:expr,) => {
- $crate::diagnostic!($span, $level, $msg)
- };
- // ($err:expr,) => { $crate::diagnostic!($err) };
-}
-
-/// Abort proc-macro execution right now and display the error.
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-#[macro_export]
-macro_rules! abort {
- ($err:expr) => {
- $crate::diagnostic!($err).abort()
- };
-
- ($span:expr, $($tts:tt)*) => {
- $crate::diagnostic!($span, $crate::Level::Error, $($tts)*).abort()
- };
-}
-
-/// Shortcut for `abort!(Span::call_site(), msg...)`. This macro
-/// is still preferable over plain panic, panics are not for error reporting.
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-///
-#[macro_export]
-macro_rules! abort_call_site {
- ($($tts:tt)*) => {
- $crate::diagnostic!(
- $crate::proc_macro2::Span::call_site(),
- $crate::Level::Error,
- $($tts)*
- ).abort()
- };
-}
-
-/// Emit an error while not aborting the proc-macro right away.
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-///
-#[macro_export]
-macro_rules! emit_error {
- ($err:expr) => {
- $crate::diagnostic!($err).emit()
- };
-
- ($span:expr, $($tts:tt)*) => {{
- let level = $crate::Level::Error;
- $crate::diagnostic!($span, level, $($tts)*).emit()
- }};
-}
-
-/// Shortcut for `emit_error!(Span::call_site(), ...)`. This macro
-/// is still preferable over plain panic, panics are not for error reporting..
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-///
-#[macro_export]
-macro_rules! emit_call_site_error {
- ($($tts:tt)*) => {
- $crate::diagnostic!(
- $crate::proc_macro2::Span()::call_site(),
- $crate::Level::Error,
- $($tts)*
- ).emit()
- };
-}
-
-/// Emit a warning. Warnings are not errors and compilation won't fail because of them.
-///
-/// **Does nothing on stable**
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-///
-#[macro_export]
-macro_rules! emit_warning {
- ($span:expr, $($tts:tt)*) => {
- $crate::diagnostic!($span, $crate::Level::Warning, $($tts)*).emit()
- };
-}
-
-/// Shortcut for `emit_warning!(Span::call_site(), ...)`.
-///
-/// **Does nothing on stable**
-///
-/// # Syntax
-///
-/// See [the guide](index.html#guide).
-///
-#[macro_export]
-macro_rules! emit_call_site_warning {
- ($($tts:tt)*) => {{
- let span = $crate::proc_macro2::Span()::call_site();
- $crate::diagnostic!(span, $crate::Level::Warning, $($tts)*).emit()
- }};
-}
-
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __pme__suggestions {
- ($var:ident) => ();
-
- ($var:ident $help:ident =? $msg:expr) => {
- let $var = if let Some(msg) = $msg {
- $var.suggestion(stringify!($help), msg.to_string())
- } else {
- $var
- };
- };
- ($var:ident $help:ident =? $span:expr => $msg:expr) => {
- let $var = if let Some(msg) = $msg {
- $var.span_suggestion($span.into(), stringify!($help), msg.to_string())
- } else {
- $var
- };
- };
-
- ($var:ident $help:ident =? $msg:expr ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help =? $msg);
- $crate::__pme__suggestions!($var $($rest)*);
- };
- ($var:ident $help:ident =? $span:expr => $msg:expr ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help =? $span => $msg);
- $crate::__pme__suggestions!($var $($rest)*);
- };
-
-
- ($var:ident $help:ident = $msg:expr) => {
- let $var = $var.suggestion(stringify!($help), $msg.to_string());
- };
- ($var:ident $help:ident = $fmt:expr, $($args:expr),+) => {
- let $var = $var.suggestion(
- stringify!($help),
- format!($fmt, $($args),*)
- );
- };
- ($var:ident $help:ident = $span:expr => $msg:expr) => {
- let $var = $var.span_suggestion($span.into(), stringify!($help), $msg.to_string());
- };
- ($var:ident $help:ident = $span:expr => $fmt:expr, $($args:expr),+) => {
- let $var = $var.span_suggestion(
- $span.into(),
- stringify!($help),
- format!($fmt, $($args),*)
- );
- };
-
- ($var:ident $help:ident = $msg:expr ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $msg);
- $crate::__pme__suggestions!($var $($rest)*);
- };
- ($var:ident $help:ident = $fmt:expr, $($args:expr),+ ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $fmt, $($args),*);
- $crate::__pme__suggestions!($var $($rest)*);
- };
- ($var:ident $help:ident = $span:expr => $msg:expr ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $span => $msg);
- $crate::__pme__suggestions!($var $($rest)*);
- };
- ($var:ident $help:ident = $span:expr => $fmt:expr, $($args:expr),+ ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $span => $fmt, $($args),*);
- $crate::__pme__suggestions!($var $($rest)*);
- };
-
- // trailing commas
-
- ($var:ident $help:ident = $msg:expr,) => {
- $crate::__pme__suggestions!($var $help = $msg)
- };
- ($var:ident $help:ident = $fmt:expr, $($args:expr),+,) => {
- $crate::__pme__suggestions!($var $help = $fmt, $($args)*)
- };
- ($var:ident $help:ident = $span:expr => $msg:expr,) => {
- $crate::__pme__suggestions!($var $help = $span => $msg)
- };
- ($var:ident $help:ident = $span:expr => $fmt:expr, $($args:expr),*,) => {
- $crate::__pme__suggestions!($var $help = $span => $fmt, $($args)*)
- };
- ($var:ident $help:ident = $msg:expr, ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $msg; $($rest)*)
- };
- ($var:ident $help:ident = $fmt:expr, $($args:expr),+, ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $fmt, $($args),*; $($rest)*)
- };
- ($var:ident $help:ident = $span:expr => $msg:expr, ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $span => $msg; $($rest)*)
- };
- ($var:ident $help:ident = $span:expr => $fmt:expr, $($args:expr),+, ; $($rest:tt)*) => {
- $crate::__pme__suggestions!($var $help = $span => $fmt, $($args),*; $($rest)*)
- };
-}
diff --git a/proc-macro-error/proc-macro-error/src/nightly.rs b/proc-macro-error/proc-macro-error/src/nightly.rs
deleted file mode 100644
index d053c2f..0000000
--- a/proc-macro-error/proc-macro-error/src/nightly.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-use std::sync::atomic::{AtomicBool, Ordering};
-
-use proc_macro::{Diagnostic as PDiag, Level as PLevel};
-
-use crate::{abort_now, check_correctness, Diagnostic, Level, SuggestionKind};
-
-pub fn abort_if_dirty() {
- check_correctness();
- if IS_DIRTY.load(Ordering::SeqCst) {
- abort_now()
- }
-}
-
-pub(crate) fn cleanup() -> Vec<Diagnostic> {
- vec![]
-}
-
-pub(crate) fn emit_diagnostic(diag: Diagnostic) {
- let Diagnostic {
- level,
- span,
- msg,
- suggestions,
- } = diag;
-
- let level = match level {
- Level::Warning => PLevel::Warning,
- Level::Error => {
- IS_DIRTY.store(true, Ordering::SeqCst);
- PLevel::Error
- }
- _ => unreachable!(),
- };
-
- let mut res = PDiag::spanned(span.unwrap(), level, msg);
-
- for (kind, msg, span) in suggestions {
- res = match (kind, span) {
- (SuggestionKind::Note, Some(span)) => res.span_note(span.unwrap(), msg),
- (SuggestionKind::Help, Some(span)) => res.span_help(span.unwrap(), msg),
- (SuggestionKind::Note, None) => res.note(msg),
- (SuggestionKind::Help, None) => res.help(msg),
- }
- }
-
- res.emit()
-}
-
-static IS_DIRTY: AtomicBool = AtomicBool::new(false);
diff --git a/proc-macro-error/proc-macro-error/src/stable.rs b/proc-macro-error/proc-macro-error/src/stable.rs
deleted file mode 100644
index 07042d3..0000000
--- a/proc-macro-error/proc-macro-error/src/stable.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-use std::cell::RefCell;
-
-use crate::{abort_now, check_correctness, Diagnostic, Level};
-
-pub fn abort_if_dirty() {
- check_correctness();
- ERR_STORAGE.with(|storage| {
- if !storage.borrow().is_empty() {
- abort_now()
- }
- });
-}
-
-pub(crate) fn cleanup() -> Vec<Diagnostic> {
- ERR_STORAGE.with(|storage| storage.replace(Vec::new()))
-}
-
-pub(crate) fn emit_diagnostic(diag: Diagnostic) {
- if diag.level == Level::Error {
- ERR_STORAGE.with(|storage| storage.borrow_mut().push(diag));
- }
-}
-
-thread_local! {
- static ERR_STORAGE: RefCell<Vec<Diagnostic>> = RefCell::new(Vec::new());
-}
diff --git a/proc-macro-error/test-crate/Cargo.toml b/proc-macro-error/test-crate/Cargo.toml
deleted file mode 100644
index 96dadc3..0000000
--- a/proc-macro-error/test-crate/Cargo.toml
+++ /dev/null
@@ -1,20 +0,0 @@
-[package]
-name = "test-crate"
-version = "0.0.0"
-authors = ["CreepySkeleton <creepy-skeleton@yandex.ru>"]
-edition = "2018"
-publish = false
-
-[lib]
-proc-macro = true
-
-[dependencies]
-proc-macro-error = { path = "../proc-macro-error"}
-quote = "1"
-proc-macro2 = "1"
-syn = {version = "1", default-features = false }
-
-[dev-dependencies]
-trybuild = "1.0"
-rustversion = "1.0"
-toml = "=0.5.2" # DO NOT BUMP
diff --git a/proc-macro-error/test-crate/src/lib.rs b/proc-macro-error/test-crate/src/lib.rs
deleted file mode 100644
index 2ea9175..0000000
--- a/proc-macro-error/test-crate/src/lib.rs
+++ /dev/null
@@ -1,123 +0,0 @@
-#[macro_use]
-extern crate proc_macro_error;
-#[macro_use]
-extern crate syn;
-extern crate proc_macro;
-
-use proc_macro2::Span;
-use proc_macro_error::{set_dummy, Level, OptionExt, ResultExt};
-use syn::{
- parse::{Parse, ParseStream},
- punctuated::Punctuated,
- spanned::Spanned,
- Ident,
-};
-
-struct IdentOrUnderscore {
- span: Span,
- part: String,
-}
-
-impl IdentOrUnderscore {
- fn new(span: Span, part: String) -> Self {
- IdentOrUnderscore { span, part }
- }
-}
-
-impl Parse for IdentOrUnderscore {
- fn parse(input: ParseStream) -> syn::Result<Self> {
- let la = input.lookahead1();
-
- if la.peek(Ident) {
- let t = input.parse::<Ident>().unwrap();
- Ok(IdentOrUnderscore::new(t.span(), t.to_string()))
- } else if la.peek(Token![_]) {
- let t = input.parse::<Token![_]>().unwrap();
- Ok(IdentOrUnderscore::new(t.span(), "_".to_string()))
- } else {
- Err(la.error())
- }
- }
-}
-
-struct Args(Vec<IdentOrUnderscore>);
-
-impl Parse for Args {
- fn parse(input: ParseStream) -> syn::Result<Self> {
- let args = Punctuated::<_, Token![,]>::parse_terminated(input)?;
- Ok(Args(args.into_iter().collect()))
- }
-}
-
-#[proc_macro]
-#[proc_macro_error]
-pub fn make_fn(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
- let mut name = String::new();
- let input = parse_macro_input!(input as Args);
-
- for arg in input.0 {
- match &*arg.part {
- "abort" => abort!(
- arg.span,
- "abort! 3{} args {}", "+", "test";
- hint = "help {} test", "message"
- ),
-
- "abort_call_site" => abort_call_site!(
- "abort_call_site! 2{} args {}", "+", "test";
- help = "help {} test", "message"
- ),
-
- "direct_abort" => {
- diagnostic!(arg.span, Level::Error, "direct MacroError::abort() test").abort()
- }
-
- "result_expect" => {
- let e = syn::Error::new(arg.span, "error");
- Err(e).expect_or_abort("Result::expect_or_abort() test")
- }
-
- "result_unwrap" => {
- let e = syn::Error::new(arg.span, "Result::unwrap_or_abort() test");
- Err(e).unwrap_or_abort()
- }
-
- "option_expect" => None.expect_or_abort("Option::expect_or_abort() test"),
-
- "need_default" => {
- set_dummy(quote! {
- impl Default for NeedDefault {
- fn default() -> Self {
- NeedDefault::A
- }
- }
- });
-
- abort!(arg.span, "set_dummy test")
- }
-
- part if part.starts_with("multi") => {
- let no_help: Option<String> = Option::None;
- let help = Some("Option help test");
- emit_error!(
- arg.span,
- "multiple error part: {}", part;
- note = "help {} test", "message";
- hint =? help;
- wow = "I see what you did here...";
- help =? no_help
- )
- }
-
- _ => name.push_str(&arg.part),
- }
- }
-
- // test that unrelated panics are not affected
- if name.is_empty() {
- panic!("unrelated panic test")
- }
-
- let name = Ident::new(&name, Span::call_site());
- quote!( fn #name() {} ).into()
-}
diff --git a/proc-macro-error/test-crate/tests/macro-errors.rs b/proc-macro-error/test-crate/tests/macro-errors.rs
deleted file mode 100644
index 8c672eb..0000000
--- a/proc-macro-error/test-crate/tests/macro-errors.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#[rustversion::attr(any(not(stable), before(1.39)), ignore)]
-#[test]
-fn ui() {
- let t = trybuild::TestCases::new();
- t.compile_fail("tests/ui/*.rs");
-}
diff --git a/proc-macro-error/test-crate/tests/ok.rs b/proc-macro-error/test-crate/tests/ok.rs
deleted file mode 100644
index 9b6a3d1..0000000
--- a/proc-macro-error/test-crate/tests/ok.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-extern crate test_crate;
-
-use test_crate::make_fn;
-
-make_fn!(it, _, works);
-
-fn main() {
- it_works();
-}
diff --git a/proc-macro-error/test-crate/tests/ui/abort.rs b/proc-macro-error/test-crate/tests/ui/abort.rs
deleted file mode 100644
index 717d772..0000000
--- a/proc-macro-error/test-crate/tests/ui/abort.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(abort);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/abort.stderr b/proc-macro-error/test-crate/tests/ui/abort.stderr
deleted file mode 100644
index 7c4e6a0..0000000
--- a/proc-macro-error/test-crate/tests/ui/abort.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: abort! 3+ args test
-
- = help: help message test
-
- --> $DIR/abort.rs:4:10
- |
-4 | make_fn!(abort);
- | ^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/call_site.rs b/proc-macro-error/test-crate/tests/ui/call_site.rs
deleted file mode 100644
index 7184cc4..0000000
--- a/proc-macro-error/test-crate/tests/ui/call_site.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(abort_call_site);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/call_site.stderr b/proc-macro-error/test-crate/tests/ui/call_site.stderr
deleted file mode 100644
index d630a3a..0000000
--- a/proc-macro-error/test-crate/tests/ui/call_site.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: abort_call_site! 2+ args test
-
- = help: help message test
-
- --> $DIR/call_site.rs:4:1
- |
-4 | make_fn!(abort_call_site);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation
diff --git a/proc-macro-error/test-crate/tests/ui/direct_abort.rs b/proc-macro-error/test-crate/tests/ui/direct_abort.rs
deleted file mode 100644
index b5a4c97..0000000
--- a/proc-macro-error/test-crate/tests/ui/direct_abort.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(direct_abort);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/direct_abort.stderr b/proc-macro-error/test-crate/tests/ui/direct_abort.stderr
deleted file mode 100644
index 7cfbae8..0000000
--- a/proc-macro-error/test-crate/tests/ui/direct_abort.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: direct MacroError::abort() test
- --> $DIR/direct_abort.rs:4:10
- |
-4 | make_fn!(direct_abort);
- | ^^^^^^^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/dummy.rs b/proc-macro-error/test-crate/tests/ui/dummy.rs
deleted file mode 100644
index 7514fe0..0000000
--- a/proc-macro-error/test-crate/tests/ui/dummy.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-enum NeedDefault {
- A,
- B
-}
-
-make_fn!(need_default);
-
-fn main() {
- let _ = NeedDefault::default();
-}
-
-
-
diff --git a/proc-macro-error/test-crate/tests/ui/dummy.stderr b/proc-macro-error/test-crate/tests/ui/dummy.stderr
deleted file mode 100644
index fd531be..0000000
--- a/proc-macro-error/test-crate/tests/ui/dummy.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: set_dummy test
- --> $DIR/dummy.rs:9:10
- |
-9 | make_fn!(need_default);
- | ^^^^^^^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/multi-error.rs b/proc-macro-error/test-crate/tests/ui/multi-error.rs
deleted file mode 100644
index 07fbb03..0000000
--- a/proc-macro-error/test-crate/tests/ui/multi-error.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(multi1, multi2, _, multi3);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/multi-error.stderr b/proc-macro-error/test-crate/tests/ui/multi-error.stderr
deleted file mode 100644
index 25174d5..0000000
--- a/proc-macro-error/test-crate/tests/ui/multi-error.stderr
+++ /dev/null
@@ -1,32 +0,0 @@
-error: multiple error part: multi1
-
- = note: help message test
- = help: Option help test
- = note: I see what you did here...
-
- --> $DIR/multi-error.rs:4:10
- |
-4 | make_fn!(multi1, multi2, _, multi3);
- | ^^^^^^
-
-error: multiple error part: multi2
-
- = note: help message test
- = help: Option help test
- = note: I see what you did here...
-
- --> $DIR/multi-error.rs:4:18
- |
-4 | make_fn!(multi1, multi2, _, multi3);
- | ^^^^^^
-
-error: multiple error part: multi3
-
- = note: help message test
- = help: Option help test
- = note: I see what you did here...
-
- --> $DIR/multi-error.rs:4:29
- |
-4 | make_fn!(multi1, multi2, _, multi3);
- | ^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/not_proc_macro.rs b/proc-macro-error/test-crate/tests/ui/not_proc_macro.rs
deleted file mode 100644
index e241c5c..0000000
--- a/proc-macro-error/test-crate/tests/ui/not_proc_macro.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-use proc_macro_error::proc_macro_error;
-
-#[proc_macro_error]
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/not_proc_macro.stderr b/proc-macro-error/test-crate/tests/ui/not_proc_macro.stderr
deleted file mode 100644
index 52d6a09..0000000
--- a/proc-macro-error/test-crate/tests/ui/not_proc_macro.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: #[proc_macro_error] attribute can be used only with a proc-macro
-
- hint: if you are really sure that #[proc_macro_error] should be applied to this exact function use #[proc_macro_error(allow_not_macro)]
-
- --> $DIR/not_proc_macro.rs:3:1
- |
-3 | #[proc_macro_error]
- | ^^^^^^^^^^^^^^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/option_expect.rs b/proc-macro-error/test-crate/tests/ui/option_expect.rs
deleted file mode 100644
index 20288ca..0000000
--- a/proc-macro-error/test-crate/tests/ui/option_expect.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(option_expect);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/option_expect.stderr b/proc-macro-error/test-crate/tests/ui/option_expect.stderr
deleted file mode 100644
index dd9ecd8..0000000
--- a/proc-macro-error/test-crate/tests/ui/option_expect.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Option::expect_or_abort() test
- --> $DIR/option_expect.rs:4:1
- |
-4 | make_fn!(option_expect);
- | ^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation
diff --git a/proc-macro-error/test-crate/tests/ui/result_expect.rs b/proc-macro-error/test-crate/tests/ui/result_expect.rs
deleted file mode 100644
index a42740b..0000000
--- a/proc-macro-error/test-crate/tests/ui/result_expect.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(result_expect);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/result_expect.stderr b/proc-macro-error/test-crate/tests/ui/result_expect.stderr
deleted file mode 100644
index c2dd81c..0000000
--- a/proc-macro-error/test-crate/tests/ui/result_expect.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Result::expect_or_abort() test: error
- --> $DIR/result_expect.rs:4:10
- |
-4 | make_fn!(result_expect);
- | ^^^^^^^^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/result_unwrap.rs b/proc-macro-error/test-crate/tests/ui/result_unwrap.rs
deleted file mode 100644
index 9b7fb1c..0000000
--- a/proc-macro-error/test-crate/tests/ui/result_unwrap.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!(result_unwrap);
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/result_unwrap.stderr b/proc-macro-error/test-crate/tests/ui/result_unwrap.stderr
deleted file mode 100644
index 2e614bd..0000000
--- a/proc-macro-error/test-crate/tests/ui/result_unwrap.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Result::unwrap_or_abort() test
- --> $DIR/result_unwrap.rs:4:10
- |
-4 | make_fn!(result_unwrap);
- | ^^^^^^^^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/unknown_setting.rs b/proc-macro-error/test-crate/tests/ui/unknown_setting.rs
deleted file mode 100644
index d8e58ea..0000000
--- a/proc-macro-error/test-crate/tests/ui/unknown_setting.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-use proc_macro_error::proc_macro_error;
-
-#[proc_macro_error(allow_not_macro, assert_unwind_safe, trololo)]
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/unknown_setting.stderr b/proc-macro-error/test-crate/tests/ui/unknown_setting.stderr
deleted file mode 100644
index a55de0b..0000000
--- a/proc-macro-error/test-crate/tests/ui/unknown_setting.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: unknown setting `trololo`, expected one of `assert_unwind_safe`, `allow_not_macro`, `proc_macro_hack`
- --> $DIR/unknown_setting.rs:3:57
- |
-3 | #[proc_macro_error(allow_not_macro, assert_unwind_safe, trololo)]
- | ^^^^^^^
diff --git a/proc-macro-error/test-crate/tests/ui/unrelated_panic.rs b/proc-macro-error/test-crate/tests/ui/unrelated_panic.rs
deleted file mode 100644
index 4863e5b..0000000
--- a/proc-macro-error/test-crate/tests/ui/unrelated_panic.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-extern crate test_crate;
-use test_crate::make_fn;
-
-make_fn!();
-
-fn main() {}
diff --git a/proc-macro-error/test-crate/tests/ui/unrelated_panic.stderr b/proc-macro-error/test-crate/tests/ui/unrelated_panic.stderr
deleted file mode 100644
index b852cfd..0000000
--- a/proc-macro-error/test-crate/tests/ui/unrelated_panic.stderr
+++ /dev/null
@@ -1,7 +0,0 @@
-error: proc macro panicked
- --> $DIR/unrelated_panic.rs:4:1
- |
-4 | make_fn!();
- | ^^^^^^^^^^^
- |
- = help: message: unrelated panic test
diff --git a/proc-macro2/.gitignore b/proc-macro2/.gitignore
deleted file mode 100644
index 6936990..0000000
--- a/proc-macro2/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/target
-**/*.rs.bk
-Cargo.lock
diff --git a/proc-macro2/.travis.yml b/proc-macro2/.travis.yml
deleted file mode 100644
index acddb57..0000000
--- a/proc-macro2/.travis.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-language: rust
-sudo: false
-
-matrix:
- include:
- - rust: 1.31.0
- - rust: stable
- - rust: beta
- - rust: nightly
- script:
- - cargo test
- - cargo test --no-default-features
- - cargo test --no-default-features -- --ignored # run the ignored test to make sure the `proc-macro` feature is disabled
- - cargo test --features span-locations
- - RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test
- - RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test --no-default-features
- - RUSTFLAGS='-Z allow-features=' cargo test
- - cargo update -Z minimal-versions && cargo build
- - rust: nightly
- name: WebAssembly
- install: rustup target add wasm32-unknown-unknown
- script: cargo test --target wasm32-unknown-unknown --no-run
-
-before_script:
- - set -o errexit
-
-script:
- - cargo test
- - cargo test --no-default-features
- - cargo test --features span-locations
- - RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test
- - RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test --no-default-features
-
-notifications:
- email:
- on_success: never
diff --git a/proc-macro2/Cargo.toml b/proc-macro2/Cargo.toml
deleted file mode 100644
index a7d0865..0000000
--- a/proc-macro2/Cargo.toml
+++ /dev/null
@@ -1,57 +0,0 @@
-[package]
-name = "proc-macro2"
-version = "1.0.7" # remember to update html_root_url
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-license = "MIT OR Apache-2.0"
-readme = "README.md"
-keywords = ["macros"]
-repository = "https://github.com/alexcrichton/proc-macro2"
-homepage = "https://github.com/alexcrichton/proc-macro2"
-documentation = "https://docs.rs/proc-macro2"
-edition = "2018"
-description = """
-A stable implementation of the upcoming new `proc_macro` API. Comes with an
-option, off by default, to also reimplement itself in terms of the upstream
-unstable API.
-"""
-
-[package.metadata.docs.rs]
-rustc-args = ["--cfg", "procmacro2_semver_exempt"]
-rustdoc-args = ["--cfg", "procmacro2_semver_exempt"]
-
-[dependencies]
-unicode-xid = "0.2"
-
-[dev-dependencies]
-quote = { version = "1.0", default_features = false }
-
-[features]
-proc-macro = []
-default = ["proc-macro"]
-
-# Expose methods Span::start and Span::end which give the line/column location
-# of a token.
-span-locations = []
-
-# This feature no longer means anything.
-nightly = []
-
-[badges]
-travis-ci = { repository = "alexcrichton/proc-macro2" }
-
-[workspace]
-members = ["benches/bench-libproc-macro"]
-
-[patch.crates-io]
-# Our doc tests depend on quote which depends on proc-macro2. Without this line,
-# the proc-macro2 dependency of quote would be the released version of
-# proc-macro2. Quote would implement its traits for types from that proc-macro2,
-# meaning impls would be missing when tested against types from the local
-# proc-macro2.
-#
-# Travis builds that are in progress at the time that you publish may spuriously
-# fail. This is because they'll be building a local proc-macro2 which carries
-# the second-most-recent version number, pulling in quote which resolves to a
-# dependency on the just-published most recent version number. Thus the patch
-# will fail to apply because the version numbers are different.
-proc-macro2 = { path = "." }
diff --git a/proc-macro2/LICENSE-APACHE b/proc-macro2/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/proc-macro2/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/proc-macro2/LICENSE-MIT b/proc-macro2/LICENSE-MIT
deleted file mode 100644
index 39e0ed6..0000000
--- a/proc-macro2/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/proc-macro2/README.md b/proc-macro2/README.md
deleted file mode 100644
index 19b0c3b..0000000
--- a/proc-macro2/README.md
+++ /dev/null
@@ -1,93 +0,0 @@
-# proc-macro2
-
-[![Build Status](https://api.travis-ci.com/alexcrichton/proc-macro2.svg?branch=master)](https://travis-ci.com/alexcrichton/proc-macro2)
-[![Latest Version](https://img.shields.io/crates/v/proc-macro2.svg)](https://crates.io/crates/proc-macro2)
-[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/proc-macro2)
-
-A wrapper around the procedural macro API of the compiler's `proc_macro` crate.
-This library serves two purposes:
-
-- **Bring proc-macro-like functionality to other contexts like build.rs and
- main.rs.** Types from `proc_macro` are entirely specific to procedural macros
- and cannot ever exist in code outside of a procedural macro. Meanwhile
- `proc_macro2` types may exist anywhere including non-macro code. By developing
- foundational libraries like [syn] and [quote] against `proc_macro2` rather
- than `proc_macro`, the procedural macro ecosystem becomes easily applicable to
- many other use cases and we avoid reimplementing non-macro equivalents of
- those libraries.
-
-- **Make procedural macros unit testable.** As a consequence of being specific
- to procedural macros, nothing that uses `proc_macro` can be executed from a
- unit test. In order for helper libraries or components of a macro to be
- testable in isolation, they must be implemented using `proc_macro2`.
-
-[syn]: https://github.com/dtolnay/syn
-[quote]: https://github.com/dtolnay/quote
-
-## Usage
-
-```toml
-[dependencies]
-proc-macro2 = "1.0"
-```
-
-The skeleton of a typical procedural macro typically looks like this:
-
-```rust
-extern crate proc_macro;
-
-#[proc_macro_derive(MyDerive)]
-pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
- let input = proc_macro2::TokenStream::from(input);
-
- let output: proc_macro2::TokenStream = {
- /* transform input */
- };
-
- proc_macro::TokenStream::from(output)
-}
-```
-
-If parsing with [Syn], you'll use [`parse_macro_input!`] instead to propagate
-parse errors correctly back to the compiler when parsing fails.
-
-[`parse_macro_input!`]: https://docs.rs/syn/1.0/syn/macro.parse_macro_input.html
-
-## Unstable features
-
-The default feature set of proc-macro2 tracks the most recent stable compiler
-API. Functionality in `proc_macro` that is not yet stable is not exposed by
-proc-macro2 by default.
-
-To opt into the additional APIs available in the most recent nightly compiler,
-the `procmacro2_semver_exempt` config flag must be passed to rustc. We will
-polyfill those nightly-only APIs back to Rust 1.31.0. As these are unstable APIs
-that track the nightly compiler, minor versions of proc-macro2 may make breaking
-changes to them at any time.
-
-```
-RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build
-```
-
-Note that this must not only be done for your crate, but for any crate that
-depends on your crate. This infectious nature is intentional, as it serves as a
-reminder that you are outside of the normal semver guarantees.
-
-Semver exempt methods are marked as such in the proc-macro2 documentation.
-
-<br>
-
-#### License
-
-<sup>
-Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
-2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
-</sup>
-
-<br>
-
-<sub>
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
-be dual licensed as above, without any additional terms or conditions.
-</sub>
diff --git a/proc-macro2/benches/bench-libproc-macro/Cargo.toml b/proc-macro2/benches/bench-libproc-macro/Cargo.toml
deleted file mode 100644
index 41d106d..0000000
--- a/proc-macro2/benches/bench-libproc-macro/Cargo.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[package]
-name = "bench-libproc-macro"
-version = "0.0.0"
-edition = "2018"
-publish = false
-
-[lib]
-path = "lib.rs"
-proc-macro = true
-
-[[bin]]
-name = "bench-libproc-macro"
-path = "main.rs"
diff --git a/proc-macro2/benches/bench-libproc-macro/README.md b/proc-macro2/benches/bench-libproc-macro/README.md
deleted file mode 100644
index 80e4939..0000000
--- a/proc-macro2/benches/bench-libproc-macro/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-Example output:
-
-```console
-$ cargo check --release
-
- Compiling bench-libproc-macro v0.0.0
-STRING: 8 millis
-TOKENSTREAM: 25721 millis
- Finished release [optimized] target(s) in 26.15s
-```
diff --git a/proc-macro2/benches/bench-libproc-macro/lib.rs b/proc-macro2/benches/bench-libproc-macro/lib.rs
deleted file mode 100644
index 46b3711..0000000
--- a/proc-macro2/benches/bench-libproc-macro/lib.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-extern crate proc_macro;
-
-use proc_macro::{Ident, Punct, Spacing, Span, TokenStream, TokenTree};
-use std::iter::once;
-use std::time::Instant;
-
-const N: u32 = 7000;
-
-#[proc_macro]
-pub fn bench(_input: TokenStream) -> TokenStream {
- let start = Instant::now();
- let mut string = String::new();
- for _ in 0..N {
- string += "core";
- string += ":";
- string += ":";
- string += "option";
- string += ":";
- string += ":";
- string += "Option";
- string += ":";
- string += ":";
- string += "None";
- string += ",";
- }
- string.parse::<TokenStream>().unwrap();
- eprintln!("STRING: {} millis", start.elapsed().as_millis());
-
- let start = Instant::now();
- let span = Span::call_site();
- let mut tokens = TokenStream::new();
- for _ in 0..N {
- // Similar to what is emitted by quote.
- tokens.extend(once(TokenTree::Ident(Ident::new("core", span))));
- tokens.extend(once(TokenTree::Punct(Punct::new(':', Spacing::Joint))));
- tokens.extend(once(TokenTree::Punct(Punct::new(':', Spacing::Alone))));
- tokens.extend(once(TokenTree::Ident(Ident::new("option", span))));
- tokens.extend(once(TokenTree::Punct(Punct::new(':', Spacing::Joint))));
- tokens.extend(once(TokenTree::Punct(Punct::new(':', Spacing::Alone))));
- tokens.extend(once(TokenTree::Ident(Ident::new("Option", span))));
- tokens.extend(once(TokenTree::Punct(Punct::new(':', Spacing::Joint))));
- tokens.extend(once(TokenTree::Punct(Punct::new(':', Spacing::Alone))));
- tokens.extend(once(TokenTree::Ident(Ident::new("None", span))));
- tokens.extend(once(TokenTree::Punct(Punct::new(',', Spacing::Joint))));
- }
- eprintln!("TOKENSTREAM: {} millis", start.elapsed().as_millis());
-
- TokenStream::new()
-}
diff --git a/proc-macro2/benches/bench-libproc-macro/main.rs b/proc-macro2/benches/bench-libproc-macro/main.rs
deleted file mode 100644
index 34eedf6..0000000
--- a/proc-macro2/benches/bench-libproc-macro/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-bench_libproc_macro::bench!();
-
-fn main() {}
diff --git a/proc-macro2/build.rs b/proc-macro2/build.rs
deleted file mode 100644
index deb9b92..0000000
--- a/proc-macro2/build.rs
+++ /dev/null
@@ -1,129 +0,0 @@
-// rustc-cfg emitted by the build script:
-//
-// "use_proc_macro"
-// Link to extern crate proc_macro. Available on any compiler and any target
-// except wasm32. Requires "proc-macro" Cargo cfg to be enabled (default is
-// enabled). On wasm32 we never link to proc_macro even if "proc-macro" cfg
-// is enabled.
-//
-// "wrap_proc_macro"
-// Wrap types from libproc_macro rather than polyfilling the whole API.
-// Enabled on rustc 1.29+ as long as procmacro2_semver_exempt is not set,
-// because we can't emulate the unstable API without emulating everything
-// else. Also enabled unconditionally on nightly, in which case the
-// procmacro2_semver_exempt surface area is implemented by using the
-// nightly-only proc_macro API.
-//
-// "proc_macro_span"
-// Enable non-dummy behavior of Span::start and Span::end methods which
-// requires an unstable compiler feature. Enabled when building with
-// nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable
-// features.
-//
-// "super_unstable"
-// Implement the semver exempt API in terms of the nightly-only proc_macro
-// API. Enabled when using procmacro2_semver_exempt on a nightly compiler.
-//
-// "span_locations"
-// Provide methods Span::start and Span::end which give the line/column
-// location of a token. Enabled by procmacro2_semver_exempt or the
-// "span-locations" Cargo cfg. This is behind a cfg because tracking
-// location inside spans is a performance hit.
-
-use std::env;
-use std::process::{self, Command};
-use std::str;
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
-
- let version = match rustc_version() {
- Some(version) => version,
- None => return,
- };
-
- if version.minor < 31 {
- eprintln!("Minimum supported rustc version is 1.31");
- process::exit(1);
- }
-
- let semver_exempt = cfg!(procmacro2_semver_exempt);
- if semver_exempt {
- // https://github.com/alexcrichton/proc-macro2/issues/147
- println!("cargo:rustc-cfg=procmacro2_semver_exempt");
- }
-
- if semver_exempt || cfg!(feature = "span-locations") {
- println!("cargo:rustc-cfg=span_locations");
- }
-
- let target = env::var("TARGET").unwrap();
- if !enable_use_proc_macro(&target) {
- return;
- }
-
- println!("cargo:rustc-cfg=use_proc_macro");
-
- if version.nightly || !semver_exempt {
- println!("cargo:rustc-cfg=wrap_proc_macro");
- }
-
- if version.nightly && feature_allowed("proc_macro_span") {
- println!("cargo:rustc-cfg=proc_macro_span");
- }
-
- if semver_exempt && version.nightly {
- println!("cargo:rustc-cfg=super_unstable");
- }
-}
-
-fn enable_use_proc_macro(target: &str) -> bool {
- // wasm targets don't have the `proc_macro` crate, disable this feature.
- if target.contains("wasm32") {
- return false;
- }
-
- // Otherwise, only enable it if our feature is actually enabled.
- cfg!(feature = "proc-macro")
-}
-
-struct RustcVersion {
- minor: u32,
- nightly: bool,
-}
-
-fn rustc_version() -> Option<RustcVersion> {
- let rustc = env::var_os("RUSTC")?;
- let output = Command::new(rustc).arg("--version").output().ok()?;
- let version = str::from_utf8(&output.stdout).ok()?;
- let nightly = version.contains("nightly") || version.contains("dev");
- let mut pieces = version.split('.');
- if pieces.next() != Some("rustc 1") {
- return None;
- }
- let minor = pieces.next()?.parse().ok()?;
- Some(RustcVersion { minor, nightly })
-}
-
-fn feature_allowed(feature: &str) -> bool {
- // Recognized formats:
- //
- // -Z allow-features=feature1,feature2
- //
- // -Zallow-features=feature1,feature2
-
- if let Some(rustflags) = env::var_os("RUSTFLAGS") {
- for mut flag in rustflags.to_string_lossy().split(' ') {
- if flag.starts_with("-Z") {
- flag = &flag["-Z".len()..];
- }
- if flag.starts_with("allow-features=") {
- flag = &flag["allow-features=".len()..];
- return flag.split(',').any(|allowed| allowed == feature);
- }
- }
- }
-
- // No allow-features= flag, allowed by default.
- true
-}
diff --git a/proc-macro2/src/fallback.rs b/proc-macro2/src/fallback.rs
deleted file mode 100644
index 9762d3b..0000000
--- a/proc-macro2/src/fallback.rs
+++ /dev/null
@@ -1,1458 +0,0 @@
-#[cfg(span_locations)]
-use std::cell::RefCell;
-#[cfg(span_locations)]
-use std::cmp;
-use std::fmt;
-use std::iter;
-use std::ops::RangeBounds;
-#[cfg(procmacro2_semver_exempt)]
-use std::path::Path;
-use std::path::PathBuf;
-use std::str::FromStr;
-use std::vec;
-
-use crate::strnom::{block_comment, skip_whitespace, whitespace, word_break, Cursor, PResult};
-use crate::{Delimiter, Punct, Spacing, TokenTree};
-use unicode_xid::UnicodeXID;
-
-#[derive(Clone)]
-pub struct TokenStream {
- inner: Vec<TokenTree>,
-}
-
-#[derive(Debug)]
-pub struct LexError;
-
-impl TokenStream {
- pub fn new() -> TokenStream {
- TokenStream { inner: Vec::new() }
- }
-
- pub fn is_empty(&self) -> bool {
- self.inner.len() == 0
- }
-}
-
-#[cfg(span_locations)]
-fn get_cursor(src: &str) -> Cursor {
- // Create a dummy file & add it to the source map
- SOURCE_MAP.with(|cm| {
- let mut cm = cm.borrow_mut();
- let name = format!("<parsed string {}>", cm.files.len());
- let span = cm.add_file(&name, src);
- Cursor {
- rest: src,
- off: span.lo,
- }
- })
-}
-
-#[cfg(not(span_locations))]
-fn get_cursor(src: &str) -> Cursor {
- Cursor { rest: src }
-}
-
-impl FromStr for TokenStream {
- type Err = LexError;
-
- fn from_str(src: &str) -> Result<TokenStream, LexError> {
- // Create a dummy file & add it to the source map
- let cursor = get_cursor(src);
-
- match token_stream(cursor) {
- Ok((input, output)) => {
- if skip_whitespace(input).len() != 0 {
- Err(LexError)
- } else {
- Ok(output)
- }
- }
- Err(LexError) => Err(LexError),
- }
- }
-}
-
-impl fmt::Display for TokenStream {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let mut joint = false;
- for (i, tt) in self.inner.iter().enumerate() {
- if i != 0 && !joint {
- write!(f, " ")?;
- }
- joint = false;
- match *tt {
- TokenTree::Group(ref tt) => {
- let (start, end) = match tt.delimiter() {
- Delimiter::Parenthesis => ("(", ")"),
- Delimiter::Brace => ("{", "}"),
- Delimiter::Bracket => ("[", "]"),
- Delimiter::None => ("", ""),
- };
- if tt.stream().into_iter().next().is_none() {
- write!(f, "{} {}", start, end)?
- } else {
- write!(f, "{} {} {}", start, tt.stream(), end)?
- }
- }
- TokenTree::Ident(ref tt) => write!(f, "{}", tt)?,
- TokenTree::Punct(ref tt) => {
- write!(f, "{}", tt.as_char())?;
- match tt.spacing() {
- Spacing::Alone => {}
- Spacing::Joint => joint = true,
- }
- }
- TokenTree::Literal(ref tt) => write!(f, "{}", tt)?,
- }
- }
-
- Ok(())
- }
-}
-
-impl fmt::Debug for TokenStream {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str("TokenStream ")?;
- f.debug_list().entries(self.clone()).finish()
- }
-}
-
-#[cfg(use_proc_macro)]
-impl From<proc_macro::TokenStream> for TokenStream {
- fn from(inner: proc_macro::TokenStream) -> TokenStream {
- inner
- .to_string()
- .parse()
- .expect("compiler token stream parse failed")
- }
-}
-
-#[cfg(use_proc_macro)]
-impl From<TokenStream> for proc_macro::TokenStream {
- fn from(inner: TokenStream) -> proc_macro::TokenStream {
- inner
- .to_string()
- .parse()
- .expect("failed to parse to compiler tokens")
- }
-}
-
-impl From<TokenTree> for TokenStream {
- fn from(tree: TokenTree) -> TokenStream {
- TokenStream { inner: vec![tree] }
- }
-}
-
-impl iter::FromIterator<TokenTree> for TokenStream {
- fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self {
- let mut v = Vec::new();
-
- for token in streams.into_iter() {
- v.push(token);
- }
-
- TokenStream { inner: v }
- }
-}
-
-impl iter::FromIterator<TokenStream> for TokenStream {
- fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
- let mut v = Vec::new();
-
- for stream in streams.into_iter() {
- v.extend(stream.inner);
- }
-
- TokenStream { inner: v }
- }
-}
-
-impl Extend<TokenTree> for TokenStream {
- fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I) {
- self.inner.extend(streams);
- }
-}
-
-impl Extend<TokenStream> for TokenStream {
- fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
- self.inner
- .extend(streams.into_iter().flat_map(|stream| stream));
- }
-}
-
-pub type TokenTreeIter = vec::IntoIter<TokenTree>;
-
-impl IntoIterator for TokenStream {
- type Item = TokenTree;
- type IntoIter = TokenTreeIter;
-
- fn into_iter(self) -> TokenTreeIter {
- self.inner.into_iter()
- }
-}
-
-#[derive(Clone, PartialEq, Eq)]
-pub struct SourceFile {
- path: PathBuf,
-}
-
-impl SourceFile {
- /// Get the path to this source file as a string.
- pub fn path(&self) -> PathBuf {
- self.path.clone()
- }
-
- pub fn is_real(&self) -> bool {
- // XXX(nika): Support real files in the future?
- false
- }
-}
-
-impl fmt::Debug for SourceFile {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("SourceFile")
- .field("path", &self.path())
- .field("is_real", &self.is_real())
- .finish()
- }
-}
-
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub struct LineColumn {
- pub line: usize,
- pub column: usize,
-}
-
-#[cfg(span_locations)]
-thread_local! {
- static SOURCE_MAP: RefCell<SourceMap> = RefCell::new(SourceMap {
- // NOTE: We start with a single dummy file which all call_site() and
- // def_site() spans reference.
- files: vec![{
- #[cfg(procmacro2_semver_exempt)]
- {
- FileInfo {
- name: "<unspecified>".to_owned(),
- span: Span { lo: 0, hi: 0 },
- lines: vec![0],
- }
- }
-
- #[cfg(not(procmacro2_semver_exempt))]
- {
- FileInfo {
- span: Span { lo: 0, hi: 0 },
- lines: vec![0],
- }
- }
- }],
- });
-}
-
-#[cfg(span_locations)]
-struct FileInfo {
- #[cfg(procmacro2_semver_exempt)]
- name: String,
- span: Span,
- lines: Vec<usize>,
-}
-
-#[cfg(span_locations)]
-impl FileInfo {
- fn offset_line_column(&self, offset: usize) -> LineColumn {
- assert!(self.span_within(Span {
- lo: offset as u32,
- hi: offset as u32
- }));
- let offset = offset - self.span.lo as usize;
- match self.lines.binary_search(&offset) {
- Ok(found) => LineColumn {
- line: found + 1,
- column: 0,
- },
- Err(idx) => LineColumn {
- line: idx,
- column: offset - self.lines[idx - 1],
- },
- }
- }
-
- fn span_within(&self, span: Span) -> bool {
- span.lo >= self.span.lo && span.hi <= self.span.hi
- }
-}
-
-/// Computesthe offsets of each line in the given source string.
-#[cfg(span_locations)]
-fn lines_offsets(s: &str) -> Vec<usize> {
- let mut lines = vec![0];
- let mut prev = 0;
- while let Some(len) = s[prev..].find('\n') {
- prev += len + 1;
- lines.push(prev);
- }
- lines
-}
-
-#[cfg(span_locations)]
-struct SourceMap {
- files: Vec<FileInfo>,
-}
-
-#[cfg(span_locations)]
-impl SourceMap {
- fn next_start_pos(&self) -> u32 {
- // Add 1 so there's always space between files.
- //
- // We'll always have at least 1 file, as we initialize our files list
- // with a dummy file.
- self.files.last().unwrap().span.hi + 1
- }
-
- fn add_file(&mut self, name: &str, src: &str) -> Span {
- let lines = lines_offsets(src);
- let lo = self.next_start_pos();
- // XXX(nika): Shouild we bother doing a checked cast or checked add here?
- let span = Span {
- lo,
- hi: lo + (src.len() as u32),
- };
-
- #[cfg(procmacro2_semver_exempt)]
- self.files.push(FileInfo {
- name: name.to_owned(),
- span,
- lines,
- });
-
- #[cfg(not(procmacro2_semver_exempt))]
- self.files.push(FileInfo { span, lines });
- let _ = name;
-
- span
- }
-
- fn fileinfo(&self, span: Span) -> &FileInfo {
- for file in &self.files {
- if file.span_within(span) {
- return file;
- }
- }
- panic!("Invalid span with no related FileInfo!");
- }
-}
-
-#[derive(Clone, Copy, PartialEq, Eq)]
-pub struct Span {
- #[cfg(span_locations)]
- lo: u32,
- #[cfg(span_locations)]
- hi: u32,
-}
-
-impl Span {
- #[cfg(not(span_locations))]
- pub fn call_site() -> Span {
- Span {}
- }
-
- #[cfg(span_locations)]
- pub fn call_site() -> Span {
- Span { lo: 0, hi: 0 }
- }
-
- #[cfg(procmacro2_semver_exempt)]
- pub fn def_site() -> Span {
- Span::call_site()
- }
-
- #[cfg(procmacro2_semver_exempt)]
- pub fn resolved_at(&self, _other: Span) -> Span {
- // Stable spans consist only of line/column information, so
- // `resolved_at` and `located_at` only select which span the
- // caller wants line/column information from.
- *self
- }
-
- #[cfg(procmacro2_semver_exempt)]
- pub fn located_at(&self, other: Span) -> Span {
- other
- }
-
- #[cfg(procmacro2_semver_exempt)]
- pub fn source_file(&self) -> SourceFile {
- SOURCE_MAP.with(|cm| {
- let cm = cm.borrow();
- let fi = cm.fileinfo(*self);
- SourceFile {
- path: Path::new(&fi.name).to_owned(),
- }
- })
- }
-
- #[cfg(span_locations)]
- pub fn start(&self) -> LineColumn {
- SOURCE_MAP.with(|cm| {
- let cm = cm.borrow();
- let fi = cm.fileinfo(*self);
- fi.offset_line_column(self.lo as usize)
- })
- }
-
- #[cfg(span_locations)]
- pub fn end(&self) -> LineColumn {
- SOURCE_MAP.with(|cm| {
- let cm = cm.borrow();
- let fi = cm.fileinfo(*self);
- fi.offset_line_column(self.hi as usize)
- })
- }
-
- #[cfg(not(span_locations))]
- pub fn join(&self, _other: Span) -> Option<Span> {
- Some(Span {})
- }
-
- #[cfg(span_locations)]
- pub fn join(&self, other: Span) -> Option<Span> {
- SOURCE_MAP.with(|cm| {
- let cm = cm.borrow();
- // If `other` is not within the same FileInfo as us, return None.
- if !cm.fileinfo(*self).span_within(other) {
- return None;
- }
- Some(Span {
- lo: cmp::min(self.lo, other.lo),
- hi: cmp::max(self.hi, other.hi),
- })
- })
- }
-
- #[cfg(not(span_locations))]
- fn first_byte(self) -> Self {
- self
- }
-
- #[cfg(span_locations)]
- fn first_byte(self) -> Self {
- Span {
- lo: self.lo,
- hi: cmp::min(self.lo.saturating_add(1), self.hi),
- }
- }
-
- #[cfg(not(span_locations))]
- fn last_byte(self) -> Self {
- self
- }
-
- #[cfg(span_locations)]
- fn last_byte(self) -> Self {
- Span {
- lo: cmp::max(self.hi.saturating_sub(1), self.lo),
- hi: self.hi,
- }
- }
-}
-
-impl fmt::Debug for Span {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- #[cfg(procmacro2_semver_exempt)]
- return write!(f, "bytes({}..{})", self.lo, self.hi);
-
- #[cfg(not(procmacro2_semver_exempt))]
- write!(f, "Span")
- }
-}
-
-pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
- if cfg!(procmacro2_semver_exempt) {
- debug.field("span", &span);
- }
-}
-
-#[derive(Clone)]
-pub struct Group {
- delimiter: Delimiter,
- stream: TokenStream,
- span: Span,
-}
-
-impl Group {
- pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
- Group {
- delimiter,
- stream,
- span: Span::call_site(),
- }
- }
-
- pub fn delimiter(&self) -> Delimiter {
- self.delimiter
- }
-
- pub fn stream(&self) -> TokenStream {
- self.stream.clone()
- }
-
- pub fn span(&self) -> Span {
- self.span
- }
-
- pub fn span_open(&self) -> Span {
- self.span.first_byte()
- }
-
- pub fn span_close(&self) -> Span {
- self.span.last_byte()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.span = span;
- }
-}
-
-impl fmt::Display for Group {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let (left, right) = match self.delimiter {
- Delimiter::Parenthesis => ("(", ")"),
- Delimiter::Brace => ("{", "}"),
- Delimiter::Bracket => ("[", "]"),
- Delimiter::None => ("", ""),
- };
-
- f.write_str(left)?;
- self.stream.fmt(f)?;
- f.write_str(right)?;
-
- Ok(())
- }
-}
-
-impl fmt::Debug for Group {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- let mut debug = fmt.debug_struct("Group");
- debug.field("delimiter", &self.delimiter);
- debug.field("stream", &self.stream);
- #[cfg(procmacro2_semver_exempt)]
- debug.field("span", &self.span);
- debug.finish()
- }
-}
-
-#[derive(Clone)]
-pub struct Ident {
- sym: String,
- span: Span,
- raw: bool,
-}
-
-impl Ident {
- fn _new(string: &str, raw: bool, span: Span) -> Ident {
- validate_ident(string);
-
- Ident {
- sym: string.to_owned(),
- span,
- raw,
- }
- }
-
- pub fn new(string: &str, span: Span) -> Ident {
- Ident::_new(string, false, span)
- }
-
- pub fn new_raw(string: &str, span: Span) -> Ident {
- Ident::_new(string, true, span)
- }
-
- pub fn span(&self) -> Span {
- self.span
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.span = span;
- }
-}
-
-fn is_ident_start(c: char) -> bool {
- ('a' <= c && c <= 'z')
- || ('A' <= c && c <= 'Z')
- || c == '_'
- || (c > '\x7f' && UnicodeXID::is_xid_start(c))
-}
-
-fn is_ident_continue(c: char) -> bool {
- ('a' <= c && c <= 'z')
- || ('A' <= c && c <= 'Z')
- || c == '_'
- || ('0' <= c && c <= '9')
- || (c > '\x7f' && UnicodeXID::is_xid_continue(c))
-}
-
-fn validate_ident(string: &str) {
- let validate = string;
- if validate.is_empty() {
- panic!("Ident is not allowed to be empty; use Option<Ident>");
- }
-
- if validate.bytes().all(|digit| digit >= b'0' && digit <= b'9') {
- panic!("Ident cannot be a number; use Literal instead");
- }
-
- fn ident_ok(string: &str) -> bool {
- let mut chars = string.chars();
- let first = chars.next().unwrap();
- if !is_ident_start(first) {
- return false;
- }
- for ch in chars {
- if !is_ident_continue(ch) {
- return false;
- }
- }
- true
- }
-
- if !ident_ok(validate) {
- panic!("{:?} is not a valid Ident", string);
- }
-}
-
-impl PartialEq for Ident {
- fn eq(&self, other: &Ident) -> bool {
- self.sym == other.sym && self.raw == other.raw
- }
-}
-
-impl<T> PartialEq<T> for Ident
-where
- T: ?Sized + AsRef<str>,
-{
- fn eq(&self, other: &T) -> bool {
- let other = other.as_ref();
- if self.raw {
- other.starts_with("r#") && self.sym == other[2..]
- } else {
- self.sym == other
- }
- }
-}
-
-impl fmt::Display for Ident {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- if self.raw {
- "r#".fmt(f)?;
- }
- self.sym.fmt(f)
- }
-}
-
-impl fmt::Debug for Ident {
- // Ident(proc_macro), Ident(r#union)
- #[cfg(not(procmacro2_semver_exempt))]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let mut debug = f.debug_tuple("Ident");
- debug.field(&format_args!("{}", self));
- debug.finish()
- }
-
- // Ident {
- // sym: proc_macro,
- // span: bytes(128..138)
- // }
- #[cfg(procmacro2_semver_exempt)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let mut debug = f.debug_struct("Ident");
- debug.field("sym", &format_args!("{}", self));
- debug.field("span", &self.span);
- debug.finish()
- }
-}
-
-#[derive(Clone)]
-pub struct Literal {
- text: String,
- span: Span,
-}
-
-macro_rules! suffixed_numbers {
- ($($name:ident => $kind:ident,)*) => ($(
- pub fn $name(n: $kind) -> Literal {
- Literal::_new(format!(concat!("{}", stringify!($kind)), n))
- }
- )*)
-}
-
-macro_rules! unsuffixed_numbers {
- ($($name:ident => $kind:ident,)*) => ($(
- pub fn $name(n: $kind) -> Literal {
- Literal::_new(n.to_string())
- }
- )*)
-}
-
-impl Literal {
- fn _new(text: String) -> Literal {
- Literal {
- text,
- span: Span::call_site(),
- }
- }
-
- suffixed_numbers! {
- u8_suffixed => u8,
- u16_suffixed => u16,
- u32_suffixed => u32,
- u64_suffixed => u64,
- u128_suffixed => u128,
- usize_suffixed => usize,
- i8_suffixed => i8,
- i16_suffixed => i16,
- i32_suffixed => i32,
- i64_suffixed => i64,
- i128_suffixed => i128,
- isize_suffixed => isize,
-
- f32_suffixed => f32,
- f64_suffixed => f64,
- }
-
- unsuffixed_numbers! {
- u8_unsuffixed => u8,
- u16_unsuffixed => u16,
- u32_unsuffixed => u32,
- u64_unsuffixed => u64,
- u128_unsuffixed => u128,
- usize_unsuffixed => usize,
- i8_unsuffixed => i8,
- i16_unsuffixed => i16,
- i32_unsuffixed => i32,
- i64_unsuffixed => i64,
- i128_unsuffixed => i128,
- isize_unsuffixed => isize,
- }
-
- pub fn f32_unsuffixed(f: f32) -> Literal {
- let mut s = f.to_string();
- if !s.contains(".") {
- s.push_str(".0");
- }
- Literal::_new(s)
- }
-
- pub fn f64_unsuffixed(f: f64) -> Literal {
- let mut s = f.to_string();
- if !s.contains(".") {
- s.push_str(".0");
- }
- Literal::_new(s)
- }
-
- pub fn string(t: &str) -> Literal {
- let mut text = String::with_capacity(t.len() + 2);
- text.push('"');
- for c in t.chars() {
- if c == '\'' {
- // escape_default turns this into "\'" which is unnecessary.
- text.push(c);
- } else {
- text.extend(c.escape_default());
- }
- }
- text.push('"');
- Literal::_new(text)
- }
-
- pub fn character(t: char) -> Literal {
- let mut text = String::new();
- text.push('\'');
- if t == '"' {
- // escape_default turns this into '\"' which is unnecessary.
- text.push(t);
- } else {
- text.extend(t.escape_default());
- }
- text.push('\'');
- Literal::_new(text)
- }
-
- pub fn byte_string(bytes: &[u8]) -> Literal {
- let mut escaped = "b\"".to_string();
- for b in bytes {
- match *b {
- b'\0' => escaped.push_str(r"\0"),
- b'\t' => escaped.push_str(r"\t"),
- b'\n' => escaped.push_str(r"\n"),
- b'\r' => escaped.push_str(r"\r"),
- b'"' => escaped.push_str("\\\""),
- b'\\' => escaped.push_str("\\\\"),
- b'\x20'..=b'\x7E' => escaped.push(*b as char),
- _ => escaped.push_str(&format!("\\x{:02X}", b)),
- }
- }
- escaped.push('"');
- Literal::_new(escaped)
- }
-
- pub fn span(&self) -> Span {
- self.span
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.span = span;
- }
-
- pub fn subspan<R: RangeBounds<usize>>(&self, _range: R) -> Option<Span> {
- None
- }
-}
-
-impl fmt::Display for Literal {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.text.fmt(f)
- }
-}
-
-impl fmt::Debug for Literal {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- let mut debug = fmt.debug_struct("Literal");
- debug.field("lit", &format_args!("{}", self.text));
- #[cfg(procmacro2_semver_exempt)]
- debug.field("span", &self.span);
- debug.finish()
- }
-}
-
-fn token_stream(mut input: Cursor) -> PResult<TokenStream> {
- let mut trees = Vec::new();
- loop {
- let input_no_ws = skip_whitespace(input);
- if input_no_ws.rest.len() == 0 {
- break;
- }
- if let Ok((a, tokens)) = doc_comment(input_no_ws) {
- input = a;
- trees.extend(tokens);
- continue;
- }
-
- let (a, tt) = match token_tree(input_no_ws) {
- Ok(p) => p,
- Err(_) => break,
- };
- trees.push(tt);
- input = a;
- }
- Ok((input, TokenStream { inner: trees }))
-}
-
-#[cfg(not(span_locations))]
-fn spanned<'a, T>(
- input: Cursor<'a>,
- f: fn(Cursor<'a>) -> PResult<'a, T>,
-) -> PResult<'a, (T, crate::Span)> {
- let (a, b) = f(skip_whitespace(input))?;
- Ok((a, ((b, crate::Span::_new_stable(Span::call_site())))))
-}
-
-#[cfg(span_locations)]
-fn spanned<'a, T>(
- input: Cursor<'a>,
- f: fn(Cursor<'a>) -> PResult<'a, T>,
-) -> PResult<'a, (T, crate::Span)> {
- let input = skip_whitespace(input);
- let lo = input.off;
- let (a, b) = f(input)?;
- let hi = a.off;
- let span = crate::Span::_new_stable(Span { lo, hi });
- Ok((a, (b, span)))
-}
-
-fn token_tree(input: Cursor) -> PResult<TokenTree> {
- let (rest, (mut tt, span)) = spanned(input, token_kind)?;
- tt.set_span(span);
- Ok((rest, tt))
-}
-
-named!(token_kind -> TokenTree, alt!(
- map!(group, |g| TokenTree::Group(crate::Group::_new_stable(g)))
- |
- map!(literal, |l| TokenTree::Literal(crate::Literal::_new_stable(l))) // must be before symbol
- |
- map!(op, TokenTree::Punct)
- |
- symbol_leading_ws
-));
-
-named!(group -> Group, alt!(
- delimited!(
- punct!("("),
- token_stream,
- punct!(")")
- ) => { |ts| Group::new(Delimiter::Parenthesis, ts) }
- |
- delimited!(
- punct!("["),
- token_stream,
- punct!("]")
- ) => { |ts| Group::new(Delimiter::Bracket, ts) }
- |
- delimited!(
- punct!("{"),
- token_stream,
- punct!("}")
- ) => { |ts| Group::new(Delimiter::Brace, ts) }
-));
-
-fn symbol_leading_ws(input: Cursor) -> PResult<TokenTree> {
- symbol(skip_whitespace(input))
-}
-
-fn symbol(input: Cursor) -> PResult<TokenTree> {
- let raw = input.starts_with("r#");
- let rest = input.advance((raw as usize) << 1);
-
- let (rest, sym) = symbol_not_raw(rest)?;
-
- if !raw {
- let ident = crate::Ident::new(sym, crate::Span::call_site());
- return Ok((rest, ident.into()));
- }
-
- if sym == "_" {
- return Err(LexError);
- }
-
- let ident = crate::Ident::_new_raw(sym, crate::Span::call_site());
- Ok((rest, ident.into()))
-}
-
-fn symbol_not_raw(input: Cursor) -> PResult<&str> {
- let mut chars = input.char_indices();
-
- match chars.next() {
- Some((_, ch)) if is_ident_start(ch) => {}
- _ => return Err(LexError),
- }
-
- let mut end = input.len();
- for (i, ch) in chars {
- if !is_ident_continue(ch) {
- end = i;
- break;
- }
- }
-
- Ok((input.advance(end), &input.rest[..end]))
-}
-
-fn literal(input: Cursor) -> PResult<Literal> {
- let input_no_ws = skip_whitespace(input);
-
- match literal_nocapture(input_no_ws) {
- Ok((a, ())) => {
- let start = input.len() - input_no_ws.len();
- let len = input_no_ws.len() - a.len();
- let end = start + len;
- Ok((a, Literal::_new(input.rest[start..end].to_string())))
- }
- Err(LexError) => Err(LexError),
- }
-}
-
-named!(literal_nocapture -> (), alt!(
- string
- |
- byte_string
- |
- byte
- |
- character
- |
- float
- |
- int
-));
-
-named!(string -> (), alt!(
- quoted_string
- |
- preceded!(
- punct!("r"),
- raw_string
- ) => { |_| () }
-));
-
-named!(quoted_string -> (), do_parse!(
- punct!("\"") >>
- cooked_string >>
- tag!("\"") >>
- option!(symbol_not_raw) >>
- (())
-));
-
-fn cooked_string(input: Cursor) -> PResult<()> {
- let mut chars = input.char_indices().peekable();
- while let Some((byte_offset, ch)) = chars.next() {
- match ch {
- '"' => {
- return Ok((input.advance(byte_offset), ()));
- }
- '\r' => {
- if let Some((_, '\n')) = chars.next() {
- // ...
- } else {
- break;
- }
- }
- '\\' => match chars.next() {
- Some((_, 'x')) => {
- if !backslash_x_char(&mut chars) {
- break;
- }
- }
- Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
- | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {}
- Some((_, 'u')) => {
- if !backslash_u(&mut chars) {
- break;
- }
- }
- Some((_, '\n')) | Some((_, '\r')) => {
- while let Some(&(_, ch)) = chars.peek() {
- if ch.is_whitespace() {
- chars.next();
- } else {
- break;
- }
- }
- }
- _ => break,
- },
- _ch => {}
- }
- }
- Err(LexError)
-}
-
-named!(byte_string -> (), alt!(
- delimited!(
- punct!("b\""),
- cooked_byte_string,
- tag!("\"")
- ) => { |_| () }
- |
- preceded!(
- punct!("br"),
- raw_string
- ) => { |_| () }
-));
-
-fn cooked_byte_string(mut input: Cursor) -> PResult<()> {
- let mut bytes = input.bytes().enumerate();
- 'outer: while let Some((offset, b)) = bytes.next() {
- match b {
- b'"' => {
- return Ok((input.advance(offset), ()));
- }
- b'\r' => {
- if let Some((_, b'\n')) = bytes.next() {
- // ...
- } else {
- break;
- }
- }
- b'\\' => match bytes.next() {
- Some((_, b'x')) => {
- if !backslash_x_byte(&mut bytes) {
- break;
- }
- }
- Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
- | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
- Some((newline, b'\n')) | Some((newline, b'\r')) => {
- let rest = input.advance(newline + 1);
- for (offset, ch) in rest.char_indices() {
- if !ch.is_whitespace() {
- input = rest.advance(offset);
- bytes = input.bytes().enumerate();
- continue 'outer;
- }
- }
- break;
- }
- _ => break,
- },
- b if b < 0x80 => {}
- _ => break,
- }
- }
- Err(LexError)
-}
-
-fn raw_string(input: Cursor) -> PResult<()> {
- let mut chars = input.char_indices();
- let mut n = 0;
- while let Some((byte_offset, ch)) = chars.next() {
- match ch {
- '"' => {
- n = byte_offset;
- break;
- }
- '#' => {}
- _ => return Err(LexError),
- }
- }
- for (byte_offset, ch) in chars {
- match ch {
- '"' if input.advance(byte_offset + 1).starts_with(&input.rest[..n]) => {
- let rest = input.advance(byte_offset + 1 + n);
- return Ok((rest, ()));
- }
- '\r' => {}
- _ => {}
- }
- }
- Err(LexError)
-}
-
-named!(byte -> (), do_parse!(
- punct!("b") >>
- tag!("'") >>
- cooked_byte >>
- tag!("'") >>
- (())
-));
-
-fn cooked_byte(input: Cursor) -> PResult<()> {
- let mut bytes = input.bytes().enumerate();
- let ok = match bytes.next().map(|(_, b)| b) {
- Some(b'\\') => match bytes.next().map(|(_, b)| b) {
- Some(b'x') => backslash_x_byte(&mut bytes),
- Some(b'n') | Some(b'r') | Some(b't') | Some(b'\\') | Some(b'0') | Some(b'\'')
- | Some(b'"') => true,
- _ => false,
- },
- b => b.is_some(),
- };
- if ok {
- match bytes.next() {
- Some((offset, _)) => {
- if input.chars().as_str().is_char_boundary(offset) {
- Ok((input.advance(offset), ()))
- } else {
- Err(LexError)
- }
- }
- None => Ok((input.advance(input.len()), ())),
- }
- } else {
- Err(LexError)
- }
-}
-
-named!(character -> (), do_parse!(
- punct!("'") >>
- cooked_char >>
- tag!("'") >>
- (())
-));
-
-fn cooked_char(input: Cursor) -> PResult<()> {
- let mut chars = input.char_indices();
- let ok = match chars.next().map(|(_, ch)| ch) {
- Some('\\') => match chars.next().map(|(_, ch)| ch) {
- Some('x') => backslash_x_char(&mut chars),
- Some('u') => backslash_u(&mut chars),
- Some('n') | Some('r') | Some('t') | Some('\\') | Some('0') | Some('\'') | Some('"') => {
- true
- }
- _ => false,
- },
- ch => ch.is_some(),
- };
- if ok {
- match chars.next() {
- Some((idx, _)) => Ok((input.advance(idx), ())),
- None => Ok((input.advance(input.len()), ())),
- }
- } else {
- Err(LexError)
- }
-}
-
-macro_rules! next_ch {
- ($chars:ident @ $pat:pat $(| $rest:pat)*) => {
- match $chars.next() {
- Some((_, ch)) => match ch {
- $pat $(| $rest)* => ch,
- _ => return false,
- },
- None => return false
- }
- };
-}
-
-fn backslash_x_char<I>(chars: &mut I) -> bool
-where
- I: Iterator<Item = (usize, char)>,
-{
- next_ch!(chars @ '0'..='7');
- next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
- true
-}
-
-fn backslash_x_byte<I>(chars: &mut I) -> bool
-where
- I: Iterator<Item = (usize, u8)>,
-{
- next_ch!(chars @ b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F');
- next_ch!(chars @ b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F');
- true
-}
-
-fn backslash_u<I>(chars: &mut I) -> bool
-where
- I: Iterator<Item = (usize, char)>,
-{
- next_ch!(chars @ '{');
- next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
- loop {
- let c = next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F' | '_' | '}');
- if c == '}' {
- return true;
- }
- }
-}
-
-fn float(input: Cursor) -> PResult<()> {
- let (mut rest, ()) = float_digits(input)?;
- if let Some(ch) = rest.chars().next() {
- if is_ident_start(ch) {
- rest = symbol_not_raw(rest)?.0;
- }
- }
- word_break(rest)
-}
-
-fn float_digits(input: Cursor) -> PResult<()> {
- let mut chars = input.chars().peekable();
- match chars.next() {
- Some(ch) if ch >= '0' && ch <= '9' => {}
- _ => return Err(LexError),
- }
-
- let mut len = 1;
- let mut has_dot = false;
- let mut has_exp = false;
- while let Some(&ch) = chars.peek() {
- match ch {
- '0'..='9' | '_' => {
- chars.next();
- len += 1;
- }
- '.' => {
- if has_dot {
- break;
- }
- chars.next();
- if chars
- .peek()
- .map(|&ch| ch == '.' || is_ident_start(ch))
- .unwrap_or(false)
- {
- return Err(LexError);
- }
- len += 1;
- has_dot = true;
- }
- 'e' | 'E' => {
- chars.next();
- len += 1;
- has_exp = true;
- break;
- }
- _ => break,
- }
- }
-
- let rest = input.advance(len);
- if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) {
- return Err(LexError);
- }
-
- if has_exp {
- let mut has_exp_value = false;
- while let Some(&ch) = chars.peek() {
- match ch {
- '+' | '-' => {
- if has_exp_value {
- break;
- }
- chars.next();
- len += 1;
- }
- '0'..='9' => {
- chars.next();
- len += 1;
- has_exp_value = true;
- }
- '_' => {
- chars.next();
- len += 1;
- }
- _ => break,
- }
- }
- if !has_exp_value {
- return Err(LexError);
- }
- }
-
- Ok((input.advance(len), ()))
-}
-
-fn int(input: Cursor) -> PResult<()> {
- let (mut rest, ()) = digits(input)?;
- if let Some(ch) = rest.chars().next() {
- if is_ident_start(ch) {
- rest = symbol_not_raw(rest)?.0;
- }
- }
- word_break(rest)
-}
-
-fn digits(mut input: Cursor) -> PResult<()> {
- let base = if input.starts_with("0x") {
- input = input.advance(2);
- 16
- } else if input.starts_with("0o") {
- input = input.advance(2);
- 8
- } else if input.starts_with("0b") {
- input = input.advance(2);
- 2
- } else {
- 10
- };
-
- let mut len = 0;
- let mut empty = true;
- for b in input.bytes() {
- let digit = match b {
- b'0'..=b'9' => (b - b'0') as u64,
- b'a'..=b'f' => 10 + (b - b'a') as u64,
- b'A'..=b'F' => 10 + (b - b'A') as u64,
- b'_' => {
- if empty && base == 10 {
- return Err(LexError);
- }
- len += 1;
- continue;
- }
- _ => break,
- };
- if digit >= base {
- return Err(LexError);
- }
- len += 1;
- empty = false;
- }
- if empty {
- Err(LexError)
- } else {
- Ok((input.advance(len), ()))
- }
-}
-
-fn op(input: Cursor) -> PResult<Punct> {
- let input = skip_whitespace(input);
- match op_char(input) {
- Ok((rest, '\'')) => {
- symbol(rest)?;
- Ok((rest, Punct::new('\'', Spacing::Joint)))
- }
- Ok((rest, ch)) => {
- let kind = match op_char(rest) {
- Ok(_) => Spacing::Joint,
- Err(LexError) => Spacing::Alone,
- };
- Ok((rest, Punct::new(ch, kind)))
- }
- Err(LexError) => Err(LexError),
- }
-}
-
-fn op_char(input: Cursor) -> PResult<char> {
- if input.starts_with("//") || input.starts_with("/*") {
- // Do not accept `/` of a comment as an op.
- return Err(LexError);
- }
-
- let mut chars = input.chars();
- let first = match chars.next() {
- Some(ch) => ch,
- None => {
- return Err(LexError);
- }
- };
- let recognized = "~!@#$%^&*-=+|;:,<.>/?'";
- if recognized.contains(first) {
- Ok((input.advance(first.len_utf8()), first))
- } else {
- Err(LexError)
- }
-}
-
-fn doc_comment(input: Cursor) -> PResult<Vec<TokenTree>> {
- let mut trees = Vec::new();
- let (rest, ((comment, inner), span)) = spanned(input, doc_comment_contents)?;
- trees.push(TokenTree::Punct(Punct::new('#', Spacing::Alone)));
- if inner {
- trees.push(Punct::new('!', Spacing::Alone).into());
- }
- let mut stream = vec![
- TokenTree::Ident(crate::Ident::new("doc", span)),
- TokenTree::Punct(Punct::new('=', Spacing::Alone)),
- TokenTree::Literal(crate::Literal::string(comment)),
- ];
- for tt in stream.iter_mut() {
- tt.set_span(span);
- }
- let group = Group::new(Delimiter::Bracket, stream.into_iter().collect());
- trees.push(crate::Group::_new_stable(group).into());
- for tt in trees.iter_mut() {
- tt.set_span(span);
- }
- Ok((rest, trees))
-}
-
-named!(doc_comment_contents -> (&str, bool), alt!(
- do_parse!(
- punct!("//!") >>
- s: take_until_newline_or_eof!() >>
- ((s, true))
- )
- |
- do_parse!(
- option!(whitespace) >>
- peek!(tag!("/*!")) >>
- s: block_comment >>
- ((s, true))
- )
- |
- do_parse!(
- punct!("///") >>
- not!(tag!("/")) >>
- s: take_until_newline_or_eof!() >>
- ((s, false))
- )
- |
- do_parse!(
- option!(whitespace) >>
- peek!(tuple!(tag!("/**"), not!(tag!("*")))) >>
- s: block_comment >>
- ((s, false))
- )
-));
diff --git a/proc-macro2/src/lib.rs b/proc-macro2/src/lib.rs
deleted file mode 100644
index bbfb375..0000000
--- a/proc-macro2/src/lib.rs
+++ /dev/null
@@ -1,1199 +0,0 @@
-//! A wrapper around the procedural macro API of the compiler's [`proc_macro`]
-//! crate. This library serves two purposes:
-//!
-//! [`proc_macro`]: https://doc.rust-lang.org/proc_macro/
-//!
-//! - **Bring proc-macro-like functionality to other contexts like build.rs and
-//! main.rs.** Types from `proc_macro` are entirely specific to procedural
-//! macros and cannot ever exist in code outside of a procedural macro.
-//! Meanwhile `proc_macro2` types may exist anywhere including non-macro code.
-//! By developing foundational libraries like [syn] and [quote] against
-//! `proc_macro2` rather than `proc_macro`, the procedural macro ecosystem
-//! becomes easily applicable to many other use cases and we avoid
-//! reimplementing non-macro equivalents of those libraries.
-//!
-//! - **Make procedural macros unit testable.** As a consequence of being
-//! specific to procedural macros, nothing that uses `proc_macro` can be
-//! executed from a unit test. In order for helper libraries or components of
-//! a macro to be testable in isolation, they must be implemented using
-//! `proc_macro2`.
-//!
-//! [syn]: https://github.com/dtolnay/syn
-//! [quote]: https://github.com/dtolnay/quote
-//!
-//! # Usage
-//!
-//! The skeleton of a typical procedural macro typically looks like this:
-//!
-//! ```
-//! extern crate proc_macro;
-//!
-//! # const IGNORE: &str = stringify! {
-//! #[proc_macro_derive(MyDerive)]
-//! # };
-//! # #[cfg(wrap_proc_macro)]
-//! pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
-//! let input = proc_macro2::TokenStream::from(input);
-//!
-//! let output: proc_macro2::TokenStream = {
-//! /* transform input */
-//! # input
-//! };
-//!
-//! proc_macro::TokenStream::from(output)
-//! }
-//! ```
-//!
-//! If parsing with [Syn], you'll use [`parse_macro_input!`] instead to
-//! propagate parse errors correctly back to the compiler when parsing fails.
-//!
-//! [`parse_macro_input!`]: https://docs.rs/syn/1.0/syn/macro.parse_macro_input.html
-//!
-//! # Unstable features
-//!
-//! The default feature set of proc-macro2 tracks the most recent stable
-//! compiler API. Functionality in `proc_macro` that is not yet stable is not
-//! exposed by proc-macro2 by default.
-//!
-//! To opt into the additional APIs available in the most recent nightly
-//! compiler, the `procmacro2_semver_exempt` config flag must be passed to
-//! rustc. We will polyfill those nightly-only APIs back to Rust 1.31.0. As
-//! these are unstable APIs that track the nightly compiler, minor versions of
-//! proc-macro2 may make breaking changes to them at any time.
-//!
-//! ```sh
-//! RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build
-//! ```
-//!
-//! Note that this must not only be done for your crate, but for any crate that
-//! depends on your crate. This infectious nature is intentional, as it serves
-//! as a reminder that you are outside of the normal semver guarantees.
-//!
-//! Semver exempt methods are marked as such in the proc-macro2 documentation.
-//!
-//! # Thread-Safety
-//!
-//! Most types in this crate are `!Sync` because the underlying compiler
-//! types make use of thread-local memory, meaning they cannot be accessed from
-//! a different thread.
-
-// Proc-macro2 types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.7")]
-#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
-#![cfg_attr(super_unstable, feature(proc_macro_raw_ident, proc_macro_def_site))]
-
-#[cfg(use_proc_macro)]
-extern crate proc_macro;
-
-use std::cmp::Ordering;
-use std::fmt;
-use std::hash::{Hash, Hasher};
-use std::iter::FromIterator;
-use std::marker;
-use std::ops::RangeBounds;
-#[cfg(procmacro2_semver_exempt)]
-use std::path::PathBuf;
-use std::rc::Rc;
-use std::str::FromStr;
-
-#[macro_use]
-mod strnom;
-mod fallback;
-
-#[cfg(not(wrap_proc_macro))]
-use crate::fallback as imp;
-#[path = "wrapper.rs"]
-#[cfg(wrap_proc_macro)]
-mod imp;
-
-/// An abstract stream of tokens, or more concretely a sequence of token trees.
-///
-/// This type provides interfaces for iterating over token trees and for
-/// collecting token trees into one stream.
-///
-/// Token stream is both the input and output of `#[proc_macro]`,
-/// `#[proc_macro_attribute]` and `#[proc_macro_derive]` definitions.
-#[derive(Clone)]
-pub struct TokenStream {
- inner: imp::TokenStream,
- _marker: marker::PhantomData<Rc<()>>,
-}
-
-/// Error returned from `TokenStream::from_str`.
-pub struct LexError {
- inner: imp::LexError,
- _marker: marker::PhantomData<Rc<()>>,
-}
-
-impl TokenStream {
- fn _new(inner: imp::TokenStream) -> TokenStream {
- TokenStream {
- inner,
- _marker: marker::PhantomData,
- }
- }
-
- fn _new_stable(inner: fallback::TokenStream) -> TokenStream {
- TokenStream {
- inner: inner.into(),
- _marker: marker::PhantomData,
- }
- }
-
- /// Returns an empty `TokenStream` containing no token trees.
- pub fn new() -> TokenStream {
- TokenStream::_new(imp::TokenStream::new())
- }
-
- /// Checks if this `TokenStream` is empty.
- pub fn is_empty(&self) -> bool {
- self.inner.is_empty()
- }
-}
-
-/// `TokenStream::default()` returns an empty stream,
-/// i.e. this is equivalent with `TokenStream::new()`.
-impl Default for TokenStream {
- fn default() -> Self {
- TokenStream::new()
- }
-}
-
-/// Attempts to break the string into tokens and parse those tokens into a token
-/// stream.
-///
-/// May fail for a number of reasons, for example, if the string contains
-/// unbalanced delimiters or characters not existing in the language.
-///
-/// NOTE: Some errors may cause panics instead of returning `LexError`. We
-/// reserve the right to change these errors into `LexError`s later.
-impl FromStr for TokenStream {
- type Err = LexError;
-
- fn from_str(src: &str) -> Result<TokenStream, LexError> {
- let e = src.parse().map_err(|e| LexError {
- inner: e,
- _marker: marker::PhantomData,
- })?;
- Ok(TokenStream::_new(e))
- }
-}
-
-#[cfg(use_proc_macro)]
-impl From<proc_macro::TokenStream> for TokenStream {
- fn from(inner: proc_macro::TokenStream) -> TokenStream {
- TokenStream::_new(inner.into())
- }
-}
-
-#[cfg(use_proc_macro)]
-impl From<TokenStream> for proc_macro::TokenStream {
- fn from(inner: TokenStream) -> proc_macro::TokenStream {
- inner.inner.into()
- }
-}
-
-impl From<TokenTree> for TokenStream {
- fn from(token: TokenTree) -> Self {
- TokenStream::_new(imp::TokenStream::from(token))
- }
-}
-
-impl Extend<TokenTree> for TokenStream {
- fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I) {
- self.inner.extend(streams)
- }
-}
-
-impl Extend<TokenStream> for TokenStream {
- fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
- self.inner
- .extend(streams.into_iter().map(|stream| stream.inner))
- }
-}
-
-/// Collects a number of token trees into a single stream.
-impl FromIterator<TokenTree> for TokenStream {
- fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self {
- TokenStream::_new(streams.into_iter().collect())
- }
-}
-impl FromIterator<TokenStream> for TokenStream {
- fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
- TokenStream::_new(streams.into_iter().map(|i| i.inner).collect())
- }
-}
-
-/// Prints the token stream as a string that is supposed to be losslessly
-/// convertible back into the same token stream (modulo spans), except for
-/// possibly `TokenTree::Group`s with `Delimiter::None` delimiters and negative
-/// numeric literals.
-impl fmt::Display for TokenStream {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-/// Prints token in a form convenient for debugging.
-impl fmt::Debug for TokenStream {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-impl fmt::Debug for LexError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-/// The source file of a given `Span`.
-///
-/// This type is semver exempt and not exposed by default.
-#[cfg(procmacro2_semver_exempt)]
-#[derive(Clone, PartialEq, Eq)]
-pub struct SourceFile {
- inner: imp::SourceFile,
- _marker: marker::PhantomData<Rc<()>>,
-}
-
-#[cfg(procmacro2_semver_exempt)]
-impl SourceFile {
- fn _new(inner: imp::SourceFile) -> Self {
- SourceFile {
- inner,
- _marker: marker::PhantomData,
- }
- }
-
- /// Get the path to this source file.
- ///
- /// ### Note
- ///
- /// If the code span associated with this `SourceFile` was generated by an
- /// external macro, this may not be an actual path on the filesystem. Use
- /// [`is_real`] to check.
- ///
- /// Also note that even if `is_real` returns `true`, if
- /// `--remap-path-prefix` was passed on the command line, the path as given
- /// may not actually be valid.
- ///
- /// [`is_real`]: #method.is_real
- pub fn path(&self) -> PathBuf {
- self.inner.path()
- }
-
- /// Returns `true` if this source file is a real source file, and not
- /// generated by an external macro's expansion.
- pub fn is_real(&self) -> bool {
- self.inner.is_real()
- }
-}
-
-#[cfg(procmacro2_semver_exempt)]
-impl fmt::Debug for SourceFile {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-/// A line-column pair representing the start or end of a `Span`.
-///
-/// This type is semver exempt and not exposed by default.
-#[cfg(span_locations)]
-#[derive(Copy, Clone, Debug, PartialEq, Eq)]
-pub struct LineColumn {
- /// The 1-indexed line in the source file on which the span starts or ends
- /// (inclusive).
- pub line: usize,
- /// The 0-indexed column (in UTF-8 characters) in the source file on which
- /// the span starts or ends (inclusive).
- pub column: usize,
-}
-
-/// A region of source code, along with macro expansion information.
-#[derive(Copy, Clone)]
-pub struct Span {
- inner: imp::Span,
- _marker: marker::PhantomData<Rc<()>>,
-}
-
-impl Span {
- fn _new(inner: imp::Span) -> Span {
- Span {
- inner,
- _marker: marker::PhantomData,
- }
- }
-
- fn _new_stable(inner: fallback::Span) -> Span {
- Span {
- inner: inner.into(),
- _marker: marker::PhantomData,
- }
- }
-
- /// The span of the invocation of the current procedural macro.
- ///
- /// Identifiers created with this span will be resolved as if they were
- /// written directly at the macro call location (call-site hygiene) and
- /// other code at the macro call site will be able to refer to them as well.
- pub fn call_site() -> Span {
- Span::_new(imp::Span::call_site())
- }
-
- /// A span that resolves at the macro definition site.
- ///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
- pub fn def_site() -> Span {
- Span::_new(imp::Span::def_site())
- }
-
- /// Creates a new span with the same line/column information as `self` but
- /// that resolves symbols as though it were at `other`.
- ///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
- pub fn resolved_at(&self, other: Span) -> Span {
- Span::_new(self.inner.resolved_at(other.inner))
- }
-
- /// Creates a new span with the same name resolution behavior as `self` but
- /// with the line/column information of `other`.
- ///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
- pub fn located_at(&self, other: Span) -> Span {
- Span::_new(self.inner.located_at(other.inner))
- }
-
- /// Convert `proc_macro2::Span` to `proc_macro::Span`.
- ///
- /// This method is available when building with a nightly compiler, or when
- /// building with rustc 1.29+ *without* semver exempt features.
- ///
- /// # Panics
- ///
- /// Panics if called from outside of a procedural macro. Unlike
- /// `proc_macro2::Span`, the `proc_macro::Span` type can only exist within
- /// the context of a procedural macro invocation.
- #[cfg(wrap_proc_macro)]
- pub fn unwrap(self) -> proc_macro::Span {
- self.inner.unwrap()
- }
-
- // Soft deprecated. Please use Span::unwrap.
- #[cfg(wrap_proc_macro)]
- #[doc(hidden)]
- pub fn unstable(self) -> proc_macro::Span {
- self.unwrap()
- }
-
- /// The original source file into which this span points.
- ///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
- pub fn source_file(&self) -> SourceFile {
- SourceFile::_new(self.inner.source_file())
- }
-
- /// Get the starting line/column in the source file for this span.
- ///
- /// This method requires the `"span-locations"` feature to be enabled.
- #[cfg(span_locations)]
- pub fn start(&self) -> LineColumn {
- let imp::LineColumn { line, column } = self.inner.start();
- LineColumn { line, column }
- }
-
- /// Get the ending line/column in the source file for this span.
- ///
- /// This method requires the `"span-locations"` feature to be enabled.
- #[cfg(span_locations)]
- pub fn end(&self) -> LineColumn {
- let imp::LineColumn { line, column } = self.inner.end();
- LineColumn { line, column }
- }
-
- /// Create a new span encompassing `self` and `other`.
- ///
- /// Returns `None` if `self` and `other` are from different files.
- ///
- /// Warning: the underlying [`proc_macro::Span::join`] method is
- /// nightly-only. When called from within a procedural macro not using a
- /// nightly compiler, this method will always return `None`.
- ///
- /// [`proc_macro::Span::join`]: https://doc.rust-lang.org/proc_macro/struct.Span.html#method.join
- pub fn join(&self, other: Span) -> Option<Span> {
- self.inner.join(other.inner).map(Span::_new)
- }
-
- /// Compares two spans to see if they're equal.
- ///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
- pub fn eq(&self, other: &Span) -> bool {
- self.inner.eq(&other.inner)
- }
-}
-
-/// Prints a span in a form convenient for debugging.
-impl fmt::Debug for Span {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-/// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`).
-#[derive(Clone)]
-pub enum TokenTree {
- /// A token stream surrounded by bracket delimiters.
- Group(Group),
- /// An identifier.
- Ident(Ident),
- /// A single punctuation character (`+`, `,`, `$`, etc.).
- Punct(Punct),
- /// A literal character (`'a'`), string (`"hello"`), number (`2.3`), etc.
- Literal(Literal),
-}
-
-impl TokenTree {
- /// Returns the span of this tree, delegating to the `span` method of
- /// the contained token or a delimited stream.
- pub fn span(&self) -> Span {
- match *self {
- TokenTree::Group(ref t) => t.span(),
- TokenTree::Ident(ref t) => t.span(),
- TokenTree::Punct(ref t) => t.span(),
- TokenTree::Literal(ref t) => t.span(),
- }
- }
-
- /// Configures the span for *only this token*.
- ///
- /// Note that if this token is a `Group` then this method will not configure
- /// the span of each of the internal tokens, this will simply delegate to
- /// the `set_span` method of each variant.
- pub fn set_span(&mut self, span: Span) {
- match *self {
- TokenTree::Group(ref mut t) => t.set_span(span),
- TokenTree::Ident(ref mut t) => t.set_span(span),
- TokenTree::Punct(ref mut t) => t.set_span(span),
- TokenTree::Literal(ref mut t) => t.set_span(span),
- }
- }
-}
-
-impl From<Group> for TokenTree {
- fn from(g: Group) -> TokenTree {
- TokenTree::Group(g)
- }
-}
-
-impl From<Ident> for TokenTree {
- fn from(g: Ident) -> TokenTree {
- TokenTree::Ident(g)
- }
-}
-
-impl From<Punct> for TokenTree {
- fn from(g: Punct) -> TokenTree {
- TokenTree::Punct(g)
- }
-}
-
-impl From<Literal> for TokenTree {
- fn from(g: Literal) -> TokenTree {
- TokenTree::Literal(g)
- }
-}
-
-/// Prints the token tree as a string that is supposed to be losslessly
-/// convertible back into the same token tree (modulo spans), except for
-/// possibly `TokenTree::Group`s with `Delimiter::None` delimiters and negative
-/// numeric literals.
-impl fmt::Display for TokenTree {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match *self {
- TokenTree::Group(ref t) => t.fmt(f),
- TokenTree::Ident(ref t) => t.fmt(f),
- TokenTree::Punct(ref t) => t.fmt(f),
- TokenTree::Literal(ref t) => t.fmt(f),
- }
- }
-}
-
-/// Prints token tree in a form convenient for debugging.
-impl fmt::Debug for TokenTree {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- // Each of these has the name in the struct type in the derived debug,
- // so don't bother with an extra layer of indirection
- match *self {
- TokenTree::Group(ref t) => t.fmt(f),
- TokenTree::Ident(ref t) => {
- let mut debug = f.debug_struct("Ident");
- debug.field("sym", &format_args!("{}", t));
- imp::debug_span_field_if_nontrivial(&mut debug, t.span().inner);
- debug.finish()
- }
- TokenTree::Punct(ref t) => t.fmt(f),
- TokenTree::Literal(ref t) => t.fmt(f),
- }
- }
-}
-
-/// A delimited token stream.
-///
-/// A `Group` internally contains a `TokenStream` which is surrounded by
-/// `Delimiter`s.
-#[derive(Clone)]
-pub struct Group {
- inner: imp::Group,
-}
-
-/// Describes how a sequence of token trees is delimited.
-#[derive(Copy, Clone, Debug, Eq, PartialEq)]
-pub enum Delimiter {
- /// `( ... )`
- Parenthesis,
- /// `{ ... }`
- Brace,
- /// `[ ... ]`
- Bracket,
- /// `Ø ... Ø`
- ///
- /// An implicit delimiter, that may, for example, appear around tokens
- /// coming from a "macro variable" `$var`. It is important to preserve
- /// operator priorities in cases like `$var * 3` where `$var` is `1 + 2`.
- /// Implicit delimiters may not survive roundtrip of a token stream through
- /// a string.
- None,
-}
-
-impl Group {
- fn _new(inner: imp::Group) -> Self {
- Group { inner }
- }
-
- fn _new_stable(inner: fallback::Group) -> Self {
- Group {
- inner: inner.into(),
- }
- }
-
- /// Creates a new `Group` with the given delimiter and token stream.
- ///
- /// This constructor will set the span for this group to
- /// `Span::call_site()`. To change the span you can use the `set_span`
- /// method below.
- pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
- Group {
- inner: imp::Group::new(delimiter, stream.inner),
- }
- }
-
- /// Returns the delimiter of this `Group`
- pub fn delimiter(&self) -> Delimiter {
- self.inner.delimiter()
- }
-
- /// Returns the `TokenStream` of tokens that are delimited in this `Group`.
- ///
- /// Note that the returned token stream does not include the delimiter
- /// returned above.
- pub fn stream(&self) -> TokenStream {
- TokenStream::_new(self.inner.stream())
- }
-
- /// Returns the span for the delimiters of this token stream, spanning the
- /// entire `Group`.
- ///
- /// ```text
- /// pub fn span(&self) -> Span {
- /// ^^^^^^^
- /// ```
- pub fn span(&self) -> Span {
- Span::_new(self.inner.span())
- }
-
- /// Returns the span pointing to the opening delimiter of this group.
- ///
- /// ```text
- /// pub fn span_open(&self) -> Span {
- /// ^
- /// ```
- pub fn span_open(&self) -> Span {
- Span::_new(self.inner.span_open())
- }
-
- /// Returns the span pointing to the closing delimiter of this group.
- ///
- /// ```text
- /// pub fn span_close(&self) -> Span {
- /// ^
- /// ```
- pub fn span_close(&self) -> Span {
- Span::_new(self.inner.span_close())
- }
-
- /// Configures the span for this `Group`'s delimiters, but not its internal
- /// tokens.
- ///
- /// This method will **not** set the span of all the internal tokens spanned
- /// by this group, but rather it will only set the span of the delimiter
- /// tokens at the level of the `Group`.
- pub fn set_span(&mut self, span: Span) {
- self.inner.set_span(span.inner)
- }
-}
-
-/// Prints the group as a string that should be losslessly convertible back
-/// into the same group (modulo spans), except for possibly `TokenTree::Group`s
-/// with `Delimiter::None` delimiters.
-impl fmt::Display for Group {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(&self.inner, formatter)
- }
-}
-
-impl fmt::Debug for Group {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- fmt::Debug::fmt(&self.inner, formatter)
- }
-}
-
-/// An `Punct` is an single punctuation character like `+`, `-` or `#`.
-///
-/// Multicharacter operators like `+=` are represented as two instances of
-/// `Punct` with different forms of `Spacing` returned.
-#[derive(Clone)]
-pub struct Punct {
- op: char,
- spacing: Spacing,
- span: Span,
-}
-
-/// Whether an `Punct` is followed immediately by another `Punct` or followed by
-/// another token or whitespace.
-#[derive(Copy, Clone, Debug, Eq, PartialEq)]
-pub enum Spacing {
- /// E.g. `+` is `Alone` in `+ =`, `+ident` or `+()`.
- Alone,
- /// E.g. `+` is `Joint` in `+=` or `'` is `Joint` in `'#`.
- ///
- /// Additionally, single quote `'` can join with identifiers to form
- /// lifetimes `'ident`.
- Joint,
-}
-
-impl Punct {
- /// Creates a new `Punct` from the given character and spacing.
- ///
- /// The `ch` argument must be a valid punctuation character permitted by the
- /// language, otherwise the function will panic.
- ///
- /// The returned `Punct` will have the default span of `Span::call_site()`
- /// which can be further configured with the `set_span` method below.
- pub fn new(op: char, spacing: Spacing) -> Punct {
- Punct {
- op,
- spacing,
- span: Span::call_site(),
- }
- }
-
- /// Returns the value of this punctuation character as `char`.
- pub fn as_char(&self) -> char {
- self.op
- }
-
- /// Returns the spacing of this punctuation character, indicating whether
- /// it's immediately followed by another `Punct` in the token stream, so
- /// they can potentially be combined into a multicharacter operator
- /// (`Joint`), or it's followed by some other token or whitespace (`Alone`)
- /// so the operator has certainly ended.
- pub fn spacing(&self) -> Spacing {
- self.spacing
- }
-
- /// Returns the span for this punctuation character.
- pub fn span(&self) -> Span {
- self.span
- }
-
- /// Configure the span for this punctuation character.
- pub fn set_span(&mut self, span: Span) {
- self.span = span;
- }
-}
-
-/// Prints the punctuation character as a string that should be losslessly
-/// convertible back into the same character.
-impl fmt::Display for Punct {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.op.fmt(f)
- }
-}
-
-impl fmt::Debug for Punct {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- let mut debug = fmt.debug_struct("Punct");
- debug.field("op", &self.op);
- debug.field("spacing", &self.spacing);
- imp::debug_span_field_if_nontrivial(&mut debug, self.span.inner);
- debug.finish()
- }
-}
-
-/// A word of Rust code, which may be a keyword or legal variable name.
-///
-/// An identifier consists of at least one Unicode code point, the first of
-/// which has the XID_Start property and the rest of which have the XID_Continue
-/// property.
-///
-/// - The empty string is not an identifier. Use `Option<Ident>`.
-/// - A lifetime is not an identifier. Use `syn::Lifetime` instead.
-///
-/// An identifier constructed with `Ident::new` is permitted to be a Rust
-/// keyword, though parsing one through its [`Parse`] implementation rejects
-/// Rust keywords. Use `input.call(Ident::parse_any)` when parsing to match the
-/// behaviour of `Ident::new`.
-///
-/// [`Parse`]: https://docs.rs/syn/1.0/syn/parse/trait.Parse.html
-///
-/// # Examples
-///
-/// A new ident can be created from a string using the `Ident::new` function.
-/// A span must be provided explicitly which governs the name resolution
-/// behavior of the resulting identifier.
-///
-/// ```
-/// use proc_macro2::{Ident, Span};
-///
-/// fn main() {
-/// let call_ident = Ident::new("calligraphy", Span::call_site());
-///
-/// println!("{}", call_ident);
-/// }
-/// ```
-///
-/// An ident can be interpolated into a token stream using the `quote!` macro.
-///
-/// ```
-/// use proc_macro2::{Ident, Span};
-/// use quote::quote;
-///
-/// fn main() {
-/// let ident = Ident::new("demo", Span::call_site());
-///
-/// // Create a variable binding whose name is this ident.
-/// let expanded = quote! { let #ident = 10; };
-///
-/// // Create a variable binding with a slightly different name.
-/// let temp_ident = Ident::new(&format!("new_{}", ident), Span::call_site());
-/// let expanded = quote! { let #temp_ident = 10; };
-/// }
-/// ```
-///
-/// A string representation of the ident is available through the `to_string()`
-/// method.
-///
-/// ```
-/// # use proc_macro2::{Ident, Span};
-/// #
-/// # let ident = Ident::new("another_identifier", Span::call_site());
-/// #
-/// // Examine the ident as a string.
-/// let ident_string = ident.to_string();
-/// if ident_string.len() > 60 {
-/// println!("Very long identifier: {}", ident_string)
-/// }
-/// ```
-#[derive(Clone)]
-pub struct Ident {
- inner: imp::Ident,
- _marker: marker::PhantomData<Rc<()>>,
-}
-
-impl Ident {
- fn _new(inner: imp::Ident) -> Ident {
- Ident {
- inner,
- _marker: marker::PhantomData,
- }
- }
-
- /// Creates a new `Ident` with the given `string` as well as the specified
- /// `span`.
- ///
- /// The `string` argument must be a valid identifier permitted by the
- /// language, otherwise the function will panic.
- ///
- /// Note that `span`, currently in rustc, configures the hygiene information
- /// for this identifier.
- ///
- /// As of this time `Span::call_site()` explicitly opts-in to "call-site"
- /// hygiene meaning that identifiers created with this span will be resolved
- /// as if they were written directly at the location of the macro call, and
- /// other code at the macro call site will be able to refer to them as well.
- ///
- /// Later spans like `Span::def_site()` will allow to opt-in to
- /// "definition-site" hygiene meaning that identifiers created with this
- /// span will be resolved at the location of the macro definition and other
- /// code at the macro call site will not be able to refer to them.
- ///
- /// Due to the current importance of hygiene this constructor, unlike other
- /// tokens, requires a `Span` to be specified at construction.
- ///
- /// # Panics
- ///
- /// Panics if the input string is neither a keyword nor a legal variable
- /// name. If you are not sure whether the string contains an identifier and
- /// need to handle an error case, use
- /// <a href="https://docs.rs/syn/1.0/syn/fn.parse_str.html"><code
- /// style="padding-right:0;">syn::parse_str</code></a><code
- /// style="padding-left:0;">::&lt;Ident&gt;</code>
- /// rather than `Ident::new`.
- pub fn new(string: &str, span: Span) -> Ident {
- Ident::_new(imp::Ident::new(string, span.inner))
- }
-
- /// Same as `Ident::new`, but creates a raw identifier (`r#ident`).
- ///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
- pub fn new_raw(string: &str, span: Span) -> Ident {
- Ident::_new_raw(string, span)
- }
-
- fn _new_raw(string: &str, span: Span) -> Ident {
- Ident::_new(imp::Ident::new_raw(string, span.inner))
- }
-
- /// Returns the span of this `Ident`.
- pub fn span(&self) -> Span {
- Span::_new(self.inner.span())
- }
-
- /// Configures the span of this `Ident`, possibly changing its hygiene
- /// context.
- pub fn set_span(&mut self, span: Span) {
- self.inner.set_span(span.inner);
- }
-}
-
-impl PartialEq for Ident {
- fn eq(&self, other: &Ident) -> bool {
- self.inner == other.inner
- }
-}
-
-impl<T> PartialEq<T> for Ident
-where
- T: ?Sized + AsRef<str>,
-{
- fn eq(&self, other: &T) -> bool {
- self.inner == other
- }
-}
-
-impl Eq for Ident {}
-
-impl PartialOrd for Ident {
- fn partial_cmp(&self, other: &Ident) -> Option<Ordering> {
- Some(self.cmp(other))
- }
-}
-
-impl Ord for Ident {
- fn cmp(&self, other: &Ident) -> Ordering {
- self.to_string().cmp(&other.to_string())
- }
-}
-
-impl Hash for Ident {
- fn hash<H: Hasher>(&self, hasher: &mut H) {
- self.to_string().hash(hasher)
- }
-}
-
-/// Prints the identifier as a string that should be losslessly convertible back
-/// into the same identifier.
-impl fmt::Display for Ident {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-impl fmt::Debug for Ident {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-/// A literal string (`"hello"`), byte string (`b"hello"`), character (`'a'`),
-/// byte character (`b'a'`), an integer or floating point number with or without
-/// a suffix (`1`, `1u8`, `2.3`, `2.3f32`).
-///
-/// Boolean literals like `true` and `false` do not belong here, they are
-/// `Ident`s.
-#[derive(Clone)]
-pub struct Literal {
- inner: imp::Literal,
- _marker: marker::PhantomData<Rc<()>>,
-}
-
-macro_rules! suffixed_int_literals {
- ($($name:ident => $kind:ident,)*) => ($(
- /// Creates a new suffixed integer literal with the specified value.
- ///
- /// This function will create an integer like `1u32` where the integer
- /// value specified is the first part of the token and the integral is
- /// also suffixed at the end. Literals created from negative numbers may
- /// not survive rountrips through `TokenStream` or strings and may be
- /// broken into two tokens (`-` and positive literal).
- ///
- /// Literals created through this method have the `Span::call_site()`
- /// span by default, which can be configured with the `set_span` method
- /// below.
- pub fn $name(n: $kind) -> Literal {
- Literal::_new(imp::Literal::$name(n))
- }
- )*)
-}
-
-macro_rules! unsuffixed_int_literals {
- ($($name:ident => $kind:ident,)*) => ($(
- /// Creates a new unsuffixed integer literal with the specified value.
- ///
- /// This function will create an integer like `1` where the integer
- /// value specified is the first part of the token. No suffix is
- /// specified on this token, meaning that invocations like
- /// `Literal::i8_unsuffixed(1)` are equivalent to
- /// `Literal::u32_unsuffixed(1)`. Literals created from negative numbers
- /// may not survive rountrips through `TokenStream` or strings and may
- /// be broken into two tokens (`-` and positive literal).
- ///
- /// Literals created through this method have the `Span::call_site()`
- /// span by default, which can be configured with the `set_span` method
- /// below.
- pub fn $name(n: $kind) -> Literal {
- Literal::_new(imp::Literal::$name(n))
- }
- )*)
-}
-
-impl Literal {
- fn _new(inner: imp::Literal) -> Literal {
- Literal {
- inner,
- _marker: marker::PhantomData,
- }
- }
-
- fn _new_stable(inner: fallback::Literal) -> Literal {
- Literal {
- inner: inner.into(),
- _marker: marker::PhantomData,
- }
- }
-
- suffixed_int_literals! {
- u8_suffixed => u8,
- u16_suffixed => u16,
- u32_suffixed => u32,
- u64_suffixed => u64,
- u128_suffixed => u128,
- usize_suffixed => usize,
- i8_suffixed => i8,
- i16_suffixed => i16,
- i32_suffixed => i32,
- i64_suffixed => i64,
- i128_suffixed => i128,
- isize_suffixed => isize,
- }
-
- unsuffixed_int_literals! {
- u8_unsuffixed => u8,
- u16_unsuffixed => u16,
- u32_unsuffixed => u32,
- u64_unsuffixed => u64,
- u128_unsuffixed => u128,
- usize_unsuffixed => usize,
- i8_unsuffixed => i8,
- i16_unsuffixed => i16,
- i32_unsuffixed => i32,
- i64_unsuffixed => i64,
- i128_unsuffixed => i128,
- isize_unsuffixed => isize,
- }
-
- /// Creates a new unsuffixed floating-point literal.
- ///
- /// This constructor is similar to those like `Literal::i8_unsuffixed` where
- /// the float's value is emitted directly into the token but no suffix is
- /// used, so it may be inferred to be a `f64` later in the compiler.
- /// Literals created from negative numbers may not survive rountrips through
- /// `TokenStream` or strings and may be broken into two tokens (`-` and
- /// positive literal).
- ///
- /// # Panics
- ///
- /// This function requires that the specified float is finite, for example
- /// if it is infinity or NaN this function will panic.
- pub fn f64_unsuffixed(f: f64) -> Literal {
- assert!(f.is_finite());
- Literal::_new(imp::Literal::f64_unsuffixed(f))
- }
-
- /// Creates a new suffixed floating-point literal.
- ///
- /// This constructor will create a literal like `1.0f64` where the value
- /// specified is the preceding part of the token and `f64` is the suffix of
- /// the token. This token will always be inferred to be an `f64` in the
- /// compiler. Literals created from negative numbers may not survive
- /// rountrips through `TokenStream` or strings and may be broken into two
- /// tokens (`-` and positive literal).
- ///
- /// # Panics
- ///
- /// This function requires that the specified float is finite, for example
- /// if it is infinity or NaN this function will panic.
- pub fn f64_suffixed(f: f64) -> Literal {
- assert!(f.is_finite());
- Literal::_new(imp::Literal::f64_suffixed(f))
- }
-
- /// Creates a new unsuffixed floating-point literal.
- ///
- /// This constructor is similar to those like `Literal::i8_unsuffixed` where
- /// the float's value is emitted directly into the token but no suffix is
- /// used, so it may be inferred to be a `f64` later in the compiler.
- /// Literals created from negative numbers may not survive rountrips through
- /// `TokenStream` or strings and may be broken into two tokens (`-` and
- /// positive literal).
- ///
- /// # Panics
- ///
- /// This function requires that the specified float is finite, for example
- /// if it is infinity or NaN this function will panic.
- pub fn f32_unsuffixed(f: f32) -> Literal {
- assert!(f.is_finite());
- Literal::_new(imp::Literal::f32_unsuffixed(f))
- }
-
- /// Creates a new suffixed floating-point literal.
- ///
- /// This constructor will create a literal like `1.0f32` where the value
- /// specified is the preceding part of the token and `f32` is the suffix of
- /// the token. This token will always be inferred to be an `f32` in the
- /// compiler. Literals created from negative numbers may not survive
- /// rountrips through `TokenStream` or strings and may be broken into two
- /// tokens (`-` and positive literal).
- ///
- /// # Panics
- ///
- /// This function requires that the specified float is finite, for example
- /// if it is infinity or NaN this function will panic.
- pub fn f32_suffixed(f: f32) -> Literal {
- assert!(f.is_finite());
- Literal::_new(imp::Literal::f32_suffixed(f))
- }
-
- /// String literal.
- pub fn string(string: &str) -> Literal {
- Literal::_new(imp::Literal::string(string))
- }
-
- /// Character literal.
- pub fn character(ch: char) -> Literal {
- Literal::_new(imp::Literal::character(ch))
- }
-
- /// Byte string literal.
- pub fn byte_string(s: &[u8]) -> Literal {
- Literal::_new(imp::Literal::byte_string(s))
- }
-
- /// Returns the span encompassing this literal.
- pub fn span(&self) -> Span {
- Span::_new(self.inner.span())
- }
-
- /// Configures the span associated for this literal.
- pub fn set_span(&mut self, span: Span) {
- self.inner.set_span(span.inner);
- }
-
- /// Returns a `Span` that is a subset of `self.span()` containing only
- /// the source bytes in range `range`. Returns `None` if the would-be
- /// trimmed span is outside the bounds of `self`.
- ///
- /// Warning: the underlying [`proc_macro::Literal::subspan`] method is
- /// nightly-only. When called from within a procedural macro not using a
- /// nightly compiler, this method will always return `None`.
- ///
- /// [`proc_macro::Literal::subspan`]: https://doc.rust-lang.org/proc_macro/struct.Literal.html#method.subspan
- pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> {
- self.inner.subspan(range).map(Span::_new)
- }
-}
-
-impl fmt::Debug for Literal {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-impl fmt::Display for Literal {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
-}
-
-/// Public implementation details for the `TokenStream` type, such as iterators.
-pub mod token_stream {
- use std::fmt;
- use std::marker;
- use std::rc::Rc;
-
- pub use crate::TokenStream;
- use crate::{imp, TokenTree};
-
- /// An iterator over `TokenStream`'s `TokenTree`s.
- ///
- /// The iteration is "shallow", e.g. the iterator doesn't recurse into
- /// delimited groups, and returns whole groups as token trees.
- #[derive(Clone)]
- pub struct IntoIter {
- inner: imp::TokenTreeIter,
- _marker: marker::PhantomData<Rc<()>>,
- }
-
- impl Iterator for IntoIter {
- type Item = TokenTree;
-
- fn next(&mut self) -> Option<TokenTree> {
- self.inner.next()
- }
- }
-
- impl fmt::Debug for IntoIter {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(f)
- }
- }
-
- impl IntoIterator for TokenStream {
- type Item = TokenTree;
- type IntoIter = IntoIter;
-
- fn into_iter(self) -> IntoIter {
- IntoIter {
- inner: self.inner.into_iter(),
- _marker: marker::PhantomData,
- }
- }
- }
-}
diff --git a/proc-macro2/src/strnom.rs b/proc-macro2/src/strnom.rs
deleted file mode 100644
index eb7d0b8..0000000
--- a/proc-macro2/src/strnom.rs
+++ /dev/null
@@ -1,391 +0,0 @@
-//! Adapted from [`nom`](https://github.com/Geal/nom).
-
-use crate::fallback::LexError;
-use std::str::{Bytes, CharIndices, Chars};
-use unicode_xid::UnicodeXID;
-
-#[derive(Copy, Clone, Eq, PartialEq)]
-pub struct Cursor<'a> {
- pub rest: &'a str,
- #[cfg(span_locations)]
- pub off: u32,
-}
-
-impl<'a> Cursor<'a> {
- #[cfg(not(span_locations))]
- pub fn advance(&self, amt: usize) -> Cursor<'a> {
- Cursor {
- rest: &self.rest[amt..],
- }
- }
- #[cfg(span_locations)]
- pub fn advance(&self, amt: usize) -> Cursor<'a> {
- Cursor {
- rest: &self.rest[amt..],
- off: self.off + (amt as u32),
- }
- }
-
- pub fn find(&self, p: char) -> Option<usize> {
- self.rest.find(p)
- }
-
- pub fn starts_with(&self, s: &str) -> bool {
- self.rest.starts_with(s)
- }
-
- pub fn is_empty(&self) -> bool {
- self.rest.is_empty()
- }
-
- pub fn len(&self) -> usize {
- self.rest.len()
- }
-
- pub fn as_bytes(&self) -> &'a [u8] {
- self.rest.as_bytes()
- }
-
- pub fn bytes(&self) -> Bytes<'a> {
- self.rest.bytes()
- }
-
- pub fn chars(&self) -> Chars<'a> {
- self.rest.chars()
- }
-
- pub fn char_indices(&self) -> CharIndices<'a> {
- self.rest.char_indices()
- }
-}
-
-pub type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
-
-pub fn whitespace(input: Cursor) -> PResult<()> {
- if input.is_empty() {
- return Err(LexError);
- }
-
- let bytes = input.as_bytes();
- let mut i = 0;
- while i < bytes.len() {
- let s = input.advance(i);
- if bytes[i] == b'/' {
- if s.starts_with("//")
- && (!s.starts_with("///") || s.starts_with("////"))
- && !s.starts_with("//!")
- {
- if let Some(len) = s.find('\n') {
- i += len + 1;
- continue;
- }
- break;
- } else if s.starts_with("/**/") {
- i += 4;
- continue;
- } else if s.starts_with("/*")
- && (!s.starts_with("/**") || s.starts_with("/***"))
- && !s.starts_with("/*!")
- {
- let (_, com) = block_comment(s)?;
- i += com.len();
- continue;
- }
- }
- match bytes[i] {
- b' ' | 0x09..=0x0d => {
- i += 1;
- continue;
- }
- b if b <= 0x7f => {}
- _ => {
- let ch = s.chars().next().unwrap();
- if is_whitespace(ch) {
- i += ch.len_utf8();
- continue;
- }
- }
- }
- return if i > 0 { Ok((s, ())) } else { Err(LexError) };
- }
- Ok((input.advance(input.len()), ()))
-}
-
-pub fn block_comment(input: Cursor) -> PResult<&str> {
- if !input.starts_with("/*") {
- return Err(LexError);
- }
-
- let mut depth = 0;
- let bytes = input.as_bytes();
- let mut i = 0;
- let upper = bytes.len() - 1;
- while i < upper {
- if bytes[i] == b'/' && bytes[i + 1] == b'*' {
- depth += 1;
- i += 1; // eat '*'
- } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
- depth -= 1;
- if depth == 0 {
- return Ok((input.advance(i + 2), &input.rest[..i + 2]));
- }
- i += 1; // eat '/'
- }
- i += 1;
- }
- Err(LexError)
-}
-
-pub fn skip_whitespace(input: Cursor) -> Cursor {
- match whitespace(input) {
- Ok((rest, _)) => rest,
- Err(LexError) => input,
- }
-}
-
-fn is_whitespace(ch: char) -> bool {
- // Rust treats left-to-right mark and right-to-left mark as whitespace
- ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}'
-}
-
-pub fn word_break(input: Cursor) -> PResult<()> {
- match input.chars().next() {
- Some(ch) if UnicodeXID::is_xid_continue(ch) => Err(LexError),
- Some(_) | None => Ok((input, ())),
- }
-}
-
-macro_rules! named {
- ($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => {
- fn $name<'a>(i: Cursor<'a>) -> $crate::strnom::PResult<'a, $o> {
- $submac!(i, $($args)*)
- }
- };
-}
-
-macro_rules! alt {
- ($i:expr, $e:ident | $($rest:tt)*) => {
- alt!($i, call!($e) | $($rest)*)
- };
-
- ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => {
- match $subrule!($i, $($args)*) {
- res @ Ok(_) => res,
- _ => alt!($i, $($rest)*)
- }
- };
-
- ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => {
- match $subrule!($i, $($args)*) {
- Ok((i, o)) => Ok((i, $gen(o))),
- Err(LexError) => alt!($i, $($rest)*)
- }
- };
-
- ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => {
- alt!($i, call!($e) => { $gen } | $($rest)*)
- };
-
- ($i:expr, $e:ident => { $gen:expr }) => {
- alt!($i, call!($e) => { $gen })
- };
-
- ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => {
- match $subrule!($i, $($args)*) {
- Ok((i, o)) => Ok((i, $gen(o))),
- Err(LexError) => Err(LexError),
- }
- };
-
- ($i:expr, $e:ident) => {
- alt!($i, call!($e))
- };
-
- ($i:expr, $subrule:ident!( $($args:tt)*)) => {
- $subrule!($i, $($args)*)
- };
-}
-
-macro_rules! do_parse {
- ($i:expr, ( $($rest:expr),* )) => {
- Ok(($i, ( $($rest),* )))
- };
-
- ($i:expr, $e:ident >> $($rest:tt)*) => {
- do_parse!($i, call!($e) >> $($rest)*)
- };
-
- ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
- match $submac!($i, $($args)*) {
- Err(LexError) => Err(LexError),
- Ok((i, _)) => do_parse!(i, $($rest)*),
- }
- };
-
- ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => {
- do_parse!($i, $field: call!($e) >> $($rest)*)
- };
-
- ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
- match $submac!($i, $($args)*) {
- Err(LexError) => Err(LexError),
- Ok((i, o)) => {
- let $field = o;
- do_parse!(i, $($rest)*)
- },
- }
- };
-}
-
-macro_rules! peek {
- ($i:expr, $submac:ident!( $($args:tt)* )) => {
- match $submac!($i, $($args)*) {
- Ok((_, o)) => Ok(($i, o)),
- Err(LexError) => Err(LexError),
- }
- };
-}
-
-macro_rules! call {
- ($i:expr, $fun:expr $(, $args:expr)*) => {
- $fun($i $(, $args)*)
- };
-}
-
-macro_rules! option {
- ($i:expr, $f:expr) => {
- match $f($i) {
- Ok((i, o)) => Ok((i, Some(o))),
- Err(LexError) => Ok(($i, None)),
- }
- };
-}
-
-macro_rules! take_until_newline_or_eof {
- ($i:expr,) => {{
- if $i.len() == 0 {
- Ok(($i, ""))
- } else {
- match $i.find('\n') {
- Some(i) => Ok(($i.advance(i), &$i.rest[..i])),
- None => Ok(($i.advance($i.len()), &$i.rest[..$i.len()])),
- }
- }
- }};
-}
-
-macro_rules! tuple {
- ($i:expr, $($rest:tt)*) => {
- tuple_parser!($i, (), $($rest)*)
- };
-}
-
-/// Do not use directly. Use `tuple!`.
-macro_rules! tuple_parser {
- ($i:expr, ($($parsed:tt),*), $e:ident, $($rest:tt)*) => {
- tuple_parser!($i, ($($parsed),*), call!($e), $($rest)*)
- };
-
- ($i:expr, (), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => {
- match $submac!($i, $($args)*) {
- Err(LexError) => Err(LexError),
- Ok((i, o)) => tuple_parser!(i, (o), $($rest)*),
- }
- };
-
- ($i:expr, ($($parsed:tt)*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => {
- match $submac!($i, $($args)*) {
- Err(LexError) => Err(LexError),
- Ok((i, o)) => tuple_parser!(i, ($($parsed)* , o), $($rest)*),
- }
- };
-
- ($i:expr, ($($parsed:tt),*), $e:ident) => {
- tuple_parser!($i, ($($parsed),*), call!($e))
- };
-
- ($i:expr, (), $submac:ident!( $($args:tt)* )) => {
- $submac!($i, $($args)*)
- };
-
- ($i:expr, ($($parsed:expr),*), $submac:ident!( $($args:tt)* )) => {
- match $submac!($i, $($args)*) {
- Err(LexError) => Err(LexError),
- Ok((i, o)) => Ok((i, ($($parsed),*, o)))
- }
- };
-
- ($i:expr, ($($parsed:expr),*)) => {
- Ok(($i, ($($parsed),*)))
- };
-}
-
-macro_rules! not {
- ($i:expr, $submac:ident!( $($args:tt)* )) => {
- match $submac!($i, $($args)*) {
- Ok((_, _)) => Err(LexError),
- Err(LexError) => Ok(($i, ())),
- }
- };
-}
-
-macro_rules! tag {
- ($i:expr, $tag:expr) => {
- if $i.starts_with($tag) {
- Ok(($i.advance($tag.len()), &$i.rest[..$tag.len()]))
- } else {
- Err(LexError)
- }
- };
-}
-
-macro_rules! punct {
- ($i:expr, $punct:expr) => {
- $crate::strnom::punct($i, $punct)
- };
-}
-
-/// Do not use directly. Use `punct!`.
-pub fn punct<'a>(input: Cursor<'a>, token: &'static str) -> PResult<'a, &'a str> {
- let input = skip_whitespace(input);
- if input.starts_with(token) {
- Ok((input.advance(token.len()), token))
- } else {
- Err(LexError)
- }
-}
-
-macro_rules! preceded {
- ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => {
- match tuple!($i, $submac!($($args)*), $submac2!($($args2)*)) {
- Ok((remaining, (_, o))) => Ok((remaining, o)),
- Err(LexError) => Err(LexError),
- }
- };
-
- ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
- preceded!($i, $submac!($($args)*), call!($g))
- };
-}
-
-macro_rules! delimited {
- ($i:expr, $submac:ident!( $($args:tt)* ), $($rest:tt)+) => {
- match tuple_parser!($i, (), $submac!($($args)*), $($rest)*) {
- Err(LexError) => Err(LexError),
- Ok((i1, (_, o, _))) => Ok((i1, o))
- }
- };
-}
-
-macro_rules! map {
- ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
- match $submac!($i, $($args)*) {
- Err(LexError) => Err(LexError),
- Ok((i, o)) => Ok((i, call!(o, $g)))
- }
- };
-
- ($i:expr, $f:expr, $g:expr) => {
- map!($i, call!($f), $g)
- };
-}
diff --git a/proc-macro2/src/wrapper.rs b/proc-macro2/src/wrapper.rs
deleted file mode 100644
index 552b938..0000000
--- a/proc-macro2/src/wrapper.rs
+++ /dev/null
@@ -1,927 +0,0 @@
-use std::fmt;
-use std::iter;
-use std::ops::RangeBounds;
-use std::panic::{self, PanicInfo};
-#[cfg(super_unstable)]
-use std::path::PathBuf;
-use std::str::FromStr;
-
-use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
-
-#[derive(Clone)]
-pub enum TokenStream {
- Compiler(DeferredTokenStream),
- Fallback(fallback::TokenStream),
-}
-
-// Work around https://github.com/rust-lang/rust/issues/65080.
-// In `impl Extend<TokenTree> for TokenStream` which is used heavily by quote,
-// we hold on to the appended tokens and do proc_macro::TokenStream::extend as
-// late as possible to batch together consecutive uses of the Extend impl.
-#[derive(Clone)]
-pub struct DeferredTokenStream {
- stream: proc_macro::TokenStream,
- extra: Vec<proc_macro::TokenTree>,
-}
-
-pub enum LexError {
- Compiler(proc_macro::LexError),
- Fallback(fallback::LexError),
-}
-
-fn nightly_works() -> bool {
- use std::sync::atomic::*;
- use std::sync::Once;
-
- static WORKS: AtomicUsize = AtomicUsize::new(0);
- static INIT: Once = Once::new();
-
- match WORKS.load(Ordering::SeqCst) {
- 1 => return false,
- 2 => return true,
- _ => {}
- }
-
- // Swap in a null panic hook to avoid printing "thread panicked" to stderr,
- // then use catch_unwind to determine whether the compiler's proc_macro is
- // working. When proc-macro2 is used from outside of a procedural macro all
- // of the proc_macro crate's APIs currently panic.
- //
- // The Once is to prevent the possibility of this ordering:
- //
- // thread 1 calls take_hook, gets the user's original hook
- // thread 1 calls set_hook with the null hook
- // thread 2 calls take_hook, thinks null hook is the original hook
- // thread 2 calls set_hook with the null hook
- // thread 1 calls set_hook with the actual original hook
- // thread 2 calls set_hook with what it thinks is the original hook
- //
- // in which the user's hook has been lost.
- //
- // There is still a race condition where a panic in a different thread can
- // happen during the interval that the user's original panic hook is
- // unregistered such that their hook is incorrectly not called. This is
- // sufficiently unlikely and less bad than printing panic messages to stderr
- // on correct use of this crate. Maybe there is a libstd feature request
- // here. For now, if a user needs to guarantee that this failure mode does
- // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from
- // the main thread before launching any other threads.
- INIT.call_once(|| {
- type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static;
-
- let null_hook: Box<PanicHook> = Box::new(|_panic_info| { /* ignore */ });
- let sanity_check = &*null_hook as *const PanicHook;
- let original_hook = panic::take_hook();
- panic::set_hook(null_hook);
-
- let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok();
- WORKS.store(works as usize + 1, Ordering::SeqCst);
-
- let hopefully_null_hook = panic::take_hook();
- panic::set_hook(original_hook);
- if sanity_check != &*hopefully_null_hook {
- panic!("observed race condition in proc_macro2::nightly_works");
- }
- });
- nightly_works()
-}
-
-fn mismatch() -> ! {
- panic!("stable/nightly mismatch")
-}
-
-impl DeferredTokenStream {
- fn new(stream: proc_macro::TokenStream) -> Self {
- DeferredTokenStream {
- stream,
- extra: Vec::new(),
- }
- }
-
- fn is_empty(&self) -> bool {
- self.stream.is_empty() && self.extra.is_empty()
- }
-
- fn evaluate_now(&mut self) {
- self.stream.extend(self.extra.drain(..));
- }
-
- fn into_token_stream(mut self) -> proc_macro::TokenStream {
- self.evaluate_now();
- self.stream
- }
-}
-
-impl TokenStream {
- pub fn new() -> TokenStream {
- if nightly_works() {
- TokenStream::Compiler(DeferredTokenStream::new(proc_macro::TokenStream::new()))
- } else {
- TokenStream::Fallback(fallback::TokenStream::new())
- }
- }
-
- pub fn is_empty(&self) -> bool {
- match self {
- TokenStream::Compiler(tts) => tts.is_empty(),
- TokenStream::Fallback(tts) => tts.is_empty(),
- }
- }
-
- fn unwrap_nightly(self) -> proc_macro::TokenStream {
- match self {
- TokenStream::Compiler(s) => s.into_token_stream(),
- TokenStream::Fallback(_) => mismatch(),
- }
- }
-
- fn unwrap_stable(self) -> fallback::TokenStream {
- match self {
- TokenStream::Compiler(_) => mismatch(),
- TokenStream::Fallback(s) => s,
- }
- }
-}
-
-impl FromStr for TokenStream {
- type Err = LexError;
-
- fn from_str(src: &str) -> Result<TokenStream, LexError> {
- if nightly_works() {
- Ok(TokenStream::Compiler(DeferredTokenStream::new(
- src.parse()?,
- )))
- } else {
- Ok(TokenStream::Fallback(src.parse()?))
- }
- }
-}
-
-impl fmt::Display for TokenStream {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- TokenStream::Compiler(tts) => tts.clone().into_token_stream().fmt(f),
- TokenStream::Fallback(tts) => tts.fmt(f),
- }
- }
-}
-
-impl From<proc_macro::TokenStream> for TokenStream {
- fn from(inner: proc_macro::TokenStream) -> TokenStream {
- TokenStream::Compiler(DeferredTokenStream::new(inner))
- }
-}
-
-impl From<TokenStream> for proc_macro::TokenStream {
- fn from(inner: TokenStream) -> proc_macro::TokenStream {
- match inner {
- TokenStream::Compiler(inner) => inner.into_token_stream(),
- TokenStream::Fallback(inner) => inner.to_string().parse().unwrap(),
- }
- }
-}
-
-impl From<fallback::TokenStream> for TokenStream {
- fn from(inner: fallback::TokenStream) -> TokenStream {
- TokenStream::Fallback(inner)
- }
-}
-
-// Assumes nightly_works().
-fn into_compiler_token(token: TokenTree) -> proc_macro::TokenTree {
- match token {
- TokenTree::Group(tt) => tt.inner.unwrap_nightly().into(),
- TokenTree::Punct(tt) => {
- let spacing = match tt.spacing() {
- Spacing::Joint => proc_macro::Spacing::Joint,
- Spacing::Alone => proc_macro::Spacing::Alone,
- };
- let mut op = proc_macro::Punct::new(tt.as_char(), spacing);
- op.set_span(tt.span().inner.unwrap_nightly());
- op.into()
- }
- TokenTree::Ident(tt) => tt.inner.unwrap_nightly().into(),
- TokenTree::Literal(tt) => tt.inner.unwrap_nightly().into(),
- }
-}
-
-impl From<TokenTree> for TokenStream {
- fn from(token: TokenTree) -> TokenStream {
- if nightly_works() {
- TokenStream::Compiler(DeferredTokenStream::new(into_compiler_token(token).into()))
- } else {
- TokenStream::Fallback(token.into())
- }
- }
-}
-
-impl iter::FromIterator<TokenTree> for TokenStream {
- fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self {
- if nightly_works() {
- TokenStream::Compiler(DeferredTokenStream::new(
- trees.into_iter().map(into_compiler_token).collect(),
- ))
- } else {
- TokenStream::Fallback(trees.into_iter().collect())
- }
- }
-}
-
-impl iter::FromIterator<TokenStream> for TokenStream {
- fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
- let mut streams = streams.into_iter();
- match streams.next() {
- Some(TokenStream::Compiler(mut first)) => {
- first.evaluate_now();
- first.stream.extend(streams.map(|s| match s {
- TokenStream::Compiler(s) => s.into_token_stream(),
- TokenStream::Fallback(_) => mismatch(),
- }));
- TokenStream::Compiler(first)
- }
- Some(TokenStream::Fallback(mut first)) => {
- first.extend(streams.map(|s| match s {
- TokenStream::Fallback(s) => s,
- TokenStream::Compiler(_) => mismatch(),
- }));
- TokenStream::Fallback(first)
- }
- None => TokenStream::new(),
- }
- }
-}
-
-impl Extend<TokenTree> for TokenStream {
- fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I) {
- match self {
- TokenStream::Compiler(tts) => {
- // Here is the reason for DeferredTokenStream.
- tts.extra
- .extend(streams.into_iter().map(into_compiler_token));
- }
- TokenStream::Fallback(tts) => tts.extend(streams),
- }
- }
-}
-
-impl Extend<TokenStream> for TokenStream {
- fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
- match self {
- TokenStream::Compiler(tts) => {
- tts.evaluate_now();
- tts.stream
- .extend(streams.into_iter().map(|stream| stream.unwrap_nightly()));
- }
- TokenStream::Fallback(tts) => {
- tts.extend(streams.into_iter().map(|stream| stream.unwrap_stable()));
- }
- }
- }
-}
-
-impl fmt::Debug for TokenStream {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- TokenStream::Compiler(tts) => tts.clone().into_token_stream().fmt(f),
- TokenStream::Fallback(tts) => tts.fmt(f),
- }
- }
-}
-
-impl From<proc_macro::LexError> for LexError {
- fn from(e: proc_macro::LexError) -> LexError {
- LexError::Compiler(e)
- }
-}
-
-impl From<fallback::LexError> for LexError {
- fn from(e: fallback::LexError) -> LexError {
- LexError::Fallback(e)
- }
-}
-
-impl fmt::Debug for LexError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- LexError::Compiler(e) => e.fmt(f),
- LexError::Fallback(e) => e.fmt(f),
- }
- }
-}
-
-#[derive(Clone)]
-pub enum TokenTreeIter {
- Compiler(proc_macro::token_stream::IntoIter),
- Fallback(fallback::TokenTreeIter),
-}
-
-impl IntoIterator for TokenStream {
- type Item = TokenTree;
- type IntoIter = TokenTreeIter;
-
- fn into_iter(self) -> TokenTreeIter {
- match self {
- TokenStream::Compiler(tts) => {
- TokenTreeIter::Compiler(tts.into_token_stream().into_iter())
- }
- TokenStream::Fallback(tts) => TokenTreeIter::Fallback(tts.into_iter()),
- }
- }
-}
-
-impl Iterator for TokenTreeIter {
- type Item = TokenTree;
-
- fn next(&mut self) -> Option<TokenTree> {
- let token = match self {
- TokenTreeIter::Compiler(iter) => iter.next()?,
- TokenTreeIter::Fallback(iter) => return iter.next(),
- };
- Some(match token {
- proc_macro::TokenTree::Group(tt) => crate::Group::_new(Group::Compiler(tt)).into(),
- proc_macro::TokenTree::Punct(tt) => {
- let spacing = match tt.spacing() {
- proc_macro::Spacing::Joint => Spacing::Joint,
- proc_macro::Spacing::Alone => Spacing::Alone,
- };
- let mut o = Punct::new(tt.as_char(), spacing);
- o.set_span(crate::Span::_new(Span::Compiler(tt.span())));
- o.into()
- }
- proc_macro::TokenTree::Ident(s) => crate::Ident::_new(Ident::Compiler(s)).into(),
- proc_macro::TokenTree::Literal(l) => crate::Literal::_new(Literal::Compiler(l)).into(),
- })
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- match self {
- TokenTreeIter::Compiler(tts) => tts.size_hint(),
- TokenTreeIter::Fallback(tts) => tts.size_hint(),
- }
- }
-}
-
-impl fmt::Debug for TokenTreeIter {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("TokenTreeIter").finish()
- }
-}
-
-#[derive(Clone, PartialEq, Eq)]
-#[cfg(super_unstable)]
-pub enum SourceFile {
- Compiler(proc_macro::SourceFile),
- Fallback(fallback::SourceFile),
-}
-
-#[cfg(super_unstable)]
-impl SourceFile {
- fn nightly(sf: proc_macro::SourceFile) -> Self {
- SourceFile::Compiler(sf)
- }
-
- /// Get the path to this source file as a string.
- pub fn path(&self) -> PathBuf {
- match self {
- SourceFile::Compiler(a) => a.path(),
- SourceFile::Fallback(a) => a.path(),
- }
- }
-
- pub fn is_real(&self) -> bool {
- match self {
- SourceFile::Compiler(a) => a.is_real(),
- SourceFile::Fallback(a) => a.is_real(),
- }
- }
-}
-
-#[cfg(super_unstable)]
-impl fmt::Debug for SourceFile {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- SourceFile::Compiler(a) => a.fmt(f),
- SourceFile::Fallback(a) => a.fmt(f),
- }
- }
-}
-
-#[cfg(any(super_unstable, feature = "span-locations"))]
-pub struct LineColumn {
- pub line: usize,
- pub column: usize,
-}
-
-#[derive(Copy, Clone)]
-pub enum Span {
- Compiler(proc_macro::Span),
- Fallback(fallback::Span),
-}
-
-impl Span {
- pub fn call_site() -> Span {
- if nightly_works() {
- Span::Compiler(proc_macro::Span::call_site())
- } else {
- Span::Fallback(fallback::Span::call_site())
- }
- }
-
- #[cfg(super_unstable)]
- pub fn def_site() -> Span {
- if nightly_works() {
- Span::Compiler(proc_macro::Span::def_site())
- } else {
- Span::Fallback(fallback::Span::def_site())
- }
- }
-
- #[cfg(super_unstable)]
- pub fn resolved_at(&self, other: Span) -> Span {
- match (self, other) {
- (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)),
- (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)),
- _ => mismatch(),
- }
- }
-
- #[cfg(super_unstable)]
- pub fn located_at(&self, other: Span) -> Span {
- match (self, other) {
- (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)),
- (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)),
- _ => mismatch(),
- }
- }
-
- pub fn unwrap(self) -> proc_macro::Span {
- match self {
- Span::Compiler(s) => s,
- Span::Fallback(_) => panic!("proc_macro::Span is only available in procedural macros"),
- }
- }
-
- #[cfg(super_unstable)]
- pub fn source_file(&self) -> SourceFile {
- match self {
- Span::Compiler(s) => SourceFile::nightly(s.source_file()),
- Span::Fallback(s) => SourceFile::Fallback(s.source_file()),
- }
- }
-
- #[cfg(any(super_unstable, feature = "span-locations"))]
- pub fn start(&self) -> LineColumn {
- match self {
- #[cfg(proc_macro_span)]
- Span::Compiler(s) => {
- let proc_macro::LineColumn { line, column } = s.start();
- LineColumn { line, column }
- }
- #[cfg(not(proc_macro_span))]
- Span::Compiler(_) => LineColumn { line: 0, column: 0 },
- Span::Fallback(s) => {
- let fallback::LineColumn { line, column } = s.start();
- LineColumn { line, column }
- }
- }
- }
-
- #[cfg(any(super_unstable, feature = "span-locations"))]
- pub fn end(&self) -> LineColumn {
- match self {
- #[cfg(proc_macro_span)]
- Span::Compiler(s) => {
- let proc_macro::LineColumn { line, column } = s.end();
- LineColumn { line, column }
- }
- #[cfg(not(proc_macro_span))]
- Span::Compiler(_) => LineColumn { line: 0, column: 0 },
- Span::Fallback(s) => {
- let fallback::LineColumn { line, column } = s.end();
- LineColumn { line, column }
- }
- }
- }
-
- pub fn join(&self, other: Span) -> Option<Span> {
- let ret = match (self, other) {
- #[cfg(proc_macro_span)]
- (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.join(b)?),
- (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.join(b)?),
- _ => return None,
- };
- Some(ret)
- }
-
- #[cfg(super_unstable)]
- pub fn eq(&self, other: &Span) -> bool {
- match (self, other) {
- (Span::Compiler(a), Span::Compiler(b)) => a.eq(b),
- (Span::Fallback(a), Span::Fallback(b)) => a.eq(b),
- _ => false,
- }
- }
-
- fn unwrap_nightly(self) -> proc_macro::Span {
- match self {
- Span::Compiler(s) => s,
- Span::Fallback(_) => mismatch(),
- }
- }
-}
-
-impl From<proc_macro::Span> for crate::Span {
- fn from(proc_span: proc_macro::Span) -> crate::Span {
- crate::Span::_new(Span::Compiler(proc_span))
- }
-}
-
-impl From<fallback::Span> for Span {
- fn from(inner: fallback::Span) -> Span {
- Span::Fallback(inner)
- }
-}
-
-impl fmt::Debug for Span {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Span::Compiler(s) => s.fmt(f),
- Span::Fallback(s) => s.fmt(f),
- }
- }
-}
-
-pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
- match span {
- Span::Compiler(s) => {
- debug.field("span", &s);
- }
- Span::Fallback(s) => fallback::debug_span_field_if_nontrivial(debug, s),
- }
-}
-
-#[derive(Clone)]
-pub enum Group {
- Compiler(proc_macro::Group),
- Fallback(fallback::Group),
-}
-
-impl Group {
- pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
- match stream {
- TokenStream::Compiler(tts) => {
- let delimiter = match delimiter {
- Delimiter::Parenthesis => proc_macro::Delimiter::Parenthesis,
- Delimiter::Bracket => proc_macro::Delimiter::Bracket,
- Delimiter::Brace => proc_macro::Delimiter::Brace,
- Delimiter::None => proc_macro::Delimiter::None,
- };
- Group::Compiler(proc_macro::Group::new(delimiter, tts.into_token_stream()))
- }
- TokenStream::Fallback(stream) => {
- Group::Fallback(fallback::Group::new(delimiter, stream))
- }
- }
- }
-
- pub fn delimiter(&self) -> Delimiter {
- match self {
- Group::Compiler(g) => match g.delimiter() {
- proc_macro::Delimiter::Parenthesis => Delimiter::Parenthesis,
- proc_macro::Delimiter::Bracket => Delimiter::Bracket,
- proc_macro::Delimiter::Brace => Delimiter::Brace,
- proc_macro::Delimiter::None => Delimiter::None,
- },
- Group::Fallback(g) => g.delimiter(),
- }
- }
-
- pub fn stream(&self) -> TokenStream {
- match self {
- Group::Compiler(g) => TokenStream::Compiler(DeferredTokenStream::new(g.stream())),
- Group::Fallback(g) => TokenStream::Fallback(g.stream()),
- }
- }
-
- pub fn span(&self) -> Span {
- match self {
- Group::Compiler(g) => Span::Compiler(g.span()),
- Group::Fallback(g) => Span::Fallback(g.span()),
- }
- }
-
- pub fn span_open(&self) -> Span {
- match self {
- #[cfg(proc_macro_span)]
- Group::Compiler(g) => Span::Compiler(g.span_open()),
- #[cfg(not(proc_macro_span))]
- Group::Compiler(g) => Span::Compiler(g.span()),
- Group::Fallback(g) => Span::Fallback(g.span_open()),
- }
- }
-
- pub fn span_close(&self) -> Span {
- match self {
- #[cfg(proc_macro_span)]
- Group::Compiler(g) => Span::Compiler(g.span_close()),
- #[cfg(not(proc_macro_span))]
- Group::Compiler(g) => Span::Compiler(g.span()),
- Group::Fallback(g) => Span::Fallback(g.span_close()),
- }
- }
-
- pub fn set_span(&mut self, span: Span) {
- match (self, span) {
- (Group::Compiler(g), Span::Compiler(s)) => g.set_span(s),
- (Group::Fallback(g), Span::Fallback(s)) => g.set_span(s),
- _ => mismatch(),
- }
- }
-
- fn unwrap_nightly(self) -> proc_macro::Group {
- match self {
- Group::Compiler(g) => g,
- Group::Fallback(_) => mismatch(),
- }
- }
-}
-
-impl From<fallback::Group> for Group {
- fn from(g: fallback::Group) -> Self {
- Group::Fallback(g)
- }
-}
-
-impl fmt::Display for Group {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Group::Compiler(group) => group.fmt(formatter),
- Group::Fallback(group) => group.fmt(formatter),
- }
- }
-}
-
-impl fmt::Debug for Group {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Group::Compiler(group) => group.fmt(formatter),
- Group::Fallback(group) => group.fmt(formatter),
- }
- }
-}
-
-#[derive(Clone)]
-pub enum Ident {
- Compiler(proc_macro::Ident),
- Fallback(fallback::Ident),
-}
-
-impl Ident {
- pub fn new(string: &str, span: Span) -> Ident {
- match span {
- Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)),
- Span::Fallback(s) => Ident::Fallback(fallback::Ident::new(string, s)),
- }
- }
-
- pub fn new_raw(string: &str, span: Span) -> Ident {
- match span {
- Span::Compiler(s) => {
- let p: proc_macro::TokenStream = string.parse().unwrap();
- let ident = match p.into_iter().next() {
- Some(proc_macro::TokenTree::Ident(mut i)) => {
- i.set_span(s);
- i
- }
- _ => panic!(),
- };
- Ident::Compiler(ident)
- }
- Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw(string, s)),
- }
- }
-
- pub fn span(&self) -> Span {
- match self {
- Ident::Compiler(t) => Span::Compiler(t.span()),
- Ident::Fallback(t) => Span::Fallback(t.span()),
- }
- }
-
- pub fn set_span(&mut self, span: Span) {
- match (self, span) {
- (Ident::Compiler(t), Span::Compiler(s)) => t.set_span(s),
- (Ident::Fallback(t), Span::Fallback(s)) => t.set_span(s),
- _ => mismatch(),
- }
- }
-
- fn unwrap_nightly(self) -> proc_macro::Ident {
- match self {
- Ident::Compiler(s) => s,
- Ident::Fallback(_) => mismatch(),
- }
- }
-}
-
-impl PartialEq for Ident {
- fn eq(&self, other: &Ident) -> bool {
- match (self, other) {
- (Ident::Compiler(t), Ident::Compiler(o)) => t.to_string() == o.to_string(),
- (Ident::Fallback(t), Ident::Fallback(o)) => t == o,
- _ => mismatch(),
- }
- }
-}
-
-impl<T> PartialEq<T> for Ident
-where
- T: ?Sized + AsRef<str>,
-{
- fn eq(&self, other: &T) -> bool {
- let other = other.as_ref();
- match self {
- Ident::Compiler(t) => t.to_string() == other,
- Ident::Fallback(t) => t == other,
- }
- }
-}
-
-impl fmt::Display for Ident {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Ident::Compiler(t) => t.fmt(f),
- Ident::Fallback(t) => t.fmt(f),
- }
- }
-}
-
-impl fmt::Debug for Ident {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Ident::Compiler(t) => t.fmt(f),
- Ident::Fallback(t) => t.fmt(f),
- }
- }
-}
-
-#[derive(Clone)]
-pub enum Literal {
- Compiler(proc_macro::Literal),
- Fallback(fallback::Literal),
-}
-
-macro_rules! suffixed_numbers {
- ($($name:ident => $kind:ident,)*) => ($(
- pub fn $name(n: $kind) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::$name(n))
- } else {
- Literal::Fallback(fallback::Literal::$name(n))
- }
- }
- )*)
-}
-
-macro_rules! unsuffixed_integers {
- ($($name:ident => $kind:ident,)*) => ($(
- pub fn $name(n: $kind) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::$name(n))
- } else {
- Literal::Fallback(fallback::Literal::$name(n))
- }
- }
- )*)
-}
-
-impl Literal {
- suffixed_numbers! {
- u8_suffixed => u8,
- u16_suffixed => u16,
- u32_suffixed => u32,
- u64_suffixed => u64,
- u128_suffixed => u128,
- usize_suffixed => usize,
- i8_suffixed => i8,
- i16_suffixed => i16,
- i32_suffixed => i32,
- i64_suffixed => i64,
- i128_suffixed => i128,
- isize_suffixed => isize,
-
- f32_suffixed => f32,
- f64_suffixed => f64,
- }
-
- unsuffixed_integers! {
- u8_unsuffixed => u8,
- u16_unsuffixed => u16,
- u32_unsuffixed => u32,
- u64_unsuffixed => u64,
- u128_unsuffixed => u128,
- usize_unsuffixed => usize,
- i8_unsuffixed => i8,
- i16_unsuffixed => i16,
- i32_unsuffixed => i32,
- i64_unsuffixed => i64,
- i128_unsuffixed => i128,
- isize_unsuffixed => isize,
- }
-
- pub fn f32_unsuffixed(f: f32) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::f32_unsuffixed(f))
- } else {
- Literal::Fallback(fallback::Literal::f32_unsuffixed(f))
- }
- }
-
- pub fn f64_unsuffixed(f: f64) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::f64_unsuffixed(f))
- } else {
- Literal::Fallback(fallback::Literal::f64_unsuffixed(f))
- }
- }
-
- pub fn string(t: &str) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::string(t))
- } else {
- Literal::Fallback(fallback::Literal::string(t))
- }
- }
-
- pub fn character(t: char) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::character(t))
- } else {
- Literal::Fallback(fallback::Literal::character(t))
- }
- }
-
- pub fn byte_string(bytes: &[u8]) -> Literal {
- if nightly_works() {
- Literal::Compiler(proc_macro::Literal::byte_string(bytes))
- } else {
- Literal::Fallback(fallback::Literal::byte_string(bytes))
- }
- }
-
- pub fn span(&self) -> Span {
- match self {
- Literal::Compiler(lit) => Span::Compiler(lit.span()),
- Literal::Fallback(lit) => Span::Fallback(lit.span()),
- }
- }
-
- pub fn set_span(&mut self, span: Span) {
- match (self, span) {
- (Literal::Compiler(lit), Span::Compiler(s)) => lit.set_span(s),
- (Literal::Fallback(lit), Span::Fallback(s)) => lit.set_span(s),
- _ => mismatch(),
- }
- }
-
- pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> {
- match self {
- #[cfg(proc_macro_span)]
- Literal::Compiler(lit) => lit.subspan(range).map(Span::Compiler),
- #[cfg(not(proc_macro_span))]
- Literal::Compiler(_lit) => None,
- Literal::Fallback(lit) => lit.subspan(range).map(Span::Fallback),
- }
- }
-
- fn unwrap_nightly(self) -> proc_macro::Literal {
- match self {
- Literal::Compiler(s) => s,
- Literal::Fallback(_) => mismatch(),
- }
- }
-}
-
-impl From<fallback::Literal> for Literal {
- fn from(s: fallback::Literal) -> Literal {
- Literal::Fallback(s)
- }
-}
-
-impl fmt::Display for Literal {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Literal::Compiler(t) => t.fmt(f),
- Literal::Fallback(t) => t.fmt(f),
- }
- }
-}
-
-impl fmt::Debug for Literal {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Literal::Compiler(t) => t.fmt(f),
- Literal::Fallback(t) => t.fmt(f),
- }
- }
-}
diff --git a/proc-macro2/tests/features.rs b/proc-macro2/tests/features.rs
deleted file mode 100644
index 073f6e6..0000000
--- a/proc-macro2/tests/features.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#[test]
-#[ignore]
-fn make_sure_no_proc_macro() {
- assert!(
- !cfg!(feature = "proc-macro"),
- "still compiled with proc_macro?"
- );
-}
diff --git a/proc-macro2/tests/marker.rs b/proc-macro2/tests/marker.rs
deleted file mode 100644
index 7af2539..0000000
--- a/proc-macro2/tests/marker.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-use proc_macro2::*;
-
-macro_rules! assert_impl {
- ($ty:ident is $($marker:ident) and +) => {
- #[test]
- #[allow(non_snake_case)]
- fn $ty() {
- fn assert_implemented<T: $($marker +)+>() {}
- assert_implemented::<$ty>();
- }
- };
-
- ($ty:ident is not $($marker:ident) or +) => {
- #[test]
- #[allow(non_snake_case)]
- fn $ty() {
- $(
- {
- // Implemented for types that implement $marker.
- trait IsNotImplemented {
- fn assert_not_implemented() {}
- }
- impl<T: $marker> IsNotImplemented for T {}
-
- // Implemented for the type being tested.
- trait IsImplemented {
- fn assert_not_implemented() {}
- }
- impl IsImplemented for $ty {}
-
- // If $ty does not implement $marker, there is no ambiguity
- // in the following trait method call.
- <$ty>::assert_not_implemented();
- }
- )+
- }
- };
-}
-
-assert_impl!(Delimiter is Send and Sync);
-assert_impl!(Spacing is Send and Sync);
-
-assert_impl!(Group is not Send or Sync);
-assert_impl!(Ident is not Send or Sync);
-assert_impl!(LexError is not Send or Sync);
-assert_impl!(Literal is not Send or Sync);
-assert_impl!(Punct is not Send or Sync);
-assert_impl!(Span is not Send or Sync);
-assert_impl!(TokenStream is not Send or Sync);
-assert_impl!(TokenTree is not Send or Sync);
-
-#[cfg(procmacro2_semver_exempt)]
-mod semver_exempt {
- use super::*;
-
- assert_impl!(LineColumn is Send and Sync);
-
- assert_impl!(SourceFile is not Send or Sync);
-}
diff --git a/proc-macro2/tests/test.rs b/proc-macro2/tests/test.rs
deleted file mode 100644
index 7528388..0000000
--- a/proc-macro2/tests/test.rs
+++ /dev/null
@@ -1,466 +0,0 @@
-use std::str::{self, FromStr};
-
-use proc_macro2::{Ident, Literal, Spacing, Span, TokenStream, TokenTree};
-
-#[test]
-fn idents() {
- assert_eq!(
- Ident::new("String", Span::call_site()).to_string(),
- "String"
- );
- assert_eq!(Ident::new("fn", Span::call_site()).to_string(), "fn");
- assert_eq!(Ident::new("_", Span::call_site()).to_string(), "_");
-}
-
-#[test]
-#[cfg(procmacro2_semver_exempt)]
-fn raw_idents() {
- assert_eq!(
- Ident::new_raw("String", Span::call_site()).to_string(),
- "r#String"
- );
- assert_eq!(Ident::new_raw("fn", Span::call_site()).to_string(), "r#fn");
- assert_eq!(Ident::new_raw("_", Span::call_site()).to_string(), "r#_");
-}
-
-#[test]
-#[should_panic(expected = "Ident is not allowed to be empty; use Option<Ident>")]
-fn ident_empty() {
- Ident::new("", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "Ident cannot be a number; use Literal instead")]
-fn ident_number() {
- Ident::new("255", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "\"a#\" is not a valid Ident")]
-fn ident_invalid() {
- Ident::new("a#", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "not a valid Ident")]
-fn raw_ident_empty() {
- Ident::new("r#", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "not a valid Ident")]
-fn raw_ident_number() {
- Ident::new("r#255", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "\"r#a#\" is not a valid Ident")]
-fn raw_ident_invalid() {
- Ident::new("r#a#", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "not a valid Ident")]
-fn lifetime_empty() {
- Ident::new("'", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = "not a valid Ident")]
-fn lifetime_number() {
- Ident::new("'255", Span::call_site());
-}
-
-#[test]
-#[should_panic(expected = r#""\'a#" is not a valid Ident"#)]
-fn lifetime_invalid() {
- Ident::new("'a#", Span::call_site());
-}
-
-#[test]
-fn literal_string() {
- assert_eq!(Literal::string("foo").to_string(), "\"foo\"");
- assert_eq!(Literal::string("\"").to_string(), "\"\\\"\"");
- assert_eq!(Literal::string("didn't").to_string(), "\"didn't\"");
-}
-
-#[test]
-fn literal_character() {
- assert_eq!(Literal::character('x').to_string(), "'x'");
- assert_eq!(Literal::character('\'').to_string(), "'\\''");
- assert_eq!(Literal::character('"').to_string(), "'\"'");
-}
-
-#[test]
-fn literal_float() {
- assert_eq!(Literal::f32_unsuffixed(10.0).to_string(), "10.0");
-}
-
-#[test]
-fn literal_suffix() {
- fn token_count(p: &str) -> usize {
- p.parse::<TokenStream>().unwrap().into_iter().count()
- }
-
- assert_eq!(token_count("999u256"), 1);
- assert_eq!(token_count("999r#u256"), 3);
- assert_eq!(token_count("1."), 1);
- assert_eq!(token_count("1.f32"), 3);
- assert_eq!(token_count("1.0_0"), 1);
- assert_eq!(token_count("1._0"), 3);
- assert_eq!(token_count("1._m"), 3);
- assert_eq!(token_count("\"\"s"), 1);
-}
-
-#[test]
-fn roundtrip() {
- fn roundtrip(p: &str) {
- println!("parse: {}", p);
- let s = p.parse::<TokenStream>().unwrap().to_string();
- println!("first: {}", s);
- let s2 = s.to_string().parse::<TokenStream>().unwrap().to_string();
- assert_eq!(s, s2);
- }
- roundtrip("a");
- roundtrip("<<");
- roundtrip("<<=");
- roundtrip(
- "
- 1
- 1.0
- 1f32
- 2f64
- 1usize
- 4isize
- 4e10
- 1_000
- 1_0i32
- 8u8
- 9
- 0
- 0xffffffffffffffffffffffffffffffff
- 1x
- 1u80
- 1f320
- ",
- );
- roundtrip("'a");
- roundtrip("'_");
- roundtrip("'static");
- roundtrip("'\\u{10__FFFF}'");
- roundtrip("\"\\u{10_F0FF__}foo\\u{1_0_0_0__}\"");
-}
-
-#[test]
-fn fail() {
- fn fail(p: &str) {
- if let Ok(s) = p.parse::<TokenStream>() {
- panic!("should have failed to parse: {}\n{:#?}", p, s);
- }
- }
- fail("' static");
- fail("r#1");
- fail("r#_");
-}
-
-#[cfg(span_locations)]
-#[test]
-fn span_test() {
- use proc_macro2::TokenTree;
-
- fn check_spans(p: &str, mut lines: &[(usize, usize, usize, usize)]) {
- let ts = p.parse::<TokenStream>().unwrap();
- check_spans_internal(ts, &mut lines);
- }
-
- fn check_spans_internal(ts: TokenStream, lines: &mut &[(usize, usize, usize, usize)]) {
- for i in ts {
- if let Some((&(sline, scol, eline, ecol), rest)) = lines.split_first() {
- *lines = rest;
-
- let start = i.span().start();
- assert_eq!(start.line, sline, "sline did not match for {}", i);
- assert_eq!(start.column, scol, "scol did not match for {}", i);
-
- let end = i.span().end();
- assert_eq!(end.line, eline, "eline did not match for {}", i);
- assert_eq!(end.column, ecol, "ecol did not match for {}", i);
-
- match i {
- TokenTree::Group(ref g) => {
- check_spans_internal(g.stream().clone(), lines);
- }
- _ => {}
- }
- }
- }
- }
-
- check_spans(
- "\
-/// This is a document comment
-testing 123
-{
- testing 234
-}",
- &[
- (1, 0, 1, 30), // #
- (1, 0, 1, 30), // [ ... ]
- (1, 0, 1, 30), // doc
- (1, 0, 1, 30), // =
- (1, 0, 1, 30), // "This is..."
- (2, 0, 2, 7), // testing
- (2, 8, 2, 11), // 123
- (3, 0, 5, 1), // { ... }
- (4, 2, 4, 9), // testing
- (4, 10, 4, 13), // 234
- ],
- );
-}
-
-#[cfg(procmacro2_semver_exempt)]
-#[cfg(not(nightly))]
-#[test]
-fn default_span() {
- let start = Span::call_site().start();
- assert_eq!(start.line, 1);
- assert_eq!(start.column, 0);
- let end = Span::call_site().end();
- assert_eq!(end.line, 1);
- assert_eq!(end.column, 0);
- let source_file = Span::call_site().source_file();
- assert_eq!(source_file.path().to_string_lossy(), "<unspecified>");
- assert!(!source_file.is_real());
-}
-
-#[cfg(procmacro2_semver_exempt)]
-#[test]
-fn span_join() {
- let source1 = "aaa\nbbb"
- .parse::<TokenStream>()
- .unwrap()
- .into_iter()
- .collect::<Vec<_>>();
- let source2 = "ccc\nddd"
- .parse::<TokenStream>()
- .unwrap()
- .into_iter()
- .collect::<Vec<_>>();
-
- assert!(source1[0].span().source_file() != source2[0].span().source_file());
- assert_eq!(
- source1[0].span().source_file(),
- source1[1].span().source_file()
- );
-
- let joined1 = source1[0].span().join(source1[1].span());
- let joined2 = source1[0].span().join(source2[0].span());
- assert!(joined1.is_some());
- assert!(joined2.is_none());
-
- let start = joined1.unwrap().start();
- let end = joined1.unwrap().end();
- assert_eq!(start.line, 1);
- assert_eq!(start.column, 0);
- assert_eq!(end.line, 2);
- assert_eq!(end.column, 3);
-
- assert_eq!(
- joined1.unwrap().source_file(),
- source1[0].span().source_file()
- );
-}
-
-#[test]
-fn no_panic() {
- let s = str::from_utf8(b"b\'\xc2\x86 \x00\x00\x00^\"").unwrap();
- assert!(s.parse::<proc_macro2::TokenStream>().is_err());
-}
-
-#[test]
-fn tricky_doc_comment() {
- let stream = "/**/".parse::<proc_macro2::TokenStream>().unwrap();
- let tokens = stream.into_iter().collect::<Vec<_>>();
- assert!(tokens.is_empty(), "not empty -- {:?}", tokens);
-
- let stream = "/// doc".parse::<proc_macro2::TokenStream>().unwrap();
- let tokens = stream.into_iter().collect::<Vec<_>>();
- assert!(tokens.len() == 2, "not length 2 -- {:?}", tokens);
- match tokens[0] {
- proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '#'),
- _ => panic!("wrong token {:?}", tokens[0]),
- }
- let mut tokens = match tokens[1] {
- proc_macro2::TokenTree::Group(ref tt) => {
- assert_eq!(tt.delimiter(), proc_macro2::Delimiter::Bracket);
- tt.stream().into_iter()
- }
- _ => panic!("wrong token {:?}", tokens[0]),
- };
-
- match tokens.next().unwrap() {
- proc_macro2::TokenTree::Ident(ref tt) => assert_eq!(tt.to_string(), "doc"),
- t => panic!("wrong token {:?}", t),
- }
- match tokens.next().unwrap() {
- proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '='),
- t => panic!("wrong token {:?}", t),
- }
- match tokens.next().unwrap() {
- proc_macro2::TokenTree::Literal(ref tt) => {
- assert_eq!(tt.to_string(), "\" doc\"");
- }
- t => panic!("wrong token {:?}", t),
- }
- assert!(tokens.next().is_none());
-
- let stream = "//! doc".parse::<proc_macro2::TokenStream>().unwrap();
- let tokens = stream.into_iter().collect::<Vec<_>>();
- assert!(tokens.len() == 3, "not length 3 -- {:?}", tokens);
-}
-
-#[test]
-fn op_before_comment() {
- let mut tts = TokenStream::from_str("~// comment").unwrap().into_iter();
- match tts.next().unwrap() {
- TokenTree::Punct(tt) => {
- assert_eq!(tt.as_char(), '~');
- assert_eq!(tt.spacing(), Spacing::Alone);
- }
- wrong => panic!("wrong token {:?}", wrong),
- }
-}
-
-#[test]
-fn raw_identifier() {
- let mut tts = TokenStream::from_str("r#dyn").unwrap().into_iter();
- match tts.next().unwrap() {
- TokenTree::Ident(raw) => assert_eq!("r#dyn", raw.to_string()),
- wrong => panic!("wrong token {:?}", wrong),
- }
- assert!(tts.next().is_none());
-}
-
-#[test]
-fn test_debug_ident() {
- let ident = Ident::new("proc_macro", Span::call_site());
-
- #[cfg(not(procmacro2_semver_exempt))]
- let expected = "Ident(proc_macro)";
-
- #[cfg(procmacro2_semver_exempt)]
- let expected = "Ident { sym: proc_macro, span: bytes(0..0) }";
-
- assert_eq!(expected, format!("{:?}", ident));
-}
-
-#[test]
-fn test_debug_tokenstream() {
- let tts = TokenStream::from_str("[a + 1]").unwrap();
-
- #[cfg(not(procmacro2_semver_exempt))]
- let expected = "\
-TokenStream [
- Group {
- delimiter: Bracket,
- stream: TokenStream [
- Ident {
- sym: a,
- },
- Punct {
- op: '+',
- spacing: Alone,
- },
- Literal {
- lit: 1,
- },
- ],
- },
-]\
- ";
-
- #[cfg(not(procmacro2_semver_exempt))]
- let expected_before_trailing_commas = "\
-TokenStream [
- Group {
- delimiter: Bracket,
- stream: TokenStream [
- Ident {
- sym: a
- },
- Punct {
- op: '+',
- spacing: Alone
- },
- Literal {
- lit: 1
- }
- ]
- }
-]\
- ";
-
- #[cfg(procmacro2_semver_exempt)]
- let expected = "\
-TokenStream [
- Group {
- delimiter: Bracket,
- stream: TokenStream [
- Ident {
- sym: a,
- span: bytes(2..3),
- },
- Punct {
- op: '+',
- spacing: Alone,
- span: bytes(4..5),
- },
- Literal {
- lit: 1,
- span: bytes(6..7),
- },
- ],
- span: bytes(1..8),
- },
-]\
- ";
-
- #[cfg(procmacro2_semver_exempt)]
- let expected_before_trailing_commas = "\
-TokenStream [
- Group {
- delimiter: Bracket,
- stream: TokenStream [
- Ident {
- sym: a,
- span: bytes(2..3)
- },
- Punct {
- op: '+',
- spacing: Alone,
- span: bytes(4..5)
- },
- Literal {
- lit: 1,
- span: bytes(6..7)
- }
- ],
- span: bytes(1..8)
- }
-]\
- ";
-
- let actual = format!("{:#?}", tts);
- if actual.ends_with(",\n]") {
- assert_eq!(expected, actual);
- } else {
- assert_eq!(expected_before_trailing_commas, actual);
- }
-}
-
-#[test]
-fn default_tokenstream_is_empty() {
- let default_token_stream: TokenStream = Default::default();
-
- assert!(default_token_stream.is_empty());
-}
diff --git a/quote/.gitignore b/quote/.gitignore
deleted file mode 100644
index 4fffb2f..0000000
--- a/quote/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/target
-/Cargo.lock
diff --git a/quote/.travis.yml b/quote/.travis.yml
deleted file mode 100644
index 7182d9b..0000000
--- a/quote/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-sudo: false
-
-language: rust
-
-rust:
- - stable
- - 1.31.0
- - beta
-
-script:
- - cargo test
-
-matrix:
- include:
- - rust: nightly
- script:
- - cargo test
- - cargo update -Z minimal-versions && cargo build
diff --git a/quote/Cargo.toml b/quote/Cargo.toml
deleted file mode 100644
index c052022..0000000
--- a/quote/Cargo.toml
+++ /dev/null
@@ -1,32 +0,0 @@
-[package]
-name = "quote"
-version = "1.0.2" # don't forget to update html_root_url, version in readme for breaking changes
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-license = "MIT OR Apache-2.0"
-description = "Quasi-quoting macro quote!(...)"
-repository = "https://github.com/dtolnay/quote"
-documentation = "https://docs.rs/quote/"
-keywords = ["syn"]
-categories = ["development-tools::procedural-macro-helpers"]
-readme = "README.md"
-include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
-edition = "2018"
-
-[lib]
-name = "quote"
-
-[dependencies]
-proc-macro2 = { version = "1.0", default-features = false }
-
-[dev-dependencies]
-rustversion = "0.1"
-trybuild = "1.0"
-
-[features]
-default = ["proc-macro"]
-# Disabling the proc-macro feature removes the dynamic library dependency on
-# libproc_macro in the rustc compiler.
-proc-macro = ["proc-macro2/proc-macro"]
-
-[badges]
-travis-ci = { repository = "dtolnay/quote" }
diff --git a/quote/LICENSE-APACHE b/quote/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/quote/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/quote/LICENSE-MIT b/quote/LICENSE-MIT
deleted file mode 100644
index 40b8817..0000000
--- a/quote/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2016 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/quote/README.md b/quote/README.md
deleted file mode 100644
index 7c7f743..0000000
--- a/quote/README.md
+++ /dev/null
@@ -1,237 +0,0 @@
-Rust Quasi-Quoting
-==================
-
-[![Build Status](https://api.travis-ci.org/dtolnay/quote.svg?branch=master)](https://travis-ci.org/dtolnay/quote)
-[![Latest Version](https://img.shields.io/crates/v/quote.svg)](https://crates.io/crates/quote)
-[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/quote/)
-
-This crate provides the [`quote!`] macro for turning Rust syntax tree data
-structures into tokens of source code.
-
-[`quote!`]: https://docs.rs/quote/1.0/quote/macro.quote.html
-
-Procedural macros in Rust receive a stream of tokens as input, execute arbitrary
-Rust code to determine how to manipulate those tokens, and produce a stream of
-tokens to hand back to the compiler to compile into the caller's crate.
-Quasi-quoting is a solution to one piece of that &mdash; producing tokens to
-return to the compiler.
-
-The idea of quasi-quoting is that we write *code* that we treat as *data*.
-Within the `quote!` macro, we can write what looks like code to our text editor
-or IDE. We get all the benefits of the editor's brace matching, syntax
-highlighting, indentation, and maybe autocompletion. But rather than compiling
-that as code into the current crate, we can treat it as data, pass it around,
-mutate it, and eventually hand it back to the compiler as tokens to compile into
-the macro caller's crate.
-
-This crate is motivated by the procedural macro use case, but is a
-general-purpose Rust quasi-quoting library and is not specific to procedural
-macros.
-
-*Version requirement: Quote supports any compiler version back to Rust's very
-first support for procedural macros in Rust 1.15.0.*
-
-[*Release notes*](https://github.com/dtolnay/quote/releases)
-
-```toml
-[dependencies]
-quote = "1.0"
-```
-
-## Syntax
-
-The quote crate provides a [`quote!`] macro within which you can write Rust code
-that gets packaged into a [`TokenStream`] and can be treated as data. You should
-think of `TokenStream` as representing a fragment of Rust source code.
-
-[`TokenStream`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.TokenStream.html
-
-Within the `quote!` macro, interpolation is done with `#var`. Any type
-implementing the [`quote::ToTokens`] trait can be interpolated. This includes
-most Rust primitive types as well as most of the syntax tree types from [`syn`].
-
-[`quote::ToTokens`]: https://docs.rs/quote/1.0/quote/trait.ToTokens.html
-[`syn`]: https://github.com/dtolnay/syn
-
-```rust
-let tokens = quote! {
- struct SerializeWith #generics #where_clause {
- value: &'a #field_ty,
- phantom: core::marker::PhantomData<#item_ty>,
- }
-
- impl #generics serde::Serialize for SerializeWith #generics #where_clause {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: serde::Serializer,
- {
- #path(self.value, serializer)
- }
- }
-
- SerializeWith {
- value: #value,
- phantom: core::marker::PhantomData::<#item_ty>,
- }
-};
-```
-
-## Repetition
-
-Repetition is done using `#(...)*` or `#(...),*` similar to `macro_rules!`. This
-iterates through the elements of any variable interpolated within the repetition
-and inserts a copy of the repetition body for each one. The variables in an
-interpolation may be anything that implements `IntoIterator`, including `Vec` or
-a pre-existing iterator.
-
-- `#(#var)*` — no separators
-- `#(#var),*` — the character before the asterisk is used as a separator
-- `#( struct #var; )*` — the repetition can contain other things
-- `#( #k => println!("{}", #v), )*` — even multiple interpolations
-
-Note that there is a difference between `#(#var ,)*` and `#(#var),*`—the latter
-does not produce a trailing comma. This matches the behavior of delimiters in
-`macro_rules!`.
-
-## Returning tokens to the compiler
-
-The `quote!` macro evaluates to an expression of type
-`proc_macro2::TokenStream`. Meanwhile Rust procedural macros are expected to
-return the type `proc_macro::TokenStream`.
-
-The difference between the two types is that `proc_macro` types are entirely
-specific to procedural macros and cannot ever exist in code outside of a
-procedural macro, while `proc_macro2` types may exist anywhere including tests
-and non-macro code like main.rs and build.rs. This is why even the procedural
-macro ecosystem is largely built around `proc_macro2`, because that ensures the
-libraries are unit testable and accessible in non-macro contexts.
-
-There is a [`From`]-conversion in both directions so returning the output of
-`quote!` from a procedural macro usually looks like `tokens.into()` or
-`proc_macro::TokenStream::from(tokens)`.
-
-[`From`]: https://doc.rust-lang.org/std/convert/trait.From.html
-
-## Examples
-
-### Combining quoted fragments
-
-Usually you don't end up constructing an entire final `TokenStream` in one
-piece. Different parts may come from different helper functions. The tokens
-produced by `quote!` themselves implement `ToTokens` and so can be interpolated
-into later `quote!` invocations to build up a final result.
-
-```rust
-let type_definition = quote! {...};
-let methods = quote! {...};
-
-let tokens = quote! {
- #type_definition
- #methods
-};
-```
-
-### Constructing identifiers
-
-Suppose we have an identifier `ident` which came from somewhere in a macro
-input and we need to modify it in some way for the macro output. Let's consider
-prepending the identifier with an underscore.
-
-Simply interpolating the identifier next to an underscore will not have the
-behavior of concatenating them. The underscore and the identifier will continue
-to be two separate tokens as if you had written `_ x`.
-
-```rust
-// incorrect
-quote! {
- let mut _#ident = 0;
-}
-```
-
-The solution is to build a new identifier token with the correct value. As this
-is such a common case, the `format_ident!` macro provides a convenient utility
-for doing so correctly.
-
-```rust
-let varname = format_ident!("_{}", ident);
-quote! {
- let mut #varname = 0;
-}
-```
-
-Alternatively, the APIs provided by Syn and proc-macro2 can be used to directly
-build the identifier. This is roughly equivalent to the above, but will not
-handle `ident` being a raw identifier.
-
-```rust
-let concatenated = format!("_{}", ident);
-let varname = syn::Ident::new(&concatenated, ident.span());
-quote! {
- let mut #varname = 0;
-}
-```
-
-### Making method calls
-
-Let's say our macro requires some type specified in the macro input to have a
-constructor called `new`. We have the type in a variable called `field_type` of
-type `syn::Type` and want to invoke the constructor.
-
-```rust
-// incorrect
-quote! {
- let value = #field_type::new();
-}
-```
-
-This works only sometimes. If `field_type` is `String`, the expanded code
-contains `String::new()` which is fine. But if `field_type` is something like
-`Vec<i32>` then the expanded code is `Vec<i32>::new()` which is invalid syntax.
-Ordinarily in handwritten Rust we would write `Vec::<i32>::new()` but for macros
-often the following is more convenient.
-
-```rust
-quote! {
- let value = <#field_type>::new();
-}
-```
-
-This expands to `<Vec<i32>>::new()` which behaves correctly.
-
-A similar pattern is appropriate for trait methods.
-
-```rust
-quote! {
- let value = <#field_type as core::default::Default>::default();
-}
-```
-
-## Hygiene
-
-Any interpolated tokens preserve the `Span` information provided by their
-`ToTokens` implementation. Tokens that originate within a `quote!` invocation
-are spanned with [`Span::call_site()`].
-
-[`Span::call_site()`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.Span.html#method.call_site
-
-A different span can be provided explicitly through the [`quote_spanned!`]
-macro.
-
-[`quote_spanned!`]: https://docs.rs/quote/1.0/quote/macro.quote_spanned.html
-
-<br>
-
-#### License
-
-<sup>
-Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
-2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
-</sup>
-
-<br>
-
-<sub>
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
-be dual licensed as above, without any additional terms or conditions.
-</sub>
diff --git a/quote/benches/bench.rs b/quote/benches/bench.rs
deleted file mode 100644
index c76a638..0000000
--- a/quote/benches/bench.rs
+++ /dev/null
@@ -1,193 +0,0 @@
-#![feature(test)]
-#![recursion_limit = "512"]
-
-extern crate test;
-
-use quote::quote;
-use test::Bencher;
-
-#[bench]
-fn bench_impl(b: &mut Bencher) {
- b.iter(|| {
- quote! {
- impl<'de> _serde::Deserialize<'de> for Response {
- fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error>
- where
- __D: _serde::Deserializer<'de>,
- {
- #[allow(non_camel_case_types)]
- enum __Field {
- __field0,
- __field1,
- __ignore,
- }
- struct __FieldVisitor;
- impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
- type Value = __Field;
- fn expecting(
- &self,
- __formatter: &mut _serde::export::Formatter,
- ) -> _serde::export::fmt::Result {
- _serde::export::Formatter::write_str(__formatter, "field identifier")
- }
- fn visit_u64<__E>(self, __value: u64) -> _serde::export::Result<Self::Value, __E>
- where
- __E: _serde::de::Error,
- {
- match __value {
- 0u64 => _serde::export::Ok(__Field::__field0),
- 1u64 => _serde::export::Ok(__Field::__field1),
- _ => _serde::export::Err(_serde::de::Error::invalid_value(
- _serde::de::Unexpected::Unsigned(__value),
- &"field index 0 <= i < 2",
- )),
- }
- }
- fn visit_str<__E>(self, __value: &str) -> _serde::export::Result<Self::Value, __E>
- where
- __E: _serde::de::Error,
- {
- match __value {
- "id" => _serde::export::Ok(__Field::__field0),
- "s" => _serde::export::Ok(__Field::__field1),
- _ => _serde::export::Ok(__Field::__ignore),
- }
- }
- fn visit_bytes<__E>(
- self,
- __value: &[u8],
- ) -> _serde::export::Result<Self::Value, __E>
- where
- __E: _serde::de::Error,
- {
- match __value {
- b"id" => _serde::export::Ok(__Field::__field0),
- b"s" => _serde::export::Ok(__Field::__field1),
- _ => _serde::export::Ok(__Field::__ignore),
- }
- }
- }
- impl<'de> _serde::Deserialize<'de> for __Field {
- #[inline]
- fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error>
- where
- __D: _serde::Deserializer<'de>,
- {
- _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor)
- }
- }
- struct __Visitor<'de> {
- marker: _serde::export::PhantomData<Response>,
- lifetime: _serde::export::PhantomData<&'de ()>,
- }
- impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
- type Value = Response;
- fn expecting(
- &self,
- __formatter: &mut _serde::export::Formatter,
- ) -> _serde::export::fmt::Result {
- _serde::export::Formatter::write_str(__formatter, "struct Response")
- }
- #[inline]
- fn visit_seq<__A>(
- self,
- mut __seq: __A,
- ) -> _serde::export::Result<Self::Value, __A::Error>
- where
- __A: _serde::de::SeqAccess<'de>,
- {
- let __field0 =
- match try!(_serde::de::SeqAccess::next_element::<u64>(&mut __seq)) {
- _serde::export::Some(__value) => __value,
- _serde::export::None => {
- return _serde::export::Err(_serde::de::Error::invalid_length(
- 0usize,
- &"struct Response with 2 elements",
- ));
- }
- };
- let __field1 =
- match try!(_serde::de::SeqAccess::next_element::<String>(&mut __seq)) {
- _serde::export::Some(__value) => __value,
- _serde::export::None => {
- return _serde::export::Err(_serde::de::Error::invalid_length(
- 1usize,
- &"struct Response with 2 elements",
- ));
- }
- };
- _serde::export::Ok(Response {
- id: __field0,
- s: __field1,
- })
- }
- #[inline]
- fn visit_map<__A>(
- self,
- mut __map: __A,
- ) -> _serde::export::Result<Self::Value, __A::Error>
- where
- __A: _serde::de::MapAccess<'de>,
- {
- let mut __field0: _serde::export::Option<u64> = _serde::export::None;
- let mut __field1: _serde::export::Option<String> = _serde::export::None;
- while let _serde::export::Some(__key) =
- try!(_serde::de::MapAccess::next_key::<__Field>(&mut __map))
- {
- match __key {
- __Field::__field0 => {
- if _serde::export::Option::is_some(&__field0) {
- return _serde::export::Err(
- <__A::Error as _serde::de::Error>::duplicate_field("id"),
- );
- }
- __field0 = _serde::export::Some(
- try!(_serde::de::MapAccess::next_value::<u64>(&mut __map)),
- );
- }
- __Field::__field1 => {
- if _serde::export::Option::is_some(&__field1) {
- return _serde::export::Err(
- <__A::Error as _serde::de::Error>::duplicate_field("s"),
- );
- }
- __field1 = _serde::export::Some(
- try!(_serde::de::MapAccess::next_value::<String>(&mut __map)),
- );
- }
- _ => {
- let _ = try!(_serde::de::MapAccess::next_value::<
- _serde::de::IgnoredAny,
- >(&mut __map));
- }
- }
- }
- let __field0 = match __field0 {
- _serde::export::Some(__field0) => __field0,
- _serde::export::None => try!(_serde::private::de::missing_field("id")),
- };
- let __field1 = match __field1 {
- _serde::export::Some(__field1) => __field1,
- _serde::export::None => try!(_serde::private::de::missing_field("s")),
- };
- _serde::export::Ok(Response {
- id: __field0,
- s: __field1,
- })
- }
- }
- const FIELDS: &'static [&'static str] = &["id", "s"];
- _serde::Deserializer::deserialize_struct(
- __deserializer,
- "Response",
- FIELDS,
- __Visitor {
- marker: _serde::export::PhantomData::<Response>,
- lifetime: _serde::export::PhantomData,
- },
- )
- }
- }
- }
- });
-}
diff --git a/quote/src/ext.rs b/quote/src/ext.rs
deleted file mode 100644
index 9e9b4a5..0000000
--- a/quote/src/ext.rs
+++ /dev/null
@@ -1,112 +0,0 @@
-use super::ToTokens;
-
-use std::iter;
-
-use proc_macro2::{TokenStream, TokenTree};
-
-/// TokenStream extension trait with methods for appending tokens.
-///
-/// This trait is sealed and cannot be implemented outside of the `quote` crate.
-pub trait TokenStreamExt: private::Sealed {
- /// For use by `ToTokens` implementations.
- ///
- /// Appends the token specified to this list of tokens.
- fn append<U>(&mut self, token: U)
- where
- U: Into<TokenTree>;
-
- /// For use by `ToTokens` implementations.
- ///
- /// ```
- /// # use quote::{quote, TokenStreamExt, ToTokens};
- /// # use proc_macro2::TokenStream;
- /// #
- /// struct X;
- ///
- /// impl ToTokens for X {
- /// fn to_tokens(&self, tokens: &mut TokenStream) {
- /// tokens.append_all(&[true, false]);
- /// }
- /// }
- ///
- /// let tokens = quote!(#X);
- /// assert_eq!(tokens.to_string(), "true false");
- /// ```
- fn append_all<I>(&mut self, iter: I)
- where
- I: IntoIterator,
- I::Item: ToTokens;
-
- /// For use by `ToTokens` implementations.
- ///
- /// Appends all of the items in the iterator `I`, separated by the tokens
- /// `U`.
- fn append_separated<I, U>(&mut self, iter: I, op: U)
- where
- I: IntoIterator,
- I::Item: ToTokens,
- U: ToTokens;
-
- /// For use by `ToTokens` implementations.
- ///
- /// Appends all tokens in the iterator `I`, appending `U` after each
- /// element, including after the last element of the iterator.
- fn append_terminated<I, U>(&mut self, iter: I, term: U)
- where
- I: IntoIterator,
- I::Item: ToTokens,
- U: ToTokens;
-}
-
-impl TokenStreamExt for TokenStream {
- fn append<U>(&mut self, token: U)
- where
- U: Into<TokenTree>,
- {
- self.extend(iter::once(token.into()));
- }
-
- fn append_all<I>(&mut self, iter: I)
- where
- I: IntoIterator,
- I::Item: ToTokens,
- {
- for token in iter {
- token.to_tokens(self);
- }
- }
-
- fn append_separated<I, U>(&mut self, iter: I, op: U)
- where
- I: IntoIterator,
- I::Item: ToTokens,
- U: ToTokens,
- {
- for (i, token) in iter.into_iter().enumerate() {
- if i > 0 {
- op.to_tokens(self);
- }
- token.to_tokens(self);
- }
- }
-
- fn append_terminated<I, U>(&mut self, iter: I, term: U)
- where
- I: IntoIterator,
- I::Item: ToTokens,
- U: ToTokens,
- {
- for token in iter {
- token.to_tokens(self);
- term.to_tokens(self);
- }
- }
-}
-
-mod private {
- use proc_macro2::TokenStream;
-
- pub trait Sealed {}
-
- impl Sealed for TokenStream {}
-}
diff --git a/quote/src/format.rs b/quote/src/format.rs
deleted file mode 100644
index 13c8811..0000000
--- a/quote/src/format.rs
+++ /dev/null
@@ -1,164 +0,0 @@
-/// Formatting macro for constructing `Ident`s.
-///
-/// <br>
-///
-/// # Syntax
-///
-/// Syntax is copied from the [`format!`] macro, supporting both positional and
-/// named arguments.
-///
-/// Only a limited set of formatting traits are supported. The current mapping
-/// of format types to traits is:
-///
-/// * `{}` ⇒ [`IdentFragment`]
-/// * `{:o}` ⇒ [`Octal`](`std::fmt::Octal`)
-/// * `{:x}` ⇒ [`LowerHex`](`std::fmt::LowerHex`)
-/// * `{:X}` ⇒ [`UpperHex`](`std::fmt::UpperHex`)
-/// * `{:b}` ⇒ [`Binary`](`std::fmt::Binary`)
-///
-/// See [`std::fmt`] for more information.
-///
-/// <br>
-///
-/// # IdentFragment
-///
-/// Unlike `format!`, this macro uses the [`IdentFragment`] formatting trait by
-/// default. This trait is like `Display`, with a few differences:
-///
-/// * `IdentFragment` is only implemented for a limited set of types, such as
-/// unsigned integers and strings.
-/// * [`Ident`] arguments will have their `r#` prefixes stripped, if present.
-///
-/// [`Ident`]: `proc_macro2::Ident`
-///
-/// <br>
-///
-/// # Hygiene
-///
-/// The [`Span`] of the first `Ident` argument is used as the span of the final
-/// identifier, falling back to [`Span::call_site`] when no identifiers are
-/// provided.
-///
-/// ```
-/// # use quote::format_ident;
-/// # let ident = format_ident!("Ident");
-/// // If `ident` is an Ident, the span of `my_ident` will be inherited from it.
-/// let my_ident = format_ident!("My{}{}", ident, "IsCool");
-/// assert_eq!(my_ident, "MyIdentIsCool");
-/// ```
-///
-/// Alternatively, the span can be overridden by passing the `span` named
-/// argument.
-///
-/// ```
-/// # use quote::format_ident;
-/// # const IGNORE_TOKENS: &'static str = stringify! {
-/// let my_span = /* ... */;
-/// # };
-/// # let my_span = proc_macro2::Span::call_site();
-/// format_ident!("MyIdent", span = my_span);
-/// ```
-///
-/// [`Span`]: `proc_macro2::Span`
-/// [`Span::call_site`]: `proc_macro2::Span::call_site`
-///
-/// <p><br></p>
-///
-/// # Panics
-///
-/// This method will panic if the resulting formatted string is not a valid
-/// identifier.
-///
-/// <br>
-///
-/// # Examples
-///
-/// Composing raw and non-raw identifiers:
-/// ```
-/// # use quote::format_ident;
-/// let my_ident = format_ident!("My{}", "Ident");
-/// assert_eq!(my_ident, "MyIdent");
-///
-/// let raw = format_ident!("r#Raw");
-/// assert_eq!(raw, "r#Raw");
-///
-/// let my_ident_raw = format_ident!("{}Is{}", my_ident, raw);
-/// assert_eq!(my_ident_raw, "MyIdentIsRaw");
-/// ```
-///
-/// Integer formatting options:
-/// ```
-/// # use quote::format_ident;
-/// let num: u32 = 10;
-///
-/// let decimal = format_ident!("Id_{}", num);
-/// assert_eq!(decimal, "Id_10");
-///
-/// let octal = format_ident!("Id_{:o}", num);
-/// assert_eq!(octal, "Id_12");
-///
-/// let binary = format_ident!("Id_{:b}", num);
-/// assert_eq!(binary, "Id_1010");
-///
-/// let lower_hex = format_ident!("Id_{:x}", num);
-/// assert_eq!(lower_hex, "Id_a");
-///
-/// let upper_hex = format_ident!("Id_{:X}", num);
-/// assert_eq!(upper_hex, "Id_A");
-/// ```
-#[macro_export]
-macro_rules! format_ident {
- ($fmt:expr) => {
- $crate::format_ident_impl!([
- ::std::option::Option::None,
- $fmt
- ])
- };
-
- ($fmt:expr, $($rest:tt)*) => {
- $crate::format_ident_impl!([
- ::std::option::Option::None,
- $fmt
- ] $($rest)*)
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! format_ident_impl {
- // Final state
- ([$span:expr, $($fmt:tt)*]) => {
- $crate::__rt::mk_ident(&format!($($fmt)*), $span)
- };
-
- // Span argument
- ([$old:expr, $($fmt:tt)*] span = $span:expr) => {
- $crate::format_ident_impl!([$old, $($fmt)*] span = $span,)
- };
- ([$old:expr, $($fmt:tt)*] span = $span:expr, $($rest:tt)*) => {
- $crate::format_ident_impl!([
- ::std::option::Option::Some::<$crate::__rt::Span>($span),
- $($fmt)*
- ] $($rest)*)
- };
-
- // Named argument
- ([$span:expr, $($fmt:tt)*] $name:ident = $arg:expr) => {
- $crate::format_ident_impl!([$span, $($fmt)*] $name = $arg,)
- };
- ([$span:expr, $($fmt:tt)*] $name:ident = $arg:expr, $($rest:tt)*) => {
- match $crate::__rt::IdentFragmentAdapter(&$arg) {
- arg => $crate::format_ident_impl!([$span.or(arg.span()), $($fmt)*, $name = arg] $($rest)*),
- }
- };
-
- // Positional argument
- ([$span:expr, $($fmt:tt)*] $arg:expr) => {
- $crate::format_ident_impl!([$span, $($fmt)*] $arg,)
- };
- ([$span:expr, $($fmt:tt)*] $arg:expr, $($rest:tt)*) => {
- match $crate::__rt::IdentFragmentAdapter(&$arg) {
- arg => $crate::format_ident_impl!([$span.or(arg.span()), $($fmt)*, arg] $($rest)*),
- }
- };
-}
diff --git a/quote/src/ident_fragment.rs b/quote/src/ident_fragment.rs
deleted file mode 100644
index 09ead65..0000000
--- a/quote/src/ident_fragment.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-use proc_macro2::{Ident, Span};
-use std::fmt;
-
-/// Specialized formatting trait used by `format_ident!`.
-///
-/// [`Ident`] arguments formatted using this trait will have their `r#` prefix
-/// stripped, if present.
-///
-/// See [`format_ident!`] for more information.
-pub trait IdentFragment {
- /// Format this value as an identifier fragment.
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result;
-
- /// Span associated with this `IdentFragment`.
- ///
- /// If non-`None`, may be inherited by formatted identifiers.
- fn span(&self) -> Option<Span> {
- None
- }
-}
-
-impl<'a, T: IdentFragment + ?Sized> IdentFragment for &'a T {
- fn span(&self) -> Option<Span> {
- <T as IdentFragment>::span(*self)
- }
-
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- IdentFragment::fmt(*self, f)
- }
-}
-
-impl<'a, T: IdentFragment + ?Sized> IdentFragment for &'a mut T {
- fn span(&self) -> Option<Span> {
- <T as IdentFragment>::span(*self)
- }
-
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- IdentFragment::fmt(*self, f)
- }
-}
-
-impl IdentFragment for Ident {
- fn span(&self) -> Option<Span> {
- Some(self.span())
- }
-
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let id = self.to_string();
- if id.starts_with("r#") {
- fmt::Display::fmt(&id[2..], f)
- } else {
- fmt::Display::fmt(&id[..], f)
- }
- }
-}
-
-// Limited set of types which this is implemented for, as we want to avoid types
-// which will often include non-identifier characters in their `Display` impl.
-macro_rules! ident_fragment_display {
- ($($T:ty),*) => {
- $(
- impl IdentFragment for $T {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(self, f)
- }
- }
- )*
- }
-}
-
-ident_fragment_display!(bool, str, String);
-ident_fragment_display!(u8, u16, u32, u64, u128, usize);
diff --git a/quote/src/lib.rs b/quote/src/lib.rs
deleted file mode 100644
index 3341a16..0000000
--- a/quote/src/lib.rs
+++ /dev/null
@@ -1,948 +0,0 @@
-//! This crate provides the [`quote!`] macro for turning Rust syntax tree data
-//! structures into tokens of source code.
-//!
-//! [`quote!`]: macro.quote.html
-//!
-//! Procedural macros in Rust receive a stream of tokens as input, execute
-//! arbitrary Rust code to determine how to manipulate those tokens, and produce
-//! a stream of tokens to hand back to the compiler to compile into the caller's
-//! crate. Quasi-quoting is a solution to one piece of that &mdash; producing
-//! tokens to return to the compiler.
-//!
-//! The idea of quasi-quoting is that we write *code* that we treat as *data*.
-//! Within the `quote!` macro, we can write what looks like code to our text
-//! editor or IDE. We get all the benefits of the editor's brace matching,
-//! syntax highlighting, indentation, and maybe autocompletion. But rather than
-//! compiling that as code into the current crate, we can treat it as data, pass
-//! it around, mutate it, and eventually hand it back to the compiler as tokens
-//! to compile into the macro caller's crate.
-//!
-//! This crate is motivated by the procedural macro use case, but is a
-//! general-purpose Rust quasi-quoting library and is not specific to procedural
-//! macros.
-//!
-//! ```toml
-//! [dependencies]
-//! quote = "1.0"
-//! ```
-//!
-//! <br>
-//!
-//! # Example
-//!
-//! The following quasi-quoted block of code is something you might find in [a]
-//! procedural macro having to do with data structure serialization. The `#var`
-//! syntax performs interpolation of runtime variables into the quoted tokens.
-//! Check out the documentation of the [`quote!`] macro for more detail about
-//! the syntax. See also the [`quote_spanned!`] macro which is important for
-//! implementing hygienic procedural macros.
-//!
-//! [a]: https://serde.rs/
-//! [`quote_spanned!`]: macro.quote_spanned.html
-//!
-//! ```
-//! # use quote::quote;
-//! #
-//! # let generics = "";
-//! # let where_clause = "";
-//! # let field_ty = "";
-//! # let item_ty = "";
-//! # let path = "";
-//! # let value = "";
-//! #
-//! let tokens = quote! {
-//! struct SerializeWith #generics #where_clause {
-//! value: &'a #field_ty,
-//! phantom: core::marker::PhantomData<#item_ty>,
-//! }
-//!
-//! impl #generics serde::Serialize for SerializeWith #generics #where_clause {
-//! fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-//! where
-//! S: serde::Serializer,
-//! {
-//! #path(self.value, serializer)
-//! }
-//! }
-//!
-//! SerializeWith {
-//! value: #value,
-//! phantom: core::marker::PhantomData::<#item_ty>,
-//! }
-//! };
-//! ```
-
-// Quote types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/quote/1.0.2")]
-
-#[cfg(all(
- not(all(target_arch = "wasm32", target_os = "unknown")),
- feature = "proc-macro"
-))]
-extern crate proc_macro;
-
-mod ext;
-mod format;
-mod ident_fragment;
-mod to_tokens;
-
-// Not public API.
-#[doc(hidden)]
-#[path = "runtime.rs"]
-pub mod __rt;
-
-pub use crate::ext::TokenStreamExt;
-pub use crate::ident_fragment::IdentFragment;
-pub use crate::to_tokens::ToTokens;
-
-// Not public API.
-#[doc(hidden)]
-pub mod spanned;
-
-/// The whole point.
-///
-/// Performs variable interpolation against the input and produces it as
-/// [`proc_macro2::TokenStream`].
-///
-/// Note: for returning tokens to the compiler in a procedural macro, use
-/// `.into()` on the result to convert to [`proc_macro::TokenStream`].
-///
-/// [`TokenStream`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.TokenStream.html
-///
-/// <br>
-///
-/// # Interpolation
-///
-/// Variable interpolation is done with `#var` (similar to `$var` in
-/// `macro_rules!` macros). This grabs the `var` variable that is currently in
-/// scope and inserts it in that location in the output tokens. Any type
-/// implementing the [`ToTokens`] trait can be interpolated. This includes most
-/// Rust primitive types as well as most of the syntax tree types from the [Syn]
-/// crate.
-///
-/// [`ToTokens`]: trait.ToTokens.html
-/// [Syn]: https://github.com/dtolnay/syn
-///
-/// Repetition is done using `#(...)*` or `#(...),*` again similar to
-/// `macro_rules!`. This iterates through the elements of any variable
-/// interpolated within the repetition and inserts a copy of the repetition body
-/// for each one. The variables in an interpolation may be a `Vec`, slice,
-/// `BTreeSet`, or any `Iterator`.
-///
-/// - `#(#var)*` — no separators
-/// - `#(#var),*` — the character before the asterisk is used as a separator
-/// - `#( struct #var; )*` — the repetition can contain other tokens
-/// - `#( #k => println!("{}", #v), )*` — even multiple interpolations
-///
-/// <br>
-///
-/// # Hygiene
-///
-/// Any interpolated tokens preserve the `Span` information provided by their
-/// `ToTokens` implementation. Tokens that originate within the `quote!`
-/// invocation are spanned with [`Span::call_site()`].
-///
-/// [`Span::call_site()`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.Span.html#method.call_site
-///
-/// A different span can be provided through the [`quote_spanned!`] macro.
-///
-/// [`quote_spanned!`]: macro.quote_spanned.html
-///
-/// <br>
-///
-/// # Return type
-///
-/// The macro evaluates to an expression of type `proc_macro2::TokenStream`.
-/// Meanwhile Rust procedural macros are expected to return the type
-/// `proc_macro::TokenStream`.
-///
-/// The difference between the two types is that `proc_macro` types are entirely
-/// specific to procedural macros and cannot ever exist in code outside of a
-/// procedural macro, while `proc_macro2` types may exist anywhere including
-/// tests and non-macro code like main.rs and build.rs. This is why even the
-/// procedural macro ecosystem is largely built around `proc_macro2`, because
-/// that ensures the libraries are unit testable and accessible in non-macro
-/// contexts.
-///
-/// There is a [`From`]-conversion in both directions so returning the output of
-/// `quote!` from a procedural macro usually looks like `tokens.into()` or
-/// `proc_macro::TokenStream::from(tokens)`.
-///
-/// [`From`]: https://doc.rust-lang.org/std/convert/trait.From.html
-///
-/// <br>
-///
-/// # Examples
-///
-/// ### Procedural macro
-///
-/// The structure of a basic procedural macro is as follows. Refer to the [Syn]
-/// crate for further useful guidance on using `quote!` as part of a procedural
-/// macro.
-///
-/// [Syn]: https://github.com/dtolnay/syn
-///
-/// ```
-/// # #[cfg(any())]
-/// extern crate proc_macro;
-/// # extern crate proc_macro2;
-///
-/// # #[cfg(any())]
-/// use proc_macro::TokenStream;
-/// # use proc_macro2::TokenStream;
-/// use quote::quote;
-///
-/// # const IGNORE_TOKENS: &'static str = stringify! {
-/// #[proc_macro_derive(HeapSize)]
-/// # };
-/// pub fn derive_heap_size(input: TokenStream) -> TokenStream {
-/// // Parse the input and figure out what implementation to generate...
-/// # const IGNORE_TOKENS: &'static str = stringify! {
-/// let name = /* ... */;
-/// let expr = /* ... */;
-/// # };
-/// #
-/// # let name = 0;
-/// # let expr = 0;
-///
-/// let expanded = quote! {
-/// // The generated impl.
-/// impl heapsize::HeapSize for #name {
-/// fn heap_size_of_children(&self) -> usize {
-/// #expr
-/// }
-/// }
-/// };
-///
-/// // Hand the output tokens back to the compiler.
-/// TokenStream::from(expanded)
-/// }
-/// ```
-///
-/// <p><br></p>
-///
-/// ### Combining quoted fragments
-///
-/// Usually you don't end up constructing an entire final `TokenStream` in one
-/// piece. Different parts may come from different helper functions. The tokens
-/// produced by `quote!` themselves implement `ToTokens` and so can be
-/// interpolated into later `quote!` invocations to build up a final result.
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// let type_definition = quote! {...};
-/// let methods = quote! {...};
-///
-/// let tokens = quote! {
-/// #type_definition
-/// #methods
-/// };
-/// ```
-///
-/// <p><br></p>
-///
-/// ### Constructing identifiers
-///
-/// Suppose we have an identifier `ident` which came from somewhere in a macro
-/// input and we need to modify it in some way for the macro output. Let's
-/// consider prepending the identifier with an underscore.
-///
-/// Simply interpolating the identifier next to an underscore will not have the
-/// behavior of concatenating them. The underscore and the identifier will
-/// continue to be two separate tokens as if you had written `_ x`.
-///
-/// ```
-/// # use proc_macro2::{self as syn, Span};
-/// # use quote::quote;
-/// #
-/// # let ident = syn::Ident::new("i", Span::call_site());
-/// #
-/// // incorrect
-/// quote! {
-/// let mut _#ident = 0;
-/// }
-/// # ;
-/// ```
-///
-/// The solution is to build a new identifier token with the correct value. As
-/// this is such a common case, the [`format_ident!`] macro provides a
-/// convenient utility for doing so correctly.
-///
-/// ```
-/// # use proc_macro2::{Ident, Span};
-/// # use quote::{format_ident, quote};
-/// #
-/// # let ident = Ident::new("i", Span::call_site());
-/// #
-/// let varname = format_ident!("_{}", ident);
-/// quote! {
-/// let mut #varname = 0;
-/// }
-/// # ;
-/// ```
-///
-/// Alternatively, the APIs provided by Syn and proc-macro2 can be used to
-/// directly build the identifier. This is roughly equivalent to the above, but
-/// will not handle `ident` being a raw identifier.
-///
-/// ```
-/// # use proc_macro2::{self as syn, Span};
-/// # use quote::quote;
-/// #
-/// # let ident = syn::Ident::new("i", Span::call_site());
-/// #
-/// let concatenated = format!("_{}", ident);
-/// let varname = syn::Ident::new(&concatenated, ident.span());
-/// quote! {
-/// let mut #varname = 0;
-/// }
-/// # ;
-/// ```
-///
-/// <p><br></p>
-///
-/// ### Making method calls
-///
-/// Let's say our macro requires some type specified in the macro input to have
-/// a constructor called `new`. We have the type in a variable called
-/// `field_type` of type `syn::Type` and want to invoke the constructor.
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// # let field_type = quote!(...);
-/// #
-/// // incorrect
-/// quote! {
-/// let value = #field_type::new();
-/// }
-/// # ;
-/// ```
-///
-/// This works only sometimes. If `field_type` is `String`, the expanded code
-/// contains `String::new()` which is fine. But if `field_type` is something
-/// like `Vec<i32>` then the expanded code is `Vec<i32>::new()` which is invalid
-/// syntax. Ordinarily in handwritten Rust we would write `Vec::<i32>::new()`
-/// but for macros often the following is more convenient.
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// # let field_type = quote!(...);
-/// #
-/// quote! {
-/// let value = <#field_type>::new();
-/// }
-/// # ;
-/// ```
-///
-/// This expands to `<Vec<i32>>::new()` which behaves correctly.
-///
-/// A similar pattern is appropriate for trait methods.
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// # let field_type = quote!(...);
-/// #
-/// quote! {
-/// let value = <#field_type as core::default::Default>::default();
-/// }
-/// # ;
-/// ```
-///
-/// <p><br></p>
-///
-/// ### Interpolating text inside of doc comments
-///
-/// Neither doc comments nor string literals get interpolation behavior in
-/// quote:
-///
-/// ```compile_fail
-/// quote! {
-/// /// try to interpolate: #ident
-/// ///
-/// /// ...
-/// }
-/// ```
-///
-/// ```compile_fail
-/// quote! {
-/// #[doc = "try to interpolate: #ident"]
-/// }
-/// ```
-///
-/// Macro calls in a doc attribute are not valid syntax:
-///
-/// ```compile_fail
-/// quote! {
-/// #[doc = concat!("try to interpolate: ", stringify!(#ident))]
-/// }
-/// ```
-///
-/// Instead the best way to build doc comments that involve variables is by
-/// formatting the doc string literal outside of quote.
-///
-/// ```rust
-/// # use proc_macro2::{Ident, Span};
-/// # use quote::quote;
-/// #
-/// # const IGNORE: &str = stringify! {
-/// let msg = format!(...);
-/// # };
-/// #
-/// # let ident = Ident::new("var", Span::call_site());
-/// # let msg = format!("try to interpolate: {}", ident);
-/// quote! {
-/// #[doc = #msg]
-/// ///
-/// /// ...
-/// }
-/// # ;
-/// ```
-///
-/// <p><br></p>
-///
-/// ### Indexing into a tuple struct
-///
-/// When interpolating indices of a tuple or tuple struct, we need them not to
-/// appears suffixed as integer literals by interpolating them as [`syn::Index`]
-/// instead.
-///
-/// [`syn::Index`]: https://docs.rs/syn/1.0/syn/struct.Index.html
-///
-/// ```compile_fail
-/// let i = 0usize..self.fields.len();
-///
-/// // expands to 0 + self.0usize.heap_size() + self.1usize.heap_size() + ...
-/// // which is not valid syntax
-/// quote! {
-/// 0 #( + self.#i.heap_size() )*
-/// }
-/// ```
-///
-/// ```
-/// # use proc_macro2::{Ident, TokenStream};
-/// # use quote::quote;
-/// #
-/// # mod syn {
-/// # use proc_macro2::{Literal, TokenStream};
-/// # use quote::{ToTokens, TokenStreamExt};
-/// #
-/// # pub struct Index(usize);
-/// #
-/// # impl From<usize> for Index {
-/// # fn from(i: usize) -> Self {
-/// # Index(i)
-/// # }
-/// # }
-/// #
-/// # impl ToTokens for Index {
-/// # fn to_tokens(&self, tokens: &mut TokenStream) {
-/// # tokens.append(Literal::usize_unsuffixed(self.0));
-/// # }
-/// # }
-/// # }
-/// #
-/// # struct Struct {
-/// # fields: Vec<Ident>,
-/// # }
-/// #
-/// # impl Struct {
-/// # fn example(&self) -> TokenStream {
-/// let i = (0..self.fields.len()).map(syn::Index::from);
-///
-/// // expands to 0 + self.0.heap_size() + self.1.heap_size() + ...
-/// quote! {
-/// 0 #( + self.#i.heap_size() )*
-/// }
-/// # }
-/// # }
-/// ```
-#[macro_export]
-macro_rules! quote {
- ($($tt:tt)*) => {
- $crate::quote_spanned!($crate::__rt::Span::call_site()=> $($tt)*)
- };
-}
-
-/// Same as `quote!`, but applies a given span to all tokens originating within
-/// the macro invocation.
-///
-/// <br>
-///
-/// # Syntax
-///
-/// A span expression of type [`Span`], followed by `=>`, followed by the tokens
-/// to quote. The span expression should be brief &mdash; use a variable for
-/// anything more than a few characters. There should be no space before the
-/// `=>` token.
-///
-/// [`Span`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.Span.html
-///
-/// ```
-/// # use proc_macro2::Span;
-/// # use quote::quote_spanned;
-/// #
-/// # const IGNORE_TOKENS: &'static str = stringify! {
-/// let span = /* ... */;
-/// # };
-/// # let span = Span::call_site();
-/// # let init = 0;
-///
-/// // On one line, use parentheses.
-/// let tokens = quote_spanned!(span=> Box::into_raw(Box::new(#init)));
-///
-/// // On multiple lines, place the span at the top and use braces.
-/// let tokens = quote_spanned! {span=>
-/// Box::into_raw(Box::new(#init))
-/// };
-/// ```
-///
-/// The lack of space before the `=>` should look jarring to Rust programmers
-/// and this is intentional. The formatting is designed to be visibly
-/// off-balance and draw the eye a particular way, due to the span expression
-/// being evaluated in the context of the procedural macro and the remaining
-/// tokens being evaluated in the generated code.
-///
-/// <br>
-///
-/// # Hygiene
-///
-/// Any interpolated tokens preserve the `Span` information provided by their
-/// `ToTokens` implementation. Tokens that originate within the `quote_spanned!`
-/// invocation are spanned with the given span argument.
-///
-/// <br>
-///
-/// # Example
-///
-/// The following procedural macro code uses `quote_spanned!` to assert that a
-/// particular Rust type implements the [`Sync`] trait so that references can be
-/// safely shared between threads.
-///
-/// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
-///
-/// ```
-/// # use quote::{quote_spanned, TokenStreamExt, ToTokens};
-/// # use proc_macro2::{Span, TokenStream};
-/// #
-/// # struct Type;
-/// #
-/// # impl Type {
-/// # fn span(&self) -> Span {
-/// # Span::call_site()
-/// # }
-/// # }
-/// #
-/// # impl ToTokens for Type {
-/// # fn to_tokens(&self, _tokens: &mut TokenStream) {}
-/// # }
-/// #
-/// # let ty = Type;
-/// # let call_site = Span::call_site();
-/// #
-/// let ty_span = ty.span();
-/// let assert_sync = quote_spanned! {ty_span=>
-/// struct _AssertSync where #ty: Sync;
-/// };
-/// ```
-///
-/// If the assertion fails, the user will see an error like the following. The
-/// input span of their type is hightlighted in the error.
-///
-/// ```text
-/// error[E0277]: the trait bound `*const (): std::marker::Sync` is not satisfied
-/// --> src/main.rs:10:21
-/// |
-/// 10 | static ref PTR: *const () = &();
-/// | ^^^^^^^^^ `*const ()` cannot be shared between threads safely
-/// ```
-///
-/// In this example it is important for the where-clause to be spanned with the
-/// line/column information of the user's input type so that error messages are
-/// placed appropriately by the compiler.
-#[macro_export]
-macro_rules! quote_spanned {
- ($span:expr=> $($tt:tt)*) => {{
- let mut _s = $crate::__rt::TokenStream::new();
- let _span: $crate::__rt::Span = $span;
- $crate::quote_each_token!(_s _span $($tt)*);
- _s
- }};
-}
-
-// Extract the names of all #metavariables and pass them to the $call macro.
-//
-// in: pounded_var_names!(then!(...) a #b c #( #d )* #e)
-// out: then!(... b);
-// then!(... d);
-// then!(... e);
-#[macro_export]
-#[doc(hidden)]
-macro_rules! pounded_var_names {
- ($call:ident! $extra:tt $($tts:tt)*) => {
- $crate::pounded_var_names_with_context!($call! $extra
- (@ $($tts)*)
- ($($tts)* @)
- )
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! pounded_var_names_with_context {
- ($call:ident! $extra:tt ($($b1:tt)*) ($($curr:tt)*)) => {
- $(
- $crate::pounded_var_with_context!($call! $extra $b1 $curr);
- )*
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! pounded_var_with_context {
- ($call:ident! $extra:tt $b1:tt ( $($inner:tt)* )) => {
- $crate::pounded_var_names!($call! $extra $($inner)*);
- };
-
- ($call:ident! $extra:tt $b1:tt [ $($inner:tt)* ]) => {
- $crate::pounded_var_names!($call! $extra $($inner)*);
- };
-
- ($call:ident! $extra:tt $b1:tt { $($inner:tt)* }) => {
- $crate::pounded_var_names!($call! $extra $($inner)*);
- };
-
- ($call:ident!($($extra:tt)*) # $var:ident) => {
- $crate::$call!($($extra)* $var);
- };
-
- ($call:ident! $extra:tt $b1:tt $curr:tt) => {};
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! quote_bind_into_iter {
- ($has_iter:ident $var:ident) => {
- // `mut` may be unused if $var occurs multiple times in the list.
- #[allow(unused_mut)]
- let (mut $var, i) = $var.quote_into_iter();
- let $has_iter = $has_iter | i;
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! quote_bind_next_or_break {
- ($var:ident) => {
- let $var = match $var.next() {
- Some(_x) => $crate::__rt::RepInterp(_x),
- None => break,
- };
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! quote_each_token {
- ($tokens:ident $span:ident $($tts:tt)*) => {
- $crate::quote_tokens_with_context!($tokens $span
- (@ @ @ @ @ @ $($tts)*)
- (@ @ @ @ @ $($tts)* @)
- (@ @ @ @ $($tts)* @ @)
- (@ @ @ $(($tts))* @ @ @)
- (@ @ $($tts)* @ @ @ @)
- (@ $($tts)* @ @ @ @ @)
- ($($tts)* @ @ @ @ @ @)
- );
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! quote_tokens_with_context {
- ($tokens:ident $span:ident
- ($($b3:tt)*) ($($b2:tt)*) ($($b1:tt)*)
- ($($curr:tt)*)
- ($($a1:tt)*) ($($a2:tt)*) ($($a3:tt)*)
- ) => {
- $(
- $crate::quote_token_with_context!($tokens $span $b3 $b2 $b1 $curr $a1 $a2 $a3);
- )*
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! quote_token_with_context {
- ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt @ $a1:tt $a2:tt $a3:tt) => {};
-
- ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) * $a3:tt) => {{
- use $crate::__rt::ext::*;
- let has_iter = $crate::__rt::ThereIsNoIteratorInRepetition;
- $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*);
- let _: $crate::__rt::HasIterator = has_iter;
- // This is `while true` instead of `loop` because if there are no
- // iterators used inside of this repetition then the body would not
- // contain any `break`, so the compiler would emit unreachable code
- // warnings on anything below the loop. We use has_iter to detect and
- // fail to compile when there are no iterators, so here we just work
- // around the unneeded extra warning.
- while true {
- $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*);
- $crate::quote_each_token!($tokens $span $($inner)*);
- }
- }};
- ($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) * $a2:tt $a3:tt) => {};
- ($tokens:ident $span:ident $b3:tt # ( $($inner:tt)* ) (*) $a1:tt $a2:tt $a3:tt) => {};
-
- ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) $sep:tt *) => {{
- use $crate::__rt::ext::*;
- let mut _i = 0usize;
- let has_iter = $crate::__rt::ThereIsNoIteratorInRepetition;
- $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*);
- let _: $crate::__rt::HasIterator = has_iter;
- while true {
- $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*);
- if _i > 0 {
- $crate::quote_token!($tokens $span $sep);
- }
- _i += 1;
- $crate::quote_each_token!($tokens $span $($inner)*);
- }
- }};
- ($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) $sep:tt * $a3:tt) => {};
- ($tokens:ident $span:ident $b3:tt # ( $($inner:tt)* ) ($sep:tt) * $a2:tt $a3:tt) => {};
- ($tokens:ident $span:ident # ( $($inner:tt)* ) * (*) $a1:tt $a2:tt $a3:tt) => {
- // https://github.com/dtolnay/quote/issues/130
- $crate::quote_token!($tokens $span *);
- };
- ($tokens:ident $span:ident # ( $($inner:tt)* ) $sep:tt (*) $a1:tt $a2:tt $a3:tt) => {};
-
- ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) $var:ident $a2:tt $a3:tt) => {
- $crate::ToTokens::to_tokens(&$var, &mut $tokens);
- };
- ($tokens:ident $span:ident $b3:tt $b2:tt # ($var:ident) $a1:tt $a2:tt $a3:tt) => {};
- ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt ($curr:tt) $a1:tt $a2:tt $a3:tt) => {
- $crate::quote_token!($tokens $span $curr);
- };
-}
-
-#[macro_export]
-#[doc(hidden)]
-macro_rules! quote_token {
- ($tokens:ident $span:ident ( $($inner:tt)* )) => {
- $tokens.extend({
- let mut g = $crate::__rt::Group::new(
- $crate::__rt::Delimiter::Parenthesis,
- $crate::quote_spanned!($span=> $($inner)*),
- );
- g.set_span($span);
- Some($crate::__rt::TokenTree::from(g))
- });
- };
-
- ($tokens:ident $span:ident [ $($inner:tt)* ]) => {
- $tokens.extend({
- let mut g = $crate::__rt::Group::new(
- $crate::__rt::Delimiter::Bracket,
- $crate::quote_spanned!($span=> $($inner)*),
- );
- g.set_span($span);
- Some($crate::__rt::TokenTree::from(g))
- });
- };
-
- ($tokens:ident $span:ident { $($inner:tt)* }) => {
- $tokens.extend({
- let mut g = $crate::__rt::Group::new(
- $crate::__rt::Delimiter::Brace,
- $crate::quote_spanned!($span=> $($inner)*),
- );
- g.set_span($span);
- Some($crate::__rt::TokenTree::from(g))
- });
- };
-
- ($tokens:ident $span:ident +) => {
- $crate::__rt::push_add(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident +=) => {
- $crate::__rt::push_add_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident &) => {
- $crate::__rt::push_and(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident &&) => {
- $crate::__rt::push_and_and(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident &=) => {
- $crate::__rt::push_and_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident @) => {
- $crate::__rt::push_at(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident !) => {
- $crate::__rt::push_bang(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ^) => {
- $crate::__rt::push_caret(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ^=) => {
- $crate::__rt::push_caret_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident :) => {
- $crate::__rt::push_colon(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ::) => {
- $crate::__rt::push_colon2(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ,) => {
- $crate::__rt::push_comma(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident /) => {
- $crate::__rt::push_div(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident /=) => {
- $crate::__rt::push_div_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident .) => {
- $crate::__rt::push_dot(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ..) => {
- $crate::__rt::push_dot2(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ...) => {
- $crate::__rt::push_dot3(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ..=) => {
- $crate::__rt::push_dot_dot_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident =) => {
- $crate::__rt::push_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ==) => {
- $crate::__rt::push_eq_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident >=) => {
- $crate::__rt::push_ge(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident >) => {
- $crate::__rt::push_gt(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident <=) => {
- $crate::__rt::push_le(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident <) => {
- $crate::__rt::push_lt(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident *=) => {
- $crate::__rt::push_mul_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident !=) => {
- $crate::__rt::push_ne(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident |) => {
- $crate::__rt::push_or(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident |=) => {
- $crate::__rt::push_or_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ||) => {
- $crate::__rt::push_or_or(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident #) => {
- $crate::__rt::push_pound(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ?) => {
- $crate::__rt::push_question(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ->) => {
- $crate::__rt::push_rarrow(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident <-) => {
- $crate::__rt::push_larrow(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident %) => {
- $crate::__rt::push_rem(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident %=) => {
- $crate::__rt::push_rem_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident =>) => {
- $crate::__rt::push_fat_arrow(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident ;) => {
- $crate::__rt::push_semi(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident <<) => {
- $crate::__rt::push_shl(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident <<=) => {
- $crate::__rt::push_shl_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident >>) => {
- $crate::__rt::push_shr(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident >>=) => {
- $crate::__rt::push_shr_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident *) => {
- $crate::__rt::push_star(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident -) => {
- $crate::__rt::push_sub(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident -=) => {
- $crate::__rt::push_sub_eq(&mut $tokens, $span);
- };
-
- ($tokens:ident $span:ident $other:tt) => {
- $crate::__rt::parse(&mut $tokens, $span, stringify!($other));
- };
-}
diff --git a/quote/src/runtime.rs b/quote/src/runtime.rs
deleted file mode 100644
index 4a1c14c..0000000
--- a/quote/src/runtime.rs
+++ /dev/null
@@ -1,373 +0,0 @@
-use crate::{IdentFragment, ToTokens, TokenStreamExt};
-use std::fmt;
-use std::ops::BitOr;
-
-pub use proc_macro2::*;
-
-pub struct HasIterator; // True
-pub struct ThereIsNoIteratorInRepetition; // False
-
-impl BitOr<ThereIsNoIteratorInRepetition> for ThereIsNoIteratorInRepetition {
- type Output = ThereIsNoIteratorInRepetition;
- fn bitor(self, _rhs: ThereIsNoIteratorInRepetition) -> ThereIsNoIteratorInRepetition {
- ThereIsNoIteratorInRepetition
- }
-}
-
-impl BitOr<ThereIsNoIteratorInRepetition> for HasIterator {
- type Output = HasIterator;
- fn bitor(self, _rhs: ThereIsNoIteratorInRepetition) -> HasIterator {
- HasIterator
- }
-}
-
-impl BitOr<HasIterator> for ThereIsNoIteratorInRepetition {
- type Output = HasIterator;
- fn bitor(self, _rhs: HasIterator) -> HasIterator {
- HasIterator
- }
-}
-
-impl BitOr<HasIterator> for HasIterator {
- type Output = HasIterator;
- fn bitor(self, _rhs: HasIterator) -> HasIterator {
- HasIterator
- }
-}
-
-/// Extension traits used by the implementation of `quote!`. These are defined
-/// in separate traits, rather than as a single trait due to ambiguity issues.
-///
-/// These traits expose a `quote_into_iter` method which should allow calling
-/// whichever impl happens to be applicable. Calling that method repeatedly on
-/// the returned value should be idempotent.
-pub mod ext {
- use super::RepInterp;
- use super::{HasIterator as HasIter, ThereIsNoIteratorInRepetition as DoesNotHaveIter};
- use crate::ToTokens;
- use std::collections::btree_set::{self, BTreeSet};
- use std::slice;
-
- /// Extension trait providing the `quote_into_iter` method on iterators.
- pub trait RepIteratorExt: Iterator + Sized {
- fn quote_into_iter(self) -> (Self, HasIter) {
- (self, HasIter)
- }
- }
-
- impl<T: Iterator> RepIteratorExt for T {}
-
- /// Extension trait providing the `quote_into_iter` method for
- /// non-iterable types. These types interpolate the same value in each
- /// iteration of the repetition.
- pub trait RepToTokensExt {
- /// Pretend to be an iterator for the purposes of `quote_into_iter`.
- /// This allows repeated calls to `quote_into_iter` to continue
- /// correctly returning DoesNotHaveIter.
- fn next(&self) -> Option<&Self> {
- Some(self)
- }
-
- fn quote_into_iter(&self) -> (&Self, DoesNotHaveIter) {
- (self, DoesNotHaveIter)
- }
- }
-
- impl<T: ToTokens + ?Sized> RepToTokensExt for T {}
-
- /// Extension trait providing the `quote_into_iter` method for types that
- /// can be referenced as an iterator.
- pub trait RepAsIteratorExt<'q> {
- type Iter: Iterator;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter);
- }
-
- impl<'q, 'a, T: RepAsIteratorExt<'q> + ?Sized> RepAsIteratorExt<'q> for &'a T {
- type Iter = T::Iter;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- <T as RepAsIteratorExt>::quote_into_iter(*self)
- }
- }
-
- impl<'q, 'a, T: RepAsIteratorExt<'q> + ?Sized> RepAsIteratorExt<'q> for &'a mut T {
- type Iter = T::Iter;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- <T as RepAsIteratorExt>::quote_into_iter(*self)
- }
- }
-
- impl<'q, T: 'q> RepAsIteratorExt<'q> for [T] {
- type Iter = slice::Iter<'q, T>;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- (self.iter(), HasIter)
- }
- }
-
- impl<'q, T: 'q> RepAsIteratorExt<'q> for Vec<T> {
- type Iter = slice::Iter<'q, T>;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- (self.iter(), HasIter)
- }
- }
-
- impl<'q, T: 'q> RepAsIteratorExt<'q> for BTreeSet<T> {
- type Iter = btree_set::Iter<'q, T>;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- (self.iter(), HasIter)
- }
- }
-
- macro_rules! array_rep_slice {
- ($($l:tt)*) => {
- $(
- impl<'q, T: 'q> RepAsIteratorExt<'q> for [T; $l] {
- type Iter = slice::Iter<'q, T>;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- (self.iter(), HasIter)
- }
- }
- )*
- }
- }
-
- array_rep_slice!(
- 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 26 27 28 29 30 31 32
- );
-
- impl<'q, T: RepAsIteratorExt<'q>> RepAsIteratorExt<'q> for RepInterp<T> {
- type Iter = T::Iter;
-
- fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
- self.0.quote_into_iter()
- }
- }
-}
-
-// Helper type used within interpolations to allow for repeated binding names.
-// Implements the relevant traits, and exports a dummy `next()` method.
-#[derive(Copy, Clone)]
-pub struct RepInterp<T>(pub T);
-
-impl<T> RepInterp<T> {
- // This method is intended to look like `Iterator::next`, and is called when
- // a name is bound multiple times, as the previous binding will shadow the
- // original `Iterator` object. This allows us to avoid advancing the
- // iterator multiple times per iteration.
- pub fn next(self) -> Option<T> {
- Some(self.0)
- }
-}
-
-impl<T: Iterator> Iterator for RepInterp<T> {
- type Item = T::Item;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.0.next()
- }
-}
-
-impl<T: ToTokens> ToTokens for RepInterp<T> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.0.to_tokens(tokens);
- }
-}
-
-fn is_ident_start(c: u8) -> bool {
- (b'a' <= c && c <= b'z') || (b'A' <= c && c <= b'Z') || c == b'_'
-}
-
-fn is_ident_continue(c: u8) -> bool {
- (b'a' <= c && c <= b'z') || (b'A' <= c && c <= b'Z') || c == b'_' || (b'0' <= c && c <= b'9')
-}
-
-fn is_ident(token: &str) -> bool {
- let mut iter = token.bytes();
- let first_ok = iter.next().map(is_ident_start).unwrap_or(false);
-
- first_ok && iter.all(is_ident_continue)
-}
-
-pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) {
- if is_ident(s) {
- // Fast path, since idents are the most common token.
- tokens.append(Ident::new(s, span));
- } else {
- let s: TokenStream = s.parse().expect("invalid token stream");
- tokens.extend(s.into_iter().map(|mut t| {
- t.set_span(span);
- t
- }));
- }
-}
-
-macro_rules! push_punct {
- ($name:ident $char1:tt) => {
- pub fn $name(tokens: &mut TokenStream, span: Span) {
- let mut punct = Punct::new($char1, Spacing::Alone);
- punct.set_span(span);
- tokens.append(punct);
- }
- };
- ($name:ident $char1:tt $char2:tt) => {
- pub fn $name(tokens: &mut TokenStream, span: Span) {
- let mut punct = Punct::new($char1, Spacing::Joint);
- punct.set_span(span);
- tokens.append(punct);
- let mut punct = Punct::new($char2, Spacing::Alone);
- punct.set_span(span);
- tokens.append(punct);
- }
- };
- ($name:ident $char1:tt $char2:tt $char3:tt) => {
- pub fn $name(tokens: &mut TokenStream, span: Span) {
- let mut punct = Punct::new($char1, Spacing::Joint);
- punct.set_span(span);
- tokens.append(punct);
- let mut punct = Punct::new($char2, Spacing::Joint);
- punct.set_span(span);
- tokens.append(punct);
- let mut punct = Punct::new($char3, Spacing::Alone);
- punct.set_span(span);
- tokens.append(punct);
- }
- };
-}
-
-push_punct!(push_add '+');
-push_punct!(push_add_eq '+' '=');
-push_punct!(push_and '&');
-push_punct!(push_and_and '&' '&');
-push_punct!(push_and_eq '&' '=');
-push_punct!(push_at '@');
-push_punct!(push_bang '!');
-push_punct!(push_caret '^');
-push_punct!(push_caret_eq '^' '=');
-push_punct!(push_colon ':');
-push_punct!(push_colon2 ':' ':');
-push_punct!(push_comma ',');
-push_punct!(push_div '/');
-push_punct!(push_div_eq '/' '=');
-push_punct!(push_dot '.');
-push_punct!(push_dot2 '.' '.');
-push_punct!(push_dot3 '.' '.' '.');
-push_punct!(push_dot_dot_eq '.' '.' '=');
-push_punct!(push_eq '=');
-push_punct!(push_eq_eq '=' '=');
-push_punct!(push_ge '>' '=');
-push_punct!(push_gt '>');
-push_punct!(push_le '<' '=');
-push_punct!(push_lt '<');
-push_punct!(push_mul_eq '*' '=');
-push_punct!(push_ne '!' '=');
-push_punct!(push_or '|');
-push_punct!(push_or_eq '|' '=');
-push_punct!(push_or_or '|' '|');
-push_punct!(push_pound '#');
-push_punct!(push_question '?');
-push_punct!(push_rarrow '-' '>');
-push_punct!(push_larrow '<' '-');
-push_punct!(push_rem '%');
-push_punct!(push_rem_eq '%' '=');
-push_punct!(push_fat_arrow '=' '>');
-push_punct!(push_semi ';');
-push_punct!(push_shl '<' '<');
-push_punct!(push_shl_eq '<' '<' '=');
-push_punct!(push_shr '>' '>');
-push_punct!(push_shr_eq '>' '>' '=');
-push_punct!(push_star '*');
-push_punct!(push_sub '-');
-push_punct!(push_sub_eq '-' '=');
-
-// Helper method for constructing identifiers from the `format_ident!` macro,
-// handling `r#` prefixes.
-//
-// Directly parsing the input string may produce a valid identifier,
-// although the input string was invalid, due to ignored characters such as
-// whitespace and comments. Instead, we always create a non-raw identifier
-// to validate that the string is OK, and only parse again if needed.
-//
-// The `is_ident` method defined above is insufficient for validation, as it
-// will reject non-ASCII identifiers.
-pub fn mk_ident(id: &str, span: Option<Span>) -> Ident {
- let span = span.unwrap_or_else(Span::call_site);
-
- let is_raw = id.starts_with("r#");
- let unraw = Ident::new(if is_raw { &id[2..] } else { id }, span);
- if !is_raw {
- return unraw;
- }
-
- // At this point, the identifier is raw, and the unraw-ed version of it was
- // successfully converted into an identifier. Try to produce a valid raw
- // identifier by running the `TokenStream` parser, and unwrapping the first
- // token as an `Ident`.
- //
- // FIXME: When `Ident::new_raw` becomes stable, this method should be
- // updated to call it when available.
- match id.parse::<TokenStream>() {
- Ok(ts) => {
- let mut iter = ts.into_iter();
- match (iter.next(), iter.next()) {
- (Some(TokenTree::Ident(mut id)), None) => {
- id.set_span(span);
- id
- }
- _ => unreachable!("valid raw ident fails to parse"),
- }
- }
- Err(_) => unreachable!("valid raw ident fails to parse"),
- }
-}
-
-// Adapts from `IdentFragment` to `fmt::Display` for use by the `format_ident!`
-// macro, and exposes span information from these fragments.
-//
-// This struct also has forwarding implementations of the formatting traits
-// `Octal`, `LowerHex`, `UpperHex`, and `Binary` to allow for their use within
-// `format_ident!`.
-#[derive(Copy, Clone)]
-pub struct IdentFragmentAdapter<T: IdentFragment>(pub T);
-
-impl<T: IdentFragment> IdentFragmentAdapter<T> {
- pub fn span(&self) -> Option<Span> {
- self.0.span()
- }
-}
-
-impl<T: IdentFragment> fmt::Display for IdentFragmentAdapter<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- IdentFragment::fmt(&self.0, f)
- }
-}
-
-impl<T: IdentFragment + fmt::Octal> fmt::Octal for IdentFragmentAdapter<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Octal::fmt(&self.0, f)
- }
-}
-
-impl<T: IdentFragment + fmt::LowerHex> fmt::LowerHex for IdentFragmentAdapter<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::LowerHex::fmt(&self.0, f)
- }
-}
-
-impl<T: IdentFragment + fmt::UpperHex> fmt::UpperHex for IdentFragmentAdapter<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::UpperHex::fmt(&self.0, f)
- }
-}
-
-impl<T: IdentFragment + fmt::Binary> fmt::Binary for IdentFragmentAdapter<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Binary::fmt(&self.0, f)
- }
-}
diff --git a/quote/src/spanned.rs b/quote/src/spanned.rs
deleted file mode 100644
index 55168bd..0000000
--- a/quote/src/spanned.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use crate::ToTokens;
-use proc_macro2::{Span, TokenStream};
-
-pub trait Spanned {
- fn __span(&self) -> Span;
-}
-
-impl Spanned for Span {
- fn __span(&self) -> Span {
- *self
- }
-}
-
-impl<T: ?Sized + ToTokens> Spanned for T {
- fn __span(&self) -> Span {
- join_spans(self.into_token_stream())
- }
-}
-
-fn join_spans(tokens: TokenStream) -> Span {
- let mut iter = tokens.into_iter().filter_map(|tt| {
- // FIXME: This shouldn't be required, since optimally spans should
- // never be invalid. This filter_map can probably be removed when
- // https://github.com/rust-lang/rust/issues/43081 is resolved.
- let span = tt.span();
- let debug = format!("{:?}", span);
- if debug.ends_with("bytes(0..0)") {
- None
- } else {
- Some(span)
- }
- });
-
- let first = match iter.next() {
- Some(span) => span,
- None => return Span::call_site(),
- };
-
- iter.fold(None, |_prev, next| Some(next))
- .and_then(|last| first.join(last))
- .unwrap_or(first)
-}
diff --git a/quote/src/to_tokens.rs b/quote/src/to_tokens.rs
deleted file mode 100644
index 7f98083..0000000
--- a/quote/src/to_tokens.rs
+++ /dev/null
@@ -1,209 +0,0 @@
-use super::TokenStreamExt;
-
-use std::borrow::Cow;
-use std::iter;
-use std::rc::Rc;
-
-use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
-
-/// Types that can be interpolated inside a `quote!` invocation.
-///
-/// [`quote!`]: macro.quote.html
-pub trait ToTokens {
- /// Write `self` to the given `TokenStream`.
- ///
- /// The token append methods provided by the [`TokenStreamExt`] extension
- /// trait may be useful for implementing `ToTokens`.
- ///
- /// [`TokenStreamExt`]: trait.TokenStreamExt.html
- ///
- /// # Example
- ///
- /// Example implementation for a struct representing Rust paths like
- /// `std::cmp::PartialEq`:
- ///
- /// ```
- /// use proc_macro2::{TokenTree, Spacing, Span, Punct, TokenStream};
- /// use quote::{TokenStreamExt, ToTokens};
- ///
- /// pub struct Path {
- /// pub global: bool,
- /// pub segments: Vec<PathSegment>,
- /// }
- ///
- /// impl ToTokens for Path {
- /// fn to_tokens(&self, tokens: &mut TokenStream) {
- /// for (i, segment) in self.segments.iter().enumerate() {
- /// if i > 0 || self.global {
- /// // Double colon `::`
- /// tokens.append(Punct::new(':', Spacing::Joint));
- /// tokens.append(Punct::new(':', Spacing::Alone));
- /// }
- /// segment.to_tokens(tokens);
- /// }
- /// }
- /// }
- /// #
- /// # pub struct PathSegment;
- /// #
- /// # impl ToTokens for PathSegment {
- /// # fn to_tokens(&self, tokens: &mut TokenStream) {
- /// # unimplemented!()
- /// # }
- /// # }
- /// ```
- fn to_tokens(&self, tokens: &mut TokenStream);
-
- /// Convert `self` directly into a `TokenStream` object.
- ///
- /// This method is implicitly implemented using `to_tokens`, and acts as a
- /// convenience method for consumers of the `ToTokens` trait.
- fn to_token_stream(&self) -> TokenStream {
- let mut tokens = TokenStream::new();
- self.to_tokens(&mut tokens);
- tokens
- }
-
- /// Convert `self` directly into a `TokenStream` object.
- ///
- /// This method is implicitly implemented using `to_tokens`, and acts as a
- /// convenience method for consumers of the `ToTokens` trait.
- fn into_token_stream(self) -> TokenStream
- where
- Self: Sized,
- {
- self.to_token_stream()
- }
-}
-
-impl<'a, T: ?Sized + ToTokens> ToTokens for &'a T {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- (**self).to_tokens(tokens);
- }
-}
-
-impl<'a, T: ?Sized + ToTokens> ToTokens for &'a mut T {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- (**self).to_tokens(tokens);
- }
-}
-
-impl<'a, T: ?Sized + ToOwned + ToTokens> ToTokens for Cow<'a, T> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- (**self).to_tokens(tokens);
- }
-}
-
-impl<T: ?Sized + ToTokens> ToTokens for Box<T> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- (**self).to_tokens(tokens);
- }
-}
-
-impl<T: ?Sized + ToTokens> ToTokens for Rc<T> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- (**self).to_tokens(tokens);
- }
-}
-
-impl<T: ToTokens> ToTokens for Option<T> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if let Some(ref t) = *self {
- t.to_tokens(tokens);
- }
- }
-}
-
-impl ToTokens for str {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(Literal::string(self));
- }
-}
-
-impl ToTokens for String {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.as_str().to_tokens(tokens);
- }
-}
-
-macro_rules! primitive {
- ($($t:ident => $name:ident)*) => ($(
- impl ToTokens for $t {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(Literal::$name(*self));
- }
- }
- )*)
-}
-
-primitive! {
- i8 => i8_suffixed
- i16 => i16_suffixed
- i32 => i32_suffixed
- i64 => i64_suffixed
- i128 => i128_suffixed
- isize => isize_suffixed
-
- u8 => u8_suffixed
- u16 => u16_suffixed
- u32 => u32_suffixed
- u64 => u64_suffixed
- u128 => u128_suffixed
- usize => usize_suffixed
-
- f32 => f32_suffixed
- f64 => f64_suffixed
-}
-
-impl ToTokens for char {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(Literal::character(*self));
- }
-}
-
-impl ToTokens for bool {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- let word = if *self { "true" } else { "false" };
- tokens.append(Ident::new(word, Span::call_site()));
- }
-}
-
-impl ToTokens for Group {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(self.clone());
- }
-}
-
-impl ToTokens for Ident {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(self.clone());
- }
-}
-
-impl ToTokens for Punct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(self.clone());
- }
-}
-
-impl ToTokens for Literal {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(self.clone());
- }
-}
-
-impl ToTokens for TokenTree {
- fn to_tokens(&self, dst: &mut TokenStream) {
- dst.append(self.clone());
- }
-}
-
-impl ToTokens for TokenStream {
- fn to_tokens(&self, dst: &mut TokenStream) {
- dst.extend(iter::once(self.clone()));
- }
-
- fn into_token_stream(self) -> TokenStream {
- self
- }
-}
diff --git a/quote/tests/compiletest.rs b/quote/tests/compiletest.rs
deleted file mode 100644
index f9aea23..0000000
--- a/quote/tests/compiletest.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#[rustversion::attr(not(nightly), ignore)]
-#[test]
-fn ui() {
- let t = trybuild::TestCases::new();
- t.compile_fail("tests/ui/*.rs");
-}
diff --git a/quote/tests/test.rs b/quote/tests/test.rs
deleted file mode 100644
index 957d470..0000000
--- a/quote/tests/test.rs
+++ /dev/null
@@ -1,429 +0,0 @@
-#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))]
-
-use std::borrow::Cow;
-use std::collections::BTreeSet;
-
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::{format_ident, quote, TokenStreamExt};
-
-struct X;
-
-impl quote::ToTokens for X {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(Ident::new("X", Span::call_site()));
- }
-}
-
-#[test]
-fn test_quote_impl() {
- let tokens = quote! {
- impl<'a, T: ToTokens> ToTokens for &'a T {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- (**self).to_tokens(tokens)
- }
- }
- };
-
- let expected = concat!(
- "impl < 'a , T : ToTokens > ToTokens for & 'a T { ",
- "fn to_tokens ( & self , tokens : & mut TokenStream ) { ",
- "( * * self ) . to_tokens ( tokens ) ",
- "} ",
- "}"
- );
-
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_substitution() {
- let x = X;
- let tokens = quote!(#x <#x> (#x) [#x] {#x});
-
- let expected = "X < X > ( X ) [ X ] { X }";
-
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_iter() {
- let primes = &[X, X, X, X];
-
- assert_eq!("X X X X", quote!(#(#primes)*).to_string());
-
- assert_eq!("X , X , X , X ,", quote!(#(#primes,)*).to_string());
-
- assert_eq!("X , X , X , X", quote!(#(#primes),*).to_string());
-}
-
-#[test]
-fn test_advanced() {
- let generics = quote!( <'a, T> );
-
- let where_clause = quote!( where T: Serialize );
-
- let field_ty = quote!(String);
-
- let item_ty = quote!(Cow<'a, str>);
-
- let path = quote!(SomeTrait::serialize_with);
-
- let value = quote!(self.x);
-
- let tokens = quote! {
- struct SerializeWith #generics #where_clause {
- value: &'a #field_ty,
- phantom: ::std::marker::PhantomData<#item_ty>,
- }
-
- impl #generics ::serde::Serialize for SerializeWith #generics #where_clause {
- fn serialize<S>(&self, s: &mut S) -> Result<(), S::Error>
- where S: ::serde::Serializer
- {
- #path(self.value, s)
- }
- }
-
- SerializeWith {
- value: #value,
- phantom: ::std::marker::PhantomData::<#item_ty>,
- }
- };
-
- let expected = concat!(
- "struct SerializeWith < 'a , T > where T : Serialize { ",
- "value : & 'a String , ",
- "phantom : :: std :: marker :: PhantomData < Cow < 'a , str > > , ",
- "} ",
- "impl < 'a , T > :: serde :: Serialize for SerializeWith < 'a , T > where T : Serialize { ",
- "fn serialize < S > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > ",
- "where S : :: serde :: Serializer ",
- "{ ",
- "SomeTrait :: serialize_with ( self . value , s ) ",
- "} ",
- "} ",
- "SerializeWith { ",
- "value : self . x , ",
- "phantom : :: std :: marker :: PhantomData :: < Cow < 'a , str > > , ",
- "}"
- );
-
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_integer() {
- let ii8 = -1i8;
- let ii16 = -1i16;
- let ii32 = -1i32;
- let ii64 = -1i64;
- let ii128 = -1i128;
- let iisize = -1isize;
- let uu8 = 1u8;
- let uu16 = 1u16;
- let uu32 = 1u32;
- let uu64 = 1u64;
- let uu128 = 1u128;
- let uusize = 1usize;
-
- let tokens = quote! {
- #ii8 #ii16 #ii32 #ii64 #ii128 #iisize
- #uu8 #uu16 #uu32 #uu64 #uu128 #uusize
- };
- let expected = "-1i8 -1i16 -1i32 -1i64 -1i128 -1isize 1u8 1u16 1u32 1u64 1u128 1usize";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_floating() {
- let e32 = 2.345f32;
-
- let e64 = 2.345f64;
-
- let tokens = quote! {
- #e32
- #e64
- };
- let expected = concat!("2.345f32 2.345f64");
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_char() {
- let zero = '\0';
- let pound = '#';
- let quote = '"';
- let apost = '\'';
- let newline = '\n';
- let heart = '\u{2764}';
-
- let tokens = quote! {
- #zero #pound #quote #apost #newline #heart
- };
- let expected = "'\\u{0}' '#' '\"' '\\'' '\\n' '\\u{2764}'";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_str() {
- let s = "\0 a 'b \" c";
- let tokens = quote!(#s);
- let expected = "\"\\u{0} a 'b \\\" c\"";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_string() {
- let s = "\0 a 'b \" c".to_string();
- let tokens = quote!(#s);
- let expected = "\"\\u{0} a 'b \\\" c\"";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_ident() {
- let foo = Ident::new("Foo", Span::call_site());
- let bar = Ident::new(&format!("Bar{}", 7), Span::call_site());
- let tokens = quote!(struct #foo; enum #bar {});
- let expected = "struct Foo ; enum Bar7 { }";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_duplicate() {
- let ch = 'x';
-
- let tokens = quote!(#ch #ch);
-
- let expected = "'x' 'x'";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_fancy_repetition() {
- let foo = vec!["a", "b"];
- let bar = vec![true, false];
-
- let tokens = quote! {
- #(#foo: #bar),*
- };
-
- let expected = r#""a" : true , "b" : false"#;
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_nested_fancy_repetition() {
- let nested = vec![vec!['a', 'b', 'c'], vec!['x', 'y', 'z']];
-
- let tokens = quote! {
- #(
- #(#nested)*
- ),*
- };
-
- let expected = "'a' 'b' 'c' , 'x' 'y' 'z'";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_duplicate_name_repetition() {
- let foo = &["a", "b"];
-
- let tokens = quote! {
- #(#foo: #foo),*
- #(#foo: #foo),*
- };
-
- let expected = r#""a" : "a" , "b" : "b" "a" : "a" , "b" : "b""#;
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_duplicate_name_repetition_no_copy() {
- let foo = vec!["a".to_owned(), "b".to_owned()];
-
- let tokens = quote! {
- #(#foo: #foo),*
- };
-
- let expected = r#""a" : "a" , "b" : "b""#;
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_btreeset_repetition() {
- let mut set = BTreeSet::new();
- set.insert("a".to_owned());
- set.insert("b".to_owned());
-
- let tokens = quote! {
- #(#set: #set),*
- };
-
- let expected = r#""a" : "a" , "b" : "b""#;
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_variable_name_conflict() {
- // The implementation of `#(...),*` uses the variable `_i` but it should be
- // fine, if a little confusing when debugging.
- let _i = vec!['a', 'b'];
- let tokens = quote! { #(#_i),* };
- let expected = "'a' , 'b'";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_nonrep_in_repetition() {
- let rep = vec!["a", "b"];
- let nonrep = "c";
-
- let tokens = quote! {
- #(#rep #rep : #nonrep #nonrep),*
- };
-
- let expected = r#""a" "a" : "c" "c" , "b" "b" : "c" "c""#;
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_empty_quote() {
- let tokens = quote!();
- assert_eq!("", tokens.to_string());
-}
-
-#[test]
-fn test_box_str() {
- let b = "str".to_owned().into_boxed_str();
- let tokens = quote! { #b };
- assert_eq!("\"str\"", tokens.to_string());
-}
-
-#[test]
-fn test_cow() {
- let owned: Cow<Ident> = Cow::Owned(Ident::new("owned", Span::call_site()));
-
- let ident = Ident::new("borrowed", Span::call_site());
- let borrowed = Cow::Borrowed(&ident);
-
- let tokens = quote! { #owned #borrowed };
- assert_eq!("owned borrowed", tokens.to_string());
-}
-
-#[test]
-fn test_closure() {
- fn field_i(i: usize) -> Ident {
- format_ident!("__field{}", i)
- }
-
- let fields = (0usize..3)
- .map(field_i as fn(_) -> _)
- .map(|var| quote! { #var });
-
- let tokens = quote! { #(#fields)* };
- assert_eq!("__field0 __field1 __field2", tokens.to_string());
-}
-
-#[test]
-fn test_append_tokens() {
- let mut a = quote!(a);
- let b = quote!(b);
- a.append_all(b);
- assert_eq!("a b", a.to_string());
-}
-
-#[test]
-fn test_format_ident() {
- let id0 = format_ident!("Aa");
- let id1 = format_ident!("Hello{x}", x = id0);
- let id2 = format_ident!("Hello{x}", x = 5usize);
- let id3 = format_ident!("Hello{}_{x}", id0, x = 10usize);
- let id4 = format_ident!("Aa", span = Span::call_site());
-
- assert_eq!(id0, "Aa");
- assert_eq!(id1, "HelloAa");
- assert_eq!(id2, "Hello5");
- assert_eq!(id3, "HelloAa_10");
- assert_eq!(id4, "Aa");
-}
-
-#[test]
-fn test_format_ident_strip_raw() {
- let id = format_ident!("r#struct");
- let my_id = format_ident!("MyId{}", id);
- let raw_my_id = format_ident!("r#MyId{}", id);
-
- assert_eq!(id, "r#struct");
- assert_eq!(my_id, "MyIdstruct");
- assert_eq!(raw_my_id, "r#MyIdstruct");
-}
-
-#[test]
-fn test_outer_line_comment() {
- let tokens = quote! {
- /// doc
- };
- let expected = "# [ doc = r\" doc\" ]";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_inner_line_comment() {
- let tokens = quote! {
- //! doc
- };
- let expected = "# ! [ doc = r\" doc\" ]";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_outer_block_comment() {
- let tokens = quote! {
- /** doc */
- };
- let expected = "# [ doc = r\" doc \" ]";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_inner_block_comment() {
- let tokens = quote! {
- /*! doc */
- };
- let expected = "# ! [ doc = r\" doc \" ]";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_outer_attr() {
- let tokens = quote! {
- #[inline]
- };
- let expected = "# [ inline ]";
- assert_eq!(expected, tokens.to_string());
-}
-
-#[test]
-fn test_inner_attr() {
- let tokens = quote! {
- #![no_std]
- };
- let expected = "# ! [ no_std ]";
- assert_eq!(expected, tokens.to_string());
-}
-
-// https://github.com/dtolnay/quote/issues/130
-#[test]
-fn test_star_after_repetition() {
- let c = vec!['0', '1'];
- let tokens = quote! {
- #(
- f(#c);
- )*
- *out = None;
- };
- let expected = "f ( '0' ) ; f ( '1' ) ; * out = None ;";
- assert_eq!(expected, tokens.to_string());
-}
diff --git a/quote/tests/ui/does-not-have-iter-interpolated-dup.rs b/quote/tests/ui/does-not-have-iter-interpolated-dup.rs
deleted file mode 100644
index 0a39f41..0000000
--- a/quote/tests/ui/does-not-have-iter-interpolated-dup.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use quote::quote;
-
-fn main() {
- let nonrep = "";
-
- // Without some protection against repetitions with no iterator somewhere
- // inside, this would loop infinitely.
- quote!(#(#nonrep #nonrep)*);
-}
diff --git a/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr b/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
deleted file mode 100644
index 6ee6fdf..0000000
--- a/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/does-not-have-iter-interpolated-dup.rs:8:5
- |
-8 | quote!(#(#nonrep #nonrep)*);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
- |
- = note: expected type `quote::__rt::HasIterator`
- found type `quote::__rt::ThereIsNoIteratorInRepetition`
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/does-not-have-iter-interpolated.rs b/quote/tests/ui/does-not-have-iter-interpolated.rs
deleted file mode 100644
index 2c740cc..0000000
--- a/quote/tests/ui/does-not-have-iter-interpolated.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use quote::quote;
-
-fn main() {
- let nonrep = "";
-
- // Without some protection against repetitions with no iterator somewhere
- // inside, this would loop infinitely.
- quote!(#(#nonrep)*);
-}
diff --git a/quote/tests/ui/does-not-have-iter-interpolated.stderr b/quote/tests/ui/does-not-have-iter-interpolated.stderr
deleted file mode 100644
index 8d6c990..0000000
--- a/quote/tests/ui/does-not-have-iter-interpolated.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/does-not-have-iter-interpolated.rs:8:5
- |
-8 | quote!(#(#nonrep)*);
- | ^^^^^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
- |
- = note: expected type `quote::__rt::HasIterator`
- found type `quote::__rt::ThereIsNoIteratorInRepetition`
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/does-not-have-iter-separated.rs b/quote/tests/ui/does-not-have-iter-separated.rs
deleted file mode 100644
index c027243..0000000
--- a/quote/tests/ui/does-not-have-iter-separated.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-use quote::quote;
-
-fn main() {
- quote!(#(a b),*);
-}
diff --git a/quote/tests/ui/does-not-have-iter-separated.stderr b/quote/tests/ui/does-not-have-iter-separated.stderr
deleted file mode 100644
index c1fd0ad..0000000
--- a/quote/tests/ui/does-not-have-iter-separated.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/does-not-have-iter-separated.rs:4:5
- |
-4 | quote!(#(a b),*);
- | ^^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
- |
- = note: expected type `quote::__rt::HasIterator`
- found type `quote::__rt::ThereIsNoIteratorInRepetition`
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/does-not-have-iter.rs b/quote/tests/ui/does-not-have-iter.rs
deleted file mode 100644
index 8908353..0000000
--- a/quote/tests/ui/does-not-have-iter.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-use quote::quote;
-
-fn main() {
- quote!(#(a b)*);
-}
diff --git a/quote/tests/ui/does-not-have-iter.stderr b/quote/tests/ui/does-not-have-iter.stderr
deleted file mode 100644
index 3b87705..0000000
--- a/quote/tests/ui/does-not-have-iter.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/does-not-have-iter.rs:4:5
- |
-4 | quote!(#(a b)*);
- | ^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
- |
- = note: expected type `quote::__rt::HasIterator`
- found type `quote::__rt::ThereIsNoIteratorInRepetition`
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/not-quotable.rs b/quote/tests/ui/not-quotable.rs
deleted file mode 100644
index f991c18..0000000
--- a/quote/tests/ui/not-quotable.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-use quote::quote;
-use std::net::Ipv4Addr;
-
-fn main() {
- let ip = Ipv4Addr::LOCALHOST;
- let _ = quote! { #ip };
-}
diff --git a/quote/tests/ui/not-quotable.stderr b/quote/tests/ui/not-quotable.stderr
deleted file mode 100644
index f51f85f..0000000
--- a/quote/tests/ui/not-quotable.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error[E0277]: the trait bound `std::net::Ipv4Addr: quote::to_tokens::ToTokens` is not satisfied
- --> $DIR/not-quotable.rs:6:13
- |
-6 | let _ = quote! { #ip };
- | ^^^^^^^^^^^^^^ the trait `quote::to_tokens::ToTokens` is not implemented for `std::net::Ipv4Addr`
- |
- = note: required by `quote::to_tokens::ToTokens::to_tokens`
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/quote/tests/ui/not-repeatable.rs b/quote/tests/ui/not-repeatable.rs
deleted file mode 100644
index ff18060..0000000
--- a/quote/tests/ui/not-repeatable.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-use quote::quote;
-use std::net::Ipv4Addr;
-
-fn main() {
- let ip = Ipv4Addr::LOCALHOST;
- let _ = quote! { #(#ip)* };
-}
diff --git a/quote/tests/ui/not-repeatable.stderr b/quote/tests/ui/not-repeatable.stderr
deleted file mode 100644
index ddcac05..0000000
--- a/quote/tests/ui/not-repeatable.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0599]: no method named `quote_into_iter` found for type `std::net::Ipv4Addr` in the current scope
- --> $DIR/not-repeatable.rs:6:13
- |
-6 | let _ = quote! { #(#ip)* };
- | ^^^^^^^^^^^^^^^^^^
- |
- = note: the method `quote_into_iter` exists but the following trait bounds were not satisfied:
- `&mut std::net::Ipv4Addr : quote::__rt::ext::RepIteratorExt`
- `&std::net::Ipv4Addr : quote::__rt::ext::RepIteratorExt`
- `std::net::Ipv4Addr : quote::__rt::ext::RepIteratorExt`
- `std::net::Ipv4Addr : quote::__rt::ext::RepToTokensExt`
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/quote/tests/ui/wrong-type-span.rs b/quote/tests/ui/wrong-type-span.rs
deleted file mode 100644
index 1ce391c..0000000
--- a/quote/tests/ui/wrong-type-span.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-use quote::quote_spanned;
-
-fn main() {
- let span = "";
- let x = 0;
- quote_spanned!(span=> #x);
-}
diff --git a/quote/tests/ui/wrong-type-span.stderr b/quote/tests/ui/wrong-type-span.stderr
deleted file mode 100644
index a6ae8ef..0000000
--- a/quote/tests/ui/wrong-type-span.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/wrong-type-span.rs:6:20
- |
-6 | quote_spanned!(span=> #x);
- | ^^^^ expected struct `proc_macro2::Span`, found &str
- |
- = note: expected type `proc_macro2::Span`
- found type `&str`
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/rand/.github/ISSUE_TEMPLATE/compile-issue.md b/rand/.github/ISSUE_TEMPLATE/compile-issue.md
deleted file mode 100644
index 8a8354b..0000000
--- a/rand/.github/ISSUE_TEMPLATE/compile-issue.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-name: Compile issue
-about: Report / ask about a compilation issue
-title: ''
-labels: ''
-assignees: ''
-
----
-
-# Common issues
-
-**Problem**: `rand_hc::Hc128Rng: rand_core::SeedableRng` (or other RNG)
-
-**Quick solution**: `cargo update`
-
-**Details**: This happens when multiple versions of the `rand_core` crate are in use. Check your `Cargo.lock` file for all versions of `rand_core`. Note that some versions (0.2.2 and 0.3.1) are compatibility shims and are not a problem by themselves.
diff --git a/rand/.github/ISSUE_TEMPLATE/feature_request.md b/rand/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 90c57c8..0000000
--- a/rand/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,18 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-## Background
-
-**What is your motivation?**
-
-**What type of application is this?** (E.g. cryptography, game, numerical simulation)
-
-## Feature request
-
-<details here>
diff --git a/rand/.github/ISSUE_TEMPLATE/other.md b/rand/.github/ISSUE_TEMPLATE/other.md
deleted file mode 100644
index a3e76ca..0000000
--- a/rand/.github/ISSUE_TEMPLATE/other.md
+++ /dev/null
@@ -1,10 +0,0 @@
----
-name: Other
-about: empty template
-title: ''
-labels: ''
-assignees: ''
-
----
-
-
diff --git a/rand/.gitignore b/rand/.gitignore
deleted file mode 100644
index ac38e81..0000000
--- a/rand/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-target
-Cargo.lock
-rand_wasm_bindgen_test*.[tj]s
-rand_wasm_bindgen_test*.wasm
diff --git a/rand/.travis.yml b/rand/.travis.yml
deleted file mode 100644
index f3790dc..0000000
--- a/rand/.travis.yml
+++ /dev/null
@@ -1,315 +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.
-# Tests run on rand:
-# - test no_std support, but only the unit tests:
-# `cargo test --tests --no-default-features`
-# - test no_std support, including the alloc feature:
-# cargo test --tests --no-default-features --features=alloc
-# - 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`
-# - 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
-# NOTE: Test for alloc feature in no_std is not included here because it depends
-# on the alloc crate stabilized in Rust 1.36.
-matrix:
- include:
- - rust: 1.32.0
- env: DESCRIPTION="Linux, 1.32.0"
- os: linux
- script:
- # Differs from standard script: rand_pcg features
- - cargo test --tests --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_distr/Cargo.toml
- - 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_jitter/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
-
- - rust: 1.32.0
- env: DESCRIPTION="OSX, 1.32.0"
- os: osx
- script:
- # Differs from standard script: rand_pcg features
- - cargo test --tests --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_distr/Cargo.toml
- - 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_jitter/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
-
- - rust: stable
- env: DESCRIPTION="Linux, stable"
-
- - rust: stable
- env: DESCRIPTION="OSX+iOS, stable"
- os: osx
- install:
- - rustup target add aarch64-apple-ios
- script:
- # Differs from standard script: includes aarch64-apple-ios cross-build
- - cargo test --tests --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_distr/Cargo.toml
- - 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_jitter/Cargo.toml
- - cargo test --manifest-path rand_os/Cargo.toml
- - cargo build --target=aarch64-apple-ios
-
- - rust: beta
- env: DESCRIPTION="Linux, beta"
-
- - rust: nightly
- os: linux
- env: DESCRIPTION="Linux, nightly, docs"
- 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: all features, doc build
- - cargo test --tests --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_distr/Cargo.toml
- - 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_jitter/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
- os: osx
- env: DESCRIPTION="OSX, nightly, docs"
- install:
- - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
- - cargo deadlinks -V
- script:
- # Differs from standard script: all features, doc build
- - cargo test --tests --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_distr/Cargo.toml
- - 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_jitter/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
-
- - 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
- - cargo list | grep install-update || cargo install -f cargo-update
- - cargo install-update -i cargo-update wasm-bindgen-cli wasm-pack
- 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
- - cargo build --manifest-path tests/wasm_bindgen/Cargo.toml --target wasm32-unknown-unknown
- - wasm-bindgen --nodejs target/wasm32-unknown-unknown/debug/rand_wasm_bindgen_test.wasm --out-dir tests/wasm_bindgen/js
- - node tests/wasm_bindgen/js/index.js
- - wasm-pack test --node tests/wasm_bindgen
-
- - 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:
- # Test the top-level crate with all features:
- - 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
- - rust: nightly
- env: DESCRIPTION="no_std platform test"
- install:
- - rustup target add thumbv6m-none-eabi
- script:
- # Test the top-level crate with all features:
- - cargo build --target=thumbv6m-none-eabi --no-default-features
-
- - rust: nightly
- os: linux
- env: DESCRIPTION="Miri, nightly"
- script:
- - sh utils/ci/miri.sh
-
-before_install:
- - set -e
- - rustup self update
-
-script:
- - cargo test --tests --no-default-features
- - cargo test --tests --no-default-features --features getrandom
- - cargo test --tests --no-default-features --features=alloc
- # 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_core/Cargo.toml --no-default-features --features=alloc
- - cargo test --manifest-path rand_distr/Cargo.toml
- - 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_jitter/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 a2ae496..0000000
--- a/rand/CHANGELOG.md
+++ /dev/null
@@ -1,568 +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.
-
-## [Unreleased]
-- Fix `no_std` behaviour, appropriately enable c2-chacha's `std` feature (#844)
-- Add a `no_std` target to CI to continously evaluate `no_std` status (#844)
-- `alloc` feature in `no_std` is available since Rust 1.36 (#856)
-
-## [0.7.0] - 2019-06-28
-
-### Fixes
-- Fix incorrect pointer usages revealed by Miri testing (#780, #781)
-- Fix (tiny!) bias in `Uniform` for 8- and 16-bit ints (#809)
-
-### Crate
-- Bumped MSRV (min supported Rust version) to 1.32.0
-- Updated to Rust Edition 2018 (#823, #824)
-- Removed dependence on `rand_xorshift`, `rand_isaac`, `rand_jitter` crates (#759, #765)
-- Remove dependency on `winapi` (#724)
-- Removed all `build.rs` files (#824)
-- Removed code already deprecated in version 0.6 (#757)
-- Removed the serde1 feature (It's still available for backwards compatibility, but it does not do anything. #830)
-- Many documentation changes
-
-### rand_core
-- Updated to `rand_core` 0.5.0
-- `Error` type redesigned with new API (#800)
-- Move `from_entropy` method to `SeedableRng` and remove `FromEntropy` (#800)
-- `SeedableRng::from_rng` is now expected to be value-stable (#815)
-
-### Standard RNGs
-- OS interface moved from `rand_os` to new `getrandom` crate (#765, [getrandom](https://github.com/rust-random/getrandom))
-- Use ChaCha for `StdRng` and `ThreadRng` (#792)
-- Feature-gate `SmallRng` (#792)
-- `ThreadRng` now supports `Copy` (#758)
-- Deprecated `EntropyRng` (#765)
-- Enable fork protection of ReseedingRng without `std` (#724)
-
-### Distributions
-- Many distributions have been moved to `rand_distr` (#761)
-- `Bernoulli::new` constructor now returns a `Result` (#803)
-- `Distribution::sample_iter` adjusted for more flexibility (#758)
-- Added `distributions::weighted::alias_method::WeightedIndex` for `O(1)` sampling (#692)
-- Support sampling `NonZeroU*` types with the `Standard` distribution (#728)
-- Optimised `Binomial` distribution sampling (#735, #740, #752)
-- Optimised SIMD float sampling (#739)
-
-### Sequences
-- Make results portable across 32- and 64-bit by using `u32` samples for `usize` where possible (#809)
-
-## [0.6.5] - 2019-01-28
-### Crates
-- Update `rand_core` to 0.4 (#703)
-- Move `JitterRng` to its own crate (#685)
-- Add a wasm-bindgen test crate (#696)
-
-### Platforms
-- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng
-
-### Doc
-- Use RFC 1946 for doc links (#691)
-- Fix some doc links and notes (#711)
-
-## [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 ef344a6..0000000
--- a/rand/Cargo.toml
+++ /dev/null
@@ -1,90 +0,0 @@
-[package]
-name = "rand"
-version = "0.7.0"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT OR 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"]
-exclude = ["/utils/*", "/.travis.yml", "/appveyor.yml", ".gitignore"]
-autobenches = true
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-# Meta-features:
-default = ["std"] # without "std" rand uses libcore
-nightly = ["simd_support"] # enables all features requiring nightly rust
-serde1 = [] # does nothing, deprecated
-
-# Optional dependencies:
-std = ["rand_core/std", "rand_chacha/std", "alloc", "getrandom"]
-alloc = ["rand_core/alloc"] # enables Vec and Box support (without std)
-# re-export optional WASM dependencies to avoid breakage:
-wasm-bindgen = ["getrandom_package/wasm-bindgen"]
-stdweb = ["getrandom_package/stdweb"]
-getrandom = ["getrandom_package", "rand_core/getrandom"]
-
-# Configuration:
-simd_support = ["packed_simd"] # enables SIMD support
-small_rng = ["rand_pcg"] # enables SmallRng
-
-[workspace]
-members = [
- "rand_core",
- "rand_distr",
- "rand_jitter",
- "rand_os",
- "rand_isaac",
- "rand_chacha",
- "rand_hc",
- "rand_pcg",
- "rand_xorshift",
- "rand_xoshiro",
- "tests/wasm_bindgen",
-]
-
-[dependencies]
-rand_core = { path = "rand_core", version = "0.5" }
-rand_pcg = { path = "rand_pcg", version = "0.2", optional = true }
-# Do not depend on 'getrandom_package' directly; use the 'getrandom' feature!
-getrandom_package = { version = "0.1.1", package = "getrandom", optional = true }
-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]
-# Used for fork protection (reseeding.rs)
-libc = { version = "0.2.22", default-features = false }
-
-# Emscripten does not support 128-bit integers, which are used by ChaCha code.
-# We work around this by using a different RNG.
-[target.'cfg(not(target_os = "emscripten"))'.dependencies]
-rand_chacha = { path = "rand_chacha", version = "0.2.1", default-features = false }
-[target.'cfg(target_os = "emscripten")'.dependencies]
-rand_hc = { path = "rand_hc", version = "0.2" }
-
-[dev-dependencies]
-rand_pcg = { path = "rand_pcg", version = "0.2" }
-# Only for benches:
-rand_hc = { path = "rand_hc", version = "0.2" }
-rand_xoshiro = { path = "rand_xoshiro", version = "0.3" }
-rand_isaac = { path = "rand_isaac", version = "0.2" }
-rand_xorshift = { path = "rand_xorshift", version = "0.2" }
-
-[package.metadata.docs.rs]
-all-features = true
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 5acbadb..0000000
--- a/rand/README.md
+++ /dev/null
@@ -1,118 +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.32+-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.7"
-```
-
-To get started using Rand, see [The Book](https://rust-random.github.io/book).
-
-
-## Versions
-
-Rand libs have inter-dependencies and make use of the
-[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits
-compatible across crate versions. (This is especially important for `RngCore`
-and `SeedableRng`.) A few crate releases are thus compatibility shims,
-depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and
-`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and
-`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can
-cause build errors. Usually, running `cargo update` is enough to fix any issues.
-
-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.7 was released in June 2019, moving most non-uniform distributions
- to an external crate, moving `from_entropy` to `SeedableRng`, and many small
- changes and fixes.
-- 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.7, Rand requires **Rustc version 1.32 or greater**.
-Rand 0.5 requires Rustc 1.22 or greater while versions
-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.
-
-## Crate Features
-
-Rand is built with these features enabled by default:
-
-- `std` enables functionality dependent on the `std` lib
-- `alloc` (implied by `std`) enables functionality requiring an allocator (when using this feature in `no_std`, Rand requires Rustc version 1.36 or greater)
-- `getrandom` (implied by `std`) is an optional dependency providing the code
- behind `rngs::OsRng`
-
-Optionally, the following dependencies can be enabled:
-
-- `log` enables logging via the `log` crate
-- `stdweb` implies `getrandom/stdweb` to enable
- `getrandom` support on `wasm32-unknown-unknown`
-- `wasm-bindgen` implies `getrandom/wasm-bindgen` to enable
- `getrandom` support on `wasm32-unknown-unknown`
-
-Additionally, these features configure Rand:
-
-- `small_rng` enables inclusion of the `SmallRng` PRNG
-- `nightly` enables all experimental features
-- `simd_support` (experimental) enables sampling of SIMD values
- (uniformly random SIMD integers and floats)
-
-Rand supports limited functionality in `no_std` mode (enabled via
-`default-features = false`). In this case, `OsRng` and `from_entropy` are
-unavailable (unless `getrandom` is enabled), large parts of `seq` are
-unavailable (unless `alloc` is enabled), and `thread_rng` and `random` are
-unavailable.
-
-# 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 ef0b4bf..0000000
--- a/rand/appveyor.yml
+++ /dev/null
@@ -1,49 +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 --tests --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 --manifest-path rand_core/Cargo.toml
- - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc
- - cargo test --manifest-path rand_distr/Cargo.toml
- - 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/generators.rs b/rand/benches/generators.rs
deleted file mode 100644
index 808bb67..0000000
--- a/rand/benches/generators.rs
+++ /dev/null
@@ -1,220 +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;
-
-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, mock::StepRng};
-use rand_isaac::{IsaacRng, Isaac64Rng};
-use rand_chacha::{ChaCha20Core, ChaCha8Rng, ChaCha12Rng, ChaCha20Rng};
-use rand_hc::{Hc128Rng};
-use rand_pcg::{Pcg32, Pcg64, Pcg64Mcg};
-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_step, StepRng::new(0, 1));
-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_pcg32, Pcg32::from_entropy());
-gen_bytes!(gen_bytes_pcg64, Pcg64::from_entropy());
-gen_bytes!(gen_bytes_pcg64mcg, Pcg64Mcg::from_entropy());
-gen_bytes!(gen_bytes_chacha8, ChaCha8Rng::from_entropy());
-gen_bytes!(gen_bytes_chacha12, ChaCha12Rng::from_entropy());
-gen_bytes!(gen_bytes_chacha20, ChaCha20Rng::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());
-#[cfg(feature="small_rng")]
-gen_bytes!(gen_bytes_small, SmallRng::from_entropy());
-gen_bytes!(gen_bytes_os, OsRng);
-
-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_step, u32, StepRng::new(0, 1));
-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_pcg32, u32, Pcg32::from_entropy());
-gen_uint!(gen_u32_pcg64, u32, Pcg64::from_entropy());
-gen_uint!(gen_u32_pcg64mcg, u32, Pcg64Mcg::from_entropy());
-gen_uint!(gen_u32_chacha8, u32, ChaCha8Rng::from_entropy());
-gen_uint!(gen_u32_chacha12, u32, ChaCha12Rng::from_entropy());
-gen_uint!(gen_u32_chacha20, u32, ChaCha20Rng::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());
-#[cfg(feature="small_rng")]
-gen_uint!(gen_u32_small, u32, SmallRng::from_entropy());
-gen_uint!(gen_u32_os, u32, OsRng);
-
-gen_uint!(gen_u64_step, u64, StepRng::new(0, 1));
-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_pcg32, u64, Pcg32::from_entropy());
-gen_uint!(gen_u64_pcg64, u64, Pcg64::from_entropy());
-gen_uint!(gen_u64_pcg64mcg, u64, Pcg64Mcg::from_entropy());
-gen_uint!(gen_u64_chacha8, u64, ChaCha8Rng::from_entropy());
-gen_uint!(gen_u64_chacha12, u64, ChaCha12Rng::from_entropy());
-gen_uint!(gen_u64_chacha20, u64, ChaCha20Rng::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());
-#[cfg(feature="small_rng")]
-gen_uint!(gen_u64_small, u64, SmallRng::from_entropy());
-gen_uint!(gen_u64_os, u64, OsRng);
-
-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_pcg32, Pcg32);
-init_gen!(init_pcg64, Pcg64);
-init_gen!(init_pcg64mcg, Pcg64Mcg);
-init_gen!(init_hc128, Hc128Rng);
-init_gen!(init_isaac, IsaacRng);
-init_gen!(init_isaac64, Isaac64Rng);
-init_gen!(init_chacha, ChaCha20Rng);
-
-const RESEEDING_BYTES_LEN: usize = 1024 * 1024;
-const RESEEDING_BENCH_N: u64 = 16;
-
-macro_rules! reseeding_bytes {
- ($fnn:ident, $thresh:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = ReseedingRng::new(ChaCha20Core::from_entropy(),
- $thresh * 1024,
- OsRng);
- let mut buf = [0u8; RESEEDING_BYTES_LEN];
- b.iter(|| {
- for _ in 0..RESEEDING_BENCH_N {
- rng.fill_bytes(&mut buf);
- black_box(&buf);
- }
- });
- b.bytes = RESEEDING_BYTES_LEN as u64 * RESEEDING_BENCH_N;
- }
- }
-}
-
-reseeding_bytes!(reseeding_chacha20_4k, 4);
-reseeding_bytes!(reseeding_chacha20_16k, 16);
-reseeding_bytes!(reseeding_chacha20_32k, 32);
-reseeding_bytes!(reseeding_chacha20_64k, 64);
-reseeding_bytes!(reseeding_chacha20_256k, 256);
-reseeding_bytes!(reseeding_chacha20_1M, 1024);
-
-
-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 4098686..0000000
--- a/rand/benches/misc.rs
+++ /dev/null
@@ -1,140 +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;
-
-const RAND_BENCH_N: u64 = 1000;
-
-use test::Bencher;
-
-use rand::prelude::*;
-use rand::distributions::{Distribution, Standard, Bernoulli};
-use rand_pcg::{Pcg32, Pcg64Mcg};
-
-#[bench]
-fn misc_gen_bool_const(b: &mut Bencher) {
- let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- for _ in 0..crate::RAND_BENCH_N {
- accum ^= rng.gen_bool(0.18);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_gen_bool_var(b: &mut Bencher) {
- let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- let mut p = 0.18;
- for _ in 0..crate::RAND_BENCH_N {
- accum ^= rng.gen_bool(p);
- p += 0.0001;
- }
- accum
- })
-}
-
-#[bench]
-fn misc_gen_ratio_const(b: &mut Bencher) {
- let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- for _ in 0..crate::RAND_BENCH_N {
- accum ^= rng.gen_ratio(2, 3);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_gen_ratio_var(b: &mut Bencher) {
- let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- for i in 2..(crate::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 = Pcg32::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let d = rand::distributions::Bernoulli::new(0.18).unwrap();
- let mut accum = true;
- for _ in 0..crate::RAND_BENCH_N {
- accum ^= rng.sample(d);
- }
- accum
- })
-}
-
-#[bench]
-fn misc_bernoulli_var(b: &mut Bencher) {
- let mut rng = Pcg32::from_rng(&mut thread_rng()).unwrap();
- b.iter(|| {
- let mut accum = true;
- let mut p = 0.18;
- for _ in 0..crate::RAND_BENCH_N {
- let d = Bernoulli::new(p).unwrap();
- accum ^= rng.sample(d);
- p += 0.0001;
- }
- accum
- })
-}
-
-#[bench]
-fn gen_1k_iter_repeat(b: &mut Bencher) {
- use std::iter;
- let mut rng = Pcg64Mcg::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) {
- let mut rng = Pcg64Mcg::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 = Pcg64Mcg::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 = Pcg64Mcg::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 4c671b8..0000000
--- a/rand/benches/seq.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.
-
-#![feature(test)]
-#![allow(non_snake_case)]
-
-extern crate test;
-
-use test::Bencher;
-
-use rand::prelude::*;
-use rand::seq::*;
-use std::mem::size_of;
-
-// We force use of 32-bit RNG since seq code is optimised for use with 32-bit
-// generators on all platforms.
-use rand_pcg::Pcg32 as SmallRng;
-
-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 * crate::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 * crate::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/benches/weighted.rs b/rand/benches/weighted.rs
deleted file mode 100644
index 5ddca3f..0000000
--- a/rand/benches/weighted.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2019 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;
-
-use test::Bencher;
-use rand::Rng;
-use rand::distributions::WeightedIndex;
-
-#[bench]
-fn weighted_index_creation(b: &mut Bencher) {
- let mut rng = rand::thread_rng();
- let weights = [1u32, 2, 4, 0, 5, 1, 7, 1, 2, 3, 4, 5, 6, 7];
- b.iter(|| {
- let distr = WeightedIndex::new(weights.to_vec()).unwrap();
- rng.sample(distr)
- })
-}
-
-#[bench]
-fn weighted_index_modification(b: &mut Bencher) {
- let mut rng = rand::thread_rng();
- let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7];
- let mut distr = WeightedIndex::new(weights.to_vec()).unwrap();
- b.iter(|| {
- distr.update_weights(&[(2, &4), (5, &1)]).unwrap();
- rng.sample(&distr)
- })
-}
diff --git a/rand/examples/monte-carlo.rs b/rand/examples/monte-carlo.rs
deleted file mode 100644
index 39c779f..0000000
--- a/rand/examples/monte-carlo.rs
+++ /dev/null
@@ -1,48 +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")]
-
-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 9fe5839..0000000
--- a/rand/examples/monty-hall.rs
+++ /dev/null
@@ -1,112 +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")]
-
-use rand::distributions::{Distribution, Uniform};
-use rand::Rng;
-
-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 d242f97..0000000
--- a/rand/rand_chacha/CHANGELOG.md
+++ /dev/null
@@ -1,18 +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.2.1] - 2019-07-22
-- Force enable the `simd` feature of `c2-chacha` (#845)
-
-## [0.2.0] - 2019-06-06
-- Rewrite based on the much faster `c2-chacha` crate (#789)
-
-## [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 6a47b86..0000000
--- a/rand/rand_chacha/Cargo.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-[package]
-name = "rand_chacha"
-version = "0.2.1"
-authors = ["The Rand Project Developers", "The Rust Project Developers", "The CryptoCorrosion Contributors"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
-c2-chacha = { version = "0.2.2", default-features = false, features = ["simd"] }
-
-[features]
-default = ["std", "simd"]
-std = ["c2-chacha/std"]
-simd = [] # deprecated
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 69a0ce7..0000000
--- a/rand/rand_chacha/README.md
+++ /dev/null
@@ -1,49 +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.32+-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].
-
-The RNGs provided by this crate are implemented via the fast stream ciphers of
-the [`c2-chacha`](https://crates.io/crates/c2-chacha) crate.
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_chacha)
-- [API documentation (docs.rs)](https://docs.rs/rand_chacha)
-- [Changelog](https://github.com/rust-random/rand/blob/master/rand_chacha/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 when disabling default features; the `std`
-feature can be explicitly required to re-enable `std` support. Using `std`
-allows detection of CPU features and thus better optimisation.
-
-
-# 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/src/chacha.rs b/rand/rand_chacha/src/chacha.rs
deleted file mode 100644
index b1b89e0..0000000
--- a/rand/rand_chacha/src/chacha.rs
+++ /dev/null
@@ -1,452 +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.
-
-#[cfg(feature = "std")]
-use std as core;
-#[cfg(not(feature = "std"))]
-use core;
-
-use c2_chacha::guts::ChaCha;
-use self::core::fmt;
-use rand_core::block::{BlockRng, BlockRngCore};
-use rand_core::{CryptoRng, Error, RngCore, SeedableRng};
-
-const STREAM_PARAM_NONCE: u32 = 1;
-const STREAM_PARAM_BLOCK: u32 = 0;
-
-pub struct Array64<T>([T; 64]);
-impl<T> Default for Array64<T> where T: Default {
- fn default() -> Self {
- Self([T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
- T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default()])
- }
-}
-impl<T> AsRef<[T]> for Array64<T> {
- fn as_ref(&self) -> &[T] {
- &self.0
- }
-}
-impl<T> AsMut<[T]> for Array64<T> {
- fn as_mut(&mut self) -> &mut [T] {
- &mut self.0
- }
-}
-impl<T> Clone for Array64<T> where T: Copy + Default {
- fn clone(&self) -> Self {
- let mut new = Self::default();
- new.0.copy_from_slice(&self.0);
- new
- }
-}
-impl<T> fmt::Debug for Array64<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Array64 {{}}")
- }
-}
-
-macro_rules! chacha_impl {
- ($ChaChaXCore:ident, $ChaChaXRng:ident, $rounds:expr, $doc:expr) => {
- #[doc=$doc]
- #[derive(Clone)]
- pub struct $ChaChaXCore {
- state: ChaCha,
- }
-
- // Custom Debug implementation that does not expose the internal state
- impl fmt::Debug for $ChaChaXCore {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ChaChaXCore {{}}")
- }
- }
-
- impl BlockRngCore for $ChaChaXCore {
- type Item = u32;
- type Results = Array64<u32>;
- #[inline]
- fn generate(&mut self, r: &mut Self::Results) {
- // Fill slice of words by writing to equivalent slice of bytes, then fixing endianness.
- self.state.refill4($rounds, unsafe {
- &mut *(&mut *r as *mut Array64<u32> as *mut [u8; 256])
- });
- for x in r.as_mut() {
- *x = x.to_le();
- }
- }
- }
-
- impl SeedableRng for $ChaChaXCore {
- type Seed = [u8; 32];
- #[inline]
- fn from_seed(seed: Self::Seed) -> Self {
- $ChaChaXCore { state: ChaCha::new(&seed, &[0u8; 8]) }
- }
- }
-
- /// 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. We provide a SIMD
- /// implementation to support high throughput on a variety of common hardware platforms.
- ///
- /// 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 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 the `set_word_pos` and `set_stream` methods.
- ///
- /// 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/)
- #[derive(Clone, Debug)]
- pub struct $ChaChaXRng {
- rng: BlockRng<$ChaChaXCore>,
- }
-
- impl SeedableRng for $ChaChaXRng {
- type Seed = [u8; 32];
- #[inline]
- fn from_seed(seed: Self::Seed) -> Self {
- let core = $ChaChaXCore::from_seed(seed);
- Self {
- rng: BlockRng::new(core),
- }
- }
- }
-
- impl RngCore for $ChaChaXRng {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.rng.next_u32()
- }
- #[inline]
- fn next_u64(&mut self) -> u64 {
- self.rng.next_u64()
- }
- #[inline]
- fn fill_bytes(&mut self, bytes: &mut [u8]) {
- self.rng.fill_bytes(bytes)
- }
- #[inline]
- fn try_fill_bytes(&mut self, bytes: &mut [u8]) -> Result<(), Error> {
- self.rng.try_fill_bytes(bytes)
- }
- }
-
- impl $ChaChaXRng {
- // The buffer is a 4-block window, i.e. it is always at a block-aligned position in the
- // stream but if the stream has been seeked it may not be self-aligned.
-
- /// 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.
- #[inline]
- pub fn get_word_pos(&self) -> u128 {
- let mut block = u128::from(self.rng.core.state.get_stream_param(STREAM_PARAM_BLOCK));
- // counter is incremented *after* filling buffer
- block -= 4;
- (block << 4) + self.rng.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.
- #[inline]
- pub fn set_word_pos(&mut self, word_offset: u128) {
- let block = (word_offset >> 4) as u64;
- self.rng
- .core
- .state
- .set_stream_param(STREAM_PARAM_BLOCK, block);
- self.rng.generate_and_set((word_offset & 15) as usize);
- }
-
- /// 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.
- #[inline]
- pub fn set_stream(&mut self, stream: u64) {
- self.rng
- .core
- .state
- .set_stream_param(STREAM_PARAM_NONCE, stream);
- if self.rng.index() != 64 {
- let wp = self.get_word_pos();
- self.set_word_pos(wp);
- }
- }
- }
-
- impl CryptoRng for $ChaChaXRng {}
-
- impl From<$ChaChaXCore> for $ChaChaXRng {
- fn from(core: $ChaChaXCore) -> Self {
- $ChaChaXRng {
- rng: BlockRng::new(core),
- }
- }
- }
- }
-}
-
-chacha_impl!(ChaCha20Core, ChaCha20Rng, 10, "ChaCha with 20 rounds");
-chacha_impl!(ChaCha12Core, ChaCha12Rng, 6, "ChaCha with 12 rounds");
-chacha_impl!(ChaCha8Core, ChaCha8Rng, 4, "ChaCha with 8 rounds");
-
-#[cfg(test)]
-mod test {
- use rand_core::{RngCore, SeedableRng};
-
- type ChaChaRng = super::ChaCha20Rng;
-
- #[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]
- 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 e374bdd..0000000
--- a/rand/rand_chacha/src/lib.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.
-
-//! 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))))]
-
-#![cfg_attr(not(feature = "std"), no_std)]
-
-pub use rand_core;
-
-mod chacha;
-
-pub use crate::chacha::{ChaCha12Core, ChaCha12Rng, ChaCha20Core, ChaCha20Rng, ChaCha8Core, ChaCha8Rng};
-
-/// ChaCha with 20 rounds
-pub type ChaChaRng = ChaCha20Rng;
-/// ChaCha with 20 rounds, low-level interface
-pub type ChaChaCore = ChaCha20Core;
diff --git a/rand/rand_core/CHANGELOG.md b/rand/rand_core/CHANGELOG.md
deleted file mode 100644
index dfdd692..0000000
--- a/rand/rand_core/CHANGELOG.md
+++ /dev/null
@@ -1,58 +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.5.1] - 2019-08-28
-- `OsRng` added to `rand_core` (#863)
-- `Error::INTERNAL_START` and `Error::CUSTOM_START` constants (#864)
-- `Error::raw_os_error` method (#864)
-- `Debug` and `Display` formatting for `getrandom` error codes without `std` (#864)
-### Changed
-- `alloc` feature in `no_std` is available since Rust 1.36 (#856)
-- Added `#[inline]` to `Error` conversion methods (#864)
-
-## [0.5.0] - 2019-06-06
-### Changed
-- Enable testing with Miri and fix incorrect pointer usages (#779, #780, #781, #783, #784)
-- Rewrite `Error` type and adjust API (#800)
-- Adjust usage of `#[inline]` for `BlockRng` and `BlockRng64`
-
-## [0.4.0] - 2019-01-24
-### Changed
-- Disable the `std` feature by default (#702)
-
-## [0.3.0] - 2018-09-24
-### Added
-- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537)
-
-## [0.2.1] - 2018-06-08
-### Added
-- References to a `CryptoRng` now also implement `CryptoRng`. (#470)
-
-## [0.2.0] - 2018-05-21
-### Changed
-- Enable the `std` feature by default. (#409)
-- Remove `BlockRng{64}::inner` and `BlockRng::inner_mut`; instead making `core` public
-- Change `BlockRngCore::Results` bound to also require `AsMut<[Self::Item]>`. (#419)
-### Added
-- Add `BlockRng{64}::index` and `BlockRng{64}::generate_and_set`. (#374, #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.)
-### Added
-- `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)
-- Add `RngCore::try_fill_bytes`. (#225)
-### Changed
-- Revise the `SeedableRng` trait. (#233)
-- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288)
-
-## [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 e52af5f..0000000
--- a/rand/rand_core/Cargo.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-[package]
-name = "rand_core"
-version = "0.5.1"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-std = ["alloc", "getrandom", "getrandom/std"] # use std library; should be default but for above bug
-alloc = [] # enables Vec and Box support without std
-serde1 = ["serde"] # enables serde for BlockRng wrapper
-
-[dependencies]
-serde = { version = "1", features = ["derive"], optional = true }
-getrandom = { version = "0.1", 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 467e66f..0000000
--- a/rand/rand_core/README.md
+++ /dev/null
@@ -1,82 +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.32+-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](https://github.com/rust-random/rand/blob/master/rand_core/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`.
-
-## Versions
-
-The current version is:
-```
-rand_core = "0.5.0"
-```
-
-Rand libs have inter-dependencies and make use of the
-[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits
-compatible across crate versions. (This is especially important for `RngCore`
-and `SeedableRng`.) A few crate releases are thus compatibility shims,
-depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and
-`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and
-`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can
-cause build errors. Usually, running `cargo update` is enough to fix any issues.
-
-## 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`,
-`std::io::Read` support for types supporting `RngCore`, and
-extensions to the `Error` type's functionality.
-
-The `std` feature is *not enabled by default*. This is primarily to avoid build
-problems where one crate implicitly requires `rand_core` with `std` support and
-another crate requires `rand` *without* `std` support. However, the `rand` crate
-continues to enable `std` support by default, both for itself and `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 0ab7458..0000000
--- a/rand/rand_core/src/block.rs
+++ /dev/null
@@ -1,437 +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` (see [`rand`](https://docs.rs/rand) crate) 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`]: crate::block::BlockRngCore
-//! [`fill_bytes`]: RngCore::fill_bytes
-
-use core::convert::AsRef;
-use core::{fmt, ptr};
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-use crate::{RngCore, CryptoRng, SeedableRng, Error};
-use crate::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][crate::block] documentation 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`].
-///
-/// [`next_u32`]: RngCore::next_u32
-/// [`next_u64`]: RngCore::next_u64
-/// [`fill_bytes`]: RngCore::fill_bytes
-/// [`try_fill_bytes`]: RngCore::try_fill_bytes
-#[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.
- #[inline]
- 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.
- #[inline(always)]
- 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.
- #[inline]
- 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.
- #[inline]
- 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]
- 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]
- fn next_u64(&mut self) -> u64 {
- let read_u64 = |results: &[u32], index| {
- if cfg!(any(target_endian = "little")) {
- // requires little-endian CPU
- #[allow(clippy::cast_ptr_alignment)] // false positive
- let ptr: *const u64 = results[index..=index+1].as_ptr() as *const u64;
- unsafe { ptr::read_unaligned(ptr) }
- } 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
- }
- }
-
- #[inline]
- 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;
- }
- }
-
- #[inline(always)]
- 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;
-
- #[inline(always)]
- fn from_seed(seed: Self::Seed) -> Self {
- Self::new(R::from_seed(seed))
- }
-
- #[inline(always)]
- fn seed_from_u64(seed: u64) -> Self {
- Self::new(R::seed_from_u64(seed))
- }
-
- #[inline(always)]
- 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.
-///
-/// [`next_u32`]: RngCore::next_u32
-/// [`next_u64`]: RngCore::next_u64
-/// [`fill_bytes`]: RngCore::fill_bytes
-/// [`try_fill_bytes`]: RngCore::try_fill_bytes
-#[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.
- #[inline]
- 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.
- #[inline(always)]
- 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.
- #[inline]
- 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.
- #[inline]
- 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]
- 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]
- 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
- }
-
- #[inline]
- 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;
- }
- }
-
- #[inline(always)]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng64<R> {
- type Seed = R::Seed;
-
- #[inline(always)]
- fn from_seed(seed: Self::Seed) -> Self {
- Self::new(R::from_seed(seed))
- }
-
- #[inline(always)]
- fn seed_from_u64(seed: u64) -> Self {
- Self::new(R::seed_from_u64(seed))
- }
-
- #[inline(always)]
- 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 30b095c..0000000
--- a/rand/rand_core/src/error.rs
+++ /dev/null
@@ -1,190 +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;
-use core::num::NonZeroU32;
-
-
-/// Error type of random number generators
-///
-/// In order to be compatible with `std` and `no_std`, this type has two
-/// possible implementations: with `std` a boxed `Error` trait object is stored,
-/// while with `no_std` we merely store an error code.
-pub struct Error {
- #[cfg(feature="std")]
- inner: Box<dyn std::error::Error + Send + Sync + 'static>,
- #[cfg(not(feature="std"))]
- code: NonZeroU32,
-}
-
-impl Error {
- /// Construct from any type supporting `std::error::Error`
- ///
- /// Available only when configured with `std`.
- ///
- /// See also `From<NonZeroU32>`, which is available with and without `std`.
- #[cfg(feature="std")]
- #[inline]
- pub fn new<E>(err: E) -> Self
- where E: Into<Box<dyn std::error::Error + Send + Sync + 'static>>
- {
- Error { inner: err.into() }
- }
-
- /// Reference the inner error (`std` only)
- ///
- /// When configured with `std`, this is a trivial operation and never
- /// panics. Without `std`, this method is simply unavailable.
- #[cfg(feature="std")]
- #[inline]
- pub fn inner(&self) -> &(dyn std::error::Error + Send + Sync + 'static) {
- &*self.inner
- }
-
- /// Unwrap the inner error (`std` only)
- ///
- /// When configured with `std`, this is a trivial operation and never
- /// panics. Without `std`, this method is simply unavailable.
- #[cfg(feature="std")]
- #[inline]
- pub fn take_inner(self) -> Box<dyn std::error::Error + Send + Sync + 'static> {
- self.inner
- }
-
- /// Codes below this point represent OS Errors (i.e. positive i32 values).
- /// Codes at or above this point, but below [`Error::CUSTOM_START`] are
- /// reserved for use by the `rand` and `getrandom` crates.
- pub const INTERNAL_START: u32 = 1 << 31;
-
- /// Codes at or above this point can be used by users to define their own
- /// custom errors.
- pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30);
-
- /// Extract the raw OS error code (if this error came from the OS)
- ///
- /// This method is identical to `std::io::Error::raw_os_error()`, except
- /// that it works in `no_std` contexts. If this method returns `None`, the
- /// error value can still be formatted via the `Diplay` implementation.
- #[inline]
- pub fn raw_os_error(&self) -> Option<i32> {
- #[cfg(feature="std")] {
- if let Some(e) = self.inner.downcast_ref::<std::io::Error>() {
- return e.raw_os_error();
- }
- }
- match self.code() {
- Some(code) if u32::from(code) < Self::INTERNAL_START =>
- Some(u32::from(code) as i32),
- _ => None,
- }
- }
-
- /// Retrieve the error code, if any.
- ///
- /// If this `Error` was constructed via `From<NonZeroU32>`, then this method
- /// will return this `NonZeroU32` code (for `no_std` this is always the
- /// case). Otherwise, this method will return `None`.
- #[inline]
- pub fn code(&self) -> Option<NonZeroU32> {
- #[cfg(feature="std")] {
- self.inner.downcast_ref::<ErrorCode>().map(|c| c.0)
- }
- #[cfg(not(feature="std"))] {
- Some(self.code)
- }
- }
-}
-
-impl fmt::Debug for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- #[cfg(feature="std")] {
- write!(f, "Error {{ inner: {:?} }}", self.inner)
- }
- #[cfg(all(feature="getrandom", not(feature="std")))] {
- getrandom::Error::from(self.code).fmt(f)
- }
- #[cfg(not(feature="getrandom"))] {
- write!(f, "Error {{ code: {} }}", self.code)
- }
- }
-}
-
-impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- #[cfg(feature="std")] {
- write!(f, "{}", self.inner)
- }
- #[cfg(all(feature="getrandom", not(feature="std")))] {
- getrandom::Error::from(self.code).fmt(f)
- }
- #[cfg(not(feature="getrandom"))] {
- write!(f, "error code {}", self.code)
- }
- }
-}
-
-impl From<NonZeroU32> for Error {
- #[inline]
- fn from(code: NonZeroU32) -> Self {
- #[cfg(feature="std")] {
- Error { inner: Box::new(ErrorCode(code)) }
- }
- #[cfg(not(feature="std"))] {
- Error { code }
- }
- }
-}
-
-#[cfg(feature="getrandom")]
-impl From<getrandom::Error> for Error {
- #[inline]
- fn from(error: getrandom::Error) -> Self {
- #[cfg(feature="std")] {
- Error { inner: Box::new(error) }
- }
- #[cfg(not(feature="std"))] {
- Error { code: error.code() }
- }
- }
-}
-
-#[cfg(feature="std")]
-impl std::error::Error for Error {
- #[inline]
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- self.inner.source()
- }
-}
-
-#[cfg(feature="std")]
-impl From<Error> for std::io::Error {
- #[inline]
- fn from(error: Error) -> Self {
- if let Some(code) = error.raw_os_error() {
- std::io::Error::from_raw_os_error(code)
- } else {
- std::io::Error::new(std::io::ErrorKind::Other, error)
- }
- }
-}
-
-#[cfg(feature="std")]
-#[derive(Debug, Copy, Clone)]
-struct ErrorCode(NonZeroU32);
-
-#[cfg(feature="std")]
-impl fmt::Display for ErrorCode {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "error code {}", self.0)
- }
-}
-
-#[cfg(feature="std")]
-impl std::error::Error for ErrorCode {}
diff --git a/rand/rand_core/src/impls.rs b/rand/rand_core/src/impls.rs
deleted file mode 100644
index dee4ed1..0000000
--- a/rand/rand_core/src/impls.rs
+++ /dev/null
@@ -1,158 +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::ptr::copy_nonoverlapping;
-use core::slice;
-use core::cmp::min;
-use core::mem::size_of;
-use crate::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] = rng.next_u64().to_le_bytes();
- l.copy_from_slice(&chunk);
- }
- let n = left.len();
- if n > 4 {
- let chunk: [u8; 8] = rng.next_u64().to_le_bytes();
- left.copy_from_slice(&chunk[..n]);
- } else if n > 0 {
- let chunk: [u8; 4] = rng.next_u32().to_le_bytes();
- 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 d8e0189..0000000
--- a/rand/rand_core/src/lib.rs
+++ /dev/null
@@ -1,492 +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://docs.rs/rand
-
-#![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))))]
-
-#![allow(clippy::unreadable_literal)]
-
-#![cfg_attr(not(feature="std"), no_std)]
-
-
-use core::default::Default;
-use core::convert::AsMut;
-use core::ptr::copy_nonoverlapping;
-
-#[cfg(all(feature="alloc", not(feature="std")))] extern crate alloc;
-#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box;
-
-pub use error::Error;
-#[cfg(feature="getrandom")] pub use os::OsRng;
-
-
-mod error;
-pub mod block;
-pub mod impls;
-pub mod le;
-#[cfg(feature="getrandom")] mod os;
-
-
-/// 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 the `Rng` trait 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
-/// [`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://docs.rs/rand
-/// [`try_fill_bytes`]: RngCore::try_fill_bytes
-/// [`fill_bytes`]: RngCore::fill_bytes
-/// [`next_u32`]: RngCore::next_u32
-/// [`next_u64`]: RngCore::next_u64
-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`](impls::next_u32_via_fill).
- 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`](impls::next_u64_via_u32) or via
- /// [`fill_bytes`](impls::next_u64_via_fill).
- 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*`](impls::fill_bytes_via_next) or
- /// via [`try_fill_bytes`](RngCore::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`]: RngCore::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.
-///
-/// [`BlockRngCore`]: block::BlockRngCore
-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).
-///
-/// [`rand`]: https://docs.rs/rand
-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 roughly equal, and values like 0, 1 and (size - 1) are unlikely.
- /// Note that many non-cryptographic PRNGs will show poor quality output
- /// if this is not adhered to. If you wish to seed from simple numbers, use
- /// `seed_from_u64` instead.
- ///
- /// All PRNG implementations should be reproducible unless otherwise noted:
- /// given a fixed `seed`, the same sequence of output should be produced
- /// on all runs, library versions and architectures (e.g. check endianness).
- /// Any "value-breaking" changes to the generator should require bumping at
- /// least the minor version and documentation of the change.
- ///
- /// It is 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 may be useful when needing to rapidly seed many PRNGs from a master
- /// PRNG, and to allow forking of PRNGs. It may be considered deterministic.
- ///
- /// The master PRNG should be at least as high quality as the child PRNGs.
- /// When seeding non-cryptographic child PRNGs, we recommend using a
- /// different algorithm for the master PRNG (ideally a CSPRNG) to avoid
- /// correlations between the child PRNGs. If this is not possible (e.g.
- /// forking using small non-crypto PRNGs) ensure that your PRNG has a good
- /// mixing function on the output or consider use of a hash function with
- /// `from_seed`.
- ///
- /// Note that seeding `XorShiftRng` from another `XorShiftRng` provides an
- /// extreme example of what can go wrong: the new PRNG will be a clone
- /// of the parent.
- ///
- /// PRNG implementations are allowed to assume that a good RNG is provided
- /// for seeding, and that it is cryptographically secure when appropriate.
- /// As of `rand` 0.7 / `rand_core` 0.5, implementations overriding this
- /// method should ensure the implementation satisfies reproducibility
- /// (in prior versions this was not required).
- ///
- /// [`rand`]: https://docs.rs/rand
- /// [`rand_os`]: https://docs.rs/rand_os
- 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))
- }
-
- /// Creates a new instance of the RNG seeded via [`getrandom`].
- ///
- /// This method is the recommended way to construct non-deterministic PRNGs
- /// since it is convenient and secure.
- ///
- /// In case the overhead of using [`getrandom`] to seed *many* PRNGs is an
- /// issue, one may prefer to seed from a local PRNG, e.g.
- /// `from_rng(thread_rng()).unwrap()`.
- ///
- /// # Panics
- ///
- /// If [`getrandom`] is unable to provide secure entropy this method will panic.
- ///
- /// [`getrandom`]: https://docs.rs/getrandom
- #[cfg(feature="getrandom")]
- fn from_entropy() -> Self {
- let mut seed = Self::Seed::default();
- if let Err(err) = getrandom::getrandom(seed.as_mut()) {
- panic!("from_entropy failed: {}", err);
- }
- 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 dyn 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_core/src/os.rs b/rand/rand_core/src/os.rs
deleted file mode 100644
index fc23a57..0000000
--- a/rand/rand_core/src/os.rs
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2019 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.
-
-//! Interface to the random number generator of the operating system.
-// Note: keep this code in sync with the rand_os crate!
-
-use getrandom::getrandom;
-use crate::{CryptoRng, RngCore, Error, impls};
-
-/// A random number generator that retrieves randomness from from the
-/// operating system.
-///
-/// This is a zero-sized struct. It can be freely constructed with `OsRng`.
-///
-/// The implementation is provided by the [getrandom] crate. Refer to
-/// [getrandom] documentation for details.
-///
-/// This struct is only available when specifying the crate feature `getrandom`
-/// or `std`. When using the `rand` lib, it is also available as `rand::rngs::OsRng`.
-///
-/// # Blocking and error handling
-///
-/// It is possible that when used during early boot the first call to `OsRng`
-/// will block until the system's RNG is initialised. It is also possible
-/// (though highly unlikely) for `OsRng` to fail on some platforms, most
-/// likely due to system mis-configuration.
-///
-/// After the first successful call, it is highly unlikely that failures or
-/// significant delays will occur (although performance should be expected to
-/// be much slower than a user-space PRNG).
-///
-/// # Usage example
-/// ```
-/// use rand_core::{RngCore, OsRng};
-///
-/// let mut key = [0u8; 16];
-/// OsRng.fill_bytes(&mut key);
-/// let random_u64 = OsRng.next_u64();
-/// ```
-///
-/// [getrandom]: https://crates.io/crates/getrandom
-#[derive(Clone, Copy, Debug, Default)]
-pub struct 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]) {
- if let Err(e) = self.try_fill_bytes(dest) {
- panic!("Error: {}", e);
- }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- getrandom(dest)?;
- Ok(())
- }
-}
-
-#[test]
-fn test_os_rng() {
- let x = OsRng.next_u64();
- let y = OsRng.next_u64();
- assert!(x != 0);
- assert!(x != y);
-}
-
-#[test]
-fn test_construction() {
- let mut rng = OsRng::default();
- assert!(rng.next_u64() != 0);
-}
diff --git a/rand/rand_distr/CHANGELOG.md b/rand/rand_distr/CHANGELOG.md
deleted file mode 100644
index 376bb95..0000000
--- a/rand/rand_distr/CHANGELOG.md
+++ /dev/null
@@ -1,21 +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.2.1] - 2019-06-29
-- Update dependency to support Rand 0.7
-- Doc link fixes
-
-## [0.2.0] - 2019-06-06
-- Remove `new` constructors for zero-sized types
-- Add Pert distribution
-- Fix undefined behavior in `Poisson`
-- Make all distributions return `Result`s instead of panicking
-- Implement `f32` support for most distributions
-- Rename `UnitSphereSurface` to `UnitSphere`
-- Implement `UnitBall` and `UnitDisc`
-
-## [0.1.0] - 2019-06-06
-Initial release. This is equivalent to the code in `rand` 0.6.5.
diff --git a/rand/rand_distr/COPYRIGHT b/rand/rand_distr/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_distr/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_distr/Cargo.toml b/rand/rand_distr/Cargo.toml
deleted file mode 100644
index 315a5b0..0000000
--- a/rand/rand_distr/Cargo.toml
+++ /dev/null
@@ -1,27 +0,0 @@
-[package]
-name = "rand_distr"
-version = "0.2.1"
-authors = ["The Rand Project Developers"]
-license = "MIT OR Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://rust-random.github.io/rand/rand_distr/"
-homepage = "https://crates.io/crates/rand_distr"
-description = """
-Sampling from random number distributions
-"""
-keywords = ["random", "rng", "distribution", "probability"]
-categories = ["algorithms"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand = { path = "..", version = "0.7" }
-
-[dev-dependencies]
-rand_pcg = { version = "0.2", path = "../rand_pcg" }
-# Histogram implementation for testing uniformity
-average = "0.9.2"
diff --git a/rand/rand_distr/LICENSE-APACHE b/rand/rand_distr/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_distr/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_distr/LICENSE-MIT b/rand/rand_distr/LICENSE-MIT
deleted file mode 100644
index cf65607..0000000
--- a/rand/rand_distr/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_distr/README.md b/rand/rand_distr/README.md
deleted file mode 100644
index 68acd2f..0000000
--- a/rand/rand_distr/README.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# rand_distr
-
-[![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_distr.svg)](https://crates.io/crates/rand_distr)
-[[![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_distr)
-[![API](https://docs.rs/rand_distr/badge.svg)](https://docs.rs/rand_distr)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Implements a full suite of random number distributions sampling routines.
-
-This crate is a super-set of the [rand::distributions] module, including support
-for sampling from Beta, Binomial, Cauchy, ChiSquared, Dirichlet, exponential,
-Fisher F, Gamma, Log-normal, Normal, Pareto, Poisson, StudentT, Triangular and
-Weibull distributions, as well as sampling points from the unit circle and unit
-sphere surface.
-
-It is worth mentioning the [statrs] crate which provides similar functionality
-along with various support functions, including PDF and CDF computation. In
-contrast, this `rand_distr` crate focusses on sampling from distributions.
-
-Unlike most Rand crates, `rand_distr` does not currently support `no_std`.
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_distr)
-- [API documentation (docs.rs)](https://docs.rs/rand_distr)
-- [Changelog](CHANGELOG.md)
-- [The Rand project](https://github.com/rust-random/rand)
-
-
-[statrs]: https://github.com/boxtown/statrs
-[rand::distributions]: https://rust-random.github.io/rand/rand/distributions/index.html
-
-## License
-
-`rand_distr` 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_distr/benches/distributions.rs b/rand/rand_distr/benches/distributions.rs
deleted file mode 100644
index 63bde36..0000000
--- a/rand/rand_distr/benches/distributions.rs
+++ /dev/null
@@ -1,316 +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)]
-
-const RAND_BENCH_N: u64 = 1000;
-
-use std::mem::size_of;
-use std::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128};
-use test::Bencher;
-use std::time::Duration;
-
-use rand::prelude::*;
-use rand_distr::{*, weighted::WeightedIndex};
-
-// At this time, distributions are optimised for 64-bit platforms.
-use rand_pcg::Pcg64Mcg;
-
-macro_rules! distr_int {
- ($fnn:ident, $ty:ty, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = Pcg64Mcg::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_nz_int {
- ($fnn:ident, $tynz:ty, $ty:ty, $distr:expr) => {
- #[bench]
- fn $fnn(b: &mut Bencher) {
- let mut rng = Pcg64Mcg::from_entropy();
- let distr = $distr;
-
- b.iter(|| {
- let mut accum = 0 as $ty;
- for _ in 0..RAND_BENCH_N {
- let x: $tynz = distr.sample(&mut rng);
- accum = accum.wrapping_add(x.get());
- }
- 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 = Pcg64Mcg::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 = Pcg64Mcg::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 = Pcg64Mcg::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 = Pcg64Mcg::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_int!(distr_uniform_usize16, usize, Uniform::new(0usize, 0xb9d7));
-distr_int!(distr_uniform_usize32, usize, Uniform::new(0usize, 0x548c0f43));
-#[cfg(target_pointer_width = "64")]
-distr_int!(distr_uniform_usize64, usize, Uniform::new(0usize, 0x3a42714f2bf927a8));
-distr_int!(distr_uniform_isize, isize, Uniform::new(-1060478432isize, 1858574057));
-
-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_nz_int!(distr_standard_nz8, NonZeroU8, u8, Standard);
-distr_nz_int!(distr_standard_nz16, NonZeroU16, u16, Standard);
-distr_nz_int!(distr_standard_nz32, NonZeroU32, u32, Standard);
-distr_nz_int!(distr_standard_nz64, NonZeroU64, u64, Standard);
-distr_nz_int!(distr_standard_nz128, NonZeroU128, u128, 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).unwrap());
-distr_float!(distr_normal, f64, Normal::new(-1.23, 4.56).unwrap());
-distr_float!(distr_log_normal, f64, LogNormal::new(-1.23, 4.56).unwrap());
-distr_float!(distr_gamma_large_shape, f64, Gamma::new(10., 1.0).unwrap());
-distr_float!(distr_gamma_small_shape, f64, Gamma::new(0.1, 1.0).unwrap());
-distr_float!(distr_cauchy, f64, Cauchy::new(4.2, 6.9).unwrap());
-distr_float!(distr_triangular, f64, Triangular::new(0., 1., 0.9).unwrap());
-distr_int!(distr_binomial, u64, Binomial::new(20, 0.7).unwrap());
-distr_int!(distr_binomial_small, u64, Binomial::new(1000000, 1e-30).unwrap());
-distr_int!(distr_poisson, u64, Poisson::new(4.0).unwrap());
-distr!(distr_bernoulli, bool, Bernoulli::new(0.18).unwrap());
-distr_arr!(distr_circle, [f64; 2], UnitCircle);
-distr_arr!(distr_sphere, [f64; 3], UnitSphere);
-
-// 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());
-
-distr_int!(distr_weighted_alias_method_i8, usize, weighted::alias_method::WeightedIndex::new(vec![1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
-distr_int!(distr_weighted_alias_method_u32, usize, weighted::alias_method::WeightedIndex::new(vec![1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
-distr_int!(distr_weighted_alias_method_f64, usize, weighted::alias_method::WeightedIndex::new(vec![1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap());
-distr_int!(distr_weighted_alias_method_large_set, usize, weighted::alias_method::WeightedIndex::new((0..10000).rev().chain(1..10001).collect()).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 = Pcg64Mcg::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 = Pcg64Mcg::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 = Pcg64Mcg::from_entropy();
- let distr = Normal::new(-2.71828, 3.14159).unwrap();
- 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;
-}
-
-macro_rules! sample_binomial {
- ($name:ident, $n:expr, $p:expr) => {
- #[bench]
- fn $name(b: &mut Bencher) {
- let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
- let (n, p) = ($n, $p);
- b.iter(|| {
- let d = Binomial::new(n, p).unwrap();
- 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);
diff --git a/rand/rand_distr/src/binomial.rs b/rand/rand_distr/src/binomial.rs
deleted file mode 100644
index 0e6bf9a..0000000
--- a/rand/rand_distr/src/binomial.rs
+++ /dev/null
@@ -1,329 +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 rand::Rng;
-use crate::{Distribution, Uniform};
-
-/// 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_distr::{Binomial, Distribution};
-///
-/// let bin = Binomial::new(20, 0.3).unwrap();
-/// 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,
-}
-
-/// Error type returned from `Binomial::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `p < 0` or `nan`.
- ProbabilityTooSmall,
- /// `p > 1`.
- ProbabilityTooLarge,
-}
-
-impl Binomial {
- /// Construct a new `Binomial` with the given shape parameters `n` (number
- /// of trials) and `p` (probability of success).
- pub fn new(n: u64, p: f64) -> Result<Binomial, Error> {
- if !(p >= 0.0) {
- return Err(Error::ProbabilityTooSmall);
- }
- if !(p <= 1.0) {
- return Err(Error::ProbabilityTooLarge);
- }
- Ok(Binomial { n, p })
- }
-}
-
-/// Convert a `f64` to an `i64`, panicing on overflow.
-// In the future (Rust 1.34), this might be replaced with `TryFrom`.
-fn f64_to_i64(x: f64) -> i64 {
- assert!(x < (::std::i64::MAX as f64));
- x as i64
-}
-
-impl Distribution<u64> for Binomial {
- #[allow(clippy::many_single_char_names)] // Same names as in the reference.
- 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;
- }
-
- // The 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
- };
-
- let result;
- let q = 1. - p;
-
- // For small n * min(p, 1 - p), the BINV algorithm based on the inverse
- // transformation of the binomial distribution is efficient. Otherwise,
- // the BTPE algorithm is used.
- //
- // Voratas Kachitvichyanukul and Bruce W. Schmeiser. 1988. Binomial
- // random variate generation. Commun. ACM 31, 2 (February 1988),
- // 216-222. http://dx.doi.org/10.1145/42372.42381
-
- // Threshold for prefering the BINV algorithm. The paper suggests 10,
- // Ranlib uses 30, and GSL uses 14.
- const BINV_THRESHOLD: f64 = 10.;
-
- if (self.n as f64) * p < BINV_THRESHOLD &&
- self.n <= (::std::i32::MAX as u64) {
- // Use the BINV algorithm.
- let s = p / q;
- let a = ((self.n + 1) as f64) * s;
- let mut r = q.powi(self.n as i32);
- let mut u: f64 = rng.gen();
- let mut x = 0;
- while u > r as f64 {
- u -= r;
- x += 1;
- r *= a / (x as f64) - s;
- }
- result = x;
- } else {
- // Use the BTPE algorithm.
-
- // Threshold for using the squeeze algorithm. This can be freely
- // chosen based on performance. Ranlib and GSL use 20.
- const SQUEEZE_THRESHOLD: i64 = 20;
-
- // Step 0: Calculate constants as functions of `n` and `p`.
- let n = self.n as f64;
- let np = n * p;
- let npq = np * q;
- let f_m = np + p;
- let m = f64_to_i64(f_m);
- // radius of triangle region, since height=1 also area of region
- let p1 = (2.195 * npq.sqrt() - 4.6 * q).floor() + 0.5;
- // tip of triangle
- let x_m = (m as f64) + 0.5;
- // left edge of triangle
- let x_l = x_m - p1;
- // right edge of triangle
- let x_r = x_m + p1;
- let c = 0.134 + 20.5 / (15.3 + (m as f64));
- // p1 + area of parallelogram region
- let p2 = p1 * (1. + 2. * c);
-
- fn lambda(a: f64) -> f64 {
- a * (1. + 0.5 * a)
- }
-
- let lambda_l = lambda((f_m - x_l) / (f_m - x_l * p));
- let lambda_r = lambda((x_r - f_m) / (x_r * q));
- // p1 + area of left tail
- let p3 = p2 + c / lambda_l;
- // p1 + area of right tail
- let p4 = p3 + c / lambda_r;
-
- // return value
- let mut y: i64;
-
- let gen_u = Uniform::new(0., p4);
- let gen_v = Uniform::new(0., 1.);
-
- loop {
- // Step 1: Generate `u` for selecting the region. If region 1 is
- // selected, generate a triangularly distributed variate.
- let u = gen_u.sample(rng);
- let mut v = gen_v.sample(rng);
- if !(u > p1) {
- y = f64_to_i64(x_m - p1 * v + u);
- break;
- }
-
- if !(u > p2) {
- // Step 2: Region 2, parallelograms. Check if region 2 is
- // used. If so, generate `y`.
- let x = x_l + (u - p1) / c;
- v = v * c + 1.0 - (x - x_m).abs() / p1;
- if v > 1. {
- continue;
- } else {
- y = f64_to_i64(x);
- }
- } else if !(u > p3) {
- // Step 3: Region 3, left exponential tail.
- y = f64_to_i64(x_l + v.ln() / lambda_l);
- if y < 0 {
- continue;
- } else {
- v *= (u - p2) * lambda_l;
- }
- } else {
- // Step 4: Region 4, right exponential tail.
- y = f64_to_i64(x_r - v.ln() / lambda_r);
- if y > 0 && (y as u64) > self.n {
- continue;
- } else {
- v *= (u - p3) * lambda_r;
- }
- }
-
- // Step 5: Acceptance/rejection comparison.
-
- // Step 5.0: Test for appropriate method of evaluating f(y).
- let k = (y - m).abs();
- if !(k > SQUEEZE_THRESHOLD && (k as f64) < 0.5 * npq - 1.) {
- // Step 5.1: Evaluate f(y) via the recursive relationship. Start the
- // search from the mode.
- let s = p / q;
- let a = s * (n + 1.);
- let mut f = 1.0;
- if m < y {
- let mut i = m;
- loop {
- i += 1;
- f *= a / (i as f64) - s;
- if i == y {
- break;
- }
- }
- } else if m > y {
- let mut i = y;
- loop {
- i += 1;
- f /= a / (i as f64) - s;
- if i == m {
- break;
- }
- }
- }
- if v > f {
- continue;
- } else {
- break;
- }
- }
-
- // Step 5.2: Squeezing. Check the value of ln(v) againts upper and
- // lower bound of ln(f(y)).
- let k = k as f64;
- let rho = (k / npq) * ((k * (k / 3. + 0.625) + 1./6.) / npq + 0.5);
- let t = -0.5 * k*k / npq;
- let alpha = v.ln();
- if alpha < t - rho {
- break;
- }
- if alpha > t + rho {
- continue;
- }
-
- // Step 5.3: Final acceptance/rejection test.
- let x1 = (y + 1) as f64;
- let f1 = (m + 1) as f64;
- let z = (f64_to_i64(n) + 1 - m) as f64;
- let w = (f64_to_i64(n) - y + 1) as f64;
-
- fn stirling(a: f64) -> f64 {
- let a2 = a * a;
- (13860. - (462. - (132. - (99. - 140. / a2) / a2) / a2) / a2) / a / 166320.
- }
-
- if alpha > x_m * (f1 / x1).ln()
- + (n - (m as f64) + 0.5) * (z / w).ln()
- + ((y - m) as f64) * (w * p / (x1 * q)).ln()
- // We use the signs from the GSL implementation, which are
- // different than the ones in the reference. According to
- // the GSL authors, the new signs were verified to be
- // correct by one of the original designers of the
- // algorithm.
- + stirling(f1) + stirling(z) - stirling(x1) - stirling(w)
- {
- continue;
- }
-
- break;
- }
- assert!(y >= 0);
- result = y as u64;
- }
-
- // Invert the result for p < 0.5.
- if p != self.p {
- self.n - result
- } else {
- result
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use rand::Rng;
- use crate::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).unwrap();
-
- 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 = crate::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 = crate::test::rng(352);
- assert_eq!(rng.sample(Binomial::new(20, 0.0).unwrap()), 0);
- assert_eq!(rng.sample(Binomial::new(20, 1.0).unwrap()), 20);
- }
-
- #[test]
- #[should_panic]
- fn test_binomial_invalid_lambda_neg() {
- Binomial::new(20, -10.0).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/cauchy.rs b/rand/rand_distr/src/cauchy.rs
deleted file mode 100644
index 6b0e7c6..0000000
--- a/rand/rand_distr/src/cauchy.rs
+++ /dev/null
@@ -1,120 +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 rand::Rng;
-use crate::{Distribution, Standard};
-use crate::utils::Float;
-
-/// 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_distr::{Cauchy, Distribution};
-///
-/// let cau = Cauchy::new(2.0, 5.0).unwrap();
-/// let v = cau.sample(&mut rand::thread_rng());
-/// println!("{} is from a Cauchy(2, 5) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Cauchy<N> {
- median: N,
- scale: N,
-}
-
-/// Error type returned from `Cauchy::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `scale <= 0` or `nan`.
- ScaleTooSmall,
-}
-
-impl<N: Float> Cauchy<N>
-where Standard: Distribution<N>
-{
- /// Construct a new `Cauchy` with the given shape parameters
- /// `median` the peak location and `scale` the scale factor.
- pub fn new(median: N, scale: N) -> Result<Cauchy<N>, Error> {
- if !(scale > N::from(0.0)) {
- return Err(Error::ScaleTooSmall);
- }
- Ok(Cauchy {
- median,
- scale
- })
- }
-}
-
-impl<N: Float> Distribution<N> for Cauchy<N>
-where Standard: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- // sample from [0, 1)
- let x = Standard.sample(rng);
- // get standard cauchy random number
- // note that π/2 is not exactly representable, even if x=0.5 the result is finite
- let comp_dev = (N::pi() * x).tan();
- // shift and scale according to parameters
- self.median + self.scale * comp_dev
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::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_averages() {
- // NOTE: given that the variance and mean are undefined,
- // this test does not have any rigorous statistical meaning.
- let cauchy = Cauchy::new(10.0, 5.0).unwrap();
- let mut rng = crate::test::rng(123);
- let mut numbers: [f64; 1000] = [0.0; 1000];
- let mut sum = 0.0;
- for i in 0..1000 {
- numbers[i] = cauchy.sample(&mut rng);
- sum += numbers[i];
- }
- let median = median(&mut numbers);
- println!("Cauchy median: {}", median);
- assert!((median - 10.0).abs() < 0.4); // not 100% certain, but probable enough
- let mean = sum / 1000.0;
- println!("Cauchy mean: {}", mean);
- // for a Cauchy distribution the mean should not converge
- assert!((mean - 10.0).abs() > 0.4); // not 100% certain, but probable enough
- }
-
- #[test]
- #[should_panic]
- fn test_cauchy_invalid_scale_zero() {
- Cauchy::new(0.0, 0.0).unwrap();
- }
-
- #[test]
- #[should_panic]
- fn test_cauchy_invalid_scale_neg() {
- Cauchy::new(0.0, -10.0).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/dirichlet.rs b/rand/rand_distr/src/dirichlet.rs
deleted file mode 100644
index 71cf73c..0000000
--- a/rand/rand_distr/src/dirichlet.rs
+++ /dev/null
@@ -1,154 +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 rand::Rng;
-use crate::{Distribution, Gamma, StandardNormal, Exp1, Open01};
-use crate::utils::Float;
-
-/// 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_distr::Dirichlet;
-///
-/// let dirichlet = Dirichlet::new(vec![1.0, 2.0, 3.0]).unwrap();
-/// 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<N> {
- /// Concentration parameters (alpha)
- alpha: Vec<N>,
-}
-
-/// Error type returned from `Dirchlet::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `alpha.len() < 2`.
- AlphaTooShort,
- /// `alpha <= 0.0` or `nan`.
- AlphaTooSmall,
- /// `size < 2`.
- SizeTooSmall,
-}
-
-impl<N: Float> Dirichlet<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Construct a new `Dirichlet` with the given alpha parameter `alpha`.
- ///
- /// Requires `alpha.len() >= 2`.
- #[inline]
- pub fn new<V: Into<Vec<N>>>(alpha: V) -> Result<Dirichlet<N>, Error> {
- let a = alpha.into();
- if a.len() < 2 {
- return Err(Error::AlphaTooShort);
- }
- for &ai in &a {
- if !(ai > N::from(0.0)) {
- return Err(Error::AlphaTooSmall);
- }
- }
-
- Ok(Dirichlet { alpha: a })
- }
-
- /// Construct a new `Dirichlet` with the given shape parameter `alpha` and `size`.
- ///
- /// Requires `size >= 2`.
- #[inline]
- pub fn new_with_size(alpha: N, size: usize) -> Result<Dirichlet<N>, Error> {
- if !(alpha > N::from(0.0)) {
- return Err(Error::AlphaTooSmall);
- }
- if size < 2 {
- return Err(Error::SizeTooSmall);
- }
- Ok(Dirichlet {
- alpha: vec![alpha; size],
- })
- }
-}
-
-impl<N: Float> Distribution<Vec<N>> for Dirichlet<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec<N> {
- let n = self.alpha.len();
- let mut samples = vec![N::from(0.0); n];
- let mut sum = N::from(0.0);
-
- for (s, &a) in samples.iter_mut().zip(self.alpha.iter()) {
- let g = Gamma::new(a, N::from(1.0)).unwrap();
- *s = g.sample(rng);
- sum += *s;
- }
- let invacc = N::from(1.0) / sum;
- for s in samples.iter_mut() {
- *s *= invacc;
- }
- samples
- }
-}
-
-#[cfg(test)]
-mod test {
- use super::Dirichlet;
- use crate::Distribution;
-
- #[test]
- fn test_dirichlet() {
- let d = Dirichlet::new(vec![1.0, 2.0, 3.0]).unwrap();
- let mut rng = crate::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_size(alpha, size).unwrap();
- let mut rng = crate::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_size(0.5f64, 1).unwrap();
- }
-
- #[test]
- #[should_panic]
- fn test_dirichlet_invalid_alpha() {
- Dirichlet::new_with_size(0.0f64, 2).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/exponential.rs b/rand/rand_distr/src/exponential.rs
deleted file mode 100644
index 8322489..0000000
--- a/rand/rand_distr/src/exponential.rs
+++ /dev/null
@@ -1,145 +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 rand::Rng;
-use crate::{ziggurat_tables, Distribution};
-use crate::utils::{ziggurat, Float};
-
-/// 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_distr::Exp1;
-///
-/// let val: f64 = thread_rng().sample(Exp1);
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Exp1;
-
-impl Distribution<f32> for Exp1 {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f32 {
- // TODO: use optimal 32-bit implementation
- let x: f64 = self.sample(rng);
- x as f32
- }
-}
-
-// 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`](crate::Exp1) is an optimised implementation for `lambda = 1`.
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{Exp, Distribution};
-///
-/// let exp = Exp::new(2.0).unwrap();
-/// let v = exp.sample(&mut rand::thread_rng());
-/// println!("{} is from a Exp(2) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Exp<N> {
- /// `lambda` stored as `1/lambda`, since this is what we scale by.
- lambda_inverse: N
-}
-
-/// Error type returned from `Exp::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `lambda <= 0` or `nan`.
- LambdaTooSmall,
-}
-
-impl<N: Float> Exp<N>
-where Exp1: Distribution<N>
-{
- /// Construct a new `Exp` with the given shape parameter
- /// `lambda`.
- #[inline]
- pub fn new(lambda: N) -> Result<Exp<N>, Error> {
- if !(lambda > N::from(0.0)) {
- return Err(Error::LambdaTooSmall);
- }
- Ok(Exp { lambda_inverse: N::from(1.0) / lambda })
- }
-}
-
-impl<N: Float> Distribution<N> for Exp<N>
-where Exp1: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- rng.sample(Exp1) * self.lambda_inverse
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::Distribution;
- use super::Exp;
-
- #[test]
- fn test_exp() {
- let exp = Exp::new(10.0).unwrap();
- let mut rng = crate::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).unwrap();
- }
- #[test]
- #[should_panic]
- fn test_exp_invalid_lambda_neg() {
- Exp::new(-10.0).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/gamma.rs b/rand/rand_distr/src/gamma.rs
deleted file mode 100644
index 4018361..0000000
--- a/rand/rand_distr/src/gamma.rs
+++ /dev/null
@@ -1,485 +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 rand::Rng;
-use crate::normal::StandardNormal;
-use crate::{Distribution, Exp1, Exp, Open01};
-use crate::utils::Float;
-
-/// 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_distr::{Distribution, Gamma};
-///
-/// let gamma = Gamma::new(2.0, 5.0).unwrap();
-/// 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<N> {
- repr: GammaRepr<N>,
-}
-
-/// Error type returned from `Gamma::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `shape <= 0` or `nan`.
- ShapeTooSmall,
- /// `scale <= 0` or `nan`.
- ScaleTooSmall,
- /// `1 / scale == 0`.
- ScaleTooLarge,
-}
-
-#[derive(Clone, Copy, Debug)]
-enum GammaRepr<N> {
- Large(GammaLargeShape<N>),
- One(Exp<N>),
- Small(GammaSmallShape<N>)
-}
-
-// 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<N> {
- inv_shape: N,
- large_shape: GammaLargeShape<N>
-}
-
-/// 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<N> {
- scale: N,
- c: N,
- d: N
-}
-
-impl<N: Float> Gamma<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Construct an object representing the `Gamma(shape, scale)`
- /// distribution.
- #[inline]
- pub fn new(shape: N, scale: N) -> Result<Gamma<N>, Error> {
- if !(shape > N::from(0.0)) {
- return Err(Error::ShapeTooSmall);
- }
- if !(scale > N::from(0.0)) {
- return Err(Error::ScaleTooSmall);
- }
-
- let repr = if shape == N::from(1.0) {
- One(Exp::new(N::from(1.0) / scale).map_err(|_| Error::ScaleTooLarge)?)
- } else if shape < N::from(1.0) {
- Small(GammaSmallShape::new_raw(shape, scale))
- } else {
- Large(GammaLargeShape::new_raw(shape, scale))
- };
- Ok(Gamma { repr })
- }
-}
-
-impl<N: Float> GammaSmallShape<N>
-where StandardNormal: Distribution<N>, Open01: Distribution<N>
-{
- fn new_raw(shape: N, scale: N) -> GammaSmallShape<N> {
- GammaSmallShape {
- inv_shape: N::from(1.0) / shape,
- large_shape: GammaLargeShape::new_raw(shape + N::from(1.0), scale)
- }
- }
-}
-
-impl<N: Float> GammaLargeShape<N>
-where StandardNormal: Distribution<N>, Open01: Distribution<N>
-{
- fn new_raw(shape: N, scale: N) -> GammaLargeShape<N> {
- let d = shape - N::from(1. / 3.);
- GammaLargeShape {
- scale,
- c: N::from(1.0) / (N::from(9.) * d).sqrt(),
- d
- }
- }
-}
-
-impl<N: Float> Distribution<N> for Gamma<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- match self.repr {
- Small(ref g) => g.sample(rng),
- One(ref g) => g.sample(rng),
- Large(ref g) => g.sample(rng),
- }
- }
-}
-impl<N: Float> Distribution<N> for GammaSmallShape<N>
-where StandardNormal: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let u: N = rng.sample(Open01);
-
- self.large_shape.sample(rng) * u.powf(self.inv_shape)
- }
-}
-impl<N: Float> Distribution<N> for GammaLargeShape<N>
-where StandardNormal: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- // Marsaglia & Tsang method, 2000
- loop {
- let x: N = rng.sample(StandardNormal);
- let v_cbrt = N::from(1.0) + self.c * x;
- if v_cbrt <= N::from(0.0) { // a^3 <= 0 iff a <= 0
- continue
- }
-
- let v = v_cbrt * v_cbrt * v_cbrt;
- let u: N = rng.sample(Open01);
-
- let x_sqr = x * x;
- if u < N::from(1.0) - N::from(0.0331) * x_sqr * x_sqr ||
- u.ln() < N::from(0.5) * x_sqr + self.d * (N::from(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_distr::{ChiSquared, Distribution};
-///
-/// let chi = ChiSquared::new(11.0).unwrap();
-/// let v = chi.sample(&mut rand::thread_rng());
-/// println!("{} is from a χ²(11) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct ChiSquared<N> {
- repr: ChiSquaredRepr<N>,
-}
-
-/// Error type returned from `ChiSquared::new` and `StudentT::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum ChiSquaredError {
- /// `0.5 * k <= 0` or `nan`.
- DoFTooSmall,
-}
-
-#[derive(Clone, Copy, Debug)]
-enum ChiSquaredRepr<N> {
- // 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<N>),
-}
-
-impl<N: Float> ChiSquared<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Create a new chi-squared distribution with degrees-of-freedom
- /// `k`.
- pub fn new(k: N) -> Result<ChiSquared<N>, ChiSquaredError> {
- let repr = if k == N::from(1.0) {
- DoFExactlyOne
- } else {
- if !(N::from(0.5) * k > N::from(0.0)) {
- return Err(ChiSquaredError::DoFTooSmall);
- }
- DoFAnythingElse(Gamma::new(N::from(0.5) * k, N::from(2.0)).unwrap())
- };
- Ok(ChiSquared { repr })
- }
-}
-impl<N: Float> Distribution<N> for ChiSquared<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- match self.repr {
- DoFExactlyOne => {
- // k == 1 => N(0,1)^2
- let norm: N = 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_distr::{FisherF, Distribution};
-///
-/// let f = FisherF::new(2.0, 32.0).unwrap();
-/// let v = f.sample(&mut rand::thread_rng());
-/// println!("{} is from an F(2, 32) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct FisherF<N> {
- numer: ChiSquared<N>,
- denom: ChiSquared<N>,
- // denom_dof / numer_dof so that this can just be a straight
- // multiplication, rather than a division.
- dof_ratio: N,
-}
-
-/// Error type returned from `FisherF::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum FisherFError {
- /// `m <= 0` or `nan`.
- MTooSmall,
- /// `n <= 0` or `nan`.
- NTooSmall,
-}
-
-impl<N: Float> FisherF<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Create a new `FisherF` distribution, with the given parameter.
- pub fn new(m: N, n: N) -> Result<FisherF<N>, FisherFError> {
- if !(m > N::from(0.0)) {
- return Err(FisherFError::MTooSmall);
- }
- if !(n > N::from(0.0)) {
- return Err(FisherFError::NTooSmall);
- }
-
- Ok(FisherF {
- numer: ChiSquared::new(m).unwrap(),
- denom: ChiSquared::new(n).unwrap(),
- dof_ratio: n / m
- })
- }
-}
-impl<N: Float> Distribution<N> for FisherF<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- 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_distr::{StudentT, Distribution};
-///
-/// let t = StudentT::new(11.0).unwrap();
-/// let v = t.sample(&mut rand::thread_rng());
-/// println!("{} is from a t(11) distribution", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct StudentT<N> {
- chi: ChiSquared<N>,
- dof: N
-}
-
-impl<N: Float> StudentT<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Create a new Student t distribution with `n` degrees of
- /// freedom.
- pub fn new(n: N) -> Result<StudentT<N>, ChiSquaredError> {
- Ok(StudentT {
- chi: ChiSquared::new(n)?,
- dof: n
- })
- }
-}
-impl<N: Float> Distribution<N> for StudentT<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let norm: N = rng.sample(StandardNormal);
- norm * (self.dof / self.chi.sample(rng)).sqrt()
- }
-}
-
-/// The Beta distribution with shape parameters `alpha` and `beta`.
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{Distribution, Beta};
-///
-/// let beta = Beta::new(2.0, 5.0).unwrap();
-/// let v = beta.sample(&mut rand::thread_rng());
-/// println!("{} is from a Beta(2, 5) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Beta<N> {
- gamma_a: Gamma<N>,
- gamma_b: Gamma<N>,
-}
-
-/// Error type returned from `Beta::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum BetaError {
- /// `alpha <= 0` or `nan`.
- AlphaTooSmall,
- /// `beta <= 0` or `nan`.
- BetaTooSmall,
-}
-
-impl<N: Float> Beta<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Construct an object representing the `Beta(alpha, beta)`
- /// distribution.
- pub fn new(alpha: N, beta: N) -> Result<Beta<N>, BetaError> {
- Ok(Beta {
- gamma_a: Gamma::new(alpha, N::from(1.))
- .map_err(|_| BetaError::AlphaTooSmall)?,
- gamma_b: Gamma::new(beta, N::from(1.))
- .map_err(|_| BetaError::BetaTooSmall)?,
- })
- }
-}
-
-impl<N: Float> Distribution<N> for Beta<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let x = self.gamma_a.sample(rng);
- let y = self.gamma_b.sample(rng);
- x / (x + y)
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::Distribution;
- use super::{Beta, ChiSquared, StudentT, FisherF};
-
- #[test]
- fn test_chi_squared_one() {
- let chi = ChiSquared::new(1.0).unwrap();
- let mut rng = crate::test::rng(201);
- for _ in 0..1000 {
- chi.sample(&mut rng);
- }
- }
- #[test]
- fn test_chi_squared_small() {
- let chi = ChiSquared::new(0.5).unwrap();
- let mut rng = crate::test::rng(202);
- for _ in 0..1000 {
- chi.sample(&mut rng);
- }
- }
- #[test]
- fn test_chi_squared_large() {
- let chi = ChiSquared::new(30.0).unwrap();
- let mut rng = crate::test::rng(203);
- for _ in 0..1000 {
- chi.sample(&mut rng);
- }
- }
- #[test]
- #[should_panic]
- fn test_chi_squared_invalid_dof() {
- ChiSquared::new(-1.0).unwrap();
- }
-
- #[test]
- fn test_f() {
- let f = FisherF::new(2.0, 32.0).unwrap();
- let mut rng = crate::test::rng(204);
- for _ in 0..1000 {
- f.sample(&mut rng);
- }
- }
-
- #[test]
- fn test_t() {
- let t = StudentT::new(11.0).unwrap();
- let mut rng = crate::test::rng(205);
- for _ in 0..1000 {
- t.sample(&mut rng);
- }
- }
-
- #[test]
- fn test_beta() {
- let beta = Beta::new(1.0, 2.0).unwrap();
- let mut rng = crate::test::rng(201);
- for _ in 0..1000 {
- beta.sample(&mut rng);
- }
- }
-
- #[test]
- #[should_panic]
- fn test_beta_invalid_dof() {
- Beta::new(0., 0.).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/lib.rs b/rand/rand_distr/src/lib.rs
deleted file mode 100644
index baf65ed..0000000
--- a/rand/rand_distr/src/lib.rs
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2019 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.
-
-#![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)]
-
-#![allow(clippy::excessive_precision, clippy::float_cmp, clippy::unreadable_literal)]
-#![allow(clippy::neg_cmp_op_on_partial_ord)] // suggested fix too verbose
-
-//! Generating random samples from probability distributions.
-//!
-//! ## Re-exports
-//!
-//! This crate is a super-set of the [`rand::distributions`] module. See the
-//! [`rand::distributions`] module documentation for an overview of the core
-//! [`Distribution`] trait and implementations.
-//!
-//! The following are re-exported:
-//!
-//! - The [`Distribution`] trait and [`DistIter`] helper type
-//! - The [`Standard`], [`Alphanumeric`], [`Uniform`], [`OpenClosed01`], [`Open01`] and [`Bernoulli`] distributions
-//! - The [`weighted`] sub-module
-//!
-//! ## Distributions
-//!
-//! This crate 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
-//! - 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
-//! - [`UnitSphere`] distribution
-//! - [`UnitBall`] distribution
-//! - [`UnitCircle`] distribution
-//! - [`UnitDisc`] distribution
-
-pub use rand::distributions::{Distribution, DistIter, Standard,
- Alphanumeric, Uniform, OpenClosed01, Open01, Bernoulli, uniform, weighted};
-
-pub use self::unit_sphere::UnitSphere;
-pub use self::unit_ball::UnitBall;
-pub use self::unit_circle::UnitCircle;
-pub use self::unit_disc::UnitDisc;
-pub use self::gamma::{Gamma, Error as GammaError, ChiSquared, ChiSquaredError,
- FisherF, FisherFError, StudentT, Beta, BetaError};
-pub use self::normal::{Normal, Error as NormalError, LogNormal, StandardNormal};
-pub use self::exponential::{Exp, Error as ExpError, Exp1};
-pub use self::pareto::{Pareto, Error as ParetoError};
-pub use self::pert::{Pert, PertError};
-pub use self::poisson::{Poisson, Error as PoissonError};
-pub use self::binomial::{Binomial, Error as BinomialError};
-pub use self::cauchy::{Cauchy, Error as CauchyError};
-pub use self::dirichlet::{Dirichlet, Error as DirichletError};
-pub use self::triangular::{Triangular, TriangularError};
-pub use self::weibull::{Weibull, Error as WeibullError};
-pub use self::utils::Float;
-
-mod unit_sphere;
-mod unit_ball;
-mod unit_circle;
-mod unit_disc;
-mod gamma;
-mod normal;
-mod exponential;
-mod pareto;
-mod pert;
-mod poisson;
-mod binomial;
-mod cauchy;
-mod dirichlet;
-mod triangular;
-mod weibull;
-mod utils;
-mod ziggurat_tables;
-
-#[cfg(test)]
-mod test {
- // Notes on testing
- //
- // Testing random number distributions correctly is hard. The following
- // testing is desired:
- //
- // - Construction: test initialisation with a few valid parameter sets.
- // - Erroneous usage: test that incorrect usage generates an error.
- // - Vector: test that usage with fixed inputs (including RNG) generates a
- // fixed output sequence on all platforms.
- // - Correctness at fixed points (optional): using a specific mock RNG,
- // check that specific values are sampled (e.g. end-points and median of
- // distribution).
- // - Correctness of PDF (extra): generate a histogram of samples within a
- // certain range, and check this approximates the PDF. These tests are
- // expected to be expensive, and should be behind a feature-gate.
- //
- // TODO: Vector and correctness tests are largely absent so far.
- // NOTE: Some distributions have tests checking only that samples can be
- // generated. This is redundant with vector and correctness tests.
-
- /// Construct a deterministic RNG with the given seed
- pub fn rng(seed: u64) -> impl rand::RngCore {
- // For tests, we want a statistically good, fast, reproducible RNG.
- // PCG32 will do fine, and will be easy to embed if we ever need to.
- const INC: u64 = 11634580027462260723;
- rand_pcg::Pcg32::new(seed, INC)
- }
-}
diff --git a/rand/rand_distr/src/normal.rs b/rand/rand_distr/src/normal.rs
deleted file mode 100644
index 882754f..0000000
--- a/rand/rand_distr/src/normal.rs
+++ /dev/null
@@ -1,219 +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 rand::Rng;
-use crate::{ziggurat_tables, Distribution, Open01};
-use crate::utils::{ziggurat, Float};
-
-/// 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_distr::StandardNormal;
-///
-/// let val: f64 = thread_rng().sample(StandardNormal);
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct StandardNormal;
-
-impl Distribution<f32> for StandardNormal {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f32 {
- // TODO: use optimal 32-bit implementation
- let x: f64 = self.sample(rng);
- x as f32
- }
-}
-
-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_distr::{Normal, Distribution};
-///
-/// // mean 2, standard deviation 3
-/// let normal = Normal::new(2.0, 3.0).unwrap();
-/// let v = normal.sample(&mut rand::thread_rng());
-/// println!("{} is from a N(2, 9) distribution", v)
-/// ```
-///
-/// [`StandardNormal`]: crate::StandardNormal
-#[derive(Clone, Copy, Debug)]
-pub struct Normal<N> {
- mean: N,
- std_dev: N,
-}
-
-/// Error type returned from `Normal::new` and `LogNormal::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `std_dev < 0` or `nan`.
- StdDevTooSmall,
-}
-
-impl<N: Float> Normal<N>
-where StandardNormal: Distribution<N>
-{
- /// Construct a new `Normal` distribution with the given mean and
- /// standard deviation.
- #[inline]
- pub fn new(mean: N, std_dev: N) -> Result<Normal<N>, Error> {
- if !(std_dev >= N::from(0.0)) {
- return Err(Error::StdDevTooSmall);
- }
- Ok(Normal {
- mean,
- std_dev
- })
- }
-}
-
-impl<N: Float> Distribution<N> for Normal<N>
-where StandardNormal: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let n: 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_distr::{LogNormal, Distribution};
-///
-/// // mean 2, standard deviation 3
-/// let log_normal = LogNormal::new(2.0, 3.0).unwrap();
-/// 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<N> {
- norm: Normal<N>
-}
-
-impl<N: Float> LogNormal<N>
-where StandardNormal: Distribution<N>
-{
- /// Construct a new `LogNormal` distribution with the given mean
- /// and standard deviation of the logarithm of the distribution.
- #[inline]
- pub fn new(mean: N, std_dev: N) -> Result<LogNormal<N>, Error> {
- if !(std_dev >= N::from(0.0)) {
- return Err(Error::StdDevTooSmall);
- }
- Ok(LogNormal { norm: Normal::new(mean, std_dev).unwrap() })
- }
-}
-
-impl<N: Float> Distribution<N> for LogNormal<N>
-where StandardNormal: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- self.norm.sample(rng).exp()
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::Distribution;
- use super::{Normal, LogNormal};
-
- #[test]
- fn test_normal() {
- let norm = Normal::new(10.0, 10.0).unwrap();
- let mut rng = crate::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).unwrap();
- }
-
-
- #[test]
- fn test_log_normal() {
- let lnorm = LogNormal::new(10.0, 10.0).unwrap();
- let mut rng = crate::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).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/pareto.rs b/rand/rand_distr/src/pareto.rs
deleted file mode 100644
index 33ea382..0000000
--- a/rand/rand_distr/src/pareto.rs
+++ /dev/null
@@ -1,89 +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 rand::Rng;
-use crate::{Distribution, OpenClosed01};
-use crate::utils::Float;
-
-/// Samples floating-point numbers according to the Pareto distribution
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand_distr::Pareto;
-///
-/// let val: f64 = thread_rng().sample(Pareto::new(1., 2.).unwrap());
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Pareto<N> {
- scale: N,
- inv_neg_shape: N,
-}
-
-/// Error type returned from `Pareto::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `scale <= 0` or `nan`.
- ScaleTooSmall,
- /// `shape <= 0` or `nan`.
- ShapeTooSmall,
-}
-
-impl<N: Float> Pareto<N>
-where OpenClosed01: Distribution<N>
-{
- /// 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 α.
- pub fn new(scale: N, shape: N) -> Result<Pareto<N>, Error> {
- if !(scale > N::from(0.0)) {
- return Err(Error::ScaleTooSmall);
- }
- if !(shape > N::from(0.0)) {
- return Err(Error::ShapeTooSmall);
- }
- Ok(Pareto { scale, inv_neg_shape: N::from(-1.0) / shape })
- }
-}
-
-impl<N: Float> Distribution<N> for Pareto<N>
-where OpenClosed01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let u: N = OpenClosed01.sample(rng);
- self.scale * u.powf(self.inv_neg_shape)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::Distribution;
- use super::Pareto;
-
- #[test]
- #[should_panic]
- fn invalid() {
- Pareto::new(0., 0.).unwrap();
- }
-
- #[test]
- fn sample() {
- let scale = 1.0;
- let shape = 2.0;
- let d = Pareto::new(scale, shape).unwrap();
- let mut rng = crate::test::rng(1);
- for _ in 0..1000 {
- let r = d.sample(&mut rng);
- assert!(r >= scale);
- }
- }
-}
diff --git a/rand/rand_distr/src/pert.rs b/rand/rand_distr/src/pert.rs
deleted file mode 100644
index 040cd05..0000000
--- a/rand/rand_distr/src/pert.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.
-//! The PERT distribution.
-
-use rand::Rng;
-use crate::{Distribution, Beta, StandardNormal, Exp1, Open01};
-use crate::utils::Float;
-
-/// The PERT distribution.
-///
-/// Similar to the [`Triangular`] distribution, the PERT distribution is
-/// parameterised by a range and a mode within that range. Unlike the
-/// [`Triangular`] distribution, the probability density function of the PERT
-/// distribution is smooth, with a configurable weighting around the mode.
-///
-/// # Example
-///
-/// ```rust
-/// use rand_distr::{Pert, Distribution};
-///
-/// let d = Pert::new(0., 5., 2.5).unwrap();
-/// let v = d.sample(&mut rand::thread_rng());
-/// println!("{} is from a PERT distribution", v);
-/// ```
-///
-/// [`Triangular`]: crate::Triangular
-#[derive(Clone, Copy, Debug)]
-pub struct Pert<N> {
- min: N,
- range: N,
- beta: Beta<N>,
-}
-
-/// Error type returned from [`Pert`] constructors.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum PertError {
- /// `max < min` or `min` or `max` is NaN.
- RangeTooSmall,
- /// `mode < min` or `mode > max` or `mode` is NaN.
- ModeRange,
- /// `shape < 0` or `shape` is NaN
- ShapeTooSmall,
-}
-
-impl<N: Float> Pert<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- /// Set up the PERT distribution with defined `min`, `max` and `mode`.
- ///
- /// This is equivalent to calling `Pert::new_shape` with `shape == 4.0`.
- #[inline]
- pub fn new(min: N, max: N, mode: N) -> Result<Pert<N>, PertError> {
- Pert::new_with_shape(min, max, mode, N::from(4.))
- }
-
- /// Set up the PERT distribution with defined `min`, `max`, `mode` and
- /// `shape`.
- pub fn new_with_shape(min: N, max: N, mode: N, shape: N) -> Result<Pert<N>, PertError> {
- if !(max > min) {
- return Err(PertError::RangeTooSmall);
- }
- if !(mode >= min && max >= mode) {
- return Err(PertError::ModeRange);
- }
- if !(shape >= N::from(0.)) {
- return Err(PertError::ShapeTooSmall);
- }
-
- let range = max - min;
- let mu = (min + max + shape * mode) / (shape + N::from(2.));
- let v = if mu == mode {
- shape * N::from(0.5) + N::from(1.)
- } else {
- (mu - min) * (N::from(2.) * mode - min - max)
- / ((mode - mu) * (max - min))
- };
- let w = v * (max - mu) / (mu - min);
- let beta = Beta::new(v, w).map_err(|_| PertError::RangeTooSmall)?;
- Ok(Pert{ min, range, beta })
- }
-}
-
-impl<N: Float> Distribution<N> for Pert<N>
-where StandardNormal: Distribution<N>, Exp1: Distribution<N>, Open01: Distribution<N>
-{
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- self.beta.sample(rng) * self.range + self.min
- }
-}
-
-#[cfg(test)]
-mod test {
- use std::f64;
- use super::*;
-
- #[test]
- fn test_pert() {
- for &(min, max, mode) in &[
- (-1., 1., 0.),
- (1., 2., 1.),
- (5., 25., 25.),
- ] {
- let _distr = Pert::new(min, max, mode).unwrap();
- // TODO: test correctness
- }
-
- for &(min, max, mode) in &[
- (-1., 1., 2.),
- (-1., 1., -2.),
- (2., 1., 1.),
- ] {
- assert!(Pert::new(min, max, mode).is_err());
- }
- }
-
- #[test]
- fn value_stability() {
- let rng = crate::test::rng(860);
- let distr = Pert::new(2., 10., 3.).unwrap(); // mean = 4, var = 12/7
- let seq = distr.sample_iter(rng).take(5).collect::<Vec<f64>>();
- println!("seq: {:?}", seq);
- let expected = vec![4.631484136029422, 3.307201472321789,
- 3.29995019556348, 3.66835483991721, 3.514246139933899];
- assert!(seq == expected);
- }
-}
diff --git a/rand/rand_distr/src/poisson.rs b/rand/rand_distr/src/poisson.rs
deleted file mode 100644
index 4f4a0b7..0000000
--- a/rand/rand_distr/src/poisson.rs
+++ /dev/null
@@ -1,233 +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 rand::Rng;
-use crate::{Distribution, Cauchy, Standard};
-use crate::utils::Float;
-
-/// The Poisson distribution `Poisson(lambda)`.
-///
-/// This distribution has a density function:
-/// `f(k) = lambda^k * exp(-lambda) / k!` for `k >= 0`.
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{Poisson, Distribution};
-///
-/// let poi = Poisson::new(2.0).unwrap();
-/// let v: u64 = poi.sample(&mut rand::thread_rng());
-/// println!("{} is from a Poisson(2) distribution", v);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Poisson<N> {
- lambda: N,
- // precalculated values
- exp_lambda: N,
- log_lambda: N,
- sqrt_2lambda: N,
- magic_val: N,
-}
-
-/// Error type returned from `Poisson::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `lambda <= 0` or `nan`.
- ShapeTooSmall,
-}
-
-impl<N: Float> Poisson<N>
-where Standard: Distribution<N>
-{
- /// Construct a new `Poisson` with the given shape parameter
- /// `lambda`.
- pub fn new(lambda: N) -> Result<Poisson<N>, Error> {
- if !(lambda > N::from(0.0)) {
- return Err(Error::ShapeTooSmall);
- }
- let log_lambda = lambda.ln();
- Ok(Poisson {
- lambda,
- exp_lambda: (-lambda).exp(),
- log_lambda,
- sqrt_2lambda: (N::from(2.0) * lambda).sqrt(),
- magic_val: lambda * log_lambda - (N::from(1.0) + lambda).log_gamma(),
- })
- }
-}
-
-impl<N: Float> Distribution<N> for Poisson<N>
-where Standard: Distribution<N>
-{
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- // using the algorithm from Numerical Recipes in C
-
- // for low expected values use the Knuth method
- if self.lambda < N::from(12.0) {
- let mut result = N::from(0.);
- let mut p = N::from(1.0);
- while p > self.exp_lambda {
- p *= rng.gen::<N>();
- result += N::from(1.);
- }
- result - N::from(1.)
- }
- // high expected values - rejection method
- else {
- // we use the Cauchy distribution as the comparison distribution
- // f(x) ~ 1/(1+x^2)
- let cauchy = Cauchy::new(N::from(0.0), N::from(1.0)).unwrap();
- let mut result;
-
- loop {
- 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 >= N::from(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();
-
- // 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 = N::from(0.9) * (N::from(1.0) + comp_dev * comp_dev)
- * (result * self.log_lambda - (N::from(1.0) + result).log_gamma() - self.magic_val).exp();
-
- // check with uniform random value - if below the threshold, we are within the target distribution
- if rng.gen::<N>() <= check {
- break;
- }
- }
- result
- }
- }
-}
-
-impl<N: Float> Distribution<u64> for Poisson<N>
-where Standard: Distribution<N>
-{
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64 {
- let result: N = self.sample(rng);
- result.to_u64().unwrap()
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::Distribution;
- use super::Poisson;
-
- #[test]
- fn test_poisson_10() {
- let poisson = Poisson::new(10.0).unwrap();
- let mut rng = crate::test::rng(123);
- let mut sum_u64 = 0;
- let mut sum_f64 = 0.;
- for _ in 0..1000 {
- let s_u64: u64 = poisson.sample(&mut rng);
- let s_f64: f64 = poisson.sample(&mut rng);
- sum_u64 += s_u64;
- sum_f64 += s_f64;
- }
- let avg_u64 = (sum_u64 as f64) / 1000.0;
- let avg_f64 = sum_f64 / 1000.0;
- println!("Poisson averages: {} (u64) {} (f64)", avg_u64, avg_f64);
- for &avg in &[avg_u64, avg_f64] {
- 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).unwrap();
- let mut rng = crate::test::rng(123);
- let mut sum_u64 = 0;
- let mut sum_f64 = 0.;
- for _ in 0..1000 {
- let s_u64: u64 = poisson.sample(&mut rng);
- let s_f64: f64 = poisson.sample(&mut rng);
- sum_u64 += s_u64;
- sum_f64 += s_f64;
- }
- let avg_u64 = (sum_u64 as f64) / 1000.0;
- let avg_f64 = sum_f64 / 1000.0;
- println!("Poisson average: {} (u64) {} (f64)", avg_u64, avg_f64);
- for &avg in &[avg_u64, avg_f64] {
- assert!((avg - 15.0).abs() < 0.5); // not 100% certain, but probable enough
- }
- }
-
- #[test]
- fn test_poisson_10_f32() {
- let poisson = Poisson::new(10.0f32).unwrap();
- let mut rng = crate::test::rng(123);
- let mut sum_u64 = 0;
- let mut sum_f32 = 0.;
- for _ in 0..1000 {
- let s_u64: u64 = poisson.sample(&mut rng);
- let s_f32: f32 = poisson.sample(&mut rng);
- sum_u64 += s_u64;
- sum_f32 += s_f32;
- }
- let avg_u64 = (sum_u64 as f32) / 1000.0;
- let avg_f32 = sum_f32 / 1000.0;
- println!("Poisson averages: {} (u64) {} (f32)", avg_u64, avg_f32);
- for &avg in &[avg_u64, avg_f32] {
- assert!((avg - 10.0).abs() < 0.5); // not 100% certain, but probable enough
- }
- }
-
- #[test]
- fn test_poisson_15_f32() {
- // Take the 'high expected values' path
- let poisson = Poisson::new(15.0f32).unwrap();
- let mut rng = crate::test::rng(123);
- let mut sum_u64 = 0;
- let mut sum_f32 = 0.;
- for _ in 0..1000 {
- let s_u64: u64 = poisson.sample(&mut rng);
- let s_f32: f32 = poisson.sample(&mut rng);
- sum_u64 += s_u64;
- sum_f32 += s_f32;
- }
- let avg_u64 = (sum_u64 as f32) / 1000.0;
- let avg_f32 = sum_f32 / 1000.0;
- println!("Poisson average: {} (u64) {} (f32)", avg_u64, avg_f32);
- for &avg in &[avg_u64, avg_f32] {
- 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).unwrap();
- }
-
- #[test]
- #[should_panic]
- fn test_poisson_invalid_lambda_neg() {
- Poisson::new(-10.0).unwrap();
- }
-}
diff --git a/rand/rand_distr/src/triangular.rs b/rand/rand_distr/src/triangular.rs
deleted file mode 100644
index dd0bbfb..0000000
--- a/rand/rand_distr/src/triangular.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.
-//! The triangular distribution.
-
-use rand::Rng;
-use crate::{Distribution, Standard};
-use crate::utils::Float;
-
-/// The triangular distribution.
-///
-/// A continuous probability distribution parameterised by a range, and a mode
-/// (most likely value) within that range.
-///
-/// The probability density function is triangular. For a similar distribution
-/// with a smooth PDF, see the [`Pert`] distribution.
-///
-/// # Example
-///
-/// ```rust
-/// use rand_distr::{Triangular, Distribution};
-///
-/// let d = Triangular::new(0., 5., 2.5).unwrap();
-/// let v = d.sample(&mut rand::thread_rng());
-/// println!("{} is from a triangular distribution", v);
-/// ```
-///
-/// [`Pert`]: crate::Pert
-#[derive(Clone, Copy, Debug)]
-pub struct Triangular<N> {
- min: N,
- max: N,
- mode: N,
-}
-
-/// Error type returned from [`Triangular::new`].
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum TriangularError {
- /// `max < min` or `min` or `max` is NaN.
- RangeTooSmall,
- /// `mode < min` or `mode > max` or `mode` is NaN.
- ModeRange,
-}
-
-impl<N: Float> Triangular<N>
-where Standard: Distribution<N>
-{
- /// Set up the Triangular distribution with defined `min`, `max` and `mode`.
- #[inline]
- pub fn new(min: N, max: N, mode: N) -> Result<Triangular<N>, TriangularError> {
- if !(max >= min) {
- return Err(TriangularError::RangeTooSmall);
- }
- if !(mode >= min && max >= mode) {
- return Err(TriangularError::ModeRange);
- }
- Ok(Triangular { min, max, mode })
- }
-}
-
-impl<N: Float> Distribution<N> for Triangular<N>
-where Standard: Distribution<N>
-{
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let f: N = rng.sample(Standard);
- let diff_mode_min = self.mode - self.min;
- let range = self.max - self.min;
- let f_range = f * range;
- if f_range < diff_mode_min {
- self.min + (f_range * diff_mode_min).sqrt()
- } else {
- self.max - ((range - f_range) * (self.max - self.mode)).sqrt()
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use std::f64;
- use rand::{Rng, rngs::mock};
- use super::*;
-
- #[test]
- fn test_triangular() {
- let mut half_rng = mock::StepRng::new(0x8000_0000_0000_0000, 0);
- assert_eq!(half_rng.gen::<f64>(), 0.5);
- for &(min, max, mode, median) in &[
- (-1., 1., 0., 0.),
- (1., 2., 1., 2. - 0.5f64.sqrt()),
- (5., 25., 25., 5. + 200f64.sqrt()),
- (1e-5, 1e5, 1e-3, 1e5 - 4999999949.5f64.sqrt()),
- (0., 1., 0.9, 0.45f64.sqrt()),
- (-4., -0.5, -2., -4.0 + 3.5f64.sqrt()),
- ] {
- println!("{} {} {} {}", min, max, mode, median);
- let distr = Triangular::new(min, max, mode).unwrap();
- // Test correct value at median:
- assert_eq!(distr.sample(&mut half_rng), median);
- }
-
- for &(min, max, mode) in &[
- (-1., 1., 2.),
- (-1., 1., -2.),
- (2., 1., 1.),
- ] {
- assert!(Triangular::new(min, max, mode).is_err());
- }
- }
-
- #[test]
- fn value_stability() {
- let rng = crate::test::rng(860);
- let distr = Triangular::new(2., 10., 3.).unwrap();
- let seq = distr.sample_iter(rng).take(5).collect::<Vec<f64>>();
- println!("seq: {:?}", seq);
- let expected = vec![5.74373257511361, 7.890059162791258,
- 4.7256280652553455, 2.9474808121184077, 3.058301946314053];
- assert!(seq == expected);
- }
-}
diff --git a/rand/rand_distr/src/unit_ball.rs b/rand/rand_distr/src/unit_ball.rs
deleted file mode 100644
index 9d61627..0000000
--- a/rand/rand_distr/src/unit_ball.rs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2019 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::Rng;
-use crate::{Distribution, Uniform, uniform::SampleUniform};
-use crate::utils::Float;
-
-/// Samples uniformly from the unit ball (surface and interior) in three
-/// dimensions.
-///
-/// Implemented via rejection sampling.
-///
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{UnitBall, Distribution};
-///
-/// let v: [f64; 3] = UnitBall.sample(&mut rand::thread_rng());
-/// println!("{:?} is from the unit ball.", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct UnitBall;
-
-impl<N: Float + SampleUniform> Distribution<[N; 3]> for UnitBall {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [N; 3] {
- let uniform = Uniform::new(N::from(-1.), N::from(1.));
- let mut x1;
- let mut x2;
- let mut x3;
- loop {
- x1 = uniform.sample(rng);
- x2 = uniform.sample(rng);
- x3 = uniform.sample(rng);
- if x1*x1 + x2*x2 + x3*x3 <= N::from(1.) {
- break;
- }
- }
- [x1, x2, x3]
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::Distribution;
- use super::UnitBall;
-
- #[test]
- fn value_stability() {
- let mut rng = crate::test::rng(2);
- let expected = [
- [0.018035709265959987, -0.4348771383120438, -0.07982762085055706],
- [0.10588569388223945, -0.4734350111375454, -0.7392104908825501],
- [0.11060237642041049, -0.16065642822852677, -0.8444043930440075]
- ];
- let samples: [[f64; 3]; 3] = [
- UnitBall.sample(&mut rng),
- UnitBall.sample(&mut rng),
- UnitBall.sample(&mut rng),
- ];
- assert_eq!(samples, expected);
- }
-}
diff --git a/rand/rand_distr/src/unit_circle.rs b/rand/rand_distr/src/unit_circle.rs
deleted file mode 100644
index 5863a1a..0000000
--- a/rand/rand_distr/src/unit_circle.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 rand::Rng;
-use crate::{Distribution, Uniform, uniform::SampleUniform};
-use crate::utils::Float;
-
-/// Samples uniformly from the edge of the unit circle in two dimensions.
-///
-/// Implemented via a method by von Neumann[^1].
-///
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{UnitCircle, Distribution};
-///
-/// let v: [f64; 2] = UnitCircle.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<N: Float + SampleUniform> Distribution<[N; 2]> for UnitCircle {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [N; 2] {
- let uniform = Uniform::new(N::from(-1.), N::from(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 < N::from(1.) {
- break;
- }
- }
- let diff = x1*x1 - x2*x2;
- [diff / sum, N::from(2.)*x1*x2 / sum]
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::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 = crate::test::rng(1);
- for _ in 0..1000 {
- let x: [f64; 2] = UnitCircle.sample(&mut rng);
- assert_almost_eq!(x[0]*x[0] + x[1]*x[1], 1., 1e-15);
- }
- }
-
- #[test]
- fn value_stability() {
- let mut rng = crate::test::rng(2);
- let expected = [
- [-0.9965658683520504, -0.08280380447614634],
- [-0.9790853270389644, -0.20345004884984505],
- [-0.8449189758898707, 0.5348943112253227],
- ];
- let samples: [[f64; 2]; 3] = [
- UnitCircle.sample(&mut rng),
- UnitCircle.sample(&mut rng),
- UnitCircle.sample(&mut rng),
- ];
- assert_eq!(samples, expected);
- }
-}
diff --git a/rand/rand_distr/src/unit_disc.rs b/rand/rand_distr/src/unit_disc.rs
deleted file mode 100644
index 97abc2f..0000000
--- a/rand/rand_distr/src/unit_disc.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2019 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::Rng;
-use crate::{Distribution, Uniform, uniform::SampleUniform};
-use crate::utils::Float;
-
-/// Samples uniformly from the unit disc in two dimensions.
-///
-/// Implemented via rejection sampling.
-///
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{UnitDisc, Distribution};
-///
-/// let v: [f64; 2] = UnitDisc.sample(&mut rand::thread_rng());
-/// println!("{:?} is from the unit Disc.", v)
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct UnitDisc;
-
-impl<N: Float + SampleUniform> Distribution<[N; 2]> for UnitDisc {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [N; 2] {
- let uniform = Uniform::new(N::from(-1.), N::from(1.));
- let mut x1;
- let mut x2;
- loop {
- x1 = uniform.sample(rng);
- x2 = uniform.sample(rng);
- if x1*x1 + x2*x2 <= N::from(1.) {
- break;
- }
- }
- [x1, x2]
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::Distribution;
- use super::UnitDisc;
-
- #[test]
- fn value_stability() {
- let mut rng = crate::test::rng(2);
- let expected = [
- [0.018035709265959987, -0.4348771383120438],
- [-0.07982762085055706, 0.7765329819820659],
- [0.21450745997299503, 0.7398636984333291]
- ];
- let samples: [[f64; 2]; 3] = [
- UnitDisc.sample(&mut rng),
- UnitDisc.sample(&mut rng),
- UnitDisc.sample(&mut rng),
- ];
- assert_eq!(samples, expected);
- }
-}
diff --git a/rand/rand_distr/src/unit_sphere.rs b/rand/rand_distr/src/unit_sphere.rs
deleted file mode 100644
index 8e0c361..0000000
--- a/rand/rand_distr/src/unit_sphere.rs
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2018-2019 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::Rng;
-use crate::{Distribution, Uniform, uniform::SampleUniform};
-use crate::utils::Float;
-
-/// Samples uniformly from the surface of the unit sphere in three dimensions.
-///
-/// Implemented via a method by Marsaglia[^1].
-///
-///
-/// # Example
-///
-/// ```
-/// use rand_distr::{UnitSphere, Distribution};
-///
-/// let v: [f64; 3] = UnitSphere.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 UnitSphere;
-
-impl<N: Float + SampleUniform> Distribution<[N; 3]> for UnitSphere {
- #[inline]
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [N; 3] {
- let uniform = Uniform::new(N::from(-1.), N::from(1.));
- loop {
- let (x1, x2) = (uniform.sample(rng), uniform.sample(rng));
- let sum = x1*x1 + x2*x2;
- if sum >= N::from(1.) {
- continue;
- }
- let factor = N::from(2.) * (N::from(1.0) - sum).sqrt();
- return [x1 * factor, x2 * factor, N::from(1.) - N::from(2.)*sum];
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::Distribution;
- use super::UnitSphere;
-
- /// 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 = crate::test::rng(1);
- for _ in 0..1000 {
- let x: [f64; 3] = UnitSphere.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 = crate::test::rng(2);
- let expected = [
- [0.03247542860231647, -0.7830477442152738, 0.6211131755296027],
- [-0.09978440840914075, 0.9706650829833128, -0.21875184231323952],
- [0.2735582468624679, 0.9435374242279655, -0.1868234852870203],
- ];
- let samples: [[f64; 3]; 3] = [
- UnitSphere.sample(&mut rng),
- UnitSphere.sample(&mut rng),
- UnitSphere.sample(&mut rng),
- ];
- assert_eq!(samples, expected);
- }
-}
diff --git a/rand/rand_distr/src/utils.rs b/rand/rand_distr/src/utils.rs
deleted file mode 100644
index 75b3500..0000000
--- a/rand/rand_distr/src/utils.rs
+++ /dev/null
@@ -1,234 +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
-
-use rand::Rng;
-use crate::ziggurat_tables;
-use rand::distributions::hidden_export::IntoFloat;
-use core::{cmp, ops};
-
-/// Trait for floating-point scalar types
-///
-/// This allows many distributions to work with `f32` or `f64` parameters and is
-/// potentially extensible. Note however that the `Exp1` and `StandardNormal`
-/// distributions are implemented exclusively for `f32` and `f64`.
-///
-/// The bounds and methods are based purely on internal
-/// requirements, and will change as needed.
-pub trait Float: Copy + Sized + cmp::PartialOrd
- + ops::Neg<Output = Self>
- + ops::Add<Output = Self>
- + ops::Sub<Output = Self>
- + ops::Mul<Output = Self>
- + ops::Div<Output = Self>
- + ops::AddAssign + ops::SubAssign + ops::MulAssign + ops::DivAssign
-{
- /// The constant π
- fn pi() -> Self;
- /// Support approximate representation of a f64 value
- fn from(x: f64) -> Self;
- /// Support converting to an unsigned integer.
- fn to_u64(self) -> Option<u64>;
-
- /// Take the absolute value of self
- fn abs(self) -> Self;
- /// Take the largest integer less than or equal to self
- fn floor(self) -> Self;
-
- /// Take the exponential of self
- fn exp(self) -> Self;
- /// Take the natural logarithm of self
- fn ln(self) -> Self;
- /// Take square root of self
- fn sqrt(self) -> Self;
- /// Take self to a floating-point power
- fn powf(self, power: Self) -> Self;
-
- /// Take the tangent of self
- fn tan(self) -> Self;
- /// Take the logarithm of the gamma function of self
- fn log_gamma(self) -> Self;
-}
-
-impl Float for f32 {
- #[inline]
- fn pi() -> Self { core::f32::consts::PI }
- #[inline]
- fn from(x: f64) -> Self { x as f32 }
- #[inline]
- fn to_u64(self) -> Option<u64> {
- if self >= 0. && self <= ::core::u64::MAX as f32 {
- Some(self as u64)
- } else {
- None
- }
- }
-
- #[inline]
- fn abs(self) -> Self { self.abs() }
- #[inline]
- fn floor(self) -> Self { self.floor() }
-
- #[inline]
- fn exp(self) -> Self { self.exp() }
- #[inline]
- fn ln(self) -> Self { self.ln() }
- #[inline]
- fn sqrt(self) -> Self { self.sqrt() }
- #[inline]
- fn powf(self, power: Self) -> Self { self.powf(power) }
-
- #[inline]
- fn tan(self) -> Self { self.tan() }
- #[inline]
- fn log_gamma(self) -> Self {
- let result = log_gamma(self.into());
- assert!(result <= ::core::f32::MAX.into());
- assert!(result >= ::core::f32::MIN.into());
- result as f32
- }
-}
-
-impl Float for f64 {
- #[inline]
- fn pi() -> Self { core::f64::consts::PI }
- #[inline]
- fn from(x: f64) -> Self { x }
- #[inline]
- fn to_u64(self) -> Option<u64> {
- if self >= 0. && self <= ::core::u64::MAX as f64 {
- Some(self as u64)
- } else {
- None
- }
- }
-
- #[inline]
- fn abs(self) -> Self { self.abs() }
- #[inline]
- fn floor(self) -> Self { self.floor() }
-
- #[inline]
- fn exp(self) -> Self { self.exp() }
- #[inline]
- fn ln(self) -> Self { self.ln() }
- #[inline]
- fn sqrt(self) -> Self { self.sqrt() }
- #[inline]
- fn powf(self, power: Self) -> Self { self.powf(power) }
-
- #[inline]
- fn tan(self) -> Self { self.tan() }
- #[inline]
- fn log_gamma(self) -> Self { log_gamma(self) }
-}
-
-/// 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.
-pub(crate) 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.
-#[inline(always)]
-pub(crate) 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 {
- 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 - std::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/rand_distr/src/weibull.rs b/rand/rand_distr/src/weibull.rs
deleted file mode 100644
index ddde380..0000000
--- a/rand/rand_distr/src/weibull.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 Weibull distribution.
-
-use rand::Rng;
-use crate::{Distribution, OpenClosed01};
-use crate::utils::Float;
-
-/// Samples floating-point numbers according to the Weibull distribution
-///
-/// # Example
-/// ```
-/// use rand::prelude::*;
-/// use rand_distr::Weibull;
-///
-/// let val: f64 = thread_rng().sample(Weibull::new(1., 10.).unwrap());
-/// println!("{}", val);
-/// ```
-#[derive(Clone, Copy, Debug)]
-pub struct Weibull<N> {
- inv_shape: N,
- scale: N,
-}
-
-/// Error type returned from `Weibull::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Error {
- /// `scale <= 0` or `nan`.
- ScaleTooSmall,
- /// `shape <= 0` or `nan`.
- ShapeTooSmall,
-}
-
-impl<N: Float> Weibull<N>
-where OpenClosed01: Distribution<N>
-{
- /// Construct a new `Weibull` distribution with given `scale` and `shape`.
- pub fn new(scale: N, shape: N) -> Result<Weibull<N>, Error> {
- if !(scale > N::from(0.0)) {
- return Err(Error::ScaleTooSmall);
- }
- if !(shape > N::from(0.0)) {
- return Err(Error::ShapeTooSmall);
- }
- Ok(Weibull { inv_shape: N::from(1.)/shape, scale })
- }
-}
-
-impl<N: Float> Distribution<N> for Weibull<N>
-where OpenClosed01: Distribution<N>
-{
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> N {
- let x: N = rng.sample(OpenClosed01);
- self.scale * (-x.ln()).powf(self.inv_shape)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::Distribution;
- use super::Weibull;
-
- #[test]
- #[should_panic]
- fn invalid() {
- Weibull::new(0., 0.).unwrap();
- }
-
- #[test]
- fn sample() {
- let scale = 1.0;
- let shape = 2.0;
- let d = Weibull::new(scale, shape).unwrap();
- let mut rng = crate::test::rng(1);
- for _ in 0..1000 {
- let r = d.sample(&mut rng);
- assert!(r >= 0.);
- }
- }
-}
diff --git a/rand/rand_distr/src/ziggurat_tables.rs b/rand/rand_distr/src/ziggurat_tables.rs
deleted file mode 100644
index ca1ce30..0000000
--- a/rand/rand_distr/src/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/rand_distr/tests/uniformity.rs b/rand/rand_distr/tests/uniformity.rs
deleted file mode 100644
index d0d9d97..0000000
--- a/rand/rand_distr/tests/uniformity.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.
-
-use average::Histogram;
-use rand::prelude::*;
-
-const N_BINS: usize = 100;
-const N_SAMPLES: u32 = 1_000_000;
-const TOL: f64 = 1e-3;
-average::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_distr::UnitSphere;
- let mut rng = rand_pcg::Pcg32::from_entropy();
- for _ in 0..N_SAMPLES {
- let v: [f64; 3] = 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_distr::UnitCircle;
- let mut rng = rand_pcg::Pcg32::from_entropy();
- for _ in 0..N_SAMPLES {
- let v: [f64; 2] = 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/rand_hc/CHANGELOG.md b/rand/rand_hc/CHANGELOG.md
deleted file mode 100644
index a629d7d..0000000
--- a/rand/rand_hc/CHANGELOG.md
+++ /dev/null
@@ -1,16 +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.2.0] - 2019-06-12
-- Bump minor crate version since rand_core bump is a breaking change
-- Switch to Edition 2018
-
-## [0.1.1] - 2019-06-06 - yanked
-- Bump `rand_core` version
-- Adjust usage of `#[inline]`
-
-## [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 40cea06..0000000
--- a/rand/rand_hc/Cargo.toml
+++ /dev/null
@@ -1,22 +0,0 @@
-[package]
-name = "rand_hc"
-version = "0.2.0"
-authors = ["The Rand Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
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 36449c0..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.32+-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](https://github.com/rust-random/rand/blob/master/rand_hc/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 a320f48..0000000
--- a/rand/rand_hc/src/hc128.rs
+++ /dev/null
@@ -1,464 +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).
-#[derive(Clone, Debug)]
-pub struct Hc128Rng(BlockRng<Hc128Core>);
-
-impl RngCore for Hc128Rng {
- #[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 Hc128Rng {
- type Seed = <Hc128Core as SeedableRng>::Seed;
-
- #[inline]
- fn from_seed(seed: Self::Seed) -> Self {
- Hc128Rng(BlockRng::<Hc128Core>::from_seed(seed))
- }
-
- #[inline]
- 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.
- #[inline(always)] // single use: SeedableRng::from_seed
- 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 c1ae665..0000000
--- a/rand/rand_hc/src/lib.rs
+++ /dev/null
@@ -1,23 +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]
-
-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 0a5591f..0000000
--- a/rand/rand_isaac/CHANGELOG.md
+++ /dev/null
@@ -1,21 +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.2.0] - 2019-06-12
-- Bump minor crate version since rand_core bump is a breaking change
-- Switch to Edition 2018
-
-## [0.1.2] - 2019-06-06 - yanked
-- Bump `rand_core` version
-- Remove deprecated code
-- Adjust usage of `#[inline]`
-
-## [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 c11c305..0000000
--- a/rand/rand_isaac/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-[package]
-name = "rand_isaac"
-version = "0.2.0"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-serde1 = ["serde", "rand_core/serde1"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
-serde = { version = "1", features = ["derive"], 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 c16c63f..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.32+-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](https://github.com/rust-random/rand/blob/master/rand_isaac/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 2caf61a..0000000
--- a/rand/rand_isaac/src/isaac.rs
+++ /dev/null
@@ -1,476 +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;
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-use rand_core::{RngCore, SeedableRng, Error, le};
-use rand_core::block::{BlockRngCore, BlockRng};
-use crate::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` from the [`rand_hc`] crate instead, which, like ISAAC, is an
-/// array-based RNG and one of the stream-ciphers selected the by eSTREAM
-///
-/// 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)
-///
-/// [`rand_hc`]: https://docs.rs/rand_hc
-#[derive(Clone, Debug)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct IsaacRng(BlockRng<IsaacCore>);
-
-impl RngCore for IsaacRng {
- #[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 IsaacRng {
- type Seed = <IsaacCore as SeedableRng>::Seed;
-
- #[inline]
- 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.
- #[inline]
- fn seed_from_u64(seed: u64) -> Self {
- IsaacRng(BlockRng::<IsaacCore>::seed_from_u64(seed))
- }
-
- #[inline]
- fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error> {
- BlockRng::<IsaacCore>::from_rng(rng).map(|rng| IsaacRng(rng))
- }
-}
-
-/// 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.
- 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 7d4b88c..0000000
--- a/rand/rand_isaac/src/isaac64.rs
+++ /dev/null
@@ -1,466 +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;
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-use rand_core::{RngCore, SeedableRng, Error, le};
-use rand_core::block::{BlockRngCore, BlockRng64};
-use crate::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` from the [`rand_hc`] crate instead, which, like ISAAC, is an
-/// array-based RNG and one of the stream-ciphers selected the by eSTREAM
-///
-/// ## 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`]: crate::isaac::IsaacRng
-/// [`rand_hc`]: https://docs.rs/rand_hc
-/// [`BlockRng64`]: rand_core::block::BlockRng64
-#[derive(Clone, Debug)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-pub struct Isaac64Rng(BlockRng64<Isaac64Core>);
-
-impl RngCore for Isaac64Rng {
- #[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 Isaac64Rng {
- type Seed = <Isaac64Core as SeedableRng>::Seed;
-
- #[inline]
- 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.
- #[inline]
- fn seed_from_u64(seed: u64) -> Self {
- Isaac64Rng(BlockRng64::<Isaac64Core>::seed_from_u64(seed))
- }
-
- #[inline]
- fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error> {
- BlockRng64::<Isaac64Core>::from_rng(rng).map(|rng| Isaac64Rng(rng))
- }
-}
-
-/// 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.
- 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) }
- }
-}
-
-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 cbe4a59..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="serde")] 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="serde", derive(Serialize, Deserialize))]
-pub struct IsaacArray<T> {
- #[cfg_attr(feature="serde",serde(with="isaac_array_serde"))]
- #[cfg_attr(feature="serde", 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="serde")]
-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 84cdf21..0000000
--- a/rand/rand_isaac/src/lib.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.
-
-//! 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="serde", test)), no_std)]
-
-pub mod isaac;
-pub mod isaac64;
-
-mod isaac_array;
-
-pub use self::isaac::IsaacRng;
-pub use self::isaac64::Isaac64Rng;
diff --git a/rand/rand_jitter/CHANGELOG.md b/rand/rand_jitter/CHANGELOG.md
deleted file mode 100644
index 9f4bb7e..0000000
--- a/rand/rand_jitter/CHANGELOG.md
+++ /dev/null
@@ -1,32 +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.2.1] - 2019-08-16
-### Changed
-- `TimerError` changed to `repr(u32)` (#864)
-- `TimerError` enum values all increased by `1<<30` to match new `rand_core::Error` range (#864)
-
-## [0.2.0] - 2019-06-06
-- Bump `rand_core` version
-- Support new `Error` type in `rand_core` 0.5
-- Remove CryptoRng trait bound (#699, #814)
-- Enable doc-testing of README
-
-## [0.1.4] - 2019-05-02
-- Change error conversion code to partially fix #738
-
-## [0.1.3] - 2019-02-05
-- Use libc in `no_std` mode to fix #723
-
-## [0.1.2] - 2019-01-31
-- Fix for older rustc compilers on Windows (#722)
-
-## [0.1.1] - 2019-01-29
-- Fix for older rustc compilers on Mac OSX / iOS (#720)
-- Misc. doc fixes
-
-## [0.1.0] - 2019-01-24
-Initial release.
diff --git a/rand/rand_jitter/COPYRIGHT b/rand/rand_jitter/COPYRIGHT
deleted file mode 100644
index 468d907..0000000
--- a/rand/rand_jitter/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_jitter/Cargo.toml b/rand/rand_jitter/Cargo.toml
deleted file mode 100644
index 5b7e3c3..0000000
--- a/rand/rand_jitter/Cargo.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-[package]
-name = "rand_jitter"
-version = "0.2.1"
-authors = ["The Rand Project Developers"]
-license = "MIT OR Apache-2.0"
-readme = "README.md"
-repository = "https://github.com/rust-random/rand"
-documentation = "https://docs.rs/rand_jitter"
-description = "Random number generator based on timing jitter"
-keywords = ["random", "rng", "os"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
-log = { version = "0.4", optional = true }
-
-[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
-# We don't need the 'use_std' feature and depending on it causes
-# issues due to: https://github.com/rust-lang/cargo/issues/1197
-libc = { version = "0.2", default_features = false }
-
-[target.'cfg(target_os = "windows")'.dependencies]
-winapi = { version = "0.3", features = ["profileapi"] }
-
-[features]
-std = ["rand_core/std"]
diff --git a/rand/rand_jitter/LICENSE-APACHE b/rand/rand_jitter/LICENSE-APACHE
deleted file mode 100644
index 17d7468..0000000
--- a/rand/rand_jitter/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_jitter/LICENSE-MIT b/rand/rand_jitter/LICENSE-MIT
deleted file mode 100644
index d93b5ba..0000000
--- a/rand/rand_jitter/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_jitter/README.md b/rand/rand_jitter/README.md
deleted file mode 100644
index 2091d6c..0000000
--- a/rand/rand_jitter/README.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# rand_jitter
-[![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_jitter.svg)](https://crates.io/crates/rand_jitter)
-[![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_jitter)
-[![API](https://docs.rs/rand_jitter/badge.svg)](https://docs.rs/rand_jitter)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
-
-Non-physical true random number generator based on timing jitter.
-
-Note that this RNG is not suited for use cases where cryptographic security is
-required (also see [this
-discussion](https://github.com/rust-random/rand/issues/699)).
-
-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_jitter)
-- [API documentation (docs.rs)](https://docs.rs/rand_jitter)
-- [Changelog](https://github.com/rust-random/rand/blob/master/rand_jitter/CHANGELOG.md)
-
-## Features
-
-This crate has optional `std` support which is *disabled by default*;
-this feature is required to provide the `JitterRng::new` function;
-without `std` support a timer must be supplied via `JitterRng::new_with_timer`.
-
-## 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:
-
-```rust,no_run
-use rand_jitter::JitterRng;
-
-use std::error::Error;
-use std::fs::File;
-use std::io::Write;
-
-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
-}
-
-fn main() -> Result<(), Box<dyn Error>> {
- let mut rng = JitterRng::new_with_timer(get_nstime);
-
- // 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(())
-}
-```
-
-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 noise 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>
- ```
-
-## License
-
-`rand_jitter` 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_jitter/benches/mod.rs b/rand/rand_jitter/benches/mod.rs
deleted file mode 100644
index bf7c8a2..0000000
--- a/rand/rand_jitter/benches/mod.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-#![feature(test)]
-#![cfg(std)]
-
-use test::Bencher;
-use rand_jitter::rand_core::RngCore;
-
-#[bench]
-fn bench_add_two(b: &mut Bencher) {
- let mut rng = rand_jitter::JitterRng::new().unwrap();
- let mut buf = [0u8; 1024];
- b.iter(|| {
- rng.fill_bytes(&mut buf[..]);
- test::black_box(&buf);
- });
- b.bytes = buf.len() as u64;
-}
-
diff --git a/rand/rand_jitter/src/error.rs b/rand/rand_jitter/src/error.rs
deleted file mode 100644
index b54fffa..0000000
--- a/rand/rand_jitter/src/error.rs
+++ /dev/null
@@ -1,77 +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.
-
-use rand_core::Error;
-use core::fmt;
-
-/// Base code for all `JitterRng` errors
-const ERROR_BASE: u32 = 0xAE53_0400;
-
-/// An error that can occur when [`JitterRng::test_timer`] fails.
-///
-/// All variants have a value of 0xAE530400 = 2924676096 plus a small
-/// increment (1 through 5).
-///
-/// [`JitterRng::test_timer`]: crate::JitterRng::test_timer
-#[derive(Debug, Clone, PartialEq, Eq)]
-#[repr(u32)]
-pub enum TimerError {
- /// No timer available.
- NoTimer = ERROR_BASE + 1,
- /// Timer too coarse to use as an entropy source.
- CoarseTimer = ERROR_BASE + 2,
- /// Timer is not monotonically increasing.
- NotMonotonic = ERROR_BASE + 3,
- /// Variations of deltas of time too small.
- TinyVariantions = ERROR_BASE + 4,
- /// Too many stuck results (indicating no added entropy).
- TooManyStuck = ERROR_BASE + 5,
- #[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.
- #[cfg(feature = "std")] {
- Error::new(err)
- }
- #[cfg(not(feature = "std"))] {
- Error::from(core::num::NonZeroU32::new(err as u32).unwrap())
- }
- }
-}
-
diff --git a/rand/rand_jitter/src/lib.rs b/rand/rand_jitter/src/lib.rs
deleted file mode 100644
index 49c53e6..0000000
--- a/rand/rand_jitter/src/lib.rs
+++ /dev/null
@@ -1,750 +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 that this RNG is not suited for use cases where cryptographic security is
-//! required (also see this [discussion]).
-//!
-//! 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 it 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.
-//!
-//! `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 [`JitterRng::new_with_timer`].
-//!
-//! This implementation is based on [Jitterentropy] 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. It is also unavailable
-//! with disabled `std` feature.
-//!
-//! [Jitterentropy]: http://www.chronox.de/jent.html
-//! [discussion]: https://github.com/rust-random/rand/issues/699
-
-#![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))))]
-
-// 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.
-#![no_std]
-#[cfg(feature = "std")]
-extern crate std;
-
-pub use rand_core;
-
-// Coming from https://crates.io/crates/doc-comment
-#[cfg(test)]
-macro_rules! doc_comment {
- ($x:expr) => {
- #[doc = $x]
- extern {}
- };
-}
-
-#[cfg(test)]
-doc_comment!(include_str!("../README.md"));
-
-#[allow(unused)]
-macro_rules! trace { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::trace!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! debug { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::debug!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! info { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::info!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! warn { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::warn!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! error { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::error!($($x)*)
- }
-) }
-
-#[cfg(feature = "std")]
-mod platform;
-mod error;
-
-use rand_core::{RngCore, Error, impls};
-pub use crate::error::TimerError;
-
-use core::{fmt, mem, ptr};
-#[cfg(feature = "std")]
-use std::sync::atomic::{AtomicUsize, 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.
-///
-/// Note that this RNG is not suitable for use cases where cryptographic
-/// security is required.
-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,
- }
- }
-}
-
-// Initialise to zero; must be positive
-#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
-static JITTER_ROUNDS: AtomicUsize = AtomicUsize::new(0);
-
-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> {
- if cfg!(target_arch = "wasm32") {
- return Err(TimerError::NoTimer);
- }
- 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_jitter::rand_core::{RngCore, Error};
- /// use rand_jitter::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.next_u64();
- ///
- /// // Ready for use
- /// let v: u64 = rng.next_u64();
- /// # Ok(())
- /// # }
- ///
- /// # let _ = try_inner();
- /// ```
- ///
- /// [`test_timer`]: JitterRng::test_timer
- /// [`set_rounds`]: JitterRng::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`]: JitterRng::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 successful, 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.
- 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 this crate's README 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
- }
-}
-
-// 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))
- }
-}
diff --git a/rand/rand_jitter/src/platform.rs b/rand/rand_jitter/src/platform.rs
deleted file mode 100644
index 8e3d0fb..0000000
--- a/rand/rand_jitter/src/platform.rs
+++ /dev/null
@@ -1,44 +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.
-
-#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))]
-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 {
- use 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 {
- use winapi;
-
- unsafe {
- let mut t = super::mem::zeroed();
- winapi::um::profileapi::QueryPerformanceCounter(&mut t);
- *t.QuadPart() as u64
- }
-}
diff --git a/rand/rand_jitter/tests/mod.rs b/rand/rand_jitter/tests/mod.rs
deleted file mode 100644
index 961dc27..0000000
--- a/rand/rand_jitter/tests/mod.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use rand_jitter::JitterRng;
-#[cfg(feature = "std")]
-use rand_core::RngCore;
-
-#[cfg(feature = "std")]
-#[test]
-fn test_jitter_init() {
- // 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/rand_os/CHANGELOG.md b/rand/rand_os/CHANGELOG.md
deleted file mode 100644
index b0c6549..0000000
--- a/rand/rand_os/CHANGELOG.md
+++ /dev/null
@@ -1,35 +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.2.2] - 2019-09-02
-### Changed
-- `OsRng` added to `rand_core`, rendering this crate deprecated (#863)
-
-## [0.2.1] - 2019-08-08
-### Fixed
-- Fix `no_std` support.
-
-## [0.2.0] - 2019-06-06
-### Changed
-- Minimum Supported Rust Version has changed to 1.32.
-- Replaced implementation with a backwards-compatible shim around
-[getrandom](https://crates.io/crates/getrandom).
-
-## [0.1.3] - 2019-03-05
-### Fixed
-- Fix support for Illumos (#730)
-- Fix deprecation warnings from atomic init (#739)
-
-## [0.1.2] - 2019-01-28
-### Changed
-- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng
-
-## [0.1.1] - 2019-01-08
-### Added
-- 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 c8010e2..0000000
--- a/rand/rand_os/Cargo.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-[package]
-name = "rand_os"
-version = "0.2.2"
-authors = ["The Rand Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-log = ["getrandom/log"]
-# re-export optional WASM dependencies to avoid breakage:
-wasm-bindgen = ["getrandom/wasm-bindgen"]
-stdweb = ["getrandom/stdweb"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5", features = ["getrandom"] }
-getrandom = "0.1.1"
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 7b68b35..0000000
--- a/rand/rand_os/README.md
+++ /dev/null
@@ -1,35 +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.32+-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 is deprecated:** `OsRng` is available in `rand_core` since version 0.5.1.
-
-This crate provides `OsRng` as a shim around
-[getrandom](https://crates.io/crates/getrandom)
-implementing `RngCore` from [rand_core](https://crates.io/crates/rand_core).
-
-Note: the `rand` crate provides an equivalent `OsRng`; the two implementations
-are equivalent, though distinct types.
-
-Links:
-
-- [API documentation (master)](https://rust-random.github.io/rand/rand_os)
-- [API documentation (docs.rs)](https://docs.rs/rand_os)
-- [Changelog](https://github.com/rust-random/rand/blob/master/rand_os/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/lib.rs b/rand/rand_os/src/lib.rs
deleted file mode 100644
index abfdf79..0000000
--- a/rand/rand_os/src/lib.rs
+++ /dev/null
@@ -1,106 +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.
-// Note: keep this code in sync with the rand::rngs::os module!
-
-#![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] // but see getrandom crate
-
-#![deprecated(since="0.2.2", note="OsRng is now provided by rand_core and rand")]
-
-pub use rand_core; // re-export
-
-use getrandom::getrandom;
-use rand_core::{CryptoRng, RngCore, Error, impls};
-
-/// A random number generator that retrieves randomness from from the
-/// operating system.
-///
-/// This is a zero-sized struct. It can be freely constructed with `OsRng`.
-///
-/// The implementation is provided by the [getrandom] crate. Refer to
-/// [getrandom] documentation for details.
-///
-/// # Blocking and error handling
-///
-/// It is possible that when used during early boot the first call to `OsRng`
-/// will block until the system's RNG is initialised. It is also possible
-/// (though highly unlikely) for `OsRng` to fail on some platforms, most
-/// likely due to system mis-configuration.
-///
-/// After the first successful call, it is highly unlikely that failures or
-/// significant delays will occur (although performance should be expected to
-/// be much slower than a user-space PRNG).
-///
-/// # Usage example
-/// ```
-/// #![allow(deprecated)]
-/// use rand_os::rand_core::RngCore;
-/// use rand_os::OsRng;
-///
-/// let mut key = [0u8; 16];
-/// OsRng.fill_bytes(&mut key);
-/// let random_u64 = OsRng.next_u64();
-/// ```
-///
-/// [getrandom]: https://crates.io/crates/getrandom
-#[derive(Clone, Copy, Debug, Default)]
-pub struct OsRng;
-
-impl OsRng {
- /// Create a new `OsRng`.
- #[deprecated(since="0.2.0", note="replace OsRng::new().unwrap() with just OsRng")]
- pub fn new() -> Result<OsRng, Error> {
- Ok(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]) {
- if let Err(e) = self.try_fill_bytes(dest) {
- panic!("Error: {}", e);
- }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- getrandom(dest)?;
- Ok(())
- }
-}
-
-#[test]
-fn test_os_rng() {
- let x = OsRng.next_u64();
- let y = OsRng.next_u64();
- assert!(x != 0);
- assert!(x != y);
-}
-
-#[test]
-fn test_construction() {
- let mut rng = OsRng::default();
- assert!(rng.next_u64() != 0);
-}
diff --git a/rand/rand_pcg/CHANGELOG.md b/rand/rand_pcg/CHANGELOG.md
deleted file mode 100644
index a9b82fd..0000000
--- a/rand/rand_pcg/CHANGELOG.md
+++ /dev/null
@@ -1,24 +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.2.0] - 2019-06-12
-- Add `Lcg128Xsl64` aka `Pcg64`
-- Bump minor crate version since rand_core bump is a breaking change
-- Switch to Edition 2018
-
-## [0.1.2] - 2019-02-23
-- require `bincode` 1.1.2 for i128 auto-detection
-- make `bincode` a dev-dependency again #663
-- 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 e2aa157..0000000
--- a/rand/rand_pcg/Cargo.toml
+++ /dev/null
@@ -1,32 +0,0 @@
-[package]
-name = "rand_pcg"
-version = "0.2.0"
-authors = ["The Rand Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-serde1 = ["serde"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
-serde = { version = "1", features = ["derive"], 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
-# We require at least 1.1.2 for i128 auto-detection
-bincode = { version = "1.1.2" }
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 fe47f2d..0000000
--- a/rand/rand_pcg/README.md
+++ /dev/null
@@ -1,43 +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.32+-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](https://github.com/rust-random/rand/blob/master/rand_pcg/CHANGELOG.md)
-
-
-## Crate Features
-
-`rand_pcg` is `no_std` compatible by default.
-
-The `serde1` feature includes implementations of `Serialize` and `Deserialize`
-for the included RNGs.
-
-## 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/src/lib.rs b/rand/rand_pcg/src/lib.rs
deleted file mode 100644
index 22ba4a0..0000000
--- a/rand/rand_pcg/src/lib.rs
+++ /dev/null
@@ -1,49 +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).
-//! - `Pcg64` aka `Lcg128Xsl64`, officially known as `pcg64`, a general
-//! purpose RNG. This is a good choice on 64-bit CPUs.
-//! - `Pcg64Mcg` aka `Mcg128Xsl64`, officially known as `pcg64_fast`,
-//! 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.
-//!
-//! 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)]
-
-#![allow(clippy::unreadable_literal)]
-
-#![no_std]
-
-mod pcg64;
-#[cfg(not(target_os = "emscripten"))] mod pcg128;
-
-pub use self::pcg64::{Pcg32, Lcg64Xsh32};
-#[cfg(not(target_os = "emscripten"))] pub use self::pcg128::{
- Pcg64, Lcg128Xsl64,
- Pcg64Mcg, Mcg128Xsl64,
-};
diff --git a/rand/rand_pcg/src/pcg128.rs b/rand/rand_pcg/src/pcg128.rs
deleted file mode 100644
index 311a41b..0000000
--- a/rand/rand_pcg/src/pcg128.rs
+++ /dev/null
@@ -1,225 +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 rand_core::{RngCore, SeedableRng, Error, le};
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-
-/// A PCG random number generator (XSL RR 128/64 (LCG) variant).
-///
-/// Permuted Congruential Generator with 128-bit state, internal Linear
-/// Congruential Generator, and 64-bit output via "xorshift low (bits),
-/// random rotation" output function.
-///
-/// This is a 128-bit LCG with explicitly chosen stream with the PCG-XSL-RR
-/// output function. This combination is the standard `pcg64`.
-///
-/// Despite the name, this implementation uses 32 bytes (256 bit) space
-/// comprising 128 bits of state and 128 bits stream selector. These are both
-/// set by `SeedableRng`, using a 256-bit seed.
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
-pub struct Lcg128Xsl64 {
- state: u128,
- increment: u128,
-}
-
-/// `Lcg128Xsl64` is also officially known as `pcg64`.
-pub type Pcg64 = Lcg128Xsl64;
-
-impl Lcg128Xsl64 {
- /// Construct an instance compatible with PCG seed and stream.
- ///
- /// Note that PCG specifies default values for both parameters:
- ///
- /// - `state = 0xcafef00dd15ea5e5`
- /// - `stream = 0xa02bdbf7bb3c0a7ac28fa16a64abf96`
- pub fn new(state: u128, stream: u128) -> Self {
- // The increment must be odd, hence we discard one bit:
- let increment = (stream << 1) | 1;
- Lcg128Xsl64::from_state_incr(state, increment)
- }
-
- #[inline]
- fn from_state_incr(state: u128, increment: u128) -> Self {
- let mut pcg = Lcg128Xsl64 { 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 Lcg128Xsl64 {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Lcg128Xsl64 {{}}")
- }
-}
-
-/// We use a single 255-bit seed to initialise the state and select a stream.
-/// One `seed` bit (lowest bit of `seed[8]`) is ignored.
-impl SeedableRng for Lcg128Xsl64 {
- 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);
- let state = u128::from(seed_u64[0]) | (u128::from(seed_u64[1]) << 64);
- let incr = u128::from(seed_u64[2]) | (u128::from(seed_u64[3]) << 64);
-
- // The increment must be odd, hence we discard one bit:
- Lcg128Xsl64::from_state_incr(state, incr | 1)
- }
-}
-
-impl RngCore for Lcg128Xsl64 {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- self.step();
- output_xsl_rr(self.state)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_impl(self, dest)
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-
-/// 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, also known as
-/// `pcg64_fast`.
-/// 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.
-#[derive(Clone)]
-#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
-pub struct Mcg128Xsl64 {
- state: u128,
-}
-
-/// A friendly name for `Mcg128Xsl64` (also known as `pcg64_fast`).
-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 = u128::from(seed_u64[0]) |
- u128::from(seed_u64[1]) << 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 {
- self.state = self.state.wrapping_mul(MULTIPLIER);
- output_xsl_rr(self.state)
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- fill_bytes_impl(self, dest)
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-#[inline(always)]
-fn output_xsl_rr(state: u128) -> u64 {
- // 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(always)]
-fn fill_bytes_impl<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] = rng.next_u64().to_le_bytes();
- l.copy_from_slice(&chunk);
- }
- let n = left.len();
- if n > 0 {
- let chunk: [u8; 8] = rng.next_u64().to_le_bytes();
- left.copy_from_slice(&chunk[..n]);
- }
-}
diff --git a/rand/rand_pcg/src/pcg64.rs b/rand/rand_pcg/src/pcg64.rs
deleted file mode 100644
index fadc6dc..0000000
--- a/rand/rand_pcg/src/pcg64.rs
+++ /dev/null
@@ -1,127 +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 rand_core::{RngCore, SeedableRng, Error, le, impls};
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-
-// 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 = 0xa02bdbf7bb3c0a7`
- // Note: stream is 1442695040888963407u64 >> 1
- 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]) {
- impls::fill_bytes_via_next(self, dest)
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
diff --git a/rand/rand_pcg/tests/lcg128xsl64.rs b/rand/rand_pcg/tests/lcg128xsl64.rs
deleted file mode 100644
index efc72ff..0000000
--- a/rand/rand_pcg/tests/lcg128xsl64.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-use rand_core::{RngCore, SeedableRng};
-use rand_pcg::{Lcg128Xsl64, Pcg64};
-
-#[test]
-fn test_lcg128xsl64_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,
- 17,18,19,20, 21,22,23,24, 25,26,27,28, 29,30,31,32];
- let mut rng1 = Lcg128Xsl64::from_seed(seed);
- assert_eq!(rng1.next_u64(), 8740028313290271629);
-
- let mut rng2 = Lcg128Xsl64::from_rng(&mut rng1).unwrap();
- assert_eq!(rng2.next_u64(), 1922280315005786345);
-
- let mut rng3 = Lcg128Xsl64::seed_from_u64(0);
- assert_eq!(rng3.next_u64(), 2354861276966075475);
-
- // This is the same as Lcg128Xsl64, so we only have a single test:
- let mut rng4 = Pcg64::seed_from_u64(0);
- assert_eq!(rng4.next_u64(), 2354861276966075475);
-}
-
-#[test]
-fn test_lcg128xsl64_true_values() {
- // Numbers copied from official test suite (C version).
- let mut rng = Lcg128Xsl64::new(42, 54);
-
- let mut results = [0u64; 6];
- for i in results.iter_mut() { *i = rng.next_u64(); }
- let expected: [u64; 6] = [0x86b1da1d72062b68, 0x1304aa46c9853d39,
- 0xa3670e9e0dd50358, 0xf9090e529a7dae00, 0xc85b9fd837996f2c, 0x606121f8e3919196];
- assert_eq!(results, expected);
-}
-
-#[cfg(feature="serde1")]
-#[test]
-fn test_lcg128xsl64_serde() {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let mut rng = Lcg128Xsl64::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: Lcg128Xsl64 = 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/lcg64xsh32.rs b/rand/rand_pcg/tests/lcg64xsh32.rs
deleted file mode 100644
index e05bcc1..0000000
--- a/rand/rand_pcg/tests/lcg64xsh32.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-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 d58fa75..0000000
--- a/rand/rand_pcg/tests/mcg128xsl64.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-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 ce3098a..0000000
--- a/rand/rand_xorshift/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.2.0] - 2019-06-12
-- Bump minor crate version since rand_core bump is a breaking change
-- Switch to Edition 2018
-
-## [0.1.2] - 2019-06-06 - yanked
-- Bump `rand_core` version
-- Make XorShiftRng::from_rng portable by enforcing Endianness (#815)
-
-## [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 9cb257b..0000000
--- a/rand/rand_xorshift/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-[package]
-name = "rand_xorshift"
-version = "0.2.0"
-authors = ["The Rand Project Developers", "The Rust Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[badges]
-travis-ci = { repository = "rust-random/rand" }
-appveyor = { repository = "rust-random/rand" }
-
-[features]
-serde1 = ["serde"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
-serde = { version = "1", features = ["derive"], 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 57de284..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.32+-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](https://github.com/rust-random/rand/blob/master/rand_xorshift/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 b9fef23..0000000
--- a/rand/rand_xorshift/src/lib.rs
+++ /dev/null
@@ -1,117 +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]
-
-use core::num::Wrapping as w;
-use core::fmt;
-use rand_core::{RngCore, SeedableRng, Error, impls, le};
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-
-/// 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> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
-
-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 b = [0u8; 16];
- loop {
- rng.try_fill_bytes(&mut b[..])?;
- if !b.iter().all(|&x| x == 0) {
- break;
- }
- }
-
- Ok(XorShiftRng {
- x: w(u32::from_le_bytes([b[0], b[1], b[2], b[3]])),
- y: w(u32::from_le_bytes([b[4], b[5], b[6], b[7]])),
- z: w(u32::from_le_bytes([b[8], b[9], b[10], b[11]])),
- w: w(u32::from_le_bytes([b[12], b[13], b[14], b[15]])),
- })
- }
-}
diff --git a/rand/rand_xorshift/tests/mod.rs b/rand/rand_xorshift/tests/mod.rs
deleted file mode 100644
index 7ecdeae..0000000
--- a/rand/rand_xorshift/tests/mod.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-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 mut rng2 = XorShiftRng::from_rng(&mut rng1).unwrap();
- // Yes, this makes rng2 a clone of rng1!
- assert_eq!(rng1.next_u64(), 15614385950550801700);
- assert_eq!(rng2.next_u64(), 15614385950550801700);
-}
-
-#[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 56cb9c2..0000000
--- a/rand/rand_xoshiro/CHANGELOG.md
+++ /dev/null
@@ -1,24 +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.1] - 2019-08-06
-- Drop `byteorder`-dependency in favor of `stdlib`-implementation.
-
-## [0.3.0] - 2019-06-12
-- Bump minor crate version since rand_core bump is a breaking change
-- Switch to Edition 2018
-
-## [0.2.1] - 2019-06-06 - yanked
-- Bump `rand_core` version
-- Document crate features in README
-
-## [0.2.0] - 2019-05-28
-- Fix `seed_from_u64(0)` for `Xoroshiro64StarStar` and `Xoroshiro64Star`. This
- breaks value stability for these generators if initialized with `seed_from_u64`.
-- Implement Serde support.
-
-## [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 128c213..0000000
--- a/rand/rand_xoshiro/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-[package]
-name = "rand_xoshiro"
-version = "0.3.1" # NB: When modifying, also modify html_root_url in lib.rs
-authors = ["The Rand Project Developers"]
-license = "MIT OR 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"]
-edition = "2018"
-
-[features]
-serde1 = ["serde"]
-
-[dependencies]
-rand_core = { path = "../rand_core", version = "0.5" }
-serde = { version = "1", features = ["derive"], 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 = { version = "1" }
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 1c02992..0000000
--- a/rand/rand_xoshiro/README.md
+++ /dev/null
@@ -1,34 +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.32+-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](https://github.com/rust-random/rand/blob/master/rand_xoshiro/CHANGELOG.md)
-
-## Crate Features
-
-`rand_xoshiro` is no_std compatible by default.
-
-The `serde1` feature includes implementations of `Serialize` and `Deserialize` for the included RNGs.
-
-## 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 b188dd6..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 = crate::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 3047e92..0000000
--- a/rand/rand_xoshiro/src/lib.rs
+++ /dev/null
@@ -1,94 +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
-
-#![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.3.1")]
-
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![allow(clippy::unreadable_literal)]
-#![no_std]
-
-#[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 rand_core;
-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 3a41450..0000000
--- a/rand/rand_xoshiro/src/splitmix64.rs
+++ /dev/null
@@ -1,149 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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 {
- SplitMix64::from_seed(seed.to_le_bytes())
- }
-}
-
-#[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 a7b4ebc..0000000
--- a/rand/rand_xoshiro/src/xoroshiro128plus.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.
-
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 21823f5..0000000
--- a/rand/rand_xoshiro/src/xoroshiro128starstar.rs
+++ /dev/null
@@ -1,127 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 6bb708a..0000000
--- a/rand/rand_xoshiro/src/xoroshiro64star.rs
+++ /dev/null
@@ -1,102 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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 {
- from_splitmix!(seed)
- }
-}
-
-#[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);
- }
- }
-
- #[test]
- fn zero_seed() {
- let mut rng = Xoroshiro64Star::seed_from_u64(0);
- assert_ne!(rng.next_u64(), 0);
- }
-}
diff --git a/rand/rand_xoshiro/src/xoroshiro64starstar.rs b/rand/rand_xoshiro/src/xoroshiro64starstar.rs
deleted file mode 100644
index 8e1aea1..0000000
--- a/rand/rand_xoshiro/src/xoroshiro64starstar.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.
-
-#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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` using `SplitMix64`.
- fn seed_from_u64(seed: u64) -> Xoroshiro64StarStar {
- from_splitmix!(seed)
- }
-}
-
-#[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);
- }
- }
-
- #[test]
- fn zero_seed() {
- let mut rng = Xoroshiro64StarStar::seed_from_u64(0);
- assert_ne!(rng.next_u64(), 0);
- }
-}
diff --git a/rand/rand_xoshiro/src/xoshiro128plus.rs b/rand/rand_xoshiro/src/xoshiro128plus.rs
deleted file mode 100644
index 7cbd612..0000000
--- a/rand/rand_xoshiro/src/xoshiro128plus.rs
+++ /dev/null
@@ -1,112 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 7af1e50..0000000
--- a/rand/rand_xoshiro/src/xoshiro128starstar.rs
+++ /dev/null
@@ -1,111 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 396f588..0000000
--- a/rand/rand_xoshiro/src/xoshiro256plus.rs
+++ /dev/null
@@ -1,131 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 2cc2029..0000000
--- a/rand/rand_xoshiro/src/xoshiro256starstar.rs
+++ /dev/null
@@ -1,128 +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="serde1")] use serde::{Serialize, Deserialize};
-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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 4b589f2..0000000
--- a/rand/rand_xoshiro/src/xoshiro512plus.rs
+++ /dev/null
@@ -1,122 +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="serde1")] use serde::{Serialize, Deserialize};
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::le::read_u64_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-use crate::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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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 2db9ac1..0000000
--- a/rand/rand_xoshiro/src/xoshiro512starstar.rs
+++ /dev/null
@@ -1,122 +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="serde1")] use serde::{Serialize, Deserialize};
-use rand_core::impls::fill_bytes_via_next;
-use rand_core::le::read_u64_into;
-use rand_core::{SeedableRng, RngCore, Error};
-
-use crate::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)]
-#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
-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.
- ///
- /// ```
- /// use rand_xoshiro::rand_core::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/rand_xoshiro/tests/serde.rs b/rand/rand_xoshiro/tests/serde.rs
deleted file mode 100644
index ee23a1d..0000000
--- a/rand/rand_xoshiro/tests/serde.rs
+++ /dev/null
@@ -1,83 +0,0 @@
-#![cfg(feature="serde1")]
-
-use rand_core::{RngCore, SeedableRng};
-use rand_xoshiro::{SplitMix64, Xoroshiro64StarStar, Xoroshiro64Star,
- Xoroshiro128Plus, Xoroshiro128StarStar, Xoshiro128StarStar, Xoshiro128Plus,
- Xoshiro256StarStar, Xoshiro256Plus, Xoshiro512StarStar, Xoshiro512Plus};
-
-macro_rules! serde_rng {
- ($rng:ident) => {
- use bincode;
- use std::io::{BufWriter, BufReader};
-
- let mut rng = $rng::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: $rng = bincode::deserialize_from(&mut read)
- .expect("Could not deserialize");
-
- for _ in 0..16 {
- assert_eq!(rng.next_u64(), deserialized.next_u64());
- }
- }
-}
-
-#[test]
-fn test_splitmix64() {
- serde_rng!(SplitMix64);
-}
-
-#[test]
-fn test_xoroshiro64starstar() {
- serde_rng!(Xoroshiro64StarStar);
-}
-
-#[test]
-fn test_xoroshiro64star() {
- serde_rng!(Xoroshiro64Star);
-}
-
-#[test]
-fn test_xoroshiro128plus() {
- serde_rng!(Xoroshiro128Plus);
-}
-
-#[test]
-fn test_xoroshiro128starstar() {
- serde_rng!(Xoroshiro128StarStar);
-}
-
-#[test]
-fn test_xoshiro128starstar() {
- serde_rng!(Xoshiro128StarStar);
-}
-
-#[test]
-fn test_xoshiro128plus() {
- serde_rng!(Xoshiro128Plus);
-}
-
-#[test]
-fn test_xoshiro256starstar() {
- serde_rng!(Xoshiro256StarStar);
-}
-
-#[test]
-fn test_xoshiro256plus() {
- serde_rng!(Xoshiro256Plus);
-}
-
-#[test]
-fn test_xoshiro512starstar() {
- serde_rng!(Xoshiro512StarStar);
-}
-
-#[test]
-fn test_xoshiro512plus() {
- serde_rng!(Xoshiro512Plus);
-}
diff --git a/rand/rustfmt.toml b/rand/rustfmt.toml
deleted file mode 100644
index 6b2aba3..0000000
--- a/rand/rustfmt.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-# This rustfmt file is added for configuration, but in practice much of our
-# code is hand-formatted, frequently with more readable results.
-
-# Comments:
-normalize_comments = true
-wrap_comments = false
-format_doc_comments = true
-comment_width = 90 # small excess is okay but prefer 80
-
-# Arguments:
-use_small_heuristics = "max"
-fn_args_density = "compressed"
-fn_single_line = false
-overflow_delimited_expr = true
-where_single_line = true
-
-# enum_discrim_align_threshold = 20
-# struct_field_align_threshold = 20
-
-# Compatibility:
-edition = "2018" # we require compatibility back to 1.32.0
-
-# Misc:
-blank_lines_upper_bound = 2
-reorder_impl_items = true
-# report_todo = "Unnumbered"
-# report_fixme = "Unnumbered"
-
-# Ignored files:
-ignore = []
diff --git a/rand/src/distributions/bernoulli.rs b/rand/src/distributions/bernoulli.rs
deleted file mode 100644
index eadd056..0000000
--- a/rand/src/distributions/bernoulli.rs
+++ /dev/null
@@ -1,166 +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 crate::Rng;
-use crate::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).unwrap();
-/// 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;
-
-/// Error type returned from `Bernoulli::new`.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum BernoulliError {
- /// `p < 0` or `p > 1`.
- InvalidProbability,
-}
-
-impl Bernoulli {
- /// Construct a new `Bernoulli` with the given probability of success `p`.
- ///
- /// # 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) -> Result<Bernoulli, BernoulliError> {
- if p < 0.0 || p >= 1.0 {
- if p == 1.0 { return Ok(Bernoulli { p_int: ALWAYS_TRUE }) }
- return Err(BernoulliError::InvalidProbability);
- }
- Ok(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`.
- #[inline]
- pub fn from_ratio(numerator: u32, denominator: u32) -> Result<Bernoulli, BernoulliError> {
- if numerator > denominator {
- return Err(BernoulliError::InvalidProbability);
- }
- if numerator == denominator {
- return Ok(Bernoulli { p_int: ALWAYS_TRUE })
- }
- let p_int = ((f64::from(numerator) / f64::from(denominator)) * SCALE) as u64;
- Ok(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 crate::Rng;
- use crate::distributions::Distribution;
- use super::Bernoulli;
-
- #[test]
- fn test_trivial() {
- let mut r = crate::test::rng(1);
- let always_false = Bernoulli::new(0.0).unwrap();
- let always_true = Bernoulli::new(1.0).unwrap();
- 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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_average() {
- const P: f64 = 0.3;
- const NUM: u32 = 3;
- const DENOM: u32 = 10;
- let d1 = Bernoulli::new(P).unwrap();
- let d2 = Bernoulli::from_ratio(NUM, DENOM).unwrap();
- const N: u32 = 100_000;
-
- let mut sum1: u32 = 0;
- let mut sum2: u32 = 0;
- let mut rng = crate::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 8fc290a..0000000
--- a/rand/src/distributions/binomial.rs
+++ /dev/null
@@ -1,313 +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.
-#![allow(deprecated)]
-#![allow(clippy::all)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, Uniform};
-
-/// 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`.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 }
- }
-}
-
-/// Convert a `f64` to an `i64`, panicing on overflow.
-// In the future (Rust 1.34), this might be replaced with `TryFrom`.
-fn f64_to_i64(x: f64) -> i64 {
- assert!(x < (::std::i64::MAX as f64));
- x as i64
-}
-
-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;
- }
-
- // The 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
- };
-
- let result;
- let q = 1. - p;
-
- // For small n * min(p, 1 - p), the BINV algorithm based on the inverse
- // transformation of the binomial distribution is efficient. Otherwise,
- // the BTPE algorithm is used.
- //
- // Voratas Kachitvichyanukul and Bruce W. Schmeiser. 1988. Binomial
- // random variate generation. Commun. ACM 31, 2 (February 1988),
- // 216-222. http://dx.doi.org/10.1145/42372.42381
-
- // Threshold for prefering the BINV algorithm. The paper suggests 10,
- // Ranlib uses 30, and GSL uses 14.
- const BINV_THRESHOLD: f64 = 10.;
-
- if (self.n as f64) * p < BINV_THRESHOLD &&
- self.n <= (::std::i32::MAX as u64) {
- // Use the BINV algorithm.
- let s = p / q;
- let a = ((self.n + 1) as f64) * s;
- let mut r = q.powi(self.n as i32);
- let mut u: f64 = rng.gen();
- let mut x = 0;
- while u > r as f64 {
- u -= r;
- x += 1;
- r *= a / (x as f64) - s;
- }
- result = x;
- } else {
- // Use the BTPE algorithm.
-
- // Threshold for using the squeeze algorithm. This can be freely
- // chosen based on performance. Ranlib and GSL use 20.
- const SQUEEZE_THRESHOLD: i64 = 20;
-
- // Step 0: Calculate constants as functions of `n` and `p`.
- let n = self.n as f64;
- let np = n * p;
- let npq = np * q;
- let f_m = np + p;
- let m = f64_to_i64(f_m);
- // radius of triangle region, since height=1 also area of region
- let p1 = (2.195 * npq.sqrt() - 4.6 * q).floor() + 0.5;
- // tip of triangle
- let x_m = (m as f64) + 0.5;
- // left edge of triangle
- let x_l = x_m - p1;
- // right edge of triangle
- let x_r = x_m + p1;
- let c = 0.134 + 20.5 / (15.3 + (m as f64));
- // p1 + area of parallelogram region
- let p2 = p1 * (1. + 2. * c);
-
- fn lambda(a: f64) -> f64 {
- a * (1. + 0.5 * a)
- }
-
- let lambda_l = lambda((f_m - x_l) / (f_m - x_l * p));
- let lambda_r = lambda((x_r - f_m) / (x_r * q));
- // p1 + area of left tail
- let p3 = p2 + c / lambda_l;
- // p1 + area of right tail
- let p4 = p3 + c / lambda_r;
-
- // return value
- let mut y: i64;
-
- let gen_u = Uniform::new(0., p4);
- let gen_v = Uniform::new(0., 1.);
-
- loop {
- // Step 1: Generate `u` for selecting the region. If region 1 is
- // selected, generate a triangularly distributed variate.
- let u = gen_u.sample(rng);
- let mut v = gen_v.sample(rng);
- if !(u > p1) {
- y = f64_to_i64(x_m - p1 * v + u);
- break;
- }
-
- if !(u > p2) {
- // Step 2: Region 2, parallelograms. Check if region 2 is
- // used. If so, generate `y`.
- let x = x_l + (u - p1) / c;
- v = v * c + 1.0 - (x - x_m).abs() / p1;
- if v > 1. {
- continue;
- } else {
- y = f64_to_i64(x);
- }
- } else if !(u > p3) {
- // Step 3: Region 3, left exponential tail.
- y = f64_to_i64(x_l + v.ln() / lambda_l);
- if y < 0 {
- continue;
- } else {
- v *= (u - p2) * lambda_l;
- }
- } else {
- // Step 4: Region 4, right exponential tail.
- y = f64_to_i64(x_r - v.ln() / lambda_r);
- if y > 0 && (y as u64) > self.n {
- continue;
- } else {
- v *= (u - p3) * lambda_r;
- }
- }
-
- // Step 5: Acceptance/rejection comparison.
-
- // Step 5.0: Test for appropriate method of evaluating f(y).
- let k = (y - m).abs();
- if !(k > SQUEEZE_THRESHOLD && (k as f64) < 0.5 * npq - 1.) {
- // Step 5.1: Evaluate f(y) via the recursive relationship. Start the
- // search from the mode.
- let s = p / q;
- let a = s * (n + 1.);
- let mut f = 1.0;
- if m < y {
- let mut i = m;
- loop {
- i += 1;
- f *= a / (i as f64) - s;
- if i == y {
- break;
- }
- }
- } else if m > y {
- let mut i = y;
- loop {
- i += 1;
- f /= a / (i as f64) - s;
- if i == m {
- break;
- }
- }
- }
- if v > f {
- continue;
- } else {
- break;
- }
- }
-
- // Step 5.2: Squeezing. Check the value of ln(v) againts upper and
- // lower bound of ln(f(y)).
- let k = k as f64;
- let rho = (k / npq) * ((k * (k / 3. + 0.625) + 1./6.) / npq + 0.5);
- let t = -0.5 * k*k / npq;
- let alpha = v.ln();
- if alpha < t - rho {
- break;
- }
- if alpha > t + rho {
- continue;
- }
-
- // Step 5.3: Final acceptance/rejection test.
- let x1 = (y + 1) as f64;
- let f1 = (m + 1) as f64;
- let z = (f64_to_i64(n) + 1 - m) as f64;
- let w = (f64_to_i64(n) - y + 1) as f64;
-
- fn stirling(a: f64) -> f64 {
- let a2 = a * a;
- (13860. - (462. - (132. - (99. - 140. / a2) / a2) / a2) / a2) / a / 166320.
- }
-
- if alpha > x_m * (f1 / x1).ln()
- + (n - (m as f64) + 0.5) * (z / w).ln()
- + ((y - m) as f64) * (w * p / (x1 * q)).ln()
- // We use the signs from the GSL implementation, which are
- // different than the ones in the reference. According to
- // the GSL authors, the new signs were verified to be
- // correct by one of the original designers of the
- // algorithm.
- + stirling(f1) + stirling(z) - stirling(x1) - stirling(w)
- {
- continue;
- }
-
- break;
- }
- assert!(y >= 0);
- result = y as u64;
- }
-
- // Invert the result for p < 0.5.
- if p != self.p {
- self.n - result
- } else {
- result
- }
- }
-}
-
-#[cfg(test)]
-mod test {
- use crate::Rng;
- use crate::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,
- "mean: {}, expected_mean: {}", mean, expected_mean);
-
- 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,
- "variance: {}, expected_variance: {}", variance, expected_variance);
- }
-
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_binomial() {
- let mut rng = crate::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 = crate::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 0a5d149..0000000
--- a/rand/src/distributions/cauchy.rs
+++ /dev/null
@@ -1,103 +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.
-#![allow(deprecated)]
-#![allow(clippy::all)]
-
-use crate::Rng;
-use crate::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))`
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::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]
- #[cfg(not(miri))] // Miri doesn't support transcendental functions
- fn test_cauchy_averages() {
- // NOTE: given that the variance and mean are undefined,
- // this test does not have any rigorous statistical meaning.
- let cauchy = Cauchy::new(10.0, 5.0);
- let mut rng = crate::test::rng(123);
- let mut numbers: [f64; 1000] = [0.0; 1000];
- let mut sum = 0.0;
- for i in 0..1000 {
- numbers[i] = cauchy.sample(&mut rng);
- sum += numbers[i];
- }
- let median = median(&mut numbers);
- println!("Cauchy median: {}", median);
- assert!((median - 10.0).abs() < 0.4); // not 100% certain, but probable enough
- let mean = sum / 1000.0;
- println!("Cauchy mean: {}", mean);
- // for a Cauchy distribution the mean should not converge
- assert!((mean - 10.0).abs() > 0.4); // 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 1ce01fd..0000000
--- a/rand/src/distributions/dirichlet.rs
+++ /dev/null
@@ -1,128 +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.
-#![allow(deprecated)]
-#![allow(clippy::all)]
-
-use crate::Rng;
-use crate::distributions::Distribution;
-use crate::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.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::distributions::Distribution;
-
- #[test]
- fn test_dirichlet() {
- let d = Dirichlet::new(vec![1.0, 2.0, 3.0]);
- let mut rng = crate::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 = crate::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 0278248..0000000
--- a/rand/src/distributions/exponential.rs
+++ /dev/null
@@ -1,108 +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.
-#![allow(deprecated)]
-
-use crate::{Rng};
-use crate::distributions::{ziggurat_tables, Distribution};
-use crate::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
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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`](crate::distributions::Exp1) is an optimised implementation for `lambda = 1`.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::distributions::Distribution;
- use super::Exp;
-
- #[test]
- fn test_exp() {
- let exp = Exp::new(10.0);
- let mut rng = crate::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 bda523a..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 crate::Rng;
-use crate::distributions::{Distribution, Standard};
-use crate::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`]: crate::distributions::Standard
-/// [`Open01`]: crate::distributions::Open01
-/// [`Uniform`]: crate::distributions::uniform::Uniform
-#[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`]: crate::distributions::Standard
-/// [`OpenClosed01`]: crate::distributions::OpenClosed01
-/// [`Uniform`]: crate::distributions::uniform::Uniform
-#[derive(Clone, Copy, Debug)]
-pub struct Open01;
-
-
-// This trait is needed by both this lib and rand_distr hence is a hidden export
-#[doc(hidden)]
-pub 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;
- $ty::from_bits(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 crate::Rng;
- use crate::distributions::{Open01, OpenClosed01};
- use crate::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 b5a97f5..0000000
--- a/rand/src/distributions/gamma.rs
+++ /dev/null
@@ -1,371 +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.
-#![allow(deprecated)]
-
-use self::GammaRepr::*;
-use self::ChiSquaredRepr::*;
-
-use crate::Rng;
-use crate::distributions::normal::StandardNormal;
-use crate::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`.
-///
-/// [^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)
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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)`.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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)`.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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`.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::distributions::Distribution;
- use super::{Beta, ChiSquared, StudentT, FisherF};
-
- const N: u32 = 100;
-
- #[test]
- fn test_chi_squared_one() {
- let chi = ChiSquared::new(1.0);
- let mut rng = crate::test::rng(201);
- for _ in 0..N {
- chi.sample(&mut rng);
- }
- }
- #[test]
- fn test_chi_squared_small() {
- let chi = ChiSquared::new(0.5);
- let mut rng = crate::test::rng(202);
- for _ in 0..N {
- chi.sample(&mut rng);
- }
- }
- #[test]
- fn test_chi_squared_large() {
- let chi = ChiSquared::new(30.0);
- let mut rng = crate::test::rng(203);
- for _ in 0..N {
- 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 = crate::test::rng(204);
- for _ in 0..N {
- f.sample(&mut rng);
- }
- }
-
- #[test]
- fn test_t() {
- let t = StudentT::new(11.0);
- let mut rng = crate::test::rng(205);
- for _ in 0..N {
- t.sample(&mut rng);
- }
- }
-
- #[test]
- fn test_beta() {
- let beta = Beta::new(1.0, 2.0);
- let mut rng = crate::test::rng(201);
- for _ in 0..N {
- 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 5238339..0000000
--- a/rand/src/distributions/integer.rs
+++ /dev/null
@@ -1,184 +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 crate::{Rng};
-use crate::distributions::{Distribution, Standard};
-use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize};
-#[cfg(not(target_os = "emscripten"))] use core::num::NonZeroU128;
-#[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(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 = u128::from(rng.next_u64());
- let y = u128::from(rng.next_u64());
- (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(not(target_os = "emscripten"))] impl_int_from_uint! { i128, u128 }
-impl_int_from_uint! { isize, usize }
-
-macro_rules! impl_nzint {
- ($ty:ty, $new:path) => {
- impl Distribution<$ty> for Standard {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> $ty {
- loop {
- if let Some(nz) = $new(rng.gen()) {
- break nz;
- }
- }
- }
- }
- }
-}
-
-impl_nzint!(NonZeroU8, NonZeroU8::new);
-impl_nzint!(NonZeroU16, NonZeroU16::new);
-impl_nzint!(NonZeroU32, NonZeroU32::new);
-impl_nzint!(NonZeroU64, NonZeroU64::new);
-#[cfg(not(target_os = "emscripten"))] impl_nzint!(NonZeroU128, NonZeroU128::new);
-impl_nzint!(NonZeroUsize, NonZeroUsize::new);
-
-#[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 crate::Rng;
- use crate::distributions::{Standard};
-
- #[test]
- fn test_integers() {
- let mut rng = crate::test::rng(806);
-
- rng.sample::<isize, _>(Standard);
- rng.sample::<i8, _>(Standard);
- rng.sample::<i16, _>(Standard);
- rng.sample::<i32, _>(Standard);
- rng.sample::<i64, _>(Standard);
- #[cfg(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(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 02ece6f..0000000
--- a/rand/src/distributions/mod.rs
+++ /dev/null
@@ -1,381 +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, e.g. [`Rng::gen`], [`Rng::gen_range`] and
-//! of course [`Rng::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.
-//!
-//! ## Random characters
-//!
-//! [`Alphanumeric`] is a simple distribution to sample random letters and
-//! numbers of the `char` type; in contrast [`Standard`] may sample any valid
-//! `char`.
-//!
-//!
-//! # Uniform numeric ranges
-//!
-//! 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`].
-//!
-//! ## Open and half-open ranges
-//!
-//! 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" section of
-//! [`Standard`] documentation for more details.
-//!
-//! # Non-uniform sampling
-//!
-//! Sampling a simple true/false outcome with a given probability has a name:
-//! the [`Bernoulli`] distribution (this is used by [`Rng::gen_bool`]).
-//!
-//! For weighted sampling from a sequence of discrete values, use the
-//! [`weighted`] module.
-//!
-//! This crate no longer includes other non-uniform distributions; instead
-//! it is recommended that you use either [`rand_distr`] or [`statrs`].
-//!
-//!
-//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution
-//! [`rand_distr`]: https://crates.io/crates/rand_distr
-//! [`statrs`]: https://crates.io/crates/statrs
-
-//! [`Alphanumeric`]: distributions::Alphanumeric
-//! [`Bernoulli`]: distributions::Bernoulli
-//! [`Open01`]: distributions::Open01
-//! [`OpenClosed01`]: distributions::OpenClosed01
-//! [`Standard`]: distributions::Standard
-//! [`Uniform`]: distributions::Uniform
-//! [`Uniform::new`]: distributions::Uniform::new
-//! [`Uniform::new_inclusive`]: distributions::Uniform::new_inclusive
-//! [`weighted`]: distributions::weighted
-//! [`rand_distr`]: https://crates.io/crates/rand_distr
-//! [`statrs`]: https://crates.io/crates/statrs
-
-use core::iter;
-use crate::Rng;
-
-pub use self::other::Alphanumeric;
-#[doc(inline)] pub use self::uniform::Uniform;
-pub use self::float::{OpenClosed01, Open01};
-pub use self::bernoulli::{Bernoulli, BernoulliError};
-#[cfg(feature="alloc")] pub use self::weighted::{WeightedIndex, WeightedError};
-
-// The following are all deprecated after being moved to rand_distr
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::unit_sphere::UnitSphereSurface;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::unit_circle::UnitCircle;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::gamma::{Gamma, ChiSquared, FisherF,
- StudentT, Beta};
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::normal::{Normal, LogNormal, StandardNormal};
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::exponential::{Exp, Exp1};
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::pareto::Pareto;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::poisson::Poisson;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::binomial::Binomial;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::cauchy::Cauchy;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::dirichlet::Dirichlet;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::triangular::Triangular;
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::weibull::Weibull;
-
-pub mod uniform;
-mod bernoulli;
-#[cfg(feature="alloc")] pub 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;
-#[doc(hidden)] pub mod hidden_export {
- pub use super::float::IntoFloat; // used by rand_distr
-}
-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.
-///
-/// [`sample_iter`]: Distribution::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.
- ///
- /// Note that this function takes `self` by value. This works since
- /// `Distribution<T>` is impl'd for `&D` where `D: Distribution<T>`,
- /// however borrowing is not automatic hence `distr.sample_iter(...)` may
- /// need to be replaced with `(&distr).sample_iter(...)` to borrow or
- /// `(&*distr).sample_iter(...)` to reborrow an existing reference.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::thread_rng;
- /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard};
- ///
- /// let rng = thread_rng();
- ///
- /// // Vec of 16 x f32:
- /// let v: Vec<f32> = Standard.sample_iter(rng).take(16).collect();
- ///
- /// // String:
- /// let s: String = Alphanumeric.sample_iter(rng).take(7).collect();
- ///
- /// // Dice-rolling:
- /// let die_range = Uniform::new_inclusive(1, 6);
- /// let mut roll_die = die_range.sample_iter(rng);
- /// while roll_die.next().unwrap() != 6 {
- /// println!("Not a 6; rolling again!");
- /// }
- /// ```
- fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
- where R: Rng, Self: Sized
- {
- DistIter {
- distr: self,
- 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.
-///
-/// [`sample_iter`]: Distribution::sample_iter
-#[derive(Debug)]
-pub struct DistIter<D, R, T> {
- distr: D,
- rng: R,
- phantom: ::core::marker::PhantomData<T>,
-}
-
-impl<D, R, T> Iterator for DistIter<D, R, T>
- where D: Distribution<T>, R: Rng
-{
- type Item = T;
-
- #[inline(always)]
- fn next(&mut self) -> Option<T> {
- // Here, self.rng may be a reference, but we must take &mut anyway.
- // Even if sample could take an R: Rng by value, we would need to do this
- // since Rng is not copyable and we cannot enforce that this is "reborrowable".
- Some(self.distr.sample(&mut self.rng))
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (usize::max_value(), None)
- }
-}
-
-impl<D, R, T> iter::FusedIterator for DistIter<D, R, T>
- where D: Distribution<T>, R: Rng {}
-
-#[cfg(features = "nightly")]
-impl<D, R, T> iter::TrustedLen for DistIter<D, R, T>
- where D: Distribution<T>, R: Rng {}
-
-
-/// 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.
-///
-/// ## Provided 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 `Standard` distribution also supports generation of the following
-/// compound types where all component types are supported:
-///
-/// * Tuples (up to 12 elements): each element is generated sequentially.
-/// * Arrays (up to 32 elements): each element is generated sequentially;
-/// see also [`Rng::fill`] which supports arbitrary array length for integer
-/// types and tends to be faster for `u32` and smaller types.
-/// * `Option<T>` first generates a `bool`, and if true generates and returns
-/// `Some(value)` where `value: T`, otherwise returning `None`.
-///
-/// ## Custom implementations
-///
-/// The [`Standard`] distribution may be implemented for user types as follows:
-///
-/// ```
-/// # #![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() }
-/// }
-/// }
-/// ```
-///
-/// ## Example usage
-/// ```
-/// use rand::prelude::*;
-/// use rand::distributions::Standard;
-///
-/// let val: f32 = StdRng::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).
-///
-/// [`Uniform`]: uniform::Uniform
-#[derive(Clone, Copy, Debug)]
-pub struct Standard;
-
-
-#[cfg(all(test, feature = "std"))]
-mod tests {
- use crate::Rng;
- use super::{Distribution, Uniform};
-
- #[test]
- fn test_distributions_iter() {
- use crate::distributions::Open01;
- let mut rng = crate::test::rng(210);
- let distr = Open01;
- let results: Vec<f32> = distr.sample_iter(&mut rng).take(100).collect();
- println!("{:?}", results);
- }
-
- #[test]
- fn test_make_an_iter() {
- fn ten_dice_rolls_other_than_five<'a, R: Rng>(rng: &'a mut R) -> impl Iterator<Item = i32> + 'a {
- Uniform::new_inclusive(1, 6)
- .sample_iter(rng)
- .filter(|x| *x != 5)
- .take(10)
- }
-
- let mut rng = crate::test::rng(211);
- let mut count = 0;
- for val in ten_dice_rolls_other_than_five(&mut rng) {
- assert!(val >= 1 && val <= 6 && val != 5);
- count += 1;
- }
- assert_eq!(count, 10);
- }
-}
diff --git a/rand/src/distributions/normal.rs b/rand/src/distributions/normal.rs
deleted file mode 100644
index 7808baf..0000000
--- a/rand/src/distributions/normal.rs
+++ /dev/null
@@ -1,170 +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.
-#![allow(deprecated)]
-
-use crate::Rng;
-use crate::distributions::{ziggurat_tables, Distribution, Open01};
-use crate::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
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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.
-///
-/// [`StandardNormal`]: crate::distributions::StandardNormal
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::distributions::Distribution;
- use super::{Normal, LogNormal};
-
- #[test]
- fn test_normal() {
- let norm = Normal::new(10.0, 10.0);
- let mut rng = crate::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 = crate::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 6ec0473..0000000
--- a/rand/src/distributions/other.rs
+++ /dev/null
@@ -1,220 +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 crate::Rng;
-use crate::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 {
- #[allow(clippy::unused_unit)]
- #[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 crate::{Rng, RngCore, Standard};
- use crate::distributions::Alphanumeric;
- #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String;
-
- #[test]
- fn test_misc() {
- let rng: &mut dyn RngCore = &mut crate::test::rng(820);
-
- rng.sample::<char, _>(Standard);
- rng.sample::<bool, _>(Standard);
- }
-
- #[cfg(feature="alloc")]
- #[test]
- fn test_chars() {
- use core::iter;
- let mut rng = crate::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 = crate::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 edc9122..0000000
--- a/rand/src/distributions/pareto.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.
-
-//! The Pareto distribution.
-#![allow(deprecated)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, OpenClosed01};
-
-/// Samples floating-point numbers according to the Pareto distribution
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::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 = crate::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 9fd6e99..0000000
--- a/rand/src/distributions/poisson.rs
+++ /dev/null
@@ -1,151 +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.
-#![allow(deprecated)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, Cauchy};
-use crate::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`.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::distributions::Distribution;
- use super::Poisson;
-
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_poisson_10() {
- let poisson = Poisson::new(10.0);
- let mut rng = crate::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]
- #[cfg(not(miri))] // Miri doesn't support transcendental functions
- fn test_poisson_15() {
- // Take the 'high expected values' path
- let poisson = Poisson::new(15.0);
- let mut rng = crate::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 3e8f8b0..0000000
--- a/rand/src/distributions/triangular.rs
+++ /dev/null
@@ -1,79 +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.
-#![allow(deprecated)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, Standard};
-
-/// The triangular distribution.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::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 = crate::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 8c90f4e..0000000
--- a/rand/src/distributions/uniform.rs
+++ /dev/null
@@ -1,1270 +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());
-//! ```
-//!
-//! [`SampleUniform`]: crate::distributions::uniform::SampleUniform
-//! [`UniformSampler`]: crate::distributions::uniform::UniformSampler
-//! [`UniformInt`]: crate::distributions::uniform::UniformInt
-//! [`UniformFloat`]: crate::distributions::uniform::UniformFloat
-//! [`UniformDuration`]: crate::distributions::uniform::UniformDuration
-//! [`SampleBorrow::borrow`]: crate::distributions::uniform::SampleBorrow::borrow
-
-#[cfg(feature = "std")]
-use std::time::Duration;
-#[cfg(not(feature = "std"))]
-use core::time::Duration;
-
-use crate::Rng;
-use crate::distributions::Distribution;
-use crate::distributions::float::IntoFloat;
-use crate::distributions::utils::{WideningMultiply, FloatSIMDUtils, FloatAsSIMD, BoolAsSIMD};
-
-#[cfg(not(feature = "std"))]
-#[allow(unused_imports)] // rustc doesn't detect that this is actually used
-use crate::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);
-/// }
-/// ```
-///
-/// [`new`]: Uniform::new
-/// [`new_inclusive`]: Uniform::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.
-///
-/// [module documentation]: crate::distributions::uniform
-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]: crate::distributions::uniform
-/// [`sample_single`]: UniformSampler::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)`.
- ///
- /// By default this is implemented using
- /// `UniformSampler::new(low, high).sample(rng)`. However, for some types
- /// more optimal implementations for single usage may be provided via this
- /// method (which is the case for integers and floats).
- /// Results may not be identical.
- 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)
- }
-}
-
-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`]: std::borrow::Borrow
-pub trait SampleBorrow<Borrowed> {
- /// Immutably borrows from an owned value. See [`Borrow::borrow`]
- ///
- /// [`Borrow::borrow`]: std::borrow::Borrow::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 simplicity, we use the same generic struct `UniformInt<X>` for all
-/// integer types `X`. This gives us only one field type, `X`; to store unsigned
-/// values of this size, we take use the fact that these conversions are no-ops.
-///
-/// For a closed range, the number of possible numbers we should generate is
-/// `range = (high - low + 1)`. To avoid bias, we must ensure that the size of
-/// our sample space, `zone`, is a multiple of `range`; other values must be
-/// rejected (by replacing with a new random sample).
-///
-/// As a special case, we use `range = 0` to represent the full range of the
-/// result type (i.e. for `new_inclusive($ty::MIN, $ty::MAX)`).
-///
-/// The optimum `zone` is the largest product of `range` which fits in our
-/// (unsigned) target type. We calculate this by calculating how many numbers we
-/// must reject: `reject = (MAX + 1) % range = (MAX - range + 1) % range`. Any (large)
-/// product of `range` will suffice, thus in `sample_single` we multiply by a
-/// power of 2 via bit-shifting (faster but may cause more rejections).
-///
-/// The smallest integer PRNGs generate is `u32`. For 8- and 16-bit outputs we
-/// use `u32` for our `zone` and samples (because it's not slower and because
-/// it reduces the chance of having to reject a sample). In this case we cannot
-/// store `zone` in the target type since it is too large, however we know
-/// `ints_to_reject < range <= $unsigned::MAX`.
-///
-/// 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.
-#[derive(Clone, Copy, Debug)]
-pub struct UniformInt<X> {
- low: X,
- range: X,
- z: X, // either ints_to_reject or zone depending on implementation
-}
-
-macro_rules! uniform_int_impl {
- ($ty:ty, $unsigned: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::$u_large::MAX;
-
- let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned;
- let ints_to_reject =
- if range > 0 {
- let range = $u_large::from(range);
- (unsigned_max - range + 1) % range
- } else {
- 0
- };
-
- UniformInt {
- low: low,
- // These are really $unsigned values, but store as $ty:
- range: range as $ty,
- z: ints_to_reject as $unsigned 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 {
- let unsigned_max = ::core::$u_large::MAX;
- let zone = unsigned_max - (self.z as $unsigned 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,
- "UniformSampler::sample_single: 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, u8, u32 }
-uniform_int_impl! { i16, u16, u32 }
-uniform_int_impl! { i32, u32, u32 }
-uniform_int_impl! { i64, u64, u64 }
-#[cfg(not(target_os = "emscripten"))]
-uniform_int_impl! { i128, u128, u128 }
-uniform_int_impl! { isize, usize, usize }
-uniform_int_impl! { u8, u8, u32 }
-uniform_int_impl! { u16, u16, u32 }
-uniform_int_impl! { u32, u32, u32 }
-uniform_int_impl! { u64, u64, u64 }
-uniform_int_impl! { usize, usize, usize }
-#[cfg(not(target_os = "emscripten"))]
-uniform_int_impl! { u128, u128, 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(),
- z: zone.cast(),
- }
- }
-
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::X {
- let range: $unsigned = self.range.cast();
- let zone: $unsigned = self.z.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`.
-///
-/// [`new`]: UniformSampler::new
-/// [`new_inclusive`]: UniformSampler::new_inclusive
-/// [`Standard`]: crate::distributions::Standard
-#[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),
- "UniformSampler::sample_single: 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: low and high must be finite");
- 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.
-#[derive(Clone, Copy, Debug)]
-pub struct UniformDuration {
- mode: UniformDurationMode,
- offset: u32,
-}
-
-#[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>,
- }
-}
-
-impl SampleUniform for Duration {
- type Sampler = UniformDuration;
-}
-
-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 -= 1;
- 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(u64::from(high_n)));
-
- if let Some(higher_bound) = max {
- let lower_bound = low_s * 1_000_000_000 + u64::from(low_n);
- 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 crate::Rng;
- use crate::rngs::mock::StepRng;
- use crate::distributions::uniform::Uniform;
- use crate::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 = crate::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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_integers() {
- use core::{i8, i16, i32, i64, isize};
- use core::{u8, u16, u32, u64, usize};
- #[cfg(not(target_os = "emscripten"))]
- use core::{i128, u128};
-
- let mut rng = crate::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(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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_floats() {
- let mut rng = crate::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")))]
- #[cfg(not(miri))] // Miri does not support catching panics
- fn test_float_assertions() {
- use std::panic::catch_unwind;
- use super::SampleUniform;
- fn range<T: SampleUniform>(low: T, high: T) {
- let mut rng = crate::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(not(miri))] // Miri is too slow
- fn test_durations() {
- #[cfg(feature = "std")]
- use std::time::Duration;
- #[cfg(not(feature = "std"))]
- use core::time::Duration;
-
- let mut rng = crate::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 crate::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 = crate::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);
- }
-
- #[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 56e75b6..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.
-
-#![allow(deprecated)]
-#![allow(clippy::all)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, Uniform};
-
-/// Samples uniformly from the edge of the unit circle in two dimensions.
-///
-/// Implemented via a method by von Neumann[^1].
-///
-/// [^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.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::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 = crate::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 = crate::test::rng(2);
- let expected = [
- [-0.9965658683520504, -0.08280380447614634],
- [-0.9790853270389644, -0.20345004884984505],
- [-0.8449189758898707, 0.5348943112253227],
- ];
- let samples = [
- UnitCircle.sample(&mut rng),
- UnitCircle.sample(&mut rng),
- UnitCircle.sample(&mut rng),
- ];
- assert_eq!(samples, expected);
- }
-}
diff --git a/rand/src/distributions/unit_sphere.rs b/rand/src/distributions/unit_sphere.rs
deleted file mode 100644
index 188f48c..0000000
--- a/rand/src/distributions/unit_sphere.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.
-
-#![allow(deprecated)]
-#![allow(clippy::all)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, Uniform};
-
-/// Samples uniformly from the surface of the unit sphere in three dimensions.
-///
-/// Implemented via a method by Marsaglia[^1].
-///
-/// [^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.
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::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 = crate::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 = crate::test::rng(2);
- let expected = [
- [0.03247542860231647, -0.7830477442152738, 0.6211131755296027],
- [-0.09978440840914075, 0.9706650829833128, -0.21875184231323952],
- [0.2735582468624679, 0.9435374242279655, -0.1868234852870203],
- ];
- let samples = [
- UnitSphereSurface.sample(&mut rng),
- UnitSphereSurface.sample(&mut rng),
- UnitSphereSurface.sample(&mut rng),
- ];
- assert_eq!(samples, expected);
- }
-}
diff --git a/rand/src/distributions/utils.rs b/rand/src/distributions/utils.rs
deleted file mode 100644
index 3af4e86..0000000
--- a/rand/src/distributions/utils.rs
+++ /dev/null
@@ -1,488 +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 crate::distributions::ziggurat_tables;
-#[cfg(feature="std")]
-use crate::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(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(target_os = "emscripten")]
-wmul_impl_large! { u64, 32 }
-#[cfg(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 {
- fn is_nan(self) -> bool;
- fn is_infinite(self) -> bool;
- fn is_finite(self) -> bool;
-}
-
-/// 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 {
- #[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())
- }
- }
-
- 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;
- #[inline]
- 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 crate::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 483714f..0000000
--- a/rand/src/distributions/weibull.rs
+++ /dev/null
@@ -1,64 +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.
-#![allow(deprecated)]
-
-use crate::Rng;
-use crate::distributions::{Distribution, OpenClosed01};
-
-/// Samples floating-point numbers according to the Weibull distribution
-#[deprecated(since="0.7.0", note="moved to rand_distr crate")]
-#[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 crate::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 = crate::test::rng(1);
- for _ in 0..1000 {
- let r = d.sample(&mut rng);
- assert!(r >= 0.);
- }
- }
-}
diff --git a/rand/src/distributions/weighted/alias_method.rs b/rand/src/distributions/weighted/alias_method.rs
deleted file mode 100644
index bdd4ba0..0000000
--- a/rand/src/distributions/weighted/alias_method.rs
+++ /dev/null
@@ -1,499 +0,0 @@
-//! This module contains an implementation of alias method for sampling random
-//! indices with probabilities proportional to a collection of weights.
-
-use super::WeightedError;
-#[cfg(not(feature = "std"))]
-use crate::alloc::vec::Vec;
-#[cfg(not(feature = "std"))]
-use crate::alloc::vec;
-use core::fmt;
-use core::iter::Sum;
-use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
-use crate::distributions::uniform::SampleUniform;
-use crate::distributions::Distribution;
-use crate::distributions::Uniform;
-use crate::Rng;
-
-/// A distribution using weighted sampling to pick a discretely selected item.
-///
-/// Sampling a [`WeightedIndex<W>`] distribution returns the index of a randomly
-/// selected element from the vector used to create the [`WeightedIndex<W>`].
-/// The chance of a given element being picked is proportional to the value of
-/// the element. The weights can have any type `W` for which a implementation of
-/// [`Weight`] exists.
-///
-/// # Performance
-///
-/// Given that `n` is the number of items in the vector used to create an
-/// [`WeightedIndex<W>`], [`WeightedIndex<W>`] will require `O(n)` amount of
-/// memory. More specifically it takes up some constant amount of memory plus
-/// the vector used to create it and a [`Vec<u32>`] with capacity `n`.
-///
-/// Time complexity for the creation of a [`WeightedIndex<W>`] is `O(n)`.
-/// Sampling is `O(1)`, it makes a call to [`Uniform<u32>::sample`] and a call
-/// to [`Uniform<W>::sample`].
-///
-/// # Example
-///
-/// ```
-/// use rand::distributions::weighted::alias_method::WeightedIndex;
-/// use rand::prelude::*;
-///
-/// let choices = vec!['a', 'b', 'c'];
-/// let weights = vec![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).collect()).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);
-/// }
-/// ```
-///
-/// [`WeightedIndex<W>`]: crate::distributions::weighted::alias_method::WeightedIndex
-/// [`Weight`]: crate::distributions::weighted::alias_method::Weight
-/// [`Vec<u32>`]: Vec
-/// [`Uniform<u32>::sample`]: Distribution::sample
-/// [`Uniform<W>::sample`]: Distribution::sample
-pub struct WeightedIndex<W: Weight> {
- aliases: Vec<u32>,
- no_alias_odds: Vec<W>,
- uniform_index: Uniform<u32>,
- uniform_within_weight_sum: Uniform<W>,
-}
-
-impl<W: Weight> WeightedIndex<W> {
- /// Creates a new [`WeightedIndex`].
- ///
- /// Returns an error if:
- /// - The vector is empty.
- /// - The vector is longer than `u32::MAX`.
- /// - For any weight `w`: `w < 0` or `w > max` where `max = W::MAX /
- /// weights.len()`.
- /// - The sum of weights is zero.
- pub fn new(weights: Vec<W>) -> Result<Self, WeightedError> {
- let n = weights.len();
- if n == 0 {
- return Err(WeightedError::NoItem);
- } else if n > ::core::u32::MAX as usize {
- return Err(WeightedError::TooMany);
- }
- let n = n as u32;
-
- let max_weight_size = W::try_from_u32_lossy(n)
- .map(|n| W::MAX / n)
- .unwrap_or(W::ZERO);
- if !weights
- .iter()
- .all(|&w| W::ZERO <= w && w <= max_weight_size)
- {
- return Err(WeightedError::InvalidWeight);
- }
-
- // The sum of weights will represent 100% of no alias odds.
- let weight_sum = Weight::sum(weights.as_slice());
- // Prevent floating point overflow due to rounding errors.
- let weight_sum = if weight_sum > W::MAX {
- W::MAX
- } else {
- weight_sum
- };
- if weight_sum == W::ZERO {
- return Err(WeightedError::AllWeightsZero);
- }
-
- // `weight_sum` would have been zero if `try_from_lossy` causes an error here.
- let n_converted = W::try_from_u32_lossy(n).unwrap();
-
- let mut no_alias_odds = weights;
- for odds in no_alias_odds.iter_mut() {
- *odds *= n_converted;
- // Prevent floating point overflow due to rounding errors.
- *odds = if *odds > W::MAX { W::MAX } else { *odds };
- }
-
- /// This struct is designed to contain three data structures at once,
- /// sharing the same memory. More precisely it contains two linked lists
- /// and an alias map, which will be the output of this method. To keep
- /// the three data structures from getting in each other's way, it must
- /// be ensured that a single index is only ever in one of them at the
- /// same time.
- struct Aliases {
- aliases: Vec<u32>,
- smalls_head: u32,
- bigs_head: u32,
- }
-
- impl Aliases {
- fn new(size: u32) -> Self {
- Aliases {
- aliases: vec![0; size as usize],
- smalls_head: ::core::u32::MAX,
- bigs_head: ::core::u32::MAX,
- }
- }
-
- fn push_small(&mut self, idx: u32) {
- self.aliases[idx as usize] = self.smalls_head;
- self.smalls_head = idx;
- }
-
- fn push_big(&mut self, idx: u32) {
- self.aliases[idx as usize] = self.bigs_head;
- self.bigs_head = idx;
- }
-
- fn pop_small(&mut self) -> u32 {
- let popped = self.smalls_head;
- self.smalls_head = self.aliases[popped as usize];
- popped
- }
-
- fn pop_big(&mut self) -> u32 {
- let popped = self.bigs_head;
- self.bigs_head = self.aliases[popped as usize];
- popped
- }
-
- fn smalls_is_empty(&self) -> bool {
- self.smalls_head == ::core::u32::MAX
- }
-
- fn bigs_is_empty(&self) -> bool {
- self.bigs_head == ::core::u32::MAX
- }
-
- fn set_alias(&mut self, idx: u32, alias: u32) {
- self.aliases[idx as usize] = alias;
- }
- }
-
- let mut aliases = Aliases::new(n);
-
- // Split indices into those with small weights and those with big weights.
- for (index, &odds) in no_alias_odds.iter().enumerate() {
- if odds < weight_sum {
- aliases.push_small(index as u32);
- } else {
- aliases.push_big(index as u32);
- }
- }
-
- // Build the alias map by finding an alias with big weight for each index with
- // small weight.
- while !aliases.smalls_is_empty() && !aliases.bigs_is_empty() {
- let s = aliases.pop_small();
- let b = aliases.pop_big();
-
- aliases.set_alias(s, b);
- no_alias_odds[b as usize] = no_alias_odds[b as usize]
- - weight_sum
- + no_alias_odds[s as usize];
-
- if no_alias_odds[b as usize] < weight_sum {
- aliases.push_small(b);
- } else {
- aliases.push_big(b);
- }
- }
-
- // The remaining indices should have no alias odds of about 100%. This is due to
- // numeric accuracy. Otherwise they would be exactly 100%.
- while !aliases.smalls_is_empty() {
- no_alias_odds[aliases.pop_small() as usize] = weight_sum;
- }
- while !aliases.bigs_is_empty() {
- no_alias_odds[aliases.pop_big() as usize] = weight_sum;
- }
-
- // Prepare distributions for sampling. Creating them beforehand improves
- // sampling performance.
- let uniform_index = Uniform::new(0, n);
- let uniform_within_weight_sum = Uniform::new(W::ZERO, weight_sum);
-
- Ok(Self {
- aliases: aliases.aliases,
- no_alias_odds,
- uniform_index,
- uniform_within_weight_sum,
- })
- }
-}
-
-impl<W: Weight> Distribution<usize> for WeightedIndex<W> {
- fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
- let candidate = rng.sample(self.uniform_index);
- if rng.sample(&self.uniform_within_weight_sum) < self.no_alias_odds[candidate as usize] {
- candidate as usize
- } else {
- self.aliases[candidate as usize] as usize
- }
- }
-}
-
-impl<W: Weight> fmt::Debug for WeightedIndex<W>
-where
- W: fmt::Debug,
- Uniform<W>: fmt::Debug,
-{
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("WeightedIndex")
- .field("aliases", &self.aliases)
- .field("no_alias_odds", &self.no_alias_odds)
- .field("uniform_index", &self.uniform_index)
- .field("uniform_within_weight_sum", &self.uniform_within_weight_sum)
- .finish()
- }
-}
-
-impl<W: Weight> Clone for WeightedIndex<W>
-where
- Uniform<W>: Clone,
-{
- fn clone(&self) -> Self {
- Self {
- aliases: self.aliases.clone(),
- no_alias_odds: self.no_alias_odds.clone(),
- uniform_index: self.uniform_index.clone(),
- uniform_within_weight_sum: self.uniform_within_weight_sum.clone(),
- }
- }
-}
-
-/// Trait that must be implemented for weights, that are used with
-/// [`WeightedIndex`]. Currently no guarantees on the correctness of
-/// [`WeightedIndex`] are given for custom implementations of this trait.
-pub trait Weight:
- Sized
- + Copy
- + SampleUniform
- + PartialOrd
- + Add<Output = Self>
- + AddAssign
- + Sub<Output = Self>
- + SubAssign
- + Mul<Output = Self>
- + MulAssign
- + Div<Output = Self>
- + DivAssign
- + Sum
-{
- /// Maximum number representable by `Self`.
- const MAX: Self;
-
- /// Element of `Self` equivalent to 0.
- const ZERO: Self;
-
- /// Produce an instance of `Self` from a `u32` value, or return `None` if
- /// out of range. Loss of precision (where `Self` is a floating point type)
- /// is acceptable.
- fn try_from_u32_lossy(n: u32) -> Option<Self>;
-
- /// Sums all values in slice `values`.
- fn sum(values: &[Self]) -> Self {
- values.iter().map(|x| *x).sum()
- }
-}
-
-macro_rules! impl_weight_for_float {
- ($T: ident) => {
- impl Weight for $T {
- const MAX: Self = ::core::$T::MAX;
- const ZERO: Self = 0.0;
-
- fn try_from_u32_lossy(n: u32) -> Option<Self> {
- Some(n as $T)
- }
-
- fn sum(values: &[Self]) -> Self {
- pairwise_sum(values)
- }
- }
- };
-}
-
-/// In comparison to naive accumulation, the pairwise sum algorithm reduces
-/// rounding errors when there are many floating point values.
-fn pairwise_sum<T: Weight>(values: &[T]) -> T {
- if values.len() <= 32 {
- values.iter().map(|x| *x).sum()
- } else {
- let mid = values.len() / 2;
- let (a, b) = values.split_at(mid);
- pairwise_sum(a) + pairwise_sum(b)
- }
-}
-
-macro_rules! impl_weight_for_int {
- ($T: ident) => {
- impl Weight for $T {
- const MAX: Self = ::core::$T::MAX;
- const ZERO: Self = 0;
-
- fn try_from_u32_lossy(n: u32) -> Option<Self> {
- let n_converted = n as Self;
- if n_converted >= Self::ZERO && n_converted as u32 == n {
- Some(n_converted)
- } else {
- None
- }
- }
- }
- };
-}
-
-impl_weight_for_float!(f64);
-impl_weight_for_float!(f32);
-impl_weight_for_int!(usize);
-#[cfg(not(target_os = "emscripten"))]
-impl_weight_for_int!(u128);
-impl_weight_for_int!(u64);
-impl_weight_for_int!(u32);
-impl_weight_for_int!(u16);
-impl_weight_for_int!(u8);
-impl_weight_for_int!(isize);
-#[cfg(not(target_os = "emscripten"))]
-impl_weight_for_int!(i128);
-impl_weight_for_int!(i64);
-impl_weight_for_int!(i32);
-impl_weight_for_int!(i16);
-impl_weight_for_int!(i8);
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weighted_index_f32() {
- test_weighted_index(f32::into);
-
- // Floating point special cases
- assert_eq!(
- WeightedIndex::new(vec![::core::f32::INFINITY]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- assert_eq!(
- WeightedIndex::new(vec![-0_f32]).unwrap_err(),
- WeightedError::AllWeightsZero
- );
- assert_eq!(
- WeightedIndex::new(vec![-1_f32]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- assert_eq!(
- WeightedIndex::new(vec![-::core::f32::INFINITY]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- assert_eq!(
- WeightedIndex::new(vec![::core::f32::NAN]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- }
-
- #[cfg(not(target_os = "emscripten"))]
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weighted_index_u128() {
- test_weighted_index(|x: u128| x as f64);
- }
-
- #[cfg(all(rustc_1_26, not(target_os = "emscripten")))]
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weighted_index_i128() {
- test_weighted_index(|x: i128| x as f64);
-
- // Signed integer special cases
- assert_eq!(
- WeightedIndex::new(vec![-1_i128]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- assert_eq!(
- WeightedIndex::new(vec![::core::i128::MIN]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- }
-
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weighted_index_u8() {
- test_weighted_index(u8::into);
- }
-
- #[test]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weighted_index_i8() {
- test_weighted_index(i8::into);
-
- // Signed integer special cases
- assert_eq!(
- WeightedIndex::new(vec![-1_i8]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- assert_eq!(
- WeightedIndex::new(vec![::core::i8::MIN]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- }
-
- fn test_weighted_index<W: Weight, F: Fn(W) -> f64>(w_to_f64: F)
- where
- WeightedIndex<W>: fmt::Debug,
- {
- const NUM_WEIGHTS: u32 = 10;
- const ZERO_WEIGHT_INDEX: u32 = 3;
- const NUM_SAMPLES: u32 = 15000;
- let mut rng = crate::test::rng(0x9c9fa0b0580a7031);
-
- let weights = {
- let mut weights = Vec::with_capacity(NUM_WEIGHTS as usize);
- let random_weight_distribution = crate::distributions::Uniform::new_inclusive(
- W::ZERO,
- W::MAX / W::try_from_u32_lossy(NUM_WEIGHTS).unwrap(),
- );
- for _ in 0..NUM_WEIGHTS {
- weights.push(rng.sample(&random_weight_distribution));
- }
- weights[ZERO_WEIGHT_INDEX as usize] = W::ZERO;
- weights
- };
- let weight_sum = weights.iter().map(|w| *w).sum::<W>();
- let expected_counts = weights
- .iter()
- .map(|&w| w_to_f64(w) / w_to_f64(weight_sum) * NUM_SAMPLES as f64)
- .collect::<Vec<f64>>();
- let weight_distribution = WeightedIndex::new(weights).unwrap();
-
- let mut counts = vec![0; NUM_WEIGHTS as usize];
- for _ in 0..NUM_SAMPLES {
- counts[rng.sample(&weight_distribution)] += 1;
- }
-
- assert_eq!(counts[ZERO_WEIGHT_INDEX as usize], 0);
- for (count, expected_count) in counts.into_iter().zip(expected_counts) {
- let difference = (count as f64 - expected_count).abs();
- let max_allowed_difference = NUM_SAMPLES as f64 / NUM_WEIGHTS as f64 * 0.1;
- assert!(difference <= max_allowed_difference);
- }
-
- assert_eq!(
- WeightedIndex::<W>::new(vec![]).unwrap_err(),
- WeightedError::NoItem
- );
- assert_eq!(
- WeightedIndex::new(vec![W::ZERO]).unwrap_err(),
- WeightedError::AllWeightsZero
- );
- assert_eq!(
- WeightedIndex::new(vec![W::MAX, W::MAX]).unwrap_err(),
- WeightedError::InvalidWeight
- );
- }
-}
diff --git a/rand/src/distributions/weighted/mod.rs b/rand/src/distributions/weighted/mod.rs
deleted file mode 100644
index 2711637..0000000
--- a/rand/src/distributions/weighted/mod.rs
+++ /dev/null
@@ -1,363 +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.
-
-//! Weighted index sampling
-//!
-//! This module provides two implementations for sampling indices:
-//!
-//! * [`WeightedIndex`] allows `O(log N)` sampling
-//! * [`alias_method::WeightedIndex`] allows `O(1)` sampling, but with
-//! much greater set-up cost
-//!
-//! [`alias_method::WeightedIndex`]: alias_method/struct.WeightedIndex.html
-
-pub mod alias_method;
-
-use crate::Rng;
-use crate::distributions::Distribution;
-use crate::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 crate::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` (method of the [`Distribution`] trait), 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>`]: crate::distributions::uniform::Uniform
-/// [`RngCore`]: crate::RngCore
-#[derive(Debug, Clone)]
-pub struct WeightedIndex<X: SampleUniform + PartialOrd> {
- cumulative_weights: Vec<X>,
- total_weight: 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.
- ///
- /// [`Uniform<X>`]: crate::distributions::uniform::Uniform
- 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::InvalidWeight);
- }
-
- let mut weights = Vec::<X>::with_capacity(iter.size_hint().0);
- for w in iter {
- if *w.borrow() < zero {
- return Err(WeightedError::InvalidWeight);
- }
- 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.clone());
-
- Ok(WeightedIndex { cumulative_weights: weights, total_weight, weight_distribution: distr })
- }
-
- /// Update a subset of weights, without changing the number of weights.
- ///
- /// `new_weights` must be sorted by the index.
- ///
- /// Using this method instead of `new` might be more efficient if only a small number of
- /// weights is modified. No allocations are performed, unless the weight type `X` uses
- /// allocation internally.
- ///
- /// In case of error, `self` is not modified.
- pub fn update_weights(&mut self, new_weights: &[(usize, &X)]) -> Result<(), WeightedError>
- where X: for<'a> ::core::ops::AddAssign<&'a X> +
- for<'a> ::core::ops::SubAssign<&'a X> +
- Clone +
- Default {
- if new_weights.is_empty() {
- return Ok(());
- }
-
- let zero = <X as Default>::default();
-
- let mut total_weight = self.total_weight.clone();
-
- // Check for errors first, so we don't modify `self` in case something
- // goes wrong.
- let mut prev_i = None;
- for &(i, w) in new_weights {
- if let Some(old_i) = prev_i {
- if old_i >= i {
- return Err(WeightedError::InvalidWeight);
- }
- }
- if *w < zero {
- return Err(WeightedError::InvalidWeight);
- }
- if i >= self.cumulative_weights.len() + 1 {
- return Err(WeightedError::TooMany);
- }
-
- let mut old_w = if i < self.cumulative_weights.len() {
- self.cumulative_weights[i].clone()
- } else {
- self.total_weight.clone()
- };
- if i > 0 {
- old_w -= &self.cumulative_weights[i - 1];
- }
-
- total_weight -= &old_w;
- total_weight += w;
- prev_i = Some(i);
- }
- if total_weight == zero {
- return Err(WeightedError::AllWeightsZero);
- }
-
- // Update the weights. Because we checked all the preconditions in the
- // previous loop, this should never panic.
- let mut iter = new_weights.iter();
-
- let mut prev_weight = zero.clone();
- let mut next_new_weight = iter.next();
- let &(first_new_index, _) = next_new_weight.unwrap();
- let mut cumulative_weight = if first_new_index > 0 {
- self.cumulative_weights[first_new_index - 1].clone()
- } else {
- zero.clone()
- };
- for i in first_new_index..self.cumulative_weights.len() {
- match next_new_weight {
- Some(&(j, w)) if i == j => {
- cumulative_weight += w;
- next_new_weight = iter.next();
- },
- _ => {
- let mut tmp = self.cumulative_weights[i].clone();
- tmp -= &prev_weight; // We know this is positive.
- cumulative_weight += &tmp;
- }
- }
- prev_weight = cumulative_weight.clone();
- core::mem::swap(&mut prev_weight, &mut self.cumulative_weights[i]);
- }
-
- self.total_weight = total_weight;
- self.weight_distribution = X::Sampler::new(zero, self.total_weight.clone());
-
- Ok(())
- }
-}
-
-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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weightedindex() {
- let mut r = crate::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::InvalidWeight);
- assert_eq!(WeightedIndex::new(&[-10, 20, 1, 30]).unwrap_err(), WeightedError::InvalidWeight);
- assert_eq!(WeightedIndex::new(&[-10]).unwrap_err(), WeightedError::InvalidWeight);
- }
-
- #[test]
- fn test_update_weights() {
- let data = [
- (&[10u32, 2, 3, 4][..],
- &[(1, &100), (2, &4)][..], // positive change
- &[10, 100, 4, 4][..]),
- (&[1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7][..],
- &[(2, &1), (5, &1), (13, &100)][..], // negative change and last element
- &[1u32, 2, 1, 0, 5, 1, 7, 1, 2, 3, 4, 5, 6, 100][..]),
- ];
-
- for (weights, update, expected_weights) in data.into_iter() {
- let total_weight = weights.iter().sum::<u32>();
- let mut distr = WeightedIndex::new(weights.to_vec()).unwrap();
- assert_eq!(distr.total_weight, total_weight);
-
- distr.update_weights(update).unwrap();
- let expected_total_weight = expected_weights.iter().sum::<u32>();
- let expected_distr = WeightedIndex::new(expected_weights.to_vec()).unwrap();
- assert_eq!(distr.total_weight, expected_total_weight);
- assert_eq!(distr.total_weight, expected_distr.total_weight);
- assert_eq!(distr.cumulative_weights, expected_distr.cumulative_weights);
- }
- }
-}
-
-/// Error type returned from `WeightedIndex::new`.
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum WeightedError {
- /// The provided weight collection contains no items.
- NoItem,
-
- /// A weight is either less than zero, greater than the supported maximum or
- /// otherwise invalid.
- InvalidWeight,
-
- /// All items in the provided weight collection are zero.
- AllWeightsZero,
-
- /// Too many weights are provided (length greater than `u32::MAX`)
- TooMany,
-}
-
-impl WeightedError {
- fn msg(&self) -> &str {
- match *self {
- WeightedError::NoItem => "No weights provided.",
- WeightedError::InvalidWeight => "A weight is invalid.",
- WeightedError::AllWeightsZero => "All weights are zero.",
- WeightedError::TooMany => "Too many weights (hit u32::MAX)",
- }
- }
-}
-
-#[cfg(feature="std")]
-impl ::std::error::Error for WeightedError {
- fn description(&self) -> &str {
- self.msg()
- }
- fn cause(&self) -> Option<&dyn (::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 b4167c3..0000000
--- a/rand/src/lib.rs
+++ /dev/null
@@ -1,720 +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`] and [`seq`] modules 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).
-
-
-#![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="simd_support", feature="nightly"), feature(stdsimd))]
-
-#![allow(clippy::excessive_precision, clippy::unreadable_literal, clippy::float_cmp)]
-
-#[cfg(all(feature="alloc", not(feature="std")))]
-extern crate alloc;
-
-#[cfg(feature = "getrandom")]
-use getrandom_package as getrandom;
-
-#[allow(unused)]
-macro_rules! trace { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::trace!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! debug { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::debug!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! info { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::info!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! warn { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::warn!($($x)*)
- }
-) }
-#[allow(unused)]
-macro_rules! error { ($($x:tt)*) => (
- #[cfg(feature = "log")] {
- log::error!($($x)*)
- }
-) }
-
-// Re-exports from rand_core
-pub use rand_core::{RngCore, CryptoRng, SeedableRng, Error};
-
-// Public exports
-#[cfg(feature="std")] pub use crate::rngs::thread::thread_rng;
-
-// Public modules
-pub mod distributions;
-pub mod prelude;
-pub mod rngs;
-pub mod seq;
-
-
-use core::{mem, slice};
-use core::num::Wrapping;
-use crate::distributions::{Distribution, Standard};
-use crate::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());
-/// ```
-pub trait Rng: RngCore {
- /// Return a random value supporting the [`Standard`] distribution.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut rng = thread_rng();
- /// let x: u32 = rng.gen();
- /// println!("{}", x);
- /// println!("{:?}", rng.gen::<(f64, bool)>());
- /// ```
- ///
- /// # Arrays and tuples
- ///
- /// The `rng.gen()` method is able to generate arrays (up to 32 elements)
- /// and tuples (up to 12 elements), so long as all element types can be
- /// generated.
- ///
- /// For arrays of integers, especially for those with small element types
- /// (< 64 bit), it will likely be faster to instead use [`Rng::fill`].
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- ///
- /// let mut rng = thread_rng();
- /// let tuple: (u8, i32, char) = rng.gen(); // arbitrary tuple support
- ///
- /// let arr1: [f32; 32] = rng.gen(); // array construction
- /// let mut arr2 = [0u8; 128];
- /// rng.fill(&mut arr2); // array fill
- /// ```
- ///
- /// [`Standard`]: distributions::Standard
- #[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::Uniform
- 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.
- ///
- /// Note that this function takes its arguments by value. This works since
- /// `(&mut R): Rng where R: Rng` and
- /// `(&D): Distribution where D: Distribution`,
- /// however borrowing is not automatic hence `rng.sample_iter(...)` may
- /// need to be replaced with `(&mut rng).sample_iter(...)`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::{thread_rng, Rng};
- /// use rand::distributions::{Alphanumeric, Uniform, Standard};
- ///
- /// let rng = thread_rng();
- ///
- /// // Vec of 16 x f32:
- /// let v: Vec<f32> = rng.sample_iter(Standard).take(16).collect();
- ///
- /// // String:
- /// let s: String = rng.sample_iter(Alphanumeric).take(7).collect();
- ///
- /// // Combined values
- /// println!("{:?}", 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<T, D>(self, distr: D) -> distributions::DistIter<D, Self, T>
- where D: Distribution<T>, 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`]: RngCore::fill_bytes
- /// [`try_fill`]: Rng::try_fill
- 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 is identical to [`fill`] except that it uses [`try_fill_bytes`]
- /// internally and forwards RNG errors.
- ///
- /// # 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()
- /// ```
- ///
- /// [`try_fill_bytes`]: RngCore::try_fill_bytes
- /// [`fill`]: Rng::fill
- 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::Bernoulli
- #[inline]
- fn gen_bool(&mut self, p: f64) -> bool {
- let d = distributions::Bernoulli::new(p).unwrap();
- 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::Bernoulli
- #[inline]
- fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool {
- let d = distributions::Bernoulli::from_ratio(numerator, denominator).unwrap();
- self.sample(d)
- }
-}
-
-impl<R: RngCore + ?Sized> Rng for R {}
-
-/// Trait for casting types to byte slices
-///
-/// This is used by the [`Rng::fill`] and [`Rng::try_fill`] methods.
-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(self.as_mut_ptr()
- as *mut u8,
- self.len() * mem::size_of::<$t>()
- )
- }
- }
- }
-
- fn to_le(&mut self) {
- for x in self {
- *x = x.to_le();
- }
- }
- }
-
- impl AsByteSliceMut for [Wrapping<$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(self.as_mut_ptr()
- as *mut u8,
- self.len() * mem::size_of::<$t>()
- )
- }
- }
- }
-
- fn to_le(&mut self) {
- for x in self {
- *x = Wrapping(x.0.to_le());
- }
- }
- }
- };
- ($t:ty, $($tt:ty,)*) => {
- impl_as_byte_slice!($t);
- // TODO: this could replace above impl once Rust #32463 is fixed
- // impl_as_byte_slice!(Wrapping<$t>);
- impl_as_byte_slice!($($tt,)*);
- }
-}
-
-impl_as_byte_slice!(u16, u32, u64, usize,);
-#[cfg(not(target_os = "emscripten"))] impl_as_byte_slice!(u128);
-impl_as_byte_slice!(i8, i16, i32, i64, isize,);
-#[cfg(not(target_os = "emscripten"))] impl_as_byte_slice!(i128);
-
-macro_rules! impl_as_byte_slice_arrays {
- ($n:expr,) => {};
- ($n:expr, $N:ident) => {
- 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()
- }
- }
- };
- ($n:expr, $N:ident, $($NN:ident,)*) => {
- impl_as_byte_slice_arrays!($n, $N);
- impl_as_byte_slice_arrays!($n - 1, $($NN,)*);
- };
- (!div $n:expr,) => {};
- (!div $n:expr, $N:ident, $($NN:ident,)*) => {
- impl_as_byte_slice_arrays!($n, $N);
- impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*);
- };
-}
-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,);
-
-/// 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();
-/// }
-/// ```
-///
-/// [`Standard`]: distributions::Standard
-#[cfg(feature="std")]
-#[inline]
-pub fn random<T>() -> T
-where Standard: Distribution<T> {
- thread_rng().gen()
-}
-
-#[cfg(test)]
-mod test {
- use crate::rngs::mock::StepRng;
- use super::*;
- #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::boxed::Box;
-
- /// Construct a deterministic RNG with the given seed
- pub fn rng(seed: u64) -> impl RngCore {
- // For tests, we want a statistically good, fast, reproducible RNG.
- // PCG32 will do fine, and will be easy to embed if we ever need to.
- const INC: u64 = 11634580027462260723;
- rand_pcg::Pcg32::new(seed, INC)
- }
-
- #[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);
-
- // Check equivalence using wrapped arrays
- let mut warray = [Wrapping(0u32); 2];
- rng.fill(&mut warray[..]);
- assert_eq!(array[0], warray[0].0);
- assert_eq!(array[1], warray[1].0);
- }
-
- #[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 crate::distributions::{Distribution, Standard};
- let mut rng = rng(109);
- let mut r = &mut rng as &mut dyn 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 crate::distributions::{Distribution, Standard};
- let rng = rng(110);
- let mut r = Box::new(rng) as Box<dyn 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]
- #[cfg(not(miri))] // Miri is too slow
- 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 3c386e8..0000000
--- a/rand/src/prelude.rs
+++ /dev/null
@@ -1,28 +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 mut r = StdRng::from_rng(thread_rng()).unwrap();
-//! # let _: f32 = r.gen();
-//! ```
-
-#[doc(no_inline)] pub use crate::distributions::Distribution;
-#[doc(no_inline)] pub use crate::rngs::StdRng;
-#[cfg(feature="small_rng")]
-#[doc(no_inline)] pub use crate::rngs::SmallRng;
-#[doc(no_inline)] #[cfg(feature="std")] pub use crate::rngs::ThreadRng;
-#[doc(no_inline)] pub use crate::{Rng, RngCore, CryptoRng, SeedableRng};
-#[doc(no_inline)] #[cfg(feature="std")] pub use crate::{random, thread_rng};
-#[doc(no_inline)] pub use crate::seq::{SliceRandom, IteratorRandom};
diff --git a/rand/src/rngs/adapter/mod.rs b/rand/src/rngs/adapter/mod.rs
deleted file mode 100644
index 659ff26..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")] mod read;
-mod reseeding;
-
-#[cfg(feature="std")] pub use self::read::{ReadRng, ReadError};
-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 901462e..0000000
--- a/rand/src/rngs/adapter/read.rs
+++ /dev/null
@@ -1,148 +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 std::fmt;
-
-use rand_core::{RngCore, Error, 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::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`]: crate::rngs::OsRng
-/// [`try_fill_bytes`]: RngCore::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.is_empty() { return Ok(()); }
- // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`.
- self.reader.read_exact(dest).map_err(|e| Error::new(ReadError(e)))
- }
-}
-
-/// `ReadRng` error type
-#[derive(Debug)]
-pub struct ReadError(std::io::Error);
-
-impl fmt::Display for ReadError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "ReadError: {}", self.0)
- }
-}
-
-impl std::error::Error for ReadError {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- Some(&self.0)
- }
-}
-
-
-#[cfg(test)]
-mod test {
- use super::ReadRng;
- use crate::RngCore;
-
- #[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[..]);
-
- let result = rng.try_fill_bytes(&mut w);
- assert!(result.is_err());
- println!("Error: {}", result.unwrap_err());
- }
-}
diff --git a/rand/src/rngs/adapter/reseeding.rs b/rand/src/rngs/adapter/reseeding.rs
deleted file mode 100644
index ec88efe..0000000
--- a/rand/src/rngs/adapter/reseeding.rs
+++ /dev/null
@@ -1,357 +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};
-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 ChaCha and Hc128 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
-///
-/// ```
-/// use rand::prelude::*;
-/// use rand_chacha::ChaCha20Core; // Internal part of ChaChaRng that
-/// // implements BlockRngCore
-/// use rand::rngs::OsRng;
-/// use rand::rngs::adapter::ReseedingRng;
-///
-/// let prng = ChaCha20Core::from_entropy();
-/// let mut reseeding_rng = ReseedingRng::new(prng, 0, OsRng);
-///
-/// println!("{}", reseeding_rng.gen::<u64>());
-///
-/// let mut cloned_rng = reseeding_rng.clone();
-/// assert!(reseeding_rng.gen::<u64>() != cloned_rng.gen::<u64>());
-/// ```
-///
-/// [`BlockRngCore`]: rand_core::block::BlockRngCore
-/// [`ReseedingRng::new`]: ReseedingRng::new
-/// [`reseed()`]: ReseedingRng::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)
- {
- #![allow(clippy::if_same_then_else)] // false positive
- 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>();
-
- if let Err(e) = self.reseed() {
- warn!("Reseeding RNG failed: {}", e);
- let _ = e;
- }
- self.fork_counter = global_fork_counter;
-
- self.bytes_until_reseed = self.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(unix, not(target_os="emscripten")))]
-mod fork {
- use core::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
- #[allow(deprecated)] // Required for compatibility with Rust < 1.24.
- use core::sync::atomic::{ATOMIC_USIZE_INIT, 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.
-
- #[allow(deprecated)]
- static RESEEDING_RNG_FORK_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
-
- pub fn get_fork_counter() -> usize {
- RESEEDING_RNG_FORK_COUNTER.load(Ordering::Relaxed)
- }
-
- #[allow(deprecated)]
- 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) {
- unsafe { libc::pthread_atfork(None, None, Some(fork_handler)) };
- FORK_HANDLER_REGISTERED.store(true, Ordering::Relaxed);
- }
- }
-}
-
-#[cfg(not(all(unix, not(target_os="emscripten"))))]
-mod fork {
- pub fn get_fork_counter() -> usize { 0 }
- pub fn register_fork_handler() {}
-}
-
-
-#[cfg(test)]
-mod test {
- use crate::{Rng, SeedableRng};
- use crate::rngs::std::Core;
- use crate::rngs::mock::StepRng;
- use super::ReseedingRng;
-
- #[test]
- fn test_reseeding() {
- let mut zero = StepRng::new(0, 0);
- let rng = Core::from_rng(&mut zero).unwrap();
- let thresh = 1; // reseed every time the buffer is exhausted
- let mut reseeding = ReseedingRng::new(rng, thresh, zero);
-
- // RNG buffer size is [u32; 64]
- // Debug is only implemented up to length 32 so use two arrays
- let mut buf = ([0u32; 32], [0u32; 32]);
- reseeding.fill(&mut buf.0);
- reseeding.fill(&mut buf.1);
- let seq = buf;
- for _ in 0..10 {
- reseeding.fill(&mut buf.0);
- reseeding.fill(&mut buf.1);
- assert_eq!(buf, seq);
- }
- }
-
- #[test]
- fn test_clone_reseeding() {
- let mut zero = StepRng::new(0, 0);
- let rng = Core::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 1ed59ab..0000000
--- a/rand/src/rngs/entropy.rs
+++ /dev/null
@@ -1,76 +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
-
-#![allow(deprecated)] // whole module is deprecated
-
-use rand_core::{RngCore, CryptoRng, Error};
-use crate::rngs::OsRng;
-
-/// An interface returning random data from external source(s), provided
-/// specifically for securely seeding algorithmic generators (PRNGs).
-///
-/// This is deprecated. It is suggested you use [`rngs::OsRng`] instead.
-///
-/// [`rngs::OsRng`]: crate::rngs::OsRng
-#[derive(Debug)]
-#[deprecated(since="0.7.0", note="use rngs::OsRng instead")]
-pub struct EntropyRng {
- source: OsRng,
-}
-
-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: OsRng }
- }
-}
-
-impl Default for EntropyRng {
- fn default() -> Self {
- EntropyRng::new()
- }
-}
-
-impl RngCore for EntropyRng {
- fn next_u32(&mut self) -> u32 {
- self.source.next_u32()
- }
-
- fn next_u64(&mut self) -> u64 {
- self.source.next_u64()
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- self.source.fill_bytes(dest)
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.source.try_fill_bytes(dest)
- }
-}
-
-impl CryptoRng for EntropyRng {}
-
-
-#[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/mock.rs b/rand/src/rngs/mock.rs
deleted file mode 100644
index b4081da..0000000
--- a/rand/src/rngs/mock.rs
+++ /dev/null
@@ -1,64 +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 {
- #[inline]
- fn next_u32(&mut self) -> u32 {
- self.next_u64() as u32
- }
-
- #[inline]
- fn next_u64(&mut self) -> u64 {
- let result = self.v;
- self.v = self.v.wrapping_add(self.a);
- result
- }
-
- #[inline]
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- impls::fill_bytes_via_next(self, dest);
- }
-
- #[inline]
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- self.fill_bytes(dest);
- Ok(())
- }
-}
diff --git a/rand/src/rngs/mod.rs b/rand/src/rngs/mod.rs
deleted file mode 100644
index abf3243..0000000
--- a/rand/src/rngs/mod.rs
+++ /dev/null
@@ -1,119 +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
-//!
-//! ## Background: Random number generators (RNGs)
-//!
-//! Computers cannot produce random numbers from nowhere. We classify
-//! random number generators as follows:
-//!
-//! - "True" random number generators (TRNGs) use hard-to-predict data sources
-//! (e.g. the high-resolution parts of event timings and sensor jitter) to
-//! harvest random bit-sequences, apply algorithms to remove bias and
-//! estimate available entropy, then combine these bits into a byte-sequence
-//! or an entropy pool. This job is usually done by the operating system or
-//! a hardware generator (HRNG).
-//! - "Pseudo"-random number generators (PRNGs) use algorithms to transform a
-//! seed into a sequence of pseudo-random numbers. These generators can be
-//! fast and produce well-distributed unpredictable random numbers (or not).
-//! They are usually deterministic: given algorithm and seed, the output
-//! sequence can be reproduced. They have finite period and eventually loop;
-//! with many algorithms this period is fixed and can be proven sufficiently
-//! long, while others are chaotic and the period depends on the seed.
-//! - "Cryptographically secure" pseudo-random number generators (CSPRNGs)
-//! are the sub-set of PRNGs which are secure. Security of the generator
-//! relies both on hiding the internal state and using a strong algorithm.
-//!
-//! ## Traits and functionality
-//!
-//! All RNGs implement the [`RngCore`] trait, as a consequence of which the
-//! [`Rng`] extension trait is automatically implemented. Secure RNGs may
-//! additionally implement the [`CryptoRng`] trait.
-//!
-//! All PRNGs require a seed to produce their random number sequence. The
-//! [`SeedableRng`] trait provides three ways of constructing PRNGs:
-//!
-//! - `from_seed` accepts a type specific to the PRNG
-//! - `from_rng` allows a PRNG to be seeded from any other RNG
-//! - `seed_from_u64` allows any PRNG to be seeded from a `u64` insecurely
-//! - `from_entropy` securely seeds a PRNG from fresh entropy
-//!
-//! Use the [`rand_core`] crate when implementing your own RNGs.
-//!
-//! ## Our generators
-//!
-//! This crate provides several random number generators:
-//!
-//! - [`OsRng`] is an interface to the operating system's random number
-//! source. Typically the operating system uses a CSPRNG with entropy
-//! provided by a TRNG and some type of on-going re-seeding.
-//! - [`ThreadRng`], provided by the [`thread_rng`] function, is a handle to a
-//! thread-local CSPRNG with periodic seeding from [`OsRng`]. Because this
-//! is local, it is typically much faster than [`OsRng`]. It should be
-//! secure, though the paranoid may prefer [`OsRng`].
-//! - [`StdRng`] is a CSPRNG chosen for good performance and trust of security
-//! (based on reviews, maturity and usage). The current algorithm is ChaCha20,
-//! which is well established and rigorously analysed.
-//! [`StdRng`] provides the algorithm used by [`ThreadRng`] but without
-//! periodic reseeding.
-//! - [`SmallRng`] is an **insecure** PRNG designed to be fast, simple, require
-//! little memory, and have good output quality.
-//!
-//! The algorithms selected for [`StdRng`] and [`SmallRng`] may change in any
-//! release and may be platform-dependent, therefore they should be considered
-//! **not reproducible**.
-//!
-//! ## Additional generators
-//!
-//! **TRNGs**: The [`rdrand`] crate provides an interface to the RDRAND and
-//! RDSEED instructions available in modern Intel and AMD CPUs.
-//! The [`rand_jitter`] crate provides a user-space implementation of
-//! entropy harvesting from CPU timer jitter, but is very slow and has
-//! [security issues](https://github.com/rust-random/rand/issues/699).
-//!
-//! **PRNGs**: Several companion crates are available, providing individual or
-//! families of PRNG algorithms. These provide the implementations behind
-//! [`StdRng`] and [`SmallRng`] but can also be used directly, indeed *should*
-//! be used directly when **reproducibility** matters.
-//! Some suggestions are: [`rand_chacha`], [`rand_pcg`], [`rand_xoshiro`].
-//! A full list can be found by searching for crates with the [`rng` tag].
-//!
-//! [`SmallRng`]: rngs::SmallRng
-//! [`StdRng`]: rngs::StdRng
-//! [`OsRng`]: rngs::OsRng
-//! [`ThreadRng`]: rngs::ThreadRng
-//! [`mock::StepRng`]: rngs::mock::StepRng
-//! [`adapter::ReadRng`]: rngs::adapter::ReadRng
-//! [`adapter::ReseedingRng`]: rngs::adapter::ReseedingRng
-//! [`rdrand`]: https://crates.io/crates/rdrand
-//! [`rand_jitter`]: https://crates.io/crates/rand_jitter
-//! [`rand_chacha`]: https://crates.io/crates/rand_chacha
-//! [`rand_pcg`]: https://crates.io/crates/rand_pcg
-//! [`rand_xoshiro`]: https://crates.io/crates/rand_xoshiro
-//! [`rng` tag]: https://crates.io/keywords/rng
-
-pub mod adapter;
-
-#[cfg(feature="std")] mod entropy;
-pub mod mock; // Public so we don't export `StepRng` directly, making it a bit
- // more clear it is intended for testing.
-#[cfg(feature="small_rng")]
-mod small;
-mod std;
-#[cfg(feature="std")] pub(crate) mod thread;
-
-#[allow(deprecated)]
-#[cfg(feature="std")] pub use self::entropy::EntropyRng;
-
-#[cfg(feature="small_rng")]
-pub use self::small::SmallRng;
-pub use self::std::StdRng;
-#[cfg(feature="std")] pub use self::thread::ThreadRng;
-
-#[cfg(feature="getrandom")] pub use rand_core::OsRng;
diff --git a/rand/src/rngs/small.rs b/rand/src/rngs/small.rs
deleted file mode 100644
index 6571363..0000000
--- a/rand/src/rngs/small.rs
+++ /dev/null
@@ -1,115 +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 rand_core::{RngCore, SeedableRng, Error};
-
-#[cfg(all(not(target_os = "emscripten"), target_pointer_width = "64"))]
-type Rng = rand_pcg::Pcg64Mcg;
-#[cfg(not(all(not(target_os = "emscripten"), target_pointer_width = "64")))]
-type Rng = rand_pcg::Pcg32;
-
-/// A small-state, fast non-crypto PRNG
-///
-/// `SmallRng` may be a good choice when a PRNG with small state, cheap
-/// initialization, good statistical quality and good performance are required.
-/// It is **not** a good choice when security against prediction or
-/// reproducibility are important.
-///
-/// This PRNG is **feature-gated**: to use, you must enable the crate feature
-/// `small_rng`.
-///
-/// The algorithm is deterministic but should not be considered reproducible
-/// due to dependence on platform and possible replacement in future
-/// library versions. For a reproducible generator, use a named PRNG from an
-/// external crate, e.g. [rand_pcg] or [rand_chacha].
-/// Refer also to [The Book](https://rust-random.github.io/book/guide-rngs.html).
-///
-/// 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 [`StdRng`].
-/// The current algorithm is [`Pcg64Mcg`](rand_pcg::Pcg64Mcg) on 64-bit
-/// platforms and [`Pcg32`](rand_pcg::Pcg32) on 32-bit platforms. Both are
-/// implemented by the [rand_pcg] crate.
-///
-/// # Examples
-///
-/// Initializing `SmallRng` with a random seed can be done using [`SeedableRng::from_entropy`]:
-///
-/// ```
-/// use rand::{Rng, SeedableRng};
-/// 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();
-/// ```
-///
-/// [`StdRng`]: crate::rngs::StdRng
-/// [`thread_rng`]: crate::thread_rng
-/// [rand_chacha]: https://crates.io/crates/rand_chacha
-/// [rand_pcg]: https://crates.io/crates/rand_pcg
-#[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()
- }
-
- #[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 SmallRng {
- type Seed = <Rng as SeedableRng>::Seed;
-
- #[inline(always)]
- fn from_seed(seed: Self::Seed) -> Self {
- SmallRng(Rng::from_seed(seed))
- }
-
- #[inline(always)]
- 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 22e08ae..0000000
--- a/rand/src/rngs/std.rs
+++ /dev/null
@@ -1,100 +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 crate::{RngCore, CryptoRng, Error, SeedableRng};
-
-#[cfg(target_os = "emscripten")] pub(crate) use rand_hc::Hc128Core as Core;
-#[cfg(not(target_os = "emscripten"))] pub(crate) use rand_chacha::ChaCha20Core as Core;
-#[cfg(target_os = "emscripten")] use rand_hc::Hc128Rng as Rng;
-#[cfg(not(target_os = "emscripten"))] use rand_chacha::ChaCha20Rng as Rng;
-
-/// 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 is the ChaCha block cipher with either 20 or 12
-/// rounds (see the `stdrng_*` feature flags, documented in the README).
-/// This may change as new evidence of cipher security and performance
-/// becomes available.
-///
-/// The algorithm is deterministic but should not be considered reproducible
-/// due to dependence on configuration and possible replacement in future
-/// library versions. For a secure reproducible generator, we recommend use of
-/// the [rand_chacha] crate directly.
-///
-/// [rand_chacha]: https://crates.io/crates/rand_chacha
-#[derive(Clone, Debug)]
-pub struct StdRng(Rng);
-
-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 = <Rng as SeedableRng>::Seed;
-
- #[inline(always)]
- fn from_seed(seed: Self::Seed) -> Self {
- StdRng(Rng::from_seed(seed))
- }
-
- #[inline(always)]
- fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> {
- Rng::from_rng(rng).map(StdRng)
- }
-}
-
-impl CryptoRng for StdRng {}
-
-
-#[cfg(test)]
-mod test {
- use crate::{RngCore, SeedableRng};
- use crate::rngs::StdRng;
-
- #[test]
- fn test_stdrng_construction() {
- // Test value-stability of StdRng. This is expected to break any time
- // the algorithm is changed.
- 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];
-
- #[cfg(any(feature="stdrng_strong", not(feature="stdrng_fast")))]
- let target = [3950704604716924505, 5573172343717151650];
- #[cfg(all(not(feature="stdrng_strong"), feature="stdrng_fast"))]
- let target = [10719222850664546238, 14064965282130556830];
-
- let mut rng0 = StdRng::from_seed(seed);
- let x0 = rng0.next_u64();
-
- let mut rng1 = StdRng::from_rng(rng0).unwrap();
- let x1 = rng1.next_u64();
-
- assert_eq!([x0, x1], target);
- }
-}
diff --git a/rand/src/rngs/thread.rs b/rand/src/rngs/thread.rs
deleted file mode 100644
index 2006f41..0000000
--- a/rand/src/rngs/thread.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.
-
-//! Thread-local random number generator
-
-use std::cell::UnsafeCell;
-use std::ptr::NonNull;
-
-use crate::{RngCore, CryptoRng, SeedableRng, Error};
-use crate::rngs::adapter::ReseedingRng;
-use crate::rngs::OsRng;
-use super::std::Core;
-
-// 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.
-
-
-// Number of generated bytes after which to reseed `ThreadRng`.
-// According to benchmarks, reseeding has a noticable impact with thresholds
-// of 32 kB and less. We choose 64 kB to avoid significant overhead.
-const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64;
-
-/// The type returned by [`thread_rng`], essentially just a reference to the
-/// PRNG in thread-local memory.
-///
-/// `ThreadRng` uses the same PRNG as [`StdRng`] for security and performance.
-/// As hinted by the name, the generator is thread-local. `ThreadRng` is a
-/// handle to this generator and thus supports `Copy`, but not `Send` or `Sync`.
-///
-/// Unlike `StdRng`, `ThreadRng` uses the [`ReseedingRng`] wrapper to reseed
-/// the PRNG from fresh entropy every 64 kiB of random data.
-/// [`OsRng`] is used to provide seed data.
-///
-/// Note that the reseeding is done as an extra precaution against side-channel
-/// attacks and mis-use (e.g. if somehow weak entropy were supplied initially).
-/// The PRNG algorithms used are assumed to be secure.
-///
-/// [`ReseedingRng`]: crate::rngs::adapter::ReseedingRng
-/// [`StdRng`]: crate::rngs::StdRng
-#[derive(Copy, Clone, Debug)]
-pub struct ThreadRng {
- // inner raw pointer implies type is neither Send nor Sync
- rng: NonNull<ReseedingRng<Core, OsRng>>,
-}
-
-thread_local!(
- static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Core, OsRng>> = {
- let r = Core::from_rng(OsRng).unwrap_or_else(|err|
- panic!("could not initialize thread_rng: {}", err));
- let rng = ReseedingRng::new(r,
- THREAD_RNG_RESEED_THRESHOLD,
- OsRng);
- 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()` equivalent.
-///
-/// For more information see [`ThreadRng`].
-pub fn thread_rng() -> ThreadRng {
- let raw = THREAD_RNG_KEY.with(|t| t.get());
- let nn = NonNull::new(raw).unwrap();
- ThreadRng { rng: nn }
-}
-
-impl Default for ThreadRng {
- fn default() -> ThreadRng {
- crate::prelude::thread_rng()
- }
-}
-
-impl RngCore for ThreadRng {
- #[inline(always)]
- fn next_u32(&mut self) -> u32 {
- unsafe { self.rng.as_mut().next_u32() }
- }
-
- #[inline(always)]
- fn next_u64(&mut self) -> u64 {
- unsafe { self.rng.as_mut().next_u64() }
- }
-
- fn fill_bytes(&mut self, dest: &mut [u8]) {
- unsafe { self.rng.as_mut().fill_bytes(dest) }
- }
-
- fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- unsafe { self.rng.as_mut().try_fill_bytes(dest) }
- }
-}
-
-impl CryptoRng for ThreadRng {}
-
-
-#[cfg(test)]
-mod test {
- #[test]
- fn test_thread_rng() {
- use crate::Rng;
- let mut r = crate::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 22a5733..0000000
--- a/rand/src/seq/index.rs
+++ /dev/null
@@ -1,409 +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.
-
-//! Low-level API for sampling indices
-
-#[cfg(feature="alloc")] use core::slice;
-
-#[cfg(feature="std")] use std::vec;
-#[cfg(all(feature="alloc", not(feature="std")))] use crate::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 crate::alloc::collections::BTreeSet;
-
-#[cfg(feature="alloc")] use crate::distributions::{Distribution, Uniform, uniform::SampleUniform};
-use crate::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
- #[inline]
- pub fn len(&self) -> usize {
- match *self {
- IndexVec::U32(ref v) => v.len(),
- IndexVec::USize(ref v) => v.len(),
- }
- }
-
- /// Returns `true` if the length is 0.
- #[inline]
- pub fn is_empty(&self) -> bool {
- match *self {
- IndexVec::U32(ref v) => v.is_empty(),
- IndexVec::USize(ref v) => v.is_empty(),
- }
- }
-
- /// Return the value at the given `index`.
- ///
- /// (Note: we cannot implement [`std::ops::Index`] because of lifetime
- /// restrictions.)
- #[inline]
- 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.
- #[inline]
- 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
- #[inline]
- pub fn iter(&self) -> IndexVecIter<'_> {
- 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
- #[inline]
- 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 {
- #[inline]
- fn from(v: Vec<u32>) -> Self {
- IndexVec::U32(v)
- }
-}
-
-impl From<Vec<usize>> for IndexVec {
- #[inline]
- 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;
- #[inline]
- fn next(&mut self) -> Option<usize> {
- use self::IndexVecIter::*;
- match *self {
- U32(ref mut iter) => iter.next().map(|i| *i as usize),
- USize(ref mut iter) => iter.next().cloned(),
- }
- }
-
- #[inline]
- 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;
-
- #[inline]
- fn next(&mut self) -> Option<Self::Item> {
- use self::IndexVecIntoIter::*;
- match *self {
- U32(ref mut v) => v.next().map(|i| i as usize),
- USize(ref mut v) => v.next(),
- }
- }
-
- #[inline]
- 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 {
- sample_rejection(rng, length, amount)
- }
- }
-}
-
-/// 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)
-}
-
-trait UInt: Copy + PartialOrd + Ord + PartialEq + Eq + SampleUniform + core::hash::Hash {
- fn zero() -> Self;
- fn as_usize(self) -> usize;
-}
-impl UInt for u32 {
- #[inline] fn zero() -> Self { 0 }
- #[inline] fn as_usize(self) -> usize { self as usize }
-}
-impl UInt for usize {
- #[inline] fn zero() -> Self { 0 }
- #[inline] fn as_usize(self) -> usize { self }
-}
-
-/// 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.
-///
-/// This function is generic over X primarily so that results are value-stable
-/// over 32-bit and 64-bit platforms.
-fn sample_rejection<X: UInt, R>(rng: &mut R, length: X, amount: X) -> IndexVec
-where R: Rng + ?Sized, IndexVec: From<Vec<X>> {
- debug_assert!(amount < length);
- #[cfg(feature="std")] let mut cache = HashSet::with_capacity(amount.as_usize());
- #[cfg(not(feature="std"))] let mut cache = BTreeSet::new();
- let distr = Uniform::new(X::zero(), length);
- let mut indices = Vec::with_capacity(amount.as_usize());
- for _ in 0..amount.as_usize() {
- let mut pos = distr.sample(rng);
- while !cache.insert(pos) {
- pos = distr.sample(rng);
- }
- indices.push(pos);
- }
-
- debug_assert_eq!(indices.len(), amount.as_usize());
- IndexVec::from(indices)
-}
-
-#[cfg(test)]
-mod test {
- #[cfg(feature="std")] use std::vec;
- #[cfg(all(feature="alloc", not(feature="std")))] use crate::alloc::vec;
- use super::*;
-
- #[test]
- fn test_sample_boundaries() {
- let mut r = crate::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, 1u32, 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, 10u32)
- .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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_sample_alg() {
- let seed_rng = crate::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 as u32, amount as u32);
- 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 cec9bb1..0000000
--- a/rand/src/seq/mod.rs
+++ /dev/null
@@ -1,791 +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.
-
-//! Sequence-related functionality
-//!
-//! This module provides:
-//!
-//! * [`seq::SliceRandom`] slice sampling and mutation
-//! * [`seq::IteratorRandom`] iterator sampling
-//! * [`seq::index::sample`] low-level API to choose multiple indices from
-//! `0..length`
-//!
-//! Also see:
-//!
-//! * [`distributions::weighted`] module which provides implementations of
-//! weighted index sampling.
-//!
-//! In order to make results reproducible across 32-64 bit architectures, all
-//! `usize` indices are sampled as a `u32` where possible (also providing a
-//! small performance boost in some cases).
-
-
-#[cfg(feature="alloc")] pub mod index;
-
-#[cfg(feature="alloc")] use core::ops::Index;
-
-#[cfg(all(feature="alloc", not(feature="std")))] use crate::alloc::vec::Vec;
-
-use crate::Rng;
-#[cfg(feature="alloc")] use crate::distributions::WeightedError;
-#[cfg(feature="alloc")] use crate::distributions::uniform::{SampleUniform, SampleBorrow};
-
-/// Extension trait on slices, providing random mutation and sampling methods.
-///
-/// This trait is implemented on all `[T]` slice types, providing several
-/// methods for choosing and shuffling elements. You must `use` this trait:
-///
-/// ```
-/// use rand::seq::SliceRandom;
-///
-/// fn main() {
-/// let mut rng = rand::thread_rng();
-/// let mut bytes = "Hello, random!".to_string().into_bytes();
-/// bytes.shuffle(&mut rng);
-/// let str = String::from_utf8(bytes).unwrap();
-/// println!("{}", str);
-/// }
-/// ```
-/// Example output (non-deterministic):
-/// ```none
-/// l,nmroHado !le
-/// ```
-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.
- ///
- /// For slices, complexity is `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.
- ///
- /// For slices, complexity is `O(1)`.
- fn choose_mut<R>(&mut self, rng: &mut R) -> Option<&mut Self::Item>
- where R: Rng + ?Sized;
-
- /// Chooses `amount` elements from the slice at random, without repetition,
- /// and in random order. The returned iterator is appropriate both for
- /// collection into a `Vec` and filling an existing buffer (see example).
- ///
- /// In case this API is not sufficiently flexible, use [`index::sample`].
- ///
- /// For slices, complexity is 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`], but where the likelihood of each outcome may be
- /// specified.
- ///
- /// The specified function `weight` maps each item `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)`.
- ///
- /// For slices of length `n`, complexity is `O(n)`.
- /// See also [`choose_weighted_mut`], [`distributions::weighted`].
- ///
- /// # 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`]: SliceRandom::choose
- /// [`choose_weighted_mut`]: SliceRandom::choose_weighted_mut
- /// [`distributions::weighted`]: crate::distributions::weighted
- #[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`], but where the likelihood of each outcome may
- /// be specified.
- ///
- /// The specified function `weight` maps each item `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)`.
- ///
- /// For slices of length `n`, complexity is `O(n)`.
- /// See also [`choose_weighted`], [`distributions::weighted`].
- ///
- /// [`choose_mut`]: SliceRandom::choose_mut
- /// [`choose_weighted`]: SliceRandom::choose_weighted
- /// [`distributions::weighted`]: crate::distributions::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.
- ///
- /// For slices of length `n`, complexity is `O(n)`.
- ///
- /// # Example
- ///
- /// ```
- /// use rand::seq::SliceRandom;
- /// use rand::thread_rng;
- ///
- /// 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.
- ///
- /// For slices, complexity is `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.
-///
-/// This trait is implemented on all sized iterators, providing methods for
-/// choosing one or more elements. You must `use` this trait:
-///
-/// ```
-/// use rand::seq::IteratorRandom;
-///
-/// fn main() {
-/// let mut rng = rand::thread_rng();
-///
-/// let faces = "😀😎😐😕😠😢";
-/// println!("I am {}!", faces.chars().choose(&mut rng).unwrap());
-/// }
-/// ```
-/// Example output (non-deterministic):
-/// ```none
-/// I am 😀!
-/// ```
-pub trait IteratorRandom: Iterator + Sized {
- /// Choose one element at random from the iterator.
- ///
- /// Returns `None` if and only if the iterator is empty.
- ///
- /// This method uses [`Iterator::size_hint`] for optimisation. With an
- /// accurate hint and where [`Iterator::nth`] is a constant-time operation
- /// this method can offer `O(1)` performance. Where no size hint is
- /// available, complexity is `O(n)` where `n` is the iterator length.
- /// Partial hints (where `lower > 0`) also improve performance.
- ///
- /// For slices, prefer [`SliceRandom::choose`] which guarantees `O(1)`
- /// performance.
- 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(gen_index(rng, lower)) };
- }
-
- // Continue until the iterator is exhausted
- loop {
- if lower > 1 {
- let ix = gen_index(rng, lower + consumed);
- let skip = if ix < lower {
- result = self.nth(ix);
- lower - (ix + 1)
- } else {
- 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 values at random from the iterator into a supplied buffer
- /// until that buffer is filled.
- ///
- /// 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 the length
- /// of the buffer 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.
- /// For slices, prefer [`SliceRandom::choose_multiple`].
- 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 = gen_index(rng, 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.
- /// For slices, prefer [`SliceRandom::choose_multiple`].
- #[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 = gen_index(rng, 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[gen_index(rng, 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[gen_index(rng, 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 crate::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 crate::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, gen_index(rng, 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, gen_index(rng, i + 1));
- }
- let r = self.split_at_mut(end);
- (r.1, r.0)
- }
-}
-
-impl<I> IteratorRandom for I where I: Iterator + Sized {}
-
-
-/// An iterator over multiple slice elements.
-///
-/// This struct is created by
-/// [`SliceRandom::choose_multiple`](trait.SliceRandom.html#tymethod.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()
- }
-}
-
-
-// Sample a number uniformly between 0 and `ubound`. Uses 32-bit sampling where
-// possible, primarily in order to produce the same output on 32-bit and 64-bit
-// platforms.
-#[inline]
-fn gen_index<R: Rng + ?Sized>(rng: &mut R, ubound: usize) -> usize {
- if ubound <= (core::u32::MAX as usize) {
- rng.gen_range(0, ubound as u32) as usize
- } else {
- rng.gen_range(0, ubound)
- }
-}
-
-
-#[cfg(test)]
-mod test {
- use super::*;
- #[cfg(feature = "alloc")] use crate::Rng;
- #[cfg(all(feature="alloc", not(feature="std")))]
- use alloc::vec::Vec;
-
- #[test]
- fn test_slice_choose() {
- let mut r = crate::test::rng(107);
- let chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'];
- let mut chosen = [0i32; 14];
- // The below all use a binomial distribution with n=1000, p=1/14.
- // binocdf(40, 1000, 1/14) ~= 2e-5; 1-binocdf(106, ..) ~= 2e-5
- for _ in 0..1000 {
- let picked = *chars.choose(&mut r).unwrap();
- chosen[(picked as usize) - ('a' as usize)] += 1;
- }
- for count in chosen.iter() {
- assert!(40 < *count && *count < 106);
- }
-
- chosen.iter_mut().for_each(|x| *x = 0);
- for _ in 0..1000 {
- *chosen.choose_mut(&mut r).unwrap() += 1;
- }
- for count in chosen.iter() {
- assert!(40 < *count && *count < 106);
- }
-
- 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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_iterator_choose() {
- let r = &mut crate::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]
- #[cfg(not(miri))] // Miri is too slow
- fn test_shuffle() {
- let mut r = crate::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() {
- // Binomial(10000, 1/24) with average 416.667
- // Octave: binocdf(n, 10000, 1/24)
- // 99.9% chance samples lie within this range:
- assert!(352 <= *count && *count <= 483, "count: {}", count);
- }
- }
-
- #[test]
- fn test_partial_shuffle() {
- let mut r = crate::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 = crate::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")]
- #[cfg(not(miri))] // Miri is too slow
- fn test_weighted() {
- let mut r = crate::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::InvalidWeight));
- assert_eq!([-1, 0].choose_weighted_mut(&mut r, |x| *x), Err(WeightedError::InvalidWeight));
- }
-}
diff --git a/rand/tests/wasm_bindgen/Cargo.toml b/rand/tests/wasm_bindgen/Cargo.toml
deleted file mode 100644
index e83c174..0000000
--- a/rand/tests/wasm_bindgen/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "rand_wasm_bindgen_test"
-description = "Minimal crate to test that rand can be build for web assembly target"
-version = "0.1.0"
-authors = ["The Rand Project Developers"]
-publish = false
-license = "MIT OR Apache-2.0"
-edition = "2018"
-
-[lib]
-crate-type = ["cdylib"]
-
-[dependencies]
-rand = { path = "../..", features = ["wasm-bindgen"] }
-wasm-bindgen = "0.2"
-wasm-bindgen-test = "0.2"
diff --git a/rand/tests/wasm_bindgen/js/index.js b/rand/tests/wasm_bindgen/js/index.js
deleted file mode 100644
index a02fb59..0000000
--- a/rand/tests/wasm_bindgen/js/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-const rand_wasm_bindgen_test = require('./rand_wasm_bindgen_test');
-
-console.log(rand_wasm_bindgen_test.generate_from_entropy());
-console.log(rand_wasm_bindgen_test.generate_from_os_rand());
-console.log(rand_wasm_bindgen_test.generate_from_seed());
diff --git a/rand/tests/wasm_bindgen/src/lib.rs b/rand/tests/wasm_bindgen/src/lib.rs
deleted file mode 100644
index 9af0b9e..0000000
--- a/rand/tests/wasm_bindgen/src/lib.rs
+++ /dev/null
@@ -1,49 +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.
-
-// Crate to test WASM with the `wasm-bindgen` lib.
-
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png")]
-
-use rand::rngs::{OsRng, StdRng};
-use rand::{Rng, SeedableRng};
-use wasm_bindgen::prelude::*;
-
-#[wasm_bindgen]
-pub fn generate_from_seed(seed: u32) -> i32 {
- StdRng::seed_from_u64(seed as u64).gen()
-}
-
-#[wasm_bindgen]
-pub fn generate_from_os_rand() -> i32 {
- OsRng.gen()
-}
-
-#[wasm_bindgen]
-pub fn generate_from_entropy() -> i32 {
- StdRng::from_entropy().gen()
-}
-
-pub mod tests {
- use wasm_bindgen_test::*;
-
- #[wasm_bindgen_test]
- fn generate_from_seed() {
- let _ = super::generate_from_seed(42);
- }
-
- #[wasm_bindgen_test]
- fn generate_from_os_rand() {
- let _ = super::generate_from_os_rand();
- }
-
- #[wasm_bindgen_test]
- fn generate_from_entropy() {
- let _ = super::generate_from_entropy();
- }
-}
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/miri.sh b/rand/utils/ci/miri.sh
deleted file mode 100644
index 209adf2..0000000
--- a/rand/utils/ci/miri.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-set -ex
-
-MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
-echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
-rustup default "$MIRI_NIGHTLY"
-
-rustup component add miri
-cargo miri setup
-
-cargo miri test --no-default-features -- -- -Zunstable-options --exclude-should-panic
-cargo miri test --features=log -- -- -Zunstable-options --exclude-should-panic
-cargo miri test --manifest-path rand_core/Cargo.toml
-cargo miri test --manifest-path rand_core/Cargo.toml --features=serde1
-cargo miri test --manifest-path rand_core/Cargo.toml --no-default-features
-#cargo miri test --manifest-path rand_distr/Cargo.toml # no unsafe and lots of slow tests
-cargo miri test --manifest-path rand_isaac/Cargo.toml --features=serde1
-cargo miri test --manifest-path rand_pcg/Cargo.toml --features=serde1
-cargo miri test --manifest-path rand_xorshift/Cargo.toml --features=serde1
-cargo miri test --manifest-path rand_xoshiro/Cargo.toml --features=serde1
-cargo miri test --manifest-path rand_chacha/Cargo.toml --no-default-features
-cargo miri test --manifest-path rand_hc/Cargo.toml
-cargo miri test --manifest-path rand_jitter/Cargo.toml
-cargo miri test --manifest-path rand_os/Cargo.toml
diff --git a/rand/utils/ci/script.sh b/rand/utils/ci/script.sh
deleted file mode 100644
index 852a850..0000000
--- a/rand/utils/ci/script.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-# Derived from https://github.com/japaric/trust
-
-set -ex
-
-main() {
- cross test --target $TARGET --tests --no-default-features
- # TODO: add simd_support feature:
- cross test --target $TARGET --features=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 --features=serde1
- cross test --target $TARGET --manifest-path rand_core/Cargo.toml --no-default-features
- cross test --target $TARGET --manifest-path rand_distr/Cargo.toml
- 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 --features=serde1
- 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
- cross test --target $TARGET --manifest-path rand_jitter/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/rustversion/.gitignore b/rustversion/.gitignore
deleted file mode 100644
index 6936990..0000000
--- a/rustversion/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/target
-**/*.rs.bk
-Cargo.lock
diff --git a/rustversion/.travis.yml b/rustversion/.travis.yml
deleted file mode 100644
index 1a615ba..0000000
--- a/rustversion/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-language: rust
-
-rust:
- - nightly
- - beta
- - stable
- - 1.31.0
-
-script:
- - cargo test
-
-matrix:
- include:
- - rust: nightly
- name: Minimal versions
- before_script:
- - cargo update -Z minimal-versions
diff --git a/rustversion/Cargo.toml b/rustversion/Cargo.toml
deleted file mode 100644
index 789c5f4..0000000
--- a/rustversion/Cargo.toml
+++ /dev/null
@@ -1,21 +0,0 @@
-[package]
-name = "rustversion"
-version = "1.0.1"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-license = "MIT OR Apache-2.0"
-description = "Conditional compilation according to rustc compiler version"
-repository = "https://github.com/dtolnay/rustversion"
-documentation = "https://docs.rs/rustversion"
-readme = "README.md"
-
-[lib]
-proc-macro = true
-
-[badges]
-travis-ci = { repository = "dtolnay/rustversion" }
-
-[dependencies]
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = { version = "1.0.1", features = ["full"] }
diff --git a/rustversion/LICENSE-APACHE b/rustversion/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/rustversion/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/rustversion/LICENSE-MIT b/rustversion/LICENSE-MIT
deleted file mode 100644
index 31aa793..0000000
--- a/rustversion/LICENSE-MIT
+++ /dev/null
@@ -1,23 +0,0 @@
-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/rustversion/README.md b/rustversion/README.md
deleted file mode 100644
index f7fdab1..0000000
--- a/rustversion/README.md
+++ /dev/null
@@ -1,138 +0,0 @@
-Compiler version cfg
-====================
-
-[![Build Status](https://api.travis-ci.com/dtolnay/rustversion.svg?branch=master)](https://travis-ci.com/dtolnay/rustversion)
-[![Latest Version](https://img.shields.io/crates/v/rustversion.svg)](https://crates.io/crates/rustversion)
-[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/rustversion)
-
-This crate provides macros for conditional compilation according to rustc
-compiler version, analogous to [`#[cfg(...)]`][cfg] and
-[`#[cfg_attr(...)]`][cfg_attr].
-
-[cfg]: https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute
-[cfg_attr]: https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute
-
-```toml
-[dependencies]
-rustversion = "1.0"
-```
-
-<br>
-
-## Selectors
-
-- <b>`#[rustversion::stable]`</b>
- —<br>
- True on any stable compiler.
-
-- <b>`#[rustversion::stable(1.34)]`</b>
- —<br>
- True on exactly the specified stable compiler.
-
-- <b>`#[rustversion::beta]`</b>
- —<br>
- True on any beta compiler.
-
-- <b>`#[rustversion::nightly]`</b>
- —<br>
- True on any nightly compiler or dev build.
-
-- <b>`#[rustversion::nightly(2019-01-01)]`</b>
- —<br>
- True on exactly one nightly.
-
-- <b>`#[rustversion::since(1.34)]`</b>
- —<br>
- True on that stable release and any later compiler, including beta and
- nightly.
-
-- <b>`#[rustversion::since(2019-01-01)]`</b>
- —<br>
- True on that nightly and all newer ones.
-
-- <b>`#[rustversion::before(`</b><i>version or date</i><b>`)]`</b>
- —<br>
- Negative of *#[rustversion::since(...)]*.
-
-- <b>`#[rustversion::not(`</b><i>selector</i><b>`)]`</b>
- —<br>
- Negative of any selector; for example *#[rustversion::not(nightly)]*.
-
-- <b>`#[rustversion::any(`</b><i>selectors...</i><b>`)]`</b>
- —<br>
- True if any of the comma-separated selectors is true; for example
- *#[rustversion::any(stable, beta)]*.
-
-- <b>`#[rustversion::all(`</b><i>selectors...</i><b>`)]`</b>
- —<br>
- True if all of the comma-separated selectors are true; for example
- *#[rustversion::all(since(1.31), before(1.34))]*.
-
-- <b>`#[rustversion::attr(`</b><i>selector</i><b>`, `</b><i>attribute</i><b>`)]`</b>
- —<br>
- For conditional inclusion of attributes; analogous to `cfg_attr`.
-
-<br>
-
-## Use cases
-
-Providing additional trait impls as types are stabilized in the standard library
-without breaking compatibility with older compilers; in this case Pin\<P\>
-stabilized in [Rust 1.33][pin]:
-
-[pin]: https://blog.rust-lang.org/2019/02/28/Rust-1.33.0.html#pinning
-
-```rust
-#[rustversion::since(1.33)]
-use std::pin::Pin;
-
-#[rustversion::since(1.33)]
-impl<P: MyTrait> MyTrait for Pin<P> {
- /* ... */
-}
-```
-
-Similar but for language features; the ability to control alignment greater than
-1 of packed structs was stabilized in [Rust 1.33][packed].
-
-[packed]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1330-2019-02-28
-
-```rust
-#[rustversion::attr(before(1.33), repr(packed))]
-#[rustversion::attr(since(1.33), repr(packed(2)))]
-struct Six(i16, i32);
-
-fn main() {
- println!("{}", std::mem::align_of::<Six>());
-}
-```
-
-Augmenting code with `const` as const impls are stabilized in the standard
-library. This use of `const` as an attribute is recognized as a special case by
-the rustversion::attr macro.
-
-```rust
-use std::time::Duration;
-
-#[rustversion::attr(since(1.32), const)]
-fn duration_as_days(dur: Duration) -> u64 {
- dur.as_secs() / 60 / 60 / 24
-}
-```
-
-<br>
-
-#### License
-
-<sup>
-Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
-2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
-</sup>
-
-<br>
-
-<sub>
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
-be dual licensed as above, without any additional terms or conditions.
-</sub>
diff --git a/rustversion/src/attr.rs b/rustversion/src/attr.rs
deleted file mode 100644
index 591b2c0..0000000
--- a/rustversion/src/attr.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-use crate::expr::Expr;
-use proc_macro2::TokenStream;
-use syn::parse::{Parse, ParseStream, Result};
-use syn::Token;
-
-pub struct Args {
- pub condition: Expr,
- pub then: Then,
-}
-
-pub enum Then {
- Const(Token![const]),
- Attribute(TokenStream),
-}
-
-impl Parse for Args {
- fn parse(input: ParseStream) -> Result<Self> {
- let condition: Expr = input.parse()?;
-
- input.parse::<Token![,]>()?;
- if input.is_empty() {
- return Err(input.error("expected one or more attrs"));
- }
-
- let const_token: Option<Token![const]> = input.parse()?;
- let then = if let Some(const_token) = const_token {
- input.parse::<Option<Token![,]>>()?;
- Then::Const(const_token)
- } else {
- input.parse().map(Then::Attribute)?
- };
-
- Ok(Args { condition, then })
- }
-}
diff --git a/rustversion/src/bound.rs b/rustversion/src/bound.rs
deleted file mode 100644
index 2546637..0000000
--- a/rustversion/src/bound.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-use crate::date::Date;
-use crate::version::{Channel::*, Version};
-use quote::quote;
-use std::cmp::Ordering;
-use syn::parse::{Error, Parse, ParseStream, Result};
-use syn::{LitFloat, LitInt, Token};
-
-pub enum Bound {
- Nightly(Date),
- Stable(Release),
-}
-
-#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
-pub struct Release {
- pub minor: u16,
- pub patch: Option<u16>,
-}
-
-impl Parse for Bound {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek2(Token![-]) {
- input.parse().map(Bound::Nightly)
- } else {
- input.parse().map(Bound::Stable)
- }
- }
-}
-
-impl Parse for Release {
- fn parse(input: ParseStream) -> Result<Self> {
- let span = input.cursor().token_stream();
- let error = || Error::new_spanned(&span, "expected rustc release number, like 1.31");
-
- let major_minor: LitFloat = input.parse().map_err(|_| error())?;
- let string = quote!(#major_minor).to_string();
-
- if !string.starts_with("1.") {
- return Err(error());
- }
-
- let minor: u16 = string[2..].parse().map_err(|_| error())?;
-
- let patch = if input.parse::<Option<Token![.]>>()?.is_some() {
- let int: LitInt = input.parse().map_err(|_| error())?;
- Some(int.base10_parse().map_err(|_| error())?)
- } else {
- None
- };
-
- Ok(Release { minor, patch })
- }
-}
-
-impl PartialEq<Bound> for Version {
- fn eq(&self, rhs: &Bound) -> bool {
- match rhs {
- Bound::Nightly(date) => match self.channel {
- Stable | Beta | Dev => false,
- Nightly(nightly) => nightly == *date,
- },
- Bound::Stable(release) => {
- self.minor == release.minor
- && release.patch.map_or(true, |patch| self.patch == patch)
- }
- }
- }
-}
-
-impl PartialOrd<Bound> for Version {
- fn partial_cmp(&self, rhs: &Bound) -> Option<Ordering> {
- match rhs {
- Bound::Nightly(date) => match self.channel {
- Stable | Beta => Some(Ordering::Less),
- Nightly(nightly) => Some(nightly.cmp(date)),
- Dev => Some(Ordering::Greater),
- },
- Bound::Stable(release) => {
- let version = (self.minor, self.patch);
- let bound = (release.minor, release.patch.unwrap_or(0));
- Some(version.cmp(&bound))
- }
- }
- }
-}
diff --git a/rustversion/src/date.rs b/rustversion/src/date.rs
deleted file mode 100644
index 631b762..0000000
--- a/rustversion/src/date.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-use crate::time;
-use std::fmt::{self, Display};
-use std::num::ParseIntError;
-use std::str::FromStr;
-use syn::parse::{Error, Parse, ParseStream};
-use syn::{LitInt, Token};
-
-#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
-pub struct Date {
- pub year: u16,
- pub month: u8,
- pub day: u8,
-}
-
-impl Display for Date {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(
- formatter,
- "{:04}-{:02}-{:02}",
- self.year, self.month, self.day,
- )
- }
-}
-
-pub struct ParseDateError;
-
-impl From<ParseIntError> for ParseDateError {
- fn from(_err: ParseIntError) -> Self {
- ParseDateError
- }
-}
-
-impl FromStr for Date {
- type Err = ParseDateError;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- let mut date = s.split('-');
- let year = date.next().ok_or(ParseDateError)?.parse()?;
- let month = date.next().ok_or(ParseDateError)?.parse()?;
- let day = date.next().ok_or(ParseDateError)?.parse()?;
- match date.next() {
- None => Ok(Date { year, month, day }),
- Some(_) => Err(ParseDateError),
- }
- }
-}
-
-impl Parse for Date {
- fn parse(input: ParseStream) -> syn::Result<Self> {
- let span = input.cursor().token_stream();
- let error = || {
- Error::new_spanned(
- &span,
- format!("expected nightly date, like {}", time::today()),
- )
- };
-
- let year: LitInt = input.parse().map_err(|_| error())?;
- input.parse::<Token![-]>()?;
- let month: LitInt = input.parse().map_err(|_| error())?;
- input.parse::<Token![-]>()?;
- let day: LitInt = input.parse().map_err(|_| error())?;
-
- let year = year.base10_parse::<u64>().map_err(|_| error())?;
- let month = month.base10_parse::<u64>().map_err(|_| error())?;
- let day = day.base10_parse::<u64>().map_err(|_| error())?;
- if year >= 3000 || month > 12 || day > 31 {
- return Err(error());
- }
-
- Ok(Date {
- year: year as u16,
- month: month as u8,
- day: day as u8,
- })
- }
-}
diff --git a/rustversion/src/expr.rs b/rustversion/src/expr.rs
deleted file mode 100644
index 2ea91af..0000000
--- a/rustversion/src/expr.rs
+++ /dev/null
@@ -1,177 +0,0 @@
-use crate::bound::{Bound, Release};
-use crate::date::Date;
-use crate::version::{Channel, Version};
-use syn::parse::{Parse, ParseStream, Result};
-use syn::punctuated::Punctuated;
-use syn::{parenthesized, token, Token};
-
-pub enum Expr {
- Stable,
- Beta,
- Nightly,
- Date(Date),
- Since(Bound),
- Before(Bound),
- Release(Release),
- Not(Box<Expr>),
- Any(Vec<Expr>),
- All(Vec<Expr>),
-}
-
-impl Expr {
- pub fn eval(&self, rustc: Version) -> bool {
- use self::Expr::*;
-
- match self {
- Stable => rustc.channel == Channel::Stable,
- Beta => rustc.channel == Channel::Beta,
- Nightly => match rustc.channel {
- Channel::Nightly(_) | Channel::Dev => true,
- Channel::Stable | Channel::Beta => false,
- },
- Date(date) => match rustc.channel {
- Channel::Nightly(rustc) => rustc == *date,
- Channel::Stable | Channel::Beta | Channel::Dev => false,
- },
- Since(bound) => rustc >= *bound,
- Before(bound) => rustc < *bound,
- Release(release) => {
- rustc.channel == Channel::Stable
- && rustc.minor == release.minor
- && release.patch.map_or(true, |patch| rustc.patch == patch)
- }
- Not(expr) => !expr.eval(rustc),
- Any(exprs) => exprs.iter().any(|e| e.eval(rustc)),
- All(exprs) => exprs.iter().all(|e| e.eval(rustc)),
- }
- }
-}
-
-type Exprs = Punctuated<Expr, Token![,]>;
-
-mod keyword {
- syn::custom_keyword!(stable);
- syn::custom_keyword!(beta);
- syn::custom_keyword!(nightly);
- syn::custom_keyword!(since);
- syn::custom_keyword!(before);
- syn::custom_keyword!(not);
- syn::custom_keyword!(any);
- syn::custom_keyword!(all);
-}
-
-impl Parse for Expr {
- fn parse(input: ParseStream) -> Result<Self> {
- let lookahead = input.lookahead1();
- if lookahead.peek(keyword::stable) {
- Self::parse_stable(input)
- } else if lookahead.peek(keyword::beta) {
- Self::parse_beta(input)
- } else if lookahead.peek(keyword::nightly) {
- Self::parse_nightly(input)
- } else if lookahead.peek(keyword::since) {
- Self::parse_since(input)
- } else if lookahead.peek(keyword::before) {
- Self::parse_before(input)
- } else if lookahead.peek(keyword::not) {
- Self::parse_not(input)
- } else if lookahead.peek(keyword::any) {
- Self::parse_any(input)
- } else if lookahead.peek(keyword::all) {
- Self::parse_all(input)
- } else {
- Err(lookahead.error())
- }
- }
-}
-
-impl Expr {
- fn parse_nightly(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::nightly>()?;
-
- if !input.peek(token::Paren) {
- return Ok(Expr::Nightly);
- }
-
- let paren;
- parenthesized!(paren in input);
- let date: Date = paren.parse()?;
- paren.parse::<Option<Token![,]>>()?;
-
- Ok(Expr::Date(date))
- }
-
- fn parse_beta(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::beta>()?;
-
- Ok(Expr::Beta)
- }
-
- fn parse_stable(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::stable>()?;
-
- if !input.peek(token::Paren) {
- return Ok(Expr::Stable);
- }
-
- let paren;
- parenthesized!(paren in input);
- let release: Release = paren.parse()?;
- paren.parse::<Option<Token![,]>>()?;
-
- Ok(Expr::Release(release))
- }
-
- fn parse_since(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::since>()?;
-
- let paren;
- parenthesized!(paren in input);
- let bound: Bound = paren.parse()?;
- paren.parse::<Option<Token![,]>>()?;
-
- Ok(Expr::Since(bound))
- }
-
- fn parse_before(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::before>()?;
-
- let paren;
- parenthesized!(paren in input);
- let bound: Bound = paren.parse()?;
- paren.parse::<Option<Token![,]>>()?;
-
- Ok(Expr::Before(bound))
- }
-
- fn parse_not(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::not>()?;
-
- let paren;
- parenthesized!(paren in input);
- let expr: Expr = paren.parse()?;
- paren.parse::<Option<Token![,]>>()?;
-
- Ok(Expr::Not(Box::new(expr)))
- }
-
- fn parse_any(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::any>()?;
-
- let paren;
- parenthesized!(paren in input);
- let exprs: Exprs = paren.parse_terminated(Expr::parse)?;
-
- Ok(Expr::Any(exprs.into_iter().collect()))
- }
-
- fn parse_all(input: ParseStream) -> Result<Self> {
- input.parse::<keyword::all>()?;
-
- let paren;
- parenthesized!(paren in input);
- let exprs: Exprs = paren.parse_terminated(Expr::parse)?;
-
- Ok(Expr::All(exprs.into_iter().collect()))
- }
-}
diff --git a/rustversion/src/lib.rs b/rustversion/src/lib.rs
deleted file mode 100644
index cf8ed21..0000000
--- a/rustversion/src/lib.rs
+++ /dev/null
@@ -1,254 +0,0 @@
-//! This crate provides macros for conditional compilation according to rustc
-//! compiler version, analogous to [`#[cfg(...)]`][cfg] and
-//! [`#[cfg_attr(...)]`][cfg_attr].
-//!
-//! [cfg]: https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute
-//! [cfg_attr]: https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute
-//!
-//! <br>
-//!
-//! # Selectors
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::stable]</code></b>
-//! —<br>
-//! True on any stable compiler.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::stable(1.34)]</code></b>
-//! —<br>
-//! True on exactly the specified stable compiler.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::beta]</code></b>
-//! —<br>
-//! True on any beta compiler.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::nightly]</code></b>
-//! —<br>
-//! True on any nightly compiler or dev build.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::nightly(2019-01-01)]</code></b>
-//! —<br>
-//! True on exactly one nightly.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::since(1.34)]</code></b>
-//! —<br>
-//! True on that stable release and any later compiler, including beta and
-//! nightly.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::since(2019-01-01)]</code></b>
-//! —<br>
-//! True on that nightly and all newer ones.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::before(</code></b><i>version or date</i><b><code>)]</code></b>
-//! —<br>
-//! Negative of <i>#[rustversion::since(...)]</i>.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::not(</code></b><i>selector</i><b><code>)]</code></b>
-//! —<br>
-//! Negative of any selector; for example <i>#[rustversion::not(nightly)]</i>.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::any(</code></b><i>selectors...</i><b><code>)]</code></b>
-//! —<br>
-//! True if any of the comma-separated selectors is true; for example
-//! <i>#[rustversion::any(stable, beta)]</i>.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::all(</code></b><i>selectors...</i><b><code>)]</code></b>
-//! —<br>
-//! True if all of the comma-separated selectors are true; for example
-//! <i>#[rustversion::all(since(1.31), before(1.34))]</i>.
-//! </p>
-//!
-//! - <p style="margin-left:50px;text-indent:-50px">
-//! <b><code>#[rustversion::attr(</code></b><i>selector</i><b><code>, </code></b><i>attribute</i><b><code>)]</code></b>
-//! —<br>
-//! For conditional inclusion of attributes; analogous to
-//! <code>cfg_attr</code>.
-//! </p>
-//!
-//! <br>
-//!
-//! # Use cases
-//!
-//! Providing additional trait impls as types are stabilized in the standard library
-//! without breaking compatibility with older compilers; in this case Pin\<P\>
-//! stabilized in [Rust 1.33][pin]:
-//!
-//! [pin]: https://blog.rust-lang.org/2019/02/28/Rust-1.33.0.html#pinning
-//!
-//! ```
-//! # trait MyTrait {}
-//! #
-//! #[rustversion::since(1.33)]
-//! use std::pin::Pin;
-//!
-//! #[rustversion::since(1.33)]
-//! impl<P: MyTrait> MyTrait for Pin<P> {
-//! /* ... */
-//! }
-//! ```
-//!
-//! Similar but for language features; the ability to control alignment greater than
-//! 1 of packed structs was stabilized in [Rust 1.33][packed].
-//!
-//! [packed]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1330-2019-02-28
-//!
-//! ```
-//! #[rustversion::attr(before(1.33), repr(packed))]
-//! #[rustversion::attr(since(1.33), repr(packed(2)))]
-//! struct Six(i16, i32);
-//!
-//! fn main() {
-//! println!("{}", std::mem::align_of::<Six>());
-//! }
-//! ```
-//!
-//! Augmenting code with `const` as const impls are stabilized in the standard
-//! library. This use of `const` as an attribute is recognized as a special case
-//! by the rustversion::attr macro.
-//!
-//! ```
-//! use std::time::Duration;
-//!
-//! #[rustversion::attr(since(1.32), const)]
-//! fn duration_as_days(dur: Duration) -> u64 {
-//! dur.as_secs() / 60 / 60 / 24
-//! }
-//! ```
-//!
-//! <br>
-
-extern crate proc_macro;
-
-mod attr;
-mod bound;
-mod date;
-mod expr;
-mod rustc;
-mod time;
-mod version;
-
-use crate::attr::Then;
-use crate::expr::Expr;
-use proc_macro::TokenStream;
-use proc_macro2::{Ident, Span, TokenStream as TokenStream2};
-use quote::quote;
-use syn::{parse_macro_input, ItemFn, Result};
-
-#[proc_macro_attribute]
-pub fn stable(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("stable", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn beta(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("beta", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn nightly(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("nightly", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn since(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("since", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn before(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("before", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn not(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("not", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn any(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("any", args, input)
-}
-
-#[proc_macro_attribute]
-pub fn all(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("all", args, input)
-}
-
-fn cfg(top: &str, args: TokenStream, input: TokenStream) -> TokenStream {
- match try_cfg(top, args, input) {
- Ok(tokens) => tokens,
- Err(err) => TokenStream::from(err.to_compile_error()),
- }
-}
-
-fn try_cfg(top: &str, args: TokenStream, input: TokenStream) -> Result<TokenStream> {
- let args = TokenStream2::from(args);
- let top = Ident::new(top, Span::call_site());
-
- let mut full_args = quote!(#top);
- if !args.is_empty() {
- full_args.extend(quote!((#args)));
- }
-
- let expr: Expr = syn::parse2(full_args)?;
- let version = rustc::version()?;
-
- if expr.eval(version) {
- Ok(input)
- } else {
- Ok(TokenStream::new())
- }
-}
-
-#[proc_macro_attribute]
-pub fn attr(args: TokenStream, input: TokenStream) -> TokenStream {
- let args = parse_macro_input!(args as attr::Args);
-
- match try_attr(args, input) {
- Ok(tokens) => tokens,
- Err(err) => TokenStream::from(err.to_compile_error()),
- }
-}
-
-fn try_attr(args: attr::Args, input: TokenStream) -> Result<TokenStream> {
- let version = rustc::version()?;
-
- if !args.condition.eval(version) {
- return Ok(input);
- }
-
- match args.then {
- Then::Const(const_token) => {
- let mut input: ItemFn = syn::parse(input)?;
- input.sig.constness = Some(const_token);
- Ok(TokenStream::from(quote!(#input)))
- }
- Then::Attribute(then) => {
- let input = TokenStream2::from(input);
- Ok(TokenStream::from(quote! {
- #[cfg_attr(all(), #then)]
- #input
- }))
- }
- }
-}
diff --git a/rustversion/src/rustc.rs b/rustversion/src/rustc.rs
deleted file mode 100644
index 4e7699d..0000000
--- a/rustversion/src/rustc.rs
+++ /dev/null
@@ -1,195 +0,0 @@
-use std::env;
-use std::ffi::OsString;
-use std::fmt::{self, Display};
-use std::io;
-use std::process::Command;
-use std::str::FromStr;
-use std::string::FromUtf8Error;
-
-use crate::date::Date;
-use crate::version::{Channel::*, Version};
-use proc_macro2::Span;
-
-#[derive(Debug)]
-pub enum Error {
- Exec(io::Error),
- Utf8(FromUtf8Error),
- Parse(String),
-}
-
-pub type Result<T> = std::result::Result<T, Error>;
-
-impl Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- use self::Error::*;
-
- match self {
- Exec(e) => write!(f, "failed to run `rustc --version`: {}", e),
- Utf8(e) => write!(f, "failed to parse output of `rustc --version`: {}", e),
- Parse(string) => write!(
- f,
- "unexpected output from `rustc --version`, please file an issue: {:?}",
- string,
- ),
- }
- }
-}
-
-impl From<FromUtf8Error> for Error {
- fn from(err: FromUtf8Error) -> Self {
- Error::Utf8(err)
- }
-}
-
-impl From<Error> for syn::Error {
- fn from(err: Error) -> Self {
- syn::Error::new(Span::call_site(), err)
- }
-}
-
-pub fn version() -> Result<Version> {
- let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
- let output = Command::new(rustc)
- .arg("--version")
- .output()
- .map_err(Error::Exec)?;
- let string = String::from_utf8(output.stdout)?;
-
- match parse(&string) {
- Some(version) => Ok(version),
- None => Err(Error::Parse(string)),
- }
-}
-
-fn parse(string: &str) -> Option<Version> {
- let last_line = string.lines().last().unwrap_or(&string);
- let mut words = last_line.trim().split(' ');
-
- if words.next()? != "rustc" {
- return None;
- }
-
- let mut version_channel = words.next()?.split('-');
- let version = version_channel.next()?;
- let channel = version_channel.next();
-
- let mut digits = version.split('.');
- let major = digits.next()?;
- if major != "1" {
- return None;
- }
- let minor = digits.next()?.parse().ok()?;
- let patch = digits.next().unwrap_or("0").parse().ok()?;
-
- let channel = match channel {
- None => Stable,
- Some(channel) if channel == "dev" => Dev,
- Some(channel) if channel.starts_with("beta") => Beta,
- Some(channel) if channel == "nightly" => {
- match words.next() {
- Some(hash) => {
- if !hash.starts_with('(') {
- return None;
- }
- let date = words.next()?;
- if !date.ends_with(')') {
- return None;
- }
- let date = Date::from_str(&date[..date.len() - 1]).ok()?;
- Nightly(date)
- }
- None => Dev,
- }
- }
- Some(_) => return None,
- };
-
- Some(Version {
- minor,
- patch,
- channel,
- })
-}
-
-#[test]
-fn test_parse() {
- let cases = &[
- (
- "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)",
- Version {
- minor: 0,
- patch: 0,
- channel: Stable,
- },
- ),
- (
- "rustc 1.18.0",
- Version {
- minor: 18,
- patch: 0,
- channel: Stable,
- },
- ),
- (
- "rustc 1.24.1 (d3ae9a9e0 2018-02-27)",
- Version {
- minor: 24,
- patch: 1,
- channel: Stable,
- },
- ),
- (
- "rustc 1.35.0-beta.3 (c13114dc8 2019-04-27)",
- Version {
- minor: 35,
- patch: 0,
- channel: Beta,
- },
- ),
- (
- "rustc 1.36.0-nightly (938d4ffe1 2019-04-27)",
- Version {
- minor: 36,
- patch: 0,
- channel: Nightly(Date {
- year: 2019,
- month: 4,
- day: 27,
- }),
- },
- ),
- (
- "rustc 1.36.0-dev",
- Version {
- minor: 36,
- patch: 0,
- channel: Dev,
- },
- ),
- (
- "rustc 1.36.0-nightly",
- Version {
- minor: 36,
- patch: 0,
- channel: Dev,
- },
- ),
- (
- "warning: invalid logging spec 'warning', ignoring it
- rustc 1.30.0-nightly (3bc2ca7e4 2018-09-20)",
- Version {
- minor: 30,
- patch: 0,
- channel: Nightly(Date {
- year: 2018,
- month: 9,
- day: 20,
- }),
- },
- ),
- ];
-
- for (string, expected) in cases {
- assert_eq!(parse(string).unwrap(), *expected);
- }
-}
diff --git a/rustversion/src/time.rs b/rustversion/src/time.rs
deleted file mode 100644
index 1e6dd90..0000000
--- a/rustversion/src/time.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use crate::date::Date;
-use std::time::{SystemTime, UNIX_EPOCH};
-
-// Timestamp of 2016-03-01 00:00:00 in UTC.
-const BASE: u64 = 1456790400;
-const BASE_YEAR: u16 = 2016;
-const BASE_MONTH: u8 = 3;
-
-// Days between leap days.
-const CYCLE: u64 = 365 * 4 + 1;
-
-const DAYS_BY_MONTH: [u8; 12] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
-
-pub fn today() -> Date {
- let default = Date {
- year: 2019,
- month: 1,
- day: 1,
- };
- try_today().unwrap_or(default)
-}
-
-fn try_today() -> Option<Date> {
- let now = SystemTime::now();
- let since_epoch = now.duration_since(UNIX_EPOCH).ok()?;
- let secs = since_epoch.as_secs();
-
- let approx_days = secs.checked_sub(BASE)? / 60 / 60 / 24;
- let cycle = approx_days / CYCLE;
- let mut rem = approx_days % CYCLE;
-
- let mut year = BASE_YEAR + cycle as u16 * 4;
- let mut month = BASE_MONTH;
- loop {
- let days_in_month = DAYS_BY_MONTH[month as usize - 1];
- if rem < days_in_month as u64 {
- let day = rem as u8 + 1;
- return Some(Date { year, month, day });
- }
- rem -= days_in_month as u64;
- year += (month == 12) as u16;
- month = month % 12 + 1;
- }
-}
diff --git a/rustversion/src/version.rs b/rustversion/src/version.rs
deleted file mode 100644
index ab3992f..0000000
--- a/rustversion/src/version.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-use crate::date::Date;
-
-#[derive(Copy, Clone, Debug, PartialEq)]
-pub struct Version {
- pub minor: u16,
- pub patch: u16,
- pub channel: Channel,
-}
-
-#[derive(Copy, Clone, Debug, PartialEq)]
-pub enum Channel {
- Stable,
- Beta,
- Nightly(Date),
- Dev,
-}
diff --git a/nitrocli/src/arg_util.rs b/src/arg_util.rs
index 930e470..3a4c001 100644
--- a/nitrocli/src/arg_util.rs
+++ b/src/arg_util.rs
@@ -33,9 +33,12 @@ macro_rules! tr {
}
macro_rules! Command {
- ( $name:ident, [ $( $(#[$doc:meta])* $var:ident$(($inner:ty))? => $exec:expr, ) *] ) => {
+ ( $(#[$docs:meta])* $name:ident, [
+ $( $(#[$doc:meta])* $var:ident$(($inner:ty))? => $exec:expr, ) *
+ ] ) => {
+ $(#[$docs])*
#[derive(Debug, PartialEq, structopt::StructOpt)]
- enum $name {
+ pub enum $name {
$(
$(#[$doc])*
$var$(($inner))?,
@@ -44,9 +47,9 @@ macro_rules! Command {
#[allow(unused_qualifications)]
impl $name {
- fn execute(
+ pub fn execute(
self,
- ctx: &mut crate::args::ExecCtx<'_>,
+ ctx: &mut crate::ExecCtx<'_>,
) -> crate::Result<()> {
match self {
$(
@@ -63,7 +66,8 @@ macro_rules! Command {
// 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, ) *] ) => {
+ ( $(#[$docs:meta])* $name:ident, [ $( $var:ident => $str:expr, ) *] ) => {
+ $(#[$docs])*
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum $name {
$(
diff --git a/nitrocli/src/args.rs b/src/args.rs
index df93814..91b340c 100644
--- a/nitrocli/src/args.rs
+++ b/src/args.rs
@@ -1,7 +1,7 @@
// args.rs
// *************************************************************************
-// * Copyright (C) 2018-2020 Daniel Mueller (deso@posteo.net) *
+// * 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 *
@@ -17,78 +17,27 @@
// * 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>;
-
-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)
- }
-}
-
/// Provides access to a Nitrokey device
#[derive(structopt::StructOpt)]
#[structopt(name = "nitrocli")]
-struct Args {
+pub struct Args {
/// Increases the log level (can be supplied multiple times)
#[structopt(short, long, global = true, parse(from_occurrences))]
- verbose: u8,
+ pub verbose: u8,
/// Selects the device model to connect to
#[structopt(short, long, global = true, possible_values = &DeviceModel::all_str())]
- model: Option<DeviceModel>,
+ pub model: Option<DeviceModel>,
#[structopt(subcommand)]
- cmd: Command,
+ pub cmd: Command,
}
-/// The available Nitrokey models.
-#[allow(unused_doc_comments)]
-Enum! {DeviceModel, [
- Pro => "pro",
- Storage => "storage",
-]}
+Enum! {
+ /// The available Nitrokey models.
+ DeviceModel, [
+ Pro => "pro",
+ Storage => "storage",
+ ]
+}
impl DeviceModel {
pub fn as_user_facing_str(&self) -> &str {
@@ -108,72 +57,73 @@ impl From<DeviceModel> for nitrokey::Model {
}
}
-/// 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| commands::list(ctx, args.no_connect),
- /// Locks the connected Nitrokey device
- Lock => 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 => commands::reset,
- /// Prints the status of the connected Nitrokey device
- Status => commands::status,
- /// Interacts with the device's unencrypted volume
- Unencrypted(UnencryptedArgs) => |ctx, args: UnencryptedArgs| args.subcmd.execute(ctx),
-]}
+Command! {
+ /// A top-level command for nitrocli.
+ 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)]
-struct ConfigArgs {
+pub struct ConfigArgs {
#[structopt(subcommand)]
subcmd: ConfigCommand,
}
Command! {ConfigCommand, [
/// Prints the Nitrokey configuration
- Get => commands::config_get,
+ Get => crate::commands::config_get,
/// Changes the Nitrokey configuration
- Set(ConfigSetArgs) => config_set,
+ Set(ConfigSetArgs) => crate::commands::config_set,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct ConfigSetArgs {
+pub struct ConfigSetArgs {
/// Sets the numlock option to the given HOTP slot
#[structopt(short = "n", long)]
- numlock: Option<u8>,
+ pub numlock: Option<u8>,
/// Unsets the numlock option
#[structopt(short = "N", long, conflicts_with("numlock"))]
- no_numlock: bool,
+ pub no_numlock: bool,
/// Sets the capslock option to the given HOTP slot
#[structopt(short = "c", long)]
- capslock: Option<u8>,
+ pub capslock: Option<u8>,
/// Unsets the capslock option
#[structopt(short = "C", long, conflicts_with("capslock"))]
- no_capslock: bool,
+ pub no_capslock: bool,
/// Sets the scrollock option to the given HOTP slot
#[structopt(short = "s", long)]
- scrollock: Option<u8>,
+ pub scrollock: Option<u8>,
/// Unsets the scrollock option
#[structopt(short = "S", long, conflicts_with("scrollock"))]
- no_scrollock: bool,
+ pub no_scrollock: bool,
/// Requires the user PIN to generate one-time passwords
#[structopt(short = "o", long)]
- otp_pin: bool,
+ pub otp_pin: bool,
/// Allows one-time password generation without PIN
#[structopt(short = "O", long, conflicts_with("otp-pin"))]
- no_otp_pin: bool,
+ pub no_otp_pin: bool,
}
#[derive(Clone, Copy, Debug)]
@@ -184,13 +134,13 @@ pub enum ConfigOption<T> {
}
impl<T> ConfigOption<T> {
- fn try_from(disable: bool, value: Option<T>, name: &'static str) -> Result<Self> {
+ pub fn try_from(disable: bool, value: Option<T>, name: &'static str) -> Result<Self, String> {
if disable {
if value.is_some() {
- Err(Error::Error(format!(
+ Err(format!(
"--{name} and --no-{name} are mutually exclusive",
name = name
- )))
+ ))
} else {
Ok(ConfigOption::Disable)
}
@@ -211,69 +161,55 @@ impl<T> ConfigOption<T> {
}
}
-fn config_set(ctx: &mut ExecCtx<'_>, args: ConfigSetArgs) -> Result<()> {
- let numlock = ConfigOption::try_from(args.no_numlock, args.numlock, "numlock")?;
- let capslock = ConfigOption::try_from(args.no_capslock, args.capslock, "capslock")?;
- let scrollock = 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
- };
- commands::config_set(ctx, numlock, capslock, scrollock, otp_pin)
-}
-
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct EncryptedArgs {
+pub struct EncryptedArgs {
#[structopt(subcommand)]
subcmd: EncryptedCommand,
}
Command! {EncryptedCommand, [
/// Closes the encrypted volume on a Nitrokey Storage
- Close => commands::encrypted_close,
+ Close => crate::commands::encrypted_close,
/// Opens the encrypted volume on a Nitrokey Storage
- Open => commands::encrypted_open,
+ Open => crate::commands::encrypted_open,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct HiddenArgs {
+pub struct HiddenArgs {
#[structopt(subcommand)]
subcmd: HiddenCommand,
}
Command! {HiddenCommand, [
/// Closes the hidden volume on a Nitrokey Storage
- Close => commands::hidden_close,
+ Close => crate::commands::hidden_close,
/// Creates a hidden volume on a Nitrokey Storage
Create(HiddenCreateArgs) => |ctx, args: HiddenCreateArgs| {
- commands::hidden_create(ctx, args.slot, args.start, args.end)
+ crate::commands::hidden_create(ctx, args.slot, args.start, args.end)
},
/// Opens the hidden volume on a Nitrokey Storage
- Open => commands::hidden_open,
+ Open => crate::commands::hidden_open,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct HiddenCreateArgs {
+pub struct HiddenCreateArgs {
/// The hidden volume slot to use
- slot: u8,
+ pub slot: u8,
/// The start location of the hidden volume as a percentage of the encrypted volume's size (0-99)
- start: u8,
+ pub start: u8,
/// The end location of the hidden volume as a percentage of the encrypted volume's size (1-100)
- end: u8,
+ pub end: u8,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct ListArgs {
+pub struct ListArgs {
/// Only print the information that is available without connecting to a device
#[structopt(short, long)]
- no_connect: bool,
+ pub no_connect: bool,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct OtpArgs {
+pub struct OtpArgs {
#[structopt(subcommand)]
subcmd: OtpCommand,
}
@@ -281,75 +217,75 @@ struct OtpArgs {
Command! {OtpCommand, [
/// Clears a one-time password slot
Clear(OtpClearArgs) => |ctx, args: OtpClearArgs| {
- commands::otp_clear(ctx, args.slot, args.algorithm)
+ crate::commands::otp_clear(ctx, args.slot, args.algorithm)
},
/// Generates a one-time password
Get(OtpGetArgs) => |ctx, args: OtpGetArgs| {
- commands::otp_get(ctx, args.slot, args.algorithm, args.time)
+ crate::commands::otp_get(ctx, args.slot, args.algorithm, args.time)
},
/// Configures a one-time password slot
- Set(OtpSetArgs) => otp_set,
+ Set(OtpSetArgs) => crate::commands::otp_set,
/// Prints the status of the one-time password slots
- Status(OtpStatusArgs) => |ctx, args: OtpStatusArgs| commands::otp_status(ctx, args.all),
+ Status(OtpStatusArgs) => |ctx, args: OtpStatusArgs| crate::commands::otp_status(ctx, args.all),
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct OtpClearArgs {
+pub struct OtpClearArgs {
/// The OTP algorithm to use
#[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
possible_values = &OtpAlgorithm::all_str())]
- algorithm: OtpAlgorithm,
+ pub algorithm: OtpAlgorithm,
/// The OTP slot to clear
- slot: u8,
+ pub slot: u8,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct OtpGetArgs {
+pub struct OtpGetArgs {
/// The OTP algorithm to use
#[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
possible_values = &OtpAlgorithm::all_str())]
- algorithm: OtpAlgorithm,
+ pub algorithm: OtpAlgorithm,
/// The time to use for TOTP generation (Unix timestamp) [default: system time]
#[structopt(short, long)]
- time: Option<u64>,
+ pub time: Option<u64>,
/// The OTP slot to use
- slot: u8,
+ pub slot: u8,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct OtpSetArgs {
+pub struct OtpSetArgs {
/// The OTP algorithm to use
#[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
possible_values = &OtpAlgorithm::all_str())]
- algorithm: OtpAlgorithm,
+ 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())]
- digits: OtpMode,
+ pub digits: OtpMode,
/// The counter value for HOTP
#[structopt(short, long, default_value = "0")]
- counter: u64,
+ pub counter: u64,
/// The time window for TOTP
#[structopt(short, long, default_value = "30")]
- time_window: u16,
+ pub time_window: u16,
/// The format of the secret
#[structopt(short, long, default_value = OtpSecretFormat::Hex.as_ref(),
possible_values = &OtpSecretFormat::all_str())]
- format: OtpSecretFormat,
+ pub format: OtpSecretFormat,
/// The OTP slot to use
- slot: u8,
+ pub slot: u8,
/// The name of the slot
- name: String,
+ pub name: String,
/// The secret to store on the slot as a hexadecimal string (or in the format set with the
/// --format option)
- secret: String,
+ pub secret: String,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct OtpStatusArgs {
+pub struct OtpStatusArgs {
/// Shows slots that are not programmed
#[structopt(short, long)]
- all: bool,
+ pub all: bool,
}
Enum! {OtpAlgorithm, [
@@ -377,113 +313,105 @@ Enum! {OtpSecretFormat, [
Hex => "hex",
]}
-fn otp_set(ctx: &mut ExecCtx<'_>, args: OtpSetArgs) -> Result<()> {
- let data = nitrokey::OtpSlotData {
- number: args.slot,
- name: args.name,
- secret: args.secret,
- mode: args.digits.into(),
- use_enter: false,
- token_id: None,
- };
- commands::otp_set(
- ctx,
- data,
- args.algorithm,
- args.counter,
- args.time_window,
- args.format,
- )
-}
-
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PinArgs {
+pub struct PinArgs {
#[structopt(subcommand)]
subcmd: PinCommand,
}
Command! {PinCommand, [
/// Clears the cached PINs
- Clear => commands::pin_clear,
+ Clear => crate::commands::pin_clear,
/// Changes a PIN
- Set(PinSetArgs) => |ctx, args: PinSetArgs| commands::pin_set(ctx, args.pintype),
+ Set(PinSetArgs) => |ctx, args: PinSetArgs| crate::commands::pin_set(ctx, args.pintype),
/// Unblocks and resets the user PIN
- Unblock => commands::pin_unblock,
+ Unblock => crate::commands::pin_unblock,
]}
+Enum! {
+ /// PIN type requested from pinentry.
+ ///
+ /// The available PIN types correspond to the PIN types used by the
+ /// Nitrokey devices: user and admin.
+ PinType, [
+ Admin => "admin",
+ User => "user",
+ ]
+}
+
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PinSetArgs {
+pub struct PinSetArgs {
/// The PIN type to change
- #[structopt(name = "type", possible_values = &pinentry::PinType::all_str())]
- pintype: pinentry::PinType,
+ #[structopt(name = "type", possible_values = &PinType::all_str())]
+ pub pintype: PinType,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PwsArgs {
+pub struct PwsArgs {
#[structopt(subcommand)]
subcmd: PwsCommand,
}
Command! {PwsCommand, [
/// Clears a password safe slot
- Clear(PwsClearArgs) => |ctx, args: PwsClearArgs| commands::pws_clear(ctx, args.slot),
+ Clear(PwsClearArgs) => |ctx, args: PwsClearArgs| crate::commands::pws_clear(ctx, args.slot),
/// Reads a password safe slot
Get(PwsGetArgs) => |ctx, args: PwsGetArgs| {
- commands::pws_get(ctx, args.slot, args.name, args.login, args.password, args.quiet)
+ 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| {
- commands::pws_set(ctx, args.slot, &args.name, &args.login, &args.password)
+ 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| commands::pws_status(ctx, args.all),
+ Status(PwsStatusArgs) => |ctx, args: PwsStatusArgs| crate::commands::pws_status(ctx, args.all),
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PwsClearArgs {
+pub struct PwsClearArgs {
/// The PWS slot to clear
- slot: u8,
+ pub slot: u8,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PwsGetArgs {
+pub struct PwsGetArgs {
/// Shows the name stored on the slot
#[structopt(short, long)]
- name: bool,
+ pub name: bool,
/// Shows the login stored on the slot
#[structopt(short, long)]
- login: bool,
+ pub login: bool,
/// Shows the password stored on the slot
#[structopt(short, long)]
- password: bool,
+ pub password: bool,
/// Prints the stored data without description
#[structopt(short, long)]
- quiet: bool,
+ pub quiet: bool,
/// The PWS slot to read
- slot: u8,
+ pub slot: u8,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PwsSetArgs {
+pub struct PwsSetArgs {
/// The PWS slot to write
- slot: u8,
+ pub slot: u8,
/// The name to store on the slot
- name: String,
+ pub name: String,
/// The login to store on the slot
- login: String,
+ pub login: String,
/// The password to store on the slot
- password: String,
+ pub password: String,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct PwsStatusArgs {
+pub struct PwsStatusArgs {
/// Shows slots that are not programmed
#[structopt(short, long)]
- all: bool,
+ pub all: bool,
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct UnencryptedArgs {
+pub struct UnencryptedArgs {
#[structopt(subcommand)]
subcmd: UnencryptedCommand,
}
@@ -491,49 +419,18 @@ struct UnencryptedArgs {
Command! {UnencryptedCommand, [
/// Changes the configuration of the unencrypted volume on a Nitrokey Storage
Set(UnencryptedSetArgs) => |ctx, args: UnencryptedSetArgs| {
- commands::unencrypted_set(ctx, args.mode)
+ crate::commands::unencrypted_set(ctx, args.mode)
},
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-struct UnencryptedSetArgs {
+pub struct UnencryptedSetArgs {
/// The mode to change to
#[structopt(name = "type", possible_values = &UnencryptedVolumeMode::all_str())]
- mode: UnencryptedVolumeMode,
+ pub mode: UnencryptedVolumeMode,
}
Enum! {UnencryptedVolumeMode, [
ReadWrite => "read-write",
ReadOnly => "read-only",
]}
-
-/// Parse the command-line arguments and execute the selected command.
-pub(crate) fn handle_arguments(ctx: &mut RunCtx<'_>, args: Vec<String>) -> Result<()> {
- use structopt::StructOpt;
-
- match 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(())
- }
- }
- }
-}
diff --git a/nitrocli/src/commands.rs b/src/commands.rs
index e361509..a2b6004 100644
--- a/nitrocli/src/commands.rs
+++ b/src/commands.rs
@@ -18,6 +18,7 @@
// *************************************************************************
use std::fmt;
+use std::mem;
use std::result;
use std::thread;
use std::time;
@@ -34,6 +35,7 @@ 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`.
@@ -42,7 +44,7 @@ fn get_error(msg: &'static str, err: nitrokey::Error) -> Error {
}
/// Set `libnitrokey`'s log level based on the execution context's verbosity.
-fn set_log_level(ctx: &mut args::ExecCtx<'_>) {
+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
@@ -58,9 +60,9 @@ fn set_log_level(ctx: &mut args::ExecCtx<'_>) {
}
/// Connect to any Nitrokey device and do something with it.
-fn with_device<F>(ctx: &mut args::ExecCtx<'_>, op: F) -> Result<()>
+fn with_device<F>(ctx: &mut ExecCtx<'_>, op: F) -> Result<()>
where
- F: FnOnce(&mut args::ExecCtx<'_>, nitrokey::DeviceWrapper<'_>) -> Result<()>,
+ F: FnOnce(&mut ExecCtx<'_>, nitrokey::DeviceWrapper<'_>) -> Result<()>,
{
let mut manager = nitrokey::take()?;
set_log_level(ctx);
@@ -79,9 +81,9 @@ where
}
/// Connect to a Nitrokey Storage device and do something with it.
-fn with_storage_device<F>(ctx: &mut args::ExecCtx<'_>, op: F) -> Result<()>
+fn with_storage_device<F>(ctx: &mut ExecCtx<'_>, op: F) -> Result<()>
where
- F: FnOnce(&mut args::ExecCtx<'_>, nitrokey::Storage<'_>) -> Result<()>,
+ F: FnOnce(&mut ExecCtx<'_>, nitrokey::Storage<'_>) -> Result<()>,
{
let mut manager = nitrokey::take()?;
set_log_level(ctx);
@@ -102,12 +104,12 @@ where
/// Connect to any Nitrokey device, retrieve a password safe handle, and
/// do something with it.
-fn with_password_safe<F>(ctx: &mut args::ExecCtx<'_>, mut op: F) -> Result<()>
+fn with_password_safe<F>(ctx: &mut ExecCtx<'_>, mut op: F) -> Result<()>
where
- F: FnMut(&mut args::ExecCtx<'_>, nitrokey::PasswordSafe<'_, '_>) -> Result<()>,
+ F: FnMut(&mut ExecCtx<'_>, nitrokey::PasswordSafe<'_, '_>) -> Result<()>,
{
with_device(ctx, |ctx, mut device| {
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::User, &device)?;
+ let pin_entry = pinentry::PinEntry::from(args::PinType::User, &device)?;
try_with_pin_and_data(
ctx,
&pin_entry,
@@ -129,15 +131,15 @@ where
///
/// If an error occurs, the error message `msg` is used.
fn authenticate<'mgr, D, A, F>(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
device: D,
- pin_type: pinentry::PinType,
+ pin_type: args::PinType,
msg: &'static str,
op: F,
) -> Result<A>
where
D: Device<'mgr>,
- F: FnMut(&mut args::ExecCtx<'_>, D, &str) -> result::Result<A, (D, nitrokey::Error)>,
+ F: FnMut(&mut ExecCtx<'_>, D, &str) -> result::Result<A, (D, nitrokey::Error)>,
{
let pin_entry = pinentry::PinEntry::from(pin_type, &device)?;
@@ -145,34 +147,28 @@ where
}
/// Authenticate the given device with the user PIN.
-fn authenticate_user<'mgr, T>(
- ctx: &mut args::ExecCtx<'_>,
- device: T,
-) -> Result<nitrokey::User<'mgr, T>>
+fn authenticate_user<'mgr, T>(ctx: &mut ExecCtx<'_>, device: T) -> Result<nitrokey::User<'mgr, T>>
where
T: Device<'mgr>,
{
authenticate(
ctx,
device,
- pinentry::PinType::User,
+ 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 args::ExecCtx<'_>,
- device: T,
-) -> Result<nitrokey::Admin<'mgr, T>>
+fn authenticate_admin<'mgr, T>(ctx: &mut ExecCtx<'_>, device: T) -> Result<nitrokey::Admin<'mgr, T>>
where
T: Device<'mgr>,
{
authenticate(
ctx,
device,
- pinentry::PinType::Admin,
+ args::PinType::Admin,
"Could not authenticate as admin",
|_ctx, device, pin| device.authenticate_admin(pin),
)
@@ -206,14 +202,14 @@ fn get_volume_status(status: &nitrokey::VolumeStatus) -> &'static str {
/// 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 args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
pin_entry: &pinentry::PinEntry,
msg: &'static str,
data: D,
mut op: F,
) -> Result<R>
where
- F: FnMut(&mut args::ExecCtx<'_>, D, &str) -> result::Result<R, (D, E)>,
+ F: FnMut(&mut ExecCtx<'_>, D, &str) -> result::Result<R, (D, E)>,
E: error::TryInto<nitrokey::Error>,
{
let mut data = data;
@@ -246,22 +242,22 @@ where
/// Try to execute the given function with a PIN.
fn try_with_pin_and_data<D, F, R, E>(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
pin_entry: &pinentry::PinEntry,
msg: &'static str,
data: D,
mut op: F,
) -> Result<R>
where
- F: FnMut(&mut args::ExecCtx<'_>, D, &str) -> result::Result<R, (D, E)>,
+ 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.
- pinentry::PinType::Admin => ctx.admin_pin.clone(),
- pinentry::PinType::User => ctx.user_pin.clone(),
+ args::PinType::Admin => ctx.admin_pin.clone(),
+ args::PinType::User => ctx.user_pin.clone(),
};
if let Some(pin) = pin {
@@ -282,7 +278,7 @@ where
/// 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 args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
pin_entry: &pinentry::PinEntry,
msg: &'static str,
mut op: F,
@@ -297,10 +293,7 @@ where
}
/// Pretty print the status of a Nitrokey Storage.
-fn print_storage_status(
- ctx: &mut args::ExecCtx<'_>,
- status: &nitrokey::StorageStatus,
-) -> Result<()> {
+fn print_storage_status(ctx: &mut ExecCtx<'_>, status: &nitrokey::StorageStatus) -> Result<()> {
println!(
ctx,
r#" Storage:
@@ -331,7 +324,7 @@ fn print_storage_status(
/// Query and pretty print the status that is common to all Nitrokey devices.
fn print_status(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
model: &'static str,
device: &nitrokey::DeviceWrapper<'_>,
) -> Result<()> {
@@ -343,7 +336,7 @@ fn print_status(
ctx,
r#"Status:
model: {model}
- serial number: 0x{id}
+ serial number: {id}
firmware version: {fwv}
user retry count: {urc}
admin retry count: {arc}"#,
@@ -366,7 +359,7 @@ fn print_status(
}
/// Inquire the status of the nitrokey.
-pub fn status(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn status(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_device(ctx, |ctx, device| {
let model = match device {
nitrokey::DeviceWrapper::Pro(_) => "Pro",
@@ -377,7 +370,7 @@ pub fn status(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
/// List the attached Nitrokey devices.
-pub fn list(ctx: &mut args::ExecCtx<'_>, no_connect: bool) -> Result<()> {
+pub fn list(ctx: &mut ExecCtx<'_>, no_connect: bool) -> Result<()> {
set_log_level(ctx);
let device_infos = nitrokey::list_devices()?;
@@ -393,7 +386,7 @@ pub fn list(ctx: &mut args::ExecCtx<'_>, no_connect: bool) -> Result<()> {
.map(|m| m.to_string())
.unwrap_or_else(|| "unknown".into());
let serial_number = match device_info.serial_number {
- Some(serial_number) => format!("0x{}", 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
@@ -402,7 +395,7 @@ pub fn list(ctx: &mut args::ExecCtx<'_>, no_connect: bool) -> Result<()> {
"N/A".to_string()
} else {
let device = manager.connect_path(device_info.path.clone())?;
- format!("0x{}", device.get_serial_number()?)
+ device.get_serial_number()?.to_string()
}
}
};
@@ -415,9 +408,9 @@ pub fn list(ctx: &mut args::ExecCtx<'_>, no_connect: bool) -> Result<()> {
}
/// Perform a factory reset.
-pub fn reset(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn reset(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_device(ctx, |ctx, mut device| {
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::Admin, &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.
@@ -439,12 +432,9 @@ pub fn reset(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
/// Change the configuration of the unencrypted volume.
-pub fn unencrypted_set(
- ctx: &mut args::ExecCtx<'_>,
- mode: args::UnencryptedVolumeMode,
-) -> Result<()> {
+pub fn unencrypted_set(ctx: &mut ExecCtx<'_>, mode: args::UnencryptedVolumeMode) -> Result<()> {
with_storage_device(ctx, |ctx, mut device| {
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::Admin, &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,
@@ -464,9 +454,9 @@ pub fn unencrypted_set(
}
/// Open the encrypted volume on the Nitrokey.
-pub fn encrypted_open(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn encrypted_open(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_storage_device(ctx, |ctx, mut device| {
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::User, &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.
@@ -479,7 +469,7 @@ pub fn encrypted_open(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
/// Close the previously opened encrypted volume.
-pub fn encrypted_close(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+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
@@ -494,7 +484,7 @@ pub fn encrypted_close(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
/// Create a hidden volume.
-pub fn hidden_create(ctx: &mut args::ExecCtx<'_>, slot: u8, start: u8, end: u8) -> Result<()> {
+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 {
@@ -513,7 +503,7 @@ pub fn hidden_create(ctx: &mut args::ExecCtx<'_>, slot: u8, start: u8, end: u8)
}
/// Open a hidden volume.
-pub fn hidden_open(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+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 {
@@ -536,7 +526,7 @@ pub fn hidden_open(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
/// Close a previously opened hidden volume.
-pub fn hidden_close(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn hidden_close(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_storage_device(ctx, |_ctx, mut device| {
unsafe { sync() };
@@ -555,7 +545,7 @@ fn format_option<T: fmt::Display>(option: Option<T>) -> String {
}
/// Read the Nitrokey configuration.
-pub fn config_get(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn config_get(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_device(ctx, |ctx, device| {
let config = device
.get_config()
@@ -577,13 +567,18 @@ pub fn config_get(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
/// 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<()> {
+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
@@ -593,7 +588,7 @@ pub fn config_set(
numlock: numlock.or(config.numlock),
capslock: capslock.or(config.capslock),
scrollock: scrollock.or(config.scrollock),
- user_password: user_password.unwrap_or(config.user_password),
+ user_password: otp_pin.unwrap_or(config.user_password),
};
device
.write_config(config)
@@ -602,7 +597,7 @@ pub fn config_set(
}
/// Lock the Nitrokey device.
-pub fn lock(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn lock(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_device(ctx, |_ctx, mut device| {
device
.lock()
@@ -630,7 +625,7 @@ fn get_unix_timestamp() -> Result<u64> {
/// Generate a one-time password on the Nitrokey device.
pub fn otp_get(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
slot: u8,
algorithm: args::OtpAlgorithm,
time: Option<u64>,
@@ -693,16 +688,18 @@ fn prepare_base32_secret(secret: &str) -> Result<String> {
}
/// Configure a one-time password slot on the Nitrokey device.
-pub fn otp_set(
- ctx: &mut args::ExecCtx<'_>,
- mut data: nitrokey::OtpSlotData,
- algorithm: args::OtpAlgorithm,
- counter: u64,
- time_window: u16,
- secret_format: args::OtpSecretFormat,
-) -> Result<()> {
+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 secret_format {
+ let secret = match args.format {
args::OtpSecretFormat::Ascii => prepare_ascii_secret(&data.secret)?,
args::OtpSecretFormat::Base32 => prepare_base32_secret(&data.secret)?,
args::OtpSecretFormat::Hex => {
@@ -720,9 +717,9 @@ pub fn otp_set(
};
let data = nitrokey::OtpSlotData { secret, ..data };
let mut 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),
+ 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(())
@@ -730,11 +727,7 @@ pub fn otp_set(
}
/// Clear an OTP slot.
-pub fn otp_clear(
- ctx: &mut args::ExecCtx<'_>,
- slot: u8,
- algorithm: args::OtpAlgorithm,
-) -> Result<()> {
+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 {
@@ -747,7 +740,7 @@ pub fn otp_clear(
}
fn print_otp_status(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
algorithm: args::OtpAlgorithm,
device: &nitrokey::DeviceWrapper<'_>,
all: bool,
@@ -781,7 +774,7 @@ fn print_otp_status(
}
/// Print the status of the OTP slots.
-pub fn otp_status(ctx: &mut args::ExecCtx<'_>, all: bool) -> Result<()> {
+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)?;
@@ -791,13 +784,10 @@ pub fn otp_status(ctx: &mut args::ExecCtx<'_>, all: bool) -> Result<()> {
}
/// Clear the PIN stored by various operations.
-pub fn pin_clear(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn pin_clear(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_device(ctx, |_ctx, device| {
- pinentry::clear(&pinentry::PinEntry::from(
- pinentry::PinType::Admin,
- &device,
- )?)?;
- pinentry::clear(&pinentry::PinEntry::from(pinentry::PinType::User, &device)?)?;
+ pinentry::clear(&pinentry::PinEntry::from(args::PinType::Admin, &device)?)?;
+ pinentry::clear(&pinentry::PinEntry::from(args::PinType::User, &device)?)?;
Ok(())
})
}
@@ -806,20 +796,16 @@ pub fn pin_clear(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
///
/// 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> {
+fn choose_pin(ctx: &mut ExecCtx<'_>, pin_entry: &pinentry::PinEntry, new: bool) -> Result<String> {
let new_pin = match pin_entry.pin_type() {
- pinentry::PinType::Admin => {
+ args::PinType::Admin => {
if new {
&ctx.new_admin_pin
} else {
&ctx.admin_pin
}
}
- pinentry::PinType::User => {
+ args::PinType::User => {
if new {
&ctx.new_user_pin
} else {
@@ -839,7 +825,7 @@ fn choose_pin(
}
/// Change a PIN.
-pub fn pin_set(ctx: &mut args::ExecCtx<'_>, pin_type: pinentry::PinType) -> Result<()> {
+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)?;
@@ -849,8 +835,8 @@ pub fn pin_set(ctx: &mut args::ExecCtx<'_>, pin_type: pinentry::PinType) -> Resu
&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),
+ args::PinType::Admin => device.change_admin_pin(&current_pin, &new_pin),
+ args::PinType::User => device.change_user_pin(&current_pin, &new_pin),
},
)?;
@@ -862,11 +848,11 @@ pub fn pin_set(ctx: &mut args::ExecCtx<'_>, pin_type: pinentry::PinType) -> Resu
}
/// Unblock and reset the user PIN.
-pub fn pin_unblock(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
+pub fn pin_unblock(ctx: &mut ExecCtx<'_>) -> Result<()> {
with_device(ctx, |ctx, mut device| {
- let pin_entry = pinentry::PinEntry::from(pinentry::PinType::User, &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(pinentry::PinType::Admin, &device)?;
+ let pin_entry = pinentry::PinEntry::from(args::PinType::Admin, &device)?;
try_with_pin(
ctx,
@@ -878,7 +864,7 @@ pub fn pin_unblock(ctx: &mut args::ExecCtx<'_>) -> Result<()> {
}
fn print_pws_data(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
description: &'static str,
result: result::Result<String, nitrokey::Error>,
quiet: bool,
@@ -911,7 +897,7 @@ fn check_slot(pws: &nitrokey::PasswordSafe<'_, '_>, slot: u8) -> Result<()> {
/// Read a PWS slot.
pub fn pws_get(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
slot: u8,
show_name: bool,
show_login: bool,
@@ -937,7 +923,7 @@ pub fn pws_get(
/// Write a PWS slot.
pub fn pws_set(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
slot: u8,
name: &str,
login: &str,
@@ -951,7 +937,7 @@ pub fn pws_set(
}
/// Clear a PWS slot.
-pub fn pws_clear(ctx: &mut args::ExecCtx<'_>, slot: u8) -> Result<()> {
+pub fn pws_clear(ctx: &mut ExecCtx<'_>, slot: u8) -> Result<()> {
with_password_safe(ctx, |_ctx, mut pws| {
pws
.erase_slot(slot)
@@ -960,7 +946,7 @@ pub fn pws_clear(ctx: &mut args::ExecCtx<'_>, slot: u8) -> Result<()> {
}
fn print_pws_slot(
- ctx: &mut args::ExecCtx<'_>,
+ ctx: &mut ExecCtx<'_>,
pws: &nitrokey::PasswordSafe<'_, '_>,
slot: usize,
programmed: bool,
@@ -981,7 +967,7 @@ fn print_pws_slot(
}
/// Print the status of all PWS slots.
-pub fn pws_status(ctx: &mut args::ExecCtx<'_>, all: bool) -> Result<()> {
+pub fn pws_status(ctx: &mut ExecCtx<'_>, all: bool) -> Result<()> {
with_password_safe(ctx, |ctx, pws| {
let slots = pws
.get_slot_status()
diff --git a/nitrocli/src/error.rs b/src/error.rs
index 3e458a6..e891da2 100644
--- a/nitrocli/src/error.rs
+++ b/src/error.rs
@@ -64,6 +64,12 @@ impl From<&str> for Error {
}
}
+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)
diff --git a/nitrocli/src/main.rs b/src/main.rs
index 9e81bf8..27097c9 100644
--- a/nitrocli/src/main.rs
+++ b/src/main.rs
@@ -34,7 +34,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
- plugin_as_library,
private_in_public,
proc_macro_derive_resolution_fallback,
renamed_and_removed_lints,
@@ -93,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.
@@ -118,7 +199,7 @@ 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) => {
let _ = eprintln!(ctx, "{}", err);
diff --git a/nitrocli/src/pinentry.rs b/src/pinentry.rs
index fd47657..d1387f4 100644
--- a/nitrocli/src/pinentry.rs
+++ b/src/pinentry.rs
@@ -25,19 +25,10 @@ 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.
@@ -52,13 +43,13 @@ 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<'mgr, 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<'mgr>,
{
@@ -71,7 +62,7 @@ impl PinEntry {
})
}
- pub fn pin_type(&self) -> PinType {
+ pub fn pin_type(&self) -> args::PinType {
self.pin_type
}
}
@@ -81,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()
}
@@ -99,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",
@@ -118,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,
}
}
}
@@ -127,7 +118,7 @@ impl SecretEntry for PinEntry {
#[derive(Debug)]
pub struct PwdEntry {
model: nitrokey::Model,
- serial: String,
+ serial: nitrokey::SerialNumber,
}
impl PwdEntry {
@@ -231,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>,
@@ -288,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,
{
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 fa311d5..fa311d5 100644
--- a/nitrocli/src/tests/config.rs
+++ b/src/tests/config.rs
diff --git a/nitrocli/src/tests/encrypted.rs b/src/tests/encrypted.rs
index aed2662..aed2662 100644
--- a/nitrocli/src/tests/encrypted.rs
+++ b/src/tests/encrypted.rs
diff --git a/nitrocli/src/tests/hidden.rs b/src/tests/hidden.rs
index eabcfd4..eabcfd4 100644
--- a/nitrocli/src/tests/hidden.rs
+++ b/src/tests/hidden.rs
diff --git a/nitrocli/src/tests/list.rs b/src/tests/list.rs
index 4f80afe..4f80afe 100644
--- a/nitrocli/src/tests/list.rs
+++ b/src/tests/list.rs
diff --git a/nitrocli/src/tests/lock.rs b/src/tests/lock.rs
index b29f394..b29f394 100644
--- a/nitrocli/src/tests/lock.rs
+++ b/src/tests/lock.rs
diff --git a/nitrocli/src/tests/mod.rs b/src/tests/mod.rs
index 1edf8f2..abf63e3 100644
--- a/nitrocli/src/tests/mod.rs
+++ b/src/tests/mod.rs
@@ -178,7 +178,7 @@ impl Nitrocli {
/// Run `nitrocli`'s `handle_arguments` function.
pub fn handle(&mut self, args: &[&str]) -> crate::Result<String> {
- let (res, out, _) = self.do_run(args, |c, a| crate::args::handle_arguments(c, a));
+ 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 0ccecf9..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 *
diff --git a/nitrocli/src/tests/pin.rs b/src/tests/pin.rs
index 958a36d..958a36d 100644
--- a/nitrocli/src/tests/pin.rs
+++ b/src/tests/pin.rs
diff --git a/nitrocli/src/tests/pws.rs b/src/tests/pws.rs
index 651b2d5..651b2d5 100644
--- a/nitrocli/src/tests/pws.rs
+++ b/src/tests/pws.rs
diff --git a/nitrocli/src/tests/reset.rs b/src/tests/reset.rs
index e197970..e197970 100644
--- a/nitrocli/src/tests/reset.rs
+++ b/src/tests/reset.rs
diff --git a/nitrocli/src/tests/run.rs b/src/tests/run.rs
index 22e7004..22e7004 100644
--- a/nitrocli/src/tests/run.rs
+++ b/src/tests/run.rs
diff --git a/nitrocli/src/tests/status.rs b/src/tests/status.rs
index c9f4976..c9f4976 100644
--- a/nitrocli/src/tests/status.rs
+++ b/src/tests/status.rs
diff --git a/nitrocli/src/tests/unencrypted.rs b/src/tests/unencrypted.rs
index ceeb17c..ceeb17c 100644
--- a/nitrocli/src/tests/unencrypted.rs
+++ b/src/tests/unencrypted.rs
diff --git a/structopt/.gitignore b/structopt/.gitignore
deleted file mode 100644
index ea63af4..0000000
--- a/structopt/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-target
-Cargo.lock
-*~
-
-.idea/
-.vscode/
diff --git a/structopt/.travis.yml b/structopt/.travis.yml
deleted file mode 100644
index dff3050..0000000
--- a/structopt/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-language: rust
-matrix:
- include:
- - rust: stable
- name: check if `cargo fmt --all` is applied
- before_script: rustup component add rustfmt-preview
- script: cargo fmt --all -- --check
-
- - language: node_js
- node_js: node
- name: check links
- install: npm install -g markdown-link-check
- script:
- - markdown-link-check -c link-check-headers.json README.md
- - markdown-link-check -c link-check-headers.json CHANGELOG.md
- - markdown-link-check -c link-check-headers.json examples/README.md
-
- - rust: 1.36.0
- - rust: stable
- - rust: beta
- - rust: nightly
-
-script:
- - cargo test $FEATURES
diff --git a/structopt/CHANGELOG.md b/structopt/CHANGELOG.md
deleted file mode 100644
index ed2a17f..0000000
--- a/structopt/CHANGELOG.md
+++ /dev/null
@@ -1,444 +0,0 @@
-# v0.3.7 (2019-12-28)
-
-Nothing's new. Just re-release of `v0.3.6` due to
-[the mess with versioning](https://github.com/TeXitoi/structopt/issues/315#issuecomment-568502792).
-
-You may notice that `structopt-derive` was bumped to `v0.4.0`, that's OK, it's not a breaking change.
-`structopt` will pull the right version in on its on.
-
-# v0.3.6 (2019-12-22) - YANKED
-
-This is unusually big patch release. It contains a number of bugfixes and
-new features, some of them may theoretically be considered breaking. We did our best
-to avoid any problems on user's side but, if it wasn't good enough, please
-[file an issue ASAP](https://github.com/TeXitoi/structopt/issues).
-
-## Bugfixes
-
-* `structopt` used to treat `::path::to::type::Vec<T>` as `Vec<T>`
- special type. [This was considered erroneous](https://github.com/TeXitoi/structopt/pull/287).
- (same for `Option<T>` and `bool`). Now only exact `Vec<T>` match is a special type.
-
-* `#[structopt(version = expr)]` where `expr` is not a string literal used to get
- overridden by auto generated `.version()` call,
- [incorrectly](https://github.com/TeXitoi/structopt/issues/283). Now it doesn't.
-
-* Fixed bug with top-level `App::*` calls on multiple `struct`s, see
- [#289](https://github.com/TeXitoi/structopt/issues/265).
-
-* Positional `bool` args with no explicit `#[structopt(parse(...))]` annotation are
- now prohibited. This couldn't work well anyway, see
- [this example](https://github.com/TeXitoi/structopt/blob/master/examples/true_or_false.rs)
- for details.
-
-* Now we've instituted strict priority between doc comments, about, help, and the like.
- See [the documentation](https://docs.rs/structopt/0.3/structopt/#help-messages).
-
- **HUGE THANKS to [`@ssokolow`](https://github.com/ssokolow)** for tidying up our documentation,
- teaching me English and explaining why our doc used to suck. I promise I'll make the rest
- of the doc up to your standards... sometime later!
-
-## New features
-
-* Implement `StructOpt` for `Box<impl StructOpt>` so from now on you can use `Box<T>`
- with `flatten` and `subcommand` ([#304](https://github.com/TeXitoi/structopt/issues/304)).
-
- ```rust
- enum Command {
- #[structopt(name = "version")]
- PrintVersion,
-
- #[structopt(name = "second")]
- DoSomething {
- #[structopt(flatten)]
- config: Box<DoSomethingConfig>,
- },
-
- #[structopt(name = "first")]
- DoSomethingElse {
- #[structopt(flatten)]
- config: Box<DoSomethingElseConfig>,
- }
- }
- ```
-
-* Introduced `#[structopt(verbatim_doc_comment)]` attribute that keeps line breaks in
- doc comments, see
- [the documentation](https://docs.rs/structopt/0.3/structopt/#doc-comment-preprocessing-and-structoptverbatim_doc_comment).
-
-* Introduced `#[structopt(rename_all_env)]` and `#[structopt(env)]` magical methods
- so you can derive env var's name from field's name. See
- [the documentation](https://docs.rs/structopt/0.3/structopt/#auto-deriving-environment-variables).
-
-## Improvements
-
-* Now we have nice README for our examples,
- [check it out](https://github.com/TeXitoi/structopt/tree/master/examples)!
-
-* Some error messages were improved and clarified, thanks for all people involved!
-
-
-# v0.3.5 (2019-11-22)
-
-* `try_from_str` functions are now called with a `&str` instead of a `&String` ([#282](https://github.com/TeXitoi/structopt/pull/282))
-
-# v0.3.4 (2019-11-08)
-
-* `rename_all` does not apply to fields that were annotated with explicit
- `short/long/name = "..."` anymore ([#265](https://github.com/TeXitoi/structopt/issues/265))
-* Now raw idents are handled correctly ([#269](https://github.com/TeXitoi/structopt/issues/269))
-* Some documentation improvements and clarification.
-
-# v0.3.3 (2019-10-10)
-
-* Add `from_flag` custom parser to create flags from non-bool types.
- Fixes [#185](https://github.com/TeXitoi/structopt/issues/185)
-
-# v0.3.2 (2019-09-18)
-
-* `structopt` does not replace `:` with `, ` inside "author" strings while inside `<...>`.
- Fixes [#156](https://github.com/TeXitoi/structopt/issues/156)
-* Introduced [`#[structopt(skip = expr)]` syntax](https://docs.rs/structopt/0.3.2/structopt/#skipping-fields).
-
-# v0.3.1 (2019-09-06)
-
-* Fix error messages ([#241](https://github.com/TeXitoi/structopt/issues/241))
-* Fix "`skip` plus long doc comment" bug ([#245](https://github.com/TeXitoi/structopt/issues/245))
-* Now `structopt` emits dummy `StructOpt` implementation along with an error. It suppresses
- meaningless errors like `from_args method is not found for Opt`
-* `.version()` not get generated if `CARGO_PKG_VERSION` is not set anymore.
-
-# v0.3.0 (2019-08-30)
-
-## Breaking changes
-
-### Bump minimum rustc version to 1.36 by [@TeXitoi](https://github.com/TeXitoi)
-Now `rustc` 1.36 is the minimum compiler version supported by `structopt`,
-it likely won't work with older compilers.
-
-### Remove "nightly" feature
-Once upon a time this feature had been used to enable some of improvements
-in `proc-macro2` crate that were available only on nightly. Nowadays this feature doesn't
-mean anything so it's now removed.
-
-### Support optional vectors of arguments for distinguishing between `-o 1 2`, `-o` and no option provided at all by [@sphynx](https://github.com/sphynx) ([#180](https://github.com/TeXitoi/structopt/issues/188)).
-
-```rust
-#[derive(StructOpt)]
-struct Opt {
- #[structopt(long)]
- fruit: Option<Vec<String>>,
-}
-
-fn main() {
- assert_eq!(Opt::from_args(&["test"]), None);
- assert_eq!(Opt::from_args(&["test", "--fruit"]), Some(vec![]));
- assert_eq!(Opt::from_args(&["test", "--fruit=apple orange"]), Some(vec!["apple", "orange"]));
-}
-```
-
-If you need to fall back to the old behavior you can use a type alias:
-```rust
-type Something = Vec<String>;
-
-#[derive(StructOpt)]
-struct Opt {
- #[structopt(long)]
- fruit: Option<Something>,
-}
-```
-
-### Change default case from 'Verbatim' into 'Kebab' by [@0ndorio](https://github.com/0ndorio) ([#202](https://github.com/TeXitoi/structopt/issues/202)).
-`structopt` 0.3 uses field renaming to deduce a name for long options and subcommands.
-
-```rust
-#[derive(StructOpt)]
-struct Opt {
- #[structopt(long)]
- http_addr: String, // will be renamed to `--http-addr`
-
- #[structopt(subcommand)]
- addr_type: AddrType // this adds `addr-type` subcommand
-}
-```
-
-`structopt` 0.2 used to leave things "as is", not renaming anything. If you want to keep old
-behavior add `#[structopt(rename_all = "verbatim")]` on top of a `struct`/`enum`.
-
-### Change `version`, `author` and `about` attributes behavior.
-Proposed by [@TeXitoi](https://github.com/TeXitoi) [(#217)](https://github.com/TeXitoi/structopt/issues/217), implemented by [@CreepySkeleton](https://github.com/CreepySkeleton) [(#229)](https://github.com/TeXitoi/structopt/pull/229).
-
-`structopt` have been deducing `version`, `author`, and `about` properties from `Cargo.toml`
-for a long time (more accurately, from `CARGO_PKG_...` environment variables).
-But many users found this behavior somewhat confusing, and a hack was added to cancel out
-this behavior: `#[structopt(author = "")]`.
-
-In `structopt` 0.3 this has changed.
-* `author` and `about` are no longer deduced by default. You should use `#[structopt(author, about)]`
- to explicitly request `structopt` to deduce them.
-* Contrary, `version` **is still deduced by default**. You can use `#[structopt(no_version)]` to
- cancel it out.
-* `#[structopt(author = "", about = "", version = "")]` is no longer a valid syntax
- and will trigger an error.
-* `#[structopt(version = "version", author = "author", about = "about")]` syntax
- stays unaffected by this changes.
-
-### Raw attributes are removed ([#198](https://github.com/TeXitoi/structopt/pull/198)) by [@sphynx](https://github.com/sphynx)
-In `structopt` 0.2 you were able to use any method from `clap::App` and `clap::Arg` via
-raw attribute: `#[structopt(raw(method_name = "arg"))]`. This syntax was kind of awkward.
-
-```rust
-#[derive(StructOpt, Debug)]
-#[structopt(raw(
- global_settings = "&[AppSettings::ColoredHelp, AppSettings::VersionlessSubcommands]"
-))]
-struct Opt {
- #[structopt(short = "l", long = "level", raw(aliases = r#"&["set-level", "lvl"]"#))]
- level: Vec<String>,
-}
-```
-
-Raw attributes were removed in 0.3. Now you can use any method from `App` and `Arg` *directly*:
-```rust
-#[derive(StructOpt)]
-#[structopt(global_settings(&[AppSettings::ColoredHelp, AppSettings::VersionlessSubcommands]))]
-struct Opt {
- #[structopt(short = "l", long = "level", aliases(&["set-level", "lvl"]))]
- level: Vec<String>,
-}
-```
-
-## Improvements
-
-### Support skipping struct fields
-Proposed by [@Morganamilo](https://github.com/Morganamilo) in ([#174](https://github.com/TeXitoi/structopt/issues/174))
-implemented by [@sphynx](https://github.com/sphynx) in ([#213](https://github.com/TeXitoi/structopt/issues/213)).
-
-Sometimes you want to include some fields in your `StructOpt` `struct` that are not options
-and `clap` should know nothing about them. In `structopt` 0.3 it's possible via the
-`#[structopt(skip)]` attribute. The field in question will be assigned with `Default::default()`
-value.
-
-```rust
-#[derive(StructOpt)]
-struct Opt {
- #[structopt(short, long)]
- speed: f32,
-
- car: String,
-
- // this field should not generate any arguments
- #[structopt(skip)]
- meta: Vec<u64>
-}
-```
-
-### Add optional feature to support `paw` by [@gameldar](https://github.com/gameldar) ([#187](https://github.com/TeXitoi/structopt/issues/187))
-
-### Significantly improve error reporting by [@CreepySkeleton](https://github.com/CreepySkeleton) ([#225](https://github.com/TeXitoi/structopt/pull/225/))
-Now (almost) every error message points to the location it originates from:
-
-```text
-error: default_value is meaningless for bool
- --> $DIR/bool_default_value.rs:14:24
- |
-14 | #[structopt(short, default_value = true)]
- | ^^^^^^^^^^^^^
-```
-
-# v0.2.16 (2019-05-29)
-
-### Support optional options with optional argument, allowing `cmd [--opt[=value]]` by [@sphynx](https://github.com/sphynx) ([#188](https://github.com/TeXitoi/structopt/issues/188))
-Sometimes you want to represent an optional option that optionally takes an argument,
-i.e `[--opt[=value]]`. This is represented by `Option<Option<T>>`
-
-```rust
-#[derive(StructOpt)]
-struct Opt {
- #[structopt(long)]
- fruit: Option<Option<String>>,
-}
-
-fn main() {
- assert_eq!(Opt::from_args(&["test"]), None);
- assert_eq!(Opt::from_args(&["test", "--fruit"]), Some(None));
- assert_eq!(Opt::from_args(&["test", "--fruit=apple"]), Some("apple"));
-}
-```
-
-# v0.2.15 (2019-03-08)
-
-* Fix [#168](https://github.com/TeXitoi/structopt/issues/168) by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.14 (2018-12-10)
-
-* Introduce smarter parsing of doc comments by [@0ndorio](https://github.com/0ndorio)
-
-# v0.2.13 (2018-11-01)
-
-* Automatic naming of fields and subcommands by [@0ndorio](https://github.com/0ndorio)
-
-# v0.2.12 (2018-10-11)
-
-* Fix minimal clap version by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.11 (2018-10-05)
-
-* Upgrade syn to 0.15 by [@konstin](https://github.com/konstin)
-
-# v0.2.10 (2018-06-07)
-
-* 1.21.0 is the minimum required rustc version by
- [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.9 (2018-06-05)
-
-* Fix a bug when using `flatten` by
- [@fbenkstein](https://github.com/fbenkstein)
-* Update syn, quote and proc_macro2 by
- [@TeXitoi](https://github.com/TeXitoi)
-* Fix a regression when there is multiple authors by
- [@windwardly](https://github.com/windwardly)
-
-# v0.2.8 (2018-04-28)
-
-* Add `StructOpt::from_iter_safe()`, which returns an `Error` instead of
- killing the program when it fails to parse, or parses one of the
- short-circuiting flags. ([#98](https://github.com/TeXitoi/structopt/pull/98)
- by [@quodlibetor](https://github.com/quodlibetor))
-* Allow users to enable `clap` features independently by
- [@Kerollmops](https://github.com/Kerollmops)
-* Fix a bug when flattening an enum
- ([#103](https://github.com/TeXitoi/structopt/pull/103) by
- [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.7 (2018-04-12)
-
-* Add flattening, the insertion of options of another StructOpt struct
- into another ([#92](https://github.com/TeXitoi/structopt/pull/92))
- by [@birkenfeld](https://github.com/birkenfeld)
-* Fail compilation when using `default_value` or `required` with
- `Option` ([#88](https://github.com/TeXitoi/structopt/pull/88)) by
- [@Kerollmops](https://github.com/Kerollmops)
-
-# v0.2.6 (2018-03-31)
-
-* Fail compilation when using `default_value` or `required` with `bool` ([#80](https://github.com/TeXitoi/structopt/issues/80)) by [@TeXitoi](https://github.com/TeXitoi)
-* Fix compilation with `#[deny(warnings)]` with the `!` type (https://github.com/rust-lang/rust/pull/49039#issuecomment-376398999) by [@TeXitoi](https://github.com/TeXitoi)
-* Improve first example in the documentation ([#82](https://github.com/TeXitoi/structopt/issues/82)) by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.5 (2018-03-07)
-
-* Work around breakage when `proc-macro2`'s nightly feature is enabled. ([#77](https://github.com/Texitoi/structopt/pull/77) and [proc-macro2#67](https://github.com/alexcrichton/proc-macro2/issues/67)) by [@fitzgen](https://github.com/fitzgen)
-
-# v0.2.4 (2018-02-25)
-
-* Fix compilation with `#![deny(missig_docs]` ([#74](https://github.com/TeXitoi/structopt/issues/74)) by [@TeXitoi](https://github.com/TeXitoi)
-* Fix [#76](https://github.com/TeXitoi/structopt/issues/76) by [@TeXitoi](https://github.com/TeXitoi)
-* Re-licensed to Apache-2.0/MIT by [@CAD97](https://github.com/cad97)
-
-# v0.2.3 (2018-02-16)
-
-* An empty line in a doc comment will result in a double linefeed in the generated about/help call by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.2 (2018-02-12)
-
-* Fix [#66](https://github.com/TeXitoi/structopt/issues/66) by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.1 (2018-02-11)
-
-* Fix a bug around enum tuple and the about message in the global help by [@TeXitoi](https://github.com/TeXitoi)
-* Fix [#65](https://github.com/TeXitoi/structopt/issues/65) by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.2.0 (2018-02-10)
-
-## Breaking changes
-
-### Don't special case `u64` by [@SergioBenitez](https://github.com/SergioBenitez)
-
-If you are using a `u64` in your struct to get the number of occurence of a flag, you should now add `parse(from_occurrences)` on the flag.
-
-For example
-```rust
-#[structopt(short = "v", long = "verbose")]
-verbose: u64,
-```
-must be changed by
-```rust
-#[structopt(short = "v", long = "verbose", parse(from_occurrences))]
-verbose: u64,
-```
-
-This feature was surprising as shown in [#30](https://github.com/TeXitoi/structopt/issues/30). Using the `parse` feature seems much more natural.
-
-### Change the signature of `Structopt::from_clap` to take its argument by reference by [@TeXitoi](https://github.com/TeXitoi)
-
-There was no reason to take the argument by value. Most of the StructOpt users will not be impacted by this change. If you are using `StructOpt::from_clap`, just add a `&` before the argument.
-
-### Fail if attributes are not used by [@TeXitoi](https://github.com/TeXitoi)
-
-StructOpt was quite fuzzy in its attribute parsing: it was only searching for interresting things, e. g. something like `#[structopt(foo(bar))]` was accepted but not used. It now fails the compilation.
-
-You should have nothing to do here. This breaking change may highlight some missuse that can be bugs.
-
-In future versions, if there is cases that are not highlighed, they will be considerated as bugs, not breaking changes.
-
-### Use `raw()` wrapping instead of `_raw` suffixing by [@TeXitoi](https://github.com/TeXitoi)
-
-The syntax of raw attributes is changed to improve the syntax.
-
-You have to change `foo_raw = "bar", baz_raw = "foo"` by `raw(foo = "bar", baz = "foo")` or `raw(foo = "bar"), raw(baz = "foo")`.
-
-## New features
-
-* Add `parse(from_occurrences)` parser by [@SergioBenitez](https://github.com/SergioBenitez)
-* Support 1-uple enum variant as subcommand by [@TeXitoi](https://github.com/TeXitoi)
-* structopt-derive crate is now an implementation detail, structopt reexport the custom derive macro by [@TeXitoi](https://github.com/TeXitoi)
-* Add the `StructOpt::from_iter` method by [@Kerollmops](https://github.com/Kerollmops)
-
-## Documentation
-
-* Improve doc by [@bestouff](https://github.com/bestouff)
-* All the documentation is now on the structopt crate by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.1.7 (2018-01-23)
-
-* Allow opting out of clap default features by [@ski-csis](https://github.com/ski-csis)
-
-# v0.1.6 (2017-11-25)
-
-* Improve documentation by [@TeXitoi](https://github.com/TeXitoi)
-* Fix bug [#31](https://github.com/TeXitoi/structopt/issues/31) by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.1.5 (2017-11-14)
-
-* Fix a bug with optional subsubcommand and Enum by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.1.4 (2017-11-09)
-
-* Implement custom string parser from either `&str` or `&OsStr` by [@kennytm](https://github.com/kennytm)
-
-# v0.1.3 (2017-11-01)
-
-* Improve doc by [@TeXitoi](https://github.com/TeXitoi)
-
-# v0.1.2 (2017-11-01)
-
-* Fix bugs [#24](https://github.com/TeXitoi/structopt/issues/24) and [#25](https://github.com/TeXitoi/structopt/issues/25) by [@TeXitoi](https://github.com/TeXitoi)
-* Support of methods with something else that a string as argument thanks to `_raw` suffix by [@Flakebi](https://github.com/Flakebi)
-
-# v0.1.1 (2017-09-22)
-
-* Better formating of multiple authors by [@killercup](https://github.com/killercup)
-
-# v0.1.0 (2017-07-17)
-
-* Subcommand support by [@williamyaoh](https://github.com/williamyaoh)
-
-# v0.0.5 (2017-06-16)
-
-* Using doc comment to populate help by [@killercup](https://github.com/killercup)
-
-# v0.0.3 (2017-02-11)
-
-* First version with flags, arguments and options support by [@TeXitoi](https://github.com/TeXitoi)
diff --git a/structopt/Cargo.toml b/structopt/Cargo.toml
deleted file mode 100644
index b43728b..0000000
--- a/structopt/Cargo.toml
+++ /dev/null
@@ -1,35 +0,0 @@
-[package]
-name = "structopt"
-version = "0.3.7"
-edition = "2018"
-authors = ["Guillaume Pinot <texitoi@texitoi.eu>", "others"]
-description = "Parse command line argument by defining a struct."
-documentation = "https://docs.rs/structopt"
-repository = "https://github.com/TeXitoi/structopt"
-keywords = ["clap", "cli", "derive", "docopt"]
-categories = ["command-line-interface"]
-license = "Apache-2.0/MIT"
-readme = "README.md"
-
-[features]
-default = ["clap/default"]
-suggestions = ["clap/suggestions"]
-color = ["clap/color"]
-wrap_help = ["clap/wrap_help"]
-yaml = ["clap/yaml"]
-lints = ["clap/lints"]
-debug = ["clap/debug"]
-no_cargo = ["clap/no_cargo"]
-doc = ["clap/doc"]
-paw = ["structopt-derive/paw"]
-
-[badges]
-travis-ci = { repository = "TeXitoi/structopt" }
-
-[dependencies]
-clap = { version = "2.33", default-features = false }
-structopt-derive = { path = "structopt-derive", version = "=0.4.0" }
-
-[dev-dependencies]
-trybuild = "1.0.5"
-rustversion = "1"
diff --git a/structopt/LICENSE-APACHE b/structopt/LICENSE-APACHE
deleted file mode 100644
index 261eeb9..0000000
--- a/structopt/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/structopt/LICENSE-MIT b/structopt/LICENSE-MIT
deleted file mode 100644
index e931b83..0000000
--- a/structopt/LICENSE-MIT
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-
-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/structopt/README.md b/structopt/README.md
deleted file mode 100644
index 48ac3c3..0000000
--- a/structopt/README.md
+++ /dev/null
@@ -1,148 +0,0 @@
-# StructOpt [![Build status](https://travis-ci.org/TeXitoi/structopt.svg?branch=master)](https://travis-ci.org/TeXitoi/structopt) [![](https://img.shields.io/crates/v/structopt.svg)](https://crates.io/crates/structopt) [![](https://docs.rs/structopt/badge.svg)](https://docs.rs/structopt)
-
-Parse command line arguments by defining a struct. It combines [clap](https://crates.io/crates/clap) with custom derive.
-
-## Documentation
-
-Find it on [Docs.rs](https://docs.rs/structopt). You can also check the [examples](https://github.com/TeXitoi/structopt/tree/master/examples) and the [changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md).
-
-## Example
-
-Add `structopt` to your dependencies of your `Cargo.toml`:
-```toml
-[dependencies]
-structopt = "0.3"
-```
-
-And then, in your rust file:
-```rust
-use std::path::PathBuf;
-use structopt::StructOpt;
-
-/// A basic example
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- // A flag, true if used in the command line. Note doc comment will
- // be used for the help message of the flag. The name of the
- // argument will be, by default, based on the name of the field.
- /// Activate debug mode
- #[structopt(short, long)]
- debug: bool,
-
- // The number of occurrences of the `v/verbose` flag
- /// Verbose mode (-v, -vv, -vvv, etc.)
- #[structopt(short, long, parse(from_occurrences))]
- verbose: u8,
-
- /// Set speed
- #[structopt(short, long, default_value = "42")]
- speed: f64,
-
- /// Output file
- #[structopt(short, long, parse(from_os_str))]
- output: PathBuf,
-
- // the long option will be translated by default to kebab case,
- // i.e. `--nb-cars`.
- /// Number of cars
- #[structopt(short = "c", long)]
- nb_cars: Option<i32>,
-
- /// admin_level to consider
- #[structopt(short, long)]
- level: Vec<String>,
-
- /// Files to process
- #[structopt(name = "FILE", parse(from_os_str))]
- files: Vec<PathBuf>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:#?}", opt);
-}
-```
-
-Using this example:
-```
-$ ./basic
-error: The following required arguments were not provided:
- --output <output>
-
-USAGE:
- basic --output <output> --speed <speed>
-
-For more information try --help
-$ ./basic --help
-basic 0.3.0
-Guillaume Pinot <texitoi@texitoi.eu>, others
-A basic example
-
-USAGE:
- basic [FLAGS] [OPTIONS] --output <output> [--] [file]...
-
-FLAGS:
- -d, --debug Activate debug mode
- -h, --help Prints help information
- -V, --version Prints version information
- -v, --verbose Verbose mode (-v, -vv, -vvv, etc.)
-
-OPTIONS:
- -l, --level <level>... admin_level to consider
- -c, --nb-cars <nb-cars> Number of cars
- -o, --output <output> Output file
- -s, --speed <speed> Set speed [default: 42]
-
-ARGS:
- <file>... Files to process
-$ ./basic -o foo.txt
-Opt {
- debug: false,
- verbose: 0,
- speed: 42.0,
- output: "foo.txt",
- nb_cars: None,
- level: [],
- files: [],
-}
-$ ./basic -o foo.txt -dvvvs 1337 -l alice -l bob --nb-cars 4 bar.txt baz.txt
-Opt {
- debug: true,
- verbose: 3,
- speed: 1337.0,
- output: "foo.txt",
- nb_cars: Some(
- 4,
- ),
- level: [
- "alice",
- "bob",
- ],
- files: [
- "bar.txt",
- "baz.txt",
- ],
-}
-```
-
-## StructOpt rustc version policy
-
-- Minimum rustc version modification must be specified in the [changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) and in the [travis configuration](https://github.com/TeXitoi/structopt/blob/master/.travis.yml).
-- Contributors can increment minimum rustc version without any justification if the new version is required by the latest version of one of StructOpt's dependencies (`cargo update` will not fail on StructOpt).
-- Contributors can increment minimum rustc version if the library user experience is improved.
-
-## License
-
-Licensed under either of
-
-- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>)
-- MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://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/structopt/examples/README.md b/structopt/examples/README.md
deleted file mode 100644
index f0db20b..0000000
--- a/structopt/examples/README.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Collection of examples "how to use `structopt`"
-
-### [Help on the bottom](after_help.rs)
-
-How to append a postscript to the help message generated.
-
-### [At least N](at_least_two.rs)
-
-How to require presence of at least N values, like `val1 val2 ... valN ... valM`.
-
-### [Basic](basic.rs)
-
-A basic example how to use `structopt`.
-
-### [Deny missing docs](deny_missing_docs.rs)
-
-**This is not an example but a test**, it should be moved to `tests` folder
-as soon as [this](https://github.com/rust-lang/rust/issues/24584) is fixed (if ever).
-
-### [Doc comments](doc_comments.rs)
-
-How to use doc comments in place of `help/long_help`.
-
-### [Enums as arguments](enum_in_args.rs)
-
-How to use `arg_enum!` with `StructOpt`.
-
-### [Arguments of subcommands in separate `struct`](enum_tuple.rs)
-
-How to extract subcommands' args into external structs.
-
-### [Environment variables](env.rs)
-
-How to use environment variable fallback an how it interacts with `default_value`.
-
-### [Advanced](example.rs)
-
-Somewhat complex example of usage of `structopt`.
-
-### [Flatten](flatten.rs)
-
-How to use `#[structopt(flatten)]`
-
-### [`bash` completions](gen_completions.rs)
-
-Generating `bash` completions with `structopt`.
-
-### [Git](git.rs)
-
-Pseudo-`git` example, shows how to use subcommands and how to document them.
-
-### [Groups](group.rs)
-
-Using `clap::Arg::group` with `structopt`.
-
-### [`key=value` pairs](keyvalue.rs)
-
-How to parse `key=value` pairs.
-
-### [`--no-*` flags](negative_flag.rs)
-
-How to add `no-thing` flag which is `true` by default and `false` if passed.
-
-### [No version](no_version.rs)
-
-How to completely remove version.
-
-### [Rename all](rename_all.rs)
-
-How `#[structopt(rename_all)]` works.
-
-### [Skip](skip.rs)
-
-How to use `#[structopt(skip)]`.
-
-### [Aliases](subcommand_aliases.rs)
-
-How to use aliases
-
-### [`true` or `false`](true_or_false.rs)
-
-How to express "`"true"` or `"false"` argument.
diff --git a/structopt/examples/after_help.rs b/structopt/examples/after_help.rs
deleted file mode 100644
index db2845f..0000000
--- a/structopt/examples/after_help.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-//! How to append a postscript to the help message generated.
-
-use structopt::StructOpt;
-
-/// I am a program and I do things.
-///
-/// Sometimes they even work.
-#[derive(StructOpt, Debug)]
-#[structopt(after_help = "Beware `-d`, dragons be here")]
-struct Opt {
- /// Release the dragon.
- #[structopt(short)]
- dragon: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/at_least_two.rs b/structopt/examples/at_least_two.rs
deleted file mode 100644
index 683db50..0000000
--- a/structopt/examples/at_least_two.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-//! How to require presence of at least N values,
-//! like `val1 val2 ... valN ... valM`.
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct Opt {
- #[structopt(required = true, min_values = 2)]
- foos: Vec<String>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/basic.rs b/structopt/examples/basic.rs
deleted file mode 100644
index 510e0e0..0000000
--- a/structopt/examples/basic.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-//! A somewhat comprehensive example of a typical `StructOpt` usage.use
-
-use std::path::PathBuf;
-use structopt::StructOpt;
-
-/// A basic example
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- // A flag, true if used in the command line. Note doc comment will
- // be used for the help message of the flag. The name of the
- // argument will be, by default, based on the name of the field.
- /// Activate debug mode
- #[structopt(short, long)]
- debug: bool,
-
- // The number of occurrences of the `v/verbose` flag
- /// Verbose mode (-v, -vv, -vvv, etc.)
- #[structopt(short, long, parse(from_occurrences))]
- verbose: u8,
-
- /// Set speed
- #[structopt(short, long, default_value = "42")]
- speed: f64,
-
- /// Output file
- #[structopt(short, long, parse(from_os_str))]
- output: PathBuf,
-
- // the long option will be translated by default to kebab case,
- // i.e. `--nb-cars`.
- /// Number of cars
- #[structopt(short = "c", long)]
- nb_cars: Option<i32>,
-
- /// admin_level to consider
- #[structopt(short, long)]
- level: Vec<String>,
-
- /// Files to process
- #[structopt(name = "FILE", parse(from_os_str))]
- files: Vec<PathBuf>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:#?}", opt);
-}
diff --git a/structopt/examples/deny_missing_docs.rs b/structopt/examples/deny_missing_docs.rs
deleted file mode 100644
index 82b1e63..0000000
--- a/structopt/examples/deny_missing_docs.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 should be in tests but it will not work until
-// https://github.com/rust-lang/rust/issues/24584 is fixed
-
-//! A test to check that structopt compiles with deny(missing_docs)
-
-#![deny(missing_docs)]
-
-use structopt::StructOpt;
-
-/// The options
-#[derive(StructOpt, Debug, PartialEq)]
-pub struct Opt {
- #[structopt(short)]
- verbose: bool,
- #[structopt(subcommand)]
- cmd: Option<Cmd>,
-}
-
-/// Some subcommands
-#[derive(StructOpt, Debug, PartialEq)]
-pub enum Cmd {
- /// command A
- A,
- /// command B
- B {
- /// Alice?
- #[structopt(short)]
- alice: bool,
- },
- /// command C
- C(COpt),
-}
-
-/// The options for C
-#[derive(StructOpt, Debug, PartialEq)]
-pub struct COpt {
- #[structopt(short)]
- bob: bool,
-}
-
-fn main() {
- println!("{:?}", Opt::from_args());
-}
diff --git a/structopt/examples/doc_comments.rs b/structopt/examples/doc_comments.rs
deleted file mode 100644
index 810101f..0000000
--- a/structopt/examples/doc_comments.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-//! How to use doc comments in place of `help/long_help`.
-
-use structopt::StructOpt;
-
-/// A basic example for the usage of doc comments as replacement
-/// of the arguments `help`, `long_help`, `about` and `long_about`.
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- /// Just use doc comments to replace `help`, `long_help`,
- /// `about` or `long_about` input.
- #[structopt(short, long)]
- first_flag: bool,
-
- /// Split between `help` and `long_help`.
- ///
- /// In the previous case structopt is going to present
- /// the whole comment both as text for the `help` and the
- /// `long_help` argument.
- ///
- /// But if the doc comment is formatted like this example
- /// -- with an empty second line splitting the heading and
- /// the rest of the comment -- only the first line is used
- /// as `help` argument. The `long_help` argument will still
- /// contain the whole comment.
- ///
- /// ## Attention
- ///
- /// Any formatting next to empty lines that could be used
- /// inside a doc comment is currently not preserved. If
- /// lists or other well formatted content is required it is
- /// necessary to use the related structopt argument with a
- /// raw string as shown on the `third_flag` description.
- #[structopt(short, long)]
- second_flag: bool,
-
- #[structopt(
- short,
- long,
- long_help = r"This is a raw string.
-
-It can be used to pass well formatted content (e.g. lists or source
-code) in the description:
-
- - first example list entry
- - second example list entry
- "
- )]
- third_flag: bool,
-
- #[structopt(subcommand)]
- sub_command: SubCommand,
-}
-
-#[derive(StructOpt, Debug)]
-#[structopt()]
-enum SubCommand {
- /// The same rules described previously for flags. Are
- /// also true for in regards of sub-commands.
- First,
-
- /// Applicable for both `about` an `help`.
- ///
- /// The formatting rules described in the comment of the
- /// `second_flag` also apply to the description of
- /// sub-commands which is normally given through the `about`
- /// and `long_about` arguments.
- Second,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/enum_in_args.rs b/structopt/examples/enum_in_args.rs
deleted file mode 100644
index 70347da..0000000
--- a/structopt/examples/enum_in_args.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-//! How to use `arg_enum!` with `StructOpt`.
-
-use clap::arg_enum;
-use structopt::StructOpt;
-
-arg_enum! {
- #[derive(Debug)]
- enum Baz {
- Foo,
- Bar,
- FooBar
- }
-}
-
-#[derive(StructOpt, Debug)]
-struct Opt {
- /// Important argument.
- #[structopt(possible_values = &Baz::variants(), case_insensitive = true)]
- i: Baz,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/enum_tuple.rs b/structopt/examples/enum_tuple.rs
deleted file mode 100644
index 0bad2e6..0000000
--- a/structopt/examples/enum_tuple.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-//! How to extract subcommands' args into external structs.
-
-use structopt::StructOpt;
-
-#[derive(Debug, StructOpt)]
-pub struct Foo {
- pub bar: Option<String>,
-}
-
-#[derive(Debug, StructOpt)]
-pub enum Command {
- #[structopt(name = "foo")]
- Foo(Foo),
-}
-
-#[derive(Debug, StructOpt)]
-#[structopt(name = "classify")]
-pub struct ApplicationArguments {
- #[structopt(subcommand)]
- pub command: Command,
-}
-
-fn main() {
- let opt = ApplicationArguments::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/env.rs b/structopt/examples/env.rs
deleted file mode 100644
index 0477089..0000000
--- a/structopt/examples/env.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-//! How to use environment variable fallback an how it
-//! interacts with `default_value`.
-
-use structopt::StructOpt;
-
-/// Example for allowing to specify options via environment variables.
-#[derive(StructOpt, Debug)]
-#[structopt(name = "env")]
-struct Opt {
- // Use `env` to enable specifying the option with an environment
- // variable. Command line arguments take precedence over env.
- /// URL for the API server
- #[structopt(long, env = "API_URL")]
- api_url: String,
-
- // The default value is used if neither argument nor environment
- // variable is specified.
- /// Number of retries
- #[structopt(long, env = "RETRIES", default_value = "5")]
- retries: u32,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:#?}", opt);
-}
diff --git a/structopt/examples/example.rs b/structopt/examples/example.rs
deleted file mode 100644
index 7a9a514..0000000
--- a/structopt/examples/example.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-//! Somewhat complex example of usage of structopt.
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "example")]
-/// An example of StructOpt usage.
-struct Opt {
- // A flag, true if used in the command line.
- #[structopt(short, long)]
- /// Activate debug mode
- debug: bool,
-
- // An argument of type float, with a default value.
- #[structopt(short, long, default_value = "42")]
- /// Set speed
- speed: f64,
-
- // Needed parameter, the first on the command line.
- /// Input file
- input: String,
-
- // An optional parameter, will be `None` if not present on the
- // command line.
- /// Output file, stdout if not present
- output: Option<String>,
-
- // An optional parameter with optional value, will be `None` if
- // not present on the command line, will be `Some(None)` if no
- // argument is provided (i.e. `--log`) and will be
- // `Some(Some(String))` if argument is provided (e.g. `--log
- // log.txt`).
- #[structopt(long)]
- #[allow(clippy::option_option)]
- /// Log file, stdout if no file, no logging if not present
- log: Option<Option<String>>,
-
- // An optional list of values, will be `None` if not present on
- // the command line, will be `Some(vec![])` if no argument is
- // provided (i.e. `--optv`) and will be `Some(Some(String))` if
- // argument list is provided (e.g. `--optv a b c`).
- #[structopt(long)]
- optv: Option<Vec<String>>,
-
- // Skipped option: it won't be parsed and will be filled with the
- // default value for its type (in this case it'll be an empty string).
- #[structopt(skip)]
- skipped: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/flatten.rs b/structopt/examples/flatten.rs
deleted file mode 100644
index d51647f..0000000
--- a/structopt/examples/flatten.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-//! How to use flattening.
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct Cmdline {
- /// switch verbosity on
- #[structopt(short)]
- verbose: bool,
-
- #[structopt(flatten)]
- daemon_opts: DaemonOpts,
-}
-
-#[derive(StructOpt, Debug)]
-struct DaemonOpts {
- /// daemon user
- #[structopt(short)]
- user: String,
-
- /// daemon group
- #[structopt(short)]
- group: String,
-}
-
-fn main() {
- let opt = Cmdline::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/gen_completions.rs b/structopt/examples/gen_completions.rs
deleted file mode 100644
index 4f35b07..0000000
--- a/structopt/examples/gen_completions.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2019-present structopt 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. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use structopt::clap::Shell;
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-/// An example of how to generate bash completions with structopt.
-struct Opt {
- #[structopt(short, long)]
- /// Activate debug mode
- debug: bool,
-}
-
-fn main() {
- // generate `bash` completions in "target" directory
- Opt::clap().gen_completions(env!("CARGO_PKG_NAME"), Shell::Bash, "target");
-
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/git.rs b/structopt/examples/git.rs
deleted file mode 100644
index 494e9d1..0000000
--- a/structopt/examples/git.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-//! `git.rs` serves as a demonstration of how to use subcommands,
-//! as well as a demonstration of adding documentation to subcommands.
-//! Documentation can be added either through doc comments or
-//! `help`/`about` attributes.
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "git")]
-/// the stupid content tracker
-enum Opt {
- /// fetch branches from remote repository
- Fetch {
- #[structopt(long)]
- dry_run: bool,
- #[structopt(long)]
- all: bool,
- #[structopt(default_value = "origin")]
- repository: String,
- },
- #[structopt(help = "add files to the staging area")]
- Add {
- #[structopt(short)]
- interactive: bool,
- #[structopt(short)]
- all: bool,
- files: Vec<String>,
- },
-}
-
-fn main() {
- let matches = Opt::from_args();
-
- println!("{:?}", matches);
-}
diff --git a/structopt/examples/group.rs b/structopt/examples/group.rs
deleted file mode 100644
index d53de6a..0000000
--- a/structopt/examples/group.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-//! How to use `clap::Arg::group`
-
-use structopt::{clap::ArgGroup, StructOpt};
-
-#[derive(StructOpt, Debug)]
-#[structopt(group = ArgGroup::with_name("verb").required(true))]
-struct Opt {
- /// Set a custom HTTP verb
- #[structopt(long, group = "verb")]
- method: Option<String>,
- /// HTTP GET
- #[structopt(long, group = "verb")]
- get: bool,
- /// HTTP HEAD
- #[structopt(long, group = "verb")]
- head: bool,
- /// HTTP POST
- #[structopt(long, group = "verb")]
- post: bool,
- /// HTTP PUT
- #[structopt(long, group = "verb")]
- put: bool,
- /// HTTP DELETE
- #[structopt(long, group = "verb")]
- delete: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/keyvalue.rs b/structopt/examples/keyvalue.rs
deleted file mode 100644
index 12ce6fc..0000000
--- a/structopt/examples/keyvalue.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-//! How to parse "key=value" pairs with structopt.
-
-use std::error::Error;
-use structopt::StructOpt;
-
-/// Parse a single key-value pair
-fn parse_key_val<T, U>(s: &str) -> Result<(T, U), Box<dyn Error>>
-where
- T: std::str::FromStr,
- T::Err: Error + 'static,
- U: std::str::FromStr,
- U::Err: Error + 'static,
-{
- let pos = s
- .find('=')
- .ok_or_else(|| format!("invalid KEY=value: no `=` found in `{}`", s))?;
- Ok((s[..pos].parse()?, s[pos + 1..].parse()?))
-}
-
-#[derive(StructOpt, Debug)]
-struct Opt {
- // number_of_values = 1 forces the user to repeat the -D option for each key-value pair:
- // my_program -D a=1 -D b=2
- // Without number_of_values = 1 you can do:
- // my_program -D a=1 b=2
- // but this makes adding an argument after the values impossible:
- // my_program -D a=1 -D b=2 my_input_file
- // becomes invalid.
- #[structopt(short = "D", parse(try_from_str = parse_key_val), number_of_values = 1)]
- defines: Vec<(String, i32)>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/negative_flag.rs b/structopt/examples/negative_flag.rs
deleted file mode 100644
index b178bf5..0000000
--- a/structopt/examples/negative_flag.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-//! How to add `no-thing` flag which is `true` by default and
-//! `false` if passed.
-
-use structopt::StructOpt;
-
-#[derive(Debug, StructOpt)]
-struct Opt {
- #[structopt(long = "no-verbose", parse(from_flag = std::ops::Not::not))]
- verbose: bool,
-}
-
-fn main() {
- let cmd = Opt::from_args();
- println!("{:#?}", cmd);
-}
diff --git a/structopt/examples/no_version.rs b/structopt/examples/no_version.rs
deleted file mode 100644
index a542ec1..0000000
--- a/structopt/examples/no_version.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-//! How to completely remove version.
-
-use structopt::clap::AppSettings;
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(
- name = "no_version",
- no_version,
- global_settings = &[AppSettings::DisableVersion]
-)]
-struct Opt {}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/rename_all.rs b/structopt/examples/rename_all.rs
deleted file mode 100644
index 35f3c4f..0000000
--- a/structopt/examples/rename_all.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-//! Example on how the `rename_all` parameter works.
-//!
-//! `rename_all` can be used to override the casing style used during argument
-//! generation. By default the `kebab-case` style will be used but there are a wide
-//! variety of other styles available.
-//!
-//! ## Supported styles overview:
-//!
-//! - **Camel Case**: Indicate word boundaries with uppercase letter, excluding
-//! the first word.
-//! - **Kebab Case**: Keep all letters lowercase and indicate word boundaries
-//! with hyphens.
-//! - **Pascal Case**: Indicate word boundaries with uppercase letter,
-//! including the first word.
-//! - **Screaming Snake Case**: Keep all letters uppercase and indicate word
-//! boundaries with underscores.
-//! - **Snake Case**: Keep all letters lowercase and indicate word boundaries
-//! with underscores.
-//! - **Verbatim**: Use the original attribute name defined in the code.
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "rename_all", rename_all = "screaming_snake_case")]
-enum Opt {
- // This subcommand will be named `FIRST_COMMAND`. As the command doesn't
- // override the initial casing style, ...
- /// A screaming loud first command. Only use if necessary.
- FirstCommand {
- // this flag will be available as `--FOO` and `-F`.
- /// This flag will even scream louder.
- #[structopt(long, short)]
- foo: bool,
- },
-
- // As we override the casing style for this variant the related subcommand
- // will be named `SecondCommand`.
- /// Not nearly as loud as the first command.
- #[structopt(rename_all = "pascal_case")]
- SecondCommand {
- // We can also override it again on a single field.
- /// Nice quiet flag. No one is annoyed.
- #[structopt(rename_all = "snake_case", long)]
- bar_option: bool,
-
- // Renaming will not be propagated into subcommand flagged enums. If
- // a non default casing style is required it must be defined on the
- // enum itself.
- #[structopt(subcommand)]
- cmds: Subcommands,
-
- // or flattened structs.
- #[structopt(flatten)]
- options: BonusOptions,
- },
-}
-
-#[derive(StructOpt, Debug)]
-enum Subcommands {
- // This one will be available as `first-subcommand`.
- FirstSubcommand,
-}
-
-#[derive(StructOpt, Debug)]
-struct BonusOptions {
- // And this one will be available as `baz-option`.
- #[structopt(long)]
- baz_option: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/skip.rs b/structopt/examples/skip.rs
deleted file mode 100644
index 1f44769..0000000
--- a/structopt/examples/skip.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-//! How to use `#[structopt(skip)]`
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug, PartialEq)]
-pub struct Opt {
- #[structopt(long, short)]
- number: u32,
- #[structopt(skip)]
- k: Kind,
- #[structopt(skip)]
- v: Vec<u32>,
-
- #[structopt(skip = Kind::A)]
- k2: Kind,
- #[structopt(skip = vec![1, 2, 3])]
- v2: Vec<u32>,
- #[structopt(skip = "cake")] // &str implements Into<String>
- s: String,
-}
-
-#[derive(Debug, PartialEq)]
-enum Kind {
- A,
- B,
-}
-
-impl Default for Kind {
- fn default() -> Self {
- return Kind::B;
- }
-}
-
-fn main() {
- assert_eq!(
- Opt::from_iter(&["test", "-n", "10"]),
- Opt {
- number: 10,
- k: Kind::B,
- v: vec![],
-
- k2: Kind::A,
- v2: vec![1, 2, 3],
- s: String::from("cake")
- }
- );
-}
diff --git a/structopt/examples/subcommand_aliases.rs b/structopt/examples/subcommand_aliases.rs
deleted file mode 100644
index 30b8cc3..0000000
--- a/structopt/examples/subcommand_aliases.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-//! How to assign some aliases to subcommands
-
-use structopt::clap::AppSettings;
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-// https://docs.rs/clap/2/clap/enum.AppSettings.html#variant.InferSubcommands
-#[structopt(setting = AppSettings::InferSubcommands)]
-enum Opt {
- // https://docs.rs/clap/2/clap/struct.App.html#method.alias
- #[structopt(alias = "foobar")]
- Foo,
- // https://docs.rs/clap/2/clap/struct.App.html#method.aliases
- #[structopt(aliases = &["baz", "fizz"])]
- Bar,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/examples/true_or_false.rs b/structopt/examples/true_or_false.rs
deleted file mode 100644
index 31a543e..0000000
--- a/structopt/examples/true_or_false.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-//! How to parse `--foo=true --bar=false` and turn them into bool.
-
-use structopt::StructOpt;
-
-fn true_or_false(s: &str) -> Result<bool, &'static str> {
- match s {
- "true" => Ok(true),
- "false" => Ok(false),
- _ => Err("expected `true` or `false`"),
- }
-}
-
-#[derive(StructOpt, Debug, PartialEq)]
-struct Opt {
- // Default parser for `try_from_str` is FromStr::from_str.
- // `impl FromStr for bool` parses `true` or `false` so this
- // works as expected.
- #[structopt(long, parse(try_from_str))]
- foo: bool,
-
- // Of course, this could be done with an explicit parser function.
- #[structopt(long, parse(try_from_str = true_or_false))]
- bar: bool,
-
- // `bool` can be positional only with explicit `parse(...)` annotation
- #[structopt(long, parse(try_from_str))]
- boom: bool,
-}
-
-fn main() {
- assert_eq!(
- Opt::from_iter(&["test", "--foo=true", "--bar=false", "true"]),
- Opt {
- foo: true,
- bar: false,
- boom: true
- }
- );
- // no beauty, only truth and falseness
- assert!(Opt::from_iter_safe(&["test", "--foo=beauty"]).is_err());
-}
diff --git a/structopt/link-check-headers.json b/structopt/link-check-headers.json
deleted file mode 100644
index c1bb248..0000000
--- a/structopt/link-check-headers.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "httpHeaders": [
- {
- "urls": [
- "https://",
- "http://"
- ],
- "headers": {
- "User-Agent": "broken links checker (https://github.com/TeXitoi/structopt)",
- "Accept": "text/html"
- }
- }
- ]
-}
diff --git a/structopt/src/lib.rs b/structopt/src/lib.rs
deleted file mode 100644
index 70c0768..0000000
--- a/structopt/src/lib.rs
+++ /dev/null
@@ -1,1015 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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.
-
-#![deny(missing_docs)]
-
-//! This crate defines the `StructOpt` trait and its custom derive.
-//!
-//! ## Features
-//!
-//! If you want to disable all the `clap` features (colors,
-//! suggestions, ..) add `default-features = false` to the `structopt`
-//! dependency:
-//!
-//! ```toml
-//! [dependencies]
-//! structopt = { version = "0.3", default-features = false }
-//! ```
-//!
-//! Support for [`paw`](https://github.com/rust-cli/paw) (the
-//! `Command line argument paw-rser abstraction for main`) is disabled
-//! by default, but can be enabled in the `structopt` dependency
-//! with the feature `paw`:
-//!
-//! ```toml
-//! [dependencies]
-//! structopt = { version = "0.3", features = [ "paw" ] }
-//! paw = "1.0"
-//! ```
-//!
-//! # Table of Contents
-//!
-//! - [How to `derive(StructOpt)`](#how-to-derivestructopt)
-//! - [Attributes](#attributes)
-//! - [Raw methods](#raw-methods)
-//! - [Magical methods](#magical-methods)
-//! - Arguments
-//! - [Type magic](#type-magic)
-//! - [Specifying argument types](#specifying-argument-types)
-//! - [Help messages](#help-messages)
-//! - [Environment variable fallback](#environment-variable-fallback)
-//! - [Skipping fields](#skipping-fields)
-//! - [Subcommands](#subcommands)
-//! - [Optional subcommands](#optional-subcommands)
-//! - [Flattening](#flattening)
-//! - [Custom string parsers](#custom-string-parsers)
-//!
-//!
-//!
-//! ## How to `derive(StructOpt)`
-//!
-//! First, let's look at the example:
-//!
-//! ```should_panic
-//! use std::path::PathBuf;
-//! use structopt::StructOpt;
-//!
-//! #[derive(Debug, StructOpt)]
-//! #[structopt(name = "example", about = "An example of StructOpt usage.")]
-//! struct Opt {
-//! /// Activate debug mode
-//! // short and long flags (-d, --debug) will be deduced from the field's name
-//! #[structopt(short, long)]
-//! debug: bool,
-//!
-//! /// Set speed
-//! // we don't want to name it "speed", need to look smart
-//! #[structopt(short = "v", long = "velocity", default_value = "42")]
-//! speed: f64,
-//!
-//! /// Input file
-//! #[structopt(parse(from_os_str))]
-//! input: PathBuf,
-//!
-//! /// Output file, stdout if not present
-//! #[structopt(parse(from_os_str))]
-//! output: Option<PathBuf>,
-//!
-//! /// Where to write the output: to `stdout` or `file`
-//! #[structopt(short)]
-//! out_type: String,
-//!
-//! /// File name: only required when `out` is set to `file`
-//! #[structopt(name = "FILE", required_if("out_type", "file"))]
-//! file_name: String,
-//! }
-//!
-//! fn main() {
-//! let opt = Opt::from_args();
-//! println!("{:?}", opt);
-//! }
-//! ```
-//!
-//! So `derive(StructOpt)` tells Rust to generate a command line parser,
-//! and the various `structopt` attributes are simply
-//! used for additional parameters.
-//!
-//! First, define a struct, whatever its name. This structure
-//! corresponds to a `clap::App`, its fields correspond to `clap::Arg`
-//! (unless they're [subcommands](#subcommands)),
-//! and you can adjust these apps and args by `#[structopt(...)]` [attributes](#attributes).
-//!
-//! **Note:**
-//! _________________
-//! Keep in mind that `StructOpt` trait is more than just `from_args` method.
-//! It has a number of additional features, including access to underlying
-//! `clap::App` via `StructOpt::clap()`. See the
-//! [trait's reference documentation](trait.StructOpt.html).
-//! _________________
-//!
-//! ## Attributes
-//!
-//! `#[structopt(...)]` attributes fall into two categories:
-//! - `structopt`'s own [magical methods](#magical-methods).
-//!
-//! They are used by `structopt` itself. They come mostly in
-//! `attr = ["whatever"]` form, but some `attr(args...)` also exist.
-//!
-//! - [`raw` attributes](#raw-methods).
-//!
-//! They represent explicit `clap::Arg/App` method calls.
-//! They are what used to be explicit `#[structopt(raw(...))]` attrs in pre-0.3 `structopt`
-//!
-//! Every `structopt attribute` looks like comma-separated sequence of methods:
-//! ```rust,ignore
-//! #[structopt(
-//! short, // method with no arguments - always magical
-//! long = "--long-option", // method with one argument
-//! required_if("out", "file"), // method with one and more args
-//! parse(from_os_str = path::to::parser) // some magical methods have their own syntax
-//! )]
-//! ```
-//!
-//! `#[structopt(...)]` attributes can be placed on top of `struct`, `enum`,
-//! `struct` field or `enum` variant. Attributes on top of `struct` or `enum`
-//! represent `clap::App` method calls, field or variant attributes correspond
-//! to `clap::Arg` method calls.
-//!
-//! In other words, the `Opt` struct from the example above
-//! will be turned into this (*details omitted*):
-//!
-//! ```
-//! # use structopt::clap::{Arg, App};
-//! App::new("example")
-//! .version("0.2.0")
-//! .about("An example of StructOpt usage.")
-//! .arg(Arg::with_name("debug")
-//! .help("Activate debug mode")
-//! .short("debug")
-//! .long("debug"))
-//! .arg(Arg::with_name("speed")
-//! .help("Set speed")
-//! .short("v")
-//! .long("velocity")
-//! .default_value("42"))
-//! // and so on
-//! # ;
-//! ```
-//!
-//! ## Raw methods
-//!
-//! They are the reason why `structopt` is so flexible.
-//!
-//! Each and every method from `clap::App` and `clap::Arg` can be used directly -
-//! just `#[structopt(method_name = single_arg)]` or `#[structopt(method_name(arg1, arg2))]`
-//! and it just works. As long as `method_name` is not one of the magical methods -
-//! it's just a method call.
-//!
-//! **Note:**
-//! _________________
-//!
-//! "Raw methods" are direct replacement for pre-0.3 structopt's
-//! `#[structopt(raw(...))]` attributes, any time you would have used a `raw()` attribute
-//! in 0.2 you should use raw method in 0.3.
-//!
-//! Unfortunately, old raw attributes collide with `clap::Arg::raw` method. To explicitly
-//! warn users of this change we allow `#[structopt(raw())]` only with `true` or `false`
-//! literals (this method is supposed to be called only with `true` anyway).
-//! __________________
-//!
-//! ## Magical methods
-//!
-//! They are the reason why `structopt` is so easy to use and convenient in most cases.
-//! Many of them have defaults, some of them get used even if not mentioned.
-//!
-//! Methods may be used on "top level" (on top of a `struct`, `enum` or `enum` variant)
-//! and/or on "field-level" (on top of a `struct` field or *inside* of an enum variant).
-//! Top level (non-magical) methods correspond to `App::method` calls, field-level methods
-//! are `Arg::method` calls.
-//!
-//! ```ignore
-//! #[structopt(top_level)]
-//! struct Foo {
-//! #[structopt(field_level)]
-//! field: u32
-//! }
-//!
-//! #[structopt(top_level)]
-//! enum Bar {
-//! #[structopt(top_level)]
-//! Pineapple {
-//! #[structopt(field_level)]
-//! chocolate: String
-//! },
-//!
-//! #[structopt(top_level)]
-//! Orange,
-//! }
-//! ```
-//!
-//! - `name`: `[name = "name"]`
-//! - On top level: `App::new("name")`.
-//!
-//! The binary name displayed in help messages. Defaults to the crate name given by Cargo.
-//!
-//! - On field-level: `Arg::with_name("name")`.
-//!
-//! The name for the argument the field stands for, this name appears in help messages.
-//! Defaults to a name, deduced from a field, see also
-//! [`rename_all`](#specifying-argument-types).
-//!
-//! - `version`: `[version = "version"]`
-//!
-//! Usable only on top level: `App::version("version" or env!(CARGO_PKG_VERSION))`.
-//!
-//! The version displayed in help messages.
-//! Defaults to the crate version given by Cargo. If `CARGO_PKG_VERSION` is not
-//! set no `.version()` calls will be generated unless requested.
-//!
-//! - `no_version`: `no_version`
-//!
-//! Usable only on top level. Prevents default `App::version` call, i.e
-//! when no `version = "version"` mentioned.
-//!
-//! - `author`: `author [= "author"]`
-//!
-//! Usable only on top level: `App::author("author" or env!(CARGO_PKG_AUTHOR))`.
-//!
-//! Author/maintainer of the binary, this name appears in help messages.
-//! Defaults to the crate author given by cargo, but only when `author` explicitly mentioned.
-//!
-//! - `about`: `about [= "about"]`
-//!
-//! Usable only on top level: `App::about("about" or env!(CARGO_PKG_DESCRIPTION))`.
-//!
-//! Short description of the binary, appears in help messages.
-//! Defaults to the crate description given by cargo,
-//! but only when `about` explicitly mentioned.
-//!
-//! - [`short`](#specifying-argument-types): `short [= "short-opt-name"]`
-//!
-//! Usable only on field-level.
-//!
-//! - [`long`](#specifying-argument-types): `long [= "long-opt-name"]`
-//!
-//! Usable only on field-level.
-//!
-//! - [`rename_all`](#specifying-argument-types): [`rename_all = "kebab"/"snake"/"screaming-snake"/"camel"/"pascal"/"verbatim"]`
-//!
-//! Usable both on top level and field level.
-//!
-//! - [`parse`](#custom-string-parsers): `parse(type [= path::to::parser::fn])`
-//!
-//! Usable only on field-level.
-//!
-//! - [`skip`](#skipping-fields): `skip [= expr]`
-//!
-//! Usable only on field-level.
-//!
-//! - [`flatten`](#flattening): `flatten`
-//!
-//! Usable only on field-level.
-//!
-//! - [`subcommand`](#subcommands): `subcommand`
-//!
-//! Usable only on field-level.
-//!
-//! - [`env`](#environment-variable-fallback): `env [= str_literal]`
-//!
-//! Usable only on field-level.
-//!
-//! - [`rename_all_env`](##auto-deriving-environment-variables): [`rename_all_env = "kebab"/"snake"/"screaming-snake"/"camel"/"pascal"/"verbatim"]`
-//!
-//! Usable both on top level and field level.
-//!
-//! - [`verbatim_doc_comment`](#doc-comment-preprocessing-and-structoptverbatim_doc_comment):
-//! `verbatim_doc_comment`
-//!
-//! Usable both on top level and field level.
-//!
-//! ## Type magic
-//!
-//! One of major things that makes `structopt` so awesome is it's type magic.
-//! Do you want optional positional argument? Use `Option<T>`! Or perhaps optional argument
-//! that optionally takes value (`[--opt=[val]]`)? Use `Option<Option<T>>`!
-//!
-//! Here is the table of types and `clap` methods they correspond to:
-//!
-//! Type | Effect | Added method call to `clap::Arg`
-//! -----------------------------|---------------------------------------------------|--------------------------------------
-//! `bool` | `true` if the flag is present | `.takes_value(false).multiple(false)`
-//! `Option<T: FromStr>` | optional positional argument or option | `.takes_value(true).multiple(false)`
-//! `Option<Option<T: FromStr>>` | optional option with optional value | `.takes_value(true).multiple(false).min_values(0).max_values(1)`
-//! `Vec<T: FromStr>` | list of options or the other positional arguments | `.takes_value(true).multiple(true)`
-//! `Option<Vec<T: FromStr>` | optional list of options | `.takes_values(true).multiple(true).min_values(0)`
-//! `T: FromStr` | required option or positional argument | `.takes_value(true).multiple(false).required(!has_default)`
-//!
-//! The `FromStr` trait is used to convert the argument to the given
-//! type, and the `Arg::validator` method is set to a method using
-//! `to_string()` (`FromStr::Err` must implement `std::fmt::Display`).
-//! If you would like to use a custom string parser other than `FromStr`, see
-//! the [same titled section](#custom-string-parsers) below.
-//!
-//! **Note:**
-//! _________________
-//! Pay attention that *only literal occurrence* of this types is special, for example
-//! `Option<T>` is special while `::std::option::Option<T>` is not.
-//!
-//! If you need to avoid special casing you can make a `type` alias and
-//! use it in place of the said type.
-//! _________________
-//!
-//! **Note:**
-//! _________________
-//! `bool` cannot be used as positional argument unless you provide an explicit parser.
-//! If you need a positional bool, for example to parse `true` or `false`, you must
-//! annotate the field with explicit [`#[structopt(parse(...))]`](#custom-string-parsers).
-//! _________________
-//!
-//! Thus, the `speed` argument is generated as:
-//!
-//! ```
-//! # extern crate clap;
-//! # fn parse_validator<T>(_: String) -> Result<(), String> { unimplemented!() }
-//! # fn main() {
-//! clap::Arg::with_name("speed")
-//! .takes_value(true)
-//! .multiple(false)
-//! .required(false)
-//! .validator(parse_validator::<f64>)
-//! .short("v")
-//! .long("velocity")
-//! .help("Set speed")
-//! .default_value("42");
-//! # }
-//! ```
-//!
-//! ## Specifying argument types
-//!
-//! There are three types of arguments that can be supplied to each
-//! (sub-)command:
-//!
-//! - short (e.g. `-h`),
-//! - long (e.g. `--help`)
-//! - and positional.
-//!
-//! Like clap, structopt defaults to creating positional arguments.
-//!
-//! If you want to generate a long argument you can specify either
-//! `long = $NAME`, or just `long` to get a long flag generated using
-//! the field name. The generated casing style can be modified using
-//! the `rename_all` attribute. See the `rename_all` example for more.
-//!
-//! For short arguments, `short` will use the first letter of the
-//! field name by default, but just like the long option it's also
-//! possible to use a custom letter through `short = $LETTER`.
-//!
-//! If an argument is renamed using `name = $NAME` any following call to
-//! `short` or `long` will use the new name.
-//!
-//! **Attention**: If these arguments are used without an explicit name
-//! the resulting flag is going to be renamed using `kebab-case` if the
-//! `rename_all` attribute was not specified previously. The same is true
-//! for subcommands with implicit naming through the related data structure.
-//!
-//! ```
-//! use structopt::StructOpt;
-//!
-//! #[derive(StructOpt)]
-//! #[structopt(rename_all = "kebab-case")]
-//! struct Opt {
-//! /// This option can be specified with something like `--foo-option
-//! /// value` or `--foo-option=value`
-//! #[structopt(long)]
-//! foo_option: String,
-//!
-//! /// This option can be specified with something like `-b value` (but
-//! /// not `--bar-option value`).
-//! #[structopt(short)]
-//! bar_option: String,
-//!
-//! /// This option can be specified either `--baz value` or `-z value`.
-//! #[structopt(short = "z", long = "baz")]
-//! baz_option: String,
-//!
-//! /// This option can be specified either by `--custom value` or
-//! /// `-c value`.
-//! #[structopt(name = "custom", long, short)]
-//! custom_option: String,
-//!
-//! /// This option is positional, meaning it is the first unadorned string
-//! /// you provide (multiple others could follow).
-//! my_positional: String,
-//!
-//! /// This option is skipped and will be filled with the default value
-//! /// for its type (in this case 0).
-//! #[structopt(skip)]
-//! skipped: u32,
-//!
-//! }
-//!
-//! # fn main() {
-//! # Opt::from_clap(&Opt::clap().get_matches_from(
-//! # &["test", "--foo-option", "", "-b", "", "--baz", "", "--custom", "", "positional"]));
-//! # }
-//! ```
-//!
-//! ## Help messages
-//!
-//! In clap, help messages for the whole binary can be specified
-//! via [`App::about`] and [`App::long_about`] while help messages
-//! for individual arguments can be specified via [`Arg::help`] and [`Arg::long_help`]".
-//!
-//! `long_*` variants are used when user calls the program with
-//! `--help` and "short" variants are used with `-h` flag. In `structopt`,
-//! you can use them via [raw methods](#raw-methods), for example:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//!
-//! #[derive(StructOpt)]
-//! #[structopt(about = "I am a program and I work, just pass `-h`")]
-//! struct Foo {
-//! #[structopt(short, help = "Pass `-h` and you'll see me!")]
-//! bar: String
-//! }
-//! ```
-//!
-//! For convenience, doc comments can be used instead of raw methods
-//! (this example works exactly like the one above):
-//!
-//! ```
-//! # use structopt::StructOpt;
-//!
-//! #[derive(StructOpt)]
-//! /// I am a program and I work, just pass `-h`
-//! struct Foo {
-//! /// Pass `-h` and you'll see me!
-//! bar: String
-//! }
-//! ```
-//!
-//! Doc comments on [top-level](#magical-methods) will be turned into
-//! `App::about/long_about` call (see below), doc comments on field-level are
-//! `Arg::help/long_help` calls.
-//!
-//! **Important:**
-//! _________________
-//!
-//! Raw methods have priority over doc comments!
-//!
-//! **Top level doc comments always generate `App::about/long_about` calls!**
-//! If you really want to use the `App::help/long_help` methods (you likely don't),
-//! use a raw method to override the `App::about` call generated from the doc comment.
-//! __________________
-//!
-//! ### `long_help` and `--help`
-//!
-//! A message passed to [`App::long_help`] or [`Arg::long_about`] will be displayed whenever
-//! your program is called with `--help` instead of `-h`. Of course, you can
-//! use them via raw methods as described [above](#help-messages).
-//!
-//! The more convenient way is to use a so-called "long" doc comment:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//! #[derive(StructOpt)]
-//! /// Hi there, I'm Robo!
-//! ///
-//! /// I like beeping, stumbling, eating your electricity,
-//! /// and making records of you singing in a shower.
-//! /// Pay up, or I'll upload it to youtube!
-//! struct Robo {
-//! /// Call my brother SkyNet.
-//! ///
-//! /// I am artificial superintelligence. I won't rest
-//! /// until I'll have destroyed humanity. Enjoy your
-//! /// pathetic existence, you mere mortals.
-//! #[structopt(long)]
-//! kill_all_humans: bool
-//! }
-//! ```
-//!
-//! A long doc comment consists of three parts:
-//! * Short summary
-//! * A blank line (whitespace only)
-//! * Detailed description, all the rest
-//!
-//! In other words, "long" doc comment consists of two or more paragraphs,
-//! with the first being a summary and the rest being the detailed description.
-//!
-//! **A long comment will result in two method calls**, `help(<summary>)` and
-//! `long_help(<whole comment>)`, so clap will display the summary with `-h`
-//! and the whole help message on `--help` (see below).
-//!
-//! So, the example above will be turned into this (details omitted):
-//! ```
-//! clap::App::new("<name>")
-//! .about("Hi there, I'm Robo!")
-//! .long_about("Hi there, I'm Robo!\n\n\
-//! I like beeping, stumbling, eating your electricity,\
-//! and making records of you singing in a shower.\
-//! Pay up or I'll upload it to youtube!")
-//! // args...
-//! # ;
-//! ```
-//!
-//! ### `-h` vs `--help` (A.K.A `help()` vs `long_help()`)
-//!
-//! The `-h` flag is not the same as `--help`.
-//!
-//! -h corresponds to Arg::help/App::about and requests short "summary" messages
-//! while --help corresponds to Arg::long_help/App::long_about and requests more
-//! detailed, descriptive messages.
-//!
-//! It is entirely up to `clap` what happens if you used only one of
-//! [`Arg::help`]/[`Arg::long_help`], see `clap`'s documentation for these methods.
-//!
-//! As of clap v2.33, if only a short message ([`Arg::help`]) or only
-//! a long ([`Arg::long_help`]) message is provided, clap will use it
-//! for both -h and --help. The same logic applies to `about/long_about`.
-//!
-//! ### Doc comment preprocessing and `#[structopt(verbatim_doc_comment)]`
-//!
-//! `structopt` applies some preprocessing to doc comments to ease the most common uses:
-//!
-//! * Strip leading and trailing whitespace from every line, if present.
-//!
-//! * Strip leading and trailing blank lines, if present.
-//!
-//! * Interpret each group of non-empty lines as a word-wrapped paragraph.
-//!
-//! We replace newlines within paragraphs with spaces to allow the output
-//! to be re-wrapped to the terminal width.
-//!
-//! * Strip any excess blank lines so that there is exactly one per paragraph break.
-//!
-//! * If the first paragraph ends in exactly one period,
-//! remove the trailing period (i.e. strip trailing periods but not trailing ellipses).
-//!
-//! Sometimes you don't want this preprocessing to apply, for example the comment contains
-//! some ASCII art or markdown tables, you would need to preserve LFs along with
-//! blank lines and the leading/trailing whitespace. You can ask `structopt` to preserve them
-//! via `#[structopt(verbatim_doc_comment)]` attribute.
-//!
-//! **This attribute must be applied to each field separately**, there's no global switch.
-//!
-//! **Important:**
-//! ______________
-//! Keep in mind that `structopt` will *still* remove one leading space from each
-//! line, even if this attribute is present, to allow for a space between
-//! `///` and the content.
-//!
-//! Also, `structopt` will *still* remove leading and trailing blank lines so
-//! these formats are equivalent:
-//!
-//! ```ignore
-//! /** This is a doc comment
-//!
-//! Hello! */
-//!
-//! /**
-//! This is a doc comment
-//!
-//! Hello!
-//! */
-//!
-//! /// This is a doc comment
-//! ///
-//! /// Hello!
-//! ```
-//!
-//! Summary
-//! ______________
-//!
-//! [`App::about`]: https://docs.rs/clap/2/clap/struct.App.html#method.about
-//! [`App::long_about`]: https://docs.rs/clap/2/clap/struct.App.html#method.long_about
-//! [`Arg::help`]: https://docs.rs/clap/2/clap/struct.Arg.html#method.help
-//! [`Arg::long_help`]: https://docs.rs/clap/2/clap/struct.Arg.html#method.long_help
-//!
-//! ## Environment variable fallback
-//!
-//! It is possible to specify an environment variable fallback option for an arguments
-//! so that its value is taken from the specified environment variable if not
-//! given through the command-line:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//!
-//! #[derive(StructOpt)]
-//! struct Foo {
-//! #[structopt(short, long, env = "PARAMETER_VALUE")]
-//! parameter_value: String
-//! }
-//! # fn main() {}
-//! ```
-//!
-//! By default, values from the environment are shown in the help output (i.e. when invoking
-//! `--help`):
-//!
-//! ```shell
-//! $ cargo run -- --help
-//! ...
-//! OPTIONS:
-//! -p, --parameter-value <parameter-value> [env: PARAMETER_VALUE=env_value]
-//! ```
-//!
-//! In some cases this may be undesirable, for example when being used for passing
-//! credentials or secret tokens. In those cases you can use `hide_env_values` to avoid
-//! having structopt emit the actual secret values:
-//! ```
-//! # use structopt::StructOpt;
-//!
-//! #[derive(StructOpt)]
-//! struct Foo {
-//! #[structopt(long = "secret", env = "SECRET_VALUE", hide_env_values = true)]
-//! secret_value: String
-//! }
-//! ```
-//!
-//! ### Auto-deriving environment variables
-//!
-//! Environment variables tend to be called after the corresponding `struct`'s field,
-//! as in example above. The field is `secret_value` and the env var is "SECRET_VALUE";
-//! the name is the same, except casing is different.
-//!
-//! It's pretty tedious and error-prone to type the same name twice,
-//! so you can ask `structopt` to do that for you.
-//!
-//! ```
-//! # use structopt::StructOpt;
-//!
-//! #[derive(StructOpt)]
-//! struct Foo {
-//! #[structopt(long = "secret", env)]
-//! secret_value: String
-//! }
-//! ```
-//!
-//! It works just like `#[structopt(short/long)]`: if `env` is not set to some concrete
-//! value the value will be derived from the field's name. This is controlled by
-//! `#[structopt(rename_all_env)]`.
-//!
-//! `rename_all_env` works exactly as `rename_all` (including overriding)
-//! except default casing is `SCREAMING_SNAKE_CASE` instead of `kebab-case`.
-//!
-//! ## Skipping fields
-//!
-//! Sometimes you may want to add a field to your `Opt` struct that is not
-//! a command line option and `clap` should know nothing about it. You can ask
-//! `structopt` to skip the field entirely via `#[structopt(skip = value)]`
-//! (`value` must implement `Into<FieldType>`)
-//! or `#[structopt(skip)]` if you want assign the field with `Default::default()`
-//! (obviously, the field's type must implement `Default`).
-//!
-//! ```
-//! # use structopt::StructOpt;
-//! #[derive(StructOpt)]
-//! pub struct Opt {
-//! #[structopt(long, short)]
-//! number: u32,
-//!
-//! // these fields are to be assigned with Default::default()
-//!
-//! #[structopt(skip)]
-//! k: String,
-//! #[structopt(skip)]
-//! v: Vec<u32>,
-//!
-//! // these fields get set explicitly
-//!
-//! #[structopt(skip = vec![1, 2, 3])]
-//! k2: Vec<u32>,
-//! #[structopt(skip = "cake")] // &str implements Into<String>
-//! v2: String,
-//! }
-//! ```
-//!
-//! ## Subcommands
-//!
-//! Some applications, especially large ones, split their functionality
-//! through the use of "subcommands". Each of these act somewhat like a separate
-//! command, but is part of the larger group.
-//! One example is `git`, which has subcommands such as `add`, `commit`,
-//! and `clone`, to mention just a few.
-//!
-//! `clap` has this functionality, and `structopt` supports it through enums:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//!
-//! # use std::path::PathBuf;
-//! #[derive(StructOpt)]
-//! #[structopt(about = "the stupid content tracker")]
-//! enum Git {
-//! Add {
-//! #[structopt(short)]
-//! interactive: bool,
-//! #[structopt(short)]
-//! patch: bool,
-//! #[structopt(parse(from_os_str))]
-//! files: Vec<PathBuf>
-//! },
-//! Fetch {
-//! #[structopt(long)]
-//! dry_run: bool,
-//! #[structopt(long)]
-//! all: bool,
-//! repository: Option<String>
-//! },
-//! Commit {
-//! #[structopt(short)]
-//! message: Option<String>,
-//! #[structopt(short)]
-//! all: bool
-//! }
-//! }
-//! # fn main() {}
-//! ```
-//!
-//! Using `derive(StructOpt)` on an enum instead of a struct will produce
-//! a `clap::App` that only takes subcommands. So `git add`, `git fetch`,
-//! and `git commit` would be commands allowed for the above example.
-//!
-//! `structopt` also provides support for applications where certain flags
-//! need to apply to all subcommands, as well as nested subcommands:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//! # fn main() {}
-//! #[derive(StructOpt)]
-//! struct MakeCookie {
-//! #[structopt(name = "supervisor", default_value = "Puck", long = "supervisor")]
-//! supervising_faerie: String,
-//! /// The faerie tree this cookie is being made in.
-//! tree: Option<String>,
-//! #[structopt(subcommand)] // Note that we mark a field as a subcommand
-//! cmd: Command
-//! }
-//!
-//! #[derive(StructOpt)]
-//! enum Command {
-//! /// Pound acorns into flour for cookie dough.
-//! Pound {
-//! acorns: u32
-//! },
-//! /// Add magical sparkles -- the secret ingredient!
-//! Sparkle {
-//! #[structopt(short, parse(from_occurrences))]
-//! magicality: u64,
-//! #[structopt(short)]
-//! color: String
-//! },
-//! Finish(Finish),
-//! }
-//!
-//! // Subcommand can also be externalized by using a 1-uple enum variant
-//! #[derive(StructOpt)]
-//! struct Finish {
-//! #[structopt(short)]
-//! time: u32,
-//! #[structopt(subcommand)] // Note that we mark a field as a subcommand
-//! finish_type: FinishType
-//! }
-//!
-//! // subsubcommand!
-//! #[derive(StructOpt)]
-//! enum FinishType {
-//! Glaze {
-//! applications: u32
-//! },
-//! Powder {
-//! flavor: String,
-//! dips: u32
-//! }
-//! }
-//! ```
-//!
-//! Marking a field with `structopt(subcommand)` will add the subcommands of the
-//! designated enum to the current `clap::App`. The designated enum *must* also
-//! be derived `StructOpt`. So the above example would take the following
-//! commands:
-//!
-//! + `make-cookie pound 50`
-//! + `make-cookie sparkle -mmm --color "green"`
-//! + `make-cookie finish 130 glaze 3`
-//!
-//! ### Optional subcommands
-//!
-//! Subcommands may be optional:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//! # fn main() {}
-//! #[derive(StructOpt)]
-//! struct Foo {
-//! file: String,
-//! #[structopt(subcommand)]
-//! cmd: Option<Command>
-//! }
-//!
-//! #[derive(StructOpt)]
-//! enum Command {
-//! Bar,
-//! Baz,
-//! Quux
-//! }
-//! ```
-//!
-//! ## Flattening
-//!
-//! It can sometimes be useful to group related arguments in a substruct,
-//! while keeping the command-line interface flat. In these cases you can mark
-//! a field as `flatten` and give it another type that derives `StructOpt`:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//! # fn main() {}
-//! #[derive(StructOpt)]
-//! struct Cmdline {
-//! /// switch on verbosity
-//! #[structopt(short)]
-//! verbose: bool,
-//! #[structopt(flatten)]
-//! daemon_opts: DaemonOpts,
-//! }
-//!
-//! #[derive(StructOpt)]
-//! struct DaemonOpts {
-//! /// daemon user
-//! #[structopt(short)]
-//! user: String,
-//! /// daemon group
-//! #[structopt(short)]
-//! group: String,
-//! }
-//! ```
-//!
-//! In this example, the derived `Cmdline` parser will support the options `-v`,
-//! `-u` and `-g`.
-//!
-//! This feature also makes it possible to define a `StructOpt` struct in a
-//! library, parse the corresponding arguments in the main argument parser, and
-//! pass off this struct to a handler provided by that library.
-//!
-//! ## Custom string parsers
-//!
-//! If the field type does not have a `FromStr` implementation, or you would
-//! like to provide a custom parsing scheme other than `FromStr`, you may
-//! provide a custom string parser using `parse(...)` like this:
-//!
-//! ```
-//! # use structopt::StructOpt;
-//! # fn main() {}
-//! use std::num::ParseIntError;
-//! use std::path::PathBuf;
-//!
-//! fn parse_hex(src: &str) -> Result<u32, ParseIntError> {
-//! u32::from_str_radix(src, 16)
-//! }
-//!
-//! #[derive(StructOpt)]
-//! struct HexReader {
-//! #[structopt(short, parse(try_from_str = parse_hex))]
-//! number: u32,
-//! #[structopt(short, parse(from_os_str))]
-//! output: PathBuf,
-//! }
-//! ```
-//!
-//! There are five kinds of custom parsers:
-//!
-//! | Kind | Signature | Default |
-//! |-------------------|---------------------------------------|---------------------------------|
-//! | `from_str` | `fn(&str) -> T` | `::std::convert::From::from` |
-//! | `try_from_str` | `fn(&str) -> Result<T, E>` | `::std::str::FromStr::from_str` |
-//! | `from_os_str` | `fn(&OsStr) -> T` | `::std::convert::From::from` |
-//! | `try_from_os_str` | `fn(&OsStr) -> Result<T, OsString>` | (no default function) |
-//! | `from_occurrences`| `fn(u64) -> T` | `value as T` |
-//! | `from_flag` | `fn(bool) -> T` | `::std::convert::From::from` |
-//!
-//! The `from_occurrences` parser is special. Using `parse(from_occurrences)`
-//! results in the _number of flags occurrences_ being stored in the relevant
-//! field or being passed to the supplied function. In other words, it converts
-//! something like `-vvv` to `3`. This is equivalent to
-//! `.takes_value(false).multiple(true)`. Note that the default parser can only
-//! be used with fields of integer types (`u8`, `usize`, `i64`, etc.).
-//!
-//! The `from_flag` parser is also special. Using `parse(from_flag)` or
-//! `parse(from_flag = some_func)` will result in the field being treated as a
-//! flag even if it does not have type `bool`.
-//!
-//! When supplying a custom string parser, `bool` will not be treated specially:
-//!
-//! Type | Effect | Added method call to `clap::Arg`
-//! ------------|-------------------|--------------------------------------
-//! `Option<T>` | optional argument | `.takes_value(true).multiple(false)`
-//! `Vec<T>` | list of arguments | `.takes_value(true).multiple(true)`
-//! `T` | required argument | `.takes_value(true).multiple(false).required(!has_default)`
-//!
-//! In the `try_from_*` variants, the function will run twice on valid input:
-//! once to validate, and once to parse. Hence, make sure the function is
-//! side-effect-free.
-
-#[doc(hidden)]
-pub use structopt_derive::*;
-
-use std::ffi::OsString;
-
-/// Re-export of clap
-pub use clap;
-
-/// A struct that is converted from command line arguments.
-pub trait StructOpt {
- /// Returns the corresponding `clap::App`.
- fn clap<'a, 'b>() -> clap::App<'a, 'b>;
-
- /// Creates the struct from `clap::ArgMatches`. It cannot fail
- /// with a parameter generated by `clap` by construction.
- fn from_clap(matches: &clap::ArgMatches<'_>) -> Self;
-
- /// Gets the struct from the command line arguments. Print the
- /// error message and quit the program in case of failure.
- fn from_args() -> Self
- where
- Self: Sized,
- {
- Self::from_clap(&Self::clap().get_matches())
- }
-
- /// Gets the struct from any iterator such as a `Vec` of your making.
- /// Print the error message and quit the program in case of failure.
- fn from_iter<I>(iter: I) -> Self
- where
- Self: Sized,
- I: IntoIterator,
- I::Item: Into<OsString> + Clone,
- {
- Self::from_clap(&Self::clap().get_matches_from(iter))
- }
-
- /// Gets the struct from any iterator such as a `Vec` of your making.
- ///
- /// Returns a `clap::Error` in case of failure. This does *not* exit in the
- /// case of `--help` or `--version`, to achieve the same behavior as
- /// `from_iter()` you must call `.exit()` on the error value.
- fn from_iter_safe<I>(iter: I) -> Result<Self, clap::Error>
- where
- Self: Sized,
- I: IntoIterator,
- I::Item: Into<OsString> + Clone,
- {
- Ok(Self::from_clap(&Self::clap().get_matches_from_safe(iter)?))
- }
-}
-
-/// This trait is NOT API. **SUBJECT TO CHANGE WITHOUT NOTICE!**.
-#[doc(hidden)]
-pub trait StructOptInternal: StructOpt {
- fn augment_clap<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- app
- }
-
- fn is_subcommand() -> bool {
- false
- }
-
- fn from_subcommand<'a, 'b>(_sub: (&'b str, Option<&'b clap::ArgMatches<'a>>)) -> Option<Self>
- where
- Self: std::marker::Sized,
- {
- None
- }
-}
-
-impl<T: StructOpt> StructOpt for Box<T> {
- fn clap<'a, 'b>() -> clap::App<'a, 'b> {
- <T as StructOpt>::clap()
- }
-
- fn from_clap(matches: &clap::ArgMatches<'_>) -> Self {
- Box::new(<T as StructOpt>::from_clap(matches))
- }
-}
-
-impl<T: StructOptInternal> StructOptInternal for Box<T> {
- #[doc(hidden)]
- fn is_subcommand() -> bool {
- <T as StructOptInternal>::is_subcommand()
- }
-
- #[doc(hidden)]
- fn from_subcommand<'a, 'b>(sub: (&'b str, Option<&'b clap::ArgMatches<'a>>)) -> Option<Self> {
- <T as StructOptInternal>::from_subcommand(sub).map(Box::new)
- }
-
- #[doc(hidden)]
- fn augment_clap<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- <T as StructOptInternal>::augment_clap(app)
- }
-}
diff --git a/structopt/structopt-derive/Cargo.toml b/structopt/structopt-derive/Cargo.toml
deleted file mode 100644
index ad547af..0000000
--- a/structopt/structopt-derive/Cargo.toml
+++ /dev/null
@@ -1,27 +0,0 @@
-[package]
-name = "structopt-derive"
-version = "0.4.0"
-edition = "2018"
-authors = ["Guillaume Pinot <texitoi@texitoi.eu>"]
-description = "Parse command line argument by defining a struct, derive crate."
-documentation = "https://docs.rs/structopt-derive"
-repository = "https://github.com/TeXitoi/structopt"
-keywords = ["clap", "cli", "derive", "docopt"]
-categories = ["command-line-interface"]
-license = "Apache-2.0/MIT"
-
-[badges]
-travis-ci = { repository = "TeXitoi/structopt" }
-
-[dependencies]
-syn = { version = "1", features = ["full"] }
-quote = "1"
-proc-macro2 = "1"
-heck = "0.3.0"
-proc-macro-error = "0.4.3"
-
-[features]
-paw = []
-
-[lib]
-proc-macro = true
diff --git a/structopt/structopt-derive/LICENSE-APACHE b/structopt/structopt-derive/LICENSE-APACHE
deleted file mode 100644
index 261eeb9..0000000
--- a/structopt/structopt-derive/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/structopt/structopt-derive/LICENSE-MIT b/structopt/structopt-derive/LICENSE-MIT
deleted file mode 100644
index e931b83..0000000
--- a/structopt/structopt-derive/LICENSE-MIT
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-
-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/structopt/structopt-derive/src/attrs.rs b/structopt/structopt-derive/src/attrs.rs
deleted file mode 100644
index ce684a2..0000000
--- a/structopt/structopt-derive/src/attrs.rs
+++ /dev/null
@@ -1,620 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use crate::doc_comments::process_doc_comment;
-use crate::{parse::*, spanned::Sp, ty::Ty};
-
-use std::env;
-
-use heck::{CamelCase, KebabCase, MixedCase, ShoutySnakeCase, SnakeCase};
-use proc_macro2::{Span, TokenStream};
-use proc_macro_error::abort;
-use quote::{quote, quote_spanned, ToTokens};
-use syn::{self, ext::IdentExt, spanned::Spanned, Attribute, Expr, Ident, LitStr, MetaNameValue};
-
-#[derive(Clone)]
-pub enum Kind {
- Arg(Sp<Ty>),
- Subcommand(Sp<Ty>),
- FlattenStruct,
- Skip(Option<Expr>),
-}
-
-#[derive(Clone)]
-pub struct Method {
- name: Ident,
- args: TokenStream,
-}
-
-#[derive(Clone)]
-pub struct Parser {
- pub kind: Sp<ParserKind>,
- pub func: TokenStream,
-}
-
-#[derive(Debug, PartialEq, Clone)]
-pub enum ParserKind {
- FromStr,
- TryFromStr,
- FromOsStr,
- TryFromOsStr,
- FromOccurrences,
- FromFlag,
-}
-
-/// Defines the casing for the attributes long representation.
-#[derive(Copy, Clone, Debug, PartialEq)]
-pub enum CasingStyle {
- /// Indicate word boundaries with uppercase letter, excluding the first word.
- Camel,
- /// Keep all letters lowercase and indicate word boundaries with hyphens.
- Kebab,
- /// Indicate word boundaries with uppercase letter, including the first word.
- Pascal,
- /// Keep all letters uppercase and indicate word boundaries with underscores.
- ScreamingSnake,
- /// Keep all letters lowercase and indicate word boundaries with underscores.
- Snake,
- /// Use the original attribute name defined in the code.
- Verbatim,
-}
-
-#[derive(Clone)]
-pub enum Name {
- Derived(Ident),
- Assigned(LitStr),
-}
-
-#[derive(Clone)]
-pub struct Attrs {
- name: Name,
- casing: Sp<CasingStyle>,
- env_casing: Sp<CasingStyle>,
- doc_comment: Vec<Method>,
- methods: Vec<Method>,
- parser: Sp<Parser>,
- author: Option<Method>,
- about: Option<Method>,
- version: Option<Method>,
- no_version: Option<Ident>,
- verbatim_doc_comment: Option<Ident>,
- has_custom_parser: bool,
- kind: Sp<Kind>,
-}
-
-impl Method {
- pub fn new(name: Ident, args: TokenStream) -> Self {
- Method { name, args }
- }
-
- fn from_lit_or_env(ident: Ident, lit: Option<LitStr>, env_var: &str) -> Option<Self> {
- let mut lit = match lit {
- Some(lit) => lit,
-
- None => match env::var(env_var) {
- Ok(val) => LitStr::new(&val, ident.span()),
- Err(_) => {
- abort!(ident.span(),
- "cannot derive `{}` from Cargo.toml", ident;
- note = "`{}` environment variable is not set", env_var;
- help = "use `{} = \"...\"` to set {} manually", ident, ident;
- );
- }
- },
- };
-
- if ident == "author" {
- let edited = process_author_str(&lit.value());
- lit = LitStr::new(&edited, lit.span());
- }
-
- Some(Method::new(ident, quote!(#lit)))
- }
-}
-
-impl ToTokens for Method {
- fn to_tokens(&self, ts: &mut TokenStream) {
- let Method { ref name, ref args } = self;
- quote!(.#name(#args)).to_tokens(ts);
- }
-}
-
-impl Parser {
- fn default_spanned(span: Span) -> Sp<Self> {
- let kind = Sp::new(ParserKind::TryFromStr, span);
- let func = quote_spanned!(span=> ::std::str::FromStr::from_str);
- Sp::new(Parser { kind, func }, span)
- }
-
- fn from_spec(parse_ident: Ident, spec: ParserSpec) -> Sp<Self> {
- use ParserKind::*;
-
- let kind = match &*spec.kind.to_string() {
- "from_str" => FromStr,
- "try_from_str" => TryFromStr,
- "from_os_str" => FromOsStr,
- "try_from_os_str" => TryFromOsStr,
- "from_occurrences" => FromOccurrences,
- "from_flag" => FromFlag,
- s => abort!(spec.kind.span(), "unsupported parser `{}`", s),
- };
-
- let func = match spec.parse_func {
- None => match kind {
- FromStr | FromOsStr => {
- quote_spanned!(spec.kind.span()=> ::std::convert::From::from)
- }
- TryFromStr => quote_spanned!(spec.kind.span()=> ::std::str::FromStr::from_str),
- TryFromOsStr => abort!(
- spec.kind.span(),
- "you must set parser for `try_from_os_str` explicitly"
- ),
- FromOccurrences => quote_spanned!(spec.kind.span()=> { |v| v as _ }),
- FromFlag => quote_spanned!(spec.kind.span()=> ::std::convert::From::from),
- },
-
- Some(func) => match func {
- syn::Expr::Path(_) => quote!(#func),
- _ => abort!(func.span(), "`parse` argument must be a function path"),
- },
- };
-
- let kind = Sp::new(kind, spec.kind.span());
- let parser = Parser { kind, func };
- Sp::new(parser, parse_ident.span())
- }
-}
-
-impl CasingStyle {
- fn from_lit(name: LitStr) -> Sp<Self> {
- use CasingStyle::*;
-
- let normalized = name.value().to_camel_case().to_lowercase();
- let cs = |kind| Sp::new(kind, name.span());
-
- match normalized.as_ref() {
- "camel" | "camelcase" => cs(Camel),
- "kebab" | "kebabcase" => cs(Kebab),
- "pascal" | "pascalcase" => cs(Pascal),
- "screamingsnake" | "screamingsnakecase" => cs(ScreamingSnake),
- "snake" | "snakecase" => cs(Snake),
- "verbatim" | "verbatimcase" => cs(Verbatim),
- s => abort!(name.span(), "unsupported casing: `{}`", s),
- }
- }
-}
-
-impl Name {
- pub fn translate(self, style: CasingStyle) -> LitStr {
- use CasingStyle::*;
-
- match self {
- Name::Assigned(lit) => lit,
- Name::Derived(ident) => {
- let s = ident.unraw().to_string();
- let s = match style {
- Pascal => s.to_camel_case(),
- Kebab => s.to_kebab_case(),
- Camel => s.to_mixed_case(),
- ScreamingSnake => s.to_shouty_snake_case(),
- Snake => s.to_snake_case(),
- Verbatim => s,
- };
- LitStr::new(&s, ident.span())
- }
- }
- }
-}
-
-impl Attrs {
- fn new(
- default_span: Span,
- name: Name,
- casing: Sp<CasingStyle>,
- env_casing: Sp<CasingStyle>,
- ) -> Self {
- Self {
- name,
- casing,
- env_casing,
- doc_comment: vec![],
- methods: vec![],
- parser: Parser::default_spanned(default_span),
- about: None,
- author: None,
- version: None,
- no_version: None,
- verbatim_doc_comment: None,
-
- has_custom_parser: false,
- kind: Sp::new(Kind::Arg(Sp::new(Ty::Other, default_span)), default_span),
- }
- }
-
- /// push `.method("str literal")`
- fn push_str_method(&mut self, name: Sp<String>, arg: Sp<String>) {
- if *name == "name" {
- self.name = Name::Assigned(arg.as_lit());
- } else {
- self.methods
- .push(Method::new(name.as_ident(), quote!(#arg)))
- }
- }
-
- fn push_attrs(&mut self, attrs: &[Attribute]) {
- use crate::parse::StructOptAttr::*;
-
- for attr in parse_structopt_attributes(attrs) {
- match attr {
- Short(ident) | Long(ident) => {
- self.push_str_method(
- ident.into(),
- self.name.clone().translate(*self.casing).into(),
- );
- }
-
- Env(ident) => {
- self.push_str_method(
- ident.into(),
- self.name.clone().translate(*self.env_casing).into(),
- );
- }
-
- Subcommand(ident) => {
- let ty = Sp::call_site(Ty::Other);
- let kind = Sp::new(Kind::Subcommand(ty), ident.span());
- self.set_kind(kind);
- }
-
- Flatten(ident) => {
- let kind = Sp::new(Kind::FlattenStruct, ident.span());
- self.set_kind(kind);
- }
-
- Skip(ident, expr) => {
- let kind = Sp::new(Kind::Skip(expr), ident.span());
- self.set_kind(kind);
- }
-
- NoVersion(ident) => self.no_version = Some(ident),
-
- VerbatimDocComment(ident) => self.verbatim_doc_comment = Some(ident),
-
- About(ident, about) => {
- self.about = Method::from_lit_or_env(ident, about, "CARGO_PKG_DESCRIPTION");
- }
-
- Author(ident, author) => {
- self.author = Method::from_lit_or_env(ident, author, "CARGO_PKG_AUTHORS");
- }
-
- Version(ident, version) => {
- self.version = Some(Method::new(ident, quote!(#version)))
- }
-
- NameLitStr(name, lit) => {
- self.push_str_method(name.into(), lit.into());
- }
-
- NameExpr(name, expr) => self.methods.push(Method::new(name, quote!(#expr))),
-
- MethodCall(name, args) => self.methods.push(Method::new(name, quote!(#(#args),*))),
-
- RenameAll(_, casing_lit) => {
- self.casing = CasingStyle::from_lit(casing_lit);
- }
-
- RenameAllEnv(_, casing_lit) => {
- self.env_casing = CasingStyle::from_lit(casing_lit);
- }
-
- Parse(ident, spec) => {
- self.has_custom_parser = true;
- self.parser = Parser::from_spec(ident, spec);
- }
- }
- }
- }
-
- fn push_doc_comment(&mut self, attrs: &[Attribute], name: &str) {
- use crate::Lit::*;
- use crate::Meta::*;
-
- let comment_parts: Vec<_> = attrs
- .iter()
- .filter(|attr| attr.path.is_ident("doc"))
- .filter_map(|attr| {
- if let Ok(NameValue(MetaNameValue { lit: Str(s), .. })) = attr.parse_meta() {
- Some(s.value())
- } else {
- // non #[doc = "..."] attributes are not our concern
- // we leave them for rustc to handle
- None
- }
- })
- .collect();
-
- self.doc_comment =
- process_doc_comment(comment_parts, name, self.verbatim_doc_comment.is_none());
- }
-
- pub fn from_struct(
- span: Span,
- attrs: &[Attribute],
- name: Name,
- argument_casing: Sp<CasingStyle>,
- env_casing: Sp<CasingStyle>,
- ) -> Self {
- let mut res = Self::new(span, name, argument_casing, env_casing);
- res.push_attrs(attrs);
- res.push_doc_comment(attrs, "about");
-
- if res.has_custom_parser {
- abort!(
- res.parser.span(),
- "`parse` attribute is only allowed on fields"
- );
- }
- match &*res.kind {
- Kind::Subcommand(_) => abort!(res.kind.span(), "subcommand is only allowed on fields"),
- Kind::FlattenStruct => abort!(res.kind.span(), "flatten is only allowed on fields"),
- Kind::Skip(_) => abort!(res.kind.span(), "skip is only allowed on fields"),
- Kind::Arg(_) => res,
- }
- }
-
- pub fn from_field(
- field: &syn::Field,
- struct_casing: Sp<CasingStyle>,
- env_casing: Sp<CasingStyle>,
- ) -> Self {
- let name = field.ident.clone().unwrap();
- let mut res = Self::new(
- field.span(),
- Name::Derived(name.clone()),
- struct_casing,
- env_casing,
- );
- res.push_doc_comment(&field.attrs, "help");
- res.push_attrs(&field.attrs);
-
- match &*res.kind {
- Kind::FlattenStruct => {
- if res.has_custom_parser {
- abort!(
- res.parser.span(),
- "parse attribute is not allowed for flattened entry"
- );
- }
- if res.has_explicit_methods() || res.has_doc_methods() {
- abort!(
- res.kind.span(),
- "methods and doc comments are not allowed for flattened entry"
- );
- }
- }
- Kind::Subcommand(_) => {
- if res.has_custom_parser {
- abort!(
- res.parser.span(),
- "parse attribute is not allowed for subcommand"
- );
- }
- if res.has_explicit_methods() {
- abort!(
- res.kind.span(),
- "methods in attributes are not allowed for subcommand"
- );
- }
-
- let ty = Ty::from_syn_ty(&field.ty);
- match *ty {
- Ty::OptionOption => {
- abort!(
- ty.span(),
- "Option<Option<T>> type is not allowed for subcommand"
- );
- }
- Ty::OptionVec => {
- abort!(
- ty.span(),
- "Option<Vec<T>> type is not allowed for subcommand"
- );
- }
- _ => (),
- }
-
- res.kind = Sp::new(Kind::Subcommand(ty), res.kind.span());
- }
- Kind::Skip(_) => {
- if res.has_explicit_methods() {
- abort!(
- res.kind.span(),
- "methods are not allowed for skipped fields"
- );
- }
- }
- Kind::Arg(orig_ty) => {
- let mut ty = Ty::from_syn_ty(&field.ty);
- if res.has_custom_parser {
- match *ty {
- Ty::Option | Ty::Vec | Ty::OptionVec => (),
- _ => ty = Sp::new(Ty::Other, ty.span()),
- }
- }
-
- match *ty {
- Ty::Bool => {
- if res.is_positional() && !res.has_custom_parser {
- abort!(ty.span(),
- "`bool` cannot be used as positional parameter with default parser";
- help = "if you want to create a flag add `long` or `short`";
- help = "If you really want a boolean parameter \
- add an explicit parser, for example `parse(try_from_str)`";
- note = "see also https://github.com/TeXitoi/structopt/tree/master/examples/true_or_false.rs";
- )
- }
- if let Some(m) = res.find_method("default_value") {
- abort!(m.name.span(), "default_value is meaningless for bool")
- }
- if let Some(m) = res.find_method("required") {
- abort!(m.name.span(), "required is meaningless for bool")
- }
- }
- Ty::Option => {
- if let Some(m) = res.find_method("default_value") {
- abort!(m.name.span(), "default_value is meaningless for Option")
- }
- if let Some(m) = res.find_method("required") {
- abort!(m.name.span(), "required is meaningless for Option")
- }
- }
- Ty::OptionOption => {
- if res.is_positional() {
- abort!(
- ty.span(),
- "Option<Option<T>> type is meaningless for positional argument"
- )
- }
- }
- Ty::OptionVec => {
- if res.is_positional() {
- abort!(
- ty.span(),
- "Option<Vec<T>> type is meaningless for positional argument"
- )
- }
- }
-
- _ => (),
- }
- res.kind = Sp::new(Kind::Arg(ty), orig_ty.span());
- }
- }
-
- res
- }
-
- fn set_kind(&mut self, kind: Sp<Kind>) {
- if let Kind::Arg(_) = *self.kind {
- self.kind = kind;
- } else {
- abort!(
- kind.span(),
- "subcommand, flatten and skip cannot be used together"
- );
- }
- }
-
- pub fn has_method(&self, name: &str) -> bool {
- self.find_method(name).is_some()
- }
-
- pub fn find_method(&self, name: &str) -> Option<&Method> {
- self.methods.iter().find(|m| m.name == name)
- }
-
- /// generate methods from attributes on top of struct or enum
- pub fn top_level_methods(&self) -> TokenStream {
- let version = match (&self.no_version, &self.version) {
- (Some(no_version), Some(_)) => abort!(
- no_version.span(),
- "`no_version` and `version = \"version\"` can't be used together"
- ),
-
- (None, Some(m)) => m.to_token_stream(),
-
- (None, None) => std::env::var("CARGO_PKG_VERSION")
- .map(|version| quote!( .version(#version) ))
- .unwrap_or_default(),
-
- (Some(_), None) => quote!(),
- };
-
- let author = &self.author;
- let about = &self.about;
- let methods = &self.methods;
- let doc_comment = &self.doc_comment;
-
- quote!( #(#doc_comment)* #author #version #about #(#methods)* )
- }
-
- /// generate methods on top of a field
- pub fn field_methods(&self) -> TokenStream {
- let methods = &self.methods;
- let doc_comment = &self.doc_comment;
- quote!( #(#doc_comment)* #(#methods)* )
- }
-
- pub fn cased_name(&self) -> LitStr {
- self.name.clone().translate(*self.casing)
- }
-
- pub fn parser(&self) -> &Sp<Parser> {
- &self.parser
- }
-
- pub fn kind(&self) -> Sp<Kind> {
- self.kind.clone()
- }
-
- pub fn casing(&self) -> Sp<CasingStyle> {
- self.casing.clone()
- }
-
- pub fn env_casing(&self) -> Sp<CasingStyle> {
- self.env_casing.clone()
- }
-
- pub fn is_positional(&self) -> bool {
- self.methods
- .iter()
- .all(|m| m.name != "long" && m.name != "short")
- }
-
- pub fn has_explicit_methods(&self) -> bool {
- self.methods
- .iter()
- .any(|m| m.name != "help" && m.name != "long_help")
- }
-
- pub fn has_doc_methods(&self) -> bool {
- !self.doc_comment.is_empty()
- || self.methods.iter().any(|m| {
- m.name == "help"
- || m.name == "long_help"
- || m.name == "about"
- || m.name == "long_about"
- })
- }
-}
-
-/// replace all `:` with `, ` when not inside the `<>`
-///
-/// `"author1:author2:author3" => "author1, author2, author3"`
-/// `"author1 <http://website1.com>:author2" => "author1 <http://website1.com>, author2"
-fn process_author_str(author: &str) -> String {
- let mut res = String::with_capacity(author.len());
- let mut inside_angle_braces = 0usize;
-
- for ch in author.chars() {
- if inside_angle_braces > 0 && ch == '>' {
- inside_angle_braces -= 1;
- res.push(ch);
- } else if ch == '<' {
- inside_angle_braces += 1;
- res.push(ch);
- } else if inside_angle_braces == 0 && ch == ':' {
- res.push_str(", ");
- } else {
- res.push(ch);
- }
- }
-
- res
-}
diff --git a/structopt/structopt-derive/src/doc_comments.rs b/structopt/structopt-derive/src/doc_comments.rs
deleted file mode 100644
index 06e1b14..0000000
--- a/structopt/structopt-derive/src/doc_comments.rs
+++ /dev/null
@@ -1,103 +0,0 @@
-//! The preprocessing we apply to doc comments.
-//!
-//! structopt works in terms of "paragraphs". Paragraph is a sequence of
-//! non-empty adjacent lines, delimited by sequences of blank (whitespace only) lines.
-
-use crate::attrs::Method;
-use quote::{format_ident, quote};
-use std::iter;
-
-pub fn process_doc_comment(lines: Vec<String>, name: &str, preprocess: bool) -> Vec<Method> {
- // multiline comments (`/** ... */`) may have LFs (`\n`) in them,
- // we need to split so we could handle the lines correctly
- //
- // we also need to remove leading and trailing blank lines
- let mut lines: Vec<&str> = lines
- .iter()
- .skip_while(|s| is_blank(s))
- .flat_map(|s| s.split('\n'))
- .collect();
-
- while let Some(true) = lines.last().map(|s| is_blank(s)) {
- lines.pop();
- }
-
- // remove one leading space no matter what
- for line in lines.iter_mut() {
- if line.starts_with(' ') {
- *line = &line[1..];
- }
- }
-
- if lines.is_empty() {
- return vec![];
- }
-
- let short_name = format_ident!("{}", name);
- let long_name = format_ident!("long_{}", name);
-
- if let Some(first_blank) = lines.iter().position(|s| is_blank(s)) {
- let (short, long) = if preprocess {
- let paragraphs = split_paragraphs(&lines);
- let short = paragraphs[0].clone();
- let long = paragraphs.join("\n\n");
- (remove_period(short), long)
- } else {
- let short = lines[..first_blank].join("\n");
- let long = lines.join("\n");
- (short, long)
- };
-
- vec![
- Method::new(short_name, quote!(#short)),
- Method::new(long_name, quote!(#long)),
- ]
- } else {
- let short = if preprocess {
- let s = merge_lines(&lines);
- remove_period(s)
- } else {
- lines.join("\n")
- };
-
- vec![Method::new(short_name, quote!(#short))]
- }
-}
-
-fn split_paragraphs(lines: &[&str]) -> Vec<String> {
- let mut last_line = 0;
- iter::from_fn(|| {
- let slice = &lines[last_line..];
- let start = slice.iter().position(|s| !is_blank(s)).unwrap_or(0);
-
- let slice = &slice[start..];
- let len = slice
- .iter()
- .position(|s| is_blank(s))
- .unwrap_or(slice.len());
-
- last_line += start + len;
-
- if len != 0 {
- Some(merge_lines(&slice[..len]))
- } else {
- None
- }
- })
- .collect()
-}
-
-fn remove_period(mut s: String) -> String {
- if s.ends_with('.') && !s.ends_with("..") {
- s.pop();
- }
- s
-}
-
-fn is_blank(s: &str) -> bool {
- s.trim().is_empty()
-}
-
-fn merge_lines(lines: &[&str]) -> String {
- lines.iter().map(|s| s.trim()).collect::<Vec<_>>().join(" ")
-}
diff --git a/structopt/structopt-derive/src/lib.rs b/structopt/structopt-derive/src/lib.rs
deleted file mode 100644
index 87eaf1f..0000000
--- a/structopt/structopt-derive/src/lib.rs
+++ /dev/null
@@ -1,667 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 crate is custom derive for `StructOpt`. It should not be used
-//! directly. See [structopt documentation](https://docs.rs/structopt)
-//! for the usage of `#[derive(StructOpt)]`.
-
-#![allow(clippy::large_enum_variant)]
-
-extern crate proc_macro;
-
-mod attrs;
-mod doc_comments;
-mod parse;
-mod spanned;
-mod ty;
-
-use crate::{
- attrs::{Attrs, CasingStyle, Kind, Name, ParserKind},
- spanned::Sp,
- ty::{sub_type, Ty},
-};
-
-use proc_macro2::{Span, TokenStream};
-use proc_macro_error::{abort, abort_call_site, proc_macro_error, set_dummy};
-use quote::{quote, quote_spanned};
-use syn::{punctuated::Punctuated, spanned::Spanned, token::Comma, *};
-
-/// Default casing style for generated arguments.
-const DEFAULT_CASING: CasingStyle = CasingStyle::Kebab;
-
-/// Default casing style for environment variables
-const DEFAULT_ENV_CASING: CasingStyle = CasingStyle::ScreamingSnake;
-
-/// Output for the `gen_xxx()` methods were we need more than a simple stream of tokens.
-///
-/// The output of a generation method is not only the stream of new tokens but also the attribute
-/// information of the current element. These attribute information may contain valuable information
-/// for any kind of child arguments.
-struct GenOutput {
- tokens: TokenStream,
- attrs: Attrs,
-}
-
-/// Generates the `StructOpt` impl.
-#[proc_macro_derive(StructOpt, attributes(structopt))]
-#[proc_macro_error]
-pub fn structopt(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
- let input: DeriveInput = syn::parse(input).unwrap();
- let gen = impl_structopt(&input);
- gen.into()
-}
-
-/// Generate a block of code to add arguments/subcommands corresponding to
-/// the `fields` to an app.
-fn gen_augmentation(
- fields: &Punctuated<Field, Comma>,
- app_var: &Ident,
- parent_attribute: &Attrs,
-) -> TokenStream {
- let mut subcmds = fields.iter().filter_map(|field| {
- let attrs = Attrs::from_field(
- field,
- parent_attribute.casing(),
- parent_attribute.env_casing(),
- );
- let kind = attrs.kind();
- if let Kind::Subcommand(ty) = &*kind {
- let subcmd_type = match (**ty, sub_type(&field.ty)) {
- (Ty::Option, Some(sub_type)) => sub_type,
- _ => &field.ty,
- };
- let required = if **ty == Ty::Option {
- quote!()
- } else {
- quote_spanned! { kind.span()=>
- let #app_var = #app_var.setting(
- ::structopt::clap::AppSettings::SubcommandRequiredElseHelp
- );
- }
- };
-
- let span = field.span();
- let ts = quote! {
- let #app_var = <#subcmd_type as ::structopt::StructOptInternal>::augment_clap(
- #app_var
- );
- #required
- };
- Some((span, ts))
- } else {
- None
- }
- });
-
- let subcmd = subcmds.next().map(|(_, ts)| ts);
- if let Some((span, _)) = subcmds.next() {
- abort!(
- span,
- "multiple subcommand sets are not allowed, that's the second"
- );
- }
-
- let args = fields.iter().filter_map(|field| {
- let attrs = Attrs::from_field(
- field,
- parent_attribute.casing(),
- parent_attribute.env_casing(),
- );
- let kind = attrs.kind();
- match &*kind {
- Kind::Subcommand(_) | Kind::Skip(_) => None,
- Kind::FlattenStruct => {
- let ty = &field.ty;
- Some(quote_spanned! { kind.span()=>
- let #app_var = <#ty as ::structopt::StructOptInternal>::augment_clap(#app_var);
- let #app_var = if <#ty as ::structopt::StructOptInternal>::is_subcommand() {
- #app_var.setting(::structopt::clap::AppSettings::SubcommandRequiredElseHelp)
- } else {
- #app_var
- };
- })
- }
- Kind::Arg(ty) => {
- let convert_type = match **ty {
- Ty::Vec | Ty::Option => sub_type(&field.ty).unwrap_or(&field.ty),
- Ty::OptionOption | Ty::OptionVec => {
- sub_type(&field.ty).and_then(sub_type).unwrap_or(&field.ty)
- }
- _ => &field.ty,
- };
-
- let occurrences = *attrs.parser().kind == ParserKind::FromOccurrences;
- let flag = *attrs.parser().kind == ParserKind::FromFlag;
-
- let parser = attrs.parser();
- let func = &parser.func;
- let validator = match *parser.kind {
- ParserKind::TryFromStr => quote_spanned! { func.span()=>
- .validator(|s| {
- #func(s.as_str())
- .map(|_: #convert_type| ())
- .map_err(|e| e.to_string())
- })
- },
- ParserKind::TryFromOsStr => quote_spanned! { func.span()=>
- .validator_os(|s| #func(&s).map(|_: #convert_type| ()))
- },
- _ => quote!(),
- };
-
- let modifier = match **ty {
- Ty::Bool => quote_spanned! { ty.span()=>
- .takes_value(false)
- .multiple(false)
- },
-
- Ty::Option => quote_spanned! { ty.span()=>
- .takes_value(true)
- .multiple(false)
- #validator
- },
-
- Ty::OptionOption => quote_spanned! { ty.span()=>
- .takes_value(true)
- .multiple(false)
- .min_values(0)
- .max_values(1)
- #validator
- },
-
- Ty::OptionVec => quote_spanned! { ty.span()=>
- .takes_value(true)
- .multiple(true)
- .min_values(0)
- #validator
- },
-
- Ty::Vec => quote_spanned! { ty.span()=>
- .takes_value(true)
- .multiple(true)
- #validator
- },
-
- Ty::Other if occurrences => quote_spanned! { ty.span()=>
- .takes_value(false)
- .multiple(true)
- },
-
- Ty::Other if flag => quote_spanned! { ty.span()=>
- .takes_value(false)
- .multiple(false)
- },
-
- Ty::Other => {
- let required = !attrs.has_method("default_value");
- quote_spanned! { ty.span()=>
- .takes_value(true)
- .multiple(false)
- .required(#required)
- #validator
- }
- }
- };
-
- let name = attrs.cased_name();
- let methods = attrs.field_methods();
-
- Some(quote_spanned! { field.span()=>
- let #app_var = #app_var.arg(
- ::structopt::clap::Arg::with_name(#name)
- #modifier
- #methods
- );
- })
- }
- }
- });
-
- let app_methods = parent_attribute.top_level_methods();
- quote! {{
- let #app_var = #app_var#app_methods;
- #( #args )*
- #subcmd
- #app_var
- }}
-}
-
-fn gen_constructor(fields: &Punctuated<Field, Comma>, parent_attribute: &Attrs) -> TokenStream {
- let fields = fields.iter().map(|field| {
- let attrs = Attrs::from_field(
- field,
- parent_attribute.casing(),
- parent_attribute.env_casing(),
- );
- let field_name = field.ident.as_ref().unwrap();
- let kind = attrs.kind();
- match &*kind {
- Kind::Subcommand(ty) => {
- let subcmd_type = match (**ty, sub_type(&field.ty)) {
- (Ty::Option, Some(sub_type)) => sub_type,
- _ => &field.ty,
- };
- let unwrapper = match **ty {
- Ty::Option => quote!(),
- _ => quote_spanned!( ty.span()=> .unwrap() ),
- };
- quote_spanned! { kind.span()=>
- #field_name: <#subcmd_type as ::structopt::StructOptInternal>::from_subcommand(
- matches.subcommand())
- #unwrapper
- }
- }
-
- Kind::FlattenStruct => quote_spanned! { kind.span()=>
- #field_name: ::structopt::StructOpt::from_clap(matches)
- },
-
- Kind::Skip(val) => match val {
- None => quote_spanned!(kind.span()=> #field_name: Default::default()),
- Some(val) => quote_spanned!(kind.span()=> #field_name: (#val).into()),
- },
-
- Kind::Arg(ty) => {
- use crate::attrs::ParserKind::*;
-
- let parser = attrs.parser();
- let func = &parser.func;
- let span = parser.kind.span();
- let (value_of, values_of, parse) = match *parser.kind {
- FromStr => (
- quote_spanned!(span=> value_of),
- quote_spanned!(span=> values_of),
- func.clone(),
- ),
- TryFromStr => (
- quote_spanned!(span=> value_of),
- quote_spanned!(span=> values_of),
- quote_spanned!(func.span()=> |s| #func(s).unwrap()),
- ),
- FromOsStr => (
- quote_spanned!(span=> value_of_os),
- quote_spanned!(span=> values_of_os),
- func.clone(),
- ),
- TryFromOsStr => (
- quote_spanned!(span=> value_of_os),
- quote_spanned!(span=> values_of_os),
- quote_spanned!(func.span()=> |s| #func(s).unwrap()),
- ),
- FromOccurrences => (
- quote_spanned!(span=> occurrences_of),
- quote!(),
- func.clone(),
- ),
- FromFlag => (quote!(), quote!(), func.clone()),
- };
-
- let flag = *attrs.parser().kind == ParserKind::FromFlag;
- let occurrences = *attrs.parser().kind == ParserKind::FromOccurrences;
- let name = attrs.cased_name();
- let field_value = match **ty {
- Ty::Bool => quote_spanned!(ty.span()=> matches.is_present(#name)),
-
- Ty::Option => quote_spanned! { ty.span()=>
- matches.#value_of(#name)
- .map(#parse)
- },
-
- Ty::OptionOption => quote_spanned! { ty.span()=>
- if matches.is_present(#name) {
- Some(matches.#value_of(#name).map(#parse))
- } else {
- None
- }
- },
-
- Ty::OptionVec => quote_spanned! { ty.span()=>
- if matches.is_present(#name) {
- Some(matches.#values_of(#name)
- .map_or_else(Vec::new, |v| v.map(#parse).collect()))
- } else {
- None
- }
- },
-
- Ty::Vec => quote_spanned! { ty.span()=>
- matches.#values_of(#name)
- .map_or_else(Vec::new, |v| v.map(#parse).collect())
- },
-
- Ty::Other if occurrences => quote_spanned! { ty.span()=>
- #parse(matches.#value_of(#name))
- },
-
- Ty::Other if flag => quote_spanned! { ty.span()=>
- #parse(matches.is_present(#name))
- },
-
- Ty::Other => quote_spanned! { ty.span()=>
- matches.#value_of(#name)
- .map(#parse)
- .unwrap()
- },
- };
-
- quote_spanned!(field.span()=> #field_name: #field_value )
- }
- }
- });
-
- quote! {{
- #( #fields ),*
- }}
-}
-
-fn gen_from_clap(
- struct_name: &Ident,
- fields: &Punctuated<Field, Comma>,
- parent_attribute: &Attrs,
-) -> TokenStream {
- let field_block = gen_constructor(fields, parent_attribute);
-
- quote! {
- fn from_clap(matches: &::structopt::clap::ArgMatches) -> Self {
- #struct_name #field_block
- }
- }
-}
-
-fn gen_clap(attrs: &[Attribute]) -> GenOutput {
- let name = std::env::var("CARGO_PKG_NAME").ok().unwrap_or_default();
-
- let attrs = Attrs::from_struct(
- Span::call_site(),
- attrs,
- Name::Assigned(LitStr::new(&name, Span::call_site())),
- Sp::call_site(DEFAULT_CASING),
- Sp::call_site(DEFAULT_ENV_CASING),
- );
- let tokens = {
- let name = attrs.cased_name();
- quote!(::structopt::clap::App::new(#name))
- };
-
- GenOutput { tokens, attrs }
-}
-
-fn gen_clap_struct(struct_attrs: &[Attribute]) -> GenOutput {
- let initial_clap_app_gen = gen_clap(struct_attrs);
- let clap_tokens = initial_clap_app_gen.tokens;
-
- let augmented_tokens = quote! {
- fn clap<'a, 'b>() -> ::structopt::clap::App<'a, 'b> {
- let app = #clap_tokens;
- <Self as ::structopt::StructOptInternal>::augment_clap(app)
- }
- };
-
- GenOutput {
- tokens: augmented_tokens,
- attrs: initial_clap_app_gen.attrs,
- }
-}
-
-fn gen_augment_clap(fields: &Punctuated<Field, Comma>, parent_attribute: &Attrs) -> TokenStream {
- let app_var = Ident::new("app", Span::call_site());
- let augmentation = gen_augmentation(fields, &app_var, parent_attribute);
- quote! {
- fn augment_clap<'a, 'b>(
- #app_var: ::structopt::clap::App<'a, 'b>
- ) -> ::structopt::clap::App<'a, 'b> {
- #augmentation
- }
- }
-}
-
-fn gen_clap_enum(enum_attrs: &[Attribute]) -> GenOutput {
- let initial_clap_app_gen = gen_clap(enum_attrs);
- let clap_tokens = initial_clap_app_gen.tokens;
-
- let tokens = quote! {
- fn clap<'a, 'b>() -> ::structopt::clap::App<'a, 'b> {
- let app = #clap_tokens
- .setting(::structopt::clap::AppSettings::SubcommandRequiredElseHelp);
- <Self as ::structopt::StructOptInternal>::augment_clap(app)
- }
- };
-
- GenOutput {
- tokens,
- attrs: initial_clap_app_gen.attrs,
- }
-}
-
-fn gen_augment_clap_enum(
- variants: &Punctuated<Variant, Comma>,
- parent_attribute: &Attrs,
-) -> TokenStream {
- use syn::Fields::*;
-
- let subcommands = variants.iter().map(|variant| {
- let attrs = Attrs::from_struct(
- variant.span(),
- &variant.attrs,
- Name::Derived(variant.ident.clone()),
- parent_attribute.casing(),
- parent_attribute.env_casing(),
- );
- let app_var = Ident::new("subcommand", Span::call_site());
- let arg_block = match variant.fields {
- Named(ref fields) => gen_augmentation(&fields.named, &app_var, &attrs),
- Unit => quote!( #app_var ),
- Unnamed(FieldsUnnamed { ref unnamed, .. }) if unnamed.len() == 1 => {
- let ty = &unnamed[0];
- quote_spanned! { ty.span()=>
- {
- let #app_var = <#ty as ::structopt::StructOptInternal>::augment_clap(
- #app_var
- );
- if <#ty as ::structopt::StructOptInternal>::is_subcommand() {
- #app_var.setting(
- ::structopt::clap::AppSettings::SubcommandRequiredElseHelp
- )
- } else {
- #app_var
- }
- }
- }
- }
- Unnamed(..) => abort_call_site!("{}: tuple enums are not supported", variant.ident),
- };
-
- let name = attrs.cased_name();
- let from_attrs = attrs.top_level_methods();
-
- quote! {
- .subcommand({
- let #app_var = ::structopt::clap::SubCommand::with_name(#name);
- let #app_var = #arg_block;
- #app_var#from_attrs
- })
- }
- });
-
- let app_methods = parent_attribute.top_level_methods();
-
- quote! {
- fn augment_clap<'a, 'b>(
- app: ::structopt::clap::App<'a, 'b>
- ) -> ::structopt::clap::App<'a, 'b> {
- app #app_methods #( #subcommands )*
- }
- }
-}
-
-fn gen_from_clap_enum(name: &Ident) -> TokenStream {
- quote! {
- fn from_clap(matches: &::structopt::clap::ArgMatches) -> Self {
- <#name as ::structopt::StructOptInternal>::from_subcommand(matches.subcommand())
- .unwrap()
- }
- }
-}
-
-fn gen_from_subcommand(
- name: &Ident,
- variants: &Punctuated<Variant, Comma>,
- parent_attribute: &Attrs,
-) -> TokenStream {
- use syn::Fields::*;
-
- let match_arms = variants.iter().map(|variant| {
- let attrs = Attrs::from_struct(
- variant.span(),
- &variant.attrs,
- Name::Derived(variant.ident.clone()),
- parent_attribute.casing(),
- parent_attribute.env_casing(),
- );
- let sub_name = attrs.cased_name();
- let variant_name = &variant.ident;
- let constructor_block = match variant.fields {
- Named(ref fields) => gen_constructor(&fields.named, &attrs),
- Unit => quote!(),
- Unnamed(ref fields) if fields.unnamed.len() == 1 => {
- let ty = &fields.unnamed[0];
- quote!( ( <#ty as ::structopt::StructOpt>::from_clap(matches) ) )
- }
- Unnamed(..) => abort_call_site!("{}: tuple enums are not supported", variant.ident),
- };
-
- quote! {
- (#sub_name, Some(matches)) =>
- Some(#name :: #variant_name #constructor_block)
- }
- });
-
- quote! {
- fn from_subcommand<'a, 'b>(
- sub: (&'b str, Option<&'b ::structopt::clap::ArgMatches<'a>>)
- ) -> Option<Self> {
- match sub {
- #( #match_arms ),*,
- _ => None
- }
- }
- }
-}
-
-#[cfg(feature = "paw")]
-fn gen_paw_impl(name: &Ident) -> TokenStream {
- quote! {
- impl paw::ParseArgs for #name {
- type Error = std::io::Error;
-
- fn parse_args() -> std::result::Result<Self, Self::Error> {
- Ok(<#name as ::structopt::StructOpt>::from_args())
- }
- }
- }
-}
-#[cfg(not(feature = "paw"))]
-fn gen_paw_impl(_: &Ident) -> TokenStream {
- TokenStream::new()
-}
-
-fn impl_structopt_for_struct(
- name: &Ident,
- fields: &Punctuated<Field, Comma>,
- attrs: &[Attribute],
-) -> TokenStream {
- let basic_clap_app_gen = gen_clap_struct(attrs);
- let augment_clap = gen_augment_clap(fields, &basic_clap_app_gen.attrs);
- let from_clap = gen_from_clap(name, fields, &basic_clap_app_gen.attrs);
- let paw_impl = gen_paw_impl(name);
-
- let clap_tokens = basic_clap_app_gen.tokens;
- quote! {
- #[allow(unused_variables)]
- #[allow(unknown_lints)]
- #[allow(clippy::all)]
- #[allow(dead_code, unreachable_code)]
- impl ::structopt::StructOpt for #name {
- #clap_tokens
- #from_clap
- }
-
- #[allow(unused_variables)]
- #[allow(unknown_lints)]
- #[allow(clippy::all)]
- #[allow(dead_code, unreachable_code)]
- impl ::structopt::StructOptInternal for #name {
- #augment_clap
- fn is_subcommand() -> bool { false }
- }
-
- #paw_impl
- }
-}
-
-fn impl_structopt_for_enum(
- name: &Ident,
- variants: &Punctuated<Variant, Comma>,
- attrs: &[Attribute],
-) -> TokenStream {
- let basic_clap_app_gen = gen_clap_enum(attrs);
-
- let augment_clap = gen_augment_clap_enum(variants, &basic_clap_app_gen.attrs);
- let from_clap = gen_from_clap_enum(name);
- let from_subcommand = gen_from_subcommand(name, variants, &basic_clap_app_gen.attrs);
- let paw_impl = gen_paw_impl(name);
-
- let clap_tokens = basic_clap_app_gen.tokens;
- quote! {
- #[allow(unknown_lints)]
- #[allow(unused_variables, dead_code, unreachable_code)]
- #[allow(clippy)]
- impl ::structopt::StructOpt for #name {
- #clap_tokens
- #from_clap
- }
-
- #[allow(unused_variables)]
- #[allow(unknown_lints)]
- #[allow(clippy::all)]
- #[allow(dead_code, unreachable_code)]
- impl ::structopt::StructOptInternal for #name {
- #augment_clap
- #from_subcommand
- fn is_subcommand() -> bool { true }
- }
-
- #paw_impl
- }
-}
-
-fn impl_structopt(input: &DeriveInput) -> TokenStream {
- use syn::Data::*;
-
- let struct_name = &input.ident;
-
- set_dummy(quote! {
- impl ::structopt::StructOpt for #struct_name {
- fn clap<'a, 'b>() -> ::structopt::clap::App<'a, 'b> {
- unimplemented!()
- }
- fn from_clap(_matches: &::structopt::clap::ArgMatches) -> Self {
- unimplemented!()
- }
- }
- });
-
- match input.data {
- Struct(DataStruct {
- fields: syn::Fields::Named(ref fields),
- ..
- }) => impl_structopt_for_struct(struct_name, &fields.named, &input.attrs),
- Enum(ref e) => impl_structopt_for_enum(struct_name, &e.variants, &input.attrs),
- _ => abort_call_site!("structopt only supports non-tuple structs and enums"),
- }
-}
diff --git a/structopt/structopt-derive/src/parse.rs b/structopt/structopt-derive/src/parse.rs
deleted file mode 100644
index a704742..0000000
--- a/structopt/structopt-derive/src/parse.rs
+++ /dev/null
@@ -1,304 +0,0 @@
-use std::iter::FromIterator;
-
-use proc_macro_error::{abort, ResultExt};
-use quote::ToTokens;
-use syn::{
- self, parenthesized,
- parse::{Parse, ParseBuffer, ParseStream},
- parse2,
- punctuated::Punctuated,
- spanned::Spanned,
- Attribute, Expr, ExprLit, Ident, Lit, LitBool, LitStr, Token,
-};
-
-pub struct StructOptAttributes {
- pub paren_token: syn::token::Paren,
- pub attrs: Punctuated<StructOptAttr, Token![,]>,
-}
-
-impl Parse for StructOptAttributes {
- fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
- let content;
- let paren_token = parenthesized!(content in input);
- let attrs = content.parse_terminated(StructOptAttr::parse)?;
-
- Ok(StructOptAttributes { paren_token, attrs })
- }
-}
-
-pub enum StructOptAttr {
- // single-identifier attributes
- Short(Ident),
- Long(Ident),
- Env(Ident),
- Flatten(Ident),
- Subcommand(Ident),
- NoVersion(Ident),
- VerbatimDocComment(Ident),
-
- // ident [= "string literal"]
- About(Ident, Option<LitStr>),
- Author(Ident, Option<LitStr>),
-
- // ident = "string literal"
- Version(Ident, LitStr),
- RenameAllEnv(Ident, LitStr),
- RenameAll(Ident, LitStr),
- NameLitStr(Ident, LitStr),
-
- // parse(parser_kind [= parser_func])
- Parse(Ident, ParserSpec),
-
- // ident [= arbitrary_expr]
- Skip(Ident, Option<Expr>),
-
- // ident = arbitrary_expr
- NameExpr(Ident, Expr),
-
- // ident(arbitrary_expr,*)
- MethodCall(Ident, Vec<Expr>),
-}
-
-impl Parse for StructOptAttr {
- fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
- use self::StructOptAttr::*;
-
- let name: Ident = input.parse()?;
- let name_str = name.to_string();
-
- if input.peek(Token![=]) {
- // `name = value` attributes.
- let assign_token = input.parse::<Token![=]>()?; // skip '='
-
- if input.peek(LitStr) {
- let lit: LitStr = input.parse()?;
- let lit_str = lit.value();
-
- let check_empty_lit = |s| {
- if lit_str.is_empty() {
- abort!(
- lit.span(),
- "`#[structopt({} = \"\")]` is deprecated in structopt 0.3, \
- now it's default behavior",
- s
- );
- }
- };
-
- match &*name_str.to_string() {
- "rename_all" => Ok(RenameAll(name, lit)),
- "rename_all_env" => Ok(RenameAllEnv(name, lit)),
-
- "version" => {
- check_empty_lit("version");
- Ok(Version(name, lit))
- }
-
- "author" => {
- check_empty_lit("author");
- Ok(Author(name, Some(lit)))
- }
-
- "about" => {
- check_empty_lit("about");
- Ok(About(name, Some(lit)))
- }
-
- "skip" => {
- let expr = ExprLit {
- attrs: vec![],
- lit: Lit::Str(lit),
- };
- let expr = Expr::Lit(expr);
- Ok(Skip(name, Some(expr)))
- }
-
- _ => Ok(NameLitStr(name, lit)),
- }
- } else {
- match input.parse::<Expr>() {
- Ok(expr) => {
- if name_str == "skip" {
- Ok(Skip(name, Some(expr)))
- } else {
- Ok(NameExpr(name, expr))
- }
- }
-
- Err(_) => abort! {
- assign_token.span(),
- "expected `string literal` or `expression` after `=`"
- },
- }
- }
- } else if input.peek(syn::token::Paren) {
- // `name(...)` attributes.
- let nested;
- parenthesized!(nested in input);
-
- match name_str.as_ref() {
- "parse" => {
- let parser_specs: Punctuated<ParserSpec, Token![,]> =
- nested.parse_terminated(ParserSpec::parse)?;
-
- if parser_specs.len() == 1 {
- Ok(Parse(name, parser_specs[0].clone()))
- } else {
- abort!(name.span(), "parse must have exactly one argument")
- }
- }
-
- "raw" => match nested.parse::<LitBool>() {
- Ok(bool_token) => {
- let expr = ExprLit {
- attrs: vec![],
- lit: Lit::Bool(bool_token),
- };
- let expr = Expr::Lit(expr);
- Ok(MethodCall(name, vec![expr]))
- }
-
- Err(_) => {
- abort!(name.span(),
- "`#[structopt(raw(...))` attributes are removed in structopt 0.3, \
- they are replaced with raw methods";
- help = "if you meant to call `clap::Arg::raw()` method \
- you should use bool literal, like `raw(true)` or `raw(false)`";
- note = raw_method_suggestion(nested);
- );
- }
- },
-
- _ => {
- let method_args: Punctuated<_, Token![,]> =
- nested.parse_terminated(Expr::parse)?;
- Ok(MethodCall(name, Vec::from_iter(method_args)))
- }
- }
- } else {
- // Attributes represented with a sole identifier.
- match name_str.as_ref() {
- "long" => Ok(Long(name)),
- "short" => Ok(Short(name)),
- "env" => Ok(Env(name)),
- "flatten" => Ok(Flatten(name)),
- "subcommand" => Ok(Subcommand(name)),
- "no_version" => Ok(NoVersion(name)),
- "verbatim_doc_comment" => Ok(VerbatimDocComment(name)),
-
- "about" => (Ok(About(name, None))),
- "author" => (Ok(Author(name, None))),
-
- "skip" => Ok(Skip(name, None)),
-
- "version" => abort!(
- name.span(),
- "#[structopt(version)] is invalid attribute, \
- structopt 0.3 inherits version from Cargo.toml by default, \
- no attribute needed"
- ),
-
- _ => abort!(name.span(), "unexpected attribute: {}", name_str),
- }
- }
- }
-}
-
-#[derive(Clone)]
-pub struct ParserSpec {
- pub kind: Ident,
- pub eq_token: Option<Token![=]>,
- pub parse_func: Option<Expr>,
-}
-
-impl Parse for ParserSpec {
- fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
- let kind = input
- .parse()
- .map_err(|_| input.error("parser specification must start with identifier"))?;
- let eq_token = input.parse()?;
- let parse_func = match eq_token {
- None => None,
- Some(_) => Some(input.parse()?),
- };
- Ok(ParserSpec {
- kind,
- eq_token,
- parse_func,
- })
- }
-}
-
-struct CommaSeparated<T>(Punctuated<T, Token![,]>);
-
-impl<T: Parse> Parse for CommaSeparated<T> {
- fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
- let res = Punctuated::parse_separated_nonempty(input)?;
- Ok(CommaSeparated(res))
- }
-}
-
-fn raw_method_suggestion(ts: ParseBuffer) -> String {
- let do_parse = move || -> Result<(Ident, CommaSeparated<Expr>), syn::Error> {
- let name = ts.parse()?;
- let _eq: Token![=] = ts.parse()?;
- let val: LitStr = ts.parse()?;
- Ok((name, syn::parse_str(&val.value())?))
- };
-
- fn to_string<T: ToTokens>(val: &T) -> String {
- val.to_token_stream()
- .to_string()
- .replace(" ", "")
- .replace(",", ", ")
- }
-
- if let Ok((name, val)) = do_parse() {
- let exprs = val.0;
- let suggestion = if exprs.len() == 1 {
- let val = to_string(&exprs[0]);
- format!(" = {}", val)
- } else {
- let val = exprs
- .into_iter()
- .map(|expr| to_string(&expr))
- .collect::<Vec<_>>()
- .join(", ");
-
- format!("({})", val)
- };
-
- format!(
- "if you need to call `clap::Arg/App::{}` method you \
- can do it like this: #[structopt({}{})]",
- name, name, suggestion
- )
- } else {
- "if you need to call some method from `clap::Arg/App` \
- you should use raw method, see \
- https://docs.rs/structopt/0.3/structopt/#raw-methods"
- .into()
- }
-}
-
-pub fn parse_structopt_attributes(all_attrs: &[Attribute]) -> Vec<StructOptAttr> {
- all_attrs
- .iter()
- .filter(|attr| attr.path.is_ident("structopt"))
- .flat_map(|attr| {
- let attrs: StructOptAttributes = parse2(attr.tokens.clone())
- .map_err(|e| match &*e.to_string() {
- // this error message is misleading and points to Span::call_site()
- // so we patch it with something meaningful
- "unexpected end of input, expected parentheses" => {
- let span = attr.path.span();
- let patch_msg = "expected parentheses after `structopt`";
- syn::Error::new(span, patch_msg)
- }
- _ => e,
- })
- .unwrap_or_abort();
- attrs.attrs
- })
- .collect()
-}
diff --git a/structopt/structopt-derive/src/spanned.rs b/structopt/structopt-derive/src/spanned.rs
deleted file mode 100644
index 2dd595b..0000000
--- a/structopt/structopt-derive/src/spanned.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::ToTokens;
-use std::ops::{Deref, DerefMut};
-use syn::LitStr;
-
-/// An entity with a span attached.
-#[derive(Debug, Clone)]
-pub struct Sp<T> {
- span: Span,
- val: T,
-}
-
-impl<T> Sp<T> {
- pub fn new(val: T, span: Span) -> Self {
- Sp { val, span }
- }
-
- pub fn call_site(val: T) -> Self {
- Sp {
- val,
- span: Span::call_site(),
- }
- }
-
- pub fn span(&self) -> Span {
- self.span
- }
-}
-
-impl<T: ToString> Sp<T> {
- pub fn as_ident(&self) -> Ident {
- Ident::new(&self.to_string(), self.span)
- }
-
- pub fn as_lit(&self) -> LitStr {
- LitStr::new(&self.to_string(), self.span)
- }
-}
-
-impl<T> Deref for Sp<T> {
- type Target = T;
-
- fn deref(&self) -> &T {
- &self.val
- }
-}
-
-impl<T> DerefMut for Sp<T> {
- fn deref_mut(&mut self) -> &mut T {
- &mut self.val
- }
-}
-
-impl From<Ident> for Sp<String> {
- fn from(ident: Ident) -> Self {
- Sp {
- val: ident.to_string(),
- span: ident.span(),
- }
- }
-}
-
-impl From<LitStr> for Sp<String> {
- fn from(lit: LitStr) -> Self {
- Sp {
- val: lit.value(),
- span: lit.span(),
- }
- }
-}
-
-impl<'a> From<Sp<&'a str>> for Sp<String> {
- fn from(sp: Sp<&'a str>) -> Self {
- Sp::new(sp.val.into(), sp.span)
- }
-}
-
-impl<U, T: PartialEq<U>> PartialEq<U> for Sp<T> {
- fn eq(&self, other: &U) -> bool {
- self.val == *other
- }
-}
-
-impl<T: AsRef<str>> AsRef<str> for Sp<T> {
- fn as_ref(&self) -> &str {
- self.val.as_ref()
- }
-}
-
-impl<T: ToTokens> ToTokens for Sp<T> {
- fn to_tokens(&self, stream: &mut TokenStream) {
- // this is the simplest way out of correct ones to change span on
- // arbitrary token tree I can come up with
- let tt = self.val.to_token_stream().into_iter().map(|mut tt| {
- tt.set_span(self.span.clone());
- tt
- });
-
- stream.extend(tt);
- }
-}
diff --git a/structopt/structopt-derive/src/ty.rs b/structopt/structopt-derive/src/ty.rs
deleted file mode 100644
index 06eb3ec..0000000
--- a/structopt/structopt-derive/src/ty.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-//! Special types handling
-
-use crate::spanned::Sp;
-
-use syn::{
- spanned::Spanned, GenericArgument, Path, PathArguments, PathArguments::AngleBracketed,
- PathSegment, Type, TypePath,
-};
-
-#[derive(Copy, Clone, PartialEq, Debug)]
-pub enum Ty {
- Bool,
- Vec,
- Option,
- OptionOption,
- OptionVec,
- Other,
-}
-
-impl Ty {
- pub fn from_syn_ty(ty: &syn::Type) -> Sp<Self> {
- use Ty::*;
- let t = |kind| Sp::new(kind, ty.span());
-
- if is_simple_ty(ty, "bool") {
- t(Bool)
- } else if is_generic_ty(ty, "Vec") {
- t(Vec)
- } else if let Some(subty) = subty_if_name(ty, "Option") {
- if is_generic_ty(subty, "Option") {
- t(OptionOption)
- } else if is_generic_ty(subty, "Vec") {
- t(OptionVec)
- } else {
- t(Option)
- }
- } else {
- t(Other)
- }
- }
-}
-
-pub fn sub_type(ty: &syn::Type) -> Option<&syn::Type> {
- subty_if(ty, |_| true)
-}
-
-fn only_last_segment(ty: &syn::Type) -> Option<&PathSegment> {
- match ty {
- Type::Path(TypePath {
- qself: None,
- path:
- Path {
- leading_colon: None,
- segments,
- },
- }) => only_one(segments.iter()),
-
- _ => None,
- }
-}
-
-fn subty_if<F>(ty: &syn::Type, f: F) -> Option<&syn::Type>
-where
- F: FnOnce(&PathSegment) -> bool,
-{
- only_last_segment(ty)
- .filter(|segment| f(segment))
- .and_then(|segment| {
- if let AngleBracketed(args) = &segment.arguments {
- only_one(args.args.iter()).and_then(|genneric| {
- if let GenericArgument::Type(ty) = genneric {
- Some(ty)
- } else {
- None
- }
- })
- } else {
- None
- }
- })
-}
-
-fn subty_if_name<'a>(ty: &'a syn::Type, name: &str) -> Option<&'a syn::Type> {
- subty_if(ty, |seg| seg.ident == name)
-}
-
-fn is_simple_ty(ty: &syn::Type, name: &str) -> bool {
- only_last_segment(ty)
- .map(|segment| {
- if let PathArguments::None = segment.arguments {
- segment.ident == name
- } else {
- false
- }
- })
- .unwrap_or(false)
-}
-
-fn is_generic_ty(ty: &syn::Type, name: &str) -> bool {
- subty_if_name(ty, name).is_some()
-}
-
-fn only_one<I, T>(mut iter: I) -> Option<T>
-where
- I: Iterator<Item = T>,
-{
- iter.next().filter(|_| iter.next().is_none())
-}
diff --git a/structopt/tests/argument_naming.rs b/structopt/tests/argument_naming.rs
deleted file mode 100644
index e7fe3d5..0000000
--- a/structopt/tests/argument_naming.rs
+++ /dev/null
@@ -1,311 +0,0 @@
-use structopt::StructOpt;
-
-#[test]
-fn test_single_word_enum_variant_is_default_renamed_into_kebab_case() {
- #[derive(StructOpt, Debug, PartialEq)]
- enum Opt {
- Command { foo: u32 },
- }
-
- assert_eq!(
- Opt::Command { foo: 0 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "command", "0"]))
- );
-}
-
-#[test]
-fn test_multi_word_enum_variant_is_renamed() {
- #[derive(StructOpt, Debug, PartialEq)]
- enum Opt {
- FirstCommand { foo: u32 },
- }
-
- assert_eq!(
- Opt::FirstCommand { foo: 0 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "first-command", "0"]))
- );
-}
-
-#[test]
-fn test_standalone_long_generates_kebab_case() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[allow(non_snake_case)]
- struct Opt {
- #[structopt(long)]
- FOO_OPTION: bool,
- }
-
- assert_eq!(
- Opt { FOO_OPTION: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--foo-option"]))
- );
-}
-
-#[test]
-fn test_custom_long_overwrites_default_name() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(long = "foo")]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--foo"]))
- );
-}
-
-#[test]
-fn test_standalone_long_uses_previous_defined_custom_name() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(name = "foo", long)]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--foo"]))
- );
-}
-
-#[test]
-fn test_standalone_long_ignores_afterwards_defined_custom_name() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(long, name = "foo")]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--foo-option"]))
- );
-}
-
-#[test]
-fn test_standalone_short_generates_kebab_case() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[allow(non_snake_case)]
- struct Opt {
- #[structopt(short)]
- FOO_OPTION: bool,
- }
-
- assert_eq!(
- Opt { FOO_OPTION: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-f"]))
- );
-}
-
-#[test]
-fn test_custom_short_overwrites_default_name() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(short = "o")]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-o"]))
- );
-}
-
-#[test]
-fn test_standalone_short_uses_previous_defined_custom_name() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(name = "option", short)]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-o"]))
- );
-}
-
-#[test]
-fn test_standalone_short_ignores_afterwards_defined_custom_name() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(short, name = "option")]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-f"]))
- );
-}
-
-#[test]
-fn test_standalone_long_uses_previous_defined_casing() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(rename_all = "screaming_snake", long)]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--FOO_OPTION"]))
- );
-}
-
-#[test]
-fn test_standalone_short_uses_previous_defined_casing() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(rename_all = "screaming_snake", short)]
- foo_option: bool,
- }
-
- assert_eq!(
- Opt { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-F"]))
- );
-}
-
-#[test]
-fn test_standalone_long_works_with_verbatim_casing() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[allow(non_snake_case)]
- struct Opt {
- #[structopt(rename_all = "verbatim", long)]
- _fOO_oPtiON: bool,
- }
-
- assert_eq!(
- Opt { _fOO_oPtiON: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--_fOO_oPtiON"]))
- );
-}
-
-#[test]
-fn test_standalone_short_works_with_verbatim_casing() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(rename_all = "verbatim", short)]
- _foo: bool,
- }
-
- assert_eq!(
- Opt { _foo: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-_"]))
- );
-}
-
-#[test]
-fn test_rename_all_is_propagated_from_struct_to_fields() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[structopt(rename_all = "screaming_snake")]
- struct Opt {
- #[structopt(long)]
- foo: bool,
- }
-
- assert_eq!(
- Opt { foo: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--FOO"]))
- );
-}
-
-#[test]
-fn test_rename_all_is_not_propagated_from_struct_into_flattened() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[structopt(rename_all = "screaming_snake")]
- struct Opt {
- #[structopt(flatten)]
- foo: Foo,
- }
-
- #[derive(StructOpt, Debug, PartialEq)]
- struct Foo {
- #[structopt(long)]
- foo: bool,
- }
-
- assert_eq!(
- Opt {
- foo: Foo { foo: true }
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--foo"]))
- );
-}
-
-#[test]
-fn test_rename_all_is_not_propagated_from_struct_into_subcommand() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[structopt(rename_all = "screaming_snake")]
- struct Opt {
- #[structopt(subcommand)]
- foo: Foo,
- }
-
- #[derive(StructOpt, Debug, PartialEq)]
- enum Foo {
- Command {
- #[structopt(long)]
- foo: bool,
- },
- }
-
- assert_eq!(
- Opt {
- foo: Foo::Command { foo: true }
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "command", "--foo"]))
- );
-}
-
-#[test]
-fn test_rename_all_is_propagated_from_enum_to_variants_and_their_fields() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[structopt(rename_all = "screaming_snake")]
- enum Opt {
- FirstVariant,
- SecondVariant {
- #[structopt(long)]
- foo: bool,
- },
- }
-
- assert_eq!(
- Opt::FirstVariant,
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "FIRST_VARIANT"]))
- );
-
- assert_eq!(
- Opt::SecondVariant { foo: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "SECOND_VARIANT", "--FOO"]))
- );
-}
-
-#[test]
-fn test_rename_all_is_propagation_can_be_overridden() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[structopt(rename_all = "screaming_snake")]
- enum Opt {
- #[structopt(rename_all = "kebab_case")]
- FirstVariant {
- #[structopt(long)]
- foo_option: bool,
- },
- SecondVariant {
- #[structopt(rename_all = "kebab_case", long)]
- foo_option: bool,
- },
- }
-
- assert_eq!(
- Opt::FirstVariant { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "first-variant", "--foo-option"]))
- );
-
- assert_eq!(
- Opt::SecondVariant { foo_option: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "SECOND_VARIANT", "--foo-option"]))
- );
-}
diff --git a/structopt/tests/arguments.rs b/structopt/tests/arguments.rs
deleted file mode 100644
index 96a0938..0000000
--- a/structopt/tests/arguments.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::clap;
-use structopt::StructOpt;
-
-#[test]
-fn required_argument() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- arg: i32,
- }
- assert_eq!(Opt { arg: 42 }, Opt::from_iter(&["test", "42"]));
- assert!(Opt::clap().get_matches_from_safe(&["test"]).is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "42", "24"])
- .is_err());
-}
-
-#[test]
-fn optional_argument() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- arg: Option<i32>,
- }
- assert_eq!(Opt { arg: Some(42) }, Opt::from_iter(&["test", "42"]));
- assert_eq!(Opt { arg: None }, Opt::from_iter(&["test"]));
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "42", "24"])
- .is_err());
-}
-
-#[test]
-fn argument_with_default() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(default_value = "42")]
- arg: i32,
- }
- assert_eq!(Opt { arg: 24 }, Opt::from_iter(&["test", "24"]));
- assert_eq!(Opt { arg: 42 }, Opt::from_iter(&["test"]));
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "42", "24"])
- .is_err());
-}
-
-#[test]
-fn arguments() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- arg: Vec<i32>,
- }
- assert_eq!(Opt { arg: vec![24] }, Opt::from_iter(&["test", "24"]));
- assert_eq!(Opt { arg: vec![] }, Opt::from_iter(&["test"]));
- assert_eq!(
- Opt { arg: vec![24, 42] },
- Opt::from_iter(&["test", "24", "42"])
- );
-}
-
-#[test]
-fn arguments_safe() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- arg: Vec<i32>,
- }
- assert_eq!(
- Opt { arg: vec![24] },
- Opt::from_iter_safe(&["test", "24"]).unwrap()
- );
- assert_eq!(Opt { arg: vec![] }, Opt::from_iter_safe(&["test"]).unwrap());
- assert_eq!(
- Opt { arg: vec![24, 42] },
- Opt::from_iter_safe(&["test", "24", "42"]).unwrap()
- );
-
- assert_eq!(
- clap::ErrorKind::ValueValidation,
- Opt::from_iter_safe(&["test", "NOPE"]).err().unwrap().kind
- );
-}
diff --git a/structopt/tests/author_version_about.rs b/structopt/tests/author_version_about.rs
deleted file mode 100644
index 0c4a4fb..0000000
--- a/structopt/tests/author_version_about.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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.
-
-mod utils;
-
-use structopt::StructOpt;
-use utils::*;
-
-#[test]
-fn no_author_version_about() {
- #[derive(StructOpt, PartialEq, Debug)]
- #[structopt(name = "foo", no_version)]
- struct Opt {}
-
- let output = get_long_help::<Opt>();
- assert!(output.starts_with("foo \n\nUSAGE:"));
-}
-
-#[test]
-fn use_env() {
- #[derive(StructOpt, PartialEq, Debug)]
- #[structopt(author, about)]
- struct Opt {}
-
- let output = get_long_help::<Opt>();
- assert!(output.starts_with("structopt 0."));
- assert!(output.contains("Guillaume Pinot <texitoi@texitoi.eu>, others"));
- assert!(output.contains("Parse command line argument by defining a struct."));
-}
-
-#[test]
-fn explicit_version_not_str() {
- const VERSION: &str = "custom version";
-
- #[derive(StructOpt)]
- #[structopt(version = VERSION)]
- pub struct Opt {}
-
- let output = get_long_help::<Opt>();
- assert!(output.contains("custom version"));
-}
diff --git a/structopt/tests/custom-string-parsers.rs b/structopt/tests/custom-string-parsers.rs
deleted file mode 100644
index 89070ed..0000000
--- a/structopt/tests/custom-string-parsers.rs
+++ /dev/null
@@ -1,306 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-use std::ffi::{CString, OsStr, OsString};
-use std::num::ParseIntError;
-use std::path::PathBuf;
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct PathOpt {
- #[structopt(short, long, parse(from_os_str))]
- path: PathBuf,
-
- #[structopt(short, default_value = "../", parse(from_os_str))]
- default_path: PathBuf,
-
- #[structopt(short, parse(from_os_str))]
- vector_path: Vec<PathBuf>,
-
- #[structopt(short, parse(from_os_str))]
- option_path_1: Option<PathBuf>,
-
- #[structopt(short = "q", parse(from_os_str))]
- option_path_2: Option<PathBuf>,
-}
-
-#[test]
-fn test_path_opt_simple() {
- assert_eq!(
- PathOpt {
- path: PathBuf::from("/usr/bin"),
- default_path: PathBuf::from("../"),
- vector_path: vec![
- PathBuf::from("/a/b/c"),
- PathBuf::from("/d/e/f"),
- PathBuf::from("/g/h/i"),
- ],
- option_path_1: None,
- option_path_2: Some(PathBuf::from("j.zip")),
- },
- PathOpt::from_clap(&PathOpt::clap().get_matches_from(&[
- "test", "-p", "/usr/bin", "-v", "/a/b/c", "-v", "/d/e/f", "-v", "/g/h/i", "-q",
- "j.zip",
- ]))
- );
-}
-
-fn parse_hex(input: &str) -> Result<u64, ParseIntError> {
- u64::from_str_radix(input, 16)
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct HexOpt {
- #[structopt(short, parse(try_from_str = parse_hex))]
- number: u64,
-}
-
-#[test]
-#[allow(clippy::unreadable_literal)]
-fn test_parse_hex() {
- assert_eq!(
- HexOpt { number: 5 },
- HexOpt::from_clap(&HexOpt::clap().get_matches_from(&["test", "-n", "5"]))
- );
- assert_eq!(
- HexOpt { number: 0xabcdef },
- HexOpt::from_clap(&HexOpt::clap().get_matches_from(&["test", "-n", "abcdef"]))
- );
-
- let err = HexOpt::clap()
- .get_matches_from_safe(&["test", "-n", "gg"])
- .unwrap_err();
- assert!(err.message.contains("invalid digit found in string"), err);
-}
-
-fn custom_parser_1(_: &str) -> &'static str {
- "A"
-}
-fn custom_parser_2(_: &str) -> Result<&'static str, u32> {
- Ok("B")
-}
-fn custom_parser_3(_: &OsStr) -> &'static str {
- "C"
-}
-fn custom_parser_4(_: &OsStr) -> Result<&'static str, OsString> {
- Ok("D")
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct NoOpOpt {
- #[structopt(short, parse(from_str = custom_parser_1))]
- a: &'static str,
- #[structopt(short, parse(try_from_str = custom_parser_2))]
- b: &'static str,
- #[structopt(short, parse(from_os_str = custom_parser_3))]
- c: &'static str,
- #[structopt(short, parse(try_from_os_str = custom_parser_4))]
- d: &'static str,
-}
-
-#[test]
-fn test_every_custom_parser() {
- assert_eq!(
- NoOpOpt {
- a: "A",
- b: "B",
- c: "C",
- d: "D"
- },
- NoOpOpt::from_clap(
- &NoOpOpt::clap().get_matches_from(&["test", "-a=?", "-b=?", "-c=?", "-d=?"])
- )
- );
-}
-
-// Note: can't use `Vec<u8>` directly, as structopt would instead look for
-// conversion function from `&str` to `u8`.
-type Bytes = Vec<u8>;
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct DefaultedOpt {
- #[structopt(short, parse(from_str))]
- bytes: Bytes,
-
- #[structopt(short, parse(try_from_str))]
- integer: u64,
-
- #[structopt(short, parse(from_os_str))]
- path: PathBuf,
-}
-
-#[test]
-fn test_parser_with_default_value() {
- assert_eq!(
- DefaultedOpt {
- bytes: b"E\xc2\xb2=p\xc2\xb2c\xc2\xb2+m\xc2\xb2c\xe2\x81\xb4".to_vec(),
- integer: 9000,
- path: PathBuf::from("src/lib.rs"),
- },
- DefaultedOpt::from_clap(&DefaultedOpt::clap().get_matches_from(&[
- "test",
- "-b",
- "E²=p²c²+m²c⁴",
- "-i",
- "9000",
- "-p",
- "src/lib.rs",
- ]))
- );
-}
-
-#[derive(PartialEq, Debug)]
-struct Foo(u8);
-
-fn foo(value: u64) -> Foo {
- Foo(value as u8)
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct Occurrences {
- #[structopt(short, long, parse(from_occurrences))]
- signed: i32,
-
- #[structopt(short, parse(from_occurrences))]
- little_signed: i8,
-
- #[structopt(short, parse(from_occurrences))]
- unsigned: usize,
-
- #[structopt(short = "r", parse(from_occurrences))]
- little_unsigned: u8,
-
- #[structopt(short, long, parse(from_occurrences = foo))]
- custom: Foo,
-}
-
-#[test]
-fn test_parser_occurrences() {
- assert_eq!(
- Occurrences {
- signed: 3,
- little_signed: 1,
- unsigned: 0,
- little_unsigned: 4,
- custom: Foo(5),
- },
- Occurrences::from_clap(&Occurrences::clap().get_matches_from(&[
- "test", "-s", "--signed", "--signed", "-l", "-rrrr", "-cccc", "--custom",
- ]))
- );
-}
-
-#[test]
-fn test_custom_bool() {
- fn parse_bool(s: &str) -> Result<bool, String> {
- match s {
- "true" => Ok(true),
- "false" => Ok(false),
- _ => Err(format!("invalid bool {}", s)),
- }
- }
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, parse(try_from_str = parse_bool))]
- debug: bool,
- #[structopt(
- short,
- default_value = "false",
- parse(try_from_str = parse_bool)
- )]
- verbose: bool,
- #[structopt(short, parse(try_from_str = parse_bool))]
- tribool: Option<bool>,
- #[structopt(short, parse(try_from_str = parse_bool))]
- bitset: Vec<bool>,
- }
-
- assert!(Opt::clap().get_matches_from_safe(&["test"]).is_err());
- assert!(Opt::clap().get_matches_from_safe(&["test", "-d"]).is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-dfoo"])
- .is_err());
- assert_eq!(
- Opt {
- debug: false,
- verbose: false,
- tribool: None,
- bitset: vec![],
- },
- Opt::from_iter(&["test", "-dfalse"])
- );
- assert_eq!(
- Opt {
- debug: true,
- verbose: false,
- tribool: None,
- bitset: vec![],
- },
- Opt::from_iter(&["test", "-dtrue"])
- );
- assert_eq!(
- Opt {
- debug: true,
- verbose: false,
- tribool: None,
- bitset: vec![],
- },
- Opt::from_iter(&["test", "-dtrue", "-vfalse"])
- );
- assert_eq!(
- Opt {
- debug: true,
- verbose: true,
- tribool: None,
- bitset: vec![],
- },
- Opt::from_iter(&["test", "-dtrue", "-vtrue"])
- );
- assert_eq!(
- Opt {
- debug: true,
- verbose: false,
- tribool: Some(false),
- bitset: vec![],
- },
- Opt::from_iter(&["test", "-dtrue", "-tfalse"])
- );
- assert_eq!(
- Opt {
- debug: true,
- verbose: false,
- tribool: Some(true),
- bitset: vec![],
- },
- Opt::from_iter(&["test", "-dtrue", "-ttrue"])
- );
- assert_eq!(
- Opt {
- debug: true,
- verbose: false,
- tribool: None,
- bitset: vec![false, true, false, false],
- },
- Opt::from_iter(&["test", "-dtrue", "-bfalse", "-btrue", "-bfalse", "-bfalse"])
- );
-}
-
-#[test]
-fn test_cstring() {
- #[derive(StructOpt)]
- struct Opt {
- #[structopt(parse(try_from_str = CString::new))]
- c_string: CString,
- }
- assert!(Opt::clap().get_matches_from_safe(&["test"]).is_err());
- assert_eq!(Opt::from_iter(&["test", "bla"]).c_string.to_bytes(), b"bla");
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "bla\0bla"])
- .is_err());
-}
diff --git a/structopt/tests/deny-warnings.rs b/structopt/tests/deny-warnings.rs
deleted file mode 100644
index 721204a..0000000
--- a/structopt/tests/deny-warnings.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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.
-
-#![deny(warnings)]
-
-use structopt::StructOpt;
-
-fn try_str(s: &str) -> Result<String, std::convert::Infallible> {
- Ok(s.into())
-}
-
-#[test]
-fn warning_never_struct() {
- #[derive(Debug, PartialEq, StructOpt)]
- struct Opt {
- #[structopt(parse(try_from_str = try_str))]
- s: String,
- }
- assert_eq!(
- Opt {
- s: "foo".to_string()
- },
- Opt::from_iter(&["test", "foo"])
- );
-}
-
-#[test]
-fn warning_never_enum() {
- #[derive(Debug, PartialEq, StructOpt)]
- enum Opt {
- Foo {
- #[structopt(parse(try_from_str = try_str))]
- s: String,
- },
- }
- assert_eq!(
- Opt::Foo {
- s: "foo".to_string()
- },
- Opt::from_iter(&["test", "foo", "foo"])
- );
-}
diff --git a/structopt/tests/doc-comments-help.rs b/structopt/tests/doc-comments-help.rs
deleted file mode 100644
index 27649b8..0000000
--- a/structopt/tests/doc-comments-help.rs
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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.
-
-mod utils;
-
-use structopt::StructOpt;
-use utils::*;
-
-#[test]
-fn doc_comments() {
- /// Lorem ipsum
- #[derive(StructOpt, PartialEq, Debug)]
- struct LoremIpsum {
- /// Fooify a bar
- /// and a baz
- #[structopt(short, long)]
- foo: bool,
- }
-
- let help = get_long_help::<LoremIpsum>();
- assert!(help.contains("Lorem ipsum"));
- assert!(help.contains("Fooify a bar and a baz"));
-}
-
-#[test]
-fn help_is_better_than_comments() {
- /// Lorem ipsum
- #[derive(StructOpt, PartialEq, Debug)]
- #[structopt(name = "lorem-ipsum", about = "Dolor sit amet")]
- struct LoremIpsum {
- /// Fooify a bar
- #[structopt(short, long, help = "DO NOT PASS A BAR UNDER ANY CIRCUMSTANCES")]
- foo: bool,
- }
-
- let help = get_long_help::<LoremIpsum>();
- assert!(help.contains("Dolor sit amet"));
- assert!(!help.contains("Lorem ipsum"));
- assert!(help.contains("DO NOT PASS A BAR"));
-}
-
-#[test]
-fn empty_line_in_doc_comment_is_double_linefeed() {
- /// Foo.
- ///
- /// Bar
- #[derive(StructOpt, PartialEq, Debug)]
- #[structopt(name = "lorem-ipsum", no_version)]
- struct LoremIpsum {}
-
- let help = get_long_help::<LoremIpsum>();
- assert!(help.starts_with("lorem-ipsum \nFoo.\n\nBar\n\nUSAGE:"));
-}
-
-#[test]
-fn field_long_doc_comment_both_help_long_help() {
- /// Lorem ipsumclap
- #[derive(StructOpt, PartialEq, Debug)]
- #[structopt(name = "lorem-ipsum", about = "Dolor sit amet")]
- struct LoremIpsum {
- /// Dot is removed from multiline comments.
- ///
- /// Long help
- #[structopt(long)]
- foo: bool,
-
- /// Dot is removed from one short comment.
- #[structopt(long)]
- bar: bool,
- }
-
- let short_help = get_help::<LoremIpsum>();
- let long_help = get_long_help::<LoremIpsum>();
-
- assert!(short_help.contains("Dot is removed from one short comment"));
- assert!(!short_help.contains("Dot is removed from one short comment."));
- assert!(short_help.contains("Dot is removed from multiline comments"));
- assert!(!short_help.contains("Dot is removed from multiline comments."));
- assert!(long_help.contains("Long help"));
- assert!(!short_help.contains("Long help"));
-}
-
-#[test]
-fn top_long_doc_comment_both_help_long_help() {
- /// Lorem ipsumclap
- #[derive(StructOpt, Debug)]
- #[structopt(name = "lorem-ipsum", about = "Dolor sit amet")]
- struct LoremIpsum {
- #[structopt(subcommand)]
- foo: SubCommand,
- }
-
- #[derive(StructOpt, Debug)]
- pub enum SubCommand {
- /// DO NOT PASS A BAR UNDER ANY CIRCUMSTANCES
- ///
- /// Or something else
- Foo {
- #[structopt(help = "foo")]
- bars: Vec<String>,
- },
- }
-
- let short_help = get_help::<LoremIpsum>();
- let long_help = get_subcommand_long_help::<LoremIpsum>("foo");
-
- assert!(!short_help.contains("Or something else"));
- assert!(long_help.contains("DO NOT PASS A BAR UNDER ANY CIRCUMSTANCES"));
- assert!(long_help.contains("Or something else"));
-}
-
-#[test]
-fn verbatim_doc_comment() {
- /// DANCE!
- ///
- /// ()
- /// |
- /// ( () )
- /// ) ________ // )
- /// () |\ \ //
- /// ( \\__ \ ______\//
- /// \__) | |
- /// | | |
- /// \ | |
- /// \|_______|
- /// // \\
- /// (( ||
- /// \\ ||
- /// ( () ||
- /// ( () ) )
- #[derive(StructOpt, Debug)]
- #[structopt(verbatim_doc_comment)]
- struct SeeFigure1 {
- #[structopt(long)]
- foo: bool,
- }
-
- let help = get_long_help::<SeeFigure1>();
- let sample = r#"
- ()
- |
- ( () )
- ) ________ // )
- () |\ \ //
-( \\__ \ ______\//
- \__) | |
- | | |
- \ | |
- \|_______|
- // \\
- (( ||
- \\ ||
- ( () ||
- ( () ) )"#;
-
- assert!(help.contains(sample))
-}
diff --git a/structopt/tests/explicit_name_no_renaming.rs b/structopt/tests/explicit_name_no_renaming.rs
deleted file mode 100644
index eff7a86..0000000
--- a/structopt/tests/explicit_name_no_renaming.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-mod utils;
-
-use structopt::StructOpt;
-use utils::*;
-
-#[test]
-fn explicit_short_long_no_rename() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short = ".", long = ".foo")]
- foo: Vec<String>,
- }
-
- assert_eq!(
- Opt {
- foo: vec!["short".into(), "long".into()]
- },
- Opt::from_iter(&["test", "-.", "short", "--.foo", "long"])
- );
-}
-
-#[test]
-fn explicit_name_no_rename() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(name = ".options")]
- foo: Vec<String>,
- }
-
- let help = get_long_help::<Opt>();
- assert!(help.contains("[.options]..."))
-}
diff --git a/structopt/tests/flags.rs b/structopt/tests/flags.rs
deleted file mode 100644
index 39a5dc3..0000000
--- a/structopt/tests/flags.rs
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[test]
-fn unique_flag() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, long)]
- alice: bool,
- }
-
- assert_eq!(
- Opt { alice: false },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert_eq!(
- Opt { alice: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]))
- );
- assert_eq!(
- Opt { alice: true },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--alice"]))
- );
- assert!(Opt::clap().get_matches_from_safe(&["test", "-i"]).is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a", "foo"])
- .is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a", "-a"])
- .is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a", "--alice"])
- .is_err());
-}
-
-#[test]
-fn multiple_flag() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, long, parse(from_occurrences))]
- alice: u64,
- #[structopt(short, long, parse(from_occurrences))]
- bob: u8,
- }
-
- assert_eq!(
- Opt { alice: 0, bob: 0 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert_eq!(
- Opt { alice: 1, bob: 0 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]))
- );
- assert_eq!(
- Opt { alice: 2, bob: 0 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "-a"]))
- );
- assert_eq!(
- Opt { alice: 2, bob: 2 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "--alice", "-bb"]))
- );
- assert_eq!(
- Opt { alice: 3, bob: 1 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-aaa", "--bob"]))
- );
- assert!(Opt::clap().get_matches_from_safe(&["test", "-i"]).is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a", "foo"])
- .is_err());
-}
-
-fn parse_from_flag(b: bool) -> std::sync::atomic::AtomicBool {
- std::sync::atomic::AtomicBool::new(b)
-}
-
-#[test]
-fn non_bool_flags() {
- #[derive(StructOpt, Debug)]
- struct Opt {
- #[structopt(short, long, parse(from_flag = parse_from_flag))]
- alice: std::sync::atomic::AtomicBool,
- #[structopt(short, long, parse(from_flag))]
- bob: std::sync::atomic::AtomicBool,
- }
-
- let falsey = Opt::from_clap(&Opt::clap().get_matches_from(&["test"]));
- assert!(!falsey.alice.load(std::sync::atomic::Ordering::Relaxed));
- assert!(!falsey.bob.load(std::sync::atomic::Ordering::Relaxed));
-
- let alice = Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]));
- assert!(alice.alice.load(std::sync::atomic::Ordering::Relaxed));
- assert!(!alice.bob.load(std::sync::atomic::Ordering::Relaxed));
-
- let bob = Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-b"]));
- assert!(!bob.alice.load(std::sync::atomic::Ordering::Relaxed));
- assert!(bob.bob.load(std::sync::atomic::Ordering::Relaxed));
-
- let both = Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-b", "-a"]));
- assert!(both.alice.load(std::sync::atomic::Ordering::Relaxed));
- assert!(both.bob.load(std::sync::atomic::Ordering::Relaxed));
-}
-
-#[test]
-fn combined_flags() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, long)]
- alice: bool,
- #[structopt(short, long, parse(from_occurrences))]
- bob: u64,
- }
-
- assert_eq!(
- Opt {
- alice: false,
- bob: 0
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert_eq!(
- Opt {
- alice: true,
- bob: 0
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]))
- );
- assert_eq!(
- Opt {
- alice: true,
- bob: 0
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]))
- );
- assert_eq!(
- Opt {
- alice: false,
- bob: 1
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-b"]))
- );
- assert_eq!(
- Opt {
- alice: true,
- bob: 1
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--alice", "--bob"]))
- );
- assert_eq!(
- Opt {
- alice: true,
- bob: 4
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-bb", "-a", "-bb"]))
- );
-}
diff --git a/structopt/tests/flatten.rs b/structopt/tests/flatten.rs
deleted file mode 100644
index 4983d86..0000000
--- a/structopt/tests/flatten.rs
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[test]
-fn flatten() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Common {
- arg: i32,
- }
-
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(flatten)]
- common: Common,
- }
- assert_eq!(
- Opt {
- common: Common { arg: 42 }
- },
- Opt::from_iter(&["test", "42"])
- );
- assert!(Opt::clap().get_matches_from_safe(&["test"]).is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "42", "24"])
- .is_err());
-}
-
-#[test]
-#[should_panic]
-fn flatten_twice() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Common {
- arg: i32,
- }
-
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(flatten)]
- c1: Common,
- // Defines "arg" twice, so this should not work.
- #[structopt(flatten)]
- c2: Common,
- }
- Opt::from_iter(&["test", "42", "43"]);
-}
-
-#[test]
-fn flatten_in_subcommand() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Common {
- arg: i32,
- }
-
- #[derive(StructOpt, PartialEq, Debug)]
- struct Add {
- #[structopt(short)]
- interactive: bool,
- #[structopt(flatten)]
- common: Common,
- }
-
- #[derive(StructOpt, PartialEq, Debug)]
- enum Opt {
- Fetch {
- #[structopt(short)]
- all: bool,
- #[structopt(flatten)]
- common: Common,
- },
-
- Add(Add),
- }
-
- assert_eq!(
- Opt::Fetch {
- all: false,
- common: Common { arg: 42 }
- },
- Opt::from_iter(&["test", "fetch", "42"])
- );
- assert_eq!(
- Opt::Add(Add {
- interactive: true,
- common: Common { arg: 43 }
- }),
- Opt::from_iter(&["test", "add", "-i", "43"])
- );
-}
diff --git a/structopt/tests/issues.rs b/structopt/tests/issues.rs
deleted file mode 100644
index 4d250ae..0000000
--- a/structopt/tests/issues.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-// https://github.com/TeXitoi/structopt/issues/151
-// https://github.com/TeXitoi/structopt/issues/289
-
-#[test]
-fn issue_151() {
- use structopt::{clap::ArgGroup, StructOpt};
-
- #[derive(StructOpt, Debug)]
- #[structopt(group = ArgGroup::with_name("verb").required(true).multiple(true))]
- struct Opt {
- #[structopt(long, group = "verb")]
- foo: bool,
- #[structopt(long, group = "verb")]
- bar: bool,
- }
-
- #[derive(Debug, StructOpt)]
- struct Cli {
- #[structopt(flatten)]
- a: Opt,
- }
-
- assert!(Cli::clap().get_matches_from_safe(&["test"]).is_err());
- assert!(Cli::clap()
- .get_matches_from_safe(&["test", "--foo"])
- .is_ok());
- assert!(Cli::clap()
- .get_matches_from_safe(&["test", "--bar"])
- .is_ok());
- assert!(Cli::clap()
- .get_matches_from_safe(&["test", "--zebra"])
- .is_err());
- assert!(Cli::clap()
- .get_matches_from_safe(&["test", "--foo", "--bar"])
- .is_ok());
-}
-
-#[test]
-fn issue_289() {
- use structopt::{clap::AppSettings, StructOpt};
-
- #[derive(StructOpt)]
- #[structopt(setting = AppSettings::InferSubcommands)]
- enum Args {
- SomeCommand(SubSubCommand),
- AnotherCommand,
- }
-
- #[derive(StructOpt)]
- #[structopt(setting = AppSettings::InferSubcommands)]
- enum SubSubCommand {
- TestCommand,
- }
-
- assert!(Args::clap()
- .get_matches_from_safe(&["test", "some-command", "test-command"])
- .is_ok());
- assert!(Args::clap()
- .get_matches_from_safe(&["test", "some", "test-command"])
- .is_ok());
- assert!(Args::clap()
- .get_matches_from_safe(&["test", "some-command", "test"])
- .is_ok());
- assert!(Args::clap()
- .get_matches_from_safe(&["test", "some", "test"])
- .is_ok());
-}
diff --git a/structopt/tests/macro-errors.rs b/structopt/tests/macro-errors.rs
deleted file mode 100644
index ae4f5a2..0000000
--- a/structopt/tests/macro-errors.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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
-
-#[rustversion::attr(any(not(stable), before(1.39)), ignore)]
-#[test]
-fn ui() {
- let t = trybuild::TestCases::new();
- t.compile_fail("tests/ui/*.rs");
-}
diff --git a/structopt/tests/nested-subcommands.rs b/structopt/tests/nested-subcommands.rs
deleted file mode 100644
index 1fbd166..0000000
--- a/structopt/tests/nested-subcommands.rs
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct Opt {
- #[structopt(short, long)]
- force: bool,
- #[structopt(short, long, parse(from_occurrences))]
- verbose: u64,
- #[structopt(subcommand)]
- cmd: Sub,
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Sub {
- Fetch {},
- Add {},
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct Opt2 {
- #[structopt(short, long)]
- force: bool,
- #[structopt(short, long, parse(from_occurrences))]
- verbose: u64,
- #[structopt(subcommand)]
- cmd: Option<Sub>,
-}
-
-#[test]
-fn test_no_cmd() {
- let result = Opt::clap().get_matches_from_safe(&["test"]);
- assert!(result.is_err());
-
- assert_eq!(
- Opt2 {
- force: false,
- verbose: 0,
- cmd: None
- },
- Opt2::from_clap(&Opt2::clap().get_matches_from(&["test"]))
- );
-}
-
-#[test]
-fn test_fetch() {
- assert_eq!(
- Opt {
- force: false,
- verbose: 3,
- cmd: Sub::Fetch {}
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-vvv", "fetch"]))
- );
- assert_eq!(
- Opt {
- force: true,
- verbose: 0,
- cmd: Sub::Fetch {}
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--force", "fetch"]))
- );
-}
-
-#[test]
-fn test_add() {
- assert_eq!(
- Opt {
- force: false,
- verbose: 0,
- cmd: Sub::Add {}
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "add"]))
- );
- assert_eq!(
- Opt {
- force: false,
- verbose: 2,
- cmd: Sub::Add {}
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-vv", "add"]))
- );
-}
-
-#[test]
-fn test_badinput() {
- let result = Opt::clap().get_matches_from_safe(&["test", "badcmd"]);
- assert!(result.is_err());
- let result = Opt::clap().get_matches_from_safe(&["test", "add", "--verbose"]);
- assert!(result.is_err());
- let result = Opt::clap().get_matches_from_safe(&["test", "--badopt", "add"]);
- assert!(result.is_err());
- let result = Opt::clap().get_matches_from_safe(&["test", "add", "--badopt"]);
- assert!(result.is_err());
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct Opt3 {
- #[structopt(short, long)]
- all: bool,
- #[structopt(subcommand)]
- cmd: Sub2,
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Sub2 {
- Foo {
- file: String,
- #[structopt(subcommand)]
- cmd: Sub3,
- },
- Bar {},
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Sub3 {
- Baz {},
- Quux {},
-}
-
-#[test]
-fn test_subsubcommand() {
- assert_eq!(
- Opt3 {
- all: true,
- cmd: Sub2::Foo {
- file: "lib.rs".to_string(),
- cmd: Sub3::Quux {}
- }
- },
- Opt3::from_clap(
- &Opt3::clap().get_matches_from(&["test", "--all", "foo", "lib.rs", "quux"])
- )
- );
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum SubSubCmdWithOption {
- Remote {
- #[structopt(subcommand)]
- cmd: Option<Remote>,
- },
- Stash {
- #[structopt(subcommand)]
- cmd: Stash,
- },
-}
-#[derive(StructOpt, PartialEq, Debug)]
-enum Remote {
- Add { name: String, url: String },
- Remove { name: String },
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Stash {
- Save,
- Pop,
-}
-
-#[test]
-fn sub_sub_cmd_with_option() {
- fn make(args: &[&str]) -> Option<SubSubCmdWithOption> {
- SubSubCmdWithOption::clap()
- .get_matches_from_safe(args)
- .ok()
- .map(|m| SubSubCmdWithOption::from_clap(&m))
- }
- assert_eq!(
- Some(SubSubCmdWithOption::Remote { cmd: None }),
- make(&["", "remote"])
- );
- assert_eq!(
- Some(SubSubCmdWithOption::Remote {
- cmd: Some(Remote::Add {
- name: "origin".into(),
- url: "http".into()
- })
- }),
- make(&["", "remote", "add", "origin", "http"])
- );
- assert_eq!(
- Some(SubSubCmdWithOption::Stash { cmd: Stash::Save }),
- make(&["", "stash", "save"])
- );
- assert_eq!(None, make(&["", "stash"]));
-}
diff --git a/structopt/tests/non_literal_attributes.rs b/structopt/tests/non_literal_attributes.rs
deleted file mode 100644
index 75b6b71..0000000
--- a/structopt/tests/non_literal_attributes.rs
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::clap::AppSettings;
-use structopt::StructOpt;
-
-pub const DISPLAY_ORDER: usize = 2;
-
-// Check if the global settings compile
-#[derive(StructOpt, Debug, PartialEq, Eq)]
-#[structopt(global_settings = &[AppSettings::ColoredHelp])]
-struct Opt {
- #[structopt(
- long = "x",
- display_order = DISPLAY_ORDER,
- next_line_help = true,
- default_value = "0",
- require_equals = true
- )]
- x: i32,
-
- #[structopt(short = "l", long = "level", aliases = &["set-level", "lvl"])]
- level: String,
-
- #[structopt(long("values"))]
- values: Vec<i32>,
-
- #[structopt(name = "FILE", requires_if("FILE", "values"))]
- files: Vec<String>,
-}
-
-#[test]
-fn test_slice() {
- assert_eq!(
- Opt {
- x: 0,
- level: "1".to_string(),
- files: Vec::new(),
- values: vec![],
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-l", "1"]))
- );
- assert_eq!(
- Opt {
- x: 0,
- level: "1".to_string(),
- files: Vec::new(),
- values: vec![],
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--level", "1"]))
- );
- assert_eq!(
- Opt {
- x: 0,
- level: "1".to_string(),
- files: Vec::new(),
- values: vec![],
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--set-level", "1"]))
- );
- assert_eq!(
- Opt {
- x: 0,
- level: "1".to_string(),
- files: Vec::new(),
- values: vec![],
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--lvl", "1"]))
- );
-}
-
-#[test]
-fn test_multi_args() {
- assert_eq!(
- Opt {
- x: 0,
- level: "1".to_string(),
- files: vec!["file".to_string()],
- values: vec![],
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-l", "1", "file"]))
- );
- assert_eq!(
- Opt {
- x: 0,
- level: "1".to_string(),
- files: vec!["FILE".to_string()],
- values: vec![1],
- },
- Opt::from_clap(
- &Opt::clap().get_matches_from(&["test", "-l", "1", "--values", "1", "--", "FILE"]),
- )
- );
-}
-
-#[test]
-fn test_multi_args_fail() {
- let result = Opt::clap().get_matches_from_safe(&["test", "-l", "1", "--", "FILE"]);
- assert!(result.is_err());
-}
-
-#[test]
-fn test_bool() {
- assert_eq!(
- Opt {
- x: 1,
- level: "1".to_string(),
- files: vec![],
- values: vec![],
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-l", "1", "--x=1"]))
- );
- let result = Opt::clap().get_matches_from_safe(&["test", "-l", "1", "--x", "1"]);
- assert!(result.is_err());
-}
-
-fn parse_hex(input: &str) -> Result<u64, std::num::ParseIntError> {
- u64::from_str_radix(input, 16)
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-struct HexOpt {
- #[structopt(short = "n", parse(try_from_str = parse_hex))]
- number: u64,
-}
-
-#[test]
-fn test_parse_hex_function_path() {
- assert_eq!(
- HexOpt { number: 5 },
- HexOpt::from_clap(&HexOpt::clap().get_matches_from(&["test", "-n", "5"]))
- );
- assert_eq!(
- HexOpt { number: 0xabcdef },
- HexOpt::from_clap(&HexOpt::clap().get_matches_from(&["test", "-n", "abcdef"]))
- );
-
- let err = HexOpt::clap()
- .get_matches_from_safe(&["test", "-n", "gg"])
- .unwrap_err();
- assert!(err.message.contains("invalid digit found in string"), err);
-}
diff --git a/structopt/tests/options.rs b/structopt/tests/options.rs
deleted file mode 100644
index 803abb4..0000000
--- a/structopt/tests/options.rs
+++ /dev/null
@@ -1,336 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[test]
-fn required_option() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, long)]
- arg: i32,
- }
- assert_eq!(
- Opt { arg: 42 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a42"]))
- );
- assert_eq!(
- Opt { arg: 42 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "42"]))
- );
- assert_eq!(
- Opt { arg: 42 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--arg", "42"]))
- );
- assert!(Opt::clap().get_matches_from_safe(&["test"]).is_err());
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a42", "-a24"])
- .is_err());
-}
-
-#[test]
-fn optional_option() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short)]
- arg: Option<i32>,
- }
- assert_eq!(
- Opt { arg: Some(42) },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a42"]))
- );
- assert_eq!(
- Opt { arg: None },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a42", "-a24"])
- .is_err());
-}
-
-#[test]
-fn option_with_default() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, default_value = "42")]
- arg: i32,
- }
- assert_eq!(
- Opt { arg: 24 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a24"]))
- );
- assert_eq!(
- Opt { arg: 42 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a42", "-a24"])
- .is_err());
-}
-
-#[test]
-fn option_with_raw_default() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, default_value = "42")]
- arg: i32,
- }
- assert_eq!(
- Opt { arg: 24 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a24"]))
- );
- assert_eq!(
- Opt { arg: 42 },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a42", "-a24"])
- .is_err());
-}
-
-#[test]
-fn options() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, long)]
- arg: Vec<i32>,
- }
- assert_eq!(
- Opt { arg: vec![24] },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a24"]))
- );
- assert_eq!(
- Opt { arg: vec![] },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert_eq!(
- Opt { arg: vec![24, 42] },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a24", "--arg", "42"]))
- );
-}
-
-#[test]
-fn empy_default_value() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short, default_value = "")]
- arg: String,
- }
- assert_eq!(Opt { arg: "".into() }, Opt::from_iter(&["test"]));
- assert_eq!(
- Opt { arg: "foo".into() },
- Opt::from_iter(&["test", "-afoo"])
- );
-}
-
-#[test]
-fn option_from_str() {
- #[derive(Debug, PartialEq)]
- struct A;
-
- impl<'a> From<&'a str> for A {
- fn from(_: &str) -> A {
- A
- }
- }
-
- #[derive(Debug, StructOpt, PartialEq)]
- struct Opt {
- #[structopt(parse(from_str))]
- a: Option<A>,
- }
-
- assert_eq!(Opt { a: None }, Opt::from_iter(&["test"]));
- assert_eq!(Opt { a: Some(A) }, Opt::from_iter(&["test", "foo"]));
-}
-
-#[test]
-fn optional_argument_for_optional_option() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short)]
- #[allow(clippy::option_option)]
- arg: Option<Option<i32>>,
- }
- assert_eq!(
- Opt {
- arg: Some(Some(42))
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a42"]))
- );
- assert_eq!(
- Opt { arg: Some(None) },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]))
- );
- assert_eq!(
- Opt { arg: None },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
- assert!(Opt::clap()
- .get_matches_from_safe(&["test", "-a42", "-a24"])
- .is_err());
-}
-
-#[test]
-fn two_option_options() {
- #[derive(StructOpt, PartialEq, Debug)]
- #[allow(clippy::option_option)]
- struct Opt {
- #[structopt(short)]
- arg: Option<Option<i32>>,
-
- #[structopt(long)]
- field: Option<Option<String>>,
- }
- assert_eq!(
- Opt {
- arg: Some(Some(42)),
- field: Some(Some("f".into()))
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a42", "--field", "f"]))
- );
- assert_eq!(
- Opt {
- arg: Some(Some(42)),
- field: Some(None)
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a42", "--field"]))
- );
- assert_eq!(
- Opt {
- arg: Some(None),
- field: Some(None)
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "--field"]))
- );
- assert_eq!(
- Opt {
- arg: Some(None),
- field: Some(Some("f".into()))
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "--field", "f"]))
- );
- assert_eq!(
- Opt {
- arg: None,
- field: Some(None)
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--field"]))
- );
- assert_eq!(
- Opt {
- arg: None,
- field: None
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
-}
-
-#[test]
-fn optional_vec() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short)]
- arg: Option<Vec<i32>>,
- }
- assert_eq!(
- Opt { arg: Some(vec![1]) },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "1"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1, 2])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a1", "-a2"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1, 2])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a1", "-a2", "-a"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1, 2])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a1", "-a", "-a2"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1, 2])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "1", "2"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1, 2, 3])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "1", "2", "-a", "3"]))
- );
-
- assert_eq!(
- Opt { arg: Some(vec![]) },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a"]))
- );
-
- assert_eq!(
- Opt { arg: Some(vec![]) },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "-a"]))
- );
-
- assert_eq!(
- Opt { arg: None },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
-}
-
-#[test]
-fn two_optional_vecs() {
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(short)]
- arg: Option<Vec<i32>>,
-
- #[structopt(short)]
- b: Option<Vec<i32>>,
- }
-
- assert_eq!(
- Opt {
- arg: Some(vec![1]),
- b: Some(vec![])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "1", "-b"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1]),
- b: Some(vec![])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a", "-b", "-a1"]))
- );
-
- assert_eq!(
- Opt {
- arg: Some(vec![1, 2]),
- b: Some(vec![1, 2])
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a1", "-a2", "-b1", "-b2"]))
- );
-
- assert_eq!(
- Opt { arg: None, b: None },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test"]))
- );
-}
diff --git a/structopt/tests/privacy.rs b/structopt/tests/privacy.rs
deleted file mode 100644
index 730bbce..0000000
--- a/structopt/tests/privacy.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-mod options {
- use super::StructOpt;
-
- #[derive(Debug, StructOpt)]
- pub struct Options {
- #[structopt(subcommand)]
- pub subcommand: super::subcommands::SubCommand,
- }
-}
-
-mod subcommands {
- use super::StructOpt;
-
- #[derive(Debug, StructOpt)]
- pub enum SubCommand {
- /// foo
- Foo {
- /// foo
- bars: Vec<String>,
- },
- }
-}
diff --git a/structopt/tests/raw_bool_literal.rs b/structopt/tests/raw_bool_literal.rs
deleted file mode 100644
index faf8628..0000000
--- a/structopt/tests/raw_bool_literal.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[test]
-fn raw_bool_literal() {
- #[derive(StructOpt, Debug, PartialEq)]
- #[structopt(no_version, name = "raw_bool")]
- struct Opt {
- #[structopt(raw(false))]
- a: String,
- #[structopt(raw(true))]
- b: String,
- }
-
- assert_eq!(
- Opt {
- a: "one".into(),
- b: "--help".into()
- },
- Opt::from_iter(&["test", "one", "--", "--help"])
- );
-}
diff --git a/structopt/tests/raw_idents.rs b/structopt/tests/raw_idents.rs
deleted file mode 100644
index c00ff66..0000000
--- a/structopt/tests/raw_idents.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-use structopt::StructOpt;
-
-#[test]
-fn raw_idents() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(short, long)]
- r#type: Vec<String>,
- }
-
- assert_eq!(
- Opt {
- r#type: vec!["long".into(), "short".into()]
- },
- Opt::from_iter(&["test", "--type", "long", "-t", "short"])
- );
-}
diff --git a/structopt/tests/rename_all_env.rs b/structopt/tests/rename_all_env.rs
deleted file mode 100644
index 1979e84..0000000
--- a/structopt/tests/rename_all_env.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-mod utils;
-
-use structopt::StructOpt;
-use utils::*;
-
-#[test]
-fn it_works() {
- #[derive(Debug, PartialEq, StructOpt)]
- #[structopt(rename_all_env = "kebab")]
- struct BehaviorModel {
- #[structopt(env)]
- be_nice: String,
- }
-
- let help = get_help::<BehaviorModel>();
- assert!(help.contains("[env: be-nice=]"));
-}
-
-#[test]
-fn default_is_screaming() {
- #[derive(Debug, PartialEq, StructOpt)]
- struct BehaviorModel {
- #[structopt(env)]
- be_nice: String,
- }
-
- let help = get_help::<BehaviorModel>();
- assert!(help.contains("[env: BE_NICE=]"));
-}
-
-#[test]
-fn overridable() {
- #[derive(Debug, PartialEq, StructOpt)]
- #[structopt(rename_all_env = "kebab")]
- struct BehaviorModel {
- #[structopt(env)]
- be_nice: String,
-
- #[structopt(rename_all_env = "pascal", env)]
- be_agressive: String,
- }
-
- let help = get_help::<BehaviorModel>();
- assert!(help.contains("[env: be-nice=]"));
- assert!(help.contains("[env: BeAgressive=]"));
-}
diff --git a/structopt/tests/skip.rs b/structopt/tests/skip.rs
deleted file mode 100644
index 47682d8..0000000
--- a/structopt/tests/skip.rs
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[test]
-fn skip_1() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(short)]
- x: u32,
- #[structopt(skip)]
- s: u32,
- }
-
- assert!(Opt::from_iter_safe(&["test", "-x", "10", "20"]).is_err());
- assert_eq!(
- Opt::from_iter(&["test", "-x", "10"]),
- Opt {
- x: 10,
- s: 0, // default
- }
- );
-}
-
-#[test]
-fn skip_2() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(short)]
- x: u32,
- #[structopt(skip)]
- ss: String,
- #[structopt(skip)]
- sn: u8,
- y: u32,
- #[structopt(skip)]
- sz: u16,
- t: u32,
- }
-
- assert_eq!(
- Opt::from_iter(&["test", "-x", "10", "20", "30"]),
- Opt {
- x: 10,
- ss: String::from(""),
- sn: 0,
- y: 20,
- sz: 0,
- t: 30,
- }
- );
-}
-
-#[test]
-fn skip_enum() {
- #[derive(Debug, PartialEq)]
- #[allow(unused)]
- enum Kind {
- A,
- B,
- }
-
- impl Default for Kind {
- fn default() -> Self {
- return Kind::B;
- }
- }
-
- #[derive(StructOpt, Debug, PartialEq)]
- pub struct Opt {
- #[structopt(long, short)]
- number: u32,
- #[structopt(skip)]
- k: Kind,
- #[structopt(skip)]
- v: Vec<u32>,
- }
-
- assert_eq!(
- Opt::from_iter(&["test", "-n", "10"]),
- Opt {
- number: 10,
- k: Kind::B,
- v: vec![],
- }
- );
-}
-
-#[test]
-fn skip_help_doc_comments() {
- #[derive(StructOpt, Debug, PartialEq)]
- pub struct Opt {
- #[structopt(skip, help = "internal_stuff")]
- a: u32,
-
- #[structopt(skip, long_help = "internal_stuff\ndo not touch")]
- b: u32,
-
- /// Not meant to be used by clap.
- ///
- /// I want a default here.
- #[structopt(skip)]
- c: u32,
-
- #[structopt(short, parse(try_from_str))]
- n: u32,
- }
-
- assert_eq!(
- Opt::from_iter(&["test", "-n", "10"]),
- Opt {
- n: 10,
- a: 0,
- b: 0,
- c: 0,
- }
- );
-}
-
-#[test]
-fn skip_val() {
- #[derive(StructOpt, Debug, PartialEq)]
- pub struct Opt {
- #[structopt(long, short)]
- number: u32,
-
- #[structopt(skip = "key")]
- k: String,
-
- #[structopt(skip = vec![1, 2, 3])]
- v: Vec<u32>,
- }
-
- assert_eq!(
- Opt::from_iter(&["test", "-n", "10"]),
- Opt {
- number: 10,
- k: "key".into(),
- v: vec![1, 2, 3]
- }
- );
-}
diff --git a/structopt/tests/special_types.rs b/structopt/tests/special_types.rs
deleted file mode 100644
index ffed5e2..0000000
--- a/structopt/tests/special_types.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-//! Checks that types like `::std::option::Option` are not special
-
-use structopt::StructOpt;
-
-#[rustversion::since(1.37)]
-#[test]
-fn special_types_bool() {
- mod inner {
- #[allow(non_camel_case_types)]
- #[derive(PartialEq, Debug)]
- pub struct bool(pub String);
-
- impl std::str::FromStr for self::bool {
- type Err = String;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- Ok(self::bool(s.into()))
- }
- }
- };
-
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- arg: inner::bool,
- }
-
- assert_eq!(
- Opt {
- arg: inner::bool("success".into())
- },
- Opt::from_iter(&["test", "success"])
- );
-}
-
-#[test]
-fn special_types_option() {
- fn parser(s: &str) -> Option<String> {
- Some(s.to_string())
- }
-
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(parse(from_str = parser))]
- arg: ::std::option::Option<String>,
- }
-
- assert_eq!(
- Opt {
- arg: Some("success".into())
- },
- Opt::from_iter(&["test", "success"])
- );
-}
-
-#[test]
-fn special_types_vec() {
- fn parser(s: &str) -> Vec<String> {
- vec![s.to_string()]
- }
-
- #[derive(StructOpt, PartialEq, Debug)]
- struct Opt {
- #[structopt(parse(from_str = parser))]
- arg: ::std::vec::Vec<String>,
- }
-
- assert_eq!(
- Opt {
- arg: vec!["success".into()]
- },
- Opt::from_iter(&["test", "success"])
- );
-}
diff --git a/structopt/tests/subcommands.rs b/structopt/tests/subcommands.rs
deleted file mode 100644
index 170c0da..0000000
--- a/structopt/tests/subcommands.rs
+++ /dev/null
@@ -1,213 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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.
-
-mod utils;
-
-use structopt::StructOpt;
-use utils::*;
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Opt {
- /// Fetch stuff from GitHub
- Fetch {
- #[structopt(long)]
- all: bool,
- #[structopt(short, long)]
- /// Overwrite local branches.
- force: bool,
- repo: String,
- },
-
- Add {
- #[structopt(short, long)]
- interactive: bool,
- #[structopt(short, long)]
- verbose: bool,
- },
-}
-
-#[test]
-fn test_fetch() {
- assert_eq!(
- Opt::Fetch {
- all: true,
- force: false,
- repo: "origin".to_string()
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "fetch", "--all", "origin"]))
- );
- assert_eq!(
- Opt::Fetch {
- all: false,
- force: true,
- repo: "origin".to_string()
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "fetch", "-f", "origin"]))
- );
-}
-
-#[test]
-fn test_add() {
- assert_eq!(
- Opt::Add {
- interactive: false,
- verbose: false
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "add"]))
- );
- assert_eq!(
- Opt::Add {
- interactive: true,
- verbose: true
- },
- Opt::from_clap(&Opt::clap().get_matches_from(&["test", "add", "-i", "-v"]))
- );
-}
-
-#[test]
-fn test_no_parse() {
- let result = Opt::clap().get_matches_from_safe(&["test", "badcmd", "-i", "-v"]);
- assert!(result.is_err());
-
- let result = Opt::clap().get_matches_from_safe(&["test", "add", "--badoption"]);
- assert!(result.is_err());
-
- let result = Opt::clap().get_matches_from_safe(&["test"]);
- assert!(result.is_err());
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Opt2 {
- DoSomething { arg: String },
-}
-
-#[test]
-/// This test is specifically to make sure that hyphenated subcommands get
-/// processed correctly.
-fn test_hyphenated_subcommands() {
- assert_eq!(
- Opt2::DoSomething {
- arg: "blah".to_string()
- },
- Opt2::from_clap(&Opt2::clap().get_matches_from(&["test", "do-something", "blah"]))
- );
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-enum Opt3 {
- Add,
- Init,
- Fetch,
-}
-
-#[test]
-fn test_null_commands() {
- assert_eq!(
- Opt3::Add,
- Opt3::from_clap(&Opt3::clap().get_matches_from(&["test", "add"]))
- );
- assert_eq!(
- Opt3::Init,
- Opt3::from_clap(&Opt3::clap().get_matches_from(&["test", "init"]))
- );
- assert_eq!(
- Opt3::Fetch,
- Opt3::from_clap(&Opt3::clap().get_matches_from(&["test", "fetch"]))
- );
-}
-
-#[derive(StructOpt, PartialEq, Debug)]
-#[structopt(about = "Not shown")]
-struct Add {
- file: String,
-}
-/// Not shown
-#[derive(StructOpt, PartialEq, Debug)]
-struct Fetch {
- remote: String,
-}
-#[derive(StructOpt, PartialEq, Debug)]
-enum Opt4 {
- // Not shown
- /// Add a file
- Add(Add),
- Init,
- /// download history from remote
- Fetch(Fetch),
-}
-
-#[test]
-fn test_tuple_commands() {
- assert_eq!(
- Opt4::Add(Add {
- file: "f".to_string()
- }),
- Opt4::from_clap(&Opt4::clap().get_matches_from(&["test", "add", "f"]))
- );
- assert_eq!(
- Opt4::Init,
- Opt4::from_clap(&Opt4::clap().get_matches_from(&["test", "init"]))
- );
- assert_eq!(
- Opt4::Fetch(Fetch {
- remote: "origin".to_string()
- }),
- Opt4::from_clap(&Opt4::clap().get_matches_from(&["test", "fetch", "origin"]))
- );
-
- let output = get_long_help::<Opt4>();
-
- assert!(output.contains("download history from remote"));
- assert!(output.contains("Add a file"));
- assert!(!output.contains("Not shown"));
-}
-
-#[test]
-fn enum_in_enum_subsubcommand() {
- #[derive(StructOpt, Debug, PartialEq)]
- pub enum Opt {
- Daemon(DaemonCommand),
- }
-
- #[derive(StructOpt, Debug, PartialEq)]
- pub enum DaemonCommand {
- Start,
- Stop,
- }
-
- let result = Opt::clap().get_matches_from_safe(&["test"]);
- assert!(result.is_err());
-
- let result = Opt::clap().get_matches_from_safe(&["test", "daemon"]);
- assert!(result.is_err());
-
- let result = Opt::from_iter(&["test", "daemon", "start"]);
- assert_eq!(Opt::Daemon(DaemonCommand::Start), result);
-}
-
-#[test]
-fn flatten_enum() {
- #[derive(StructOpt, Debug, PartialEq)]
- struct Opt {
- #[structopt(flatten)]
- sub_cmd: SubCmd,
- }
- #[derive(StructOpt, Debug, PartialEq)]
- enum SubCmd {
- Foo,
- Bar,
- }
-
- assert!(Opt::from_iter_safe(&["test"]).is_err());
- assert_eq!(
- Opt::from_iter(&["test", "foo"]),
- Opt {
- sub_cmd: SubCmd::Foo
- }
- );
-}
diff --git a/structopt/tests/ui/bool_default_value.rs b/structopt/tests/ui/bool_default_value.rs
deleted file mode 100644
index 9bdb0c9..0000000
--- a/structopt/tests/ui/bool_default_value.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(short, default_value = true)]
- b: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/bool_default_value.stderr b/structopt/tests/ui/bool_default_value.stderr
deleted file mode 100644
index 1e26a2d..0000000
--- a/structopt/tests/ui/bool_default_value.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: default_value is meaningless for bool
- --> $DIR/bool_default_value.rs:14:24
- |
-14 | #[structopt(short, default_value = true)]
- | ^^^^^^^^^^^^^
diff --git a/structopt/tests/ui/bool_required.rs b/structopt/tests/ui/bool_required.rs
deleted file mode 100644
index 018223c..0000000
--- a/structopt/tests/ui/bool_required.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(short, required = true)]
- b: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/bool_required.stderr b/structopt/tests/ui/bool_required.stderr
deleted file mode 100644
index 0b80d48..0000000
--- a/structopt/tests/ui/bool_required.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: required is meaningless for bool
- --> $DIR/bool_required.rs:14:24
- |
-14 | #[structopt(short, required = true)]
- | ^^^^^^^^
diff --git a/structopt/tests/ui/flatten_and_doc.rs b/structopt/tests/ui/flatten_and_doc.rs
deleted file mode 100644
index 2dc154d..0000000
--- a/structopt/tests/ui/flatten_and_doc.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct DaemonOpts {
- #[structopt(short)]
- user: String,
- #[structopt(short)]
- group: String,
-}
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- /// Opts.
- #[structopt(flatten)]
- opts: DaemonOpts,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/flatten_and_doc.stderr b/structopt/tests/ui/flatten_and_doc.stderr
deleted file mode 100644
index 2724dbb..0000000
--- a/structopt/tests/ui/flatten_and_doc.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: methods and doc comments are not allowed for flattened entry
- --> $DIR/flatten_and_doc.rs:23:17
- |
-23 | #[structopt(flatten)]
- | ^^^^^^^
diff --git a/structopt/tests/ui/flatten_and_methods.rs b/structopt/tests/ui/flatten_and_methods.rs
deleted file mode 100644
index ff1af2e..0000000
--- a/structopt/tests/ui/flatten_and_methods.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct DaemonOpts {
- #[structopt(short)]
- user: String,
- #[structopt(short)]
- group: String,
-}
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(short, flatten)]
- opts: DaemonOpts,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/flatten_and_methods.stderr b/structopt/tests/ui/flatten_and_methods.stderr
deleted file mode 100644
index f058eb3..0000000
--- a/structopt/tests/ui/flatten_and_methods.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: methods and doc comments are not allowed for flattened entry
- --> $DIR/flatten_and_methods.rs:22:24
- |
-22 | #[structopt(short, flatten)]
- | ^^^^^^^
diff --git a/structopt/tests/ui/flatten_and_parse.rs b/structopt/tests/ui/flatten_and_parse.rs
deleted file mode 100644
index 3317272..0000000
--- a/structopt/tests/ui/flatten_and_parse.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct DaemonOpts {
- #[structopt(short)]
- user: String,
- #[structopt(short)]
- group: String,
-}
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(flatten, parse(from_occurrences))]
- opts: DaemonOpts,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/flatten_and_parse.stderr b/structopt/tests/ui/flatten_and_parse.stderr
deleted file mode 100644
index e217a84..0000000
--- a/structopt/tests/ui/flatten_and_parse.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: parse attribute is not allowed for flattened entry
- --> $DIR/flatten_and_parse.rs:22:26
- |
-22 | #[structopt(flatten, parse(from_occurrences))]
- | ^^^^^
diff --git a/structopt/tests/ui/non_existent_attr.rs b/structopt/tests/ui/non_existent_attr.rs
deleted file mode 100644
index 96daf45..0000000
--- a/structopt/tests/ui/non_existent_attr.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(short, non_existing_attribute = 1)]
- debug: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/non_existent_attr.stderr b/structopt/tests/ui/non_existent_attr.stderr
deleted file mode 100644
index 17bb87f..0000000
--- a/structopt/tests/ui/non_existent_attr.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error[E0599]: no method named `non_existing_attribute` found for type `clap::args::arg::Arg<'_, '_>` in the current scope
- --> $DIR/non_existent_attr.rs:14:24
- |
-14 | #[structopt(short, non_existing_attribute = 1)]
- | ^^^^^^^^^^^^^^^^^^^^^^ method not found in `clap::args::arg::Arg<'_, '_>`
diff --git a/structopt/tests/ui/opt_opt_nonpositional.rs b/structopt/tests/ui/opt_opt_nonpositional.rs
deleted file mode 100644
index 2a08105..0000000
--- a/structopt/tests/ui/opt_opt_nonpositional.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- n: Option<Option<u32>>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/opt_opt_nonpositional.stderr b/structopt/tests/ui/opt_opt_nonpositional.stderr
deleted file mode 100644
index 586bf7a..0000000
--- a/structopt/tests/ui/opt_opt_nonpositional.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Option<Option<T>> type is meaningless for positional argument
- --> $DIR/opt_opt_nonpositional.rs:14:8
- |
-14 | n: Option<Option<u32>>,
- | ^^^^^^
diff --git a/structopt/tests/ui/opt_vec_nonpositional.rs b/structopt/tests/ui/opt_vec_nonpositional.rs
deleted file mode 100644
index 0f6f078..0000000
--- a/structopt/tests/ui/opt_vec_nonpositional.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- n: Option<Vec<u32>>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/opt_vec_nonpositional.stderr b/structopt/tests/ui/opt_vec_nonpositional.stderr
deleted file mode 100644
index 6f01de5..0000000
--- a/structopt/tests/ui/opt_vec_nonpositional.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Option<Vec<T>> type is meaningless for positional argument
- --> $DIR/opt_vec_nonpositional.rs:14:8
- |
-14 | n: Option<Vec<u32>>,
- | ^^^^^^
diff --git a/structopt/tests/ui/option_default_value.rs b/structopt/tests/ui/option_default_value.rs
deleted file mode 100644
index a86bc0e..0000000
--- a/structopt/tests/ui/option_default_value.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(short, default_value = 1)]
- n: Option<u32>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/option_default_value.stderr b/structopt/tests/ui/option_default_value.stderr
deleted file mode 100644
index 2215497..0000000
--- a/structopt/tests/ui/option_default_value.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: default_value is meaningless for Option
- --> $DIR/option_default_value.rs:14:24
- |
-14 | #[structopt(short, default_value = 1)]
- | ^^^^^^^^^^^^^
diff --git a/structopt/tests/ui/option_required.rs b/structopt/tests/ui/option_required.rs
deleted file mode 100644
index d91afbf..0000000
--- a/structopt/tests/ui/option_required.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(short, required = true)]
- n: Option<u32>,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/option_required.stderr b/structopt/tests/ui/option_required.stderr
deleted file mode 100644
index 0230d57..0000000
--- a/structopt/tests/ui/option_required.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: required is meaningless for Option
- --> $DIR/option_required.rs:14:24
- |
-14 | #[structopt(short, required = true)]
- | ^^^^^^^^
diff --git a/structopt/tests/ui/parse_empty_try_from_os.rs b/structopt/tests/ui/parse_empty_try_from_os.rs
deleted file mode 100644
index acfef0b..0000000
--- a/structopt/tests/ui/parse_empty_try_from_os.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(parse(try_from_os_str))]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/parse_empty_try_from_os.stderr b/structopt/tests/ui/parse_empty_try_from_os.stderr
deleted file mode 100644
index 3dc9f24..0000000
--- a/structopt/tests/ui/parse_empty_try_from_os.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: you must set parser for `try_from_os_str` explicitly
- --> $DIR/parse_empty_try_from_os.rs:14:23
- |
-14 | #[structopt(parse(try_from_os_str))]
- | ^^^^^^^^^^^^^^^
diff --git a/structopt/tests/ui/parse_function_is_not_path.rs b/structopt/tests/ui/parse_function_is_not_path.rs
deleted file mode 100644
index 5eebc57..0000000
--- a/structopt/tests/ui/parse_function_is_not_path.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(parse(from_str = "2"))]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/parse_function_is_not_path.stderr b/structopt/tests/ui/parse_function_is_not_path.stderr
deleted file mode 100644
index 7cf7444..0000000
--- a/structopt/tests/ui/parse_function_is_not_path.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: `parse` argument must be a function path
- --> $DIR/parse_function_is_not_path.rs:14:34
- |
-14 | #[structopt(parse(from_str = "2"))]
- | ^^^
diff --git a/structopt/tests/ui/parse_literal_spec.rs b/structopt/tests/ui/parse_literal_spec.rs
deleted file mode 100644
index b6f125a..0000000
--- a/structopt/tests/ui/parse_literal_spec.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(parse("from_str"))]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/parse_literal_spec.stderr b/structopt/tests/ui/parse_literal_spec.stderr
deleted file mode 100644
index 6e99e8b..0000000
--- a/structopt/tests/ui/parse_literal_spec.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: parser specification must start with identifier
- --> $DIR/parse_literal_spec.rs:14:23
- |
-14 | #[structopt(parse("from_str"))]
- | ^^^^^^^^^^
diff --git a/structopt/tests/ui/parse_not_zero_args.rs b/structopt/tests/ui/parse_not_zero_args.rs
deleted file mode 100644
index 8729178..0000000
--- a/structopt/tests/ui/parse_not_zero_args.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt(parse(from_str, from_str))]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/parse_not_zero_args.stderr b/structopt/tests/ui/parse_not_zero_args.stderr
deleted file mode 100644
index 11abe06..0000000
--- a/structopt/tests/ui/parse_not_zero_args.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: parse must have exactly one argument
- --> $DIR/parse_not_zero_args.rs:14:17
- |
-14 | #[structopt(parse(from_str, from_str))]
- | ^^^^^
diff --git a/structopt/tests/ui/positional_bool.rs b/structopt/tests/ui/positional_bool.rs
deleted file mode 100644
index 4dbf538..0000000
--- a/structopt/tests/ui/positional_bool.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct Opt {
- verbose: bool,
-}
-
-fn main() {
- Opt::from_args();
-} \ No newline at end of file
diff --git a/structopt/tests/ui/positional_bool.stderr b/structopt/tests/ui/positional_bool.stderr
deleted file mode 100644
index c3ed1ad..0000000
--- a/structopt/tests/ui/positional_bool.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: `bool` cannot be used as positional parameter with default parser
-
- = help: if you want to create a flag add `long` or `short`
- = help: If you really want a boolean parameter add an explicit parser, for example `parse(try_from_str)`
- = note: see also https://github.com/TeXitoi/structopt/tree/master/examples/true_or_false.rs
-
- --> $DIR/positional_bool.rs:5:14
- |
-5 | verbose: bool,
- | ^^^^
diff --git a/structopt/tests/ui/raw.rs b/structopt/tests/ui/raw.rs
deleted file mode 100644
index b94f783..0000000
--- a/structopt/tests/ui/raw.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct Opt {
- #[structopt(raw(case_insensitive = "true"))]
- s: String,
-}
-
-#[derive(StructOpt, Debug)]
-struct Opt2 {
- #[structopt(raw(requires_if = r#""one", "two""#))]
- s: String,
-}
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/raw.stderr b/structopt/tests/ui/raw.stderr
deleted file mode 100644
index 93b5e38..0000000
--- a/structopt/tests/ui/raw.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error: `#[structopt(raw(...))` attributes are removed in structopt 0.3, they are replaced with raw methods
-
- = help: if you meant to call `clap::Arg::raw()` method you should use bool literal, like `raw(true)` or `raw(false)`
- = note: if you need to call `clap::Arg/App::case_insensitive` method you can do it like this: #[structopt(case_insensitive = true)]
-
- --> $DIR/raw.rs:13:17
- |
-13 | #[structopt(raw(case_insensitive = "true"))]
- | ^^^
-
-error: `#[structopt(raw(...))` attributes are removed in structopt 0.3, they are replaced with raw methods
-
- = help: if you meant to call `clap::Arg::raw()` method you should use bool literal, like `raw(true)` or `raw(false)`
- = note: if you need to call `clap::Arg/App::requires_if` method you can do it like this: #[structopt(requires_if("one", "two"))]
-
- --> $DIR/raw.rs:19:17
- |
-19 | #[structopt(raw(requires_if = r#""one", "two""#))]
- | ^^^
diff --git a/structopt/tests/ui/rename_all_wrong_casing.rs b/structopt/tests/ui/rename_all_wrong_casing.rs
deleted file mode 100644
index 4dabe14..0000000
--- a/structopt/tests/ui/rename_all_wrong_casing.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic", rename_all = "fail")]
-struct Opt {
- #[structopt(short)]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/rename_all_wrong_casing.stderr b/structopt/tests/ui/rename_all_wrong_casing.stderr
deleted file mode 100644
index 2a72080..0000000
--- a/structopt/tests/ui/rename_all_wrong_casing.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: unsupported casing: `fail`
- --> $DIR/rename_all_wrong_casing.rs:12:42
- |
-12 | #[structopt(name = "basic", rename_all = "fail")]
- | ^^^^^^
diff --git a/structopt/tests/ui/skip_flatten.rs b/structopt/tests/ui/skip_flatten.rs
deleted file mode 100644
index 8668ec2..0000000
--- a/structopt/tests/ui/skip_flatten.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(skip, flatten)]
- cmd: Command,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-impl Default for Command {
- fn default() -> Self {
- Command::Pound { acorns: 0 }
- }
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/skip_flatten.stderr b/structopt/tests/ui/skip_flatten.stderr
deleted file mode 100644
index 76477a3..0000000
--- a/structopt/tests/ui/skip_flatten.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: subcommand, flatten and skip cannot be used together
- --> $DIR/skip_flatten.rs:17:23
- |
-17 | #[structopt(skip, flatten)]
- | ^^^^^^^
diff --git a/structopt/tests/ui/skip_subcommand.rs b/structopt/tests/ui/skip_subcommand.rs
deleted file mode 100644
index 5d21426..0000000
--- a/structopt/tests/ui/skip_subcommand.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(subcommand, skip)]
- cmd: Command,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-impl Default for Command {
- fn default() -> Self {
- Command::Pound { acorns: 0 }
- }
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/skip_subcommand.stderr b/structopt/tests/ui/skip_subcommand.stderr
deleted file mode 100644
index aba2d69..0000000
--- a/structopt/tests/ui/skip_subcommand.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: subcommand, flatten and skip cannot be used together
- --> $DIR/skip_subcommand.rs:17:29
- |
-17 | #[structopt(subcommand, skip)]
- | ^^^^
diff --git a/structopt/tests/ui/skip_with_other_options.rs b/structopt/tests/ui/skip_with_other_options.rs
deleted file mode 100644
index 73c5342..0000000
--- a/structopt/tests/ui/skip_with_other_options.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "test")]
-pub struct Opt {
- #[structopt(long)]
- a: u32,
- #[structopt(skip, long)]
- b: u32,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/skip_with_other_options.stderr b/structopt/tests/ui/skip_with_other_options.stderr
deleted file mode 100644
index 3345f92..0000000
--- a/structopt/tests/ui/skip_with_other_options.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: methods are not allowed for skipped fields
- --> $DIR/skip_with_other_options.rs:8:17
- |
-8 | #[structopt(skip, long)]
- | ^^^^
diff --git a/structopt/tests/ui/skip_without_default.rs b/structopt/tests/ui/skip_without_default.rs
deleted file mode 100644
index bc47511..0000000
--- a/structopt/tests/ui/skip_without_default.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(Debug)]
-enum Kind {
- A,
- B,
-}
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "test")]
-pub struct Opt {
- #[structopt(short)]
- number: u32,
- #[structopt(skip)]
- k: Kind,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/skip_without_default.stderr b/structopt/tests/ui/skip_without_default.stderr
deleted file mode 100644
index 330898f..0000000
--- a/structopt/tests/ui/skip_without_default.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0277]: the trait bound `Kind: std::default::Default` is not satisfied
- --> $DIR/skip_without_default.rs:22:17
- |
-22 | #[structopt(skip)]
- | ^^^^ the trait `std::default::Default` is not implemented for `Kind`
- |
- = note: required by `std::default::Default::default`
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/structopt/tests/ui/struct_flatten.rs b/structopt/tests/ui/struct_flatten.rs
deleted file mode 100644
index 2b205f1..0000000
--- a/structopt/tests/ui/struct_flatten.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic", flatten)]
-struct Opt {
- #[structopt(short)]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/struct_flatten.stderr b/structopt/tests/ui/struct_flatten.stderr
deleted file mode 100644
index 7f0fc6d..0000000
--- a/structopt/tests/ui/struct_flatten.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: flatten is only allowed on fields
- --> $DIR/struct_flatten.rs:12:29
- |
-12 | #[structopt(name = "basic", flatten)]
- | ^^^^^^^
diff --git a/structopt/tests/ui/struct_parse.rs b/structopt/tests/ui/struct_parse.rs
deleted file mode 100644
index e428b23..0000000
--- a/structopt/tests/ui/struct_parse.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic", parse(from_str))]
-struct Opt {
- #[structopt(short)]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/struct_parse.stderr b/structopt/tests/ui/struct_parse.stderr
deleted file mode 100644
index 5518214..0000000
--- a/structopt/tests/ui/struct_parse.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: `parse` attribute is only allowed on fields
- --> $DIR/struct_parse.rs:12:29
- |
-12 | #[structopt(name = "basic", parse(from_str))]
- | ^^^^^
diff --git a/structopt/tests/ui/struct_subcommand.rs b/structopt/tests/ui/struct_subcommand.rs
deleted file mode 100644
index ac0b145..0000000
--- a/structopt/tests/ui/struct_subcommand.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic", subcommand)]
-struct Opt {
- #[structopt(short)]
- s: String,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/struct_subcommand.stderr b/structopt/tests/ui/struct_subcommand.stderr
deleted file mode 100644
index 438f6f8..0000000
--- a/structopt/tests/ui/struct_subcommand.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: subcommand is only allowed on fields
- --> $DIR/struct_subcommand.rs:12:29
- |
-12 | #[structopt(name = "basic", subcommand)]
- | ^^^^^^^^^^
diff --git a/structopt/tests/ui/structopt_empty_attr.rs b/structopt/tests/ui/structopt_empty_attr.rs
deleted file mode 100644
index a7fc0b9..0000000
--- a/structopt/tests/ui/structopt_empty_attr.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt]
- debug: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
-
diff --git a/structopt/tests/ui/structopt_empty_attr.stderr b/structopt/tests/ui/structopt_empty_attr.stderr
deleted file mode 100644
index dde3630..0000000
--- a/structopt/tests/ui/structopt_empty_attr.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: expected parentheses after `structopt`
- --> $DIR/structopt_empty_attr.rs:14:7
- |
-14 | #[structopt]
- | ^^^^^^^^^
diff --git a/structopt/tests/ui/structopt_name_value_attr.rs b/structopt/tests/ui/structopt_name_value_attr.rs
deleted file mode 100644
index 3d9388f..0000000
--- a/structopt/tests/ui/structopt_name_value_attr.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- #[structopt = "short"]
- debug: bool,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
-
diff --git a/structopt/tests/ui/structopt_name_value_attr.stderr b/structopt/tests/ui/structopt_name_value_attr.stderr
deleted file mode 100644
index f681978..0000000
--- a/structopt/tests/ui/structopt_name_value_attr.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: expected parentheses
- --> $DIR/structopt_name_value_attr.rs:14:17
- |
-14 | #[structopt = "short"]
- | ^
diff --git a/structopt/tests/ui/subcommand_and_flatten.rs b/structopt/tests/ui/subcommand_and_flatten.rs
deleted file mode 100644
index 742ee6d..0000000
--- a/structopt/tests/ui/subcommand_and_flatten.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(subcommand, flatten)]
- cmd: Command,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/subcommand_and_flatten.stderr b/structopt/tests/ui/subcommand_and_flatten.stderr
deleted file mode 100644
index cacea5e..0000000
--- a/structopt/tests/ui/subcommand_and_flatten.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: subcommand, flatten and skip cannot be used together
- --> $DIR/subcommand_and_flatten.rs:17:29
- |
-17 | #[structopt(subcommand, flatten)]
- | ^^^^^^^
diff --git a/structopt/tests/ui/subcommand_and_methods.rs b/structopt/tests/ui/subcommand_and_methods.rs
deleted file mode 100644
index 890f10c..0000000
--- a/structopt/tests/ui/subcommand_and_methods.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(subcommand, long)]
- cmd: Command,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/subcommand_and_methods.stderr b/structopt/tests/ui/subcommand_and_methods.stderr
deleted file mode 100644
index ccaf28d..0000000
--- a/structopt/tests/ui/subcommand_and_methods.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: methods in attributes are not allowed for subcommand
- --> $DIR/subcommand_and_methods.rs:17:17
- |
-17 | #[structopt(subcommand, long)]
- | ^^^^^^^^^^
diff --git a/structopt/tests/ui/subcommand_and_parse.rs b/structopt/tests/ui/subcommand_and_parse.rs
deleted file mode 100644
index f24e4bc..0000000
--- a/structopt/tests/ui/subcommand_and_parse.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(subcommand, parse(from_occurrences))]
- cmd: Command,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/subcommand_and_parse.stderr b/structopt/tests/ui/subcommand_and_parse.stderr
deleted file mode 100644
index 4070056..0000000
--- a/structopt/tests/ui/subcommand_and_parse.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: parse attribute is not allowed for subcommand
- --> $DIR/subcommand_and_parse.rs:17:29
- |
-17 | #[structopt(subcommand, parse(from_occurrences))]
- | ^^^^^
diff --git a/structopt/tests/ui/subcommand_opt_opt.rs b/structopt/tests/ui/subcommand_opt_opt.rs
deleted file mode 100644
index 1dd84e5..0000000
--- a/structopt/tests/ui/subcommand_opt_opt.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(subcommand)]
- cmd: Option<Option<Command>>,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/subcommand_opt_opt.stderr b/structopt/tests/ui/subcommand_opt_opt.stderr
deleted file mode 100644
index daad02f..0000000
--- a/structopt/tests/ui/subcommand_opt_opt.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Option<Option<T>> type is not allowed for subcommand
- --> $DIR/subcommand_opt_opt.rs:18:10
- |
-18 | cmd: Option<Option<Command>>,
- | ^^^^^^
diff --git a/structopt/tests/ui/subcommand_opt_vec.rs b/structopt/tests/ui/subcommand_opt_vec.rs
deleted file mode 100644
index 17bffbf..0000000
--- a/structopt/tests/ui/subcommand_opt_vec.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "make-cookie")]
-struct MakeCookie {
- #[structopt(short)]
- s: String,
-
- #[structopt(subcommand)]
- cmd: Option<Vec<Command>>,
-}
-
-#[derive(StructOpt, Debug)]
-enum Command {
- #[structopt(name = "pound")]
- /// Pound acorns into flour for cookie dough.
- Pound { acorns: u32 },
-
- Sparkle {
- #[structopt(short)]
- color: String,
- },
-}
-
-fn main() {
- let opt = MakeCookie::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/subcommand_opt_vec.stderr b/structopt/tests/ui/subcommand_opt_vec.stderr
deleted file mode 100644
index a9833a6..0000000
--- a/structopt/tests/ui/subcommand_opt_vec.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Option<Vec<T>> type is not allowed for subcommand
- --> $DIR/subcommand_opt_vec.rs:18:10
- |
-18 | cmd: Option<Vec<Command>>,
- | ^^^^^^
diff --git a/structopt/tests/ui/tuple_struct.rs b/structopt/tests/ui/tuple_struct.rs
deleted file mode 100644
index af9b1d5..0000000
--- a/structopt/tests/ui/tuple_struct.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// 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 structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt(u32);
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/structopt/tests/ui/tuple_struct.stderr b/structopt/tests/ui/tuple_struct.stderr
deleted file mode 100644
index 9f2876f..0000000
--- a/structopt/tests/ui/tuple_struct.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: structopt only supports non-tuple structs and enums
- --> $DIR/tuple_struct.rs:11:10
- |
-11 | #[derive(StructOpt, Debug)]
- | ^^^^^^^^^
diff --git a/structopt/tests/utils.rs b/structopt/tests/utils.rs
deleted file mode 100644
index c0684a2..0000000
--- a/structopt/tests/utils.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#![allow(unused)]
-
-use structopt::StructOpt;
-
-pub fn get_help<T: StructOpt>() -> String {
- let mut output = Vec::new();
- <T as StructOpt>::clap().write_help(&mut output).unwrap();
- let output = String::from_utf8(output).unwrap();
-
- eprintln!("\n%%% HELP %%%:=====\n{}\n=====\n", output);
- eprintln!("\n%%% HELP (DEBUG) %%%:=====\n{:?}\n=====\n", output);
-
- output
-}
-
-pub fn get_long_help<T: StructOpt>() -> String {
- let mut output = Vec::new();
- <T as StructOpt>::clap()
- .write_long_help(&mut output)
- .unwrap();
- let output = String::from_utf8(output).unwrap();
-
- eprintln!("\n%%% LONG_HELP %%%:=====\n{}\n=====\n", output);
- eprintln!("\n%%% LONG_HELP (DEBUG) %%%:=====\n{:?}\n=====\n", output);
-
- output
-}
-
-pub fn get_subcommand_long_help<T: StructOpt>(subcmd: &str) -> String {
- let output = <T as StructOpt>::clap()
- .get_matches_from_safe(vec!["test", subcmd, "--help"])
- .expect_err("")
- .message;
-
- eprintln!(
- "\n%%% SUBCOMMAND `{}` HELP %%%:=====\n{}\n=====\n",
- subcmd, output
- );
- eprintln!(
- "\n%%% SUBCOMMAND `{}` HELP (DEBUG) %%%:=====\n{:?}\n=====\n",
- subcmd, output
- );
-
- output
-}
diff --git a/syn-mid/.editorconfig b/syn-mid/.editorconfig
deleted file mode 100644
index 920ea40..0000000
--- a/syn-mid/.editorconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-# EditorConfig configuration
-# http://EditorConfig.org
-
-# Top-most EditorConfig file
-root = true
-
-# Unix-style newlines with a newline ending every file, utf-8 charset
-[*]
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-charset = utf-8
-
-# Match rust/toml, set 4 space indentation
-[*.{rs,toml}]
-indent_style = space
-indent_size = 4
-
-# Match yaml/markdown, set 2 space indentation
-[*.{yml,md}]
-indent_style = space
-indent_size = 2
diff --git a/syn-mid/.gitignore b/syn-mid/.gitignore
deleted file mode 100644
index 2e6c307..0000000
--- a/syn-mid/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.idea/
-.vscode/
-target/
-**/*.rs.bk
-Cargo.lock
-___*
diff --git a/syn-mid/.rustfmt.toml b/syn-mid/.rustfmt.toml
deleted file mode 100644
index a27c0b7..0000000
--- a/syn-mid/.rustfmt.toml
+++ /dev/null
@@ -1,4 +0,0 @@
-# Set the default settings again to always apply the proper formatting without being affected by the editor settings.
-# https://github.com/rust-lang/rls/issues/501#issuecomment-333717736
-edition = "2018"
-tab_spaces = 4
diff --git a/syn-mid/CHANGELOG.md b/syn-mid/CHANGELOG.md
deleted file mode 100644
index 25c17c1..0000000
--- a/syn-mid/CHANGELOG.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# Unreleased
-
-# 0.4.0 - 2019-08-15
-
-* Updated all data structures based on `syn` 1.0.
-
-* Updated `proc-macro2`, `syn`, and `quote` to 1.0.
-
-* Bumped the minimum required version from Rust 1.30 to Rust 1.31.
-
-# 0.3.0 - 2019-02-18
-
-* Removed support for unneeded syntax.
-
-* Removed unneeded types and fields.
-
-* Implemented `Parse` for `Block`.
-
-* Changed `clone-impls` feature to "disabled by default".
-
-* Removed `extra-traits` feature.
-
-* Bumped the minimum required version from Rust 1.15 to Rust 1.30.
-
-# 0.2.0 - 2019-02-15
-
-* Reduced features.
-
-* Fixed bugs.
-
-# 0.1.0 - 2019-02-14
-
-Initial release
diff --git a/syn-mid/Cargo.toml b/syn-mid/Cargo.toml
deleted file mode 100644
index f92e7a0..0000000
--- a/syn-mid/Cargo.toml
+++ /dev/null
@@ -1,23 +0,0 @@
-[package]
-name = "syn-mid"
-version = "0.4.0"
-authors = ["Taiki Endo <te316e89@gmail.com>"]
-edition = "2018"
-license = "Apache-2.0/MIT"
-repository = "https://github.com/taiki-e/syn-mid"
-documentation = "https://docs.rs/syn-mid/"
-readme = "README.md"
-keywords = ["syn", "macros"]
-categories = ["development-tools::procedural-macro-helpers"]
-description = "Providing the features between \"full\" and \"derive\" of syn."
-
-[workspace]
-members = ["examples/const_fn", "examples/const_fn_test"]
-
-[features]
-clone-impls = ["syn/clone-impls"]
-
-[dependencies]
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = { version = "1.0", default-features = false, features = ["parsing", "printing", "derive"] }
diff --git a/syn-mid/LICENSE-APACHE b/syn-mid/LICENSE-APACHE
deleted file mode 100644
index d645695..0000000
--- a/syn-mid/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/syn-mid/LICENSE-MIT b/syn-mid/LICENSE-MIT
deleted file mode 100644
index 31aa793..0000000
--- a/syn-mid/LICENSE-MIT
+++ /dev/null
@@ -1,23 +0,0 @@
-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/syn-mid/README.md b/syn-mid/README.md
deleted file mode 100644
index b9b1c75..0000000
--- a/syn-mid/README.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# syn-mid
-
-[![Build Status][azure-badge]][azure-url]
-[![Crates.io][crates-version-badge]][crates-url]
-[![Docs.rs][docs-badge]][docs-url]
-[![License][crates-license-badge]][crates-url]
-[![Minimum supported Rust version][rustc-badge]][rustc-url]
-
-[azure-badge]: https://dev.azure.com/taiki-e/taiki-e/_apis/build/status/taiki-e.syn-mid?branchName=master
-[azure-url]: https://dev.azure.com/taiki-e/taiki-e/_build/latest?definitionId=11&branchName=master
-[crates-version-badge]: https://img.shields.io/crates/v/syn-mid.svg
-[crates-license-badge]: https://img.shields.io/crates/l/syn-mid.svg
-[crates-badge]: https://img.shields.io/crates/v/syn-mid.svg
-[crates-url]: https://crates.io/crates/syn-mid/
-[docs-badge]: https://docs.rs/syn-mid/badge.svg
-[docs-url]: https://docs.rs/syn-mid/
-[rustc-badge]: https://img.shields.io/badge/rustc-1.31+-lightgray.svg
-[rustc-url]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
-
-Providing the features between "full" and "derive" of syn.
-
-This crate provides the following two unique data structures.
-
-* `syn_mid::ItemFn` -- A function whose body is not parsed.
-
- ```text
- fn process(n: usize) -> Result<()> { ... }
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ ^
- ```
-
-* `syn_mid::Block` -- A block whose body is not parsed.
-
- ```text
- { ... }
- ^ ^
- ```
-
-Other data structures are the same as data structures of [syn]. These are defined in this crate because they cannot be used in [syn] without "full" feature.
-
-[syn]: https://github.com/dtolnay/syn
-
-## Usage
-
-Add this to your `Cargo.toml`:
-
-```toml
-[dependencies]
-syn-mid = "0.4"
-```
-
-The current syn-mid requires Rust 1.31 or later.
-
-[**Examples**](examples)
-
-[**Documentation**](https://docs.rs/syn-mid/)
-
-## Optional features
-
-* **`clone-impls`** — Clone impls for all syntax tree types.
-
-## 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/syn-mid/azure-pipelines.yml b/syn-mid/azure-pipelines.yml
deleted file mode 100644
index 6f0c968..0000000
--- a/syn-mid/azure-pipelines.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-trigger:
-- master
-- staging
-- trying
-
-variables:
- RUSTFLAGS: -Dwarnings
-
-jobs:
-# This is the minimum Rust version supported by syn-mid.
-# When updating this, the reminder to update the minimum supported
-# Rust version in README.md.
-#
-# Tests are not run as tests may require newer versions of rust.
-- template: ci/azure-test.yml
- parameters:
- name: minrust
- rust: 1.31.0
-
-- template: ci/azure-test.yml
- parameters:
- name: stable
- rust: stable
-
-- template: ci/azure-test.yml
- parameters:
- name: beta
- rust: beta
-
-- template: ci/azure-test.yml
- parameters:
- name: nightly
- rust: nightly
- cmd: test
-
-- template: ci/azure-clippy.yml
- parameters:
- name: clippy
- rust: nightly
-
-- template: ci/azure-rustfmt.yml
- parameters:
- name: rustfmt
- rust: stable
-
-- template: ci/azure-rustdoc.yml
- parameters:
- name: rustdoc
- rust: nightly
diff --git a/syn-mid/bors.toml b/syn-mid/bors.toml
deleted file mode 100644
index b477894..0000000
--- a/syn-mid/bors.toml
+++ /dev/null
@@ -1 +0,0 @@
-status = ["taiki-e.syn-mid"]
diff --git a/syn-mid/ci/azure-clippy.yml b/syn-mid/ci/azure-clippy.yml
deleted file mode 100644
index 22165c6..0000000
--- a/syn-mid/ci/azure-clippy.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-jobs:
-- job: ${{ parameters.name }}
- displayName: Clippy
- pool:
- vmImage: ubuntu-16.04
-
- steps:
- - template: azure-install-rust.yml
- parameters:
- rust: ${{ parameters.rust }}
-
- - script: |
- set +e
- if rustup component add clippy; then
- set -e
- else
- set -e
- target=`curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/clippy`
- echo "'clippy' is unavailable on the toolchain '${{ parameters.rust }}', use the toolchain 'nightly-$target' instead"
- rustup toolchain install nightly-$target
- rustup default nightly-$target
- rustup component add clippy
- rustup toolchain list
- rustc -Vv
- cargo -V
- fi
- cargo clippy --version
- displayName: rustup component add clippy
-
- - script: cargo clippy --all --all-features
- displayName: cargo clippy --all-features
diff --git a/syn-mid/ci/azure-install-rust.yml b/syn-mid/ci/azure-install-rust.yml
deleted file mode 100644
index 6b008c6..0000000
--- a/syn-mid/ci/azure-install-rust.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-steps:
- # Linux and macOS.
- - script: |
- set -e
- curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
- export PATH=$PATH:$HOME/.cargo/bin
- rustup toolchain install $RUSTUP_TOOLCHAIN
- rustup default $RUSTUP_TOOLCHAIN
- echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
- env:
- RUSTUP_TOOLCHAIN: ${{ parameters.rust }}
- displayName: Install rust (*nix)
- condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
-
- # Windows.
- - script: |
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe -y --default-toolchain none
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustup toolchain install %RUSTUP_TOOLCHAIN%
- rustup default %RUSTUP_TOOLCHAIN%
- echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
- env:
- RUSTUP_TOOLCHAIN: ${{ parameters.rust }}
- displayName: Install rust (windows)
- condition: eq(variables['Agent.OS'], 'Windows_NT')
-
- # All platforms.
- - script: |
- rustup toolchain list
- rustc -Vv
- cargo -V
- displayName: Query rust and cargo versions
diff --git a/syn-mid/ci/azure-rustdoc.yml b/syn-mid/ci/azure-rustdoc.yml
deleted file mode 100644
index 99a43ff..0000000
--- a/syn-mid/ci/azure-rustdoc.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-jobs:
-- job: ${{ parameters.name }}
- displayName: Rustdoc
- pool:
- vmImage: ubuntu-16.04
-
- steps:
- - template: azure-install-rust.yml
- parameters:
- rust: ${{ parameters.rust }}
-
- - script: RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all --all-features
- displayName: cargo doc --all-features
diff --git a/syn-mid/ci/azure-rustfmt.yml b/syn-mid/ci/azure-rustfmt.yml
deleted file mode 100644
index 0b20da3..0000000
--- a/syn-mid/ci/azure-rustfmt.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-jobs:
-- job: ${{ parameters.name }}
- displayName: Rustfmt
- pool:
- vmImage: ubuntu-16.04
-
- steps:
- - template: azure-install-rust.yml
- parameters:
- rust: ${{ parameters.rust }}
-
- - script: |
- rustup component add rustfmt
- cargo fmt --version
- displayName: rustup component add rustfmt
-
- - script: cargo fmt --all -- --check
- displayName: cargo fmt -- --check
diff --git a/syn-mid/ci/azure-test.yml b/syn-mid/ci/azure-test.yml
deleted file mode 100644
index 32a56ed..0000000
--- a/syn-mid/ci/azure-test.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-parameters:
- cmd: check
-
-jobs:
-- job: ${{ parameters.name }}
- displayName: ${{ parameters.displayName }} ${{ parameters.rust }}
- strategy:
- matrix:
- Linux:
- vmImage: ubuntu-16.04
-
- ${{ if parameters.cross }}:
- MacOS:
- vmImage: macOS-10.13
- Windows:
- vmImage: vs2017-win2016
- pool:
- vmImage: $(vmImage)
-
- steps:
- - template: azure-install-rust.yml
- parameters:
- rust: ${{ parameters.rust }}
-
- - script: |
- cargo ${{ parameters.cmd }}
- cargo ${{ parameters.cmd }} --all-features
- displayName: cargo ${{ parameters.cmd }}
-
- - ${{ if eq(parameters.rust, 'nightly') }}:
- - script: |
- cargo update -Zminimal-versions
- cargo check --all-features
- displayName: cargo check -Zminimal-versions
diff --git a/syn-mid/examples/const_fn/Cargo.toml b/syn-mid/examples/const_fn/Cargo.toml
deleted file mode 100644
index d823e76..0000000
--- a/syn-mid/examples/const_fn/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "const_fn"
-version = "0.0.0"
-authors = ["Taiki Endo <te316e89@gmail.com>"]
-edition = "2018"
-publish = false
-
-[lib]
-proc-macro = true
-path = "lib.rs"
-
-[dependencies]
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = "1.0"
-syn-mid = { version = "0.4", path = "../..", features = ["clone-impls"] }
diff --git a/syn-mid/examples/const_fn/lib.rs b/syn-mid/examples/const_fn/lib.rs
deleted file mode 100644
index 29255f2..0000000
--- a/syn-mid/examples/const_fn/lib.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-#![warn(rust_2018_idioms)]
-
-extern crate proc_macro;
-
-use proc_macro::TokenStream;
-use proc_macro2::TokenStream as TokenStream2;
-use quote::quote;
-use syn_mid::ItemFn;
-
-/// An attribute for easy generation of a const function with conditional compilations.
-#[proc_macro_attribute]
-pub fn const_fn(args: TokenStream, function: TokenStream) -> TokenStream {
- assert!(!args.is_empty(), "requires an argument");
-
- let mut function = syn::parse_macro_input!(function as ItemFn);
- let mut const_function = function.clone();
-
- if function.constness.is_some() {
- function.constness = None;
- } else {
- const_function.constness = Some(Default::default());
- }
-
- let args = TokenStream2::from(args);
- TokenStream::from(quote! {
- #[cfg(not(#args))]
- #function
- #[cfg(#args)]
- #const_function
- })
-}
diff --git a/syn-mid/examples/const_fn_test/Cargo.toml b/syn-mid/examples/const_fn_test/Cargo.toml
deleted file mode 100644
index b3e2807..0000000
--- a/syn-mid/examples/const_fn_test/Cargo.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-name = "const_fn_test"
-version = "0.0.0"
-authors = ["Taiki Endo <te316e89@gmail.com>"]
-edition = "2018"
-publish = false
-
-[dependencies]
-const_fn = { path = "../const_fn" }
diff --git a/syn-mid/examples/const_fn_test/build.rs b/syn-mid/examples/const_fn_test/build.rs
deleted file mode 100644
index bebf234..0000000
--- a/syn-mid/examples/const_fn_test/build.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-use std::{env, process::Command};
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
-
- if is_nightly() {
- println!("cargo:rustc-cfg=nightly");
- }
-}
-
-fn is_nightly() -> bool {
- env::var_os("RUSTC")
- .and_then(|rustc| Command::new(rustc).arg("--version").output().ok())
- .and_then(|output| String::from_utf8(output.stdout).ok())
- .map_or(false, |version| version.contains("nightly"))
-}
diff --git a/syn-mid/examples/const_fn_test/tests/test.rs b/syn-mid/examples/const_fn_test/tests/test.rs
deleted file mode 100644
index 1b2c742..0000000
--- a/syn-mid/examples/const_fn_test/tests/test.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-#![cfg_attr(nightly, feature(const_fn, const_vec_new))]
-#![warn(rust_2018_idioms)]
-#![allow(dead_code)]
-
-use const_fn::const_fn;
-
-#[const_fn(nightly)]
-fn const_vec_new<T>() -> Vec<T> {
- let vec = Vec::new();
- vec
-}
-
-#[test]
-fn test_stable() {
- assert_eq!(const_vec_new::<u8>(), Vec::new());
-}
-
-#[cfg(nightly)]
-const CONST_UNSTABLE: Vec<u8> = const_vec_new();
-
-#[cfg(nightly)]
-#[test]
-fn test_unstable() {
- assert_eq!(CONST_UNSTABLE, Vec::new());
-}
diff --git a/syn-mid/src/arg.rs b/syn-mid/src/arg.rs
deleted file mode 100644
index 593a1ac..0000000
--- a/syn-mid/src/arg.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-use syn::{Attribute, Lifetime, Token};
-
-use super::PatType;
-
-ast_enum_of_structs! {
- /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`.
- pub enum FnArg {
- /// The `self` argument of an associated method, whether taken by value
- /// or by reference.
- Receiver(Receiver),
-
- /// A function argument accepted by pattern and type.
- Typed(PatType),
- }
-}
-
-ast_struct! {
- /// The `self` argument of an associated method, whether taken by value
- /// or by reference.
- pub struct Receiver {
- pub attrs: Vec<Attribute>,
- pub reference: Option<(Token![&], Option<Lifetime>)>,
- pub mutability: Option<Token![mut]>,
- pub self_token: Token![self],
- }
-}
-
-mod parsing {
- use syn::{
- parse::{discouraged::Speculative, Parse, ParseStream, Result},
- Attribute, Token,
- };
-
- use super::{FnArg, PatType, Receiver};
-
- impl Parse for FnArg {
- fn parse(input: ParseStream<'_>) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
-
- let ahead = input.fork();
- if let Ok(mut receiver) = ahead.parse::<Receiver>() {
- if !ahead.peek(Token![:]) {
- input.advance_to(&ahead);
- receiver.attrs = attrs;
- return Ok(FnArg::Receiver(receiver));
- }
- }
-
- let mut typed = input.call(fn_arg_typed)?;
- typed.attrs = attrs;
- Ok(FnArg::Typed(typed))
- }
- }
-
- impl Parse for Receiver {
- fn parse(input: ParseStream<'_>) -> Result<Self> {
- Ok(Self {
- attrs: Vec::new(),
- reference: {
- if input.peek(Token![&]) {
- Some((input.parse()?, input.parse()?))
- } else {
- None
- }
- },
- mutability: input.parse()?,
- self_token: input.parse()?,
- })
- }
- }
-
- fn fn_arg_typed(input: ParseStream<'_>) -> Result<PatType> {
- Ok(PatType {
- attrs: Vec::new(),
- pat: input.parse()?,
- colon_token: input.parse()?,
- ty: Box::new(input.parse()?),
- })
- }
-}
-
-mod printing {
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use super::Receiver;
-
- impl ToTokens for Receiver {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(&self.attrs);
- if let Some((ampersand, lifetime)) = &self.reference {
- ampersand.to_tokens(tokens);
- lifetime.to_tokens(tokens);
- }
- self.mutability.to_tokens(tokens);
- self.self_token.to_tokens(tokens);
- }
- }
-}
diff --git a/syn-mid/src/lib.rs b/syn-mid/src/lib.rs
deleted file mode 100644
index 69bdec9..0000000
--- a/syn-mid/src/lib.rs
+++ /dev/null
@@ -1,190 +0,0 @@
-//! Providing the features between "full" and "derive" of syn.
-//!
-//! This crate provides the following two unique data structures.
-//!
-//! * [`syn_mid::ItemFn`] -- A function whose body is not parsed.
-//!
-//! ```text
-//! fn process(n: usize) -> Result<()> { ... }
-//! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ ^
-//! ```
-//!
-//! * [`syn_mid::Block`] -- A block whose body is not parsed.
-//!
-//! ```text
-//! { ... }
-//! ^ ^
-//! ```
-//!
-//! Other data structures are the same as data structures of [syn]. These are defined in this crate
-//! because they cannot be used in [syn] without "full" feature.
-//!
-//! ## Optional features
-//!
-//! syn-mid in the default features aims to provide the features between "full"
-//! and "derive" of [syn].
-//!
-//! * **`clone-impls`** — Clone impls for all syntax tree types.
-//!
-//! [`syn_mid::ItemFn`]: struct.ItemFn.html
-//! [`syn_mid::Block`]: struct.Block.html
-//! [syn]: https://github.com/dtolnay/syn
-//!
-
-#![doc(html_root_url = "https://docs.rs/syn-mid/0.4.0")]
-#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
-#![warn(unsafe_code)]
-#![warn(rust_2018_idioms, unreachable_pub)]
-#![warn(single_use_lifetimes)]
-#![warn(clippy::all, clippy::pedantic)]
-#![allow(
- clippy::eval_order_dependence,
- clippy::large_enum_variant,
- clippy::module_name_repetitions,
- clippy::use_self
-)]
-
-// Many of the code contained in this crate are copies from https://github.com/dtolnay/syn.
-
-#[macro_use]
-mod macros;
-
-mod arg;
-mod pat;
-mod path;
-
-pub use self::arg::*;
-pub use self::pat::*;
-
-use proc_macro2::TokenStream;
-use syn::{
- punctuated::Punctuated, token, Abi, Attribute, Generics, Ident, ReturnType, Token, Visibility,
-};
-
-ast_struct! {
- /// A braced block containing Rust statements.
- pub struct Block {
- pub brace_token: token::Brace,
- /// Statements in a block
- pub stmts: TokenStream,
- }
-}
-
-ast_struct! {
- /// A free-standing function: `fn process(n: usize) -> Result<()> { ...
- /// }`.
- pub struct ItemFn {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub constness: Option<Token![const]>,
- pub asyncness: Option<Token![async]>,
- pub unsafety: Option<Token![unsafe]>,
- pub abi: Option<Abi>,
- pub fn_token: Token![fn],
- pub ident: Ident,
- pub generics: Generics,
- pub paren_token: token::Paren,
- pub inputs: Punctuated<FnArg, Token![,]>,
- pub output: ReturnType,
- pub block: Block,
- }
-}
-
-mod parsing {
- use syn::{
- braced, parenthesized,
- parse::{Parse, ParseStream, Result},
- Abi, Attribute, Generics, Ident, ReturnType, Token, Visibility, WhereClause,
- };
-
- use super::{Block, FnArg, ItemFn};
-
- impl Parse for Block {
- fn parse(input: ParseStream<'_>) -> Result<Self> {
- let content;
- Ok(Self {
- brace_token: braced!(content in input),
- stmts: content.parse()?,
- })
- }
- }
-
- impl Parse for ItemFn {
- fn parse(input: ParseStream<'_>) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let constness: Option<Token![const]> = input.parse()?;
- let asyncness: Option<Token![async]> = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let abi: Option<Abi> = input.parse()?;
- let fn_token: Token![fn] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
-
- let content;
- let paren_token = parenthesized!(content in input);
- let inputs = content.parse_terminated(FnArg::parse)?;
-
- let output: ReturnType = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
-
- let block = input.parse()?;
-
- Ok(Self {
- attrs,
- vis,
- constness,
- asyncness,
- unsafety,
- abi,
- fn_token,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- paren_token,
- inputs,
- output,
- block,
- })
- }
- }
-}
-
-mod printing {
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use super::{Block, ItemFn};
-
- impl ToTokens for Block {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.stmts.clone());
- });
- }
- }
-
- impl ToTokens for ItemFn {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(&self.attrs);
- self.vis.to_tokens(tokens);
- self.constness.to_tokens(tokens);
- self.asyncness.to_tokens(tokens);
- self.unsafety.to_tokens(tokens);
- self.abi.to_tokens(tokens);
- self.fn_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- self.inputs.to_tokens(tokens);
- });
- self.output.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.block.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.block.stmts.clone());
- });
- }
- }
-}
diff --git a/syn-mid/src/macros.rs b/syn-mid/src/macros.rs
deleted file mode 100644
index 87be7b4..0000000
--- a/syn-mid/src/macros.rs
+++ /dev/null
@@ -1,107 +0,0 @@
-macro_rules! ast_struct {
- (
- [$($attrs_pub:tt)*]
- struct $name:ident $($rest:tt)*
- ) => {
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* struct $name $($rest)*
- };
-
- ($($t:tt)*) => {
- strip_attrs_pub!(ast_struct!($($t)*));
- };
-}
-
-macro_rules! ast_enum {
- (
- [$($attrs_pub:tt)*]
- enum $name:ident $($rest:tt)*
- ) => (
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* enum $name $($rest)*
- );
-
- ($($t:tt)*) => {
- strip_attrs_pub!(ast_enum!($($t)*));
- };
-}
-
-macro_rules! ast_enum_of_structs {
- (
- $(#[$enum_attr:meta])*
- $pub:ident $enum:ident $name:ident $body:tt
- ) => {
- ast_enum!($(#[$enum_attr])* $pub $enum $name $body);
- ast_enum_of_structs_impl!($pub $enum $name $body);
- };
-}
-
-macro_rules! ast_enum_of_structs_impl {
- (
- $pub:ident $enum:ident $name:ident {
- $(
- $(#[$variant_attr:meta])*
- $variant:ident $( ($member:ident) )*,
- )*
- }
- ) => {
- check_keyword_matches!(pub $pub);
- check_keyword_matches!(enum $enum);
-
- $(
- $(
- impl From<$member> for $name {
- fn from(e: $member) -> $name {
- $name::$variant(e)
- }
- }
- )*
- )*
-
- generate_to_tokens! {
- ()
- tokens
- $name { $($variant $($member)*,)* }
- }
- };
-}
-
-macro_rules! generate_to_tokens {
- (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => {
- generate_to_tokens!(
- ($($arms)* $name::$variant => {})
- $tokens $name { $($next)* }
- );
- };
-
- (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident $member:ident, $($next:tt)*}) => {
- generate_to_tokens!(
- ($($arms)* $name::$variant(_e) => quote::ToTokens::to_tokens(_e, $tokens),)
- $tokens $name { $($next)* }
- );
- };
-
- (($($arms:tt)*) $tokens:ident $name:ident {}) => {
- impl quote::ToTokens for $name {
- fn to_tokens(&self, $tokens: &mut proc_macro2::TokenStream) {
- match self {
- $($arms)*
- }
- }
- }
- };
-}
-
-macro_rules! strip_attrs_pub {
- ($mac:ident!($(#[$m:meta])* $pub:ident $($t:tt)*)) => {
- check_keyword_matches!(pub $pub);
-
- $mac!([$(#[$m])* $pub] $($t)*);
- };
-}
-
-macro_rules! check_keyword_matches {
- (struct struct) => {};
- (enum enum) => {};
- (pub pub) => {};
-}
diff --git a/syn-mid/src/pat.rs b/syn-mid/src/pat.rs
deleted file mode 100644
index 8f95381..0000000
--- a/syn-mid/src/pat.rs
+++ /dev/null
@@ -1,413 +0,0 @@
-use syn::{punctuated::Punctuated, token, Attribute, Ident, Member, Path, Token, Type};
-
-ast_enum_of_structs! {
- /// A pattern in a local binding, function signature, match expression, or
- /// various other places.
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- pub enum Pat {
- /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
- Ident(PatIdent),
-
- /// A path pattern like `Color::Red`.
- Path(PatPath),
-
- /// A reference pattern: `&mut var`.
- Reference(PatReference),
-
- /// A struct or struct variant pattern: `Variant { x, y, .. }`.
- Struct(PatStruct),
-
- /// A tuple pattern: `(a, b)`.
- Tuple(PatTuple),
-
- /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
- TupleStruct(PatTupleStruct),
-
- /// A type ascription pattern: `foo: f64`.
- Type(PatType),
-
- /// A pattern that matches any value: `_`.
- Wild(PatWild),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
- pub struct PatIdent {
- pub attrs: Vec<Attribute>,
- pub by_ref: Option<Token![ref]>,
- pub mutability: Option<Token![mut]>,
- pub ident: Ident,
- }
-}
-
-ast_struct! {
- /// A path pattern like `Color::Red`.
- pub struct PatPath {
- pub attrs: Vec<Attribute>,
- pub path: Path,
- }
-}
-
-ast_struct! {
- /// A reference pattern: `&mut var`.
- pub struct PatReference {
- pub attrs: Vec<Attribute>,
- pub and_token: Token![&],
- pub mutability: Option<Token![mut]>,
- pub pat: Box<Pat>,
- }
-}
-
-ast_struct! {
- /// A struct or struct variant pattern: `Variant { x, y, .. }`.
- pub struct PatStruct {
- pub attrs: Vec<Attribute>,
- pub path: Path,
- pub brace_token: token::Brace,
- pub fields: Punctuated<FieldPat, Token![,]>,
- pub dot2_token: Option<Token![..]>,
- }
-}
-
-ast_struct! {
- /// A tuple pattern: `(a, b)`.
- pub struct PatTuple {
- pub attrs: Vec<Attribute>,
- pub paren_token: token::Paren,
- pub elems: Punctuated<Pat, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
- pub struct PatTupleStruct {
- pub attrs: Vec<Attribute>,
- pub path: Path,
- pub pat: PatTuple,
- }
-}
-
-ast_struct! {
- /// A type ascription pattern: `foo: f64`.
- pub struct PatType {
- pub attrs: Vec<Attribute>,
- pub pat: Box<Pat>,
- pub colon_token: Token![:],
- pub ty: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A pattern that matches any value: `_`.
- pub struct PatWild {
- pub attrs: Vec<Attribute>,
- pub underscore_token: Token![_],
- }
-}
-
-ast_struct! {
- /// A single field in a struct pattern.
- ///
- /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated
- /// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token.
- pub struct FieldPat {
- pub attrs: Vec<Attribute>,
- pub member: Member,
- pub colon_token: Option<Token![:]>,
- pub pat: Box<Pat>,
- }
-}
-
-mod parsing {
- use syn::{
- braced,
- ext::IdentExt,
- parenthesized,
- parse::{Parse, ParseStream, Result},
- punctuated::Punctuated,
- token, Ident, Member, Path, Token,
- };
-
- use crate::path;
-
- use super::{
- FieldPat, Pat, PatIdent, PatPath, PatReference, PatStruct, PatTuple, PatTupleStruct,
- PatWild,
- };
-
- impl Parse for Pat {
- fn parse(input: ParseStream<'_>) -> Result<Self> {
- let lookahead = input.lookahead1();
- if lookahead.peek(Ident)
- && ({
- input.peek2(Token![::])
- || input.peek2(token::Brace)
- || input.peek2(token::Paren)
- })
- || input.peek(Token![self]) && input.peek2(Token![::])
- || lookahead.peek(Token![::])
- || lookahead.peek(Token![<])
- || input.peek(Token![Self])
- || input.peek(Token![super])
- || input.peek(Token![extern])
- || input.peek(Token![crate])
- {
- pat_path_or_struct(input)
- } else if lookahead.peek(Token![_]) {
- input.call(pat_wild).map(Pat::Wild)
- } else if lookahead.peek(Token![ref])
- || lookahead.peek(Token![mut])
- || input.peek(Token![self])
- || input.peek(Ident)
- {
- input.call(pat_ident).map(Pat::Ident)
- } else if lookahead.peek(Token![&]) {
- input.call(pat_reference).map(Pat::Reference)
- } else if lookahead.peek(token::Paren) {
- input.call(pat_tuple).map(Pat::Tuple)
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- fn pat_path_or_struct(input: ParseStream<'_>) -> Result<Pat> {
- let path = path::parse_path(input)?;
-
- if input.peek(token::Brace) {
- pat_struct(input, path).map(Pat::Struct)
- } else if input.peek(token::Paren) {
- pat_tuple_struct(input, path).map(Pat::TupleStruct)
- } else {
- Ok(Pat::Path(PatPath {
- attrs: Vec::new(),
- path,
- }))
- }
- }
-
- fn pat_wild(input: ParseStream<'_>) -> Result<PatWild> {
- Ok(PatWild {
- attrs: Vec::new(),
- underscore_token: input.parse()?,
- })
- }
-
- fn pat_ident(input: ParseStream<'_>) -> Result<PatIdent> {
- Ok(PatIdent {
- attrs: Vec::new(),
- by_ref: input.parse()?,
- mutability: input.parse()?,
- ident: input.call(Ident::parse_any)?,
- })
- }
-
- fn pat_tuple_struct(input: ParseStream<'_>, path: Path) -> Result<PatTupleStruct> {
- Ok(PatTupleStruct {
- attrs: Vec::new(),
- path,
- pat: input.call(pat_tuple)?,
- })
- }
-
- fn pat_struct(input: ParseStream<'_>, path: Path) -> Result<PatStruct> {
- let content;
- let brace_token = braced!(content in input);
-
- let mut fields = Punctuated::new();
- while !content.is_empty() && !content.peek(Token![..]) {
- let value = content.call(field_pat)?;
- fields.push_value(value);
- if !content.peek(Token![,]) {
- break;
- }
- let punct: Token![,] = content.parse()?;
- fields.push_punct(punct);
- }
-
- let dot2_token = if fields.empty_or_trailing() && content.peek(Token![..]) {
- Some(content.parse()?)
- } else {
- None
- };
-
- Ok(PatStruct {
- attrs: Vec::new(),
- path,
- brace_token,
- fields,
- dot2_token,
- })
- }
-
- fn field_pat(input: ParseStream<'_>) -> Result<FieldPat> {
- let boxed: Option<Token![box]> = input.parse()?;
- let by_ref: Option<Token![ref]> = input.parse()?;
- let mutability: Option<Token![mut]> = input.parse()?;
- let member: Member = input.parse()?;
-
- if boxed.is_none() && by_ref.is_none() && mutability.is_none() && input.peek(Token![:])
- || is_unnamed(&member)
- {
- return Ok(FieldPat {
- attrs: Vec::new(),
- member,
- colon_token: input.parse()?,
- pat: input.parse()?,
- });
- }
-
- let ident = match member {
- Member::Named(ident) => ident,
- Member::Unnamed(_) => unreachable!(),
- };
-
- let pat = Pat::Ident(PatIdent {
- attrs: Vec::new(),
- by_ref,
- mutability,
- ident: ident.clone(),
- });
-
- Ok(FieldPat {
- member: Member::Named(ident),
- pat: Box::new(pat),
- attrs: Vec::new(),
- colon_token: None,
- })
- }
-
- fn pat_tuple(input: ParseStream<'_>) -> Result<PatTuple> {
- let content;
- let paren_token = parenthesized!(content in input);
-
- let mut elems = Punctuated::new();
- while !content.is_empty() {
- let value: Pat = content.parse()?;
- elems.push_value(value);
- if content.is_empty() {
- break;
- }
- let punct = content.parse()?;
- elems.push_punct(punct);
- }
-
- Ok(PatTuple {
- attrs: Vec::new(),
- paren_token,
- elems,
- })
- }
-
- fn pat_reference(input: ParseStream<'_>) -> Result<PatReference> {
- Ok(PatReference {
- attrs: Vec::new(),
- and_token: input.parse()?,
- mutability: input.parse()?,
- pat: input.parse()?,
- })
- }
-
- fn is_unnamed(member: &Member) -> bool {
- match member {
- Member::Named(_) => false,
- Member::Unnamed(_) => true,
- }
- }
-}
-
-mod printing {
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
- use syn::Token;
-
- use super::{
- FieldPat, PatIdent, PatPath, PatReference, PatStruct, PatTuple, PatTupleStruct, PatType,
- PatWild,
- };
-
- impl ToTokens for PatWild {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.underscore_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatIdent {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.by_ref.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatStruct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.path.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- self.fields.to_tokens(tokens);
- // NOTE: We need a comma before the dot2 token if it is present.
- if !self.fields.empty_or_trailing() && self.dot2_token.is_some() {
- <Token![,]>::default().to_tokens(tokens);
- }
- self.dot2_token.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for PatTupleStruct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.path.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(&self.attrs);
- self.pat.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatPath {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.path.to_tokens(tokens)
- }
- }
-
- impl ToTokens for PatTuple {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.paren_token.surround(tokens, |tokens| {
- self.elems.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for PatReference {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.and_token.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- }
- }
-
- impl ToTokens for FieldPat {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if let Some(colon_token) = &self.colon_token {
- self.member.to_tokens(tokens);
- colon_token.to_tokens(tokens);
- }
- self.pat.to_tokens(tokens);
- }
- }
-}
diff --git a/syn-mid/src/path.rs b/syn-mid/src/path.rs
deleted file mode 100644
index 8093b53..0000000
--- a/syn-mid/src/path.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use syn::{
- ext::IdentExt,
- parse::{ParseStream, Result},
- punctuated::Punctuated,
- Ident, Path, PathArguments, PathSegment, Token,
-};
-
-fn parse_path_segment(input: ParseStream<'_>) -> Result<PathSegment> {
- if input.peek(Token![super])
- || input.peek(Token![self])
- || input.peek(Token![crate])
- || input.peek(Token![extern])
- {
- let ident = input.call(Ident::parse_any)?;
- return Ok(PathSegment::from(ident));
- }
-
- let ident = if input.peek(Token![Self]) {
- input.call(Ident::parse_any)?
- } else {
- input.parse()?
- };
-
- if input.peek(Token![::]) && input.peek3(Token![<]) {
- Ok(PathSegment {
- ident,
- arguments: PathArguments::AngleBracketed(input.parse()?),
- })
- } else {
- Ok(PathSegment::from(ident))
- }
-}
-
-pub(crate) fn parse_path(input: ParseStream<'_>) -> Result<Path> {
- Ok(Path {
- leading_colon: input.parse()?,
- segments: {
- let mut segments = Punctuated::new();
- let value = parse_path_segment(input)?;
- segments.push_value(value);
- while input.peek(Token![::]) {
- let punct: Token![::] = input.parse()?;
- segments.push_punct(punct);
- let value = parse_path_segment(input)?;
- segments.push_value(value);
- }
- segments
- },
- })
-}
diff --git a/syn/.gitignore b/syn/.gitignore
deleted file mode 100644
index 9fa6883..0000000
--- a/syn/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-target
-Cargo.lock
-tests/rust/*
diff --git a/syn/.travis.yml b/syn/.travis.yml
deleted file mode 100644
index a8719cc..0000000
--- a/syn/.travis.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-language: rust
-
-before_script:
- - set -o errexit
-
-script:
- - shopt -s expand_aliases
- - alias build="cargo build ${TARGET+--target=$TARGET}"
- - build --no-default-features
- - build
- - build --features full
- - build --features 'fold visit visit-mut'
- - build --features 'full fold visit visit-mut'
- - build --no-default-features --features derive
- - build --no-default-features --features 'derive parsing'
- - build --no-default-features --features 'derive printing'
- - build --no-default-features --features 'proc-macro parsing printing'
- - build --no-default-features --features full
- - build --no-default-features --features 'full parsing'
- - build --no-default-features --features 'full printing'
- - build --no-default-features --features 'full parsing printing'
- - build --no-default-features --features 'fold visit visit-mut parsing printing'
- - build --no-default-features --features 'full fold visit visit-mut parsing printing'
-
-matrix:
- include:
- - rust: nightly
- name: Tests
- install:
- - rustup component add rustc-dev
- script:
- - cargo test --all-features --release
- - rust: nightly
- - rust: stable
- - rust: beta
- - rust: 1.31.0
- - rust: nightly
- name: Examples
- script:
- - cargo check --manifest-path examples/dump-syntax/Cargo.toml
- - cargo check --manifest-path examples/heapsize/example/Cargo.toml
- - cargo check --manifest-path examples/lazy-static/example/Cargo.toml
- - cargo check --manifest-path examples/trace-var/example/Cargo.toml
- - rust: nightly
- name: Codegen
- script:
- - (cd codegen && cargo run)
- - git diff --exit-code
- - rust: nightly
- name: Minimal versions
- script:
- - cargo update -Z minimal-versions
- - cargo build --all-features
- - rust: nightly
- name: Clippy
- script:
- - rustup component add clippy || travis_terminate 0
- - cargo clippy --all-features
- - rust: nightly
- name: WebAssembly
- env: TARGET=wasm32-unknown-unknown
- install:
- - rustup target add "${TARGET}"
- - rust: nightly
- name: WASI
- env: TARGET=wasm32-wasi
- install:
- - rustup target add "${TARGET}"
- allow_failures:
- - rust: nightly
- name: Clippy
- fast_finish: true
-
-env:
- global:
- - RUST_MIN_STACK=20000000
diff --git a/syn/Cargo.toml b/syn/Cargo.toml
deleted file mode 100644
index 11ad921..0000000
--- a/syn/Cargo.toml
+++ /dev/null
@@ -1,72 +0,0 @@
-[package]
-name = "syn"
-version = "1.0.12" # don't forget to update html_root_url and syn.json
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-license = "MIT OR Apache-2.0"
-description = "Parser for Rust source code"
-repository = "https://github.com/dtolnay/syn"
-documentation = "https://docs.rs/syn"
-categories = ["development-tools::procedural-macro-helpers"]
-readme = "README.md"
-include = [
- "/benches/**",
- "/build.rs",
- "/Cargo.toml",
- "/LICENSE-APACHE",
- "/LICENSE-MIT",
- "/README.md",
- "/src/**",
- "/tests/**",
-]
-edition = "2018"
-
-[features]
-default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"]
-derive = []
-full = []
-parsing = []
-printing = ["quote"]
-visit = []
-visit-mut = []
-fold = []
-clone-impls = []
-extra-traits = []
-proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"]
-
-[dependencies]
-proc-macro2 = { version = "1.0.7", default-features = false }
-quote = { version = "1.0", optional = true, default-features = false }
-unicode-xid = "0.2"
-
-[dev-dependencies]
-anyhow = "1.0"
-flate2 = "1.0"
-insta = "0.12"
-rayon = "1.0"
-ref-cast = "1.0"
-regex = "1.0"
-reqwest = { version = "0.10", features = ["blocking"] }
-tar = "0.4"
-termcolor = "1.0"
-walkdir = "2.1"
-
-[[bench]]
-name = "rust"
-harness = false
-required-features = ["full", "parsing"]
-
-[[bench]]
-name = "file"
-required-features = ["full", "parsing"]
-
-[package.metadata.docs.rs]
-all-features = true
-
-[package.metadata.playground]
-all-features = true
-
-[badges]
-travis-ci = { repository = "dtolnay/syn" }
-
-[workspace]
-members = ["dev", "json"]
diff --git a/syn/LICENSE-APACHE b/syn/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/syn/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/syn/LICENSE-MIT b/syn/LICENSE-MIT
deleted file mode 100644
index 31aa793..0000000
--- a/syn/LICENSE-MIT
+++ /dev/null
@@ -1,23 +0,0 @@
-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/syn/README.md b/syn/README.md
deleted file mode 100644
index 29a7f32..0000000
--- a/syn/README.md
+++ /dev/null
@@ -1,291 +0,0 @@
-Parser for Rust source code
-===========================
-
-[![Build Status](https://api.travis-ci.org/dtolnay/syn.svg?branch=master)](https://travis-ci.org/dtolnay/syn)
-[![Latest Version](https://img.shields.io/crates/v/syn.svg)](https://crates.io/crates/syn)
-[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/syn/1.0/syn/)
-[![Rustc Version 1.31+](https://img.shields.io/badge/rustc-1.31+-lightgray.svg)](https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html)
-
-Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree
-of Rust source code.
-
-Currently this library is geared toward use in Rust procedural macros, but
-contains some APIs that may be useful more generally.
-
-- **Data structures** — Syn provides a complete syntax tree that can represent
- any valid Rust source code. The syntax tree is rooted at [`syn::File`] which
- represents a full source file, but there are other entry points that may be
- useful to procedural macros including [`syn::Item`], [`syn::Expr`] and
- [`syn::Type`].
-
-- **Derives** — Of particular interest to derive macros is [`syn::DeriveInput`]
- which is any of the three legal input items to a derive macro. An example
- below shows using this type in a library that can derive implementations of a
- user-defined trait.
-
-- **Parsing** — Parsing in Syn is built around [parser functions] with the
- signature `fn(ParseStream) -> Result<T>`. Every syntax tree node defined by
- Syn is individually parsable and may be used as a building block for custom
- syntaxes, or you may dream up your own brand new syntax without involving any
- of our syntax tree types.
-
-- **Location information** — Every token parsed by Syn is associated with a
- `Span` that tracks line and column information back to the source of that
- token. These spans allow a procedural macro to display detailed error messages
- pointing to all the right places in the user's code. There is an example of
- this below.
-
-- **Feature flags** — Functionality is aggressively feature gated so your
- procedural macros enable only what they need, and do not pay in compile time
- for all the rest.
-
-[`syn::File`]: https://docs.rs/syn/1.0/syn/struct.File.html
-[`syn::Item`]: https://docs.rs/syn/1.0/syn/enum.Item.html
-[`syn::Expr`]: https://docs.rs/syn/1.0/syn/enum.Expr.html
-[`syn::Type`]: https://docs.rs/syn/1.0/syn/enum.Type.html
-[`syn::DeriveInput`]: https://docs.rs/syn/1.0/syn/struct.DeriveInput.html
-[parser functions]: https://docs.rs/syn/1.0/syn/parse/index.html
-
-If you get stuck with anything involving procedural macros in Rust I am happy to
-provide help even if the issue is not related to Syn. Please file a ticket in
-this repo.
-
-*Version requirement: Syn supports rustc 1.31 and up.*
-
-[*Release notes*](https://github.com/dtolnay/syn/releases)
-
-<br>
-
-## Resources
-
-The best way to learn about procedural macros is by writing some. Consider
-working through [this procedural macro workshop][workshop] to get familiar with
-the different types of procedural macros. The workshop contains relevant links
-into the Syn documentation as you work through each project.
-
-[workshop]: https://github.com/dtolnay/proc-macro-workshop
-
-<br>
-
-## Example of a derive macro
-
-The canonical derive macro using Syn looks like this. We write an ordinary Rust
-function tagged with a `proc_macro_derive` attribute and the name of the trait
-we are deriving. Any time that derive appears in the user's code, the Rust
-compiler passes their data structure as tokens into our macro. We get to execute
-arbitrary Rust code to figure out what to do with those tokens, then hand some
-tokens back to the compiler to compile into the user's crate.
-
-[`TokenStream`]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html
-
-```toml
-[dependencies]
-syn = "1.0"
-quote = "1.0"
-
-[lib]
-proc-macro = true
-```
-
-```rust
-extern crate proc_macro;
-
-use proc_macro::TokenStream;
-use quote::quote;
-use syn::{parse_macro_input, DeriveInput};
-
-#[proc_macro_derive(MyMacro)]
-pub fn my_macro(input: TokenStream) -> TokenStream {
- // Parse the input tokens into a syntax tree
- let input = parse_macro_input!(input as DeriveInput);
-
- // Build the output, possibly using quasi-quotation
- let expanded = quote! {
- // ...
- };
-
- // Hand the output tokens back to the compiler
- TokenStream::from(expanded)
-}
-```
-
-The [`heapsize`] example directory shows a complete working implementation of a
-derive macro. It works on any Rust compiler 1.31+. The example derives a
-`HeapSize` trait which computes an estimate of the amount of heap memory owned
-by a value.
-
-[`heapsize`]: examples/heapsize
-
-```rust
-pub trait HeapSize {
- /// Total number of bytes of heap memory owned by `self`.
- fn heap_size_of_children(&self) -> usize;
-}
-```
-
-The derive macro allows users to write `#[derive(HeapSize)]` on data structures
-in their program.
-
-```rust
-#[derive(HeapSize)]
-struct Demo<'a, T: ?Sized> {
- a: Box<T>,
- b: u8,
- c: &'a str,
- d: String,
-}
-```
-
-<br>
-
-## Spans and error reporting
-
-The token-based procedural macro API provides great control over where the
-compiler's error messages are displayed in user code. Consider the error the
-user sees if one of their field types does not implement `HeapSize`.
-
-```rust
-#[derive(HeapSize)]
-struct Broken {
- ok: String,
- bad: std::thread::Thread,
-}
-```
-
-By tracking span information all the way through the expansion of a procedural
-macro as shown in the `heapsize` example, token-based macros in Syn are able to
-trigger errors that directly pinpoint the source of the problem.
-
-```
-error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
- --> src/main.rs:7:5
- |
-7 | bad: std::thread::Thread,
- | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `std::thread::Thread`
-```
-
-<br>
-
-## Parsing a custom syntax
-
-The [`lazy-static`] example directory shows the implementation of a
-`functionlike!(...)` procedural macro in which the input tokens are parsed using
-Syn's parsing API.
-
-[`lazy-static`]: examples/lazy-static
-
-The example reimplements the popular `lazy_static` crate from crates.io as a
-procedural macro.
-
-```
-lazy_static! {
- static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap();
-}
-```
-
-The implementation shows how to trigger custom warnings and error messages on
-the macro input.
-
-```
-warning: come on, pick a more creative name
- --> src/main.rs:10:16
- |
-10 | static ref FOO: String = "lazy_static".to_owned();
- | ^^^
-```
-
-<br>
-
-## Testing
-
-When testing macros, we often care not just that the macro can be used
-successfully but also that when the macro is provided with invalid input it
-produces maximally helpful error messages. Consider using the [`trybuild`] crate
-to write tests for errors that are emitted by your macro or errors detected by
-the Rust compiler in the expanded code following misuse of the macro. Such tests
-help avoid regressions from later refactors that mistakenly make an error no
-longer trigger or be less helpful than it used to be.
-
-[`trybuild`]: https://github.com/dtolnay/trybuild
-
-<br>
-
-## Debugging
-
-When developing a procedural macro it can be helpful to look at what the
-generated code looks like. Use `cargo rustc -- -Zunstable-options
---pretty=expanded` or the [`cargo expand`] subcommand.
-
-[`cargo expand`]: https://github.com/dtolnay/cargo-expand
-
-To show the expanded code for some crate that uses your procedural macro, run
-`cargo expand` from that crate. To show the expanded code for one of your own
-test cases, run `cargo expand --test the_test_case` where the last argument is
-the name of the test file without the `.rs` extension.
-
-This write-up by Brandon W Maister discusses debugging in more detail:
-[Debugging Rust's new Custom Derive system][debugging].
-
-[debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/
-
-<br>
-
-## Optional features
-
-Syn puts a lot of functionality behind optional features in order to optimize
-compile time for the most common use cases. The following features are
-available.
-
-- **`derive`** *(enabled by default)* — Data structures for representing the
- possible input to a derive macro, including structs and enums and types.
-- **`full`** — Data structures for representing the syntax tree of all valid
- Rust source code, including items and expressions.
-- **`parsing`** *(enabled by default)* — Ability to parse input tokens into a
- syntax tree node of a chosen type.
-- **`printing`** *(enabled by default)* — Ability to print a syntax tree node as
- tokens of Rust source code.
-- **`visit`** — Trait for traversing a syntax tree.
-- **`visit-mut`** — Trait for traversing and mutating in place a syntax tree.
-- **`fold`** — Trait for transforming an owned syntax tree.
-- **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree
- types.
-- **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree
- types.
-- **`proc-macro`** *(enabled by default)* — Runtime dependency on the dynamic
- library libproc_macro from rustc toolchain.
-
-<br>
-
-## Proc macro shim
-
-Syn operates on the token representation provided by the [proc-macro2] crate
-from crates.io rather than using the compiler's built in proc-macro crate
-directly. This enables code using Syn to execute outside of the context of a
-procedural macro, such as in unit tests or build.rs, and we avoid needing
-incompatible ecosystems for proc macros vs non-macro use cases.
-
-In general all of your code should be written against proc-macro2 rather than
-proc-macro. The one exception is in the signatures of procedural macro entry
-points, which are required by the language to use `proc_macro::TokenStream`.
-
-The proc-macro2 crate will automatically detect and use the compiler's data
-structures when a procedural macro is active.
-
-[proc-macro2]: https://docs.rs/proc-macro2/1.0.0/proc_macro2/
-
-<br>
-
-#### License
-
-<sup>
-Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
-2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
-</sup>
-
-<br>
-
-<sub>
-Unless you explicitly state otherwise, any contribution intentionally submitted
-for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
-be dual licensed as above, without any additional terms or conditions.
-</sub>
diff --git a/syn/appveyor.yml b/syn/appveyor.yml
deleted file mode 100644
index 020c8ac..0000000
--- a/syn/appveyor.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-environment:
- matrix:
- - TARGET: x86_64-pc-windows-msvc
-
-install:
- - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
- - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
- - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
- - SET PATH=%PATH%;C:\MinGW\bin
- - rustc -V
- - cargo -V
-
-build: false
-
-test_script:
- - cargo build --all-features
diff --git a/syn/benches/file.rs b/syn/benches/file.rs
deleted file mode 100644
index 58ab8df..0000000
--- a/syn/benches/file.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// $ cargo bench --features full --bench file
-
-#![feature(rustc_private, test)]
-#![recursion_limit = "1024"]
-
-extern crate test;
-
-#[macro_use]
-#[path = "../tests/macros/mod.rs"]
-mod macros;
-
-#[path = "../tests/common/mod.rs"]
-mod common;
-#[path = "../tests/repo/mod.rs"]
-pub mod repo;
-
-use proc_macro2::TokenStream;
-use std::fs;
-use std::str::FromStr;
-use test::Bencher;
-
-const FILE: &str = "tests/rust/src/libcore/str/mod.rs";
-
-#[bench]
-fn parse_file(b: &mut Bencher) {
- repo::clone_rust();
- let content = fs::read_to_string(FILE).unwrap();
- let tokens = TokenStream::from_str(&content).unwrap();
- b.iter(|| syn::parse2::<syn::File>(tokens.clone()));
-}
diff --git a/syn/benches/rust.rs b/syn/benches/rust.rs
deleted file mode 100644
index 941ecb9..0000000
--- a/syn/benches/rust.rs
+++ /dev/null
@@ -1,158 +0,0 @@
-// $ cargo bench --features full --bench rust
-//
-// Syn only, useful for profiling:
-// $ RUSTFLAGS='--cfg syn_only' cargo build --release --features full --bench rust
-
-#![cfg_attr(not(syn_only), feature(rustc_private))]
-#![recursion_limit = "1024"]
-
-#[macro_use]
-#[path = "../tests/macros/mod.rs"]
-mod macros;
-
-#[path = "../tests/common/mod.rs"]
-mod common;
-#[path = "../tests/repo/mod.rs"]
-mod repo;
-
-use std::fs;
-use std::time::{Duration, Instant};
-
-#[cfg(not(syn_only))]
-mod tokenstream_parse {
- use proc_macro2::TokenStream;
- use std::str::FromStr;
-
- pub fn bench(content: &str) -> Result<(), ()> {
- TokenStream::from_str(content).map(drop).map_err(drop)
- }
-}
-
-mod syn_parse {
- pub fn bench(content: &str) -> Result<(), ()> {
- syn::parse_file(content).map(drop).map_err(drop)
- }
-}
-
-#[cfg(not(syn_only))]
-mod libsyntax_parse {
- extern crate rustc_data_structures;
- extern crate rustc_parse;
- extern crate rustc_span;
- extern crate syntax;
-
- use rustc_data_structures::sync::Lrc;
- use rustc_span::FileName;
- use syntax::edition::Edition;
- use syntax::errors::{emitter::Emitter, Diagnostic, Handler};
- use syntax::sess::ParseSess;
- use syntax::source_map::{FilePathMapping, SourceMap};
-
- pub fn bench(content: &str) -> Result<(), ()> {
- struct SilentEmitter;
-
- impl Emitter for SilentEmitter {
- fn emit_diagnostic(&mut self, _diag: &Diagnostic) {}
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
- None
- }
- }
-
- syntax::with_globals(Edition::Edition2018, || {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let emitter = Box::new(SilentEmitter);
- let handler = Handler::with_emitter(false, None, emitter);
- let sess = ParseSess::with_span_handler(handler, cm);
- if let Err(mut diagnostic) = rustc_parse::parse_crate_from_source_str(
- FileName::Custom("bench".to_owned()),
- content.to_owned(),
- &sess,
- ) {
- diagnostic.cancel();
- return Err(());
- };
- Ok(())
- })
- }
-}
-
-#[cfg(not(syn_only))]
-mod read_from_disk {
- pub fn bench(content: &str) -> Result<(), ()> {
- let _ = content;
- Ok(())
- }
-}
-
-fn exec(mut codepath: impl FnMut(&str) -> Result<(), ()>) -> Duration {
- let begin = Instant::now();
- let mut success = 0;
- let mut total = 0;
-
- walkdir::WalkDir::new("tests/rust/src")
- .into_iter()
- .filter_entry(repo::base_dir_filter)
- .for_each(|entry| {
- let entry = entry.unwrap();
- let path = entry.path();
- if path.is_dir() {
- return;
- }
- let content = fs::read_to_string(path).unwrap();
- let ok = codepath(&content).is_ok();
- success += ok as usize;
- total += 1;
- if !ok {
- eprintln!("FAIL {}", path.display());
- }
- });
-
- assert_eq!(success, total);
- begin.elapsed()
-}
-
-fn main() {
- repo::clone_rust();
-
- macro_rules! testcases {
- ($($(#[$cfg:meta])* $name:path,)*) => {
- vec![
- $(
- $(#[$cfg])*
- (stringify!($name), $name as fn(&str) -> Result<(), ()>),
- )*
- ]
- };
- }
-
- #[cfg(not(syn_only))]
- {
- let mut lines = 0;
- let mut files = 0;
- exec(|content| {
- lines += content.lines().count();
- files += 1;
- Ok(())
- });
- eprintln!("\n{} lines in {} files", lines, files);
- }
-
- for (name, f) in testcases!(
- #[cfg(not(syn_only))]
- read_from_disk::bench,
- #[cfg(not(syn_only))]
- tokenstream_parse::bench,
- syn_parse::bench,
- #[cfg(not(syn_only))]
- libsyntax_parse::bench,
- ) {
- eprint!("{:20}", format!("{}:", name));
- let elapsed = exec(f);
- eprintln!(
- "elapsed={}.{:03}s",
- elapsed.as_secs(),
- elapsed.subsec_millis(),
- );
- }
- eprintln!();
-}
diff --git a/syn/build.rs b/syn/build.rs
deleted file mode 100644
index c6040c1..0000000
--- a/syn/build.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-use std::env;
-use std::process::Command;
-use std::str::{self, FromStr};
-
-// The rustc-cfg strings below are *not* public API. Please let us know by
-// opening a GitHub issue if your build environment requires some way to enable
-// these cfgs other than by executing our build script.
-fn main() {
- let compiler = match rustc_version() {
- Some(compiler) => compiler,
- None => return,
- };
-
- if compiler.minor < 36 {
- println!("cargo:rustc-cfg=syn_omit_await_from_token_macro");
- }
-
- if !compiler.nightly {
- println!("cargo:rustc-cfg=syn_disable_nightly_tests");
- }
-}
-
-struct Compiler {
- minor: u32,
- nightly: bool,
-}
-
-fn rustc_version() -> Option<Compiler> {
- let rustc = match env::var_os("RUSTC") {
- Some(rustc) => rustc,
- None => return None,
- };
-
- let output = match Command::new(rustc).arg("--version").output() {
- Ok(output) => output,
- Err(_) => return None,
- };
-
- let version = match str::from_utf8(&output.stdout) {
- Ok(version) => version,
- Err(_) => return None,
- };
-
- let mut pieces = version.split('.');
- if pieces.next() != Some("rustc 1") {
- return None;
- }
-
- let next = match pieces.next() {
- Some(next) => next,
- None => return None,
- };
-
- let minor = match u32::from_str(next) {
- Ok(minor) => minor,
- Err(_) => return None,
- };
-
- Some(Compiler {
- minor,
- nightly: version.contains("nightly"),
- })
-}
diff --git a/syn/codegen/Cargo.toml b/syn/codegen/Cargo.toml
deleted file mode 100644
index 44d890b..0000000
--- a/syn/codegen/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-[package]
-name = "syn-internal-codegen"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>", "Nika Layzell <nika@thelayzells.com>"]
-edition = "2018"
-
-publish = false # this is an internal crate which should never be published
-
-[dependencies]
-anyhow = "1.0"
-color-backtrace = "0.2"
-indexmap = { version = "1.0", features = ["serde-1"] }
-inflections = "1.1"
-proc-macro2 = { version = "1.0", features = ["span-locations"] }
-quote = "1.0"
-rustfmt = { package = "rustfmt-nightly", git = "https://github.com/rust-lang-nursery/rustfmt" }
-semver = { version = "0.9", features = ["serde"] }
-serde = { version = "1.0.88", features = ["derive"] }
-serde_json = "1.0.38"
-syn-codegen = { path = "../json" }
-syn = { path = "..", features = ["full", "extra-traits"] }
-thiserror = "1.0"
-toml = "0.4.10"
-
-# work around https://github.com/crossbeam-rs/crossbeam/issues/435
-# until https://github.com/BurntSushi/ripgrep/pull/1427 is released
-crossbeam-utils = "=0.6.5"
-
-[workspace]
-# Prefer that `cargo clean` in syn's directory does not require a rebuild of
-# rustfmt in the codegen directory.
diff --git a/syn/codegen/README.md b/syn/codegen/README.md
deleted file mode 100644
index df46bd2..0000000
--- a/syn/codegen/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# syn_codegen
-
-This is an internal (not published on crates.io) crate which is used to generate
-the files in the `gen/` directory of `syn`. It is used to ensure that the
-implementations for `Fold`, `Visit`, and `VisitMut` remain in sync with the
-actual AST.
-
-To run this program, run `cargo run` in this directory, and the `gen/` folder
-will be re-generated.
-
-This program is slow, and is therefore not run when building `syn` as part of
-the build script to save on compile time.
diff --git a/syn/codegen/src/debug.rs b/syn/codegen/src/debug.rs
deleted file mode 100644
index 9193881..0000000
--- a/syn/codegen/src/debug.rs
+++ /dev/null
@@ -1,308 +0,0 @@
-use crate::file;
-use anyhow::Result;
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::quote;
-use syn::Index;
-use syn_codegen::{Data, Definitions, Node, Type};
-
-const DEBUG_SRC: &str = "../tests/debug/gen.rs";
-
-fn rust_type(ty: &Type) -> TokenStream {
- match ty {
- Type::Syn(ty) => {
- let ident = Ident::new(ty, Span::call_site());
- quote!(syn::#ident)
- }
- Type::Std(ty) => {
- let ident = Ident::new(ty, Span::call_site());
- quote!(#ident)
- }
- Type::Ext(ty) => {
- let ident = Ident::new(ty, Span::call_site());
- quote!(proc_macro2::#ident)
- }
- Type::Token(ty) | Type::Group(ty) => {
- let ident = Ident::new(ty, Span::call_site());
- quote!(syn::token::#ident)
- }
- Type::Punctuated(ty) => {
- let element = rust_type(&ty.element);
- let punct = Ident::new(&ty.punct, Span::call_site());
- quote!(syn::punctuated::Punctuated<#element, #punct>)
- }
- Type::Option(ty) => {
- let inner = rust_type(ty);
- quote!(Option<#inner>)
- }
- Type::Box(ty) => {
- let inner = rust_type(ty);
- quote!(Box<#inner>)
- }
- Type::Vec(ty) => {
- let inner = rust_type(ty);
- quote!(Vec<#inner>)
- }
- Type::Tuple(ty) => {
- let inner = ty.iter().map(rust_type);
- quote!((#(#inner,)*))
- }
- }
-}
-
-fn is_printable(ty: &Type) -> bool {
- match ty {
- Type::Ext(name) => name != "Span",
- Type::Box(ty) => is_printable(ty),
- Type::Tuple(ty) => ty.iter().any(is_printable),
- Type::Token(_) | Type::Group(_) => false,
- Type::Syn(name) => name != "Reserved",
- Type::Std(_) | Type::Punctuated(_) | Type::Option(_) | Type::Vec(_) => true,
- }
-}
-
-fn format_field(val: &TokenStream, ty: &Type) -> Option<TokenStream> {
- if !is_printable(ty) {
- return None;
- }
- let format = match ty {
- Type::Option(ty) => {
- let inner = quote!(_val);
- let format = format_field(&inner, ty).map(|format| {
- quote! {
- formatter.write_str("(")?;
- Debug::fmt(#format, formatter)?;
- formatter.write_str(")")?;
- }
- });
- let ty = rust_type(ty);
- quote!({
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Option<#ty>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match &self.0 {
- Some(#inner) => {
- formatter.write_str("Some")?;
- #format
- Ok(())
- }
- None => formatter.write_str("None"),
- }
- }
- }
- Print::ref_cast(#val)
- })
- }
- Type::Tuple(ty) => {
- let printable: Vec<TokenStream> = ty
- .iter()
- .enumerate()
- .filter_map(|(i, ty)| {
- let index = Index::from(i);
- let val = quote!(&#val.#index);
- format_field(&val, ty)
- })
- .collect();
- if printable.len() == 1 {
- printable.into_iter().next().unwrap()
- } else {
- quote! {
- &(#(#printable),*)
- }
- }
- }
- _ => quote! { Lite(#val) },
- };
- Some(format)
-}
-
-fn syntax_tree_enum<'a>(outer: &str, inner: &str, fields: &'a [Type]) -> Option<&'a str> {
- if fields.len() != 1 {
- return None;
- }
- const WHITELIST: &[&str] = &["PathArguments", "Visibility"];
- match &fields[0] {
- Type::Syn(ty) if WHITELIST.contains(&outer) || outer.to_owned() + inner == *ty => Some(ty),
- _ => None,
- }
-}
-
-fn lookup<'a>(defs: &'a Definitions, name: &str) -> &'a Node {
- for node in &defs.types {
- if node.ident == name {
- return node;
- }
- }
- panic!("not found: {}", name)
-}
-
-fn expand_impl_body(defs: &Definitions, node: &Node, name: &str) -> TokenStream {
- let ident = Ident::new(&node.ident, Span::call_site());
-
- match &node.data {
- Data::Enum(variants) => {
- let arms = variants.iter().map(|(v, fields)| {
- let variant = Ident::new(v, Span::call_site());
- if fields.is_empty() {
- quote! {
- syn::#ident::#variant => formatter.write_str(#v),
- }
- } else if let Some(inner) = syntax_tree_enum(name, v, fields) {
- let path = format!("{}::{}", name, v);
- let format = expand_impl_body(defs, lookup(defs, inner), &path);
- quote! {
- syn::#ident::#variant(_val) => {
- #format
- }
- }
- } else if fields.len() == 1 {
- let ty = &fields[0];
- let val = quote!(_val);
- let format = format_field(&val, ty).map(|format| {
- quote! {
- formatter.write_str("(")?;
- Debug::fmt(#format, formatter)?;
- formatter.write_str(")")?;
- }
- });
- quote! {
- syn::#ident::#variant(_val) => {
- formatter.write_str(#v)?;
- #format
- Ok(())
- }
- }
- } else {
- let pats = (0..fields.len())
- .map(|i| Ident::new(&format!("_v{}", i), Span::call_site()));
- let fields = fields.iter().enumerate().filter_map(|(i, ty)| {
- let index = Ident::new(&format!("_v{}", i), Span::call_site());
- let val = quote!(#index);
- let format = format_field(&val, ty)?;
- Some(quote! {
- formatter.field(#format);
- })
- });
- quote! {
- syn::#ident::#variant(#(#pats),*) => {
- let mut formatter = formatter.debug_tuple(#v);
- #(#fields)*
- formatter.finish()
- }
- }
- }
- });
- let nonexhaustive = if node.exhaustive {
- None
- } else {
- Some(quote!(_ => unreachable!()))
- };
- quote! {
- match _val {
- #(#arms)*
- #nonexhaustive
- }
- }
- }
- Data::Struct(fields) => {
- let fields = fields.iter().filter_map(|(f, ty)| {
- let ident = Ident::new(f, Span::call_site());
- if let Type::Option(ty) = ty {
- let inner = quote!(_val);
- let format = format_field(&inner, ty).map(|format| {
- quote! {
- let #inner = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(#format, formatter)?;
- formatter.write_str(")")?;
- }
- });
- let ty = rust_type(ty);
- Some(quote! {
- if let Some(val) = &_val.#ident {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(#ty);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- #format
- Ok(())
- }
- }
- formatter.field(#f, Print::ref_cast(val));
- }
- })
- } else {
- let val = quote!(&_val.#ident);
- let format = format_field(&val, ty)?;
- let mut call = quote! {
- formatter.field(#f, #format);
- };
- if let Type::Vec(_) | Type::Punctuated(_) = ty {
- call = quote! {
- if !_val.#ident.is_empty() {
- #call
- }
- };
- }
- Some(call)
- }
- });
- quote! {
- let mut formatter = formatter.debug_struct(#name);
- #(#fields)*
- formatter.finish()
- }
- }
- Data::Private => {
- if node.ident == "LitInt" || node.ident == "LitFloat" {
- quote! {
- write!(formatter, "{}", _val)
- }
- } else {
- quote! {
- write!(formatter, "{:?}", _val.value())
- }
- }
- }
- }
-}
-
-fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
- if node.ident == "Reserved" {
- return TokenStream::new();
- }
-
- let ident = Ident::new(&node.ident, Span::call_site());
- let body = expand_impl_body(defs, node, &node.ident);
-
- quote! {
- impl Debug for Lite<syn::#ident> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- #body
- }
- }
- }
-}
-
-pub fn generate(defs: &Definitions) -> Result<()> {
- let mut impls = TokenStream::new();
- for node in &defs.types {
- impls.extend(expand_impl(&defs, node));
- }
-
- file::write(
- DEBUG_SRC,
- quote! {
- use super::{Lite, RefCast};
- use std::fmt::{self, Debug};
-
- #impls
- },
- )?;
-
- Ok(())
-}
diff --git a/syn/codegen/src/file.rs b/syn/codegen/src/file.rs
deleted file mode 100644
index 5521d75..0000000
--- a/syn/codegen/src/file.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-use anyhow::Result;
-use proc_macro2::TokenStream;
-use std::fs;
-use std::io::Write;
-use std::path::Path;
-
-pub fn write<P: AsRef<Path>>(path: P, content: TokenStream) -> Result<()> {
- let mut formatted = Vec::new();
- writeln!(
- formatted,
- "// This file is @generated by syn-internal-codegen."
- )?;
- writeln!(formatted, "// It is not intended for manual editing.")?;
- writeln!(formatted)?;
-
- let mut config = rustfmt::Config::default();
- config.set().emit_mode(rustfmt::EmitMode::Stdout);
- config.set().verbose(rustfmt::Verbosity::Quiet);
- config.set().format_macro_matchers(true);
- config.set().normalize_doc_attributes(true);
-
- let mut session = rustfmt::Session::new(config, Some(&mut formatted));
- session.format(rustfmt::Input::Text(content.to_string()))?;
- drop(session);
-
- if path.as_ref().is_file() && fs::read(&path)? == formatted {
- return Ok(());
- }
-
- fs::write(path, formatted)?;
- Ok(())
-}
diff --git a/syn/codegen/src/fold.rs b/syn/codegen/src/fold.rs
deleted file mode 100644
index 6914d76..0000000
--- a/syn/codegen/src/fold.rs
+++ /dev/null
@@ -1,284 +0,0 @@
-use crate::{file, full, gen};
-use anyhow::Result;
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::quote;
-use syn::Index;
-use syn_codegen::{Data, Definitions, Features, Node, Type};
-
-const FOLD_SRC: &str = "../src/gen/fold.rs";
-
-fn simple_visit(item: &str, name: &TokenStream) -> TokenStream {
- let ident = gen::under_name(item);
- let method = Ident::new(&format!("fold_{}", ident), Span::call_site());
- quote! {
- f.#method(#name)
- }
-}
-
-fn visit(
- ty: &Type,
- features: &Features,
- defs: &Definitions,
- name: &TokenStream,
-) -> Option<TokenStream> {
- match ty {
- Type::Box(t) => {
- let res = visit(t, features, defs, &quote!(*#name))?;
- Some(quote! {
- Box::new(#res)
- })
- }
- Type::Vec(t) => {
- let operand = quote!(it);
- let val = visit(t, features, defs, &operand)?;
- Some(quote! {
- FoldHelper::lift(#name, |it| { #val })
- })
- }
- Type::Punctuated(p) => {
- let operand = quote!(it);
- let val = visit(&p.element, features, defs, &operand)?;
- Some(quote! {
- FoldHelper::lift(#name, |it| { #val })
- })
- }
- Type::Option(t) => {
- let it = quote!(it);
- let val = visit(t, features, defs, &it)?;
- Some(quote! {
- (#name).map(|it| { #val })
- })
- }
- Type::Tuple(t) => {
- let mut code = TokenStream::new();
- for (i, elem) in t.iter().enumerate() {
- let i = Index::from(i);
- let it = quote!((#name).#i);
- let val = visit(elem, features, defs, &it).unwrap_or(it);
- code.extend(val);
- code.extend(quote!(,));
- }
- Some(quote! {
- (#code)
- })
- }
- Type::Token(t) => {
- let repr = &defs.tokens[t];
- let is_keyword = repr.chars().next().unwrap().is_alphabetic();
- let spans = if is_keyword {
- quote!(span)
- } else {
- quote!(spans)
- };
- let ty = if repr == "await" {
- quote!(crate::token::Await)
- } else {
- syn::parse_str(&format!("Token![{}]", repr)).unwrap()
- };
- Some(quote! {
- #ty(tokens_helper(f, &#name.#spans))
- })
- }
- Type::Group(t) => {
- let ty = Ident::new(t, Span::call_site());
- Some(quote! {
- #ty(tokens_helper(f, &#name.span))
- })
- }
- Type::Syn(t) => {
- fn requires_full(features: &Features) -> bool {
- features.any.contains("full") && features.any.len() == 1
- }
- let mut res = simple_visit(t, name);
- let target = defs.types.iter().find(|ty| ty.ident == *t).unwrap();
- if requires_full(&target.features) && !requires_full(features) {
- res = quote!(full!(#res));
- }
- Some(res)
- }
- Type::Ext(t) if gen::TERMINAL_TYPES.contains(&&t[..]) => Some(simple_visit(t, name)),
- Type::Ext(_) | Type::Std(_) => None,
- }
-}
-
-fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Definitions) {
- let under_name = gen::under_name(&s.ident);
- let ty = Ident::new(&s.ident, Span::call_site());
- let fold_fn = Ident::new(&format!("fold_{}", under_name), Span::call_site());
-
- let mut fold_impl = TokenStream::new();
-
- match &s.data {
- Data::Enum(variants) => {
- let mut fold_variants = TokenStream::new();
-
- for (variant, fields) in variants {
- let variant_ident = Ident::new(variant, Span::call_site());
-
- if fields.is_empty() {
- fold_variants.extend(quote! {
- #ty::#variant_ident => {
- #ty::#variant_ident
- }
- });
- } else {
- let mut bind_fold_fields = TokenStream::new();
- let mut fold_fields = TokenStream::new();
-
- for (idx, ty) in fields.iter().enumerate() {
- let name = format!("_binding_{}", idx);
- let binding = Ident::new(&name, Span::call_site());
-
- bind_fold_fields.extend(quote! {
- #binding,
- });
-
- let owned_binding = quote!(#binding);
-
- fold_fields.extend(
- visit(ty, &s.features, defs, &owned_binding).unwrap_or(owned_binding),
- );
-
- fold_fields.extend(quote!(,));
- }
-
- fold_variants.extend(quote! {
- #ty::#variant_ident(#bind_fold_fields) => {
- #ty::#variant_ident(
- #fold_fields
- )
- }
- });
- }
- }
-
- let nonexhaustive = if s.exhaustive {
- None
- } else {
- Some(quote!(_ => unreachable!()))
- };
-
- fold_impl.extend(quote! {
- match node {
- #fold_variants
- #nonexhaustive
- }
- });
- }
- Data::Struct(fields) => {
- let mut fold_fields = TokenStream::new();
-
- for (field, ty) in fields {
- let id = Ident::new(&field, Span::call_site());
- let ref_toks = quote!(node.#id);
-
- if let Type::Syn(ty) = ty {
- if ty == "Reserved" {
- fold_fields.extend(quote! {
- #id: #ref_toks,
- });
- continue;
- }
- }
-
- let fold = visit(&ty, &s.features, defs, &ref_toks).unwrap_or(ref_toks);
-
- fold_fields.extend(quote! {
- #id: #fold,
- });
- }
-
- if !fields.is_empty() {
- fold_impl.extend(quote! {
- #ty {
- #fold_fields
- }
- })
- } else {
- if ty == "Ident" {
- fold_impl.extend(quote! {
- let mut node = node;
- let span = f.fold_span(node.span());
- node.set_span(span);
- });
- }
- fold_impl.extend(quote! {
- node
- });
- }
- }
- Data::Private => {
- if ty == "Ident" {
- fold_impl.extend(quote! {
- let mut node = node;
- let span = f.fold_span(node.span());
- node.set_span(span);
- });
- }
- fold_impl.extend(quote! {
- node
- });
- }
- }
-
- let fold_span_only =
- s.data == Data::Private && !gen::TERMINAL_TYPES.contains(&s.ident.as_str());
- if fold_span_only {
- fold_impl = quote! {
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
- };
- }
-
- traits.extend(quote! {
- fn #fold_fn(&mut self, i: #ty) -> #ty {
- #fold_fn(self, i)
- }
- });
-
- impls.extend(quote! {
- pub fn #fold_fn<F>(f: &mut F, node: #ty) -> #ty
- where
- F: Fold + ?Sized,
- {
- #fold_impl
- }
- });
-}
-
-pub fn generate(defs: &Definitions) -> Result<()> {
- let (traits, impls) = gen::traverse(defs, node);
- let full_macro = full::get_macro();
- file::write(
- FOLD_SRC,
- quote! {
- // Unreachable code is generated sometimes without the full feature.
- #![allow(unreachable_code, unused_variables)]
-
- use crate::*;
- #[cfg(any(feature = "full", feature = "derive"))]
- use crate::token::{Brace, Bracket, Paren, Group};
- use proc_macro2::Span;
- #[cfg(any(feature = "full", feature = "derive"))]
- use crate::gen::helper::fold::*;
-
- #full_macro
-
- /// Syntax tree traversal to transform the nodes of an owned syntax tree.
- ///
- /// See the [module documentation] for details.
- ///
- /// [module documentation]: self
- ///
- /// *This trait is available if Syn is built with the `"fold"` feature.*
- pub trait Fold {
- #traits
- }
-
- #impls
- },
- )?;
- Ok(())
-}
diff --git a/syn/codegen/src/full.rs b/syn/codegen/src/full.rs
deleted file mode 100644
index a410031..0000000
--- a/syn/codegen/src/full.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-use proc_macro2::TokenStream;
-use quote::quote;
-
-pub fn get_macro() -> TokenStream {
- quote! {
- #[cfg(feature = "full")]
- macro_rules! full {
- ($e:expr) => {
- $e
- };
- }
-
- #[cfg(all(feature = "derive", not(feature = "full")))]
- macro_rules! full {
- ($e:expr) => {
- unreachable!()
- };
- }
- }
-}
diff --git a/syn/codegen/src/gen.rs b/syn/codegen/src/gen.rs
deleted file mode 100644
index ef43182..0000000
--- a/syn/codegen/src/gen.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-use inflections::Inflect;
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::quote;
-use syn_codegen::{Data, Definitions, Features, Node};
-
-pub const TERMINAL_TYPES: &[&str] = &["Span", "Ident"];
-
-pub fn under_name(name: &str) -> Ident {
- Ident::new(&name.to_snake_case(), Span::call_site())
-}
-
-pub fn traverse(
- defs: &Definitions,
- node: fn(&mut TokenStream, &mut TokenStream, &Node, &Definitions),
-) -> (TokenStream, TokenStream) {
- let mut types = defs.types.clone();
- for terminal in TERMINAL_TYPES {
- types.push(Node {
- ident: terminal.to_string(),
- features: Features::default(),
- data: Data::Private,
- exhaustive: true,
- });
- }
- types.sort_by(|a, b| a.ident.cmp(&b.ident));
-
- let mut traits = TokenStream::new();
- let mut impls = TokenStream::new();
- for s in types {
- if s.ident == "Reserved" {
- continue;
- }
- let features = &s.features.any;
- let features = match features.len() {
- 0 => quote!(),
- 1 => quote!(#[cfg(feature = #(#features)*)]),
- _ => quote!(#[cfg(any(#(feature = #features),*))]),
- };
- traits.extend(features.clone());
- impls.extend(features);
- node(&mut traits, &mut impls, &s, defs);
- }
-
- (traits, impls)
-}
diff --git a/syn/codegen/src/json.rs b/syn/codegen/src/json.rs
deleted file mode 100644
index 53904bf..0000000
--- a/syn/codegen/src/json.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-use anyhow::Result;
-use std::fs;
-use std::path::Path;
-use syn_codegen::Definitions;
-
-pub fn generate(defs: &Definitions) -> Result<()> {
- let mut j = serde_json::to_string_pretty(&defs)?;
- j.push('\n');
-
- let check: Definitions = serde_json::from_str(&j)?;
- assert_eq!(*defs, check);
-
- let codegen_root = Path::new(env!("CARGO_MANIFEST_DIR"));
- let json_path = codegen_root.join("../syn.json");
- fs::write(json_path, j)?;
-
- Ok(())
-}
diff --git a/syn/codegen/src/main.rs b/syn/codegen/src/main.rs
deleted file mode 100644
index 9b1b5dd..0000000
--- a/syn/codegen/src/main.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// This crate crawls the Syn source directory to find all structs and enums that
-// form the Syn syntax tree.
-//
-// A machine-readable representation of the syntax tree is saved to syn.json in
-// the repo root for other code generation tools to consume. The syn-codegen
-// crate (https://docs.rs/syn-codegen/) provides the data structures for parsing
-// and making use of syn.json from Rust code.
-//
-// Finally this crate generates the Visit, VisitMut, and Fold traits in Syn
-// programmatically from the syntax tree description.
-
-#![recursion_limit = "128"]
-#![allow(clippy::needless_pass_by_value)]
-
-mod debug;
-mod file;
-mod fold;
-mod full;
-mod gen;
-mod json;
-mod operand;
-mod parse;
-mod version;
-mod visit;
-mod visit_mut;
-
-fn main() -> anyhow::Result<()> {
- color_backtrace::install();
- let defs = parse::parse()?;
- json::generate(&defs)?;
- fold::generate(&defs)?;
- visit::generate(&defs)?;
- visit_mut::generate(&defs)?;
- debug::generate(&defs)?;
- Ok(())
-}
diff --git a/syn/codegen/src/operand.rs b/syn/codegen/src/operand.rs
deleted file mode 100644
index db3bd18..0000000
--- a/syn/codegen/src/operand.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use proc_macro2::TokenStream;
-use quote::quote;
-
-pub enum Operand {
- Borrowed(TokenStream),
- Owned(TokenStream),
-}
-
-pub use self::Operand::*;
-
-impl Operand {
- pub fn tokens(&self) -> &TokenStream {
- match self {
- Borrowed(n) | Owned(n) => n,
- }
- }
-
- pub fn ref_tokens(&self) -> TokenStream {
- match self {
- Borrowed(n) => n.clone(),
- Owned(n) => quote!(&#n),
- }
- }
-
- pub fn ref_mut_tokens(&self) -> TokenStream {
- match self {
- Borrowed(n) => n.clone(),
- Owned(n) => quote!(&mut #n),
- }
- }
-
- pub fn owned_tokens(&self) -> TokenStream {
- match self {
- Borrowed(n) => quote!(*#n),
- Owned(n) => n.clone(),
- }
- }
-}
diff --git a/syn/codegen/src/parse.rs b/syn/codegen/src/parse.rs
deleted file mode 100644
index cdd6085..0000000
--- a/syn/codegen/src/parse.rs
+++ /dev/null
@@ -1,657 +0,0 @@
-use crate::version;
-use anyhow::{bail, Result};
-use indexmap::IndexMap;
-use quote::quote;
-use syn::parse::Parser;
-use syn::{parse_quote, Data, DataStruct, DeriveInput, Ident, Item};
-use syn_codegen as types;
-use thiserror::Error;
-
-use std::collections::BTreeMap;
-use std::fs;
-use std::path::{Path, PathBuf};
-
-const SYN_CRATE_ROOT: &str = "../src/lib.rs";
-const TOKEN_SRC: &str = "../src/token.rs";
-const IGNORED_MODS: &[&str] = &["fold", "visit", "visit_mut"];
-const EXTRA_TYPES: &[&str] = &["Lifetime"];
-const NONEXHAUSTIVE: &str = "__Nonexhaustive";
-
-// NOTE: BTreeMap is used here instead of HashMap to have deterministic output.
-type ItemLookup = BTreeMap<Ident, AstItem>;
-type TokenLookup = BTreeMap<String, String>;
-
-/// Parse the contents of `src` and return a list of AST types.
-pub fn parse() -> Result<types::Definitions> {
- let mut item_lookup = BTreeMap::new();
- load_file(SYN_CRATE_ROOT, &[], &mut item_lookup)?;
-
- let token_lookup = load_token_file(TOKEN_SRC)?;
-
- let version = version::get()?;
-
- let types = item_lookup
- .values()
- .map(|item| introspect_item(item, &item_lookup, &token_lookup))
- .collect();
-
- let tokens = token_lookup
- .into_iter()
- .map(|(name, ty)| (ty, name))
- .collect();
-
- Ok(types::Definitions {
- version,
- types,
- tokens,
- })
-}
-
-/// Data extracted from syn source
-#[derive(Clone)]
-pub struct AstItem {
- ast: DeriveInput,
- features: Vec<syn::Attribute>,
-}
-
-fn introspect_item(item: &AstItem, items: &ItemLookup, tokens: &TokenLookup) -> types::Node {
- let features = introspect_features(&item.features);
-
- match &item.ast.data {
- Data::Enum(ref data) => types::Node {
- ident: item.ast.ident.to_string(),
- features,
- data: types::Data::Enum(introspect_enum(data, items, tokens)),
- exhaustive: data.variants.iter().all(|v| v.ident != NONEXHAUSTIVE),
- },
- Data::Struct(ref data) => types::Node {
- ident: item.ast.ident.to_string(),
- features,
- data: {
- if data.fields.iter().all(|f| is_pub(&f.vis)) {
- types::Data::Struct(introspect_struct(data, items, tokens))
- } else {
- types::Data::Private
- }
- },
- exhaustive: true,
- },
- Data::Union(..) => panic!("Union not supported"),
- }
-}
-
-fn introspect_enum(
- item: &syn::DataEnum,
- items: &ItemLookup,
- tokens: &TokenLookup,
-) -> types::Variants {
- item.variants
- .iter()
- .filter_map(|variant| {
- if variant.ident == NONEXHAUSTIVE {
- return None;
- }
- let fields = match &variant.fields {
- syn::Fields::Unnamed(fields) => fields
- .unnamed
- .iter()
- .map(|field| introspect_type(&field.ty, items, tokens))
- .collect(),
- syn::Fields::Unit => vec![],
- _ => panic!("Enum representation not supported"),
- };
- Some((variant.ident.to_string(), fields))
- })
- .collect()
-}
-
-fn introspect_struct(
- item: &syn::DataStruct,
- items: &ItemLookup,
- tokens: &TokenLookup,
-) -> types::Fields {
- match &item.fields {
- syn::Fields::Named(fields) => fields
- .named
- .iter()
- .map(|field| {
- (
- field.ident.as_ref().unwrap().to_string(),
- introspect_type(&field.ty, items, tokens),
- )
- })
- .collect(),
- syn::Fields::Unit => IndexMap::new(),
- _ => panic!("Struct representation not supported"),
- }
-}
-
-fn introspect_type(item: &syn::Type, items: &ItemLookup, tokens: &TokenLookup) -> types::Type {
- match item {
- syn::Type::Path(syn::TypePath {
- qself: None,
- ref path,
- }) => {
- let last = path.segments.last().unwrap();
- let string = last.ident.to_string();
-
- match string.as_str() {
- "Option" => {
- let nested = introspect_type(first_arg(&last.arguments), items, tokens);
- types::Type::Option(Box::new(nested))
- }
- "Punctuated" => {
- let nested = introspect_type(first_arg(&last.arguments), items, tokens);
- let punct = match introspect_type(last_arg(&last.arguments), items, tokens) {
- types::Type::Token(s) => s,
- _ => panic!(),
- };
-
- types::Type::Punctuated(types::Punctuated {
- element: Box::new(nested),
- punct,
- })
- }
- "Vec" => {
- let nested = introspect_type(first_arg(&last.arguments), items, tokens);
- types::Type::Vec(Box::new(nested))
- }
- "Box" => {
- let nested = introspect_type(first_arg(&last.arguments), items, tokens);
- types::Type::Box(Box::new(nested))
- }
- "Brace" | "Bracket" | "Paren" | "Group" => types::Type::Group(string),
- "TokenStream" | "Literal" | "Ident" | "Span" => types::Type::Ext(string),
- "String" | "u32" | "usize" | "bool" => types::Type::Std(string),
- "Await" => types::Type::Token("Await".to_string()),
- _ => {
- if items.get(&last.ident).is_some() || last.ident == "Reserved" {
- types::Type::Syn(string)
- } else {
- unimplemented!("{}", string);
- }
- }
- }
- }
- syn::Type::Tuple(syn::TypeTuple { ref elems, .. }) => {
- let tys = elems
- .iter()
- .map(|ty| introspect_type(&ty, items, tokens))
- .collect();
- types::Type::Tuple(tys)
- }
- syn::Type::Macro(syn::TypeMacro { ref mac })
- if mac.path.segments.last().unwrap().ident == "Token" =>
- {
- let content = mac.tokens.to_string();
- let ty = tokens.get(&content).unwrap().to_string();
-
- types::Type::Token(ty)
- }
- _ => panic!("{}", quote!(#item).to_string()),
- }
-}
-
-fn introspect_features(attrs: &[syn::Attribute]) -> types::Features {
- let mut ret = types::Features::default();
-
- for attr in attrs {
- if !attr.path.is_ident("cfg") {
- continue;
- }
-
- let features = parsing::parse_features.parse2(attr.tokens.clone()).unwrap();
-
- if ret.any.is_empty() {
- ret = features;
- } else if ret.any.len() < features.any.len() {
- assert!(ret.any.iter().all(|f| features.any.contains(f)));
- } else {
- assert!(features.any.iter().all(|f| ret.any.contains(f)));
- ret = features;
- }
- }
-
- ret
-}
-
-fn is_pub(vis: &syn::Visibility) -> bool {
- match vis {
- syn::Visibility::Public(_) => true,
- _ => false,
- }
-}
-
-fn first_arg(params: &syn::PathArguments) -> &syn::Type {
- let data = match *params {
- syn::PathArguments::AngleBracketed(ref data) => data,
- _ => panic!("Expected at least 1 type argument here"),
- };
-
- match *data
- .args
- .first()
- .expect("Expected at least 1 type argument here")
- {
- syn::GenericArgument::Type(ref ty) => ty,
- _ => panic!("Expected at least 1 type argument here"),
- }
-}
-
-fn last_arg(params: &syn::PathArguments) -> &syn::Type {
- let data = match *params {
- syn::PathArguments::AngleBracketed(ref data) => data,
- _ => panic!("Expected at least 1 type argument here"),
- };
-
- match *data
- .args
- .last()
- .expect("Expected at least 1 type argument here")
- {
- syn::GenericArgument::Type(ref ty) => ty,
- _ => panic!("Expected at least 1 type argument here"),
- }
-}
-
-mod parsing {
- use super::{AstItem, TokenLookup};
-
- use proc_macro2::{TokenStream, TokenTree};
- use quote::quote;
- use syn;
- use syn::parse::{ParseStream, Result};
- use syn::*;
- use syn_codegen as types;
-
- use std::collections::{BTreeMap, BTreeSet};
-
- fn peek_tag(input: ParseStream, tag: &str) -> bool {
- let ahead = input.fork();
- ahead.parse::<Token![#]>().is_ok()
- && ahead
- .parse::<Ident>()
- .map(|ident| ident == tag)
- .unwrap_or(false)
- }
-
- // Parses #full - returns #[cfg(feature = "full")] if it is present, and
- // nothing otherwise.
- fn full(input: ParseStream) -> Vec<syn::Attribute> {
- if peek_tag(input, "full") {
- input.parse::<Token![#]>().unwrap();
- input.parse::<Ident>().unwrap();
- vec![parse_quote!(#[cfg(feature = "full")])]
- } else {
- vec![]
- }
- }
-
- fn skip_manual_extra_traits(input: ParseStream) {
- if peek_tag(input, "manual_extra_traits") || peek_tag(input, "manual_extra_traits_debug") {
- input.parse::<Token![#]>().unwrap();
- input.parse::<Ident>().unwrap();
- }
- }
-
- // Parses a simple AstStruct without the `pub struct` prefix.
- fn ast_struct_inner(input: ParseStream) -> Result<AstItem> {
- let ident: Ident = input.parse()?;
- let features = full(input);
- skip_manual_extra_traits(input);
- let rest: TokenStream = input.parse()?;
- Ok(AstItem {
- ast: syn::parse2(quote! {
- pub struct #ident #rest
- })?,
- features,
- })
- }
-
- pub fn ast_struct(input: ParseStream) -> Result<AstItem> {
- input.call(Attribute::parse_outer)?;
- input.parse::<Token![pub]>()?;
- input.parse::<Token![struct]>()?;
- let res = input.call(ast_struct_inner)?;
- Ok(res)
- }
-
- fn no_visit(input: ParseStream) -> bool {
- if peek_tag(input, "no_visit") {
- input.parse::<Token![#]>().unwrap();
- input.parse::<Ident>().unwrap();
- true
- } else {
- false
- }
- }
-
- pub fn ast_enum(input: ParseStream) -> Result<Option<AstItem>> {
- input.call(Attribute::parse_outer)?;
- input.parse::<Token![pub]>()?;
- input.parse::<Token![enum]>()?;
- let ident: Ident = input.parse()?;
- skip_manual_extra_traits(input);
- let no_visit = no_visit(input);
- let rest: TokenStream = input.parse()?;
- Ok(if no_visit {
- None
- } else {
- Some(AstItem {
- ast: syn::parse2(quote! {
- pub enum #ident #rest
- })?,
- features: vec![],
- })
- })
- }
-
- // A single variant of an ast_enum_of_structs!
- struct EosVariant {
- name: Ident,
- member: Option<Path>,
- }
- fn eos_variant(input: ParseStream) -> Result<EosVariant> {
- input.call(Attribute::parse_outer)?;
- let variant: Ident = input.parse()?;
- let member = if input.peek(token::Paren) {
- let content;
- parenthesized!(content in input);
- let path: Path = content.parse()?;
- Some(path)
- } else {
- None
- };
- input.parse::<Token![,]>()?;
- Ok(EosVariant {
- name: variant,
- member,
- })
- }
-
- pub fn ast_enum_of_structs(input: ParseStream) -> Result<AstItem> {
- input.call(Attribute::parse_outer)?;
- input.parse::<Token![pub]>()?;
- input.parse::<Token![enum]>()?;
- let ident: Ident = input.parse()?;
- skip_manual_extra_traits(input);
-
- let content;
- braced!(content in input);
- let mut variants = Vec::new();
- while !content.is_empty() {
- variants.push(content.call(eos_variant)?);
- }
-
- if let Some(ident) = input.parse::<Option<Ident>>()? {
- assert_eq!(ident, "do_not_generate_to_tokens");
- }
-
- let enum_item = {
- let variants = variants.iter().map(|v| {
- let name = v.name.clone();
- match v.member {
- Some(ref member) => quote!(#name(#member)),
- None => quote!(#name),
- }
- });
- parse_quote! {
- pub enum #ident {
- #(#variants),*
- }
- }
- };
- Ok(AstItem {
- ast: enum_item,
- features: vec![],
- })
- }
-
- mod kw {
- syn::custom_keyword!(macro_rules);
- syn::custom_keyword!(Token);
- }
-
- pub fn parse_token_macro(input: ParseStream) -> Result<TokenLookup> {
- input.parse::<TokenTree>()?;
- input.parse::<Token![=>]>()?;
-
- let definition;
- braced!(definition in input);
- definition.call(Attribute::parse_outer)?;
- definition.parse::<kw::macro_rules>()?;
- definition.parse::<Token![!]>()?;
- definition.parse::<kw::Token>()?;
-
- let rules;
- braced!(rules in definition);
- input.parse::<Token![;]>()?;
-
- let mut tokens = BTreeMap::new();
- while !rules.is_empty() {
- if rules.peek(Token![$]) {
- rules.parse::<Token![$]>()?;
- rules.parse::<TokenTree>()?;
- rules.parse::<Token![*]>()?;
- tokens.insert("await".to_owned(), "Await".to_owned());
- } else {
- let pattern;
- parenthesized!(pattern in rules);
- let token = pattern.parse::<TokenStream>()?.to_string();
- rules.parse::<Token![=>]>()?;
- let expansion;
- braced!(expansion in rules);
- rules.parse::<Token![;]>()?;
- expansion.parse::<Token![$]>()?;
- let path: Path = expansion.parse()?;
- let ty = path.segments.last().unwrap().ident.to_string();
- tokens.insert(token, ty.to_string());
- }
- }
- Ok(tokens)
- }
-
- fn parse_feature(input: ParseStream) -> Result<String> {
- let i: syn::Ident = input.parse()?;
- assert_eq!(i, "feature");
-
- input.parse::<Token![=]>()?;
- let s = input.parse::<syn::LitStr>()?;
-
- Ok(s.value())
- }
-
- pub fn parse_features(input: ParseStream) -> Result<types::Features> {
- let mut features = BTreeSet::new();
-
- let level_1;
- parenthesized!(level_1 in input);
-
- let i: syn::Ident = level_1.fork().parse()?;
-
- if i == "any" {
- level_1.parse::<syn::Ident>()?;
-
- let level_2;
- parenthesized!(level_2 in level_1);
-
- while !level_2.is_empty() {
- features.insert(parse_feature(&level_2)?);
-
- if !level_2.is_empty() {
- level_2.parse::<Token![,]>()?;
- }
- }
- } else if i == "feature" {
- features.insert(parse_feature(&level_1)?);
- assert!(level_1.is_empty());
- } else {
- panic!("{:?}", i);
- }
-
- assert!(input.is_empty());
-
- Ok(types::Features { any: features })
- }
-}
-
-fn get_features(attrs: &[syn::Attribute], base: &[syn::Attribute]) -> Vec<syn::Attribute> {
- let mut ret = base.to_owned();
-
- for attr in attrs {
- if attr.path.is_ident("cfg") {
- ret.push(attr.clone());
- }
- }
-
- ret
-}
-
-#[derive(Error, Debug)]
-#[error("{path}:{line}:{column}: {error}")]
-struct LoadFileError {
- path: PathBuf,
- line: usize,
- column: usize,
- error: syn::Error,
-}
-
-fn load_file<P: AsRef<Path>>(
- name: P,
- features: &[syn::Attribute],
- lookup: &mut ItemLookup,
-) -> Result<()> {
- let error = match do_load_file(&name, features, lookup).err() {
- None => return Ok(()),
- Some(error) => error,
- };
-
- let error = error.downcast::<syn::Error>()?;
- let span = error.span().start();
-
- bail!(LoadFileError {
- path: name.as_ref().to_owned(),
- line: span.line,
- column: span.column + 1,
- error,
- })
-}
-
-fn do_load_file<P: AsRef<Path>>(
- name: P,
- features: &[syn::Attribute],
- lookup: &mut ItemLookup,
-) -> Result<()> {
- let name = name.as_ref();
- let parent = name.parent().expect("no parent path");
-
- // Parse the file
- let src = fs::read_to_string(name)?;
- let file = syn::parse_file(&src)?;
-
- // Collect all of the interesting AstItems declared in this file or submodules.
- 'items: for item in file.items {
- match item {
- Item::Mod(item) => {
- // Don't inspect inline modules.
- if item.content.is_some() {
- continue;
- }
-
- // We don't want to try to load the generated rust files and
- // parse them, so we ignore them here.
- for name in IGNORED_MODS {
- if item.ident == name {
- continue 'items;
- }
- }
-
- // Lookup any #[cfg()] attributes on the module and add them to
- // the feature set.
- //
- // The derive module is weird because it is built with either
- // `full` or `derive` but exported only under `derive`.
- let features = if item.ident == "derive" {
- vec![parse_quote!(#[cfg(feature = "derive")])]
- } else {
- get_features(&item.attrs, features)
- };
-
- // Look up the submodule file, and recursively parse it.
- // Only handles same-directory .rs file submodules for now.
- let path = parent.join(&format!("{}.rs", item.ident));
- load_file(path, &features, lookup)?;
- }
- Item::Macro(item) => {
- // Lookip any #[cfg()] attributes directly on the macro
- // invocation, and add them to the feature set.
- let features = get_features(&item.attrs, features);
-
- // Try to parse the AstItem declaration out of the item.
- let tts = item.mac.tokens.clone();
- let found = if item.mac.path.is_ident("ast_struct") {
- Some(parsing::ast_struct.parse2(tts)?)
- } else if item.mac.path.is_ident("ast_enum") {
- parsing::ast_enum.parse2(tts)?
- } else if item.mac.path.is_ident("ast_enum_of_structs") {
- Some(parsing::ast_enum_of_structs.parse2(tts)?)
- } else {
- continue;
- };
-
- // Record our features on the parsed AstItems.
- for mut item in found {
- if item.ast.ident != "Reserved" {
- item.features.extend(features.clone());
- lookup.insert(item.ast.ident.clone(), item);
- }
- }
- }
- Item::Struct(item) => {
- let ident = item.ident;
- if EXTRA_TYPES.contains(&&ident.to_string()[..]) {
- lookup.insert(
- ident.clone(),
- AstItem {
- ast: DeriveInput {
- ident,
- vis: item.vis,
- attrs: item.attrs,
- generics: item.generics,
- data: Data::Struct(DataStruct {
- fields: item.fields,
- struct_token: item.struct_token,
- semi_token: item.semi_token,
- }),
- },
- features: features.to_owned(),
- },
- );
- }
- }
- _ => {}
- }
- }
- Ok(())
-}
-
-fn load_token_file<P: AsRef<Path>>(name: P) -> Result<TokenLookup> {
- let name = name.as_ref();
- let src = fs::read_to_string(name)?;
- let file = syn::parse_file(&src)?;
- for item in file.items {
- match item {
- Item::Macro(item) => {
- match item.ident {
- Some(ref i) if i == "export_token_macro" => {}
- _ => continue,
- }
- let tokens = item.mac.parse_body_with(parsing::parse_token_macro)?;
- return Ok(tokens);
- }
- _ => {}
- }
- }
-
- panic!("failed to parse Token macro")
-}
diff --git a/syn/codegen/src/version.rs b/syn/codegen/src/version.rs
deleted file mode 100644
index 9374624..0000000
--- a/syn/codegen/src/version.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-use anyhow::Result;
-use semver::Version;
-use serde::Deserialize;
-
-use std::fs;
-use std::path::Path;
-
-pub fn get() -> Result<Version> {
- let codegen_root = Path::new(env!("CARGO_MANIFEST_DIR"));
- let syn_cargo_toml = codegen_root.join("../Cargo.toml");
- let manifest = fs::read_to_string(syn_cargo_toml)?;
- let parsed: Manifest = toml::from_str(&manifest)?;
- Ok(parsed.package.version)
-}
-
-#[derive(Debug, Deserialize)]
-struct Manifest {
- package: Package,
-}
-
-#[derive(Debug, Deserialize)]
-struct Package {
- version: Version,
-}
diff --git a/syn/codegen/src/visit.rs b/syn/codegen/src/visit.rs
deleted file mode 100644
index 41bc9e9..0000000
--- a/syn/codegen/src/visit.rs
+++ /dev/null
@@ -1,265 +0,0 @@
-use crate::operand::{Borrowed, Operand, Owned};
-use crate::{file, full, gen};
-use anyhow::Result;
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::quote;
-use syn::Index;
-use syn_codegen::{Data, Definitions, Features, Node, Type};
-
-const VISIT_SRC: &str = "../src/gen/visit.rs";
-
-fn simple_visit(item: &str, name: &Operand) -> TokenStream {
- let ident = gen::under_name(item);
- let method = Ident::new(&format!("visit_{}", ident), Span::call_site());
- let name = name.ref_tokens();
- quote! {
- v.#method(#name)
- }
-}
-
-fn noop_visit(name: &Operand) -> TokenStream {
- let name = name.tokens();
- quote! {
- skip!(#name)
- }
-}
-
-fn visit(
- ty: &Type,
- features: &Features,
- defs: &Definitions,
- name: &Operand,
-) -> Option<TokenStream> {
- match ty {
- Type::Box(t) => {
- let name = name.owned_tokens();
- visit(t, features, defs, &Owned(quote!(*#name)))
- }
- Type::Vec(t) => {
- let operand = Borrowed(quote!(it));
- let val = visit(t, features, defs, &operand)?;
- let name = name.ref_tokens();
- Some(quote! {
- for it in #name {
- #val
- }
- })
- }
- Type::Punctuated(p) => {
- let operand = Borrowed(quote!(it));
- let val = visit(&p.element, features, defs, &operand)?;
- let name = name.ref_tokens();
- Some(quote! {
- for el in Punctuated::pairs(#name) {
- let (it, p) = el.into_tuple();
- #val;
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- })
- }
- Type::Option(t) => {
- let it = Borrowed(quote!(it));
- let val = visit(t, features, defs, &it)?;
- let name = name.owned_tokens();
- Some(quote! {
- if let Some(it) = &#name {
- #val
- }
- })
- }
- Type::Tuple(t) => {
- let mut code = TokenStream::new();
- for (i, elem) in t.iter().enumerate() {
- let name = name.tokens();
- let i = Index::from(i);
- let it = Owned(quote!((#name).#i));
- let val = visit(elem, features, defs, &it).unwrap_or_else(|| noop_visit(&it));
- code.extend(val);
- code.extend(quote!(;));
- }
- Some(code)
- }
- Type::Token(t) => {
- let name = name.tokens();
- let repr = &defs.tokens[t];
- let is_keyword = repr.chars().next().unwrap().is_alphabetic();
- let spans = if is_keyword {
- quote!(span)
- } else {
- quote!(spans)
- };
- Some(quote! {
- tokens_helper(v, &#name.#spans)
- })
- }
- Type::Group(_) => {
- let name = name.tokens();
- Some(quote! {
- tokens_helper(v, &#name.span)
- })
- }
- Type::Syn(t) => {
- fn requires_full(features: &Features) -> bool {
- features.any.contains("full") && features.any.len() == 1
- }
- let mut res = simple_visit(t, name);
- let target = defs.types.iter().find(|ty| ty.ident == *t).unwrap();
- if requires_full(&target.features) && !requires_full(features) {
- res = quote!(full!(#res));
- }
- Some(res)
- }
- Type::Ext(t) if gen::TERMINAL_TYPES.contains(&&t[..]) => Some(simple_visit(t, name)),
- Type::Ext(_) | Type::Std(_) => None,
- }
-}
-
-fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Definitions) {
- let under_name = gen::under_name(&s.ident);
- let ty = Ident::new(&s.ident, Span::call_site());
- let visit_fn = Ident::new(&format!("visit_{}", under_name), Span::call_site());
-
- let mut visit_impl = TokenStream::new();
-
- match &s.data {
- Data::Enum(variants) => {
- let mut visit_variants = TokenStream::new();
-
- for (variant, fields) in variants {
- let variant_ident = Ident::new(variant, Span::call_site());
-
- if fields.is_empty() {
- visit_variants.extend(quote! {
- #ty::#variant_ident => {}
- });
- } else {
- let mut bind_visit_fields = TokenStream::new();
- let mut visit_fields = TokenStream::new();
-
- for (idx, ty) in fields.iter().enumerate() {
- let name = format!("_binding_{}", idx);
- let binding = Ident::new(&name, Span::call_site());
-
- bind_visit_fields.extend(quote! {
- #binding,
- });
-
- let borrowed_binding = Borrowed(quote!(#binding));
-
- visit_fields.extend(
- visit(ty, &s.features, defs, &borrowed_binding)
- .unwrap_or_else(|| noop_visit(&borrowed_binding)),
- );
-
- visit_fields.extend(quote!(;));
- }
-
- visit_variants.extend(quote! {
- #ty::#variant_ident(#bind_visit_fields) => {
- #visit_fields
- }
- });
- }
- }
-
- let nonexhaustive = if s.exhaustive {
- None
- } else {
- Some(quote!(_ => unreachable!()))
- };
-
- visit_impl.extend(quote! {
- match node {
- #visit_variants
- #nonexhaustive
- }
- });
- }
- Data::Struct(fields) => {
- for (field, ty) in fields {
- if let Type::Syn(ty) = ty {
- if ty == "Reserved" {
- continue;
- }
- }
-
- let id = Ident::new(&field, Span::call_site());
- let ref_toks = Owned(quote!(node.#id));
- let visit_field = visit(&ty, &s.features, defs, &ref_toks)
- .unwrap_or_else(|| noop_visit(&ref_toks));
- visit_impl.extend(quote! {
- #visit_field;
- });
- }
- }
- Data::Private => {
- if ty == "Ident" {
- visit_impl.extend(quote! {
- v.visit_span(&node.span());
- });
- }
- }
- }
-
- let ast_lifetime = if s.ident == "Span" {
- None
- } else {
- Some(quote!('ast))
- };
-
- traits.extend(quote! {
- fn #visit_fn(&mut self, i: &#ast_lifetime #ty) {
- #visit_fn(self, i)
- }
- });
-
- impls.extend(quote! {
- pub fn #visit_fn<'ast, V>(v: &mut V, node: &#ast_lifetime #ty)
- where
- V: Visit<'ast> + ?Sized,
- {
- #visit_impl
- }
- });
-}
-
-pub fn generate(defs: &Definitions) -> Result<()> {
- let (traits, impls) = gen::traverse(defs, node);
- let full_macro = full::get_macro();
- file::write(
- VISIT_SRC,
- quote! {
- #![allow(unused_variables)]
-
- use crate::*;
- #[cfg(any(feature = "full", feature = "derive"))]
- use crate::punctuated::Punctuated;
- use proc_macro2::Span;
- #[cfg(any(feature = "full", feature = "derive"))]
- use crate::gen::helper::visit::*;
-
- #full_macro
-
- #[cfg(any(feature = "full", feature = "derive"))]
- macro_rules! skip {
- ($($tt:tt)*) => {};
- }
-
- /// Syntax tree traversal to walk a shared borrow of a syntax tree.
- ///
- /// See the [module documentation] for details.
- ///
- /// [module documentation]: self
- ///
- /// *This trait is available if Syn is built with the `"visit"` feature.*
- pub trait Visit<'ast> {
- #traits
- }
-
- #impls
- },
- )?;
- Ok(())
-}
diff --git a/syn/codegen/src/visit_mut.rs b/syn/codegen/src/visit_mut.rs
deleted file mode 100644
index 71e56b3..0000000
--- a/syn/codegen/src/visit_mut.rs
+++ /dev/null
@@ -1,262 +0,0 @@
-use crate::operand::{Borrowed, Operand, Owned};
-use crate::{file, full, gen};
-use anyhow::Result;
-use proc_macro2::{Ident, Span, TokenStream};
-use quote::quote;
-use syn::Index;
-use syn_codegen::{Data, Definitions, Features, Node, Type};
-
-const VISIT_MUT_SRC: &str = "../src/gen/visit_mut.rs";
-
-fn simple_visit(item: &str, name: &Operand) -> TokenStream {
- let ident = gen::under_name(item);
- let method = Ident::new(&format!("visit_{}_mut", ident), Span::call_site());
- let name = name.ref_mut_tokens();
- quote! {
- v.#method(#name)
- }
-}
-
-fn noop_visit(name: &Operand) -> TokenStream {
- let name = name.tokens();
- quote! {
- skip!(#name)
- }
-}
-
-fn visit(
- ty: &Type,
- features: &Features,
- defs: &Definitions,
- name: &Operand,
-) -> Option<TokenStream> {
- match ty {
- Type::Box(t) => {
- let name = name.owned_tokens();
- visit(t, features, defs, &Owned(quote!(*#name)))
- }
- Type::Vec(t) => {
- let operand = Borrowed(quote!(it));
- let val = visit(t, features, defs, &operand)?;
- let name = name.ref_mut_tokens();
- Some(quote! {
- for it in #name {
- #val
- }
- })
- }
- Type::Punctuated(p) => {
- let operand = Borrowed(quote!(it));
- let val = visit(&p.element, features, defs, &operand)?;
- let name = name.ref_mut_tokens();
- Some(quote! {
- for el in Punctuated::pairs_mut(#name) {
- let (it, p) = el.into_tuple();
- #val;
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- })
- }
- Type::Option(t) => {
- let it = Borrowed(quote!(it));
- let val = visit(t, features, defs, &it)?;
- let name = name.owned_tokens();
- Some(quote! {
- if let Some(it) = &mut #name {
- #val
- }
- })
- }
- Type::Tuple(t) => {
- let mut code = TokenStream::new();
- for (i, elem) in t.iter().enumerate() {
- let name = name.tokens();
- let i = Index::from(i);
- let it = Owned(quote!((#name).#i));
- let val = visit(elem, features, defs, &it).unwrap_or_else(|| noop_visit(&it));
- code.extend(val);
- code.extend(quote!(;));
- }
- Some(code)
- }
- Type::Token(t) => {
- let name = name.tokens();
- let repr = &defs.tokens[t];
- let is_keyword = repr.chars().next().unwrap().is_alphabetic();
- let spans = if is_keyword {
- quote!(span)
- } else {
- quote!(spans)
- };
- Some(quote! {
- tokens_helper(v, &mut #name.#spans)
- })
- }
- Type::Group(_) => {
- let name = name.tokens();
- Some(quote! {
- tokens_helper(v, &mut #name.span)
- })
- }
- Type::Syn(t) => {
- fn requires_full(features: &Features) -> bool {
- features.any.contains("full") && features.any.len() == 1
- }
- let mut res = simple_visit(t, name);
- let target = defs.types.iter().find(|ty| ty.ident == *t).unwrap();
- if requires_full(&target.features) && !requires_full(features) {
- res = quote!(full!(#res));
- }
- Some(res)
- }
- Type::Ext(t) if gen::TERMINAL_TYPES.contains(&&t[..]) => Some(simple_visit(t, name)),
- Type::Ext(_) | Type::Std(_) => None,
- }
-}
-
-fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Definitions) {
- let under_name = gen::under_name(&s.ident);
- let ty = Ident::new(&s.ident, Span::call_site());
- let visit_mut_fn = Ident::new(&format!("visit_{}_mut", under_name), Span::call_site());
-
- let mut visit_mut_impl = TokenStream::new();
-
- match &s.data {
- Data::Enum(variants) => {
- let mut visit_mut_variants = TokenStream::new();
-
- for (variant, fields) in variants {
- let variant_ident = Ident::new(variant, Span::call_site());
-
- if fields.is_empty() {
- visit_mut_variants.extend(quote! {
- #ty::#variant_ident => {}
- });
- } else {
- let mut bind_visit_mut_fields = TokenStream::new();
- let mut visit_mut_fields = TokenStream::new();
-
- for (idx, ty) in fields.iter().enumerate() {
- let name = format!("_binding_{}", idx);
- let binding = Ident::new(&name, Span::call_site());
-
- bind_visit_mut_fields.extend(quote! {
- #binding,
- });
-
- let borrowed_binding = Borrowed(quote!(#binding));
-
- visit_mut_fields.extend(
- visit(ty, &s.features, defs, &borrowed_binding)
- .unwrap_or_else(|| noop_visit(&borrowed_binding)),
- );
-
- visit_mut_fields.extend(quote!(;));
- }
-
- visit_mut_variants.extend(quote! {
- #ty::#variant_ident(#bind_visit_mut_fields) => {
- #visit_mut_fields
- }
- });
- }
- }
-
- let nonexhaustive = if s.exhaustive {
- None
- } else {
- Some(quote!(_ => unreachable!()))
- };
-
- visit_mut_impl.extend(quote! {
- match node {
- #visit_mut_variants
- #nonexhaustive
- }
- });
- }
- Data::Struct(fields) => {
- for (field, ty) in fields {
- if let Type::Syn(ty) = ty {
- if ty == "Reserved" {
- continue;
- }
- }
-
- let id = Ident::new(&field, Span::call_site());
- let ref_toks = Owned(quote!(node.#id));
- let visit_mut_field = visit(&ty, &s.features, defs, &ref_toks)
- .unwrap_or_else(|| noop_visit(&ref_toks));
- visit_mut_impl.extend(quote! {
- #visit_mut_field;
- });
- }
- }
- Data::Private => {
- if ty == "Ident" {
- visit_mut_impl.extend(quote! {
- let mut span = node.span();
- v.visit_span_mut(&mut span);
- node.set_span(span);
- });
- }
- }
- }
-
- traits.extend(quote! {
- fn #visit_mut_fn(&mut self, i: &mut #ty) {
- #visit_mut_fn(self, i)
- }
- });
-
- impls.extend(quote! {
- pub fn #visit_mut_fn<V>(v: &mut V, node: &mut #ty)
- where
- V: VisitMut + ?Sized,
- {
- #visit_mut_impl
- }
- });
-}
-
-pub fn generate(defs: &Definitions) -> Result<()> {
- let (traits, impls) = gen::traverse(defs, node);
- let full_macro = full::get_macro();
- file::write(
- VISIT_MUT_SRC,
- quote! {
- #![allow(unused_variables)]
-
- use crate::*;
- #[cfg(any(feature = "full", feature = "derive"))]
- use crate::punctuated::Punctuated;
- use proc_macro2::Span;
- #[cfg(any(feature = "full", feature = "derive"))]
- use crate::gen::helper::visit_mut::*;
-
- #full_macro
-
- #[cfg(any(feature = "full", feature = "derive"))]
- macro_rules! skip {
- ($($tt:tt)*) => {};
- }
-
- /// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in
- /// place.
- ///
- /// See the [module documentation] for details.
- ///
- /// [module documentation]: self
- ///
- /// *This trait is available if Syn is built with the `"visit-mut"` feature.*
- pub trait VisitMut {
- #traits
- }
-
- #impls
- },
- )?;
- Ok(())
-}
diff --git a/syn/dev/Cargo.toml b/syn/dev/Cargo.toml
deleted file mode 100644
index 79486c1..0000000
--- a/syn/dev/Cargo.toml
+++ /dev/null
@@ -1,22 +0,0 @@
-[package]
-name = "syn-dev"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[lib]
-path = "parse.rs"
-proc-macro = true
-
-[[bin]]
-path = "main.rs"
-name = "syn-dev"
-
-[dependencies]
-quote = "1.0"
-
-[dependencies.syn]
-path = ".."
-default-features = false
-features = ["parsing", "full", "extra-traits", "proc-macro"]
diff --git a/syn/dev/README.md b/syn/dev/README.md
deleted file mode 100644
index 91b9846..0000000
--- a/syn/dev/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-A little project skeleton for troubleshooting Syn's parsers during development,
-especially when adding support for new Rust syntax.
-
-Place a sample of the syntax you are working on into main.rs and then run `cargo
-check` to try parsing it, revealing the resulting syntax tree or else showing
-the position and error message if the input fails to parse.
diff --git a/syn/dev/main.rs b/syn/dev/main.rs
deleted file mode 100644
index eb67546..0000000
--- a/syn/dev/main.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-syn_dev::r#mod! {
- // Write Rust code here and run `cargo check` to have Syn parse it.
-
-}
diff --git a/syn/dev/parse.rs b/syn/dev/parse.rs
deleted file mode 100644
index 2a92550..0000000
--- a/syn/dev/parse.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-extern crate proc_macro;
-
-use proc_macro::TokenStream;
-use quote::quote;
-use syn::File;
-
-#[proc_macro]
-pub fn r#mod(input: TokenStream) -> TokenStream {
- let compile_error = syn::parse::<File>(input)
- .map(|file| println!("{:#?}", file))
- .map_err(|err| err.to_compile_error())
- .err();
-
- TokenStream::from(quote! {
- #compile_error
- fn main() {}
- })
-}
diff --git a/syn/examples/README.md b/syn/examples/README.md
deleted file mode 100644
index fdd69d6..0000000
--- a/syn/examples/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-### [`dump-syntax`](dump-syntax)
-
-Little utility to parse a Rust source file into a `syn::File` and print out a
-debug representation of the syntax tree.
-
-### [`heapsize`](heapsize)
-
-An example implementation of a derive macro that generates trait impls.
-
-### [`lazy-static`](lazy-static)
-
-An example of parsing a custom syntax within a `functionlike!(...)` procedural
-macro. Demonstrates how to trigger custom warnings and error messages on
-individual tokens of the input.
-
-### [`trace-var`](trace-var)
-
-An attribute procedural macro that uses a syntax tree traversal to transform
-certain syntax tree nodes in a function body.
diff --git a/syn/examples/dump-syntax/Cargo.toml b/syn/examples/dump-syntax/Cargo.toml
deleted file mode 100644
index 0bc9f62..0000000
--- a/syn/examples/dump-syntax/Cargo.toml
+++ /dev/null
@@ -1,17 +0,0 @@
-[package]
-name = "dump-syntax"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[dependencies]
-colored = "1.7"
-proc-macro2 = { version = "1.0", features = ["span-locations"] }
-
-[dependencies.syn]
-path = "../.."
-default-features = false
-features = ["parsing", "full", "extra-traits"]
-
-[workspace]
diff --git a/syn/examples/dump-syntax/README.md b/syn/examples/dump-syntax/README.md
deleted file mode 100644
index 37c84d8..0000000
--- a/syn/examples/dump-syntax/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-Parse a Rust source file into a `syn::File` and print out a debug representation
-of the syntax tree.
-
-Use the following command from this directory to test this program by running it
-on its own source code:
-
-```
-cargo run -- src/main.rs
-```
-
-The output will begin with:
-
-```
-File {
- shebang: None,
- attrs: [
- Attribute {
- pound_token: Pound,
- style: Inner(
- Bang
- ),
- bracket_token: Bracket,
- path: Path {
- leading_colon: None,
- segments: [
- ...
-}
-```
diff --git a/syn/examples/dump-syntax/src/main.rs b/syn/examples/dump-syntax/src/main.rs
deleted file mode 100644
index 240b7a2..0000000
--- a/syn/examples/dump-syntax/src/main.rs
+++ /dev/null
@@ -1,149 +0,0 @@
-//! Parse a Rust source file into a `syn::File` and print out a debug
-//! representation of the syntax tree.
-//!
-//! Use the following command from this directory to test this program by
-//! running it on its own source code:
-//!
-//! cargo run -- src/main.rs
-//!
-//! The output will begin with:
-//!
-//! File {
-//! shebang: None,
-//! attrs: [
-//! Attribute {
-//! pound_token: Pound,
-//! style: Inner(
-//! ...
-//! }
-
-use std::borrow::Cow;
-use std::env;
-use std::ffi::OsStr;
-use std::fmt::{self, Display};
-use std::fs;
-use std::io::{self, Write};
-use std::path::{Path, PathBuf};
-use std::process;
-
-use colored::Colorize;
-
-enum Error {
- IncorrectUsage,
- ReadFile(io::Error),
- ParseFile {
- error: syn::Error,
- filepath: PathBuf,
- source_code: String,
- },
-}
-
-impl Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- use self::Error::*;
-
- match self {
- IncorrectUsage => write!(f, "Usage: dump-syntax path/to/filename.rs"),
- ReadFile(error) => write!(f, "Unable to read file: {}", error),
- ParseFile {
- error,
- filepath,
- source_code,
- } => render_location(f, error, filepath, source_code),
- }
- }
-}
-
-fn main() {
- if let Err(error) = try_main() {
- let _ = writeln!(io::stderr(), "{}", error);
- process::exit(1);
- }
-}
-
-fn try_main() -> Result<(), Error> {
- let mut args = env::args_os();
- let _ = args.next(); // executable name
-
- let filepath = match (args.next(), args.next()) {
- (Some(arg), None) => PathBuf::from(arg),
- _ => return Err(Error::IncorrectUsage),
- };
-
- let code = fs::read_to_string(&filepath).map_err(Error::ReadFile)?;
- let syntax = syn::parse_file(&code).map_err({
- |error| Error::ParseFile {
- error,
- filepath,
- source_code: code,
- }
- })?;
- println!("{:#?}", syntax);
-
- Ok(())
-}
-
-// Render a rustc-style error message, including colors.
-//
-// error: Syn unable to parse file
-// --> main.rs:40:17
-// |
-// 40 | fn fmt(&self formatter: &mut fmt::Formatter) -> fmt::Result {
-// | ^^^^^^^^^ expected `,`
-//
-fn render_location(
- formatter: &mut fmt::Formatter,
- err: &syn::Error,
- filepath: &Path,
- code: &str,
-) -> fmt::Result {
- let start = err.span().start();
- let mut end = err.span().end();
-
- if start.line == end.line && start.column == end.column {
- return render_fallback(formatter, err);
- }
-
- let code_line = match code.lines().nth(start.line - 1) {
- Some(line) => line,
- None => return render_fallback(formatter, err),
- };
-
- if end.line > start.line {
- end.line = start.line;
- end.column = code_line.len();
- }
-
- let filename = filepath
- .file_name()
- .map(OsStr::to_string_lossy)
- .unwrap_or(Cow::Borrowed("main.rs"));
-
- write!(
- formatter,
- "\n\
- {error}{header}\n\
- {indent}{arrow} {filename}:{linenum}:{colnum}\n\
- {indent} {pipe}\n\
- {label} {pipe} {code}\n\
- {indent} {pipe} {offset}{underline} {message}\n\
- ",
- error = "error".red().bold(),
- header = ": Syn unable to parse file".bold(),
- indent = " ".repeat(start.line.to_string().len()),
- arrow = "-->".blue().bold(),
- filename = filename,
- linenum = start.line,
- colnum = start.column,
- pipe = "|".blue().bold(),
- label = start.line.to_string().blue().bold(),
- code = code_line.trim_end(),
- offset = " ".repeat(start.column),
- underline = "^".repeat(end.column - start.column).red().bold(),
- message = err.to_string().red(),
- )
-}
-
-fn render_fallback(formatter: &mut fmt::Formatter, err: &syn::Error) -> fmt::Result {
- write!(formatter, "Unable to parse file: {}", err)
-}
diff --git a/syn/examples/heapsize/Cargo.toml b/syn/examples/heapsize/Cargo.toml
deleted file mode 100644
index 9b19214..0000000
--- a/syn/examples/heapsize/Cargo.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[workspace]
-members = ["example", "heapsize", "heapsize_derive"]
diff --git a/syn/examples/heapsize/README.md b/syn/examples/heapsize/README.md
deleted file mode 100644
index e789559..0000000
--- a/syn/examples/heapsize/README.md
+++ /dev/null
@@ -1,72 +0,0 @@
-A derive macro that generates trait impls.
-
-- [`heapsize/src/lib.rs`](heapsize/src/lib.rs)
-- [`heapsize_derive/src/lib.rs`](heapsize_derive/src/lib.rs)
-- [`example/src/main.rs`](example/src/main.rs)
-
-We are deriving the `HeapSize` trait which computes an estimate of the amount of
-heap memory owned by a value.
-
-```rust
-pub trait HeapSize {
- /// Total number of bytes of heap memory owned by `self`.
- fn heap_size_of_children(&self) -> usize;
-}
-```
-
-The derive macro allows users to write `#[derive(HeapSize)]` on data structures
-in their program.
-
-```rust
-#[derive(HeapSize)]
-struct Demo<'a, T: ?Sized> {
- a: Box<T>,
- b: u8,
- c: &'a str,
- d: String,
-}
-```
-
-The trait impl generated by the derive macro here would look like:
-
-```rust
-impl<'a, T: ?Sized + heapsize::HeapSize> heapsize::HeapSize for Demo<'a, T> {
- fn heap_size_of_children(&self) -> usize {
- 0 + heapsize::HeapSize::heap_size_of_children(&self.a)
- + heapsize::HeapSize::heap_size_of_children(&self.b)
- + heapsize::HeapSize::heap_size_of_children(&self.c)
- + heapsize::HeapSize::heap_size_of_children(&self.d)
- }
-}
-```
-
-The implementation of `heapsize_derive` demonstrates some attention to "spans"
-of error messages. For each subexpression in the generated code we apply the
-span of the input fragment under which we would want to trigger a compiler error
-if the subexpression fails to compile. In this example, each recursive call to
-`heap_size_of_children` is associated with the span of the corresponding struct
-field. Thus we get errors in the right place if any of the field types do not
-implement the `HeapSize` trait.
-
-```
-error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
- --> src/main.rs:7:5
- |
-7 | bad: std::thread::Thread,
- | ^^^ the trait `HeapSize` is not implemented for `std::thread::Thread`
-```
-
-Some unstable APIs in the `proc-macro2` crate let us improve this further by
-joining together the span of the field name and the field type. There is no
-difference in our code &mdash; everything is as shown in this directory &mdash;
-but building the example crate with `cargo build` shows errors like the one
-above and building with `RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build`
-is able to show errors like the following.
-
-```
-error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
- --> src/main.rs:7:5
- |
-7 | bad: std::thread::Thread,
- | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `std::thread::Thread`
-```
diff --git a/syn/examples/heapsize/example/Cargo.toml b/syn/examples/heapsize/example/Cargo.toml
deleted file mode 100644
index 85c7699..0000000
--- a/syn/examples/heapsize/example/Cargo.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-name = "heapsize_example"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[dependencies]
-heapsize = { path = "../heapsize" }
diff --git a/syn/examples/heapsize/example/src/main.rs b/syn/examples/heapsize/example/src/main.rs
deleted file mode 100644
index 9332b11..0000000
--- a/syn/examples/heapsize/example/src/main.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use heapsize::HeapSize;
-
-#[derive(HeapSize)]
-struct Demo<'a, T: ?Sized> {
- a: Box<T>,
- b: u8,
- c: &'a str,
- d: String,
-}
-
-fn main() {
- let demo = Demo {
- a: b"bytestring".to_vec().into_boxed_slice(),
- b: 255,
- c: "&'static str",
- d: "String".to_owned(),
- };
-
- // 10 + 0 + 0 + 6 = 16
- println!(
- "heap size = {} + {} + {} + {} = {}",
- demo.a.heap_size_of_children(),
- demo.b.heap_size_of_children(),
- demo.c.heap_size_of_children(),
- demo.d.heap_size_of_children(),
- demo.heap_size_of_children()
- );
-}
diff --git a/syn/examples/heapsize/heapsize/Cargo.toml b/syn/examples/heapsize/heapsize/Cargo.toml
deleted file mode 100644
index 27bb954..0000000
--- a/syn/examples/heapsize/heapsize/Cargo.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-name = "heapsize"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[dependencies]
-heapsize_derive = { path = "../heapsize_derive" }
diff --git a/syn/examples/heapsize/heapsize/src/lib.rs b/syn/examples/heapsize/heapsize/src/lib.rs
deleted file mode 100644
index 30bb6d6..0000000
--- a/syn/examples/heapsize/heapsize/src/lib.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-use std::mem;
-
-pub use heapsize_derive::*;
-
-pub trait HeapSize {
- /// Total number of bytes of heap memory owned by `self`.
- ///
- /// Does not include the size of `self` itself, which may or may not be on
- /// the heap. Includes only children of `self`, meaning things pointed to by
- /// `self`.
- fn heap_size_of_children(&self) -> usize;
-}
-
-//
-// In a real version of this library there would be lots more impls here, but
-// here are some interesting ones.
-//
-
-impl HeapSize for u8 {
- /// A `u8` does not own any heap memory.
- fn heap_size_of_children(&self) -> usize {
- 0
- }
-}
-
-impl HeapSize for String {
- /// A `String` owns enough heap memory to hold its reserved capacity.
- fn heap_size_of_children(&self) -> usize {
- self.capacity()
- }
-}
-
-impl<T> HeapSize for Box<T>
-where
- T: ?Sized + HeapSize,
-{
- /// A `Box` owns however much heap memory was allocated to hold the value of
- /// type `T` that we placed on the heap, plus transitively however much `T`
- /// itself owns.
- fn heap_size_of_children(&self) -> usize {
- mem::size_of_val(&**self) + (**self).heap_size_of_children()
- }
-}
-
-impl<T> HeapSize for [T]
-where
- T: HeapSize,
-{
- /// Sum of heap memory owned by each element of a dynamically sized slice of
- /// `T`.
- fn heap_size_of_children(&self) -> usize {
- self.iter().map(HeapSize::heap_size_of_children).sum()
- }
-}
-
-impl<'a, T> HeapSize for &'a T
-where
- T: ?Sized,
-{
- /// A shared reference does not own heap memory.
- fn heap_size_of_children(&self) -> usize {
- 0
- }
-}
diff --git a/syn/examples/heapsize/heapsize_derive/Cargo.toml b/syn/examples/heapsize/heapsize_derive/Cargo.toml
deleted file mode 100644
index f4357b9..0000000
--- a/syn/examples/heapsize/heapsize_derive/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "heapsize_derive"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[lib]
-proc-macro = true
-
-[dependencies]
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = { path = "../../.." }
diff --git a/syn/examples/heapsize/heapsize_derive/src/lib.rs b/syn/examples/heapsize/heapsize_derive/src/lib.rs
deleted file mode 100644
index 9176b29..0000000
--- a/syn/examples/heapsize/heapsize_derive/src/lib.rs
+++ /dev/null
@@ -1,96 +0,0 @@
-extern crate proc_macro;
-
-use proc_macro2::TokenStream;
-use quote::{quote, quote_spanned};
-use syn::spanned::Spanned;
-use syn::{parse_macro_input, parse_quote, Data, DeriveInput, Fields, GenericParam, Generics, Index};
-
-#[proc_macro_derive(HeapSize)]
-pub fn derive_heap_size(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
- // Parse the input tokens into a syntax tree.
- let input = parse_macro_input!(input as DeriveInput);
-
- // Used in the quasi-quotation below as `#name`.
- let name = input.ident;
-
- // Add a bound `T: HeapSize` to every type parameter T.
- let generics = add_trait_bounds(input.generics);
- let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
-
- // Generate an expression to sum up the heap size of each field.
- let sum = heap_size_sum(&input.data);
-
- let expanded = quote! {
- // The generated impl.
- impl #impl_generics heapsize::HeapSize for #name #ty_generics #where_clause {
- fn heap_size_of_children(&self) -> usize {
- #sum
- }
- }
- };
-
- // Hand the output tokens back to the compiler.
- proc_macro::TokenStream::from(expanded)
-}
-
-// Add a bound `T: HeapSize` to every type parameter T.
-fn add_trait_bounds(mut generics: Generics) -> Generics {
- for param in &mut generics.params {
- if let GenericParam::Type(ref mut type_param) = *param {
- type_param.bounds.push(parse_quote!(heapsize::HeapSize));
- }
- }
- generics
-}
-
-// Generate an expression to sum up the heap size of each field.
-fn heap_size_sum(data: &Data) -> TokenStream {
- match *data {
- Data::Struct(ref data) => {
- match data.fields {
- Fields::Named(ref fields) => {
- // Expands to an expression like
- //
- // 0 + self.x.heap_size() + self.y.heap_size() + self.z.heap_size()
- //
- // but using fully qualified function call syntax.
- //
- // We take some care to use the span of each `syn::Field` as
- // the span of the corresponding `heap_size_of_children`
- // call. This way if one of the field types does not
- // implement `HeapSize` then the compiler's error message
- // underlines which field it is. An example is shown in the
- // readme of the parent directory.
- let recurse = fields.named.iter().map(|f| {
- let name = &f.ident;
- quote_spanned! {f.span()=>
- heapsize::HeapSize::heap_size_of_children(&self.#name)
- }
- });
- quote! {
- 0 #(+ #recurse)*
- }
- }
- Fields::Unnamed(ref fields) => {
- // Expands to an expression like
- //
- // 0 + self.0.heap_size() + self.1.heap_size() + self.2.heap_size()
- let recurse = fields.unnamed.iter().enumerate().map(|(i, f)| {
- let index = Index::from(i);
- quote_spanned! {f.span()=>
- heapsize::HeapSize::heap_size_of_children(&self.#index)
- }
- });
- quote! {
- 0 #(+ #recurse)*
- }
- }
- Fields::Unit => {
- // Unit structs cannot own more than 0 bytes of heap memory.
- quote!(0)
- }
- }
- }
- Data::Enum(_) | Data::Union(_) => unimplemented!(),
- }
-}
diff --git a/syn/examples/lazy-static/Cargo.toml b/syn/examples/lazy-static/Cargo.toml
deleted file mode 100644
index 586e547..0000000
--- a/syn/examples/lazy-static/Cargo.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[workspace]
-members = ["example", "lazy-static"]
diff --git a/syn/examples/lazy-static/README.md b/syn/examples/lazy-static/README.md
deleted file mode 100644
index bc64585..0000000
--- a/syn/examples/lazy-static/README.md
+++ /dev/null
@@ -1,42 +0,0 @@
-An example of parsing a custom syntax within a `functionlike!(...)` procedural
-macro. Demonstrates how to trigger custom warnings and error messages on
-individual tokens of the input.
-
-- [`lazy-static/src/lib.rs`](lazy-static/src/lib.rs)
-- [`example/src/main.rs`](example/src/main.rs)
-
-The library implements a `lazy_static!` macro similar to the one from the real
-[`lazy_static`](https://docs.rs/lazy_static/1.0.0/lazy_static/) crate on
-crates.io.
-
-```rust
-lazy_static! {
- static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap();
-}
-```
-
-Compile and run the example by doing `cargo run` in the directory of the
-`example` crate.
-
-The implementation shows how to trigger custom warnings and error messages on
-the macro input. For example if you try adding an uncreatively named `FOO` lazy
-static, the macro will scold you with the following warning.
-
-```
-warning: come on, pick a more creative name
- --> src/main.rs:10:16
- |
-10 | static ref FOO: String = "lazy_static".to_owned();
- | ^^^
-```
-
-And if you try to lazily initialize `() = ()`, the macro will outright refuse to
-compile it for you.
-
-```
-error: I can't think of a legitimate use for lazily initializing the value `()`
- --> src/main.rs:10:27
- |
-10 | static ref UNIT: () = ();
- | ^^
-```
diff --git a/syn/examples/lazy-static/example/Cargo.toml b/syn/examples/lazy-static/example/Cargo.toml
deleted file mode 100644
index 716b08c..0000000
--- a/syn/examples/lazy-static/example/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "example"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[dependencies]
-lazy_static = { path = "../lazy-static" }
-regex = "0.2"
diff --git a/syn/examples/lazy-static/example/src/main.rs b/syn/examples/lazy-static/example/src/main.rs
deleted file mode 100644
index c4f64af..0000000
--- a/syn/examples/lazy-static/example/src/main.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-use lazy_static::lazy_static;
-use regex::Regex;
-
-lazy_static! {
- static ref USERNAME: Regex = {
- println!("Compiling username regex...");
- Regex::new("^[a-z0-9_-]{3,16}$").unwrap()
- };
-}
-
-fn main() {
- println!("Let's validate some usernames.");
- validate("fergie");
- validate("will.i.am");
-}
-
-fn validate(name: &str) {
- // The USERNAME regex is compiled lazily the first time its value is accessed.
- println!("is_match({:?}): {}", name, USERNAME.is_match(name));
-}
diff --git a/syn/examples/lazy-static/lazy-static/Cargo.toml b/syn/examples/lazy-static/lazy-static/Cargo.toml
deleted file mode 100644
index bf65787..0000000
--- a/syn/examples/lazy-static/lazy-static/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "lazy_static"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[lib]
-proc-macro = true
-
-[dependencies]
-proc-macro2 = { version = "1.0", features = ["nightly"] }
-quote = "1.0"
-syn = { path = "../../../", features = ["full"] }
diff --git a/syn/examples/lazy-static/lazy-static/src/lib.rs b/syn/examples/lazy-static/lazy-static/src/lib.rs
deleted file mode 100644
index 254ca72..0000000
--- a/syn/examples/lazy-static/lazy-static/src/lib.rs
+++ /dev/null
@@ -1,143 +0,0 @@
-#![recursion_limit = "128"]
-#![feature(proc_macro_diagnostic)]
-
-extern crate proc_macro;
-use self::proc_macro::TokenStream;
-
-use quote::{quote, quote_spanned};
-use syn::parse::{Parse, ParseStream, Result};
-use syn::spanned::Spanned;
-use syn::{parse_macro_input, Expr, Ident, Token, Type, Visibility};
-
-/// Parses the following syntax, which aligns with the input of the real
-/// `lazy_static` crate.
-///
-/// lazy_static! {
-/// $VISIBILITY static ref $NAME: $TYPE = $EXPR;
-/// }
-///
-/// For example:
-///
-/// lazy_static! {
-/// static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap();
-/// }
-struct LazyStatic {
- visibility: Visibility,
- name: Ident,
- ty: Type,
- init: Expr,
-}
-
-impl Parse for LazyStatic {
- fn parse(input: ParseStream) -> Result<Self> {
- let visibility: Visibility = input.parse()?;
- input.parse::<Token![static]>()?;
- input.parse::<Token![ref]>()?;
- let name: Ident = input.parse()?;
- input.parse::<Token![:]>()?;
- let ty: Type = input.parse()?;
- input.parse::<Token![=]>()?;
- let init: Expr = input.parse()?;
- input.parse::<Token![;]>()?;
- Ok(LazyStatic {
- visibility,
- name,
- ty,
- init,
- })
- }
-}
-
-#[proc_macro]
-pub fn lazy_static(input: TokenStream) -> TokenStream {
- let LazyStatic {
- visibility,
- name,
- ty,
- init,
- } = parse_macro_input!(input as LazyStatic);
-
- // The warning looks like this.
- //
- // warning: come on, pick a more creative name
- // --> src/main.rs:10:16
- // |
- // 10 | static ref FOO: String = "lazy_static".to_owned();
- // | ^^^
- if name == "FOO" {
- name.span()
- .unwrap()
- .warning("come on, pick a more creative name")
- .emit();
- }
-
- // The error looks like this.
- //
- // error: I can't think of a legitimate use for lazily initializing the value `()`
- // --> src/main.rs:10:27
- // |
- // 10 | static ref UNIT: () = ();
- // | ^^
- if let Expr::Tuple(ref init) = init {
- if init.elems.is_empty() {
- init.span()
- .unwrap()
- .error("I can't think of a legitimate use for lazily initializing the value `()`")
- .emit();
- return TokenStream::new();
- }
- }
-
- // Assert that the static type implements Sync. If not, user sees an error
- // message like the following. We span this assertion with the field type's
- // line/column so that the error message appears in the correct place.
- //
- // error[E0277]: the trait bound `*const (): std::marker::Sync` is not satisfied
- // --> src/main.rs:10:21
- // |
- // 10 | static ref PTR: *const () = &();
- // | ^^^^^^^^^ `*const ()` cannot be shared between threads safely
- let assert_sync = quote_spanned! {ty.span()=>
- struct _AssertSync where #ty: std::marker::Sync;
- };
-
- // Check for Sized. Not vital to check here, but the error message is less
- // confusing this way than if they get a Sized error in one of our
- // implementation details where it assumes Sized.
- //
- // error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied
- // --> src/main.rs:10:19
- // |
- // 10 | static ref A: str = "";
- // | ^^^ `str` does not have a constant size known at compile-time
- let assert_sized = quote_spanned! {ty.span()=>
- struct _AssertSized where #ty: std::marker::Sized;
- };
-
- let init_ptr = quote_spanned! {init.span()=>
- Box::into_raw(Box::new(#init))
- };
-
- let expanded = quote! {
- #visibility struct #name;
-
- impl std::ops::Deref for #name {
- type Target = #ty;
-
- fn deref(&self) -> &#ty {
- #assert_sync
- #assert_sized
-
- static ONCE: std::sync::Once = std::sync::Once::new();
- static mut VALUE: *mut #ty = 0 as *mut #ty;
-
- unsafe {
- ONCE.call_once(|| VALUE = #init_ptr);
- &*VALUE
- }
- }
- }
- };
-
- TokenStream::from(expanded)
-}
diff --git a/syn/examples/trace-var/Cargo.toml b/syn/examples/trace-var/Cargo.toml
deleted file mode 100644
index b54454d..0000000
--- a/syn/examples/trace-var/Cargo.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[workspace]
-members = ["example", "trace-var"]
diff --git a/syn/examples/trace-var/README.md b/syn/examples/trace-var/README.md
deleted file mode 100644
index b93fae2..0000000
--- a/syn/examples/trace-var/README.md
+++ /dev/null
@@ -1,61 +0,0 @@
-An example of an attribute procedural macro. The `#[trace_var(...)]` attribute
-prints the value of the given variables each time they are reassigned.
-
-- [`trace-var/src/lib.rs`](trace-var/src/lib.rs)
-- [`example/src/main.rs`](example/src/main.rs)
-
-Consider the following factorial implementation.
-
-```rust
-#[trace_var(p, n)]
-fn factorial(mut n: u64) -> u64 {
- let mut p = 1;
- while n > 1 {
- p *= n;
- n -= 1;
- }
- p
-}
-```
-
-Invoking this with `factorial(8)` prints all the values of `p` and `n` during
-the execution of the function.
-
-```
-p = 1
-p = 8
-n = 7
-p = 56
-n = 6
-p = 336
-n = 5
-p = 1680
-n = 4
-p = 6720
-n = 3
-p = 20160
-n = 2
-p = 40320
-n = 1
-```
-
-The procedural macro uses a syntax tree [`Fold`] to rewrite every `let`
-statement and assignment expression in the following way:
-
-[`Fold`]: https://docs.rs/syn/1.0/syn/fold/trait.Fold.html
-
-```rust
-// Before
-let VAR = INIT;
-
-// After
-let VAR = { let VAR = INIT; println!("VAR = {:?}", VAR); VAR };
-```
-
-```rust
-// Before
-VAR = INIT
-
-// After
-{ VAR = INIT; println!("VAR = {:?}", VAR); }
-```
diff --git a/syn/examples/trace-var/example/Cargo.toml b/syn/examples/trace-var/example/Cargo.toml
deleted file mode 100644
index d2ad650..0000000
--- a/syn/examples/trace-var/example/Cargo.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-name = "example"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[dependencies]
-trace-var = { path = "../trace-var" }
diff --git a/syn/examples/trace-var/example/src/main.rs b/syn/examples/trace-var/example/src/main.rs
deleted file mode 100644
index da2c10b..0000000
--- a/syn/examples/trace-var/example/src/main.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-use trace_var::trace_var;
-
-fn main() {
- println!("{}", factorial(8));
-}
-
-#[trace_var(p, n)]
-fn factorial(mut n: u64) -> u64 {
- let mut p = 1;
- while n > 1 {
- p *= n;
- n -= 1;
- }
- p
-}
diff --git a/syn/examples/trace-var/trace-var/Cargo.toml b/syn/examples/trace-var/trace-var/Cargo.toml
deleted file mode 100644
index 72f56e9..0000000
--- a/syn/examples/trace-var/trace-var/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "trace-var"
-version = "0.0.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-publish = false
-
-[lib]
-proc-macro = true
-
-[dependencies]
-proc-macro2 = { version = "1.0", features = ["nightly"] }
-quote = "1.0"
-syn = { path = "../../../", features = ["full", "fold"] }
diff --git a/syn/examples/trace-var/trace-var/src/lib.rs b/syn/examples/trace-var/trace-var/src/lib.rs
deleted file mode 100644
index 0ecfb47..0000000
--- a/syn/examples/trace-var/trace-var/src/lib.rs
+++ /dev/null
@@ -1,180 +0,0 @@
-extern crate proc_macro;
-use self::proc_macro::TokenStream;
-
-use quote::{quote, ToTokens};
-use std::collections::HashSet as Set;
-use syn::fold::{self, Fold};
-use syn::parse::{Parse, ParseStream, Result};
-use syn::punctuated::Punctuated;
-use syn::{parse_macro_input, parse_quote, Expr, Ident, ItemFn, Local, Pat, Stmt, Token};
-
-/// Parses a list of variable names separated by commas.
-///
-/// a, b, c
-///
-/// This is how the compiler passes in arguments to our attribute -- it is
-/// everything inside the delimiters after the attribute name.
-///
-/// #[trace_var(a, b, c)]
-/// ^^^^^^^
-struct Args {
- vars: Set<Ident>,
-}
-
-impl Parse for Args {
- fn parse(input: ParseStream) -> Result<Self> {
- let vars = Punctuated::<Ident, Token![,]>::parse_terminated(input)?;
- Ok(Args {
- vars: vars.into_iter().collect(),
- })
- }
-}
-
-impl Args {
- /// Determines whether the given `Expr` is a path referring to one of the
- /// variables we intend to print. Expressions are used as the left-hand side
- /// of the assignment operator.
- fn should_print_expr(&self, e: &Expr) -> bool {
- match *e {
- Expr::Path(ref e) => {
- if e.path.leading_colon.is_some() {
- false
- } else if e.path.segments.len() != 1 {
- false
- } else {
- let first = e.path.segments.first().unwrap();
- self.vars.contains(&first.ident) && first.arguments.is_empty()
- }
- }
- _ => false,
- }
- }
-
- /// Determines whether the given `Pat` is an identifier equal to one of the
- /// variables we intend to print. Patterns are used as the left-hand side of
- /// a `let` binding.
- fn should_print_pat(&self, p: &Pat) -> bool {
- match p {
- Pat::Ident(ref p) => self.vars.contains(&p.ident),
- _ => false,
- }
- }
-
- /// Produces an expression that assigns the right-hand side to the left-hand
- /// side and then prints the value.
- ///
- /// // Before
- /// VAR = INIT
- ///
- /// // After
- /// { VAR = INIT; println!("VAR = {:?}", VAR); }
- fn assign_and_print(&mut self, left: Expr, op: &dyn ToTokens, right: Expr) -> Expr {
- let right = fold::fold_expr(self, right);
- parse_quote!({
- #left #op #right;
- println!(concat!(stringify!(#left), " = {:?}"), #left);
- })
- }
-
- /// Produces a let-binding that assigns the right-hand side to the left-hand
- /// side and then prints the value.
- ///
- /// // Before
- /// let VAR = INIT;
- ///
- /// // After
- /// let VAR = { let VAR = INIT; println!("VAR = {:?}", VAR); VAR };
- fn let_and_print(&mut self, local: Local) -> Stmt {
- let Local { pat, init, .. } = local;
- let init = self.fold_expr(*init.unwrap().1);
- let ident = match pat {
- Pat::Ident(ref p) => &p.ident,
- _ => unreachable!(),
- };
- parse_quote! {
- let #pat = {
- #[allow(unused_mut)]
- let #pat = #init;
- println!(concat!(stringify!(#ident), " = {:?}"), #ident);
- #ident
- };
- }
- }
-}
-
-/// The `Fold` trait is a way to traverse an owned syntax tree and replace some
-/// of its nodes.
-///
-/// Syn provides two other syntax tree traversal traits: `Visit` which walks a
-/// shared borrow of a syntax tree, and `VisitMut` which walks an exclusive
-/// borrow of a syntax tree and can mutate it in place.
-///
-/// All three traits have a method corresponding to each type of node in Syn's
-/// syntax tree. All of these methods have default no-op implementations that
-/// simply recurse on any child nodes. We can override only those methods for
-/// which we want non-default behavior. In this case the traversal needs to
-/// transform `Expr` and `Stmt` nodes.
-impl Fold for Args {
- fn fold_expr(&mut self, e: Expr) -> Expr {
- match e {
- Expr::Assign(e) => {
- if self.should_print_expr(&e.left) {
- self.assign_and_print(*e.left, &e.eq_token, *e.right)
- } else {
- Expr::Assign(fold::fold_expr_assign(self, e))
- }
- }
- Expr::AssignOp(e) => {
- if self.should_print_expr(&e.left) {
- self.assign_and_print(*e.left, &e.op, *e.right)
- } else {
- Expr::AssignOp(fold::fold_expr_assign_op(self, e))
- }
- }
- _ => fold::fold_expr(self, e),
- }
- }
-
- fn fold_stmt(&mut self, s: Stmt) -> Stmt {
- match s {
- Stmt::Local(s) => {
- if s.init.is_some() && self.should_print_pat(&s.pat) {
- self.let_and_print(s)
- } else {
- Stmt::Local(fold::fold_local(self, s))
- }
- }
- _ => fold::fold_stmt(self, s),
- }
- }
-}
-
-/// Attribute to print the value of the given variables each time they are
-/// reassigned.
-///
-/// # Example
-///
-/// ```
-/// #[trace_var(p, n)]
-/// fn factorial(mut n: u64) -> u64 {
-/// let mut p = 1;
-/// while n > 1 {
-/// p *= n;
-/// n -= 1;
-/// }
-/// p
-/// }
-/// ```
-#[proc_macro_attribute]
-pub fn trace_var(args: TokenStream, input: TokenStream) -> TokenStream {
- let input = parse_macro_input!(input as ItemFn);
-
- // Parse the list of variables the user wanted to print.
- let mut args = parse_macro_input!(args as Args);
-
- // Use a syntax tree traversal to transform the function body.
- let output = args.fold_item_fn(input);
-
- // Hand the resulting function body back to the compiler.
- TokenStream::from(quote!(#output))
-}
diff --git a/syn/json/Cargo.toml b/syn/json/Cargo.toml
deleted file mode 100644
index 77104dc..0000000
--- a/syn/json/Cargo.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-[package]
-name = "syn-codegen"
-version = "0.1.0"
-authors = ["David Tolnay <dtolnay@gmail.com>"]
-edition = "2018"
-license = "MIT OR Apache-2.0"
-description = "Syntax tree describing Syn's syntax tree"
-repository = "https://github.com/dtolnay/syn"
-documentation = "https://docs.rs/syn-codegen"
-categories = ["development-tools::procedural-macro-helpers"]
-
-[dependencies]
-indexmap = { version = "1.0", features = ["serde-1"] }
-semver = { version = "0.9", features = ["serde"] }
-serde = { version = "1.0.88", features = ["derive"] }
-
-[dev-dependencies]
-serde_json = "1.0"
diff --git a/syn/json/src/lib.rs b/syn/json/src/lib.rs
deleted file mode 100644
index e3546d9..0000000
--- a/syn/json/src/lib.rs
+++ /dev/null
@@ -1,214 +0,0 @@
-//! # Data structures that describe Syn's syntax tree.
-//!
-//! The Syn syntax tree is made up of more than 200 types. Occasionally it can
-//! come up that you need to implement some behavior across them all.
-//!
-//! - For example [the Rust integration for AST Explorer][astexplorer] wants to
-//! turn a syntax tree from Syn into a JavaScript value understood by the
-//! platform's existing cross-language syntax tree visualization code.
-//!
-//! [astexplorer]: https://astexplorer.net/#/gist/388150a52f74d45a355d2b5e865ded96/0c6d563f28d900472f699c21a1845ad20ae9927f
-//!
-//! - As another example from within Syn itself, the traits and implementations
-//! of the [`visit`], [`visit_mut`], and [`fold`] modules can be generated
-//! programmatically from a description of the syntax tree.
-//!
-//! [`visit`]: https://docs.rs/syn/1.0/syn/visit/index.html
-//! [`visit_mut`]: https://docs.rs/syn/1.0/syn/visit_mut/index.html
-//! [`fold`]: https://docs.rs/syn/1.0/syn/fold/index.html
-//!
-//! To make this type of code as easy as possible to implement in any language,
-//! every Syn release comes with a machine-readable description of that version
-//! of the syntax tree as a JSON file [syn.json]. This `syn-codegen` crate
-//! provides the canonical data structures for parsing and making use of the
-//! representation in syn.json from Rust code.
-//!
-//! [syn.json]: https://raw.githubusercontent.com/dtolnay/syn/master/syn.json
-//!
-//! ## Example
-//!
-//! ```
-//! use syn_codegen::Definitions;
-//!
-//! # const IGNORE: &str = stringify! {
-//! const SYN: &str = include_str!("syn.json");
-//! # };
-//! # const SYN: &str = include_str!("../../syn.json");
-//!
-//! fn main() {
-//! let defs: Definitions = serde_json::from_str(SYN).unwrap();
-//!
-//! for node in &defs.types {
-//! println!("syn::{}", node.ident);
-//! }
-//! }
-//! ```
-
-use indexmap::IndexMap;
-use semver::Version;
-use serde::{Deserialize, Deserializer, Serialize};
-
-use std::collections::{BTreeMap, BTreeSet};
-
-/// Top-level content of the syntax tree description.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-pub struct Definitions {
- /// The Syn version whose syntax tree is described by this data.
- pub version: Version,
-
- /// Syntax tree types defined by Syn.
- pub types: Vec<Node>,
-
- /// Token types defined by Syn (keywords as well as punctuation).
- ///
- /// The keys in the map are the Rust type name for the token. The values in
- /// the map are the printed token representation.
- ///
- /// These tokens are accessible in the Syn public API as `syn::token::#name`
- /// or alternatively `syn::Token![#repr]`.
- pub tokens: BTreeMap<String, String>,
-}
-
-/// Syntax tree type defined by Syn.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-pub struct Node {
- /// Name of the type.
- ///
- /// This type is accessible in the Syn public API as `syn::#name`.
- pub ident: String,
-
- /// Features behind which this type is cfg gated.
- pub features: Features,
-
- /// Content of the data structure.
- #[serde(
- flatten,
- skip_serializing_if = "is_private",
- deserialize_with = "private_if_absent"
- )]
- pub data: Data,
-
- #[serde(skip_serializing_if = "is_true", default = "bool_true")]
- pub exhaustive: bool,
-}
-
-/// Content of a syntax tree data structure.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-pub enum Data {
- /// This is an opaque type with no publicy accessible structure.
- Private,
-
- /// This type is a braced struct with named fields.
- #[serde(rename = "fields")]
- Struct(Fields),
-
- /// This type is an enum.
- #[serde(rename = "variants")]
- Enum(Variants),
-}
-
-/// Fields of a braced struct syntax tree node with named fields.
-///
-/// The keys in the map are the field names.
-pub type Fields = IndexMap<String, Type>;
-
-/// Variants of an enum syntax tree node.
-///
-/// The keys in the map are the variant names.
-///
-/// Variants are unit variants if they hold no data and tuple variants
-/// otherwise. The Syn syntax tree does not make use of braced variants.
-pub type Variants = IndexMap<String, Vec<Type>>;
-
-/// Type of a struct field or tuple variant field in the syntax tree.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(rename_all = "lowercase")]
-pub enum Type {
- /// Syntax tree type defined by Syn.
- ///
- /// This name will match the ident of some `Node`.
- Syn(String),
-
- /// Type defined by the Rust language or standard library.
- ///
- /// All such types used by Syn are accessible in the Rust prelude and can be
- /// used without a qualifying path in most Rust code.
- Std(String),
-
- /// Type defined by proc-macro2.
- ///
- /// The type is accessible in the proc-macro2 public API as
- /// `proc_macro2::#name`.
- #[serde(rename = "proc_macro2")]
- Ext(String),
-
- /// Keyword or punctuation token type defined by Syn.
- ///
- /// This name will match one of the keys in the `tokens` map.
- Token(String),
-
- /// Grouping token defined by Syn.
- ///
- /// The type is accessible in the Syn public API as `syn::token::#name`.
- Group(String),
-
- /// Punctuated list.
- ///
- /// This refers to `syn::punctuated::Punctuated<T, P>` with the specified
- /// element type and punctuation.
- Punctuated(Punctuated),
-
- /// `std::option::Option`
- Option(Box<Type>),
-
- /// `std::boxed::Box`
- Box(Box<Type>),
-
- /// `std::vec::Vec`
- Vec(Box<Type>),
-
- /// Rust tuple with two or more fields.
- Tuple(Vec<Type>),
-}
-
-/// Type of a punctuated list.
-///
-/// This refers to `syn::punctuated::Punctuated<#element, #punct>`.
-///
-/// The punct string will match one of the keys in the `tokens` map.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-pub struct Punctuated {
- pub element: Box<Type>,
- pub punct: String,
-}
-
-/// Features behind which a syntax tree type is cfg gated.
-#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
-pub struct Features {
- /// Type is accessible if at least one of these features is enabled against
- /// the Syn dependency.
- pub any: BTreeSet<String>,
-}
-
-fn is_private(data: &Data) -> bool {
- match data {
- Data::Private => true,
- Data::Struct(_) | Data::Enum(_) => false,
- }
-}
-
-fn private_if_absent<'de, D>(deserializer: D) -> Result<Data, D::Error>
-where
- D: Deserializer<'de>,
-{
- let option = Option::deserialize(deserializer)?;
- Ok(option.unwrap_or(Data::Private))
-}
-
-fn is_true(b: &bool) -> bool {
- *b
-}
-
-fn bool_true() -> bool {
- true
-}
diff --git a/syn/src/attr.rs b/syn/src/attr.rs
deleted file mode 100644
index a8e16ea..0000000
--- a/syn/src/attr.rs
+++ /dev/null
@@ -1,682 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-
-use std::iter;
-
-use proc_macro2::TokenStream;
-
-#[cfg(feature = "parsing")]
-use crate::parse::{Parse, ParseBuffer, ParseStream, Parser, Result};
-#[cfg(feature = "parsing")]
-use crate::punctuated::Pair;
-#[cfg(feature = "extra-traits")]
-use crate::tt::TokenStreamHelper;
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-
-ast_struct! {
- /// An attribute like `#[repr(transparent)]`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// <br>
- ///
- /// # Syntax
- ///
- /// Rust has six types of attributes.
- ///
- /// - Outer attributes like `#[repr(transparent)]`. These appear outside or
- /// in front of the item they describe.
- /// - Inner attributes like `#![feature(proc_macro)]`. These appear inside
- /// of the item they describe, usually a module.
- /// - Outer doc comments like `/// # Example`.
- /// - Inner doc comments like `//! Please file an issue`.
- /// - Outer block comments `/** # Example */`.
- /// - Inner block comments `/*! Please file an issue */`.
- ///
- /// The `style` field of type `AttrStyle` distinguishes whether an attribute
- /// is outer or inner. Doc comments and block comments are promoted to
- /// attributes, as this is how they are processed by the compiler and by
- /// `macro_rules!` macros.
- ///
- /// The `path` field gives the possibly colon-delimited path against which
- /// the attribute is resolved. It is equal to `"doc"` for desugared doc
- /// comments. The `tokens` field contains the rest of the attribute body as
- /// tokens.
- ///
- /// ```text
- /// #[derive(Copy)] #[crate::precondition x < 5]
- /// ^^^^^^~~~~~~ ^^^^^^^^^^^^^^^^^^^ ~~~~~
- /// path tokens path tokens
- /// ```
- ///
- /// <br>
- ///
- /// # Parsing from tokens to Attribute
- ///
- /// This type does not implement the [`Parse`] trait and thus cannot be
- /// parsed directly by [`ParseStream::parse`]. Instead use
- /// [`ParseStream::call`] with one of the two parser functions
- /// [`Attribute::parse_outer`] or [`Attribute::parse_inner`] depending on
- /// which you intend to parse.
- ///
- /// [`Parse`]: parse::Parse
- /// [`ParseStream::parse`]: parse::ParseBuffer::parse
- /// [`ParseStream::call`]: parse::ParseBuffer::call
- ///
- /// ```
- /// use syn::{Attribute, Ident, Result, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // Parses a unit struct with attributes.
- /// //
- /// // #[path = "s.tmpl"]
- /// // struct S;
- /// struct UnitStruct {
- /// attrs: Vec<Attribute>,
- /// struct_token: Token![struct],
- /// name: Ident,
- /// semi_token: Token![;],
- /// }
- ///
- /// impl Parse for UnitStruct {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// Ok(UnitStruct {
- /// attrs: input.call(Attribute::parse_outer)?,
- /// struct_token: input.parse()?,
- /// name: input.parse()?,
- /// semi_token: input.parse()?,
- /// })
- /// }
- /// }
- /// ```
- ///
- /// <p><br></p>
- ///
- /// # Parsing from Attribute to structured arguments
- ///
- /// The grammar of attributes in Rust is very flexible, which makes the
- /// syntax tree not that useful on its own. In particular, arguments of the
- /// attribute are held in an arbitrary `tokens: TokenStream`. Macros are
- /// expected to check the `path` of the attribute, decide whether they
- /// recognize it, and then parse the remaining tokens according to whatever
- /// grammar they wish to require for that kind of attribute.
- ///
- /// If the attribute you are parsing is expected to conform to the
- /// conventional structured form of attribute, use [`parse_meta()`] to
- /// obtain that structured representation. If the attribute follows some
- /// other grammar of its own, use [`parse_args()`] to parse that into the
- /// expected data structure.
- ///
- /// [`parse_meta()`]: Attribute::parse_meta
- /// [`parse_args()`]: Attribute::parse_args
- ///
- /// <p><br></p>
- ///
- /// # Doc comments
- ///
- /// The compiler transforms doc comments, such as `/// comment` and `/*!
- /// comment */`, into attributes before macros are expanded. Each comment is
- /// expanded into an attribute of the form `#[doc = r"comment"]`.
- ///
- /// As an example, the following `mod` items are expanded identically:
- ///
- /// ```
- /// # use syn::{ItemMod, parse_quote};
- /// let doc: ItemMod = parse_quote! {
- /// /// Single line doc comments
- /// /// We write so many!
- /// /**
- /// * Multi-line comments...
- /// * May span many lines
- /// */
- /// mod example {
- /// //! Of course, they can be inner too
- /// /*! And fit in a single line */
- /// }
- /// };
- /// let attr: ItemMod = parse_quote! {
- /// #[doc = r" Single line doc comments"]
- /// #[doc = r" We write so many!"]
- /// #[doc = r" Multi-line comments...
- /// May span many lines"]
- /// mod example {
- /// #![doc = r" Of course, they can be inner too"]
- /// #![doc = r" And fit in a single line "]
- /// }
- /// };
- /// assert_eq!(doc, attr);
- /// ```
- pub struct Attribute #manual_extra_traits {
- pub pound_token: Token![#],
- pub style: AttrStyle,
- pub bracket_token: token::Bracket,
- pub path: Path,
- pub tokens: TokenStream,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Attribute {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Attribute {
- fn eq(&self, other: &Self) -> bool {
- self.style == other.style
- && self.pound_token == other.pound_token
- && self.bracket_token == other.bracket_token
- && self.path == other.path
- && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens)
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Attribute {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- self.style.hash(state);
- self.pound_token.hash(state);
- self.bracket_token.hash(state);
- self.path.hash(state);
- TokenStreamHelper(&self.tokens).hash(state);
- }
-}
-
-impl Attribute {
- /// Parses the content of the attribute, consisting of the path and tokens,
- /// as a [`Meta`] if possible.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_meta(&self) -> Result<Meta> {
- fn clone_ident_segment(segment: &PathSegment) -> PathSegment {
- PathSegment {
- ident: segment.ident.clone(),
- arguments: PathArguments::None,
- }
- }
-
- let path = Path {
- leading_colon: self
- .path
- .leading_colon
- .as_ref()
- .map(|colon| Token![::](colon.spans)),
- segments: self
- .path
- .segments
- .pairs()
- .map(|pair| match pair {
- Pair::Punctuated(seg, punct) => {
- Pair::Punctuated(clone_ident_segment(seg), Token![::](punct.spans))
- }
- Pair::End(seg) => Pair::End(clone_ident_segment(seg)),
- })
- .collect(),
- };
-
- let parser = |input: ParseStream| parsing::parse_meta_after_path(path, input);
- parse::Parser::parse2(parser, self.tokens.clone())
- }
-
- /// Parse the arguments to the attribute as a syntax tree.
- ///
- /// This is similar to `syn::parse2::<T>(attr.tokens)` except that:
- ///
- /// - the surrounding delimiters are *not* included in the input to the
- /// parser; and
- /// - the error message has a more useful span when `tokens` is empty.
- ///
- /// ```text
- /// #[my_attr(value < 5)]
- /// ^^^^^^^^^ what gets parsed
- /// ```
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_args<T: Parse>(&self) -> Result<T> {
- self.parse_args_with(T::parse)
- }
-
- /// Parse the arguments to the attribute using the given parser.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_args_with<F: Parser>(&self, parser: F) -> Result<F::Output> {
- let parser = |input: ParseStream| {
- let args = enter_args(self, input)?;
- parse::parse_stream(parser, &args)
- };
- parser.parse2(self.tokens.clone())
- }
-
- /// Parses zero or more outer attributes from the stream.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_outer(input: ParseStream) -> Result<Vec<Self>> {
- let mut attrs = Vec::new();
- while input.peek(Token![#]) {
- attrs.push(input.call(parsing::single_parse_outer)?);
- }
- Ok(attrs)
- }
-
- /// Parses zero or more inner attributes from the stream.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_inner(input: ParseStream) -> Result<Vec<Self>> {
- let mut attrs = Vec::new();
- while input.peek(Token![#]) && input.peek2(Token![!]) {
- attrs.push(input.call(parsing::single_parse_inner)?);
- }
- Ok(attrs)
- }
-}
-
-#[cfg(feature = "parsing")]
-fn error_expected_args(attr: &Attribute) -> Error {
- let style = match attr.style {
- AttrStyle::Outer => "#",
- AttrStyle::Inner(_) => "#!",
- };
-
- let mut path = String::new();
- for segment in &attr.path.segments {
- if !path.is_empty() || attr.path.leading_colon.is_some() {
- path += "::";
- }
- path += &segment.ident.to_string();
- }
-
- let msg = format!("expected attribute arguments: {}[{}(...)]", style, path);
-
- #[cfg(feature = "printing")]
- return Error::new_spanned(attr, msg);
-
- #[cfg(not(feature = "printing"))]
- return Error::new(attr.bracket_token.span, msg);
-}
-
-#[cfg(feature = "parsing")]
-fn enter_args<'a>(attr: &Attribute, input: ParseStream<'a>) -> Result<ParseBuffer<'a>> {
- if input.is_empty() {
- return Err(error_expected_args(attr));
- };
-
- let content;
- if input.peek(token::Paren) {
- parenthesized!(content in input);
- } else if input.peek(token::Bracket) {
- bracketed!(content in input);
- } else if input.peek(token::Brace) {
- braced!(content in input);
- } else {
- return Err(input.error("unexpected token in attribute arguments"));
- }
-
- if input.is_empty() {
- Ok(content)
- } else {
- Err(input.error("unexpected token in attribute arguments"))
- }
-}
-
-ast_enum! {
- /// Distinguishes between attributes that decorate an item and attributes
- /// that are contained within an item.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Outer attributes
- ///
- /// - `#[repr(transparent)]`
- /// - `/// # Example`
- /// - `/** Please file an issue */`
- ///
- /// # Inner attributes
- ///
- /// - `#![feature(proc_macro)]`
- /// - `//! # Example`
- /// - `/*! Please file an issue */`
- #[cfg_attr(feature = "clone-impls", derive(Copy))]
- pub enum AttrStyle {
- Outer,
- Inner(Token![!]),
- }
-}
-
-ast_enum_of_structs! {
- /// Content of a compile-time structured attribute.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// ## Path
- ///
- /// A meta path is like the `test` in `#[test]`.
- ///
- /// ## List
- ///
- /// A meta list is like the `derive(Copy)` in `#[derive(Copy)]`.
- ///
- /// ## NameValue
- ///
- /// A name-value meta is like the `path = "..."` in `#[path =
- /// "sys/windows.rs"]`.
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Meta {
- Path(Path),
-
- /// A structured list within an attribute, like `derive(Copy, Clone)`.
- List(MetaList),
-
- /// A name-value pair within an attribute, like `feature = "nightly"`.
- NameValue(MetaNameValue),
- }
-}
-
-ast_struct! {
- /// A structured list within an attribute, like `derive(Copy, Clone)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct MetaList {
- pub path: Path,
- pub paren_token: token::Paren,
- pub nested: Punctuated<NestedMeta, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A name-value pair within an attribute, like `feature = "nightly"`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct MetaNameValue {
- pub path: Path,
- pub eq_token: Token![=],
- pub lit: Lit,
- }
-}
-
-impl Meta {
- /// Returns the identifier that begins this structured meta item.
- ///
- /// For example this would return the `test` in `#[test]`, the `derive` in
- /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`.
- pub fn path(&self) -> &Path {
- match self {
- Meta::Path(path) => path,
- Meta::List(meta) => &meta.path,
- Meta::NameValue(meta) => &meta.path,
- }
- }
-}
-
-ast_enum_of_structs! {
- /// Element of a compile-time attribute list.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub enum NestedMeta {
- /// A structured meta item, like the `Copy` in `#[derive(Copy)]` which
- /// would be a nested `Meta::Path`.
- Meta(Meta),
-
- /// A Rust literal, like the `"new_name"` in `#[rename("new_name")]`.
- Lit(Lit),
- }
-}
-
-/// Conventional argument type associated with an invocation of an attribute
-/// macro.
-///
-/// For example if we are developing an attribute macro that is intended to be
-/// invoked on function items as follows:
-///
-/// ```
-/// # const IGNORE: &str = stringify! {
-/// #[my_attribute(path = "/v1/refresh")]
-/// # };
-/// pub fn refresh() {
-/// /* ... */
-/// }
-/// ```
-///
-/// The implementation of this macro would want to parse its attribute arguments
-/// as type `AttributeArgs`.
-///
-/// ```
-/// extern crate proc_macro;
-///
-/// use proc_macro::TokenStream;
-/// use syn::{parse_macro_input, AttributeArgs, ItemFn};
-///
-/// # const IGNORE: &str = stringify! {
-/// #[proc_macro_attribute]
-/// # };
-/// pub fn my_attribute(args: TokenStream, input: TokenStream) -> TokenStream {
-/// let args = parse_macro_input!(args as AttributeArgs);
-/// let input = parse_macro_input!(input as ItemFn);
-///
-/// /* ... */
-/// # "".parse().unwrap()
-/// }
-/// ```
-pub type AttributeArgs = Vec<NestedMeta>;
-
-pub trait FilterAttrs<'a> {
- type Ret: Iterator<Item = &'a Attribute>;
-
- fn outer(self) -> Self::Ret;
- fn inner(self) -> Self::Ret;
-}
-
-impl<'a, T> FilterAttrs<'a> for T
-where
- T: IntoIterator<Item = &'a Attribute>,
-{
- type Ret = iter::Filter<T::IntoIter, fn(&&Attribute) -> bool>;
-
- fn outer(self) -> Self::Ret {
- fn is_outer(attr: &&Attribute) -> bool {
- match attr.style {
- AttrStyle::Outer => true,
- _ => false,
- }
- }
- self.into_iter().filter(is_outer)
- }
-
- fn inner(self) -> Self::Ret {
- fn is_inner(attr: &&Attribute) -> bool {
- match attr.style {
- AttrStyle::Inner(_) => true,
- _ => false,
- }
- }
- self.into_iter().filter(is_inner)
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::ext::IdentExt;
- use crate::parse::{Parse, ParseStream, Result};
- #[cfg(feature = "full")]
- use crate::private;
-
- pub fn single_parse_inner(input: ParseStream) -> Result<Attribute> {
- let content;
- Ok(Attribute {
- pound_token: input.parse()?,
- style: AttrStyle::Inner(input.parse()?),
- bracket_token: bracketed!(content in input),
- path: content.call(Path::parse_mod_style)?,
- tokens: content.parse()?,
- })
- }
-
- pub fn single_parse_outer(input: ParseStream) -> Result<Attribute> {
- let content;
- Ok(Attribute {
- pound_token: input.parse()?,
- style: AttrStyle::Outer,
- bracket_token: bracketed!(content in input),
- path: content.call(Path::parse_mod_style)?,
- tokens: content.parse()?,
- })
- }
-
- #[cfg(feature = "full")]
- impl private {
- pub fn attrs(outer: Vec<Attribute>, inner: Vec<Attribute>) -> Vec<Attribute> {
- let mut attrs = outer;
- attrs.extend(inner);
- attrs
- }
- }
-
- // Like Path::parse_mod_style but accepts keywords in the path.
- fn parse_meta_path(input: ParseStream) -> Result<Path> {
- Ok(Path {
- leading_colon: input.parse()?,
- segments: {
- let mut segments = Punctuated::new();
- while input.peek(Ident::peek_any) {
- let ident = Ident::parse_any(input)?;
- segments.push_value(PathSegment::from(ident));
- if !input.peek(Token![::]) {
- break;
- }
- let punct = input.parse()?;
- segments.push_punct(punct);
- }
- if segments.is_empty() {
- return Err(input.error("expected path"));
- } else if segments.trailing_punct() {
- return Err(input.error("expected path segment"));
- }
- segments
- },
- })
- }
-
- impl Parse for Meta {
- fn parse(input: ParseStream) -> Result<Self> {
- let path = input.call(parse_meta_path)?;
- parse_meta_after_path(path, input)
- }
- }
-
- impl Parse for MetaList {
- fn parse(input: ParseStream) -> Result<Self> {
- let path = input.call(parse_meta_path)?;
- parse_meta_list_after_path(path, input)
- }
- }
-
- impl Parse for MetaNameValue {
- fn parse(input: ParseStream) -> Result<Self> {
- let path = input.call(parse_meta_path)?;
- parse_meta_name_value_after_path(path, input)
- }
- }
-
- impl Parse for NestedMeta {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Lit) && !(input.peek(LitBool) && input.peek2(Token![=])) {
- input.parse().map(NestedMeta::Lit)
- } else if input.peek(Ident::peek_any) {
- input.parse().map(NestedMeta::Meta)
- } else {
- Err(input.error("expected identifier or literal"))
- }
- }
- }
-
- pub fn parse_meta_after_path(path: Path, input: ParseStream) -> Result<Meta> {
- if input.peek(token::Paren) {
- parse_meta_list_after_path(path, input).map(Meta::List)
- } else if input.peek(Token![=]) {
- parse_meta_name_value_after_path(path, input).map(Meta::NameValue)
- } else {
- Ok(Meta::Path(path))
- }
- }
-
- fn parse_meta_list_after_path(path: Path, input: ParseStream) -> Result<MetaList> {
- let content;
- Ok(MetaList {
- path,
- paren_token: parenthesized!(content in input),
- nested: content.parse_terminated(NestedMeta::parse)?,
- })
- }
-
- fn parse_meta_name_value_after_path(path: Path, input: ParseStream) -> Result<MetaNameValue> {
- Ok(MetaNameValue {
- path,
- eq_token: input.parse()?,
- lit: input.parse()?,
- })
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
- use proc_macro2::TokenStream;
- use quote::ToTokens;
-
- impl ToTokens for Attribute {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.pound_token.to_tokens(tokens);
- if let AttrStyle::Inner(b) = &self.style {
- b.to_tokens(tokens);
- }
- self.bracket_token.surround(tokens, |tokens| {
- self.path.to_tokens(tokens);
- self.tokens.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for MetaList {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.path.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- self.nested.to_tokens(tokens);
- })
- }
- }
-
- impl ToTokens for MetaNameValue {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.path.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.lit.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/await.rs b/syn/src/await.rs
deleted file mode 100644
index a8e24fd..0000000
--- a/syn/src/await.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-// See include!("await.rs") in token.rs.
-export_token_macro![(await)];
diff --git a/syn/src/bigint.rs b/syn/src/bigint.rs
deleted file mode 100644
index 5397d6b..0000000
--- a/syn/src/bigint.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-use std::ops::{AddAssign, MulAssign};
-
-// For implementing base10_digits() accessor on LitInt.
-pub struct BigInt {
- digits: Vec<u8>,
-}
-
-impl BigInt {
- pub fn new() -> Self {
- BigInt { digits: Vec::new() }
- }
-
- pub fn to_string(&self) -> String {
- let mut repr = String::with_capacity(self.digits.len());
-
- let mut has_nonzero = false;
- for digit in self.digits.iter().rev() {
- has_nonzero |= *digit != 0;
- if has_nonzero {
- repr.push((*digit + b'0') as char);
- }
- }
-
- if repr.is_empty() {
- repr.push('0');
- }
-
- repr
- }
-
- fn reserve_two_digits(&mut self) {
- let len = self.digits.len();
- let desired =
- len + !self.digits.ends_with(&[0, 0]) as usize + !self.digits.ends_with(&[0]) as usize;
- self.digits.resize(desired, 0);
- }
-}
-
-impl AddAssign<u8> for BigInt {
- // Assumes increment <16.
- fn add_assign(&mut self, mut increment: u8) {
- self.reserve_two_digits();
-
- let mut i = 0;
- while increment > 0 {
- let sum = self.digits[i] + increment;
- self.digits[i] = sum % 10;
- increment = sum / 10;
- i += 1;
- }
- }
-}
-
-impl MulAssign<u8> for BigInt {
- // Assumes base <=16.
- fn mul_assign(&mut self, base: u8) {
- self.reserve_two_digits();
-
- let mut carry = 0;
- for digit in &mut self.digits {
- let prod = *digit * base + carry;
- *digit = prod % 10;
- carry = prod / 10;
- }
- }
-}
diff --git a/syn/src/buffer.rs b/syn/src/buffer.rs
deleted file mode 100644
index 5c2dd8a..0000000
--- a/syn/src/buffer.rs
+++ /dev/null
@@ -1,382 +0,0 @@
-//! A stably addressed token buffer supporting efficient traversal based on a
-//! cheaply copyable cursor.
-//!
-//! *This module is available if Syn is built with the `"parsing"` feature.*
-
-// This module is heavily commented as it contains most of the unsafe code in
-// Syn, and caution should be used when editing it. The public-facing interface
-// is 100% safe but the implementation is fragile internally.
-
-#[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "proc-macro"
-))]
-use crate::proc_macro as pm;
-use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
-
-use std::marker::PhantomData;
-use std::ptr;
-
-use crate::Lifetime;
-
-/// Internal type which is used instead of `TokenTree` to represent a token tree
-/// within a `TokenBuffer`.
-enum Entry {
- // Mimicking types from proc-macro.
- Group(Group, TokenBuffer),
- Ident(Ident),
- Punct(Punct),
- Literal(Literal),
- // End entries contain a raw pointer to the entry from the containing
- // token tree, or null if this is the outermost level.
- End(*const Entry),
-}
-
-/// A buffer that can be efficiently traversed multiple times, unlike
-/// `TokenStream` which requires a deep copy in order to traverse more than
-/// once.
-///
-/// *This type is available if Syn is built with the `"parsing"` feature.*
-pub struct TokenBuffer {
- // NOTE: Do not derive clone on this - there are raw pointers inside which
- // will be messed up. Moving the `TokenBuffer` itself is safe as the actual
- // backing slices won't be moved.
- data: Box<[Entry]>,
-}
-
-impl TokenBuffer {
- // NOTE: DO NOT MUTATE THE `Vec` RETURNED FROM THIS FUNCTION ONCE IT
- // RETURNS, THE ADDRESS OF ITS BACKING MEMORY MUST REMAIN STABLE.
- fn inner_new(stream: TokenStream, up: *const Entry) -> TokenBuffer {
- // Build up the entries list, recording the locations of any Groups
- // in the list to be processed later.
- let mut entries = Vec::new();
- let mut seqs = Vec::new();
- for tt in stream {
- match tt {
- TokenTree::Ident(sym) => {
- entries.push(Entry::Ident(sym));
- }
- TokenTree::Punct(op) => {
- entries.push(Entry::Punct(op));
- }
- TokenTree::Literal(l) => {
- entries.push(Entry::Literal(l));
- }
- TokenTree::Group(g) => {
- // Record the index of the interesting entry, and store an
- // `End(null)` there temporarially.
- seqs.push((entries.len(), g));
- entries.push(Entry::End(ptr::null()));
- }
- }
- }
- // Add an `End` entry to the end with a reference to the enclosing token
- // stream which was passed in.
- entries.push(Entry::End(up));
-
- // NOTE: This is done to ensure that we don't accidentally modify the
- // length of the backing buffer. The backing buffer must remain at a
- // constant address after this point, as we are going to store a raw
- // pointer into it.
- let mut entries = entries.into_boxed_slice();
- for (idx, group) in seqs {
- // We know that this index refers to one of the temporary
- // `End(null)` entries, and we know that the last entry is
- // `End(up)`, so the next index is also valid.
- let seq_up = &entries[idx + 1] as *const Entry;
-
- // The end entry stored at the end of this Entry::Group should
- // point to the Entry which follows the Group in the list.
- let inner = Self::inner_new(group.stream(), seq_up);
- entries[idx] = Entry::Group(group, inner);
- }
-
- TokenBuffer { data: entries }
- }
-
- /// Creates a `TokenBuffer` containing all the tokens from the input
- /// `TokenStream`.
- ///
- /// *This method is available if Syn is built with both the `"parsing"` and
- /// `"proc-macro"` features.*
- #[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "proc-macro"
- ))]
- pub fn new(stream: pm::TokenStream) -> TokenBuffer {
- Self::new2(stream.into())
- }
-
- /// Creates a `TokenBuffer` containing all the tokens from the input
- /// `TokenStream`.
- pub fn new2(stream: TokenStream) -> TokenBuffer {
- Self::inner_new(stream, ptr::null())
- }
-
- /// Creates a cursor referencing the first token in the buffer and able to
- /// traverse until the end of the buffer.
- pub fn begin(&self) -> Cursor {
- unsafe { Cursor::create(&self.data[0], &self.data[self.data.len() - 1]) }
- }
-}
-
-/// A cheaply copyable cursor into a `TokenBuffer`.
-///
-/// This cursor holds a shared reference into the immutable data which is used
-/// internally to represent a `TokenStream`, and can be efficiently manipulated
-/// and copied around.
-///
-/// An empty `Cursor` can be created directly, or one may create a `TokenBuffer`
-/// object and get a cursor to its first token with `begin()`.
-///
-/// Two cursors are equal if they have the same location in the same input
-/// stream, and have the same scope.
-///
-/// *This type is available if Syn is built with the `"parsing"` feature.*
-#[derive(Copy, Clone, Eq, PartialEq)]
-pub struct Cursor<'a> {
- // The current entry which the `Cursor` is pointing at.
- ptr: *const Entry,
- // This is the only `Entry::End(..)` object which this cursor is allowed to
- // point at. All other `End` objects are skipped over in `Cursor::create`.
- scope: *const Entry,
- // Cursor is covariant in 'a. This field ensures that our pointers are still
- // valid.
- marker: PhantomData<&'a Entry>,
-}
-
-impl<'a> Cursor<'a> {
- /// Creates a cursor referencing a static empty TokenStream.
- pub fn empty() -> Self {
- // It's safe in this situation for us to put an `Entry` object in global
- // storage, despite it not actually being safe to send across threads
- // (`Ident` is a reference into a thread-local table). This is because
- // this entry never includes a `Ident` object.
- //
- // This wrapper struct allows us to break the rules and put a `Sync`
- // object in global storage.
- struct UnsafeSyncEntry(Entry);
- unsafe impl Sync for UnsafeSyncEntry {}
- static EMPTY_ENTRY: UnsafeSyncEntry = UnsafeSyncEntry(Entry::End(0 as *const Entry));
-
- Cursor {
- ptr: &EMPTY_ENTRY.0,
- scope: &EMPTY_ENTRY.0,
- marker: PhantomData,
- }
- }
-
- /// This create method intelligently exits non-explicitly-entered
- /// `None`-delimited scopes when the cursor reaches the end of them,
- /// allowing for them to be treated transparently.
- unsafe fn create(mut ptr: *const Entry, scope: *const Entry) -> Self {
- // NOTE: If we're looking at a `End(..)`, we want to advance the cursor
- // past it, unless `ptr == scope`, which means that we're at the edge of
- // our cursor's scope. We should only have `ptr != scope` at the exit
- // from None-delimited groups entered with `ignore_none`.
- while let Entry::End(exit) = *ptr {
- if ptr == scope {
- break;
- }
- ptr = exit;
- }
-
- Cursor {
- ptr,
- scope,
- marker: PhantomData,
- }
- }
-
- /// Get the current entry.
- fn entry(self) -> &'a Entry {
- unsafe { &*self.ptr }
- }
-
- /// Bump the cursor to point at the next token after the current one. This
- /// is undefined behavior if the cursor is currently looking at an
- /// `Entry::End`.
- unsafe fn bump(self) -> Cursor<'a> {
- Cursor::create(self.ptr.offset(1), self.scope)
- }
-
- /// If the cursor is looking at a `None`-delimited group, move it to look at
- /// the first token inside instead. If the group is empty, this will move
- /// the cursor past the `None`-delimited group.
- ///
- /// WARNING: This mutates its argument.
- fn ignore_none(&mut self) {
- if let Entry::Group(group, buf) = self.entry() {
- if group.delimiter() == Delimiter::None {
- // NOTE: We call `Cursor::create` here to make sure that
- // situations where we should immediately exit the span after
- // entering it are handled correctly.
- unsafe {
- *self = Cursor::create(&buf.data[0], self.scope);
- }
- }
- }
- }
-
- /// Checks whether the cursor is currently pointing at the end of its valid
- /// scope.
- pub fn eof(self) -> bool {
- // We're at eof if we're at the end of our scope.
- self.ptr == self.scope
- }
-
- /// If the cursor is pointing at a `Group` with the given delimiter, returns
- /// a cursor into that group and one pointing to the next `TokenTree`.
- pub fn group(mut self, delim: Delimiter) -> Option<(Cursor<'a>, Span, Cursor<'a>)> {
- // If we're not trying to enter a none-delimited group, we want to
- // ignore them. We have to make sure to _not_ ignore them when we want
- // to enter them, of course. For obvious reasons.
- if delim != Delimiter::None {
- self.ignore_none();
- }
-
- if let Entry::Group(group, buf) = self.entry() {
- if group.delimiter() == delim {
- return Some((buf.begin(), group.span(), unsafe { self.bump() }));
- }
- }
-
- None
- }
-
- /// If the cursor is pointing at a `Ident`, returns it along with a cursor
- /// pointing at the next `TokenTree`.
- pub fn ident(mut self) -> Option<(Ident, Cursor<'a>)> {
- self.ignore_none();
- match self.entry() {
- Entry::Ident(ident) => Some((ident.clone(), unsafe { self.bump() })),
- _ => None,
- }
- }
-
- /// If the cursor is pointing at an `Punct`, returns it along with a cursor
- /// pointing at the next `TokenTree`.
- pub fn punct(mut self) -> Option<(Punct, Cursor<'a>)> {
- self.ignore_none();
- match self.entry() {
- Entry::Punct(op) if op.as_char() != '\'' => Some((op.clone(), unsafe { self.bump() })),
- _ => None,
- }
- }
-
- /// If the cursor is pointing at a `Literal`, return it along with a cursor
- /// pointing at the next `TokenTree`.
- pub fn literal(mut self) -> Option<(Literal, Cursor<'a>)> {
- self.ignore_none();
- match self.entry() {
- Entry::Literal(lit) => Some((lit.clone(), unsafe { self.bump() })),
- _ => None,
- }
- }
-
- /// If the cursor is pointing at a `Lifetime`, returns it along with a
- /// cursor pointing at the next `TokenTree`.
- pub fn lifetime(mut self) -> Option<(Lifetime, Cursor<'a>)> {
- self.ignore_none();
- match self.entry() {
- Entry::Punct(op) if op.as_char() == '\'' && op.spacing() == Spacing::Joint => {
- let next = unsafe { self.bump() };
- match next.ident() {
- Some((ident, rest)) => {
- let lifetime = Lifetime {
- apostrophe: op.span(),
- ident,
- };
- Some((lifetime, rest))
- }
- None => None,
- }
- }
- _ => None,
- }
- }
-
- /// Copies all remaining tokens visible from this cursor into a
- /// `TokenStream`.
- pub fn token_stream(self) -> TokenStream {
- let mut tts = Vec::new();
- let mut cursor = self;
- while let Some((tt, rest)) = cursor.token_tree() {
- tts.push(tt);
- cursor = rest;
- }
- tts.into_iter().collect()
- }
-
- /// If the cursor is pointing at a `TokenTree`, returns it along with a
- /// cursor pointing at the next `TokenTree`.
- ///
- /// Returns `None` if the cursor has reached the end of its stream.
- ///
- /// This method does not treat `None`-delimited groups as transparent, and
- /// will return a `Group(None, ..)` if the cursor is looking at one.
- pub fn token_tree(self) -> Option<(TokenTree, Cursor<'a>)> {
- let tree = match self.entry() {
- Entry::Group(group, _) => group.clone().into(),
- Entry::Literal(lit) => lit.clone().into(),
- Entry::Ident(ident) => ident.clone().into(),
- Entry::Punct(op) => op.clone().into(),
- Entry::End(..) => {
- return None;
- }
- };
-
- Some((tree, unsafe { self.bump() }))
- }
-
- /// Returns the `Span` of the current token, or `Span::call_site()` if this
- /// cursor points to eof.
- pub fn span(self) -> Span {
- match self.entry() {
- Entry::Group(group, _) => group.span(),
- Entry::Literal(l) => l.span(),
- Entry::Ident(t) => t.span(),
- Entry::Punct(o) => o.span(),
- Entry::End(..) => Span::call_site(),
- }
- }
-
- /// Skip over the next token without cloning it. Returns `None` if this
- /// cursor points to eof.
- ///
- /// This method treats `'lifetimes` as a single token.
- pub(crate) fn skip(self) -> Option<Cursor<'a>> {
- match self.entry() {
- Entry::End(..) => None,
-
- // Treat lifetimes as a single tt for the purposes of 'skip'.
- Entry::Punct(op) if op.as_char() == '\'' && op.spacing() == Spacing::Joint => {
- let next = unsafe { self.bump() };
- match next.entry() {
- Entry::Ident(_) => Some(unsafe { next.bump() }),
- _ => Some(next),
- }
- }
- _ => Some(unsafe { self.bump() }),
- }
- }
-}
-
-pub(crate) fn same_scope(a: Cursor, b: Cursor) -> bool {
- a.scope == b.scope
-}
-
-pub(crate) fn open_span_of_group(cursor: Cursor) -> Span {
- match cursor.entry() {
- Entry::Group(group, _) => group.span_open(),
- _ => cursor.span(),
- }
-}
-
-pub(crate) fn close_span_of_group(cursor: Cursor) -> Span {
- match cursor.entry() {
- Entry::Group(group, _) => group.span_close(),
- _ => cursor.span(),
- }
-}
diff --git a/syn/src/custom_keyword.rs b/syn/src/custom_keyword.rs
deleted file mode 100644
index 200e847..0000000
--- a/syn/src/custom_keyword.rs
+++ /dev/null
@@ -1,252 +0,0 @@
-/// Define a type that supports parsing and printing a given identifier as if it
-/// were a keyword.
-///
-/// # Usage
-///
-/// As a convention, it is recommended that this macro be invoked within a
-/// module called `kw` or `keyword` and that the resulting parser be invoked
-/// with a `kw::` or `keyword::` prefix.
-///
-/// ```
-/// mod kw {
-/// syn::custom_keyword!(whatever);
-/// }
-/// ```
-///
-/// The generated syntax tree node supports the following operations just like
-/// any built-in keyword token.
-///
-/// - [Peeking] — `input.peek(kw::whatever)`
-///
-/// - [Parsing] — `input.parse::<kw::whatever>()?`
-///
-/// - [Printing] — `quote!( ... #whatever_token ... )`
-///
-/// - Construction from a [`Span`] — `let whatever_token = kw::whatever(sp)`
-///
-/// - Field access to its span — `let sp = whatever_token.span`
-///
-/// [Peeking]: parse::ParseBuffer::peek
-/// [Parsing]: parse::ParseBuffer::parse
-/// [Printing]: quote::ToTokens
-/// [`Span`]: proc_macro2::Span
-///
-/// # Example
-///
-/// This example parses input that looks like `bool = true` or `str = "value"`.
-/// The key must be either the identifier `bool` or the identifier `str`. If
-/// `bool`, the value may be either `true` or `false`. If `str`, the value may
-/// be any string literal.
-///
-/// The symbols `bool` and `str` are not reserved keywords in Rust so these are
-/// not considered keywords in the `syn::token` module. Like any other
-/// identifier that is not a keyword, these can be declared as custom keywords
-/// by crates that need to use them as such.
-///
-/// ```
-/// use syn::{LitBool, LitStr, Result, Token};
-/// use syn::parse::{Parse, ParseStream};
-///
-/// mod kw {
-/// syn::custom_keyword!(bool);
-/// syn::custom_keyword!(str);
-/// }
-///
-/// enum Argument {
-/// Bool {
-/// bool_token: kw::bool,
-/// eq_token: Token![=],
-/// value: LitBool,
-/// },
-/// Str {
-/// str_token: kw::str,
-/// eq_token: Token![=],
-/// value: LitStr,
-/// },
-/// }
-///
-/// impl Parse for Argument {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// let lookahead = input.lookahead1();
-/// if lookahead.peek(kw::bool) {
-/// Ok(Argument::Bool {
-/// bool_token: input.parse::<kw::bool>()?,
-/// eq_token: input.parse()?,
-/// value: input.parse()?,
-/// })
-/// } else if lookahead.peek(kw::str) {
-/// Ok(Argument::Str {
-/// str_token: input.parse::<kw::str>()?,
-/// eq_token: input.parse()?,
-/// value: input.parse()?,
-/// })
-/// } else {
-/// Err(lookahead.error())
-/// }
-/// }
-/// }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! custom_keyword {
- ($ident:ident) => {
- #[allow(non_camel_case_types)]
- pub struct $ident {
- pub span: $crate::export::Span,
- }
-
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn $ident<__S: $crate::export::IntoSpans<[$crate::export::Span; 1]>>(
- span: __S,
- ) -> $ident {
- $ident {
- span: $crate::export::IntoSpans::into_spans(span)[0],
- }
- }
-
- impl $crate::export::Default for $ident {
- fn default() -> Self {
- $ident {
- span: $crate::export::Span::call_site(),
- }
- }
- }
-
- impl_parse_for_custom_keyword!($ident);
- impl_to_tokens_for_custom_keyword!($ident);
- impl_clone_for_custom_keyword!($ident);
- impl_extra_traits_for_custom_keyword!($ident);
- };
-}
-
-// Not public API.
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_parse_for_custom_keyword {
- ($ident:ident) => {
- // For peek.
- impl $crate::token::CustomToken for $ident {
- fn peek(cursor: $crate::buffer::Cursor) -> $crate::export::bool {
- if let Some((ident, _rest)) = cursor.ident() {
- ident == stringify!($ident)
- } else {
- false
- }
- }
-
- fn display() -> &'static $crate::export::str {
- concat!("`", stringify!($ident), "`")
- }
- }
-
- impl $crate::parse::Parse for $ident {
- fn parse(input: $crate::parse::ParseStream) -> $crate::parse::Result<$ident> {
- input.step(|cursor| {
- if let $crate::export::Some((ident, rest)) = cursor.ident() {
- if ident == stringify!($ident) {
- return $crate::export::Ok(($ident { span: ident.span() }, rest));
- }
- }
- $crate::export::Err(cursor.error(concat!(
- "expected `",
- stringify!($ident),
- "`"
- )))
- })
- }
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "parsing"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_parse_for_custom_keyword {
- ($ident:ident) => {};
-}
-
-// Not public API.
-#[cfg(feature = "printing")]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_to_tokens_for_custom_keyword {
- ($ident:ident) => {
- impl $crate::export::ToTokens for $ident {
- fn to_tokens(&self, tokens: &mut $crate::export::TokenStream2) {
- let ident = $crate::Ident::new(stringify!($ident), self.span);
- $crate::export::TokenStreamExt::append(tokens, ident);
- }
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "printing"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_to_tokens_for_custom_keyword {
- ($ident:ident) => {};
-}
-
-// Not public API.
-#[cfg(feature = "clone-impls")]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_clone_for_custom_keyword {
- ($ident:ident) => {
- impl $crate::export::Copy for $ident {}
-
- impl $crate::export::Clone for $ident {
- fn clone(&self) -> Self {
- *self
- }
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "clone-impls"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_clone_for_custom_keyword {
- ($ident:ident) => {};
-}
-
-// Not public API.
-#[cfg(feature = "extra-traits")]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_extra_traits_for_custom_keyword {
- ($ident:ident) => {
- impl $crate::export::Debug for $ident {
- fn fmt(&self, f: &mut $crate::export::Formatter) -> $crate::export::fmt::Result {
- $crate::export::Formatter::write_str(
- f,
- concat!("Keyword [", stringify!($ident), "]"),
- )
- }
- }
-
- impl $crate::export::Eq for $ident {}
-
- impl $crate::export::PartialEq for $ident {
- fn eq(&self, _other: &Self) -> $crate::export::bool {
- true
- }
- }
-
- impl $crate::export::Hash for $ident {
- fn hash<__H: $crate::export::Hasher>(&self, _state: &mut __H) {}
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "extra-traits"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_extra_traits_for_custom_keyword {
- ($ident:ident) => {};
-}
diff --git a/syn/src/custom_punctuation.rs b/syn/src/custom_punctuation.rs
deleted file mode 100644
index 29fa448..0000000
--- a/syn/src/custom_punctuation.rs
+++ /dev/null
@@ -1,309 +0,0 @@
-/// Define a type that supports parsing and printing a multi-character symbol
-/// as if it were a punctuation token.
-///
-/// # Usage
-///
-/// ```
-/// syn::custom_punctuation!(LeftRightArrow, <=>);
-/// ```
-///
-/// The generated syntax tree node supports the following operations just like
-/// any built-in punctuation token.
-///
-/// - [Peeking] — `input.peek(LeftRightArrow)`
-///
-/// - [Parsing] — `input.parse::<LeftRightArrow>()?`
-///
-/// - [Printing] — `quote!( ... #lrarrow ... )`
-///
-/// - Construction from a [`Span`] — `let lrarrow = LeftRightArrow(sp)`
-///
-/// - Construction from multiple [`Span`] — `let lrarrow = LeftRightArrow([sp, sp, sp])`
-///
-/// - Field access to its spans — `let spans = lrarrow.spans`
-///
-/// [Peeking]: parse::ParseBuffer::peek
-/// [Parsing]: parse::ParseBuffer::parse
-/// [Printing]: quote::ToTokens
-/// [`Span`]: proc_macro2::Span
-///
-/// # Example
-///
-/// ```
-/// use proc_macro2::{TokenStream, TokenTree};
-/// use syn::parse::{Parse, ParseStream, Peek, Result};
-/// use syn::punctuated::Punctuated;
-/// use syn::Expr;
-///
-/// syn::custom_punctuation!(PathSeparator, </>);
-///
-/// // expr </> expr </> expr ...
-/// struct PathSegments {
-/// segments: Punctuated<Expr, PathSeparator>,
-/// }
-///
-/// impl Parse for PathSegments {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// let mut segments = Punctuated::new();
-///
-/// let first = parse_until(input, PathSeparator)?;
-/// segments.push_value(syn::parse2(first)?);
-///
-/// while input.peek(PathSeparator) {
-/// segments.push_punct(input.parse()?);
-///
-/// let next = parse_until(input, PathSeparator)?;
-/// segments.push_value(syn::parse2(next)?);
-/// }
-///
-/// Ok(PathSegments { segments })
-/// }
-/// }
-///
-/// fn parse_until<E: Peek>(input: ParseStream, end: E) -> Result<TokenStream> {
-/// let mut tokens = TokenStream::new();
-/// while !input.is_empty() && !input.peek(end) {
-/// let next: TokenTree = input.parse()?;
-/// tokens.extend(Some(next));
-/// }
-/// Ok(tokens)
-/// }
-///
-/// fn main() {
-/// let input = r#" a::b </> c::d::e "#;
-/// let _: PathSegments = syn::parse_str(input).unwrap();
-/// }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {
- pub struct $ident {
- pub spans: custom_punctuation_repr!($($tt)+),
- }
-
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn $ident<__S: $crate::export::IntoSpans<custom_punctuation_repr!($($tt)+)>>(
- spans: __S,
- ) -> $ident {
- let _validate_len = 0 $(+ custom_punctuation_len!(strict, $tt))*;
- $ident {
- spans: $crate::export::IntoSpans::into_spans(spans)
- }
- }
-
- impl $crate::export::Default for $ident {
- fn default() -> Self {
- $ident($crate::export::Span::call_site())
- }
- }
-
- impl_parse_for_custom_punctuation!($ident, $($tt)+);
- impl_to_tokens_for_custom_punctuation!($ident, $($tt)+);
- impl_clone_for_custom_punctuation!($ident, $($tt)+);
- impl_extra_traits_for_custom_punctuation!($ident, $($tt)+);
- };
-}
-
-// Not public API.
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! impl_parse_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {
- impl $crate::token::CustomToken for $ident {
- fn peek(cursor: $crate::buffer::Cursor) -> bool {
- $crate::token::parsing::peek_punct(cursor, stringify_punct!($($tt)+))
- }
-
- fn display() -> &'static $crate::export::str {
- custom_punctuation_concat!("`", stringify_punct!($($tt)+), "`")
- }
- }
-
- impl $crate::parse::Parse for $ident {
- fn parse(input: $crate::parse::ParseStream) -> $crate::parse::Result<$ident> {
- let spans: custom_punctuation_repr!($($tt)+) =
- $crate::token::parsing::punct(input, stringify_punct!($($tt)+))?;
- Ok($ident(spans))
- }
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "parsing"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_parse_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {};
-}
-
-// Not public API.
-#[cfg(feature = "printing")]
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! impl_to_tokens_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {
- impl $crate::export::ToTokens for $ident {
- fn to_tokens(&self, tokens: &mut $crate::export::TokenStream2) {
- $crate::token::printing::punct(stringify_punct!($($tt)+), &self.spans, tokens)
- }
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "printing"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_to_tokens_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {};
-}
-
-// Not public API.
-#[cfg(feature = "clone-impls")]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_clone_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {
- impl $crate::export::Copy for $ident {}
-
- impl $crate::export::Clone for $ident {
- fn clone(&self) -> Self {
- *self
- }
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "clone-impls"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_clone_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {};
-}
-
-// Not public API.
-#[cfg(feature = "extra-traits")]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_extra_traits_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {
- impl $crate::export::Debug for $ident {
- fn fmt(&self, f: &mut $crate::export::Formatter) -> $crate::export::fmt::Result {
- $crate::export::Formatter::write_str(f, stringify!($ident))
- }
- }
-
- impl $crate::export::Eq for $ident {}
-
- impl $crate::export::PartialEq for $ident {
- fn eq(&self, _other: &Self) -> $crate::export::bool {
- true
- }
- }
-
- impl $crate::export::Hash for $ident {
- fn hash<__H: $crate::export::Hasher>(&self, _state: &mut __H) {}
- }
- };
-}
-
-// Not public API.
-#[cfg(not(feature = "extra-traits"))]
-#[doc(hidden)]
-#[macro_export]
-macro_rules! impl_extra_traits_for_custom_punctuation {
- ($ident:ident, $($tt:tt)+) => {};
-}
-
-// Not public API.
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! custom_punctuation_repr {
- ($($tt:tt)+) => {
- [$crate::export::Span; 0 $(+ custom_punctuation_len!(lenient, $tt))+]
- };
-}
-
-// Not public API.
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-#[rustfmt::skip]
-macro_rules! custom_punctuation_len {
- ($mode:ident, +) => { 1 };
- ($mode:ident, +=) => { 2 };
- ($mode:ident, &) => { 1 };
- ($mode:ident, &&) => { 2 };
- ($mode:ident, &=) => { 2 };
- ($mode:ident, @) => { 1 };
- ($mode:ident, !) => { 1 };
- ($mode:ident, ^) => { 1 };
- ($mode:ident, ^=) => { 2 };
- ($mode:ident, :) => { 1 };
- ($mode:ident, ::) => { 2 };
- ($mode:ident, ,) => { 1 };
- ($mode:ident, /) => { 1 };
- ($mode:ident, /=) => { 2 };
- ($mode:ident, .) => { 1 };
- ($mode:ident, ..) => { 2 };
- ($mode:ident, ...) => { 3 };
- ($mode:ident, ..=) => { 3 };
- ($mode:ident, =) => { 1 };
- ($mode:ident, ==) => { 2 };
- ($mode:ident, >=) => { 2 };
- ($mode:ident, >) => { 1 };
- ($mode:ident, <=) => { 2 };
- ($mode:ident, <) => { 1 };
- ($mode:ident, *=) => { 2 };
- ($mode:ident, !=) => { 2 };
- ($mode:ident, |) => { 1 };
- ($mode:ident, |=) => { 2 };
- ($mode:ident, ||) => { 2 };
- ($mode:ident, #) => { 1 };
- ($mode:ident, ?) => { 1 };
- ($mode:ident, ->) => { 2 };
- ($mode:ident, <-) => { 2 };
- ($mode:ident, %) => { 1 };
- ($mode:ident, %=) => { 2 };
- ($mode:ident, =>) => { 2 };
- ($mode:ident, ;) => { 1 };
- ($mode:ident, <<) => { 2 };
- ($mode:ident, <<=) => { 3 };
- ($mode:ident, >>) => { 2 };
- ($mode:ident, >>=) => { 3 };
- ($mode:ident, *) => { 1 };
- ($mode:ident, -) => { 1 };
- ($mode:ident, -=) => { 2 };
- ($mode:ident, ~) => { 1 };
- (lenient, $tt:tt) => { 0 };
- (strict, $tt:tt) => {{ custom_punctuation_unexpected!($tt); 0 }};
-}
-
-// Not public API.
-#[doc(hidden)]
-#[macro_export]
-macro_rules! custom_punctuation_unexpected {
- () => {};
-}
-
-// Not public API.
-#[doc(hidden)]
-#[macro_export]
-macro_rules! stringify_punct {
- ($($tt:tt)+) => {
- concat!($(stringify!($tt)),+)
- };
-}
-
-// Not public API.
-// Without this, local_inner_macros breaks when looking for concat!
-#[doc(hidden)]
-#[macro_export]
-macro_rules! custom_punctuation_concat {
- ($($tt:tt)*) => {
- concat!($($tt)*)
- };
-}
diff --git a/syn/src/data.rs b/syn/src/data.rs
deleted file mode 100644
index 184a79e..0000000
--- a/syn/src/data.rs
+++ /dev/null
@@ -1,456 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-
-ast_struct! {
- /// An enum variant.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Variant {
- /// Attributes tagged on the variant.
- pub attrs: Vec<Attribute>,
-
- /// Name of the variant.
- pub ident: Ident,
-
- /// Content stored in the variant.
- pub fields: Fields,
-
- /// Explicit discriminant: `Variant = 1`
- pub discriminant: Option<(Token![=], Expr)>,
- }
-}
-
-ast_enum_of_structs! {
- /// Data stored within an enum variant or struct.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Fields {
- /// Named fields of a struct or struct variant such as `Point { x: f64,
- /// y: f64 }`.
- Named(FieldsNamed),
-
- /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`.
- Unnamed(FieldsUnnamed),
-
- /// Unit struct or unit variant such as `None`.
- Unit,
- }
-}
-
-ast_struct! {
- /// Named fields of a struct or struct variant such as `Point { x: f64,
- /// y: f64 }`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct FieldsNamed {
- pub brace_token: token::Brace,
- pub named: Punctuated<Field, Token![,]>,
- }
-}
-
-ast_struct! {
- /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct FieldsUnnamed {
- pub paren_token: token::Paren,
- pub unnamed: Punctuated<Field, Token![,]>,
- }
-}
-
-impl Fields {
- /// Get an iterator over the borrowed [`Field`] items in this object. This
- /// iterator can be used to iterate over a named or unnamed struct or
- /// variant's fields uniformly.
- pub fn iter(&self) -> punctuated::Iter<Field> {
- match self {
- Fields::Unit => crate::punctuated::empty_punctuated_iter(),
- Fields::Named(f) => f.named.iter(),
- Fields::Unnamed(f) => f.unnamed.iter(),
- }
- }
-
- /// Get an iterator over the mutably borrowed [`Field`] items in this
- /// object. This iterator can be used to iterate over a named or unnamed
- /// struct or variant's fields uniformly.
- pub fn iter_mut(&mut self) -> punctuated::IterMut<Field> {
- match self {
- Fields::Unit => crate::punctuated::empty_punctuated_iter_mut(),
- Fields::Named(f) => f.named.iter_mut(),
- Fields::Unnamed(f) => f.unnamed.iter_mut(),
- }
- }
-
- /// Returns the number of fields.
- pub fn len(&self) -> usize {
- match self {
- Fields::Unit => 0,
- Fields::Named(f) => f.named.len(),
- Fields::Unnamed(f) => f.unnamed.len(),
- }
- }
-
- /// Returns `true` if there are zero fields.
- pub fn is_empty(&self) -> bool {
- match self {
- Fields::Unit => true,
- Fields::Named(f) => f.named.is_empty(),
- Fields::Unnamed(f) => f.unnamed.is_empty(),
- }
- }
-}
-
-impl IntoIterator for Fields {
- type Item = Field;
- type IntoIter = punctuated::IntoIter<Field>;
-
- fn into_iter(self) -> Self::IntoIter {
- match self {
- Fields::Unit => Punctuated::<Field, ()>::new().into_iter(),
- Fields::Named(f) => f.named.into_iter(),
- Fields::Unnamed(f) => f.unnamed.into_iter(),
- }
- }
-}
-
-impl<'a> IntoIterator for &'a Fields {
- type Item = &'a Field;
- type IntoIter = punctuated::Iter<'a, Field>;
-
- fn into_iter(self) -> Self::IntoIter {
- self.iter()
- }
-}
-
-impl<'a> IntoIterator for &'a mut Fields {
- type Item = &'a mut Field;
- type IntoIter = punctuated::IterMut<'a, Field>;
-
- fn into_iter(self) -> Self::IntoIter {
- self.iter_mut()
- }
-}
-
-ast_struct! {
- /// A field of a struct or enum variant.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Field {
- /// Attributes tagged on the field.
- pub attrs: Vec<Attribute>,
-
- /// Visibility of the field.
- pub vis: Visibility,
-
- /// Name of the field, if any.
- ///
- /// Fields of tuple structs have no names.
- pub ident: Option<Ident>,
-
- pub colon_token: Option<Token![:]>,
-
- /// Type of the field.
- pub ty: Type,
- }
-}
-
-ast_enum_of_structs! {
- /// The visibility level of an item: inherited or `pub` or
- /// `pub(restricted)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Visibility {
- /// A public visibility level: `pub`.
- Public(VisPublic),
-
- /// A crate-level visibility: `crate`.
- Crate(VisCrate),
-
- /// A visibility level restricted to some path: `pub(self)` or
- /// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
- Restricted(VisRestricted),
-
- /// An inherited visibility, which usually means private.
- Inherited,
- }
-}
-
-ast_struct! {
- /// A public visibility level: `pub`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct VisPublic {
- pub pub_token: Token![pub],
- }
-}
-
-ast_struct! {
- /// A crate-level visibility: `crate`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct VisCrate {
- pub crate_token: Token![crate],
- }
-}
-
-ast_struct! {
- /// A visibility level restricted to some path: `pub(self)` or
- /// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct VisRestricted {
- pub pub_token: Token![pub],
- pub paren_token: token::Paren,
- pub in_token: Option<Token![in]>,
- pub path: Box<Path>,
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::ext::IdentExt;
- use crate::parse::discouraged::Speculative;
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for Variant {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(Variant {
- attrs: input.call(Attribute::parse_outer)?,
- ident: input.parse()?,
- fields: {
- if input.peek(token::Brace) {
- Fields::Named(input.parse()?)
- } else if input.peek(token::Paren) {
- Fields::Unnamed(input.parse()?)
- } else {
- Fields::Unit
- }
- },
- discriminant: {
- if input.peek(Token![=]) {
- let eq_token: Token![=] = input.parse()?;
- let discriminant: Expr = input.parse()?;
- Some((eq_token, discriminant))
- } else {
- None
- }
- },
- })
- }
- }
-
- impl Parse for FieldsNamed {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- Ok(FieldsNamed {
- brace_token: braced!(content in input),
- named: content.parse_terminated(Field::parse_named)?,
- })
- }
- }
-
- impl Parse for FieldsUnnamed {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- Ok(FieldsUnnamed {
- paren_token: parenthesized!(content in input),
- unnamed: content.parse_terminated(Field::parse_unnamed)?,
- })
- }
- }
-
- impl Field {
- /// Parses a named (braced struct) field.
- pub fn parse_named(input: ParseStream) -> Result<Self> {
- Ok(Field {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- ident: Some(input.parse()?),
- colon_token: Some(input.parse()?),
- ty: input.parse()?,
- })
- }
-
- /// Parses an unnamed (tuple struct) field.
- pub fn parse_unnamed(input: ParseStream) -> Result<Self> {
- Ok(Field {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- ident: None,
- colon_token: None,
- ty: input.parse()?,
- })
- }
- }
-
- impl Parse for Visibility {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![pub]) {
- Self::parse_pub(input)
- } else if input.peek(Token![crate]) {
- Self::parse_crate(input)
- } else {
- Ok(Visibility::Inherited)
- }
- }
- }
-
- impl Visibility {
- fn parse_pub(input: ParseStream) -> Result<Self> {
- let pub_token = input.parse::<Token![pub]>()?;
-
- if input.peek(token::Paren) {
- let ahead = input.fork();
-
- let content;
- let paren_token = parenthesized!(content in ahead);
- if content.peek(Token![crate])
- || content.peek(Token![self])
- || content.peek(Token![super])
- {
- let path = content.call(Ident::parse_any)?;
-
- // Ensure there are no additional tokens within `content`.
- // Without explicitly checking, we may misinterpret a tuple
- // field as a restricted visibility, causing a parse error.
- // e.g. `pub (crate::A, crate::B)` (Issue #720).
- if content.is_empty() {
- input.advance_to(&ahead);
- return Ok(Visibility::Restricted(VisRestricted {
- pub_token,
- paren_token,
- in_token: None,
- path: Box::new(Path::from(path)),
- }));
- }
- } else if content.peek(Token![in]) {
- let in_token: Token![in] = content.parse()?;
- let path = content.call(Path::parse_mod_style)?;
-
- input.advance_to(&ahead);
- return Ok(Visibility::Restricted(VisRestricted {
- pub_token,
- paren_token,
- in_token: Some(in_token),
- path: Box::new(path),
- }));
- }
- }
-
- Ok(Visibility::Public(VisPublic { pub_token }))
- }
-
- fn parse_crate(input: ParseStream) -> Result<Self> {
- if input.peek2(Token![::]) {
- Ok(Visibility::Inherited)
- } else {
- Ok(Visibility::Crate(VisCrate {
- crate_token: input.parse()?,
- }))
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use crate::print::TokensOrDefault;
-
- impl ToTokens for Variant {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(&self.attrs);
- self.ident.to_tokens(tokens);
- self.fields.to_tokens(tokens);
- if let Some((eq_token, disc)) = &self.discriminant {
- eq_token.to_tokens(tokens);
- disc.to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for FieldsNamed {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.brace_token.surround(tokens, |tokens| {
- self.named.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for FieldsUnnamed {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.paren_token.surround(tokens, |tokens| {
- self.unnamed.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for Field {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(&self.attrs);
- self.vis.to_tokens(tokens);
- if let Some(ident) = &self.ident {
- ident.to_tokens(tokens);
- TokensOrDefault(&self.colon_token).to_tokens(tokens);
- }
- self.ty.to_tokens(tokens);
- }
- }
-
- impl ToTokens for VisPublic {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.pub_token.to_tokens(tokens)
- }
- }
-
- impl ToTokens for VisCrate {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.crate_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for VisRestricted {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.pub_token.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- // TODO: If we have a path which is not "self" or "super" or
- // "crate", automatically add the "in" token.
- self.in_token.to_tokens(tokens);
- self.path.to_tokens(tokens);
- });
- }
- }
-}
diff --git a/syn/src/derive.rs b/syn/src/derive.rs
deleted file mode 100644
index 8cb9cf7..0000000
--- a/syn/src/derive.rs
+++ /dev/null
@@ -1,273 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-
-ast_struct! {
- /// Data structure sent to a `proc_macro_derive` macro.
- ///
- /// *This type is available if Syn is built with the `"derive"` feature.*
- pub struct DeriveInput {
- /// Attributes tagged on the whole struct or enum.
- pub attrs: Vec<Attribute>,
-
- /// Visibility of the struct or enum.
- pub vis: Visibility,
-
- /// Name of the struct or enum.
- pub ident: Ident,
-
- /// Generics required to complete the definition.
- pub generics: Generics,
-
- /// Data within the struct or enum.
- pub data: Data,
- }
-}
-
-ast_enum_of_structs! {
- /// The storage of a struct, enum or union data structure.
- ///
- /// *This type is available if Syn is built with the `"derive"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Data {
- /// A struct input to a `proc_macro_derive` macro.
- Struct(DataStruct),
-
- /// An enum input to a `proc_macro_derive` macro.
- Enum(DataEnum),
-
- /// An untagged union input to a `proc_macro_derive` macro.
- Union(DataUnion),
- }
-
- do_not_generate_to_tokens
-}
-
-ast_struct! {
- /// A struct input to a `proc_macro_derive` macro.
- ///
- /// *This type is available if Syn is built with the `"derive"`
- /// feature.*
- pub struct DataStruct {
- pub struct_token: Token![struct],
- pub fields: Fields,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-ast_struct! {
- /// An enum input to a `proc_macro_derive` macro.
- ///
- /// *This type is available if Syn is built with the `"derive"`
- /// feature.*
- pub struct DataEnum {
- pub enum_token: Token![enum],
- pub brace_token: token::Brace,
- pub variants: Punctuated<Variant, Token![,]>,
- }
-}
-
-ast_struct! {
- /// An untagged union input to a `proc_macro_derive` macro.
- ///
- /// *This type is available if Syn is built with the `"derive"`
- /// feature.*
- pub struct DataUnion {
- pub union_token: Token![union],
- pub fields: FieldsNamed,
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for DeriveInput {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis = input.parse::<Visibility>()?;
-
- let lookahead = input.lookahead1();
- if lookahead.peek(Token![struct]) {
- let struct_token = input.parse::<Token![struct]>()?;
- let ident = input.parse::<Ident>()?;
- let generics = input.parse::<Generics>()?;
- let (where_clause, fields, semi) = data_struct(input)?;
- Ok(DeriveInput {
- attrs,
- vis,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- data: Data::Struct(DataStruct {
- struct_token,
- fields,
- semi_token: semi,
- }),
- })
- } else if lookahead.peek(Token![enum]) {
- let enum_token = input.parse::<Token![enum]>()?;
- let ident = input.parse::<Ident>()?;
- let generics = input.parse::<Generics>()?;
- let (where_clause, brace, variants) = data_enum(input)?;
- Ok(DeriveInput {
- attrs,
- vis,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- data: Data::Enum(DataEnum {
- enum_token,
- brace_token: brace,
- variants,
- }),
- })
- } else if lookahead.peek(Token![union]) {
- let union_token = input.parse::<Token![union]>()?;
- let ident = input.parse::<Ident>()?;
- let generics = input.parse::<Generics>()?;
- let (where_clause, fields) = data_union(input)?;
- Ok(DeriveInput {
- attrs,
- vis,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- data: Data::Union(DataUnion {
- union_token,
- fields,
- }),
- })
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- pub fn data_struct(
- input: ParseStream,
- ) -> Result<(Option<WhereClause>, Fields, Option<Token![;]>)> {
- let mut lookahead = input.lookahead1();
- let mut where_clause = None;
- if lookahead.peek(Token![where]) {
- where_clause = Some(input.parse()?);
- lookahead = input.lookahead1();
- }
-
- if where_clause.is_none() && lookahead.peek(token::Paren) {
- let fields = input.parse()?;
-
- lookahead = input.lookahead1();
- if lookahead.peek(Token![where]) {
- where_clause = Some(input.parse()?);
- lookahead = input.lookahead1();
- }
-
- if lookahead.peek(Token![;]) {
- let semi = input.parse()?;
- Ok((where_clause, Fields::Unnamed(fields), Some(semi)))
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(token::Brace) {
- let fields = input.parse()?;
- Ok((where_clause, Fields::Named(fields), None))
- } else if lookahead.peek(Token![;]) {
- let semi = input.parse()?;
- Ok((where_clause, Fields::Unit, Some(semi)))
- } else {
- Err(lookahead.error())
- }
- }
-
- pub fn data_enum(
- input: ParseStream,
- ) -> Result<(
- Option<WhereClause>,
- token::Brace,
- Punctuated<Variant, Token![,]>,
- )> {
- let where_clause = input.parse()?;
-
- let content;
- let brace = braced!(content in input);
- let variants = content.parse_terminated(Variant::parse)?;
-
- Ok((where_clause, brace, variants))
- }
-
- pub fn data_union(input: ParseStream) -> Result<(Option<WhereClause>, FieldsNamed)> {
- let where_clause = input.parse()?;
- let fields = input.parse()?;
- Ok((where_clause, fields))
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::ToTokens;
-
- use crate::attr::FilterAttrs;
- use crate::print::TokensOrDefault;
-
- impl ToTokens for DeriveInput {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- for attr in self.attrs.outer() {
- attr.to_tokens(tokens);
- }
- self.vis.to_tokens(tokens);
- match &self.data {
- Data::Struct(d) => d.struct_token.to_tokens(tokens),
- Data::Enum(d) => d.enum_token.to_tokens(tokens),
- Data::Union(d) => d.union_token.to_tokens(tokens),
- }
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- match &self.data {
- Data::Struct(data) => match &data.fields {
- Fields::Named(fields) => {
- self.generics.where_clause.to_tokens(tokens);
- fields.to_tokens(tokens);
- }
- Fields::Unnamed(fields) => {
- fields.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- TokensOrDefault(&data.semi_token).to_tokens(tokens);
- }
- Fields::Unit => {
- self.generics.where_clause.to_tokens(tokens);
- TokensOrDefault(&data.semi_token).to_tokens(tokens);
- }
- },
- Data::Enum(data) => {
- self.generics.where_clause.to_tokens(tokens);
- data.brace_token.surround(tokens, |tokens| {
- data.variants.to_tokens(tokens);
- });
- }
- Data::Union(data) => {
- self.generics.where_clause.to_tokens(tokens);
- data.fields.to_tokens(tokens);
- }
- }
- }
- }
-}
diff --git a/syn/src/discouraged.rs b/syn/src/discouraged.rs
deleted file mode 100644
index 29d1006..0000000
--- a/syn/src/discouraged.rs
+++ /dev/null
@@ -1,195 +0,0 @@
-//! Extensions to the parsing API with niche applicability.
-
-use super::*;
-
-/// Extensions to the `ParseStream` API to support speculative parsing.
-pub trait Speculative {
- /// Advance this parse stream to the position of a forked parse stream.
- ///
- /// This is the opposite operation to [`ParseStream::fork`]. You can fork a
- /// parse stream, perform some speculative parsing, then join the original
- /// stream to the fork to "commit" the parsing from the fork to the main
- /// stream.
- ///
- /// If you can avoid doing this, you should, as it limits the ability to
- /// generate useful errors. That said, it is often the only way to parse
- /// syntax of the form `A* B*` for arbitrary syntax `A` and `B`. The problem
- /// is that when the fork fails to parse an `A`, it's impossible to tell
- /// whether that was because of a syntax error and the user meant to provide
- /// an `A`, or that the `A`s are finished and its time to start parsing
- /// `B`s. Use with care.
- ///
- /// Also note that if `A` is a subset of `B`, `A* B*` can be parsed by
- /// parsing `B*` and removing the leading members of `A` from the
- /// repetition, bypassing the need to involve the downsides associated with
- /// speculative parsing.
- ///
- /// [`ParseStream::fork`]: ParseBuffer::fork
- ///
- /// # Example
- ///
- /// There has been chatter about the possibility of making the colons in the
- /// turbofish syntax like `path::to::<T>` no longer required by accepting
- /// `path::to<T>` in expression position. Specifically, according to [RFC
- /// 2544], [`PathSegment`] parsing should always try to consume a following
- /// `<` token as the start of generic arguments, and reset to the `<` if
- /// that fails (e.g. the token is acting as a less-than operator).
- ///
- /// This is the exact kind of parsing behavior which requires the "fork,
- /// try, commit" behavior that [`ParseStream::fork`] discourages. With
- /// `advance_to`, we can avoid having to parse the speculatively parsed
- /// content a second time.
- ///
- /// This change in behavior can be implemented in syn by replacing just the
- /// `Parse` implementation for `PathSegment`:
- ///
- /// ```
- /// # use syn::ext::IdentExt;
- /// use syn::parse::discouraged::Speculative;
- /// # use syn::parse::{Parse, ParseStream};
- /// # use syn::{Ident, PathArguments, Result, Token};
- ///
- /// pub struct PathSegment {
- /// pub ident: Ident,
- /// pub arguments: PathArguments,
- /// }
- /// #
- /// # impl<T> From<T> for PathSegment
- /// # where
- /// # T: Into<Ident>,
- /// # {
- /// # fn from(ident: T) -> Self {
- /// # PathSegment {
- /// # ident: ident.into(),
- /// # arguments: PathArguments::None,
- /// # }
- /// # }
- /// # }
- ///
- /// impl Parse for PathSegment {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// if input.peek(Token![super])
- /// || input.peek(Token![self])
- /// || input.peek(Token![Self])
- /// || input.peek(Token![crate])
- /// || input.peek(Token![extern])
- /// {
- /// let ident = input.call(Ident::parse_any)?;
- /// return Ok(PathSegment::from(ident));
- /// }
- ///
- /// let ident = input.parse()?;
- /// if input.peek(Token![::]) && input.peek3(Token![<]) {
- /// return Ok(PathSegment {
- /// ident,
- /// arguments: PathArguments::AngleBracketed(input.parse()?),
- /// });
- /// }
- /// if input.peek(Token![<]) && !input.peek(Token![<=]) {
- /// let fork = input.fork();
- /// if let Ok(arguments) = fork.parse() {
- /// input.advance_to(&fork);
- /// return Ok(PathSegment {
- /// ident,
- /// arguments: PathArguments::AngleBracketed(arguments),
- /// });
- /// }
- /// }
- /// Ok(PathSegment::from(ident))
- /// }
- /// }
- ///
- /// # syn::parse_str::<PathSegment>("a<b,c>").unwrap();
- /// ```
- ///
- /// # Drawbacks
- ///
- /// The main drawback of this style of speculative parsing is in error
- /// presentation. Even if the lookahead is the "correct" parse, the error
- /// that is shown is that of the "fallback" parse. To use the same example
- /// as the turbofish above, take the following unfinished "turbofish":
- ///
- /// ```text
- /// let _ = f<&'a fn(), for<'a> serde::>();
- /// ```
- ///
- /// If this is parsed as generic arguments, we can provide the error message
- ///
- /// ```text
- /// error: expected identifier
- /// --> src.rs:L:C
- /// |
- /// L | let _ = f<&'a fn(), for<'a> serde::>();
- /// | ^
- /// ```
- ///
- /// but if parsed using the above speculative parsing, it falls back to
- /// assuming that the `<` is a less-than when it fails to parse the generic
- /// arguments, and tries to interpret the `&'a` as the start of a labelled
- /// loop, resulting in the much less helpful error
- ///
- /// ```text
- /// error: expected `:`
- /// --> src.rs:L:C
- /// |
- /// L | let _ = f<&'a fn(), for<'a> serde::>();
- /// | ^^
- /// ```
- ///
- /// This can be mitigated with various heuristics (two examples: show both
- /// forks' parse errors, or show the one that consumed more tokens), but
- /// when you can control the grammar, sticking to something that can be
- /// parsed LL(3) and without the LL(*) speculative parsing this makes
- /// possible, displaying reasonable errors becomes much more simple.
- ///
- /// [RFC 2544]: https://github.com/rust-lang/rfcs/pull/2544
- /// [`PathSegment`]: crate::PathSegment
- ///
- /// # Performance
- ///
- /// This method performs a cheap fixed amount of work that does not depend
- /// on how far apart the two streams are positioned.
- ///
- /// # Panics
- ///
- /// The forked stream in the argument of `advance_to` must have been
- /// obtained by forking `self`. Attempting to advance to any other stream
- /// will cause a panic.
- fn advance_to(&self, fork: &Self);
-}
-
-impl<'a> Speculative for ParseBuffer<'a> {
- fn advance_to(&self, fork: &Self) {
- if !crate::buffer::same_scope(self.cursor(), fork.cursor()) {
- panic!("Fork was not derived from the advancing parse stream");
- }
-
- let (self_unexp, self_sp) = inner_unexpected(self);
- let (fork_unexp, fork_sp) = inner_unexpected(fork);
- if !Rc::ptr_eq(&self_unexp, &fork_unexp) {
- match (fork_sp, self_sp) {
- // Unexpected set on the fork, but not on `self`, copy it over.
- (Some(span), None) => {
- self_unexp.set(Unexpected::Some(span));
- }
- // Unexpected unset. Use chain to propagate errors from fork.
- (None, None) => {
- fork_unexp.set(Unexpected::Chain(self_unexp));
-
- // Ensure toplevel 'unexpected' tokens from the fork don't
- // bubble up the chain by replacing the root `unexpected`
- // pointer, only 'unexpected' tokens from existing group
- // parsers should bubble.
- fork.unexpected
- .set(Some(Rc::new(Cell::new(Unexpected::None))));
- }
- // Unexpected has been set on `self`. No changes needed.
- (_, Some(_)) => {}
- }
- }
-
- // See comment on `cell` in the struct definition.
- self.cell
- .set(unsafe { mem::transmute::<Cursor, Cursor<'static>>(fork.cursor()) })
- }
-}
diff --git a/syn/src/error.rs b/syn/src/error.rs
deleted file mode 100644
index 146d652..0000000
--- a/syn/src/error.rs
+++ /dev/null
@@ -1,357 +0,0 @@
-use std;
-use std::fmt::{self, Debug, Display};
-use std::iter::FromIterator;
-use std::slice;
-use std::vec;
-
-use proc_macro2::{
- Delimiter, Group, Ident, LexError, Literal, Punct, Spacing, Span, TokenStream, TokenTree,
-};
-#[cfg(feature = "printing")]
-use quote::ToTokens;
-
-#[cfg(feature = "parsing")]
-use crate::buffer::Cursor;
-use crate::thread::ThreadBound;
-
-/// The result of a Syn parser.
-pub type Result<T> = std::result::Result<T, Error>;
-
-/// Error returned when a Syn parser cannot parse the input tokens.
-///
-/// # Error reporting in proc macros
-///
-/// The correct way to report errors back to the compiler from a procedural
-/// macro is by emitting an appropriately spanned invocation of
-/// [`compile_error!`] in the generated code. This produces a better diagnostic
-/// message than simply panicking the macro.
-///
-/// [`compile_error!`]: https://doc.rust-lang.org/std/macro.compile_error.html
-///
-/// When parsing macro input, the [`parse_macro_input!`] macro handles the
-/// conversion to `compile_error!` automatically.
-///
-/// ```
-/// extern crate proc_macro;
-///
-/// use proc_macro::TokenStream;
-/// use syn::{parse_macro_input, AttributeArgs, ItemFn};
-///
-/// # const IGNORE: &str = stringify! {
-/// #[proc_macro_attribute]
-/// # };
-/// pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream {
-/// let args = parse_macro_input!(args as AttributeArgs);
-/// let input = parse_macro_input!(input as ItemFn);
-///
-/// /* ... */
-/// # TokenStream::new()
-/// }
-/// ```
-///
-/// For errors that arise later than the initial parsing stage, the
-/// [`.to_compile_error()`] method can be used to perform an explicit conversion
-/// to `compile_error!`.
-///
-/// [`.to_compile_error()`]: Error::to_compile_error
-///
-/// ```
-/// # extern crate proc_macro;
-/// #
-/// # use proc_macro::TokenStream;
-/// # use syn::{parse_macro_input, DeriveInput};
-/// #
-/// # const IGNORE: &str = stringify! {
-/// #[proc_macro_derive(MyDerive)]
-/// # };
-/// pub fn my_derive(input: TokenStream) -> TokenStream {
-/// let input = parse_macro_input!(input as DeriveInput);
-///
-/// // fn(DeriveInput) -> syn::Result<proc_macro2::TokenStream>
-/// expand::my_derive(input)
-/// .unwrap_or_else(|err| err.to_compile_error())
-/// .into()
-/// }
-/// #
-/// # mod expand {
-/// # use proc_macro2::TokenStream;
-/// # use syn::{DeriveInput, Result};
-/// #
-/// # pub fn my_derive(input: DeriveInput) -> Result<TokenStream> {
-/// # unimplemented!()
-/// # }
-/// # }
-/// ```
-#[derive(Clone)]
-pub struct Error {
- messages: Vec<ErrorMessage>,
-}
-
-struct ErrorMessage {
- // Span is implemented as an index into a thread-local interner to keep the
- // size small. It is not safe to access from a different thread. We want
- // errors to be Send and Sync to play nicely with the Failure crate, so pin
- // the span we're given to its original thread and assume it is
- // Span::call_site if accessed from any other thread.
- start_span: ThreadBound<Span>,
- end_span: ThreadBound<Span>,
- message: String,
-}
-
-#[cfg(test)]
-struct _Test
-where
- Error: Send + Sync;
-
-impl Error {
- /// Usually the [`ParseStream::error`] method will be used instead, which
- /// automatically uses the correct span from the current position of the
- /// parse stream.
- ///
- /// Use `Error::new` when the error needs to be triggered on some span other
- /// than where the parse stream is currently positioned.
- ///
- /// [`ParseStream::error`]: crate::parse::ParseBuffer::error
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{Error, Ident, LitStr, Result, Token};
- /// use syn::parse::ParseStream;
- ///
- /// // Parses input that looks like `name = "string"` where the key must be
- /// // the identifier `name` and the value may be any string literal.
- /// // Returns the string literal.
- /// fn parse_name(input: ParseStream) -> Result<LitStr> {
- /// let name_token: Ident = input.parse()?;
- /// if name_token != "name" {
- /// // Trigger an error not on the current position of the stream,
- /// // but on the position of the unexpected identifier.
- /// return Err(Error::new(name_token.span(), "expected `name`"));
- /// }
- /// input.parse::<Token![=]>()?;
- /// let s: LitStr = input.parse()?;
- /// Ok(s)
- /// }
- /// ```
- pub fn new<T: Display>(span: Span, message: T) -> Self {
- Error {
- messages: vec![ErrorMessage {
- start_span: ThreadBound::new(span),
- end_span: ThreadBound::new(span),
- message: message.to_string(),
- }],
- }
- }
-
- /// Creates an error with the specified message spanning the given syntax
- /// tree node.
- ///
- /// Unlike the `Error::new` constructor, this constructor takes an argument
- /// `tokens` which is a syntax tree node. This allows the resulting `Error`
- /// to attempt to span all tokens inside of `tokens`. While you would
- /// typically be able to use the `Spanned` trait with the above `Error::new`
- /// constructor, implementation limitations today mean that
- /// `Error::new_spanned` may provide a higher-quality error message on
- /// stable Rust.
- ///
- /// When in doubt it's recommended to stick to `Error::new` (or
- /// `ParseStream::error`)!
- #[cfg(feature = "printing")]
- pub fn new_spanned<T: ToTokens, U: Display>(tokens: T, message: U) -> Self {
- let mut iter = tokens.into_token_stream().into_iter();
- let start = iter.next().map_or_else(Span::call_site, |t| t.span());
- let end = iter.last().map_or(start, |t| t.span());
- Error {
- messages: vec![ErrorMessage {
- start_span: ThreadBound::new(start),
- end_span: ThreadBound::new(end),
- message: message.to_string(),
- }],
- }
- }
-
- /// The source location of the error.
- ///
- /// Spans are not thread-safe so this function returns `Span::call_site()`
- /// if called from a different thread than the one on which the `Error` was
- /// originally created.
- pub fn span(&self) -> Span {
- let start = match self.messages[0].start_span.get() {
- Some(span) => *span,
- None => return Span::call_site(),
- };
- let end = match self.messages[0].end_span.get() {
- Some(span) => *span,
- None => return Span::call_site(),
- };
- start.join(end).unwrap_or(start)
- }
-
- /// Render the error as an invocation of [`compile_error!`].
- ///
- /// The [`parse_macro_input!`] macro provides a convenient way to invoke
- /// this method correctly in a procedural macro.
- ///
- /// [`compile_error!`]: https://doc.rust-lang.org/std/macro.compile_error.html
- pub fn to_compile_error(&self) -> TokenStream {
- self.messages
- .iter()
- .map(ErrorMessage::to_compile_error)
- .collect()
- }
-
- /// Add another error message to self such that when `to_compile_error()` is
- /// called, both errors will be emitted together.
- pub fn combine(&mut self, another: Error) {
- self.messages.extend(another.messages)
- }
-}
-
-impl ErrorMessage {
- fn to_compile_error(&self) -> TokenStream {
- let start = self
- .start_span
- .get()
- .cloned()
- .unwrap_or_else(Span::call_site);
- let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site);
-
- // compile_error!($message)
- TokenStream::from_iter(vec![
- TokenTree::Ident(Ident::new("compile_error", start)),
- TokenTree::Punct({
- let mut punct = Punct::new('!', Spacing::Alone);
- punct.set_span(start);
- punct
- }),
- TokenTree::Group({
- let mut group = Group::new(Delimiter::Brace, {
- TokenStream::from_iter(vec![TokenTree::Literal({
- let mut string = Literal::string(&self.message);
- string.set_span(end);
- string
- })])
- });
- group.set_span(end);
- group
- }),
- ])
- }
-}
-
-#[cfg(feature = "parsing")]
-pub fn new_at<T: Display>(scope: Span, cursor: Cursor, message: T) -> Error {
- if cursor.eof() {
- Error::new(scope, format!("unexpected end of input, {}", message))
- } else {
- let span = crate::buffer::open_span_of_group(cursor);
- Error::new(span, message)
- }
-}
-
-impl Debug for Error {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- if self.messages.len() == 1 {
- formatter
- .debug_tuple("Error")
- .field(&self.messages[0])
- .finish()
- } else {
- formatter
- .debug_tuple("Error")
- .field(&self.messages)
- .finish()
- }
- }
-}
-
-impl Debug for ErrorMessage {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- Debug::fmt(&self.message, formatter)
- }
-}
-
-impl Display for Error {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str(&self.messages[0].message)
- }
-}
-
-impl Clone for ErrorMessage {
- fn clone(&self) -> Self {
- let start = self
- .start_span
- .get()
- .cloned()
- .unwrap_or_else(Span::call_site);
- let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site);
- ErrorMessage {
- start_span: ThreadBound::new(start),
- end_span: ThreadBound::new(end),
- message: self.message.clone(),
- }
- }
-}
-
-impl std::error::Error for Error {
- fn description(&self) -> &str {
- "parse error"
- }
-}
-
-impl From<LexError> for Error {
- fn from(err: LexError) -> Self {
- Error::new(Span::call_site(), format!("{:?}", err))
- }
-}
-
-impl IntoIterator for Error {
- type Item = Error;
- type IntoIter = IntoIter;
-
- fn into_iter(self) -> Self::IntoIter {
- IntoIter {
- messages: self.messages.into_iter(),
- }
- }
-}
-
-pub struct IntoIter {
- messages: vec::IntoIter<ErrorMessage>,
-}
-
-impl Iterator for IntoIter {
- type Item = Error;
-
- fn next(&mut self) -> Option<Self::Item> {
- Some(Error {
- messages: vec![self.messages.next()?],
- })
- }
-}
-
-impl<'a> IntoIterator for &'a Error {
- type Item = Error;
- type IntoIter = Iter<'a>;
-
- fn into_iter(self) -> Self::IntoIter {
- Iter {
- messages: self.messages.iter(),
- }
- }
-}
-
-pub struct Iter<'a> {
- messages: slice::Iter<'a, ErrorMessage>,
-}
-
-impl<'a> Iterator for Iter<'a> {
- type Item = Error;
-
- fn next(&mut self) -> Option<Self::Item> {
- Some(Error {
- messages: vec![self.messages.next()?.clone()],
- })
- }
-}
diff --git a/syn/src/export.rs b/syn/src/export.rs
deleted file mode 100644
index 37dc467..0000000
--- a/syn/src/export.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-pub use std::clone::Clone;
-pub use std::cmp::{Eq, PartialEq};
-pub use std::convert::From;
-pub use std::default::Default;
-pub use std::fmt::{self, Debug, Formatter};
-pub use std::hash::{Hash, Hasher};
-pub use std::marker::Copy;
-pub use std::option::Option::{None, Some};
-pub use std::result::Result::{Err, Ok};
-
-#[cfg(feature = "printing")]
-pub extern crate quote;
-
-pub use proc_macro2::{Span, TokenStream as TokenStream2};
-
-pub use crate::span::IntoSpans;
-
-#[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "proc-macro"
-))]
-pub use proc_macro::TokenStream;
-
-#[cfg(feature = "printing")]
-pub use quote::{ToTokens, TokenStreamExt};
-
-#[allow(non_camel_case_types)]
-pub type bool = help::Bool;
-#[allow(non_camel_case_types)]
-pub type str = help::Str;
-
-mod help {
- pub type Bool = bool;
- pub type Str = str;
-}
diff --git a/syn/src/expr.rs b/syn/src/expr.rs
deleted file mode 100644
index 603dc32..0000000
--- a/syn/src/expr.rs
+++ /dev/null
@@ -1,3236 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-#[cfg(feature = "extra-traits")]
-use crate::tt::TokenStreamHelper;
-use proc_macro2::{Span, TokenStream};
-#[cfg(feature = "printing")]
-use quote::IdentFragment;
-#[cfg(feature = "printing")]
-use std::fmt::{self, Display};
-use std::hash::{Hash, Hasher};
-#[cfg(all(feature = "parsing", feature = "full"))]
-use std::mem;
-
-ast_enum_of_structs! {
- /// A Rust expression.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enums
- ///
- /// This type is a syntax tree enum. In Syn this and other syntax tree enums
- /// are designed to be traversed using the following rebinding idiom.
- ///
- /// ```
- /// # use syn::Expr;
- /// #
- /// # fn example(expr: Expr) {
- /// # const IGNORE: &str = stringify! {
- /// let expr: Expr = /* ... */;
- /// # };
- /// match expr {
- /// Expr::MethodCall(expr) => {
- /// /* ... */
- /// }
- /// Expr::Cast(expr) => {
- /// /* ... */
- /// }
- /// Expr::If(expr) => {
- /// /* ... */
- /// }
- ///
- /// /* ... */
- /// # _ => {}
- /// # }
- /// # }
- /// ```
- ///
- /// We begin with a variable `expr` of type `Expr` that has no fields
- /// (because it is an enum), and by matching on it and rebinding a variable
- /// with the same name `expr` we effectively imbue our variable with all of
- /// the data fields provided by the variant that it turned out to be. So for
- /// example above if we ended up in the `MethodCall` case then we get to use
- /// `expr.receiver`, `expr.args` etc; if we ended up in the `If` case we get
- /// to use `expr.cond`, `expr.then_branch`, `expr.else_branch`.
- ///
- /// This approach avoids repeating the variant names twice on every line.
- ///
- /// ```
- /// # use syn::{Expr, ExprMethodCall};
- /// #
- /// # fn example(expr: Expr) {
- /// // Repetitive; recommend not doing this.
- /// match expr {
- /// Expr::MethodCall(ExprMethodCall { method, args, .. }) => {
- /// # }
- /// # _ => {}
- /// # }
- /// # }
- /// ```
- ///
- /// In general, the name to which a syntax tree enum variant is bound should
- /// be a suitable name for the complete syntax tree enum type.
- ///
- /// ```
- /// # use syn::{Expr, ExprField};
- /// #
- /// # fn example(discriminant: ExprField) {
- /// // Binding is called `base` which is the name I would use if I were
- /// // assigning `*discriminant.base` without an `if let`.
- /// if let Expr::Tuple(base) = *discriminant.base {
- /// # }
- /// # }
- /// ```
- ///
- /// A sign that you may not be choosing the right variable names is if you
- /// see names getting repeated in your code, like accessing
- /// `receiver.receiver` or `pat.pat` or `cond.cond`.
- pub enum Expr #manual_extra_traits {
- /// A slice literal expression: `[a, b, c, d]`.
- Array(ExprArray),
-
- /// An assignment expression: `a = compute()`.
- Assign(ExprAssign),
-
- /// A compound assignment expression: `counter += 1`.
- AssignOp(ExprAssignOp),
-
- /// An async block: `async { ... }`.
- Async(ExprAsync),
-
- /// An await expression: `fut.await`.
- Await(ExprAwait),
-
- /// A binary operation: `a + b`, `a * b`.
- Binary(ExprBinary),
-
- /// A blocked scope: `{ ... }`.
- Block(ExprBlock),
-
- /// A box expression: `box f`.
- Box(ExprBox),
-
- /// A `break`, with an optional label to break and an optional
- /// expression.
- Break(ExprBreak),
-
- /// A function call expression: `invoke(a, b)`.
- Call(ExprCall),
-
- /// A cast expression: `foo as f64`.
- Cast(ExprCast),
-
- /// A closure expression: `|a, b| a + b`.
- Closure(ExprClosure),
-
- /// A `continue`, with an optional label.
- Continue(ExprContinue),
-
- /// Access of a named struct field (`obj.k`) or unnamed tuple struct
- /// field (`obj.0`).
- Field(ExprField),
-
- /// A for loop: `for pat in expr { ... }`.
- ForLoop(ExprForLoop),
-
- /// An expression contained within invisible delimiters.
- ///
- /// This variant is important for faithfully representing the precedence
- /// of expressions and is related to `None`-delimited spans in a
- /// `TokenStream`.
- Group(ExprGroup),
-
- /// An `if` expression with an optional `else` block: `if expr { ... }
- /// else { ... }`.
- ///
- /// The `else` branch expression may only be an `If` or `Block`
- /// expression, not any of the other types of expression.
- If(ExprIf),
-
- /// A square bracketed indexing expression: `vector[2]`.
- Index(ExprIndex),
-
- /// A `let` guard: `let Some(x) = opt`.
- Let(ExprLet),
-
- /// A literal in place of an expression: `1`, `"foo"`.
- Lit(ExprLit),
-
- /// Conditionless loop: `loop { ... }`.
- Loop(ExprLoop),
-
- /// A macro invocation expression: `format!("{}", q)`.
- Macro(ExprMacro),
-
- /// A `match` expression: `match n { Some(n) => {}, None => {} }`.
- Match(ExprMatch),
-
- /// A method call expression: `x.foo::<T>(a, b)`.
- MethodCall(ExprMethodCall),
-
- /// A parenthesized expression: `(a + b)`.
- Paren(ExprParen),
-
- /// A path like `std::mem::replace` possibly containing generic
- /// parameters and a qualified self-type.
- ///
- /// A plain identifier like `x` is a path of length 1.
- Path(ExprPath),
-
- /// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`.
- Range(ExprRange),
-
- /// A referencing operation: `&a` or `&mut a`.
- Reference(ExprReference),
-
- /// An array literal constructed from one repeated element: `[0u8; N]`.
- Repeat(ExprRepeat),
-
- /// A `return`, with an optional value to be returned.
- Return(ExprReturn),
-
- /// A struct literal expression: `Point { x: 1, y: 1 }`.
- ///
- /// The `rest` provides the value of the remaining fields as in `S { a:
- /// 1, b: 1, ..rest }`.
- Struct(ExprStruct),
-
- /// A try-expression: `expr?`.
- Try(ExprTry),
-
- /// A try block: `try { ... }`.
- TryBlock(ExprTryBlock),
-
- /// A tuple expression: `(a, b, c, d)`.
- Tuple(ExprTuple),
-
- /// A type ascription expression: `foo: f64`.
- Type(ExprType),
-
- /// A unary operation: `!x`, `*x`.
- Unary(ExprUnary),
-
- /// An unsafe block: `unsafe { ... }`.
- Unsafe(ExprUnsafe),
-
- /// Tokens in expression position not interpreted by Syn.
- Verbatim(TokenStream),
-
- /// A while loop: `while expr { ... }`.
- While(ExprWhile),
-
- /// A yield expression: `yield expr`.
- Yield(ExprYield),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// A slice literal expression: `[a, b, c, d]`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprArray #full {
- pub attrs: Vec<Attribute>,
- pub bracket_token: token::Bracket,
- pub elems: Punctuated<Expr, Token![,]>,
- }
-}
-
-ast_struct! {
- /// An assignment expression: `a = compute()`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprAssign #full {
- pub attrs: Vec<Attribute>,
- pub left: Box<Expr>,
- pub eq_token: Token![=],
- pub right: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A compound assignment expression: `counter += 1`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprAssignOp #full {
- pub attrs: Vec<Attribute>,
- pub left: Box<Expr>,
- pub op: BinOp,
- pub right: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// An async block: `async { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprAsync #full {
- pub attrs: Vec<Attribute>,
- pub async_token: Token![async],
- pub capture: Option<Token![move]>,
- pub block: Block,
- }
-}
-
-ast_struct! {
- /// An await expression: `fut.await`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprAwait #full {
- pub attrs: Vec<Attribute>,
- pub base: Box<Expr>,
- pub dot_token: Token![.],
- pub await_token: token::Await,
- }
-}
-
-ast_struct! {
- /// A binary operation: `a + b`, `a * b`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprBinary {
- pub attrs: Vec<Attribute>,
- pub left: Box<Expr>,
- pub op: BinOp,
- pub right: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A blocked scope: `{ ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprBlock #full {
- pub attrs: Vec<Attribute>,
- pub label: Option<Label>,
- pub block: Block,
- }
-}
-
-ast_struct! {
- /// A box expression: `box f`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprBox #full {
- pub attrs: Vec<Attribute>,
- pub box_token: Token![box],
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A `break`, with an optional label to break and an optional
- /// expression.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprBreak #full {
- pub attrs: Vec<Attribute>,
- pub break_token: Token![break],
- pub label: Option<Lifetime>,
- pub expr: Option<Box<Expr>>,
- }
-}
-
-ast_struct! {
- /// A function call expression: `invoke(a, b)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprCall {
- pub attrs: Vec<Attribute>,
- pub func: Box<Expr>,
- pub paren_token: token::Paren,
- pub args: Punctuated<Expr, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A cast expression: `foo as f64`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprCast {
- pub attrs: Vec<Attribute>,
- pub expr: Box<Expr>,
- pub as_token: Token![as],
- pub ty: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A closure expression: `|a, b| a + b`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprClosure #full {
- pub attrs: Vec<Attribute>,
- pub asyncness: Option<Token![async]>,
- pub movability: Option<Token![static]>,
- pub capture: Option<Token![move]>,
- pub or1_token: Token![|],
- pub inputs: Punctuated<Pat, Token![,]>,
- pub or2_token: Token![|],
- pub output: ReturnType,
- pub body: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A `continue`, with an optional label.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprContinue #full {
- pub attrs: Vec<Attribute>,
- pub continue_token: Token![continue],
- pub label: Option<Lifetime>,
- }
-}
-
-ast_struct! {
- /// Access of a named struct field (`obj.k`) or unnamed tuple struct
- /// field (`obj.0`).
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprField {
- pub attrs: Vec<Attribute>,
- pub base: Box<Expr>,
- pub dot_token: Token![.],
- pub member: Member,
- }
-}
-
-ast_struct! {
- /// A for loop: `for pat in expr { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprForLoop #full {
- pub attrs: Vec<Attribute>,
- pub label: Option<Label>,
- pub for_token: Token![for],
- pub pat: Pat,
- pub in_token: Token![in],
- pub expr: Box<Expr>,
- pub body: Block,
- }
-}
-
-ast_struct! {
- /// An expression contained within invisible delimiters.
- ///
- /// This variant is important for faithfully representing the precedence
- /// of expressions and is related to `None`-delimited spans in a
- /// `TokenStream`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprGroup #full {
- pub attrs: Vec<Attribute>,
- pub group_token: token::Group,
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// An `if` expression with an optional `else` block: `if expr { ... }
- /// else { ... }`.
- ///
- /// The `else` branch expression may only be an `If` or `Block`
- /// expression, not any of the other types of expression.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprIf #full {
- pub attrs: Vec<Attribute>,
- pub if_token: Token![if],
- pub cond: Box<Expr>,
- pub then_branch: Block,
- pub else_branch: Option<(Token![else], Box<Expr>)>,
- }
-}
-
-ast_struct! {
- /// A square bracketed indexing expression: `vector[2]`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprIndex {
- pub attrs: Vec<Attribute>,
- pub expr: Box<Expr>,
- pub bracket_token: token::Bracket,
- pub index: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A `let` guard: `let Some(x) = opt`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprLet #full {
- pub attrs: Vec<Attribute>,
- pub let_token: Token![let],
- pub pat: Pat,
- pub eq_token: Token![=],
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A literal in place of an expression: `1`, `"foo"`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprLit {
- pub attrs: Vec<Attribute>,
- pub lit: Lit,
- }
-}
-
-ast_struct! {
- /// Conditionless loop: `loop { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprLoop #full {
- pub attrs: Vec<Attribute>,
- pub label: Option<Label>,
- pub loop_token: Token![loop],
- pub body: Block,
- }
-}
-
-ast_struct! {
- /// A macro invocation expression: `format!("{}", q)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprMacro #full {
- pub attrs: Vec<Attribute>,
- pub mac: Macro,
- }
-}
-
-ast_struct! {
- /// A `match` expression: `match n { Some(n) => {}, None => {} }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprMatch #full {
- pub attrs: Vec<Attribute>,
- pub match_token: Token![match],
- pub expr: Box<Expr>,
- pub brace_token: token::Brace,
- pub arms: Vec<Arm>,
- }
-}
-
-ast_struct! {
- /// A method call expression: `x.foo::<T>(a, b)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprMethodCall #full {
- pub attrs: Vec<Attribute>,
- pub receiver: Box<Expr>,
- pub dot_token: Token![.],
- pub method: Ident,
- pub turbofish: Option<MethodTurbofish>,
- pub paren_token: token::Paren,
- pub args: Punctuated<Expr, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A parenthesized expression: `(a + b)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprParen {
- pub attrs: Vec<Attribute>,
- pub paren_token: token::Paren,
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A path like `std::mem::replace` possibly containing generic
- /// parameters and a qualified self-type.
- ///
- /// A plain identifier like `x` is a path of length 1.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprPath {
- pub attrs: Vec<Attribute>,
- pub qself: Option<QSelf>,
- pub path: Path,
- }
-}
-
-ast_struct! {
- /// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprRange #full {
- pub attrs: Vec<Attribute>,
- pub from: Option<Box<Expr>>,
- pub limits: RangeLimits,
- pub to: Option<Box<Expr>>,
- }
-}
-
-ast_struct! {
- /// A referencing operation: `&a` or `&mut a`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprReference #full {
- pub attrs: Vec<Attribute>,
- pub and_token: Token![&],
- pub raw: Reserved,
- pub mutability: Option<Token![mut]>,
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// An array literal constructed from one repeated element: `[0u8; N]`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprRepeat #full {
- pub attrs: Vec<Attribute>,
- pub bracket_token: token::Bracket,
- pub expr: Box<Expr>,
- pub semi_token: Token![;],
- pub len: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A `return`, with an optional value to be returned.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprReturn #full {
- pub attrs: Vec<Attribute>,
- pub return_token: Token![return],
- pub expr: Option<Box<Expr>>,
- }
-}
-
-ast_struct! {
- /// A struct literal expression: `Point { x: 1, y: 1 }`.
- ///
- /// The `rest` provides the value of the remaining fields as in `S { a:
- /// 1, b: 1, ..rest }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprStruct #full {
- pub attrs: Vec<Attribute>,
- pub path: Path,
- pub brace_token: token::Brace,
- pub fields: Punctuated<FieldValue, Token![,]>,
- pub dot2_token: Option<Token![..]>,
- pub rest: Option<Box<Expr>>,
- }
-}
-
-ast_struct! {
- /// A try-expression: `expr?`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprTry #full {
- pub attrs: Vec<Attribute>,
- pub expr: Box<Expr>,
- pub question_token: Token![?],
- }
-}
-
-ast_struct! {
- /// A try block: `try { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprTryBlock #full {
- pub attrs: Vec<Attribute>,
- pub try_token: Token![try],
- pub block: Block,
- }
-}
-
-ast_struct! {
- /// A tuple expression: `(a, b, c, d)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprTuple #full {
- pub attrs: Vec<Attribute>,
- pub paren_token: token::Paren,
- pub elems: Punctuated<Expr, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A type ascription expression: `foo: f64`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprType #full {
- pub attrs: Vec<Attribute>,
- pub expr: Box<Expr>,
- pub colon_token: Token![:],
- pub ty: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A unary operation: `!x`, `*x`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ExprUnary {
- pub attrs: Vec<Attribute>,
- pub op: UnOp,
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// An unsafe block: `unsafe { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprUnsafe #full {
- pub attrs: Vec<Attribute>,
- pub unsafe_token: Token![unsafe],
- pub block: Block,
- }
-}
-
-ast_struct! {
- /// A while loop: `while expr { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprWhile #full {
- pub attrs: Vec<Attribute>,
- pub label: Option<Label>,
- pub while_token: Token![while],
- pub cond: Box<Expr>,
- pub body: Block,
- }
-}
-
-ast_struct! {
- /// A yield expression: `yield expr`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ExprYield #full {
- pub attrs: Vec<Attribute>,
- pub yield_token: Token![yield],
- pub expr: Option<Box<Expr>>,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Expr {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Expr {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (Expr::Array(this), Expr::Array(other)) => this == other,
- (Expr::Assign(this), Expr::Assign(other)) => this == other,
- (Expr::AssignOp(this), Expr::AssignOp(other)) => this == other,
- (Expr::Async(this), Expr::Async(other)) => this == other,
- (Expr::Await(this), Expr::Await(other)) => this == other,
- (Expr::Binary(this), Expr::Binary(other)) => this == other,
- (Expr::Block(this), Expr::Block(other)) => this == other,
- (Expr::Box(this), Expr::Box(other)) => this == other,
- (Expr::Break(this), Expr::Break(other)) => this == other,
- (Expr::Call(this), Expr::Call(other)) => this == other,
- (Expr::Cast(this), Expr::Cast(other)) => this == other,
- (Expr::Closure(this), Expr::Closure(other)) => this == other,
- (Expr::Continue(this), Expr::Continue(other)) => this == other,
- (Expr::Field(this), Expr::Field(other)) => this == other,
- (Expr::ForLoop(this), Expr::ForLoop(other)) => this == other,
- (Expr::Group(this), Expr::Group(other)) => this == other,
- (Expr::If(this), Expr::If(other)) => this == other,
- (Expr::Index(this), Expr::Index(other)) => this == other,
- (Expr::Let(this), Expr::Let(other)) => this == other,
- (Expr::Lit(this), Expr::Lit(other)) => this == other,
- (Expr::Loop(this), Expr::Loop(other)) => this == other,
- (Expr::Macro(this), Expr::Macro(other)) => this == other,
- (Expr::Match(this), Expr::Match(other)) => this == other,
- (Expr::MethodCall(this), Expr::MethodCall(other)) => this == other,
- (Expr::Paren(this), Expr::Paren(other)) => this == other,
- (Expr::Path(this), Expr::Path(other)) => this == other,
- (Expr::Range(this), Expr::Range(other)) => this == other,
- (Expr::Reference(this), Expr::Reference(other)) => this == other,
- (Expr::Repeat(this), Expr::Repeat(other)) => this == other,
- (Expr::Return(this), Expr::Return(other)) => this == other,
- (Expr::Struct(this), Expr::Struct(other)) => this == other,
- (Expr::Try(this), Expr::Try(other)) => this == other,
- (Expr::TryBlock(this), Expr::TryBlock(other)) => this == other,
- (Expr::Tuple(this), Expr::Tuple(other)) => this == other,
- (Expr::Type(this), Expr::Type(other)) => this == other,
- (Expr::Unary(this), Expr::Unary(other)) => this == other,
- (Expr::Unsafe(this), Expr::Unsafe(other)) => this == other,
- (Expr::Verbatim(this), Expr::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- (Expr::While(this), Expr::While(other)) => this == other,
- (Expr::Yield(this), Expr::Yield(other)) => this == other,
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Expr {
- fn hash<H>(&self, hash: &mut H)
- where
- H: Hasher,
- {
- match self {
- Expr::Array(expr) => {
- hash.write_u8(0);
- expr.hash(hash);
- }
- Expr::Assign(expr) => {
- hash.write_u8(1);
- expr.hash(hash);
- }
- Expr::AssignOp(expr) => {
- hash.write_u8(2);
- expr.hash(hash);
- }
- Expr::Async(expr) => {
- hash.write_u8(3);
- expr.hash(hash);
- }
- Expr::Await(expr) => {
- hash.write_u8(4);
- expr.hash(hash);
- }
- Expr::Binary(expr) => {
- hash.write_u8(5);
- expr.hash(hash);
- }
- Expr::Block(expr) => {
- hash.write_u8(6);
- expr.hash(hash);
- }
- Expr::Box(expr) => {
- hash.write_u8(7);
- expr.hash(hash);
- }
- Expr::Break(expr) => {
- hash.write_u8(8);
- expr.hash(hash);
- }
- Expr::Call(expr) => {
- hash.write_u8(9);
- expr.hash(hash);
- }
- Expr::Cast(expr) => {
- hash.write_u8(10);
- expr.hash(hash);
- }
- Expr::Closure(expr) => {
- hash.write_u8(11);
- expr.hash(hash);
- }
- Expr::Continue(expr) => {
- hash.write_u8(12);
- expr.hash(hash);
- }
- Expr::Field(expr) => {
- hash.write_u8(13);
- expr.hash(hash);
- }
- Expr::ForLoop(expr) => {
- hash.write_u8(14);
- expr.hash(hash);
- }
- Expr::Group(expr) => {
- hash.write_u8(15);
- expr.hash(hash);
- }
- Expr::If(expr) => {
- hash.write_u8(16);
- expr.hash(hash);
- }
- Expr::Index(expr) => {
- hash.write_u8(17);
- expr.hash(hash);
- }
- Expr::Let(expr) => {
- hash.write_u8(18);
- expr.hash(hash);
- }
- Expr::Lit(expr) => {
- hash.write_u8(19);
- expr.hash(hash);
- }
- Expr::Loop(expr) => {
- hash.write_u8(20);
- expr.hash(hash);
- }
- Expr::Macro(expr) => {
- hash.write_u8(21);
- expr.hash(hash);
- }
- Expr::Match(expr) => {
- hash.write_u8(22);
- expr.hash(hash);
- }
- Expr::MethodCall(expr) => {
- hash.write_u8(23);
- expr.hash(hash);
- }
- Expr::Paren(expr) => {
- hash.write_u8(24);
- expr.hash(hash);
- }
- Expr::Path(expr) => {
- hash.write_u8(25);
- expr.hash(hash);
- }
- Expr::Range(expr) => {
- hash.write_u8(26);
- expr.hash(hash);
- }
- Expr::Reference(expr) => {
- hash.write_u8(27);
- expr.hash(hash);
- }
- Expr::Repeat(expr) => {
- hash.write_u8(28);
- expr.hash(hash);
- }
- Expr::Return(expr) => {
- hash.write_u8(29);
- expr.hash(hash);
- }
- Expr::Struct(expr) => {
- hash.write_u8(30);
- expr.hash(hash);
- }
- Expr::Try(expr) => {
- hash.write_u8(31);
- expr.hash(hash);
- }
- Expr::TryBlock(expr) => {
- hash.write_u8(32);
- expr.hash(hash);
- }
- Expr::Tuple(expr) => {
- hash.write_u8(33);
- expr.hash(hash);
- }
- Expr::Type(expr) => {
- hash.write_u8(34);
- expr.hash(hash);
- }
- Expr::Unary(expr) => {
- hash.write_u8(35);
- expr.hash(hash);
- }
- Expr::Unsafe(expr) => {
- hash.write_u8(36);
- expr.hash(hash);
- }
- Expr::Verbatim(expr) => {
- hash.write_u8(37);
- TokenStreamHelper(expr).hash(hash);
- }
- Expr::While(expr) => {
- hash.write_u8(38);
- expr.hash(hash);
- }
- Expr::Yield(expr) => {
- hash.write_u8(39);
- expr.hash(hash);
- }
- Expr::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-impl Expr {
- #[cfg(all(feature = "parsing", feature = "full"))]
- pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> {
- match self {
- Expr::Box(ExprBox { attrs, .. })
- | Expr::Array(ExprArray { attrs, .. })
- | Expr::Call(ExprCall { attrs, .. })
- | Expr::MethodCall(ExprMethodCall { attrs, .. })
- | Expr::Tuple(ExprTuple { attrs, .. })
- | Expr::Binary(ExprBinary { attrs, .. })
- | Expr::Unary(ExprUnary { attrs, .. })
- | Expr::Lit(ExprLit { attrs, .. })
- | Expr::Cast(ExprCast { attrs, .. })
- | Expr::Type(ExprType { attrs, .. })
- | Expr::Let(ExprLet { attrs, .. })
- | Expr::If(ExprIf { attrs, .. })
- | Expr::While(ExprWhile { attrs, .. })
- | Expr::ForLoop(ExprForLoop { attrs, .. })
- | Expr::Loop(ExprLoop { attrs, .. })
- | Expr::Match(ExprMatch { attrs, .. })
- | Expr::Closure(ExprClosure { attrs, .. })
- | Expr::Unsafe(ExprUnsafe { attrs, .. })
- | Expr::Block(ExprBlock { attrs, .. })
- | Expr::Assign(ExprAssign { attrs, .. })
- | Expr::AssignOp(ExprAssignOp { attrs, .. })
- | Expr::Field(ExprField { attrs, .. })
- | Expr::Index(ExprIndex { attrs, .. })
- | Expr::Range(ExprRange { attrs, .. })
- | Expr::Path(ExprPath { attrs, .. })
- | Expr::Reference(ExprReference { attrs, .. })
- | Expr::Break(ExprBreak { attrs, .. })
- | Expr::Continue(ExprContinue { attrs, .. })
- | Expr::Return(ExprReturn { attrs, .. })
- | Expr::Macro(ExprMacro { attrs, .. })
- | Expr::Struct(ExprStruct { attrs, .. })
- | Expr::Repeat(ExprRepeat { attrs, .. })
- | Expr::Paren(ExprParen { attrs, .. })
- | Expr::Group(ExprGroup { attrs, .. })
- | Expr::Try(ExprTry { attrs, .. })
- | Expr::Async(ExprAsync { attrs, .. })
- | Expr::Await(ExprAwait { attrs, .. })
- | Expr::TryBlock(ExprTryBlock { attrs, .. })
- | Expr::Yield(ExprYield { attrs, .. }) => mem::replace(attrs, new),
- Expr::Verbatim(_) => Vec::new(),
- Expr::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-ast_enum! {
- /// A struct or tuple struct field accessed in a struct literal or field
- /// expression.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- #[derive(Eq, PartialEq, Hash)]
- pub enum Member #manual_extra_traits {
- /// A named field like `self.x`.
- Named(Ident),
- /// An unnamed field like `self.0`.
- Unnamed(Index),
- }
-}
-
-#[cfg(feature = "printing")]
-impl IdentFragment for Member {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Member::Named(m) => Display::fmt(m, formatter),
- Member::Unnamed(m) => Display::fmt(&m.index, formatter),
- }
- }
-
- fn span(&self) -> Option<Span> {
- match self {
- Member::Named(m) => Some(m.span()),
- Member::Unnamed(m) => Some(m.span),
- }
- }
-}
-
-ast_struct! {
- /// The index of an unnamed tuple struct field.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Index #manual_extra_traits {
- pub index: u32,
- pub span: Span,
- }
-}
-
-impl From<usize> for Index {
- fn from(index: usize) -> Index {
- assert!(index < u32::max_value() as usize);
- Index {
- index: index as u32,
- span: Span::call_site(),
- }
- }
-}
-
-impl Eq for Index {}
-
-impl PartialEq for Index {
- fn eq(&self, other: &Self) -> bool {
- self.index == other.index
- }
-}
-
-impl Hash for Index {
- fn hash<H: Hasher>(&self, state: &mut H) {
- self.index.hash(state);
- }
-}
-
-#[cfg(feature = "printing")]
-impl IdentFragment for Index {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- Display::fmt(&self.index, formatter)
- }
-
- fn span(&self) -> Option<Span> {
- Some(self.span)
- }
-}
-
-#[cfg(feature = "full")]
-ast_struct! {
- #[derive(Default)]
- pub struct Reserved {
- _private: (),
- }
-}
-
-#[cfg(feature = "full")]
-ast_struct! {
- /// The `::<>` explicit type parameters passed to a method call:
- /// `parse::<u64>()`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct MethodTurbofish {
- pub colon2_token: Token![::],
- pub lt_token: Token![<],
- pub args: Punctuated<GenericMethodArgument, Token![,]>,
- pub gt_token: Token![>],
- }
-}
-
-#[cfg(feature = "full")]
-ast_enum! {
- /// An individual generic argument to a method, like `T`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub enum GenericMethodArgument {
- /// A type argument.
- Type(Type),
- /// A const expression. Must be inside of a block.
- ///
- /// NOTE: Identity expressions are represented as Type arguments, as
- /// they are indistinguishable syntactically.
- Const(Expr),
- }
-}
-
-#[cfg(feature = "full")]
-ast_struct! {
- /// A field-value pair in a struct literal.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct FieldValue {
- /// Attributes tagged on the field.
- pub attrs: Vec<Attribute>,
-
- /// Name or index of the field.
- pub member: Member,
-
- /// The colon in `Struct { x: x }`. If written in shorthand like
- /// `Struct { x }`, there is no colon.
- pub colon_token: Option<Token![:]>,
-
- /// Value of the field.
- pub expr: Expr,
- }
-}
-
-#[cfg(feature = "full")]
-ast_struct! {
- /// A lifetime labeling a `for`, `while`, or `loop`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct Label {
- pub name: Lifetime,
- pub colon_token: Token![:],
- }
-}
-
-#[cfg(feature = "full")]
-ast_struct! {
- /// One arm of a `match` expression: `0...10 => { return true; }`.
- ///
- /// As in:
- ///
- /// ```
- /// # fn f() -> bool {
- /// # let n = 0;
- /// match n {
- /// 0...10 => {
- /// return true;
- /// }
- /// // ...
- /// # _ => {}
- /// }
- /// # false
- /// # }
- /// ```
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct Arm {
- pub attrs: Vec<Attribute>,
- pub pat: Pat,
- pub guard: Option<(Token![if], Box<Expr>)>,
- pub fat_arrow_token: Token![=>],
- pub body: Box<Expr>,
- pub comma: Option<Token![,]>,
- }
-}
-
-#[cfg(feature = "full")]
-ast_enum! {
- /// Limit types of a range, inclusive or exclusive.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- #[cfg_attr(feature = "clone-impls", derive(Copy))]
- pub enum RangeLimits {
- /// Inclusive at the beginning, exclusive at the end.
- HalfOpen(Token![..]),
- /// Inclusive at the beginning and end.
- Closed(Token![..=]),
- }
-}
-
-#[cfg(any(feature = "parsing", feature = "printing"))]
-#[cfg(feature = "full")]
-pub(crate) fn requires_terminator(expr: &Expr) -> bool {
- // see https://github.com/rust-lang/rust/blob/eb8f2586e/src/libsyntax/parse/classify.rs#L17-L37
- match *expr {
- Expr::Unsafe(..)
- | Expr::Block(..)
- | Expr::If(..)
- | Expr::Match(..)
- | Expr::While(..)
- | Expr::Loop(..)
- | Expr::ForLoop(..)
- | Expr::Async(..)
- | Expr::TryBlock(..) => false,
- _ => true,
- }
-}
-
-#[cfg(feature = "parsing")]
-pub(crate) mod parsing {
- use super::*;
-
- use crate::parse::discouraged::Speculative;
- use crate::parse::{Parse, ParseStream, Result};
- use crate::path;
-
- // When we're parsing expressions which occur before blocks, like in an if
- // statement's condition, we cannot parse a struct literal.
- //
- // Struct literals are ambiguous in certain positions
- // https://github.com/rust-lang/rfcs/pull/92
- #[derive(Copy, Clone)]
- pub struct AllowStruct(bool);
-
- #[derive(Copy, Clone, PartialEq, PartialOrd)]
- enum Precedence {
- Any,
- Assign,
- Range,
- Or,
- And,
- Compare,
- BitOr,
- BitXor,
- BitAnd,
- Shift,
- Arithmetic,
- Term,
- Cast,
- }
-
- impl Precedence {
- fn of(op: &BinOp) -> Self {
- match *op {
- BinOp::Add(_) | BinOp::Sub(_) => Precedence::Arithmetic,
- BinOp::Mul(_) | BinOp::Div(_) | BinOp::Rem(_) => Precedence::Term,
- BinOp::And(_) => Precedence::And,
- BinOp::Or(_) => Precedence::Or,
- BinOp::BitXor(_) => Precedence::BitXor,
- BinOp::BitAnd(_) => Precedence::BitAnd,
- BinOp::BitOr(_) => Precedence::BitOr,
- BinOp::Shl(_) | BinOp::Shr(_) => Precedence::Shift,
- BinOp::Eq(_)
- | BinOp::Lt(_)
- | BinOp::Le(_)
- | BinOp::Ne(_)
- | BinOp::Ge(_)
- | BinOp::Gt(_) => Precedence::Compare,
- BinOp::AddEq(_)
- | BinOp::SubEq(_)
- | BinOp::MulEq(_)
- | BinOp::DivEq(_)
- | BinOp::RemEq(_)
- | BinOp::BitXorEq(_)
- | BinOp::BitAndEq(_)
- | BinOp::BitOrEq(_)
- | BinOp::ShlEq(_)
- | BinOp::ShrEq(_) => Precedence::Assign,
- }
- }
- }
-
- impl Parse for Expr {
- fn parse(input: ParseStream) -> Result<Self> {
- ambiguous_expr(input, AllowStruct(true))
- }
- }
-
- #[cfg(feature = "full")]
- fn expr_no_struct(input: ParseStream) -> Result<Expr> {
- ambiguous_expr(input, AllowStruct(false))
- }
-
- #[cfg(feature = "full")]
- fn parse_expr(
- input: ParseStream,
- mut lhs: Expr,
- allow_struct: AllowStruct,
- base: Precedence,
- ) -> Result<Expr> {
- loop {
- if input
- .fork()
- .parse::<BinOp>()
- .ok()
- .map_or(false, |op| Precedence::of(&op) >= base)
- {
- let op: BinOp = input.parse()?;
- let precedence = Precedence::of(&op);
- let mut rhs = unary_expr(input, allow_struct)?;
- loop {
- let next = peek_precedence(input);
- if next > precedence || next == precedence && precedence == Precedence::Assign {
- rhs = parse_expr(input, rhs, allow_struct, next)?;
- } else {
- break;
- }
- }
- lhs = if precedence == Precedence::Assign {
- Expr::AssignOp(ExprAssignOp {
- attrs: Vec::new(),
- left: Box::new(lhs),
- op,
- right: Box::new(rhs),
- })
- } else {
- Expr::Binary(ExprBinary {
- attrs: Vec::new(),
- left: Box::new(lhs),
- op,
- right: Box::new(rhs),
- })
- };
- } else if Precedence::Assign >= base
- && input.peek(Token![=])
- && !input.peek(Token![==])
- && !input.peek(Token![=>])
- {
- let eq_token: Token![=] = input.parse()?;
- let mut rhs = unary_expr(input, allow_struct)?;
- loop {
- let next = peek_precedence(input);
- if next >= Precedence::Assign {
- rhs = parse_expr(input, rhs, allow_struct, next)?;
- } else {
- break;
- }
- }
- lhs = Expr::Assign(ExprAssign {
- attrs: Vec::new(),
- left: Box::new(lhs),
- eq_token,
- right: Box::new(rhs),
- });
- } else if Precedence::Range >= base && input.peek(Token![..]) {
- let limits: RangeLimits = input.parse()?;
- let rhs = if input.is_empty()
- || input.peek(Token![,])
- || input.peek(Token![;])
- || !allow_struct.0 && input.peek(token::Brace)
- {
- None
- } else {
- let mut rhs = unary_expr(input, allow_struct)?;
- loop {
- let next = peek_precedence(input);
- if next > Precedence::Range {
- rhs = parse_expr(input, rhs, allow_struct, next)?;
- } else {
- break;
- }
- }
- Some(rhs)
- };
- lhs = Expr::Range(ExprRange {
- attrs: Vec::new(),
- from: Some(Box::new(lhs)),
- limits,
- to: rhs.map(Box::new),
- });
- } else if Precedence::Cast >= base && input.peek(Token![as]) {
- let as_token: Token![as] = input.parse()?;
- let ty = input.call(Type::without_plus)?;
- lhs = Expr::Cast(ExprCast {
- attrs: Vec::new(),
- expr: Box::new(lhs),
- as_token,
- ty: Box::new(ty),
- });
- } else if Precedence::Cast >= base && input.peek(Token![:]) && !input.peek(Token![::]) {
- let colon_token: Token![:] = input.parse()?;
- let ty = input.call(Type::without_plus)?;
- lhs = Expr::Type(ExprType {
- attrs: Vec::new(),
- expr: Box::new(lhs),
- colon_token,
- ty: Box::new(ty),
- });
- } else {
- break;
- }
- }
- Ok(lhs)
- }
-
- #[cfg(not(feature = "full"))]
- fn parse_expr(
- input: ParseStream,
- mut lhs: Expr,
- allow_struct: AllowStruct,
- base: Precedence,
- ) -> Result<Expr> {
- loop {
- if input
- .fork()
- .parse::<BinOp>()
- .ok()
- .map_or(false, |op| Precedence::of(&op) >= base)
- {
- let op: BinOp = input.parse()?;
- let precedence = Precedence::of(&op);
- let mut rhs = unary_expr(input, allow_struct)?;
- loop {
- let next = peek_precedence(input);
- if next > precedence || next == precedence && precedence == Precedence::Assign {
- rhs = parse_expr(input, rhs, allow_struct, next)?;
- } else {
- break;
- }
- }
- lhs = Expr::Binary(ExprBinary {
- attrs: Vec::new(),
- left: Box::new(lhs),
- op,
- right: Box::new(rhs),
- });
- } else if Precedence::Cast >= base && input.peek(Token![as]) {
- let as_token: Token![as] = input.parse()?;
- let ty = input.call(Type::without_plus)?;
- lhs = Expr::Cast(ExprCast {
- attrs: Vec::new(),
- expr: Box::new(lhs),
- as_token,
- ty: Box::new(ty),
- });
- } else {
- break;
- }
- }
- Ok(lhs)
- }
-
- fn peek_precedence(input: ParseStream) -> Precedence {
- if let Ok(op) = input.fork().parse() {
- Precedence::of(&op)
- } else if input.peek(Token![=]) && !input.peek(Token![=>]) {
- Precedence::Assign
- } else if input.peek(Token![..]) {
- Precedence::Range
- } else if input.peek(Token![as]) || input.peek(Token![:]) && !input.peek(Token![::]) {
- Precedence::Cast
- } else {
- Precedence::Any
- }
- }
-
- // Parse an arbitrary expression.
- fn ambiguous_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- let lhs = unary_expr(input, allow_struct)?;
- parse_expr(input, lhs, allow_struct, Precedence::Any)
- }
-
- // <UnOp> <trailer>
- // & <trailer>
- // &mut <trailer>
- // box <trailer>
- #[cfg(feature = "full")]
- fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- let ahead = input.fork();
- let attrs = ahead.call(Attribute::parse_outer)?;
- if ahead.peek(Token![&])
- || ahead.peek(Token![box])
- || ahead.peek(Token![*])
- || ahead.peek(Token![!])
- || ahead.peek(Token![-])
- {
- input.advance_to(&ahead);
- if input.peek(Token![&]) {
- Ok(Expr::Reference(ExprReference {
- attrs,
- and_token: input.parse()?,
- raw: Reserved::default(),
- mutability: input.parse()?,
- expr: Box::new(unary_expr(input, allow_struct)?),
- }))
- } else if input.peek(Token![box]) {
- Ok(Expr::Box(ExprBox {
- attrs,
- box_token: input.parse()?,
- expr: Box::new(unary_expr(input, allow_struct)?),
- }))
- } else {
- Ok(Expr::Unary(ExprUnary {
- attrs,
- op: input.parse()?,
- expr: Box::new(unary_expr(input, allow_struct)?),
- }))
- }
- } else {
- trailer_expr(input, allow_struct)
- }
- }
-
- #[cfg(not(feature = "full"))]
- fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- let ahead = input.fork();
- let attrs = ahead.call(Attribute::parse_outer)?;
- if ahead.peek(Token![*]) || ahead.peek(Token![!]) || ahead.peek(Token![-]) {
- input.advance_to(&ahead);
- Ok(Expr::Unary(ExprUnary {
- attrs,
- op: input.parse()?,
- expr: Box::new(unary_expr(input, allow_struct)?),
- }))
- } else {
- trailer_expr(input, allow_struct)
- }
- }
-
- // <atom> (..<args>) ...
- // <atom> . <ident> (..<args>) ...
- // <atom> . <ident> ...
- // <atom> . <lit> ...
- // <atom> [ <expr> ] ...
- // <atom> ? ...
- #[cfg(feature = "full")]
- fn trailer_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- if input.peek(token::Group) {
- return input.call(expr_group).map(Expr::Group);
- }
-
- let outer_attrs = input.call(Attribute::parse_outer)?;
-
- let atom = atom_expr(input, allow_struct)?;
- let mut e = trailer_helper(input, atom)?;
-
- let inner_attrs = e.replace_attrs(Vec::new());
- let attrs = private::attrs(outer_attrs, inner_attrs);
- e.replace_attrs(attrs);
- Ok(e)
- }
-
- #[cfg(feature = "full")]
- fn trailer_helper(input: ParseStream, mut e: Expr) -> Result<Expr> {
- loop {
- if input.peek(token::Paren) {
- let content;
- e = Expr::Call(ExprCall {
- attrs: Vec::new(),
- func: Box::new(e),
- paren_token: parenthesized!(content in input),
- args: content.parse_terminated(Expr::parse)?,
- });
- } else if input.peek(Token![.]) && !input.peek(Token![..]) {
- let dot_token: Token![.] = input.parse()?;
-
- if input.peek(token::Await) {
- e = Expr::Await(ExprAwait {
- attrs: Vec::new(),
- base: Box::new(e),
- dot_token,
- await_token: input.parse()?,
- });
- continue;
- }
-
- let member: Member = input.parse()?;
- let turbofish = if member.is_named() && input.peek(Token![::]) {
- Some(MethodTurbofish {
- colon2_token: input.parse()?,
- lt_token: input.parse()?,
- args: {
- let mut args = Punctuated::new();
- loop {
- if input.peek(Token![>]) {
- break;
- }
- let value = input.call(generic_method_argument)?;
- args.push_value(value);
- if input.peek(Token![>]) {
- break;
- }
- let punct = input.parse()?;
- args.push_punct(punct);
- }
- args
- },
- gt_token: input.parse()?,
- })
- } else {
- None
- };
-
- if turbofish.is_some() || input.peek(token::Paren) {
- if let Member::Named(method) = member {
- let content;
- e = Expr::MethodCall(ExprMethodCall {
- attrs: Vec::new(),
- receiver: Box::new(e),
- dot_token,
- method,
- turbofish,
- paren_token: parenthesized!(content in input),
- args: content.parse_terminated(Expr::parse)?,
- });
- continue;
- }
- }
-
- e = Expr::Field(ExprField {
- attrs: Vec::new(),
- base: Box::new(e),
- dot_token,
- member,
- });
- } else if input.peek(token::Bracket) {
- let content;
- e = Expr::Index(ExprIndex {
- attrs: Vec::new(),
- expr: Box::new(e),
- bracket_token: bracketed!(content in input),
- index: content.parse()?,
- });
- } else if input.peek(Token![?]) {
- e = Expr::Try(ExprTry {
- attrs: Vec::new(),
- expr: Box::new(e),
- question_token: input.parse()?,
- });
- } else {
- break;
- }
- }
- Ok(e)
- }
-
- #[cfg(not(feature = "full"))]
- fn trailer_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- let mut e = atom_expr(input, allow_struct)?;
-
- loop {
- if input.peek(token::Paren) {
- let content;
- e = Expr::Call(ExprCall {
- attrs: Vec::new(),
- func: Box::new(e),
- paren_token: parenthesized!(content in input),
- args: content.parse_terminated(Expr::parse)?,
- });
- } else if input.peek(Token![.]) && !input.peek(Token![..]) && !input.peek2(token::Await)
- {
- e = Expr::Field(ExprField {
- attrs: Vec::new(),
- base: Box::new(e),
- dot_token: input.parse()?,
- member: input.parse()?,
- });
- } else if input.peek(token::Bracket) {
- let content;
- e = Expr::Index(ExprIndex {
- attrs: Vec::new(),
- expr: Box::new(e),
- bracket_token: bracketed!(content in input),
- index: content.parse()?,
- });
- } else {
- break;
- }
- }
-
- Ok(e)
- }
-
- // Parse all atomic expressions which don't have to worry about precedence
- // interactions, as they are fully contained.
- #[cfg(feature = "full")]
- fn atom_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- if input.peek(token::Group) {
- input.call(expr_group).map(Expr::Group)
- } else if input.peek(Lit) {
- input.parse().map(Expr::Lit)
- } else if input.peek(Token![async])
- && (input.peek2(token::Brace) || input.peek2(Token![move]) && input.peek3(token::Brace))
- {
- input.call(expr_async).map(Expr::Async)
- } else if input.peek(Token![try]) && input.peek2(token::Brace) {
- input.call(expr_try_block).map(Expr::TryBlock)
- } else if input.peek(Token![|])
- || input.peek(Token![async]) && (input.peek2(Token![|]) || input.peek2(Token![move]))
- || input.peek(Token![static])
- || input.peek(Token![move])
- {
- expr_closure(input, allow_struct).map(Expr::Closure)
- } else if input.peek(Ident)
- || input.peek(Token![::])
- || input.peek(Token![<])
- || input.peek(Token![self])
- || input.peek(Token![Self])
- || input.peek(Token![super])
- || input.peek(Token![extern])
- || input.peek(Token![crate])
- {
- path_or_macro_or_struct(input, allow_struct)
- } else if input.peek(token::Paren) {
- paren_or_tuple(input)
- } else if input.peek(Token![break]) {
- expr_break(input, allow_struct).map(Expr::Break)
- } else if input.peek(Token![continue]) {
- input.call(expr_continue).map(Expr::Continue)
- } else if input.peek(Token![return]) {
- expr_ret(input, allow_struct).map(Expr::Return)
- } else if input.peek(token::Bracket) {
- array_or_repeat(input)
- } else if input.peek(Token![let]) {
- input.call(expr_let).map(Expr::Let)
- } else if input.peek(Token![if]) {
- input.parse().map(Expr::If)
- } else if input.peek(Token![while]) {
- input.parse().map(Expr::While)
- } else if input.peek(Token![for]) {
- input.parse().map(Expr::ForLoop)
- } else if input.peek(Token![loop]) {
- input.parse().map(Expr::Loop)
- } else if input.peek(Token![match]) {
- input.parse().map(Expr::Match)
- } else if input.peek(Token![yield]) {
- input.call(expr_yield).map(Expr::Yield)
- } else if input.peek(Token![unsafe]) {
- input.call(expr_unsafe).map(Expr::Unsafe)
- } else if input.peek(token::Brace) {
- input.call(expr_block).map(Expr::Block)
- } else if input.peek(Token![..]) {
- expr_range(input, allow_struct).map(Expr::Range)
- } else if input.peek(Lifetime) {
- let the_label: Label = input.parse()?;
- let mut expr = if input.peek(Token![while]) {
- Expr::While(input.parse()?)
- } else if input.peek(Token![for]) {
- Expr::ForLoop(input.parse()?)
- } else if input.peek(Token![loop]) {
- Expr::Loop(input.parse()?)
- } else if input.peek(token::Brace) {
- Expr::Block(input.call(expr_block)?)
- } else {
- return Err(input.error("expected loop or block expression"));
- };
- match &mut expr {
- Expr::While(ExprWhile { label, .. })
- | Expr::ForLoop(ExprForLoop { label, .. })
- | Expr::Loop(ExprLoop { label, .. })
- | Expr::Block(ExprBlock { label, .. }) => *label = Some(the_label),
- _ => unreachable!(),
- }
- Ok(expr)
- } else {
- Err(input.error("expected expression"))
- }
- }
-
- #[cfg(not(feature = "full"))]
- fn atom_expr(input: ParseStream, _allow_struct: AllowStruct) -> Result<Expr> {
- if input.peek(Lit) {
- input.parse().map(Expr::Lit)
- } else if input.peek(token::Paren) {
- input.call(expr_paren).map(Expr::Paren)
- } else if input.peek(Ident)
- || input.peek(Token![::])
- || input.peek(Token![<])
- || input.peek(Token![self])
- || input.peek(Token![Self])
- || input.peek(Token![super])
- || input.peek(Token![extern])
- || input.peek(Token![crate])
- {
- input.parse().map(Expr::Path)
- } else {
- Err(input.error("unsupported expression; enable syn's features=[\"full\"]"))
- }
- }
-
- #[cfg(feature = "full")]
- fn path_or_macro_or_struct(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- let expr: ExprPath = input.parse()?;
- if expr.qself.is_some() {
- return Ok(Expr::Path(expr));
- }
-
- if input.peek(Token![!]) && !input.peek(Token![!=]) {
- let mut contains_arguments = false;
- for segment in &expr.path.segments {
- match segment.arguments {
- PathArguments::None => {}
- PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => {
- contains_arguments = true;
- }
- }
- }
-
- if !contains_arguments {
- let bang_token: Token![!] = input.parse()?;
- let (delimiter, tokens) = mac::parse_delimiter(input)?;
- return Ok(Expr::Macro(ExprMacro {
- attrs: Vec::new(),
- mac: Macro {
- path: expr.path,
- bang_token,
- delimiter,
- tokens,
- },
- }));
- }
- }
-
- if allow_struct.0 && input.peek(token::Brace) {
- let outer_attrs = Vec::new();
- expr_struct_helper(input, outer_attrs, expr.path).map(Expr::Struct)
- } else {
- Ok(Expr::Path(expr))
- }
- }
-
- #[cfg(feature = "full")]
- fn paren_or_tuple(input: ParseStream) -> Result<Expr> {
- let content;
- let paren_token = parenthesized!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- if content.is_empty() {
- return Ok(Expr::Tuple(ExprTuple {
- attrs: inner_attrs,
- paren_token,
- elems: Punctuated::new(),
- }));
- }
-
- let first: Expr = content.parse()?;
- if content.is_empty() {
- return Ok(Expr::Paren(ExprParen {
- attrs: inner_attrs,
- paren_token,
- expr: Box::new(first),
- }));
- }
-
- let mut elems = Punctuated::new();
- elems.push_value(first);
- while !content.is_empty() {
- let punct = content.parse()?;
- elems.push_punct(punct);
- if content.is_empty() {
- break;
- }
- let value = content.parse()?;
- elems.push_value(value);
- }
- Ok(Expr::Tuple(ExprTuple {
- attrs: inner_attrs,
- paren_token,
- elems,
- }))
- }
-
- #[cfg(feature = "full")]
- fn array_or_repeat(input: ParseStream) -> Result<Expr> {
- let content;
- let bracket_token = bracketed!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- if content.is_empty() {
- return Ok(Expr::Array(ExprArray {
- attrs: inner_attrs,
- bracket_token,
- elems: Punctuated::new(),
- }));
- }
-
- let first: Expr = content.parse()?;
- if content.is_empty() || content.peek(Token![,]) {
- let mut elems = Punctuated::new();
- elems.push_value(first);
- while !content.is_empty() {
- let punct = content.parse()?;
- elems.push_punct(punct);
- if content.is_empty() {
- break;
- }
- let value = content.parse()?;
- elems.push_value(value);
- }
- Ok(Expr::Array(ExprArray {
- attrs: inner_attrs,
- bracket_token,
- elems,
- }))
- } else if content.peek(Token![;]) {
- let semi_token: Token![;] = content.parse()?;
- let len: Expr = content.parse()?;
- Ok(Expr::Repeat(ExprRepeat {
- attrs: inner_attrs,
- bracket_token,
- expr: Box::new(first),
- semi_token,
- len: Box::new(len),
- }))
- } else {
- Err(content.error("expected `,` or `;`"))
- }
- }
-
- #[cfg(feature = "full")]
- pub(crate) fn expr_early(input: ParseStream) -> Result<Expr> {
- let mut attrs = input.call(Attribute::parse_outer)?;
- let mut expr = if input.peek(Token![if]) {
- Expr::If(input.parse()?)
- } else if input.peek(Token![while]) {
- Expr::While(input.parse()?)
- } else if input.peek(Token![for]) {
- Expr::ForLoop(input.parse()?)
- } else if input.peek(Token![loop]) {
- Expr::Loop(input.parse()?)
- } else if input.peek(Token![match]) {
- Expr::Match(input.parse()?)
- } else if input.peek(Token![try]) && input.peek2(token::Brace) {
- Expr::TryBlock(input.call(expr_try_block)?)
- } else if input.peek(Token![unsafe]) {
- Expr::Unsafe(input.call(expr_unsafe)?)
- } else if input.peek(token::Brace) {
- Expr::Block(input.call(expr_block)?)
- } else {
- let allow_struct = AllowStruct(true);
- let mut expr = unary_expr(input, allow_struct)?;
-
- attrs.extend(expr.replace_attrs(Vec::new()));
- expr.replace_attrs(attrs);
-
- return parse_expr(input, expr, allow_struct, Precedence::Any);
- };
-
- if input.peek(Token![.]) || input.peek(Token![?]) {
- expr = trailer_helper(input, expr)?;
-
- attrs.extend(expr.replace_attrs(Vec::new()));
- expr.replace_attrs(attrs);
-
- let allow_struct = AllowStruct(true);
- return parse_expr(input, expr, allow_struct, Precedence::Any);
- }
-
- attrs.extend(expr.replace_attrs(Vec::new()));
- expr.replace_attrs(attrs);
- Ok(expr)
- }
-
- impl Parse for ExprLit {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ExprLit {
- attrs: Vec::new(),
- lit: input.parse()?,
- })
- }
- }
-
- #[cfg(feature = "full")]
- fn expr_group(input: ParseStream) -> Result<ExprGroup> {
- let group = crate::group::parse_group(input)?;
- Ok(ExprGroup {
- attrs: Vec::new(),
- group_token: group.token,
- expr: group.content.parse()?,
- })
- }
-
- #[cfg(not(feature = "full"))]
- fn expr_paren(input: ParseStream) -> Result<ExprParen> {
- let content;
- Ok(ExprParen {
- attrs: Vec::new(),
- paren_token: parenthesized!(content in input),
- expr: content.parse()?,
- })
- }
-
- #[cfg(feature = "full")]
- fn generic_method_argument(input: ParseStream) -> Result<GenericMethodArgument> {
- // TODO parse const generics as well
- input.parse().map(GenericMethodArgument::Type)
- }
-
- #[cfg(feature = "full")]
- fn expr_let(input: ParseStream) -> Result<ExprLet> {
- Ok(ExprLet {
- attrs: Vec::new(),
- let_token: input.parse()?,
- pat: {
- let leading_vert: Option<Token![|]> = input.parse()?;
- let pat: Pat = input.parse()?;
- if leading_vert.is_some()
- || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=])
- {
- let mut cases = Punctuated::new();
- cases.push_value(pat);
- while input.peek(Token![|])
- && !input.peek(Token![||])
- && !input.peek(Token![|=])
- {
- let punct = input.parse()?;
- cases.push_punct(punct);
- let pat: Pat = input.parse()?;
- cases.push_value(pat);
- }
- Pat::Or(PatOr {
- attrs: Vec::new(),
- leading_vert,
- cases,
- })
- } else {
- pat
- }
- },
- eq_token: input.parse()?,
- expr: Box::new(input.call(expr_no_struct)?),
- })
- }
-
- #[cfg(feature = "full")]
- impl Parse for ExprIf {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ExprIf {
- attrs: Vec::new(),
- if_token: input.parse()?,
- cond: Box::new(input.call(expr_no_struct)?),
- then_branch: input.parse()?,
- else_branch: {
- if input.peek(Token![else]) {
- Some(input.call(else_block)?)
- } else {
- None
- }
- },
- })
- }
- }
-
- #[cfg(feature = "full")]
- fn else_block(input: ParseStream) -> Result<(Token![else], Box<Expr>)> {
- let else_token: Token![else] = input.parse()?;
-
- let lookahead = input.lookahead1();
- let else_branch = if input.peek(Token![if]) {
- input.parse().map(Expr::If)?
- } else if input.peek(token::Brace) {
- Expr::Block(ExprBlock {
- attrs: Vec::new(),
- label: None,
- block: input.parse()?,
- })
- } else {
- return Err(lookahead.error());
- };
-
- Ok((else_token, Box::new(else_branch)))
- }
-
- #[cfg(feature = "full")]
- impl Parse for ExprForLoop {
- fn parse(input: ParseStream) -> Result<Self> {
- let label: Option<Label> = input.parse()?;
- let for_token: Token![for] = input.parse()?;
-
- let leading_vert: Option<Token![|]> = input.parse()?;
- let mut pat: Pat = input.parse()?;
- if leading_vert.is_some() || input.peek(Token![|]) {
- let mut cases = Punctuated::new();
- cases.push_value(pat);
- while input.peek(Token![|]) {
- let punct = input.parse()?;
- cases.push_punct(punct);
- let pat: Pat = input.parse()?;
- cases.push_value(pat);
- }
- pat = Pat::Or(PatOr {
- attrs: Vec::new(),
- leading_vert,
- cases,
- });
- }
-
- let in_token: Token![in] = input.parse()?;
- let expr: Expr = input.call(expr_no_struct)?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
-
- Ok(ExprForLoop {
- attrs: inner_attrs,
- label,
- for_token,
- pat,
- in_token,
- expr: Box::new(expr),
- body: Block { brace_token, stmts },
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for ExprLoop {
- fn parse(input: ParseStream) -> Result<Self> {
- let label: Option<Label> = input.parse()?;
- let loop_token: Token![loop] = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
-
- Ok(ExprLoop {
- attrs: inner_attrs,
- label,
- loop_token,
- body: Block { brace_token, stmts },
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for ExprMatch {
- fn parse(input: ParseStream) -> Result<Self> {
- let match_token: Token![match] = input.parse()?;
- let expr = expr_no_struct(input)?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
-
- let mut arms = Vec::new();
- while !content.is_empty() {
- arms.push(content.call(Arm::parse)?);
- }
-
- Ok(ExprMatch {
- attrs: inner_attrs,
- match_token,
- expr: Box::new(expr),
- brace_token,
- arms,
- })
- }
- }
-
- macro_rules! impl_by_parsing_expr {
- (
- $(
- $expr_type:ty, $variant:ident, $msg:expr,
- )*
- ) => {
- $(
- #[cfg(all(feature = "full", feature = "printing"))]
- impl Parse for $expr_type {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut expr: Expr = input.parse()?;
- loop {
- match expr {
- Expr::$variant(inner) => return Ok(inner),
- Expr::Group(next) => expr = *next.expr,
- _ => return Err(Error::new_spanned(expr, $msg)),
- }
- }
- }
- }
- )*
- };
- }
-
- impl_by_parsing_expr! {
- ExprBox, Box, "expected box expression",
- ExprArray, Array, "expected slice literal expression",
- ExprCall, Call, "expected function call expression",
- ExprMethodCall, MethodCall, "expected method call expression",
- ExprTuple, Tuple, "expected tuple expression",
- ExprBinary, Binary, "expected binary operation",
- ExprUnary, Unary, "expected unary operation",
- ExprCast, Cast, "expected cast expression",
- ExprType, Type, "expected type ascription expression",
- ExprLet, Let, "expected let guard",
- ExprClosure, Closure, "expected closure expression",
- ExprUnsafe, Unsafe, "expected unsafe block",
- ExprBlock, Block, "expected blocked scope",
- ExprAssign, Assign, "expected assignment expression",
- ExprAssignOp, AssignOp, "expected compound assignment expression",
- ExprField, Field, "expected struct field access",
- ExprIndex, Index, "expected indexing expression",
- ExprRange, Range, "expected range expression",
- ExprReference, Reference, "expected referencing operation",
- ExprBreak, Break, "expected break expression",
- ExprContinue, Continue, "expected continue expression",
- ExprReturn, Return, "expected return expression",
- ExprMacro, Macro, "expected macro invocation expression",
- ExprStruct, Struct, "expected struct literal expression",
- ExprRepeat, Repeat, "expected array literal constructed from one repeated element",
- ExprParen, Paren, "expected parenthesized expression",
- ExprTry, Try, "expected try expression",
- ExprAsync, Async, "expected async block",
- ExprTryBlock, TryBlock, "expected try block",
- ExprYield, Yield, "expected yield expression",
- }
-
- #[cfg(feature = "full")]
- fn expr_try_block(input: ParseStream) -> Result<ExprTryBlock> {
- Ok(ExprTryBlock {
- attrs: Vec::new(),
- try_token: input.parse()?,
- block: input.parse()?,
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_yield(input: ParseStream) -> Result<ExprYield> {
- Ok(ExprYield {
- attrs: Vec::new(),
- yield_token: input.parse()?,
- expr: {
- if !input.is_empty() && !input.peek(Token![,]) && !input.peek(Token![;]) {
- Some(input.parse()?)
- } else {
- None
- }
- },
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_closure(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprClosure> {
- let asyncness: Option<Token![async]> = input.parse()?;
- let movability: Option<Token![static]> = if asyncness.is_none() {
- input.parse()?
- } else {
- None
- };
- let capture: Option<Token![move]> = input.parse()?;
- let or1_token: Token![|] = input.parse()?;
-
- let mut inputs = Punctuated::new();
- loop {
- if input.peek(Token![|]) {
- break;
- }
- let value = closure_arg(input)?;
- inputs.push_value(value);
- if input.peek(Token![|]) {
- break;
- }
- let punct: Token![,] = input.parse()?;
- inputs.push_punct(punct);
- }
-
- let or2_token: Token![|] = input.parse()?;
-
- let (output, body) = if input.peek(Token![->]) {
- let arrow_token: Token![->] = input.parse()?;
- let ty: Type = input.parse()?;
- let body: Block = input.parse()?;
- let output = ReturnType::Type(arrow_token, Box::new(ty));
- let block = Expr::Block(ExprBlock {
- attrs: Vec::new(),
- label: None,
- block: body,
- });
- (output, block)
- } else {
- let body = ambiguous_expr(input, allow_struct)?;
- (ReturnType::Default, body)
- };
-
- Ok(ExprClosure {
- attrs: Vec::new(),
- asyncness,
- movability,
- capture,
- or1_token,
- inputs,
- or2_token,
- output,
- body: Box::new(body),
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_async(input: ParseStream) -> Result<ExprAsync> {
- Ok(ExprAsync {
- attrs: Vec::new(),
- async_token: input.parse()?,
- capture: input.parse()?,
- block: input.parse()?,
- })
- }
-
- #[cfg(feature = "full")]
- fn closure_arg(input: ParseStream) -> Result<Pat> {
- let attrs = input.call(Attribute::parse_outer)?;
- let mut pat: Pat = input.parse()?;
-
- if input.peek(Token![:]) {
- Ok(Pat::Type(PatType {
- attrs,
- pat: Box::new(pat),
- colon_token: input.parse()?,
- ty: input.parse()?,
- }))
- } else {
- match &mut pat {
- Pat::Box(pat) => pat.attrs = attrs,
- Pat::Ident(pat) => pat.attrs = attrs,
- Pat::Lit(pat) => pat.attrs = attrs,
- Pat::Macro(pat) => pat.attrs = attrs,
- Pat::Or(pat) => pat.attrs = attrs,
- Pat::Path(pat) => pat.attrs = attrs,
- Pat::Range(pat) => pat.attrs = attrs,
- Pat::Reference(pat) => pat.attrs = attrs,
- Pat::Rest(pat) => pat.attrs = attrs,
- Pat::Slice(pat) => pat.attrs = attrs,
- Pat::Struct(pat) => pat.attrs = attrs,
- Pat::Tuple(pat) => pat.attrs = attrs,
- Pat::TupleStruct(pat) => pat.attrs = attrs,
- Pat::Type(_) => unreachable!(),
- Pat::Verbatim(_) => {}
- Pat::Wild(pat) => pat.attrs = attrs,
- Pat::__Nonexhaustive => unreachable!(),
- }
- Ok(pat)
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for ExprWhile {
- fn parse(input: ParseStream) -> Result<Self> {
- let label: Option<Label> = input.parse()?;
- let while_token: Token![while] = input.parse()?;
- let cond = expr_no_struct(input)?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
-
- Ok(ExprWhile {
- attrs: inner_attrs,
- label,
- while_token,
- cond: Box::new(cond),
- body: Block { brace_token, stmts },
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for Label {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(Label {
- name: input.parse()?,
- colon_token: input.parse()?,
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for Option<Label> {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Lifetime) {
- input.parse().map(Some)
- } else {
- Ok(None)
- }
- }
- }
-
- #[cfg(feature = "full")]
- fn expr_continue(input: ParseStream) -> Result<ExprContinue> {
- Ok(ExprContinue {
- attrs: Vec::new(),
- continue_token: input.parse()?,
- label: input.parse()?,
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_break(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprBreak> {
- Ok(ExprBreak {
- attrs: Vec::new(),
- break_token: input.parse()?,
- label: input.parse()?,
- expr: {
- if input.is_empty()
- || input.peek(Token![,])
- || input.peek(Token![;])
- || !allow_struct.0 && input.peek(token::Brace)
- {
- None
- } else {
- let expr = ambiguous_expr(input, allow_struct)?;
- Some(Box::new(expr))
- }
- },
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_ret(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprReturn> {
- Ok(ExprReturn {
- attrs: Vec::new(),
- return_token: input.parse()?,
- expr: {
- if input.is_empty() || input.peek(Token![,]) || input.peek(Token![;]) {
- None
- } else {
- // NOTE: return is greedy and eats blocks after it even when in a
- // position where structs are not allowed, such as in if statement
- // conditions. For example:
- //
- // if return { println!("A") } {} // Prints "A"
- let expr = ambiguous_expr(input, allow_struct)?;
- Some(Box::new(expr))
- }
- },
- })
- }
-
- #[cfg(feature = "full")]
- impl Parse for FieldValue {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let member: Member = input.parse()?;
- let (colon_token, value) = if input.peek(Token![:]) || !member.is_named() {
- let colon_token: Token![:] = input.parse()?;
- let value: Expr = input.parse()?;
- (Some(colon_token), value)
- } else if let Member::Named(ident) = &member {
- let value = Expr::Path(ExprPath {
- attrs: Vec::new(),
- qself: None,
- path: Path::from(ident.clone()),
- });
- (None, value)
- } else {
- unreachable!()
- };
-
- Ok(FieldValue {
- attrs,
- member,
- colon_token,
- expr: value,
- })
- }
- }
-
- #[cfg(feature = "full")]
- fn expr_struct_helper(
- input: ParseStream,
- outer_attrs: Vec<Attribute>,
- path: Path,
- ) -> Result<ExprStruct> {
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let attrs = private::attrs(outer_attrs, inner_attrs);
-
- let mut fields = Punctuated::new();
- while !content.is_empty() {
- if content.peek(Token![..]) {
- return Ok(ExprStruct {
- attrs,
- brace_token,
- path,
- fields,
- dot2_token: Some(content.parse()?),
- rest: Some(Box::new(content.parse()?)),
- });
- }
-
- fields.push(content.parse()?);
- if !content.peek(Token![,]) {
- break;
- }
- let punct: Token![,] = content.parse()?;
- fields.push_punct(punct);
- }
-
- Ok(ExprStruct {
- attrs,
- brace_token,
- path,
- fields,
- dot2_token: None,
- rest: None,
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_unsafe(input: ParseStream) -> Result<ExprUnsafe> {
- let unsafe_token: Token![unsafe] = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
-
- Ok(ExprUnsafe {
- attrs: inner_attrs,
- unsafe_token,
- block: Block { brace_token, stmts },
- })
- }
-
- #[cfg(feature = "full")]
- pub fn expr_block(input: ParseStream) -> Result<ExprBlock> {
- let label: Option<Label> = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
-
- Ok(ExprBlock {
- attrs: inner_attrs,
- label,
- block: Block { brace_token, stmts },
- })
- }
-
- #[cfg(feature = "full")]
- fn expr_range(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprRange> {
- Ok(ExprRange {
- attrs: Vec::new(),
- from: None,
- limits: input.parse()?,
- to: {
- if input.is_empty()
- || input.peek(Token![,])
- || input.peek(Token![;])
- || !allow_struct.0 && input.peek(token::Brace)
- {
- None
- } else {
- let to = ambiguous_expr(input, allow_struct)?;
- Some(Box::new(to))
- }
- },
- })
- }
-
- #[cfg(feature = "full")]
- impl Parse for RangeLimits {
- fn parse(input: ParseStream) -> Result<Self> {
- let lookahead = input.lookahead1();
- if lookahead.peek(Token![..=]) {
- input.parse().map(RangeLimits::Closed)
- } else if lookahead.peek(Token![...]) {
- let dot3: Token![...] = input.parse()?;
- Ok(RangeLimits::Closed(Token![..=](dot3.spans)))
- } else if lookahead.peek(Token![..]) {
- input.parse().map(RangeLimits::HalfOpen)
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- impl Parse for ExprPath {
- fn parse(input: ParseStream) -> Result<Self> {
- #[cfg(not(feature = "full"))]
- let attrs = Vec::new();
- #[cfg(feature = "full")]
- let attrs = input.call(Attribute::parse_outer)?;
-
- let (qself, path) = path::parsing::qpath(input, true)?;
-
- Ok(ExprPath { attrs, qself, path })
- }
- }
-
- impl Parse for Member {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Ident) {
- input.parse().map(Member::Named)
- } else if input.peek(LitInt) {
- input.parse().map(Member::Unnamed)
- } else {
- Err(input.error("expected identifier or integer"))
- }
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for Arm {
- fn parse(input: ParseStream) -> Result<Arm> {
- let requires_comma;
- Ok(Arm {
- attrs: input.call(Attribute::parse_outer)?,
- pat: {
- let leading_vert: Option<Token![|]> = input.parse()?;
- let pat: Pat = input.parse()?;
- if leading_vert.is_some() || input.peek(Token![|]) {
- let mut cases = Punctuated::new();
- cases.push_value(pat);
- while input.peek(Token![|]) {
- let punct = input.parse()?;
- cases.push_punct(punct);
- let pat: Pat = input.parse()?;
- cases.push_value(pat);
- }
- Pat::Or(PatOr {
- attrs: Vec::new(),
- leading_vert,
- cases,
- })
- } else {
- pat
- }
- },
- guard: {
- if input.peek(Token![if]) {
- let if_token: Token![if] = input.parse()?;
- let guard: Expr = input.parse()?;
- Some((if_token, Box::new(guard)))
- } else {
- None
- }
- },
- fat_arrow_token: input.parse()?,
- body: {
- let body = input.call(expr_early)?;
- requires_comma = requires_terminator(&body);
- Box::new(body)
- },
- comma: {
- if requires_comma && !input.is_empty() {
- Some(input.parse()?)
- } else {
- input.parse()?
- }
- },
- })
- }
- }
-
- impl Parse for Index {
- fn parse(input: ParseStream) -> Result<Self> {
- let lit: LitInt = input.parse()?;
- if lit.suffix().is_empty() {
- Ok(Index {
- index: lit
- .base10_digits()
- .parse()
- .map_err(|err| Error::new(lit.span(), err))?,
- span: lit.span(),
- })
- } else {
- Err(Error::new(lit.span(), "expected unsuffixed integer"))
- }
- }
- }
-
- #[cfg(feature = "full")]
- impl Member {
- fn is_named(&self) -> bool {
- match *self {
- Member::Named(_) => true,
- Member::Unnamed(_) => false,
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-pub(crate) mod printing {
- use super::*;
-
- use proc_macro2::{Literal, TokenStream};
- use quote::{ToTokens, TokenStreamExt};
-
- #[cfg(feature = "full")]
- use crate::attr::FilterAttrs;
- #[cfg(feature = "full")]
- use crate::print::TokensOrDefault;
-
- // If the given expression is a bare `ExprStruct`, wraps it in parenthesis
- // before appending it to `TokenStream`.
- #[cfg(feature = "full")]
- fn wrap_bare_struct(tokens: &mut TokenStream, e: &Expr) {
- if let Expr::Struct(_) = *e {
- token::Paren::default().surround(tokens, |tokens| {
- e.to_tokens(tokens);
- });
- } else {
- e.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- pub(crate) fn outer_attrs_to_tokens(attrs: &[Attribute], tokens: &mut TokenStream) {
- tokens.append_all(attrs.outer());
- }
-
- #[cfg(feature = "full")]
- fn inner_attrs_to_tokens(attrs: &[Attribute], tokens: &mut TokenStream) {
- tokens.append_all(attrs.inner());
- }
-
- #[cfg(not(feature = "full"))]
- pub(crate) fn outer_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {}
-
- #[cfg(not(feature = "full"))]
- fn inner_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {}
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprBox {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.box_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprArray {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.bracket_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- self.elems.to_tokens(tokens);
- })
- }
- }
-
- impl ToTokens for ExprCall {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.func.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- self.args.to_tokens(tokens);
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprMethodCall {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.receiver.to_tokens(tokens);
- self.dot_token.to_tokens(tokens);
- self.method.to_tokens(tokens);
- self.turbofish.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- self.args.to_tokens(tokens);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for MethodTurbofish {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.colon2_token.to_tokens(tokens);
- self.lt_token.to_tokens(tokens);
- self.args.to_tokens(tokens);
- self.gt_token.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for GenericMethodArgument {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- GenericMethodArgument::Type(t) => t.to_tokens(tokens),
- GenericMethodArgument::Const(c) => c.to_tokens(tokens),
- }
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprTuple {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.paren_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- self.elems.to_tokens(tokens);
- // If we only have one argument, we need a trailing comma to
- // distinguish ExprTuple from ExprParen.
- if self.elems.len() == 1 && !self.elems.trailing_punct() {
- <Token![,]>::default().to_tokens(tokens);
- }
- })
- }
- }
-
- impl ToTokens for ExprBinary {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.left.to_tokens(tokens);
- self.op.to_tokens(tokens);
- self.right.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ExprUnary {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.op.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ExprLit {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.lit.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ExprCast {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.expr.to_tokens(tokens);
- self.as_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.expr.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- fn maybe_wrap_else(tokens: &mut TokenStream, else_: &Option<(Token![else], Box<Expr>)>) {
- if let Some((else_token, else_)) = else_ {
- else_token.to_tokens(tokens);
-
- // If we are not one of the valid expressions to exist in an else
- // clause, wrap ourselves in a block.
- match **else_ {
- Expr::If(_) | Expr::Block(_) => {
- else_.to_tokens(tokens);
- }
- _ => {
- token::Brace::default().surround(tokens, |tokens| {
- else_.to_tokens(tokens);
- });
- }
- }
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprLet {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.let_token.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- wrap_bare_struct(tokens, &self.expr);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprIf {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.if_token.to_tokens(tokens);
- wrap_bare_struct(tokens, &self.cond);
- self.then_branch.to_tokens(tokens);
- maybe_wrap_else(tokens, &self.else_branch);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprWhile {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.label.to_tokens(tokens);
- self.while_token.to_tokens(tokens);
- wrap_bare_struct(tokens, &self.cond);
- self.body.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- tokens.append_all(&self.body.stmts);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprForLoop {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.label.to_tokens(tokens);
- self.for_token.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- self.in_token.to_tokens(tokens);
- wrap_bare_struct(tokens, &self.expr);
- self.body.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- tokens.append_all(&self.body.stmts);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprLoop {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.label.to_tokens(tokens);
- self.loop_token.to_tokens(tokens);
- self.body.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- tokens.append_all(&self.body.stmts);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprMatch {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.match_token.to_tokens(tokens);
- wrap_bare_struct(tokens, &self.expr);
- self.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- for (i, arm) in self.arms.iter().enumerate() {
- arm.to_tokens(tokens);
- // Ensure that we have a comma after a non-block arm, except
- // for the last one.
- let is_last = i == self.arms.len() - 1;
- if !is_last && requires_terminator(&arm.body) && arm.comma.is_none() {
- <Token![,]>::default().to_tokens(tokens);
- }
- }
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprAsync {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.async_token.to_tokens(tokens);
- self.capture.to_tokens(tokens);
- self.block.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprAwait {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.base.to_tokens(tokens);
- self.dot_token.to_tokens(tokens);
- self.await_token.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprTryBlock {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.try_token.to_tokens(tokens);
- self.block.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprYield {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.yield_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprClosure {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.asyncness.to_tokens(tokens);
- self.movability.to_tokens(tokens);
- self.capture.to_tokens(tokens);
- self.or1_token.to_tokens(tokens);
- self.inputs.to_tokens(tokens);
- self.or2_token.to_tokens(tokens);
- self.output.to_tokens(tokens);
- self.body.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprUnsafe {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.unsafe_token.to_tokens(tokens);
- self.block.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- tokens.append_all(&self.block.stmts);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprBlock {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.label.to_tokens(tokens);
- self.block.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- tokens.append_all(&self.block.stmts);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprAssign {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.left.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.right.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprAssignOp {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.left.to_tokens(tokens);
- self.op.to_tokens(tokens);
- self.right.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ExprField {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.base.to_tokens(tokens);
- self.dot_token.to_tokens(tokens);
- self.member.to_tokens(tokens);
- }
- }
-
- impl ToTokens for Member {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- Member::Named(ident) => ident.to_tokens(tokens),
- Member::Unnamed(index) => index.to_tokens(tokens),
- }
- }
- }
-
- impl ToTokens for Index {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- let mut lit = Literal::i64_unsuffixed(i64::from(self.index));
- lit.set_span(self.span);
- tokens.append(lit);
- }
- }
-
- impl ToTokens for ExprIndex {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.expr.to_tokens(tokens);
- self.bracket_token.surround(tokens, |tokens| {
- self.index.to_tokens(tokens);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprRange {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.from.to_tokens(tokens);
- match &self.limits {
- RangeLimits::HalfOpen(t) => t.to_tokens(tokens),
- RangeLimits::Closed(t) => t.to_tokens(tokens),
- }
- self.to.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ExprPath {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- private::print_path(tokens, &self.qself, &self.path);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprReference {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.and_token.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprBreak {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.break_token.to_tokens(tokens);
- self.label.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprContinue {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.continue_token.to_tokens(tokens);
- self.label.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprReturn {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.return_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.mac.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprStruct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.path.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- self.fields.to_tokens(tokens);
- if self.rest.is_some() {
- TokensOrDefault(&self.dot2_token).to_tokens(tokens);
- self.rest.to_tokens(tokens);
- }
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprRepeat {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.bracket_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- self.expr.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- self.len.to_tokens(tokens);
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprGroup {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.group_token.surround(tokens, |tokens| {
- self.expr.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for ExprParen {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.paren_token.surround(tokens, |tokens| {
- inner_attrs_to_tokens(&self.attrs, tokens);
- self.expr.to_tokens(tokens);
- });
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for ExprTry {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.expr.to_tokens(tokens);
- self.question_token.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for Label {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.name.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for FieldValue {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- outer_attrs_to_tokens(&self.attrs, tokens);
- self.member.to_tokens(tokens);
- if let Some(colon_token) = &self.colon_token {
- colon_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- }
- }
- }
-
- #[cfg(feature = "full")]
- impl ToTokens for Arm {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(&self.attrs);
- self.pat.to_tokens(tokens);
- if let Some((if_token, guard)) = &self.guard {
- if_token.to_tokens(tokens);
- guard.to_tokens(tokens);
- }
- self.fat_arrow_token.to_tokens(tokens);
- self.body.to_tokens(tokens);
- self.comma.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/ext.rs b/syn/src/ext.rs
deleted file mode 100644
index d09577a..0000000
--- a/syn/src/ext.rs
+++ /dev/null
@@ -1,135 +0,0 @@
-//! Extension traits to provide parsing methods on foreign types.
-//!
-//! *This module is available if Syn is built with the `"parsing"` feature.*
-
-use proc_macro2::Ident;
-
-use crate::parse::{ParseStream, Result};
-
-use crate::buffer::Cursor;
-use crate::parse::Peek;
-use crate::sealed::lookahead;
-use crate::token::CustomToken;
-
-/// Additional methods for `Ident` not provided by proc-macro2 or libproc_macro.
-///
-/// This trait is sealed and cannot be implemented for types outside of Syn. It
-/// is implemented only for `proc_macro2::Ident`.
-///
-/// *This trait is available if Syn is built with the `"parsing"` feature.*
-pub trait IdentExt: Sized + private::Sealed {
- /// Parses any identifier including keywords.
- ///
- /// This is useful when parsing macro input which allows Rust keywords as
- /// identifiers.
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{Error, Ident, Result, Token};
- /// use syn::ext::IdentExt;
- /// use syn::parse::ParseStream;
- ///
- /// mod kw {
- /// syn::custom_keyword!(name);
- /// }
- ///
- /// // Parses input that looks like `name = NAME` where `NAME` can be
- /// // any identifier.
- /// //
- /// // Examples:
- /// //
- /// // name = anything
- /// // name = impl
- /// fn parse_dsl(input: ParseStream) -> Result<Ident> {
- /// input.parse::<kw::name>()?;
- /// input.parse::<Token![=]>()?;
- /// let name = input.call(Ident::parse_any)?;
- /// Ok(name)
- /// }
- /// ```
- fn parse_any(input: ParseStream) -> Result<Self>;
-
- /// Peeks any identifier including keywords. Usage:
- /// `input.peek(Ident::peek_any)`
- ///
- /// This is different from `input.peek(Ident)` which only returns true in
- /// the case of an ident which is not a Rust keyword.
- #[allow(non_upper_case_globals)]
- const peek_any: private::PeekFn = private::PeekFn;
-
- /// Strips the raw marker `r#`, if any, from the beginning of an ident.
- ///
- /// - unraw(`x`) = `x`
- /// - unraw(`move`) = `move`
- /// - unraw(`r#move`) = `move`
- ///
- /// # Example
- ///
- /// In the case of interop with other languages like Python that have a
- /// different set of keywords than Rust, we might come across macro input
- /// that involves raw identifiers to refer to ordinary variables in the
- /// other language with a name that happens to be a Rust keyword.
- ///
- /// The function below appends an identifier from the caller's input onto a
- /// fixed prefix. Without using `unraw()`, this would tend to produce
- /// invalid identifiers like `__pyo3_get_r#move`.
- ///
- /// ```
- /// use proc_macro2::Span;
- /// use syn::Ident;
- /// use syn::ext::IdentExt;
- ///
- /// fn ident_for_getter(variable: &Ident) -> Ident {
- /// let getter = format!("__pyo3_get_{}", variable.unraw());
- /// Ident::new(&getter, Span::call_site())
- /// }
- /// ```
- fn unraw(&self) -> Ident;
-}
-
-impl IdentExt for Ident {
- fn parse_any(input: ParseStream) -> Result<Self> {
- input.step(|cursor| match cursor.ident() {
- Some((ident, rest)) => Ok((ident, rest)),
- None => Err(cursor.error("expected ident")),
- })
- }
-
- fn unraw(&self) -> Ident {
- let string = self.to_string();
- if string.starts_with("r#") {
- Ident::new(&string[2..], self.span())
- } else {
- self.clone()
- }
- }
-}
-
-impl Peek for private::PeekFn {
- type Token = private::IdentAny;
-}
-
-impl CustomToken for private::IdentAny {
- fn peek(cursor: Cursor) -> bool {
- cursor.ident().is_some()
- }
-
- fn display() -> &'static str {
- "identifier"
- }
-}
-
-impl lookahead::Sealed for private::PeekFn {}
-
-mod private {
- use proc_macro2::Ident;
-
- pub trait Sealed {}
-
- impl Sealed for Ident {}
-
- #[derive(Copy, Clone)]
- pub struct PeekFn;
- pub struct IdentAny;
-}
diff --git a/syn/src/file.rs b/syn/src/file.rs
deleted file mode 100644
index 88c02fe..0000000
--- a/syn/src/file.rs
+++ /dev/null
@@ -1,113 +0,0 @@
-use super::*;
-
-ast_struct! {
- /// A complete file of Rust source code.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Example
- ///
- /// Parse a Rust source file into a `syn::File` and print out a debug
- /// representation of the syntax tree.
- ///
- /// ```
- /// use std::env;
- /// use std::fs::File;
- /// use std::io::Read;
- /// use std::process;
- ///
- /// fn main() {
- /// # }
- /// #
- /// # fn fake_main() {
- /// let mut args = env::args();
- /// let _ = args.next(); // executable name
- ///
- /// let filename = match (args.next(), args.next()) {
- /// (Some(filename), None) => filename,
- /// _ => {
- /// eprintln!("Usage: dump-syntax path/to/filename.rs");
- /// process::exit(1);
- /// }
- /// };
- ///
- /// let mut file = File::open(&filename).expect("Unable to open file");
- ///
- /// let mut src = String::new();
- /// file.read_to_string(&mut src).expect("Unable to read file");
- ///
- /// let syntax = syn::parse_file(&src).expect("Unable to parse file");
- /// println!("{:#?}", syntax);
- /// }
- /// ```
- ///
- /// Running with its own source code as input, this program prints output
- /// that begins with:
- ///
- /// ```text
- /// File {
- /// shebang: None,
- /// attrs: [],
- /// items: [
- /// ExternCrate(
- /// ItemExternCrate {
- /// attrs: [],
- /// vis: Inherited,
- /// extern_token: Extern,
- /// crate_token: Crate,
- /// ident: Ident {
- /// term: Term(
- /// "syn"
- /// ),
- /// span: Span
- /// },
- /// rename: None,
- /// semi_token: Semi
- /// }
- /// ),
- /// ...
- /// ```
- pub struct File {
- pub shebang: Option<String>,
- pub attrs: Vec<Attribute>,
- pub items: Vec<Item>,
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for File {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(File {
- shebang: None,
- attrs: input.call(Attribute::parse_inner)?,
- items: {
- let mut items = Vec::new();
- while !input.is_empty() {
- items.push(input.parse()?);
- }
- items
- },
- })
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
- use crate::attr::FilterAttrs;
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- impl ToTokens for File {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(&self.items);
- }
- }
-}
diff --git a/syn/src/gen/fold.rs b/syn/src/gen/fold.rs
deleted file mode 100644
index f51218b..0000000
--- a/syn/src/gen/fold.rs
+++ /dev/null
@@ -1,3236 +0,0 @@
-// This file is @generated by syn-internal-codegen.
-// It is not intended for manual editing.
-
-#![allow(unreachable_code, unused_variables)]
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::gen::helper::fold::*;
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::token::{Brace, Bracket, Group, Paren};
-use crate::*;
-use proc_macro2::Span;
-#[cfg(feature = "full")]
-macro_rules! full {
- ($e:expr) => {
- $e
- };
-}
-#[cfg(all(feature = "derive", not(feature = "full")))]
-macro_rules! full {
- ($e:expr) => {
- unreachable!()
- };
-}
-/// Syntax tree traversal to transform the nodes of an owned syntax tree.
-///
-/// See the [module documentation] for details.
-///
-/// [module documentation]: self
-///
-/// *This trait is available if Syn is built with the `"fold"` feature.*
-pub trait Fold {
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_abi(&mut self, i: Abi) -> Abi {
- fold_abi(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_angle_bracketed_generic_arguments(
- &mut self,
- i: AngleBracketedGenericArguments,
- ) -> AngleBracketedGenericArguments {
- fold_angle_bracketed_generic_arguments(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_arm(&mut self, i: Arm) -> Arm {
- fold_arm(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_attr_style(&mut self, i: AttrStyle) -> AttrStyle {
- fold_attr_style(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_attribute(&mut self, i: Attribute) -> Attribute {
- fold_attribute(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_bare_fn_arg(&mut self, i: BareFnArg) -> BareFnArg {
- fold_bare_fn_arg(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_bin_op(&mut self, i: BinOp) -> BinOp {
- fold_bin_op(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_binding(&mut self, i: Binding) -> Binding {
- fold_binding(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_block(&mut self, i: Block) -> Block {
- fold_block(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_bound_lifetimes(&mut self, i: BoundLifetimes) -> BoundLifetimes {
- fold_bound_lifetimes(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_const_param(&mut self, i: ConstParam) -> ConstParam {
- fold_const_param(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_constraint(&mut self, i: Constraint) -> Constraint {
- fold_constraint(self, i)
- }
- #[cfg(feature = "derive")]
- fn fold_data(&mut self, i: Data) -> Data {
- fold_data(self, i)
- }
- #[cfg(feature = "derive")]
- fn fold_data_enum(&mut self, i: DataEnum) -> DataEnum {
- fold_data_enum(self, i)
- }
- #[cfg(feature = "derive")]
- fn fold_data_struct(&mut self, i: DataStruct) -> DataStruct {
- fold_data_struct(self, i)
- }
- #[cfg(feature = "derive")]
- fn fold_data_union(&mut self, i: DataUnion) -> DataUnion {
- fold_data_union(self, i)
- }
- #[cfg(feature = "derive")]
- fn fold_derive_input(&mut self, i: DeriveInput) -> DeriveInput {
- fold_derive_input(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr(&mut self, i: Expr) -> Expr {
- fold_expr(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_array(&mut self, i: ExprArray) -> ExprArray {
- fold_expr_array(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_assign(&mut self, i: ExprAssign) -> ExprAssign {
- fold_expr_assign(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_assign_op(&mut self, i: ExprAssignOp) -> ExprAssignOp {
- fold_expr_assign_op(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_async(&mut self, i: ExprAsync) -> ExprAsync {
- fold_expr_async(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_await(&mut self, i: ExprAwait) -> ExprAwait {
- fold_expr_await(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_binary(&mut self, i: ExprBinary) -> ExprBinary {
- fold_expr_binary(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_block(&mut self, i: ExprBlock) -> ExprBlock {
- fold_expr_block(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_box(&mut self, i: ExprBox) -> ExprBox {
- fold_expr_box(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_break(&mut self, i: ExprBreak) -> ExprBreak {
- fold_expr_break(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_call(&mut self, i: ExprCall) -> ExprCall {
- fold_expr_call(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_cast(&mut self, i: ExprCast) -> ExprCast {
- fold_expr_cast(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_closure(&mut self, i: ExprClosure) -> ExprClosure {
- fold_expr_closure(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_continue(&mut self, i: ExprContinue) -> ExprContinue {
- fold_expr_continue(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_field(&mut self, i: ExprField) -> ExprField {
- fold_expr_field(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_for_loop(&mut self, i: ExprForLoop) -> ExprForLoop {
- fold_expr_for_loop(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_group(&mut self, i: ExprGroup) -> ExprGroup {
- fold_expr_group(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_if(&mut self, i: ExprIf) -> ExprIf {
- fold_expr_if(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_index(&mut self, i: ExprIndex) -> ExprIndex {
- fold_expr_index(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_let(&mut self, i: ExprLet) -> ExprLet {
- fold_expr_let(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_lit(&mut self, i: ExprLit) -> ExprLit {
- fold_expr_lit(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_loop(&mut self, i: ExprLoop) -> ExprLoop {
- fold_expr_loop(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_macro(&mut self, i: ExprMacro) -> ExprMacro {
- fold_expr_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_match(&mut self, i: ExprMatch) -> ExprMatch {
- fold_expr_match(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_method_call(&mut self, i: ExprMethodCall) -> ExprMethodCall {
- fold_expr_method_call(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_paren(&mut self, i: ExprParen) -> ExprParen {
- fold_expr_paren(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_path(&mut self, i: ExprPath) -> ExprPath {
- fold_expr_path(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_range(&mut self, i: ExprRange) -> ExprRange {
- fold_expr_range(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_reference(&mut self, i: ExprReference) -> ExprReference {
- fold_expr_reference(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_repeat(&mut self, i: ExprRepeat) -> ExprRepeat {
- fold_expr_repeat(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_return(&mut self, i: ExprReturn) -> ExprReturn {
- fold_expr_return(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_struct(&mut self, i: ExprStruct) -> ExprStruct {
- fold_expr_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_try(&mut self, i: ExprTry) -> ExprTry {
- fold_expr_try(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_try_block(&mut self, i: ExprTryBlock) -> ExprTryBlock {
- fold_expr_try_block(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple {
- fold_expr_tuple(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_type(&mut self, i: ExprType) -> ExprType {
- fold_expr_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_expr_unary(&mut self, i: ExprUnary) -> ExprUnary {
- fold_expr_unary(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_unsafe(&mut self, i: ExprUnsafe) -> ExprUnsafe {
- fold_expr_unsafe(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_while(&mut self, i: ExprWhile) -> ExprWhile {
- fold_expr_while(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_expr_yield(&mut self, i: ExprYield) -> ExprYield {
- fold_expr_yield(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_field(&mut self, i: Field) -> Field {
- fold_field(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_field_pat(&mut self, i: FieldPat) -> FieldPat {
- fold_field_pat(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_field_value(&mut self, i: FieldValue) -> FieldValue {
- fold_field_value(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_fields(&mut self, i: Fields) -> Fields {
- fold_fields(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_fields_named(&mut self, i: FieldsNamed) -> FieldsNamed {
- fold_fields_named(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_fields_unnamed(&mut self, i: FieldsUnnamed) -> FieldsUnnamed {
- fold_fields_unnamed(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_file(&mut self, i: File) -> File {
- fold_file(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_fn_arg(&mut self, i: FnArg) -> FnArg {
- fold_fn_arg(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_foreign_item(&mut self, i: ForeignItem) -> ForeignItem {
- fold_foreign_item(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_foreign_item_fn(&mut self, i: ForeignItemFn) -> ForeignItemFn {
- fold_foreign_item_fn(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_foreign_item_macro(&mut self, i: ForeignItemMacro) -> ForeignItemMacro {
- fold_foreign_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_foreign_item_static(&mut self, i: ForeignItemStatic) -> ForeignItemStatic {
- fold_foreign_item_static(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_foreign_item_type(&mut self, i: ForeignItemType) -> ForeignItemType {
- fold_foreign_item_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_generic_argument(&mut self, i: GenericArgument) -> GenericArgument {
- fold_generic_argument(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_generic_method_argument(&mut self, i: GenericMethodArgument) -> GenericMethodArgument {
- fold_generic_method_argument(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_generic_param(&mut self, i: GenericParam) -> GenericParam {
- fold_generic_param(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_generics(&mut self, i: Generics) -> Generics {
- fold_generics(self, i)
- }
- fn fold_ident(&mut self, i: Ident) -> Ident {
- fold_ident(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_impl_item(&mut self, i: ImplItem) -> ImplItem {
- fold_impl_item(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_impl_item_const(&mut self, i: ImplItemConst) -> ImplItemConst {
- fold_impl_item_const(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro {
- fold_impl_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_impl_item_method(&mut self, i: ImplItemMethod) -> ImplItemMethod {
- fold_impl_item_method(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_impl_item_type(&mut self, i: ImplItemType) -> ImplItemType {
- fold_impl_item_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_index(&mut self, i: Index) -> Index {
- fold_index(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item(&mut self, i: Item) -> Item {
- fold_item(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_const(&mut self, i: ItemConst) -> ItemConst {
- fold_item_const(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_enum(&mut self, i: ItemEnum) -> ItemEnum {
- fold_item_enum(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_extern_crate(&mut self, i: ItemExternCrate) -> ItemExternCrate {
- fold_item_extern_crate(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_fn(&mut self, i: ItemFn) -> ItemFn {
- fold_item_fn(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_foreign_mod(&mut self, i: ItemForeignMod) -> ItemForeignMod {
- fold_item_foreign_mod(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_impl(&mut self, i: ItemImpl) -> ItemImpl {
- fold_item_impl(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_macro(&mut self, i: ItemMacro) -> ItemMacro {
- fold_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_macro2(&mut self, i: ItemMacro2) -> ItemMacro2 {
- fold_item_macro2(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_mod(&mut self, i: ItemMod) -> ItemMod {
- fold_item_mod(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_static(&mut self, i: ItemStatic) -> ItemStatic {
- fold_item_static(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_struct(&mut self, i: ItemStruct) -> ItemStruct {
- fold_item_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_trait(&mut self, i: ItemTrait) -> ItemTrait {
- fold_item_trait(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_trait_alias(&mut self, i: ItemTraitAlias) -> ItemTraitAlias {
- fold_item_trait_alias(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_type(&mut self, i: ItemType) -> ItemType {
- fold_item_type(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_union(&mut self, i: ItemUnion) -> ItemUnion {
- fold_item_union(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_item_use(&mut self, i: ItemUse) -> ItemUse {
- fold_item_use(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_label(&mut self, i: Label) -> Label {
- fold_label(self, i)
- }
- fn fold_lifetime(&mut self, i: Lifetime) -> Lifetime {
- fold_lifetime(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef {
- fold_lifetime_def(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit(&mut self, i: Lit) -> Lit {
- fold_lit(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_bool(&mut self, i: LitBool) -> LitBool {
- fold_lit_bool(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_byte(&mut self, i: LitByte) -> LitByte {
- fold_lit_byte(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_byte_str(&mut self, i: LitByteStr) -> LitByteStr {
- fold_lit_byte_str(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_char(&mut self, i: LitChar) -> LitChar {
- fold_lit_char(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat {
- fold_lit_float(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_int(&mut self, i: LitInt) -> LitInt {
- fold_lit_int(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_lit_str(&mut self, i: LitStr) -> LitStr {
- fold_lit_str(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_local(&mut self, i: Local) -> Local {
- fold_local(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_macro(&mut self, i: Macro) -> Macro {
- fold_macro(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_macro_delimiter(&mut self, i: MacroDelimiter) -> MacroDelimiter {
- fold_macro_delimiter(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_member(&mut self, i: Member) -> Member {
- fold_member(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_meta(&mut self, i: Meta) -> Meta {
- fold_meta(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_meta_list(&mut self, i: MetaList) -> MetaList {
- fold_meta_list(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_meta_name_value(&mut self, i: MetaNameValue) -> MetaNameValue {
- fold_meta_name_value(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_method_turbofish(&mut self, i: MethodTurbofish) -> MethodTurbofish {
- fold_method_turbofish(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_nested_meta(&mut self, i: NestedMeta) -> NestedMeta {
- fold_nested_meta(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_parenthesized_generic_arguments(
- &mut self,
- i: ParenthesizedGenericArguments,
- ) -> ParenthesizedGenericArguments {
- fold_parenthesized_generic_arguments(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat(&mut self, i: Pat) -> Pat {
- fold_pat(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_box(&mut self, i: PatBox) -> PatBox {
- fold_pat_box(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_ident(&mut self, i: PatIdent) -> PatIdent {
- fold_pat_ident(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_lit(&mut self, i: PatLit) -> PatLit {
- fold_pat_lit(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_macro(&mut self, i: PatMacro) -> PatMacro {
- fold_pat_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_or(&mut self, i: PatOr) -> PatOr {
- fold_pat_or(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_path(&mut self, i: PatPath) -> PatPath {
- fold_pat_path(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_range(&mut self, i: PatRange) -> PatRange {
- fold_pat_range(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_reference(&mut self, i: PatReference) -> PatReference {
- fold_pat_reference(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_rest(&mut self, i: PatRest) -> PatRest {
- fold_pat_rest(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_slice(&mut self, i: PatSlice) -> PatSlice {
- fold_pat_slice(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_struct(&mut self, i: PatStruct) -> PatStruct {
- fold_pat_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_tuple(&mut self, i: PatTuple) -> PatTuple {
- fold_pat_tuple(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_tuple_struct(&mut self, i: PatTupleStruct) -> PatTupleStruct {
- fold_pat_tuple_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_type(&mut self, i: PatType) -> PatType {
- fold_pat_type(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_pat_wild(&mut self, i: PatWild) -> PatWild {
- fold_pat_wild(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_path(&mut self, i: Path) -> Path {
- fold_path(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_path_arguments(&mut self, i: PathArguments) -> PathArguments {
- fold_path_arguments(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_path_segment(&mut self, i: PathSegment) -> PathSegment {
- fold_path_segment(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_predicate_eq(&mut self, i: PredicateEq) -> PredicateEq {
- fold_predicate_eq(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_predicate_lifetime(&mut self, i: PredicateLifetime) -> PredicateLifetime {
- fold_predicate_lifetime(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_predicate_type(&mut self, i: PredicateType) -> PredicateType {
- fold_predicate_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_qself(&mut self, i: QSelf) -> QSelf {
- fold_qself(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_range_limits(&mut self, i: RangeLimits) -> RangeLimits {
- fold_range_limits(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_receiver(&mut self, i: Receiver) -> Receiver {
- fold_receiver(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_return_type(&mut self, i: ReturnType) -> ReturnType {
- fold_return_type(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_signature(&mut self, i: Signature) -> Signature {
- fold_signature(self, i)
- }
- fn fold_span(&mut self, i: Span) -> Span {
- fold_span(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_stmt(&mut self, i: Stmt) -> Stmt {
- fold_stmt(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_trait_bound(&mut self, i: TraitBound) -> TraitBound {
- fold_trait_bound(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_trait_bound_modifier(&mut self, i: TraitBoundModifier) -> TraitBoundModifier {
- fold_trait_bound_modifier(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_trait_item(&mut self, i: TraitItem) -> TraitItem {
- fold_trait_item(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_trait_item_const(&mut self, i: TraitItemConst) -> TraitItemConst {
- fold_trait_item_const(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro {
- fold_trait_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_trait_item_method(&mut self, i: TraitItemMethod) -> TraitItemMethod {
- fold_trait_item_method(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_trait_item_type(&mut self, i: TraitItemType) -> TraitItemType {
- fold_trait_item_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type(&mut self, i: Type) -> Type {
- fold_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_array(&mut self, i: TypeArray) -> TypeArray {
- fold_type_array(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_bare_fn(&mut self, i: TypeBareFn) -> TypeBareFn {
- fold_type_bare_fn(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_group(&mut self, i: TypeGroup) -> TypeGroup {
- fold_type_group(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_impl_trait(&mut self, i: TypeImplTrait) -> TypeImplTrait {
- fold_type_impl_trait(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_infer(&mut self, i: TypeInfer) -> TypeInfer {
- fold_type_infer(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_macro(&mut self, i: TypeMacro) -> TypeMacro {
- fold_type_macro(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_never(&mut self, i: TypeNever) -> TypeNever {
- fold_type_never(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_param(&mut self, i: TypeParam) -> TypeParam {
- fold_type_param(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_param_bound(&mut self, i: TypeParamBound) -> TypeParamBound {
- fold_type_param_bound(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_paren(&mut self, i: TypeParen) -> TypeParen {
- fold_type_paren(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_path(&mut self, i: TypePath) -> TypePath {
- fold_type_path(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_ptr(&mut self, i: TypePtr) -> TypePtr {
- fold_type_ptr(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_reference(&mut self, i: TypeReference) -> TypeReference {
- fold_type_reference(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_slice(&mut self, i: TypeSlice) -> TypeSlice {
- fold_type_slice(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_trait_object(&mut self, i: TypeTraitObject) -> TypeTraitObject {
- fold_type_trait_object(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_type_tuple(&mut self, i: TypeTuple) -> TypeTuple {
- fold_type_tuple(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_un_op(&mut self, i: UnOp) -> UnOp {
- fold_un_op(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_use_glob(&mut self, i: UseGlob) -> UseGlob {
- fold_use_glob(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_use_group(&mut self, i: UseGroup) -> UseGroup {
- fold_use_group(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_use_name(&mut self, i: UseName) -> UseName {
- fold_use_name(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_use_path(&mut self, i: UsePath) -> UsePath {
- fold_use_path(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_use_rename(&mut self, i: UseRename) -> UseRename {
- fold_use_rename(self, i)
- }
- #[cfg(feature = "full")]
- fn fold_use_tree(&mut self, i: UseTree) -> UseTree {
- fold_use_tree(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_variadic(&mut self, i: Variadic) -> Variadic {
- fold_variadic(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_variant(&mut self, i: Variant) -> Variant {
- fold_variant(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_vis_crate(&mut self, i: VisCrate) -> VisCrate {
- fold_vis_crate(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_vis_public(&mut self, i: VisPublic) -> VisPublic {
- fold_vis_public(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_vis_restricted(&mut self, i: VisRestricted) -> VisRestricted {
- fold_vis_restricted(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_visibility(&mut self, i: Visibility) -> Visibility {
- fold_visibility(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_where_clause(&mut self, i: WhereClause) -> WhereClause {
- fold_where_clause(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn fold_where_predicate(&mut self, i: WherePredicate) -> WherePredicate {
- fold_where_predicate(self, i)
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_abi<F>(f: &mut F, node: Abi) -> Abi
-where
- F: Fold + ?Sized,
-{
- Abi {
- extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)),
- name: (node.name).map(|it| f.fold_lit_str(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_angle_bracketed_generic_arguments<F>(
- f: &mut F,
- node: AngleBracketedGenericArguments,
-) -> AngleBracketedGenericArguments
-where
- F: Fold + ?Sized,
-{
- AngleBracketedGenericArguments {
- colon2_token: (node.colon2_token).map(|it| Token ! [ :: ](tokens_helper(f, &it.spans))),
- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
- args: FoldHelper::lift(node.args, |it| f.fold_generic_argument(it)),
- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_arm<F>(f: &mut F, node: Arm) -> Arm
-where
- F: Fold + ?Sized,
-{
- Arm {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- pat: f.fold_pat(node.pat),
- guard: (node.guard).map(|it| {
- (
- Token![if](tokens_helper(f, &(it).0.span)),
- Box::new(f.fold_expr(*(it).1)),
- )
- }),
- fat_arrow_token: Token ! [ => ](tokens_helper(f, &node.fat_arrow_token.spans)),
- body: Box::new(f.fold_expr(*node.body)),
- comma: (node.comma).map(|it| Token ! [ , ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_attr_style<F>(f: &mut F, node: AttrStyle) -> AttrStyle
-where
- F: Fold + ?Sized,
-{
- match node {
- AttrStyle::Outer => AttrStyle::Outer,
- AttrStyle::Inner(_binding_0) => {
- AttrStyle::Inner(Token![!](tokens_helper(f, &_binding_0.spans)))
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_attribute<F>(f: &mut F, node: Attribute) -> Attribute
-where
- F: Fold + ?Sized,
-{
- Attribute {
- pound_token: Token ! [ # ](tokens_helper(f, &node.pound_token.spans)),
- style: f.fold_attr_style(node.style),
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- path: f.fold_path(node.path),
- tokens: node.tokens,
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_bare_fn_arg<F>(f: &mut F, node: BareFnArg) -> BareFnArg
-where
- F: Fold + ?Sized,
-{
- BareFnArg {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- name: (node.name).map(|it| {
- (
- f.fold_ident((it).0),
- Token ! [ : ](tokens_helper(f, &(it).1.spans)),
- )
- }),
- ty: f.fold_type(node.ty),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_bin_op<F>(f: &mut F, node: BinOp) -> BinOp
-where
- F: Fold + ?Sized,
-{
- match node {
- BinOp::Add(_binding_0) => BinOp::Add(Token ! [ + ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Sub(_binding_0) => BinOp::Sub(Token ! [ - ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Mul(_binding_0) => BinOp::Mul(Token ! [ * ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Div(_binding_0) => BinOp::Div(Token ! [ / ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Rem(_binding_0) => BinOp::Rem(Token ! [ % ](tokens_helper(f, &_binding_0.spans))),
- BinOp::And(_binding_0) => BinOp::And(Token ! [ && ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Or(_binding_0) => BinOp::Or(Token ! [ || ](tokens_helper(f, &_binding_0.spans))),
- BinOp::BitXor(_binding_0) => {
- BinOp::BitXor(Token ! [ ^ ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::BitAnd(_binding_0) => {
- BinOp::BitAnd(Token ! [ & ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::BitOr(_binding_0) => {
- BinOp::BitOr(Token ! [ | ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::Shl(_binding_0) => BinOp::Shl(Token ! [ << ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Shr(_binding_0) => BinOp::Shr(Token ! [ >> ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Eq(_binding_0) => BinOp::Eq(Token ! [ == ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [ < ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Le(_binding_0) => BinOp::Le(Token ! [ <= ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Ne(_binding_0) => BinOp::Ne(Token ! [ != ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Ge(_binding_0) => BinOp::Ge(Token ! [ >= ](tokens_helper(f, &_binding_0.spans))),
- BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [ > ](tokens_helper(f, &_binding_0.spans))),
- BinOp::AddEq(_binding_0) => {
- BinOp::AddEq(Token ! [ += ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::SubEq(_binding_0) => {
- BinOp::SubEq(Token ! [ -= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::MulEq(_binding_0) => {
- BinOp::MulEq(Token ! [ *= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::DivEq(_binding_0) => {
- BinOp::DivEq(Token ! [ /= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::RemEq(_binding_0) => {
- BinOp::RemEq(Token ! [ %= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::BitXorEq(_binding_0) => {
- BinOp::BitXorEq(Token ! [ ^= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::BitAndEq(_binding_0) => {
- BinOp::BitAndEq(Token ! [ &= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::BitOrEq(_binding_0) => {
- BinOp::BitOrEq(Token ! [ |= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::ShlEq(_binding_0) => {
- BinOp::ShlEq(Token ! [ <<= ](tokens_helper(f, &_binding_0.spans)))
- }
- BinOp::ShrEq(_binding_0) => {
- BinOp::ShrEq(Token ! [ >>= ](tokens_helper(f, &_binding_0.spans)))
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_binding<F>(f: &mut F, node: Binding) -> Binding
-where
- F: Fold + ?Sized,
-{
- Binding {
- ident: f.fold_ident(node.ident),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- ty: f.fold_type(node.ty),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_block<F>(f: &mut F, node: Block) -> Block
-where
- F: Fold + ?Sized,
-{
- Block {
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- stmts: FoldHelper::lift(node.stmts, |it| f.fold_stmt(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_bound_lifetimes<F>(f: &mut F, node: BoundLifetimes) -> BoundLifetimes
-where
- F: Fold + ?Sized,
-{
- BoundLifetimes {
- for_token: Token![for](tokens_helper(f, &node.for_token.span)),
- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
- lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_lifetime_def(it)),
- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_const_param<F>(f: &mut F, node: ConstParam) -> ConstParam
-where
- F: Fold + ?Sized,
-{
- ConstParam {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- const_token: Token![const](tokens_helper(f, &node.const_token.span)),
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: f.fold_type(node.ty),
- eq_token: (node.eq_token).map(|it| Token ! [ = ](tokens_helper(f, &it.spans))),
- default: (node.default).map(|it| f.fold_expr(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_constraint<F>(f: &mut F, node: Constraint) -> Constraint
-where
- F: Fold + ?Sized,
-{
- Constraint {
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- }
-}
-#[cfg(feature = "derive")]
-pub fn fold_data<F>(f: &mut F, node: Data) -> Data
-where
- F: Fold + ?Sized,
-{
- match node {
- Data::Struct(_binding_0) => Data::Struct(f.fold_data_struct(_binding_0)),
- Data::Enum(_binding_0) => Data::Enum(f.fold_data_enum(_binding_0)),
- Data::Union(_binding_0) => Data::Union(f.fold_data_union(_binding_0)),
- }
-}
-#[cfg(feature = "derive")]
-pub fn fold_data_enum<F>(f: &mut F, node: DataEnum) -> DataEnum
-where
- F: Fold + ?Sized,
-{
- DataEnum {
- enum_token: Token![enum](tokens_helper(f, &node.enum_token.span)),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- variants: FoldHelper::lift(node.variants, |it| f.fold_variant(it)),
- }
-}
-#[cfg(feature = "derive")]
-pub fn fold_data_struct<F>(f: &mut F, node: DataStruct) -> DataStruct
-where
- F: Fold + ?Sized,
-{
- DataStruct {
- struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)),
- fields: f.fold_fields(node.fields),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "derive")]
-pub fn fold_data_union<F>(f: &mut F, node: DataUnion) -> DataUnion
-where
- F: Fold + ?Sized,
-{
- DataUnion {
- union_token: Token![union](tokens_helper(f, &node.union_token.span)),
- fields: f.fold_fields_named(node.fields),
- }
-}
-#[cfg(feature = "derive")]
-pub fn fold_derive_input<F>(f: &mut F, node: DeriveInput) -> DeriveInput
-where
- F: Fold + ?Sized,
-{
- DeriveInput {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- data: f.fold_data(node.data),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr<F>(f: &mut F, node: Expr) -> Expr
-where
- F: Fold + ?Sized,
-{
- match node {
- Expr::Array(_binding_0) => Expr::Array(full!(f.fold_expr_array(_binding_0))),
- Expr::Assign(_binding_0) => Expr::Assign(full!(f.fold_expr_assign(_binding_0))),
- Expr::AssignOp(_binding_0) => Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))),
- Expr::Async(_binding_0) => Expr::Async(full!(f.fold_expr_async(_binding_0))),
- Expr::Await(_binding_0) => Expr::Await(full!(f.fold_expr_await(_binding_0))),
- Expr::Binary(_binding_0) => Expr::Binary(f.fold_expr_binary(_binding_0)),
- Expr::Block(_binding_0) => Expr::Block(full!(f.fold_expr_block(_binding_0))),
- Expr::Box(_binding_0) => Expr::Box(full!(f.fold_expr_box(_binding_0))),
- Expr::Break(_binding_0) => Expr::Break(full!(f.fold_expr_break(_binding_0))),
- Expr::Call(_binding_0) => Expr::Call(f.fold_expr_call(_binding_0)),
- Expr::Cast(_binding_0) => Expr::Cast(f.fold_expr_cast(_binding_0)),
- Expr::Closure(_binding_0) => Expr::Closure(full!(f.fold_expr_closure(_binding_0))),
- Expr::Continue(_binding_0) => Expr::Continue(full!(f.fold_expr_continue(_binding_0))),
- Expr::Field(_binding_0) => Expr::Field(f.fold_expr_field(_binding_0)),
- Expr::ForLoop(_binding_0) => Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))),
- Expr::Group(_binding_0) => Expr::Group(full!(f.fold_expr_group(_binding_0))),
- Expr::If(_binding_0) => Expr::If(full!(f.fold_expr_if(_binding_0))),
- Expr::Index(_binding_0) => Expr::Index(f.fold_expr_index(_binding_0)),
- Expr::Let(_binding_0) => Expr::Let(full!(f.fold_expr_let(_binding_0))),
- Expr::Lit(_binding_0) => Expr::Lit(f.fold_expr_lit(_binding_0)),
- Expr::Loop(_binding_0) => Expr::Loop(full!(f.fold_expr_loop(_binding_0))),
- Expr::Macro(_binding_0) => Expr::Macro(full!(f.fold_expr_macro(_binding_0))),
- Expr::Match(_binding_0) => Expr::Match(full!(f.fold_expr_match(_binding_0))),
- Expr::MethodCall(_binding_0) => {
- Expr::MethodCall(full!(f.fold_expr_method_call(_binding_0)))
- }
- Expr::Paren(_binding_0) => Expr::Paren(f.fold_expr_paren(_binding_0)),
- Expr::Path(_binding_0) => Expr::Path(f.fold_expr_path(_binding_0)),
- Expr::Range(_binding_0) => Expr::Range(full!(f.fold_expr_range(_binding_0))),
- Expr::Reference(_binding_0) => Expr::Reference(full!(f.fold_expr_reference(_binding_0))),
- Expr::Repeat(_binding_0) => Expr::Repeat(full!(f.fold_expr_repeat(_binding_0))),
- Expr::Return(_binding_0) => Expr::Return(full!(f.fold_expr_return(_binding_0))),
- Expr::Struct(_binding_0) => Expr::Struct(full!(f.fold_expr_struct(_binding_0))),
- Expr::Try(_binding_0) => Expr::Try(full!(f.fold_expr_try(_binding_0))),
- Expr::TryBlock(_binding_0) => Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))),
- Expr::Tuple(_binding_0) => Expr::Tuple(full!(f.fold_expr_tuple(_binding_0))),
- Expr::Type(_binding_0) => Expr::Type(full!(f.fold_expr_type(_binding_0))),
- Expr::Unary(_binding_0) => Expr::Unary(f.fold_expr_unary(_binding_0)),
- Expr::Unsafe(_binding_0) => Expr::Unsafe(full!(f.fold_expr_unsafe(_binding_0))),
- Expr::Verbatim(_binding_0) => Expr::Verbatim(_binding_0),
- Expr::While(_binding_0) => Expr::While(full!(f.fold_expr_while(_binding_0))),
- Expr::Yield(_binding_0) => Expr::Yield(full!(f.fold_expr_yield(_binding_0))),
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_array<F>(f: &mut F, node: ExprArray) -> ExprArray
-where
- F: Fold + ?Sized,
-{
- ExprArray {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- elems: FoldHelper::lift(node.elems, |it| f.fold_expr(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_assign<F>(f: &mut F, node: ExprAssign) -> ExprAssign
-where
- F: Fold + ?Sized,
-{
- ExprAssign {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- left: Box::new(f.fold_expr(*node.left)),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- right: Box::new(f.fold_expr(*node.right)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_assign_op<F>(f: &mut F, node: ExprAssignOp) -> ExprAssignOp
-where
- F: Fold + ?Sized,
-{
- ExprAssignOp {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- left: Box::new(f.fold_expr(*node.left)),
- op: f.fold_bin_op(node.op),
- right: Box::new(f.fold_expr(*node.right)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_async<F>(f: &mut F, node: ExprAsync) -> ExprAsync
-where
- F: Fold + ?Sized,
-{
- ExprAsync {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- async_token: Token![async](tokens_helper(f, &node.async_token.span)),
- capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))),
- block: f.fold_block(node.block),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_await<F>(f: &mut F, node: ExprAwait) -> ExprAwait
-where
- F: Fold + ?Sized,
-{
- ExprAwait {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- base: Box::new(f.fold_expr(*node.base)),
- dot_token: Token ! [ . ](tokens_helper(f, &node.dot_token.spans)),
- await_token: crate::token::Await(tokens_helper(f, &node.await_token.span)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_binary<F>(f: &mut F, node: ExprBinary) -> ExprBinary
-where
- F: Fold + ?Sized,
-{
- ExprBinary {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- left: Box::new(f.fold_expr(*node.left)),
- op: f.fold_bin_op(node.op),
- right: Box::new(f.fold_expr(*node.right)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_block<F>(f: &mut F, node: ExprBlock) -> ExprBlock
-where
- F: Fold + ?Sized,
-{
- ExprBlock {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- label: (node.label).map(|it| f.fold_label(it)),
- block: f.fold_block(node.block),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_box<F>(f: &mut F, node: ExprBox) -> ExprBox
-where
- F: Fold + ?Sized,
-{
- ExprBox {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- box_token: Token![box](tokens_helper(f, &node.box_token.span)),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_break<F>(f: &mut F, node: ExprBreak) -> ExprBreak
-where
- F: Fold + ?Sized,
-{
- ExprBreak {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- break_token: Token![break](tokens_helper(f, &node.break_token.span)),
- label: (node.label).map(|it| f.fold_lifetime(it)),
- expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_call<F>(f: &mut F, node: ExprCall) -> ExprCall
-where
- F: Fold + ?Sized,
-{
- ExprCall {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- func: Box::new(f.fold_expr(*node.func)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- args: FoldHelper::lift(node.args, |it| f.fold_expr(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_cast<F>(f: &mut F, node: ExprCast) -> ExprCast
-where
- F: Fold + ?Sized,
-{
- ExprCast {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- expr: Box::new(f.fold_expr(*node.expr)),
- as_token: Token![as](tokens_helper(f, &node.as_token.span)),
- ty: Box::new(f.fold_type(*node.ty)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_closure<F>(f: &mut F, node: ExprClosure) -> ExprClosure
-where
- F: Fold + ?Sized,
-{
- ExprClosure {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))),
- movability: (node.movability).map(|it| Token![static](tokens_helper(f, &it.span))),
- capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))),
- or1_token: Token ! [ | ](tokens_helper(f, &node.or1_token.spans)),
- inputs: FoldHelper::lift(node.inputs, |it| f.fold_pat(it)),
- or2_token: Token ! [ | ](tokens_helper(f, &node.or2_token.spans)),
- output: f.fold_return_type(node.output),
- body: Box::new(f.fold_expr(*node.body)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_continue<F>(f: &mut F, node: ExprContinue) -> ExprContinue
-where
- F: Fold + ?Sized,
-{
- ExprContinue {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- continue_token: Token![continue](tokens_helper(f, &node.continue_token.span)),
- label: (node.label).map(|it| f.fold_lifetime(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_field<F>(f: &mut F, node: ExprField) -> ExprField
-where
- F: Fold + ?Sized,
-{
- ExprField {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- base: Box::new(f.fold_expr(*node.base)),
- dot_token: Token ! [ . ](tokens_helper(f, &node.dot_token.spans)),
- member: f.fold_member(node.member),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_for_loop<F>(f: &mut F, node: ExprForLoop) -> ExprForLoop
-where
- F: Fold + ?Sized,
-{
- ExprForLoop {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- label: (node.label).map(|it| f.fold_label(it)),
- for_token: Token![for](tokens_helper(f, &node.for_token.span)),
- pat: f.fold_pat(node.pat),
- in_token: Token![in](tokens_helper(f, &node.in_token.span)),
- expr: Box::new(f.fold_expr(*node.expr)),
- body: f.fold_block(node.body),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_group<F>(f: &mut F, node: ExprGroup) -> ExprGroup
-where
- F: Fold + ?Sized,
-{
- ExprGroup {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- group_token: Group(tokens_helper(f, &node.group_token.span)),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_if<F>(f: &mut F, node: ExprIf) -> ExprIf
-where
- F: Fold + ?Sized,
-{
- ExprIf {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- if_token: Token![if](tokens_helper(f, &node.if_token.span)),
- cond: Box::new(f.fold_expr(*node.cond)),
- then_branch: f.fold_block(node.then_branch),
- else_branch: (node.else_branch).map(|it| {
- (
- Token![else](tokens_helper(f, &(it).0.span)),
- Box::new(f.fold_expr(*(it).1)),
- )
- }),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_index<F>(f: &mut F, node: ExprIndex) -> ExprIndex
-where
- F: Fold + ?Sized,
-{
- ExprIndex {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- expr: Box::new(f.fold_expr(*node.expr)),
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- index: Box::new(f.fold_expr(*node.index)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_let<F>(f: &mut F, node: ExprLet) -> ExprLet
-where
- F: Fold + ?Sized,
-{
- ExprLet {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- let_token: Token![let](tokens_helper(f, &node.let_token.span)),
- pat: f.fold_pat(node.pat),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_lit<F>(f: &mut F, node: ExprLit) -> ExprLit
-where
- F: Fold + ?Sized,
-{
- ExprLit {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- lit: f.fold_lit(node.lit),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_loop<F>(f: &mut F, node: ExprLoop) -> ExprLoop
-where
- F: Fold + ?Sized,
-{
- ExprLoop {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- label: (node.label).map(|it| f.fold_label(it)),
- loop_token: Token![loop](tokens_helper(f, &node.loop_token.span)),
- body: f.fold_block(node.body),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_macro<F>(f: &mut F, node: ExprMacro) -> ExprMacro
-where
- F: Fold + ?Sized,
-{
- ExprMacro {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- mac: f.fold_macro(node.mac),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_match<F>(f: &mut F, node: ExprMatch) -> ExprMatch
-where
- F: Fold + ?Sized,
-{
- ExprMatch {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- match_token: Token![match](tokens_helper(f, &node.match_token.span)),
- expr: Box::new(f.fold_expr(*node.expr)),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- arms: FoldHelper::lift(node.arms, |it| f.fold_arm(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_method_call<F>(f: &mut F, node: ExprMethodCall) -> ExprMethodCall
-where
- F: Fold + ?Sized,
-{
- ExprMethodCall {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- receiver: Box::new(f.fold_expr(*node.receiver)),
- dot_token: Token ! [ . ](tokens_helper(f, &node.dot_token.spans)),
- method: f.fold_ident(node.method),
- turbofish: (node.turbofish).map(|it| f.fold_method_turbofish(it)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- args: FoldHelper::lift(node.args, |it| f.fold_expr(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_paren<F>(f: &mut F, node: ExprParen) -> ExprParen
-where
- F: Fold + ?Sized,
-{
- ExprParen {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_path<F>(f: &mut F, node: ExprPath) -> ExprPath
-where
- F: Fold + ?Sized,
-{
- ExprPath {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- qself: (node.qself).map(|it| f.fold_qself(it)),
- path: f.fold_path(node.path),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_range<F>(f: &mut F, node: ExprRange) -> ExprRange
-where
- F: Fold + ?Sized,
-{
- ExprRange {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- from: (node.from).map(|it| Box::new(f.fold_expr(*it))),
- limits: f.fold_range_limits(node.limits),
- to: (node.to).map(|it| Box::new(f.fold_expr(*it))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_reference<F>(f: &mut F, node: ExprReference) -> ExprReference
-where
- F: Fold + ?Sized,
-{
- ExprReference {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- and_token: Token ! [ & ](tokens_helper(f, &node.and_token.spans)),
- raw: node.raw,
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_repeat<F>(f: &mut F, node: ExprRepeat) -> ExprRepeat
-where
- F: Fold + ?Sized,
-{
- ExprRepeat {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- expr: Box::new(f.fold_expr(*node.expr)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- len: Box::new(f.fold_expr(*node.len)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_return<F>(f: &mut F, node: ExprReturn) -> ExprReturn
-where
- F: Fold + ?Sized,
-{
- ExprReturn {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- return_token: Token![return](tokens_helper(f, &node.return_token.span)),
- expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_struct<F>(f: &mut F, node: ExprStruct) -> ExprStruct
-where
- F: Fold + ?Sized,
-{
- ExprStruct {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- path: f.fold_path(node.path),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- fields: FoldHelper::lift(node.fields, |it| f.fold_field_value(it)),
- dot2_token: (node.dot2_token).map(|it| Token![..](tokens_helper(f, &it.spans))),
- rest: (node.rest).map(|it| Box::new(f.fold_expr(*it))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_try<F>(f: &mut F, node: ExprTry) -> ExprTry
-where
- F: Fold + ?Sized,
-{
- ExprTry {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- expr: Box::new(f.fold_expr(*node.expr)),
- question_token: Token ! [ ? ](tokens_helper(f, &node.question_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_try_block<F>(f: &mut F, node: ExprTryBlock) -> ExprTryBlock
-where
- F: Fold + ?Sized,
-{
- ExprTryBlock {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- try_token: Token![try](tokens_helper(f, &node.try_token.span)),
- block: f.fold_block(node.block),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_tuple<F>(f: &mut F, node: ExprTuple) -> ExprTuple
-where
- F: Fold + ?Sized,
-{
- ExprTuple {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- elems: FoldHelper::lift(node.elems, |it| f.fold_expr(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_type<F>(f: &mut F, node: ExprType) -> ExprType
-where
- F: Fold + ?Sized,
-{
- ExprType {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- expr: Box::new(f.fold_expr(*node.expr)),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_expr_unary<F>(f: &mut F, node: ExprUnary) -> ExprUnary
-where
- F: Fold + ?Sized,
-{
- ExprUnary {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- op: f.fold_un_op(node.op),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_unsafe<F>(f: &mut F, node: ExprUnsafe) -> ExprUnsafe
-where
- F: Fold + ?Sized,
-{
- ExprUnsafe {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- unsafe_token: Token![unsafe](tokens_helper(f, &node.unsafe_token.span)),
- block: f.fold_block(node.block),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_while<F>(f: &mut F, node: ExprWhile) -> ExprWhile
-where
- F: Fold + ?Sized,
-{
- ExprWhile {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- label: (node.label).map(|it| f.fold_label(it)),
- while_token: Token![while](tokens_helper(f, &node.while_token.span)),
- cond: Box::new(f.fold_expr(*node.cond)),
- body: f.fold_block(node.body),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_expr_yield<F>(f: &mut F, node: ExprYield) -> ExprYield
-where
- F: Fold + ?Sized,
-{
- ExprYield {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- yield_token: Token![yield](tokens_helper(f, &node.yield_token.span)),
- expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_field<F>(f: &mut F, node: Field) -> Field
-where
- F: Fold + ?Sized,
-{
- Field {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- ident: (node.ident).map(|it| f.fold_ident(it)),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- ty: f.fold_type(node.ty),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_field_pat<F>(f: &mut F, node: FieldPat) -> FieldPat
-where
- F: Fold + ?Sized,
-{
- FieldPat {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- member: f.fold_member(node.member),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- pat: Box::new(f.fold_pat(*node.pat)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_field_value<F>(f: &mut F, node: FieldValue) -> FieldValue
-where
- F: Fold + ?Sized,
-{
- FieldValue {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- member: f.fold_member(node.member),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- expr: f.fold_expr(node.expr),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_fields<F>(f: &mut F, node: Fields) -> Fields
-where
- F: Fold + ?Sized,
-{
- match node {
- Fields::Named(_binding_0) => Fields::Named(f.fold_fields_named(_binding_0)),
- Fields::Unnamed(_binding_0) => Fields::Unnamed(f.fold_fields_unnamed(_binding_0)),
- Fields::Unit => Fields::Unit,
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_fields_named<F>(f: &mut F, node: FieldsNamed) -> FieldsNamed
-where
- F: Fold + ?Sized,
-{
- FieldsNamed {
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- named: FoldHelper::lift(node.named, |it| f.fold_field(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_fields_unnamed<F>(f: &mut F, node: FieldsUnnamed) -> FieldsUnnamed
-where
- F: Fold + ?Sized,
-{
- FieldsUnnamed {
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- unnamed: FoldHelper::lift(node.unnamed, |it| f.fold_field(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_file<F>(f: &mut F, node: File) -> File
-where
- F: Fold + ?Sized,
-{
- File {
- shebang: node.shebang,
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- items: FoldHelper::lift(node.items, |it| f.fold_item(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_fn_arg<F>(f: &mut F, node: FnArg) -> FnArg
-where
- F: Fold + ?Sized,
-{
- match node {
- FnArg::Receiver(_binding_0) => FnArg::Receiver(f.fold_receiver(_binding_0)),
- FnArg::Typed(_binding_0) => FnArg::Typed(f.fold_pat_type(_binding_0)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_foreign_item<F>(f: &mut F, node: ForeignItem) -> ForeignItem
-where
- F: Fold + ?Sized,
-{
- match node {
- ForeignItem::Fn(_binding_0) => ForeignItem::Fn(f.fold_foreign_item_fn(_binding_0)),
- ForeignItem::Static(_binding_0) => {
- ForeignItem::Static(f.fold_foreign_item_static(_binding_0))
- }
- ForeignItem::Type(_binding_0) => ForeignItem::Type(f.fold_foreign_item_type(_binding_0)),
- ForeignItem::Macro(_binding_0) => ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)),
- ForeignItem::Verbatim(_binding_0) => ForeignItem::Verbatim(_binding_0),
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_foreign_item_fn<F>(f: &mut F, node: ForeignItemFn) -> ForeignItemFn
-where
- F: Fold + ?Sized,
-{
- ForeignItemFn {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- sig: f.fold_signature(node.sig),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_foreign_item_macro<F>(f: &mut F, node: ForeignItemMacro) -> ForeignItemMacro
-where
- F: Fold + ?Sized,
-{
- ForeignItemMacro {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- mac: f.fold_macro(node.mac),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_foreign_item_static<F>(f: &mut F, node: ForeignItemStatic) -> ForeignItemStatic
-where
- F: Fold + ?Sized,
-{
- ForeignItemStatic {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- static_token: Token![static](tokens_helper(f, &node.static_token.span)),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_foreign_item_type<F>(f: &mut F, node: ForeignItemType) -> ForeignItemType
-where
- F: Fold + ?Sized,
-{
- ForeignItemType {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- type_token: Token![type](tokens_helper(f, &node.type_token.span)),
- ident: f.fold_ident(node.ident),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_generic_argument<F>(f: &mut F, node: GenericArgument) -> GenericArgument
-where
- F: Fold + ?Sized,
-{
- match node {
- GenericArgument::Lifetime(_binding_0) => {
- GenericArgument::Lifetime(f.fold_lifetime(_binding_0))
- }
- GenericArgument::Type(_binding_0) => GenericArgument::Type(f.fold_type(_binding_0)),
- GenericArgument::Binding(_binding_0) => {
- GenericArgument::Binding(f.fold_binding(_binding_0))
- }
- GenericArgument::Constraint(_binding_0) => {
- GenericArgument::Constraint(f.fold_constraint(_binding_0))
- }
- GenericArgument::Const(_binding_0) => GenericArgument::Const(f.fold_expr(_binding_0)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_generic_method_argument<F>(
- f: &mut F,
- node: GenericMethodArgument,
-) -> GenericMethodArgument
-where
- F: Fold + ?Sized,
-{
- match node {
- GenericMethodArgument::Type(_binding_0) => {
- GenericMethodArgument::Type(f.fold_type(_binding_0))
- }
- GenericMethodArgument::Const(_binding_0) => {
- GenericMethodArgument::Const(f.fold_expr(_binding_0))
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_generic_param<F>(f: &mut F, node: GenericParam) -> GenericParam
-where
- F: Fold + ?Sized,
-{
- match node {
- GenericParam::Type(_binding_0) => GenericParam::Type(f.fold_type_param(_binding_0)),
- GenericParam::Lifetime(_binding_0) => {
- GenericParam::Lifetime(f.fold_lifetime_def(_binding_0))
- }
- GenericParam::Const(_binding_0) => GenericParam::Const(f.fold_const_param(_binding_0)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_generics<F>(f: &mut F, node: Generics) -> Generics
-where
- F: Fold + ?Sized,
-{
- Generics {
- lt_token: (node.lt_token).map(|it| Token ! [ < ](tokens_helper(f, &it.spans))),
- params: FoldHelper::lift(node.params, |it| f.fold_generic_param(it)),
- gt_token: (node.gt_token).map(|it| Token ! [ > ](tokens_helper(f, &it.spans))),
- where_clause: (node.where_clause).map(|it| f.fold_where_clause(it)),
- }
-}
-pub fn fold_ident<F>(f: &mut F, node: Ident) -> Ident
-where
- F: Fold + ?Sized,
-{
- let mut node = node;
- let span = f.fold_span(node.span());
- node.set_span(span);
- node
-}
-#[cfg(feature = "full")]
-pub fn fold_impl_item<F>(f: &mut F, node: ImplItem) -> ImplItem
-where
- F: Fold + ?Sized,
-{
- match node {
- ImplItem::Const(_binding_0) => ImplItem::Const(f.fold_impl_item_const(_binding_0)),
- ImplItem::Method(_binding_0) => ImplItem::Method(f.fold_impl_item_method(_binding_0)),
- ImplItem::Type(_binding_0) => ImplItem::Type(f.fold_impl_item_type(_binding_0)),
- ImplItem::Macro(_binding_0) => ImplItem::Macro(f.fold_impl_item_macro(_binding_0)),
- ImplItem::Verbatim(_binding_0) => ImplItem::Verbatim(_binding_0),
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_impl_item_const<F>(f: &mut F, node: ImplItemConst) -> ImplItemConst
-where
- F: Fold + ?Sized,
-{
- ImplItemConst {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))),
- const_token: Token![const](tokens_helper(f, &node.const_token.span)),
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: f.fold_type(node.ty),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- expr: f.fold_expr(node.expr),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_impl_item_macro<F>(f: &mut F, node: ImplItemMacro) -> ImplItemMacro
-where
- F: Fold + ?Sized,
-{
- ImplItemMacro {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- mac: f.fold_macro(node.mac),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_impl_item_method<F>(f: &mut F, node: ImplItemMethod) -> ImplItemMethod
-where
- F: Fold + ?Sized,
-{
- ImplItemMethod {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))),
- sig: f.fold_signature(node.sig),
- block: f.fold_block(node.block),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_impl_item_type<F>(f: &mut F, node: ImplItemType) -> ImplItemType
-where
- F: Fold + ?Sized,
-{
- ImplItemType {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))),
- type_token: Token![type](tokens_helper(f, &node.type_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- ty: f.fold_type(node.ty),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_index<F>(f: &mut F, node: Index) -> Index
-where
- F: Fold + ?Sized,
-{
- Index {
- index: node.index,
- span: f.fold_span(node.span),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item<F>(f: &mut F, node: Item) -> Item
-where
- F: Fold + ?Sized,
-{
- match node {
- Item::Const(_binding_0) => Item::Const(f.fold_item_const(_binding_0)),
- Item::Enum(_binding_0) => Item::Enum(f.fold_item_enum(_binding_0)),
- Item::ExternCrate(_binding_0) => Item::ExternCrate(f.fold_item_extern_crate(_binding_0)),
- Item::Fn(_binding_0) => Item::Fn(f.fold_item_fn(_binding_0)),
- Item::ForeignMod(_binding_0) => Item::ForeignMod(f.fold_item_foreign_mod(_binding_0)),
- Item::Impl(_binding_0) => Item::Impl(f.fold_item_impl(_binding_0)),
- Item::Macro(_binding_0) => Item::Macro(f.fold_item_macro(_binding_0)),
- Item::Macro2(_binding_0) => Item::Macro2(f.fold_item_macro2(_binding_0)),
- Item::Mod(_binding_0) => Item::Mod(f.fold_item_mod(_binding_0)),
- Item::Static(_binding_0) => Item::Static(f.fold_item_static(_binding_0)),
- Item::Struct(_binding_0) => Item::Struct(f.fold_item_struct(_binding_0)),
- Item::Trait(_binding_0) => Item::Trait(f.fold_item_trait(_binding_0)),
- Item::TraitAlias(_binding_0) => Item::TraitAlias(f.fold_item_trait_alias(_binding_0)),
- Item::Type(_binding_0) => Item::Type(f.fold_item_type(_binding_0)),
- Item::Union(_binding_0) => Item::Union(f.fold_item_union(_binding_0)),
- Item::Use(_binding_0) => Item::Use(f.fold_item_use(_binding_0)),
- Item::Verbatim(_binding_0) => Item::Verbatim(_binding_0),
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_const<F>(f: &mut F, node: ItemConst) -> ItemConst
-where
- F: Fold + ?Sized,
-{
- ItemConst {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- const_token: Token![const](tokens_helper(f, &node.const_token.span)),
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- expr: Box::new(f.fold_expr(*node.expr)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_enum<F>(f: &mut F, node: ItemEnum) -> ItemEnum
-where
- F: Fold + ?Sized,
-{
- ItemEnum {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- enum_token: Token![enum](tokens_helper(f, &node.enum_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- variants: FoldHelper::lift(node.variants, |it| f.fold_variant(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_extern_crate<F>(f: &mut F, node: ItemExternCrate) -> ItemExternCrate
-where
- F: Fold + ?Sized,
-{
- ItemExternCrate {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)),
- crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)),
- ident: f.fold_ident(node.ident),
- rename: (node.rename).map(|it| {
- (
- Token![as](tokens_helper(f, &(it).0.span)),
- f.fold_ident((it).1),
- )
- }),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_fn<F>(f: &mut F, node: ItemFn) -> ItemFn
-where
- F: Fold + ?Sized,
-{
- ItemFn {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- sig: f.fold_signature(node.sig),
- block: Box::new(f.fold_block(*node.block)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_foreign_mod<F>(f: &mut F, node: ItemForeignMod) -> ItemForeignMod
-where
- F: Fold + ?Sized,
-{
- ItemForeignMod {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- abi: f.fold_abi(node.abi),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- items: FoldHelper::lift(node.items, |it| f.fold_foreign_item(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_impl<F>(f: &mut F, node: ItemImpl) -> ItemImpl
-where
- F: Fold + ?Sized,
-{
- ItemImpl {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))),
- unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))),
- impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)),
- generics: f.fold_generics(node.generics),
- trait_: (node.trait_).map(|it| {
- (
- ((it).0).map(|it| Token![!](tokens_helper(f, &it.spans))),
- f.fold_path((it).1),
- Token![for](tokens_helper(f, &(it).2.span)),
- )
- }),
- self_ty: Box::new(f.fold_type(*node.self_ty)),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- items: FoldHelper::lift(node.items, |it| f.fold_impl_item(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_macro<F>(f: &mut F, node: ItemMacro) -> ItemMacro
-where
- F: Fold + ?Sized,
-{
- ItemMacro {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- ident: (node.ident).map(|it| f.fold_ident(it)),
- mac: f.fold_macro(node.mac),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_macro2<F>(f: &mut F, node: ItemMacro2) -> ItemMacro2
-where
- F: Fold + ?Sized,
-{
- ItemMacro2 {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- macro_token: Token![macro](tokens_helper(f, &node.macro_token.span)),
- ident: f.fold_ident(node.ident),
- rules: node.rules,
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_mod<F>(f: &mut F, node: ItemMod) -> ItemMod
-where
- F: Fold + ?Sized,
-{
- ItemMod {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- mod_token: Token![mod](tokens_helper(f, &node.mod_token.span)),
- ident: f.fold_ident(node.ident),
- content: (node.content).map(|it| {
- (
- Brace(tokens_helper(f, &(it).0.span)),
- FoldHelper::lift((it).1, |it| f.fold_item(it)),
- )
- }),
- semi: (node.semi).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_static<F>(f: &mut F, node: ItemStatic) -> ItemStatic
-where
- F: Fold + ?Sized,
-{
- ItemStatic {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- static_token: Token![static](tokens_helper(f, &node.static_token.span)),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- expr: Box::new(f.fold_expr(*node.expr)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_struct<F>(f: &mut F, node: ItemStruct) -> ItemStruct
-where
- F: Fold + ?Sized,
-{
- ItemStruct {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- fields: f.fold_fields(node.fields),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_trait<F>(f: &mut F, node: ItemTrait) -> ItemTrait
-where
- F: Fold + ?Sized,
-{
- ItemTrait {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))),
- auto_token: (node.auto_token).map(|it| Token![auto](tokens_helper(f, &it.span))),
- trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- supertraits: FoldHelper::lift(node.supertraits, |it| f.fold_type_param_bound(it)),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- items: FoldHelper::lift(node.items, |it| f.fold_trait_item(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_trait_alias<F>(f: &mut F, node: ItemTraitAlias) -> ItemTraitAlias
-where
- F: Fold + ?Sized,
-{
- ItemTraitAlias {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_type<F>(f: &mut F, node: ItemType) -> ItemType
-where
- F: Fold + ?Sized,
-{
- ItemType {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- type_token: Token![type](tokens_helper(f, &node.type_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_union<F>(f: &mut F, node: ItemUnion) -> ItemUnion
-where
- F: Fold + ?Sized,
-{
- ItemUnion {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- union_token: Token![union](tokens_helper(f, &node.union_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- fields: f.fold_fields_named(node.fields),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_item_use<F>(f: &mut F, node: ItemUse) -> ItemUse
-where
- F: Fold + ?Sized,
-{
- ItemUse {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- vis: f.fold_visibility(node.vis),
- use_token: Token![use](tokens_helper(f, &node.use_token.span)),
- leading_colon: (node.leading_colon).map(|it| Token ! [ :: ](tokens_helper(f, &it.spans))),
- tree: f.fold_use_tree(node.tree),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_label<F>(f: &mut F, node: Label) -> Label
-where
- F: Fold + ?Sized,
-{
- Label {
- name: f.fold_lifetime(node.name),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- }
-}
-pub fn fold_lifetime<F>(f: &mut F, node: Lifetime) -> Lifetime
-where
- F: Fold + ?Sized,
-{
- Lifetime {
- apostrophe: f.fold_span(node.apostrophe),
- ident: f.fold_ident(node.ident),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lifetime_def<F>(f: &mut F, node: LifetimeDef) -> LifetimeDef
-where
- F: Fold + ?Sized,
-{
- LifetimeDef {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- lifetime: f.fold_lifetime(node.lifetime),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit<F>(f: &mut F, node: Lit) -> Lit
-where
- F: Fold + ?Sized,
-{
- match node {
- Lit::Str(_binding_0) => Lit::Str(f.fold_lit_str(_binding_0)),
- Lit::ByteStr(_binding_0) => Lit::ByteStr(f.fold_lit_byte_str(_binding_0)),
- Lit::Byte(_binding_0) => Lit::Byte(f.fold_lit_byte(_binding_0)),
- Lit::Char(_binding_0) => Lit::Char(f.fold_lit_char(_binding_0)),
- Lit::Int(_binding_0) => Lit::Int(f.fold_lit_int(_binding_0)),
- Lit::Float(_binding_0) => Lit::Float(f.fold_lit_float(_binding_0)),
- Lit::Bool(_binding_0) => Lit::Bool(f.fold_lit_bool(_binding_0)),
- Lit::Verbatim(_binding_0) => Lit::Verbatim(_binding_0),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_bool<F>(f: &mut F, node: LitBool) -> LitBool
-where
- F: Fold + ?Sized,
-{
- LitBool {
- value: node.value,
- span: f.fold_span(node.span),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_byte<F>(f: &mut F, node: LitByte) -> LitByte
-where
- F: Fold + ?Sized,
-{
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_byte_str<F>(f: &mut F, node: LitByteStr) -> LitByteStr
-where
- F: Fold + ?Sized,
-{
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_char<F>(f: &mut F, node: LitChar) -> LitChar
-where
- F: Fold + ?Sized,
-{
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_float<F>(f: &mut F, node: LitFloat) -> LitFloat
-where
- F: Fold + ?Sized,
-{
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_int<F>(f: &mut F, node: LitInt) -> LitInt
-where
- F: Fold + ?Sized,
-{
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_lit_str<F>(f: &mut F, node: LitStr) -> LitStr
-where
- F: Fold + ?Sized,
-{
- let span = f.fold_span(node.span());
- let mut node = node;
- node.set_span(span);
- node
-}
-#[cfg(feature = "full")]
-pub fn fold_local<F>(f: &mut F, node: Local) -> Local
-where
- F: Fold + ?Sized,
-{
- Local {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- let_token: Token![let](tokens_helper(f, &node.let_token.span)),
- pat: f.fold_pat(node.pat),
- init: (node.init).map(|it| {
- (
- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
- Box::new(f.fold_expr(*(it).1)),
- )
- }),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_macro<F>(f: &mut F, node: Macro) -> Macro
-where
- F: Fold + ?Sized,
-{
- Macro {
- path: f.fold_path(node.path),
- bang_token: Token![!](tokens_helper(f, &node.bang_token.spans)),
- delimiter: f.fold_macro_delimiter(node.delimiter),
- tokens: node.tokens,
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_macro_delimiter<F>(f: &mut F, node: MacroDelimiter) -> MacroDelimiter
-where
- F: Fold + ?Sized,
-{
- match node {
- MacroDelimiter::Paren(_binding_0) => {
- MacroDelimiter::Paren(Paren(tokens_helper(f, &_binding_0.span)))
- }
- MacroDelimiter::Brace(_binding_0) => {
- MacroDelimiter::Brace(Brace(tokens_helper(f, &_binding_0.span)))
- }
- MacroDelimiter::Bracket(_binding_0) => {
- MacroDelimiter::Bracket(Bracket(tokens_helper(f, &_binding_0.span)))
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_member<F>(f: &mut F, node: Member) -> Member
-where
- F: Fold + ?Sized,
-{
- match node {
- Member::Named(_binding_0) => Member::Named(f.fold_ident(_binding_0)),
- Member::Unnamed(_binding_0) => Member::Unnamed(f.fold_index(_binding_0)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_meta<F>(f: &mut F, node: Meta) -> Meta
-where
- F: Fold + ?Sized,
-{
- match node {
- Meta::Path(_binding_0) => Meta::Path(f.fold_path(_binding_0)),
- Meta::List(_binding_0) => Meta::List(f.fold_meta_list(_binding_0)),
- Meta::NameValue(_binding_0) => Meta::NameValue(f.fold_meta_name_value(_binding_0)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_meta_list<F>(f: &mut F, node: MetaList) -> MetaList
-where
- F: Fold + ?Sized,
-{
- MetaList {
- path: f.fold_path(node.path),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- nested: FoldHelper::lift(node.nested, |it| f.fold_nested_meta(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_meta_name_value<F>(f: &mut F, node: MetaNameValue) -> MetaNameValue
-where
- F: Fold + ?Sized,
-{
- MetaNameValue {
- path: f.fold_path(node.path),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- lit: f.fold_lit(node.lit),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_method_turbofish<F>(f: &mut F, node: MethodTurbofish) -> MethodTurbofish
-where
- F: Fold + ?Sized,
-{
- MethodTurbofish {
- colon2_token: Token ! [ :: ](tokens_helper(f, &node.colon2_token.spans)),
- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
- args: FoldHelper::lift(node.args, |it| f.fold_generic_method_argument(it)),
- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_nested_meta<F>(f: &mut F, node: NestedMeta) -> NestedMeta
-where
- F: Fold + ?Sized,
-{
- match node {
- NestedMeta::Meta(_binding_0) => NestedMeta::Meta(f.fold_meta(_binding_0)),
- NestedMeta::Lit(_binding_0) => NestedMeta::Lit(f.fold_lit(_binding_0)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_parenthesized_generic_arguments<F>(
- f: &mut F,
- node: ParenthesizedGenericArguments,
-) -> ParenthesizedGenericArguments
-where
- F: Fold + ?Sized,
-{
- ParenthesizedGenericArguments {
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- inputs: FoldHelper::lift(node.inputs, |it| f.fold_type(it)),
- output: f.fold_return_type(node.output),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat<F>(f: &mut F, node: Pat) -> Pat
-where
- F: Fold + ?Sized,
-{
- match node {
- Pat::Box(_binding_0) => Pat::Box(f.fold_pat_box(_binding_0)),
- Pat::Ident(_binding_0) => Pat::Ident(f.fold_pat_ident(_binding_0)),
- Pat::Lit(_binding_0) => Pat::Lit(f.fold_pat_lit(_binding_0)),
- Pat::Macro(_binding_0) => Pat::Macro(f.fold_pat_macro(_binding_0)),
- Pat::Or(_binding_0) => Pat::Or(f.fold_pat_or(_binding_0)),
- Pat::Path(_binding_0) => Pat::Path(f.fold_pat_path(_binding_0)),
- Pat::Range(_binding_0) => Pat::Range(f.fold_pat_range(_binding_0)),
- Pat::Reference(_binding_0) => Pat::Reference(f.fold_pat_reference(_binding_0)),
- Pat::Rest(_binding_0) => Pat::Rest(f.fold_pat_rest(_binding_0)),
- Pat::Slice(_binding_0) => Pat::Slice(f.fold_pat_slice(_binding_0)),
- Pat::Struct(_binding_0) => Pat::Struct(f.fold_pat_struct(_binding_0)),
- Pat::Tuple(_binding_0) => Pat::Tuple(f.fold_pat_tuple(_binding_0)),
- Pat::TupleStruct(_binding_0) => Pat::TupleStruct(f.fold_pat_tuple_struct(_binding_0)),
- Pat::Type(_binding_0) => Pat::Type(f.fold_pat_type(_binding_0)),
- Pat::Verbatim(_binding_0) => Pat::Verbatim(_binding_0),
- Pat::Wild(_binding_0) => Pat::Wild(f.fold_pat_wild(_binding_0)),
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_box<F>(f: &mut F, node: PatBox) -> PatBox
-where
- F: Fold + ?Sized,
-{
- PatBox {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- box_token: Token![box](tokens_helper(f, &node.box_token.span)),
- pat: Box::new(f.fold_pat(*node.pat)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_ident<F>(f: &mut F, node: PatIdent) -> PatIdent
-where
- F: Fold + ?Sized,
-{
- PatIdent {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- by_ref: (node.by_ref).map(|it| Token![ref](tokens_helper(f, &it.span))),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- ident: f.fold_ident(node.ident),
- subpat: (node.subpat).map(|it| {
- (
- Token ! [ @ ](tokens_helper(f, &(it).0.spans)),
- Box::new(f.fold_pat(*(it).1)),
- )
- }),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_lit<F>(f: &mut F, node: PatLit) -> PatLit
-where
- F: Fold + ?Sized,
-{
- PatLit {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- expr: Box::new(f.fold_expr(*node.expr)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_macro<F>(f: &mut F, node: PatMacro) -> PatMacro
-where
- F: Fold + ?Sized,
-{
- PatMacro {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- mac: f.fold_macro(node.mac),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_or<F>(f: &mut F, node: PatOr) -> PatOr
-where
- F: Fold + ?Sized,
-{
- PatOr {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- leading_vert: (node.leading_vert).map(|it| Token ! [ | ](tokens_helper(f, &it.spans))),
- cases: FoldHelper::lift(node.cases, |it| f.fold_pat(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_path<F>(f: &mut F, node: PatPath) -> PatPath
-where
- F: Fold + ?Sized,
-{
- PatPath {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- qself: (node.qself).map(|it| f.fold_qself(it)),
- path: f.fold_path(node.path),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_range<F>(f: &mut F, node: PatRange) -> PatRange
-where
- F: Fold + ?Sized,
-{
- PatRange {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- lo: Box::new(f.fold_expr(*node.lo)),
- limits: f.fold_range_limits(node.limits),
- hi: Box::new(f.fold_expr(*node.hi)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_reference<F>(f: &mut F, node: PatReference) -> PatReference
-where
- F: Fold + ?Sized,
-{
- PatReference {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- and_token: Token ! [ & ](tokens_helper(f, &node.and_token.spans)),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- pat: Box::new(f.fold_pat(*node.pat)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_rest<F>(f: &mut F, node: PatRest) -> PatRest
-where
- F: Fold + ?Sized,
-{
- PatRest {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- dot2_token: Token![..](tokens_helper(f, &node.dot2_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_slice<F>(f: &mut F, node: PatSlice) -> PatSlice
-where
- F: Fold + ?Sized,
-{
- PatSlice {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_struct<F>(f: &mut F, node: PatStruct) -> PatStruct
-where
- F: Fold + ?Sized,
-{
- PatStruct {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- path: f.fold_path(node.path),
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- fields: FoldHelper::lift(node.fields, |it| f.fold_field_pat(it)),
- dot2_token: (node.dot2_token).map(|it| Token![..](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_tuple<F>(f: &mut F, node: PatTuple) -> PatTuple
-where
- F: Fold + ?Sized,
-{
- PatTuple {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_tuple_struct<F>(f: &mut F, node: PatTupleStruct) -> PatTupleStruct
-where
- F: Fold + ?Sized,
-{
- PatTupleStruct {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- path: f.fold_path(node.path),
- pat: f.fold_pat_tuple(node.pat),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_type<F>(f: &mut F, node: PatType) -> PatType
-where
- F: Fold + ?Sized,
-{
- PatType {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- pat: Box::new(f.fold_pat(*node.pat)),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_pat_wild<F>(f: &mut F, node: PatWild) -> PatWild
-where
- F: Fold + ?Sized,
-{
- PatWild {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- underscore_token: Token![_](tokens_helper(f, &node.underscore_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_path<F>(f: &mut F, node: Path) -> Path
-where
- F: Fold + ?Sized,
-{
- Path {
- leading_colon: (node.leading_colon).map(|it| Token ! [ :: ](tokens_helper(f, &it.spans))),
- segments: FoldHelper::lift(node.segments, |it| f.fold_path_segment(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_path_arguments<F>(f: &mut F, node: PathArguments) -> PathArguments
-where
- F: Fold + ?Sized,
-{
- match node {
- PathArguments::None => PathArguments::None,
- PathArguments::AngleBracketed(_binding_0) => {
- PathArguments::AngleBracketed(f.fold_angle_bracketed_generic_arguments(_binding_0))
- }
- PathArguments::Parenthesized(_binding_0) => {
- PathArguments::Parenthesized(f.fold_parenthesized_generic_arguments(_binding_0))
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_path_segment<F>(f: &mut F, node: PathSegment) -> PathSegment
-where
- F: Fold + ?Sized,
-{
- PathSegment {
- ident: f.fold_ident(node.ident),
- arguments: f.fold_path_arguments(node.arguments),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_predicate_eq<F>(f: &mut F, node: PredicateEq) -> PredicateEq
-where
- F: Fold + ?Sized,
-{
- PredicateEq {
- lhs_ty: f.fold_type(node.lhs_ty),
- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
- rhs_ty: f.fold_type(node.rhs_ty),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_predicate_lifetime<F>(f: &mut F, node: PredicateLifetime) -> PredicateLifetime
-where
- F: Fold + ?Sized,
-{
- PredicateLifetime {
- lifetime: f.fold_lifetime(node.lifetime),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_predicate_type<F>(f: &mut F, node: PredicateType) -> PredicateType
-where
- F: Fold + ?Sized,
-{
- PredicateType {
- lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)),
- bounded_ty: f.fold_type(node.bounded_ty),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_qself<F>(f: &mut F, node: QSelf) -> QSelf
-where
- F: Fold + ?Sized,
-{
- QSelf {
- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
- ty: Box::new(f.fold_type(*node.ty)),
- position: node.position,
- as_token: (node.as_token).map(|it| Token![as](tokens_helper(f, &it.span))),
- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_range_limits<F>(f: &mut F, node: RangeLimits) -> RangeLimits
-where
- F: Fold + ?Sized,
-{
- match node {
- RangeLimits::HalfOpen(_binding_0) => {
- RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans)))
- }
- RangeLimits::Closed(_binding_0) => {
- RangeLimits::Closed(Token ! [ ..= ](tokens_helper(f, &_binding_0.spans)))
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_receiver<F>(f: &mut F, node: Receiver) -> Receiver
-where
- F: Fold + ?Sized,
-{
- Receiver {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- reference: (node.reference).map(|it| {
- (
- Token ! [ & ](tokens_helper(f, &(it).0.spans)),
- ((it).1).map(|it| f.fold_lifetime(it)),
- )
- }),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- self_token: Token![self](tokens_helper(f, &node.self_token.span)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_return_type<F>(f: &mut F, node: ReturnType) -> ReturnType
-where
- F: Fold + ?Sized,
-{
- match node {
- ReturnType::Default => ReturnType::Default,
- ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type(
- Token ! [ -> ](tokens_helper(f, &_binding_0.spans)),
- Box::new(f.fold_type(*_binding_1)),
- ),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_signature<F>(f: &mut F, node: Signature) -> Signature
-where
- F: Fold + ?Sized,
-{
- Signature {
- constness: (node.constness).map(|it| Token![const](tokens_helper(f, &it.span))),
- asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))),
- unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))),
- abi: (node.abi).map(|it| f.fold_abi(it)),
- fn_token: Token![fn](tokens_helper(f, &node.fn_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- inputs: FoldHelper::lift(node.inputs, |it| f.fold_fn_arg(it)),
- variadic: (node.variadic).map(|it| f.fold_variadic(it)),
- output: f.fold_return_type(node.output),
- }
-}
-pub fn fold_span<F>(f: &mut F, node: Span) -> Span
-where
- F: Fold + ?Sized,
-{
- node
-}
-#[cfg(feature = "full")]
-pub fn fold_stmt<F>(f: &mut F, node: Stmt) -> Stmt
-where
- F: Fold + ?Sized,
-{
- match node {
- Stmt::Local(_binding_0) => Stmt::Local(f.fold_local(_binding_0)),
- Stmt::Item(_binding_0) => Stmt::Item(f.fold_item(_binding_0)),
- Stmt::Expr(_binding_0) => Stmt::Expr(f.fold_expr(_binding_0)),
- Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi(
- f.fold_expr(_binding_0),
- Token ! [ ; ](tokens_helper(f, &_binding_1.spans)),
- ),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_trait_bound<F>(f: &mut F, node: TraitBound) -> TraitBound
-where
- F: Fold + ?Sized,
-{
- TraitBound {
- paren_token: (node.paren_token).map(|it| Paren(tokens_helper(f, &it.span))),
- modifier: f.fold_trait_bound_modifier(node.modifier),
- lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)),
- path: f.fold_path(node.path),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_trait_bound_modifier<F>(f: &mut F, node: TraitBoundModifier) -> TraitBoundModifier
-where
- F: Fold + ?Sized,
-{
- match node {
- TraitBoundModifier::None => TraitBoundModifier::None,
- TraitBoundModifier::Maybe(_binding_0) => {
- TraitBoundModifier::Maybe(Token ! [ ? ](tokens_helper(f, &_binding_0.spans)))
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_trait_item<F>(f: &mut F, node: TraitItem) -> TraitItem
-where
- F: Fold + ?Sized,
-{
- match node {
- TraitItem::Const(_binding_0) => TraitItem::Const(f.fold_trait_item_const(_binding_0)),
- TraitItem::Method(_binding_0) => TraitItem::Method(f.fold_trait_item_method(_binding_0)),
- TraitItem::Type(_binding_0) => TraitItem::Type(f.fold_trait_item_type(_binding_0)),
- TraitItem::Macro(_binding_0) => TraitItem::Macro(f.fold_trait_item_macro(_binding_0)),
- TraitItem::Verbatim(_binding_0) => TraitItem::Verbatim(_binding_0),
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_trait_item_const<F>(f: &mut F, node: TraitItemConst) -> TraitItemConst
-where
- F: Fold + ?Sized,
-{
- TraitItemConst {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- const_token: Token![const](tokens_helper(f, &node.const_token.span)),
- ident: f.fold_ident(node.ident),
- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
- ty: f.fold_type(node.ty),
- default: (node.default).map(|it| {
- (
- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
- f.fold_expr((it).1),
- )
- }),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_trait_item_macro<F>(f: &mut F, node: TraitItemMacro) -> TraitItemMacro
-where
- F: Fold + ?Sized,
-{
- TraitItemMacro {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- mac: f.fold_macro(node.mac),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_trait_item_method<F>(f: &mut F, node: TraitItemMethod) -> TraitItemMethod
-where
- F: Fold + ?Sized,
-{
- TraitItemMethod {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- sig: f.fold_signature(node.sig),
- default: (node.default).map(|it| f.fold_block(it)),
- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_trait_item_type<F>(f: &mut F, node: TraitItemType) -> TraitItemType
-where
- F: Fold + ?Sized,
-{
- TraitItemType {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- type_token: Token![type](tokens_helper(f, &node.type_token.span)),
- ident: f.fold_ident(node.ident),
- generics: f.fold_generics(node.generics),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- default: (node.default).map(|it| {
- (
- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
- f.fold_type((it).1),
- )
- }),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type<F>(f: &mut F, node: Type) -> Type
-where
- F: Fold + ?Sized,
-{
- match node {
- Type::Array(_binding_0) => Type::Array(f.fold_type_array(_binding_0)),
- Type::BareFn(_binding_0) => Type::BareFn(f.fold_type_bare_fn(_binding_0)),
- Type::Group(_binding_0) => Type::Group(f.fold_type_group(_binding_0)),
- Type::ImplTrait(_binding_0) => Type::ImplTrait(f.fold_type_impl_trait(_binding_0)),
- Type::Infer(_binding_0) => Type::Infer(f.fold_type_infer(_binding_0)),
- Type::Macro(_binding_0) => Type::Macro(f.fold_type_macro(_binding_0)),
- Type::Never(_binding_0) => Type::Never(f.fold_type_never(_binding_0)),
- Type::Paren(_binding_0) => Type::Paren(f.fold_type_paren(_binding_0)),
- Type::Path(_binding_0) => Type::Path(f.fold_type_path(_binding_0)),
- Type::Ptr(_binding_0) => Type::Ptr(f.fold_type_ptr(_binding_0)),
- Type::Reference(_binding_0) => Type::Reference(f.fold_type_reference(_binding_0)),
- Type::Slice(_binding_0) => Type::Slice(f.fold_type_slice(_binding_0)),
- Type::TraitObject(_binding_0) => Type::TraitObject(f.fold_type_trait_object(_binding_0)),
- Type::Tuple(_binding_0) => Type::Tuple(f.fold_type_tuple(_binding_0)),
- Type::Verbatim(_binding_0) => Type::Verbatim(_binding_0),
- _ => unreachable!(),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_array<F>(f: &mut F, node: TypeArray) -> TypeArray
-where
- F: Fold + ?Sized,
-{
- TypeArray {
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- elem: Box::new(f.fold_type(*node.elem)),
- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
- len: f.fold_expr(node.len),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_bare_fn<F>(f: &mut F, node: TypeBareFn) -> TypeBareFn
-where
- F: Fold + ?Sized,
-{
- TypeBareFn {
- lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)),
- unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))),
- abi: (node.abi).map(|it| f.fold_abi(it)),
- fn_token: Token![fn](tokens_helper(f, &node.fn_token.span)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- inputs: FoldHelper::lift(node.inputs, |it| f.fold_bare_fn_arg(it)),
- variadic: (node.variadic).map(|it| f.fold_variadic(it)),
- output: f.fold_return_type(node.output),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_group<F>(f: &mut F, node: TypeGroup) -> TypeGroup
-where
- F: Fold + ?Sized,
-{
- TypeGroup {
- group_token: Group(tokens_helper(f, &node.group_token.span)),
- elem: Box::new(f.fold_type(*node.elem)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_impl_trait<F>(f: &mut F, node: TypeImplTrait) -> TypeImplTrait
-where
- F: Fold + ?Sized,
-{
- TypeImplTrait {
- impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_infer<F>(f: &mut F, node: TypeInfer) -> TypeInfer
-where
- F: Fold + ?Sized,
-{
- TypeInfer {
- underscore_token: Token![_](tokens_helper(f, &node.underscore_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_macro<F>(f: &mut F, node: TypeMacro) -> TypeMacro
-where
- F: Fold + ?Sized,
-{
- TypeMacro {
- mac: f.fold_macro(node.mac),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_never<F>(f: &mut F, node: TypeNever) -> TypeNever
-where
- F: Fold + ?Sized,
-{
- TypeNever {
- bang_token: Token![!](tokens_helper(f, &node.bang_token.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_param<F>(f: &mut F, node: TypeParam) -> TypeParam
-where
- F: Fold + ?Sized,
-{
- TypeParam {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- ident: f.fold_ident(node.ident),
- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- eq_token: (node.eq_token).map(|it| Token ! [ = ](tokens_helper(f, &it.spans))),
- default: (node.default).map(|it| f.fold_type(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_param_bound<F>(f: &mut F, node: TypeParamBound) -> TypeParamBound
-where
- F: Fold + ?Sized,
-{
- match node {
- TypeParamBound::Trait(_binding_0) => TypeParamBound::Trait(f.fold_trait_bound(_binding_0)),
- TypeParamBound::Lifetime(_binding_0) => {
- TypeParamBound::Lifetime(f.fold_lifetime(_binding_0))
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_paren<F>(f: &mut F, node: TypeParen) -> TypeParen
-where
- F: Fold + ?Sized,
-{
- TypeParen {
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- elem: Box::new(f.fold_type(*node.elem)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_path<F>(f: &mut F, node: TypePath) -> TypePath
-where
- F: Fold + ?Sized,
-{
- TypePath {
- qself: (node.qself).map(|it| f.fold_qself(it)),
- path: f.fold_path(node.path),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_ptr<F>(f: &mut F, node: TypePtr) -> TypePtr
-where
- F: Fold + ?Sized,
-{
- TypePtr {
- star_token: Token ! [ * ](tokens_helper(f, &node.star_token.spans)),
- const_token: (node.const_token).map(|it| Token![const](tokens_helper(f, &it.span))),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- elem: Box::new(f.fold_type(*node.elem)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_reference<F>(f: &mut F, node: TypeReference) -> TypeReference
-where
- F: Fold + ?Sized,
-{
- TypeReference {
- and_token: Token ! [ & ](tokens_helper(f, &node.and_token.spans)),
- lifetime: (node.lifetime).map(|it| f.fold_lifetime(it)),
- mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
- elem: Box::new(f.fold_type(*node.elem)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_slice<F>(f: &mut F, node: TypeSlice) -> TypeSlice
-where
- F: Fold + ?Sized,
-{
- TypeSlice {
- bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
- elem: Box::new(f.fold_type(*node.elem)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_trait_object<F>(f: &mut F, node: TypeTraitObject) -> TypeTraitObject
-where
- F: Fold + ?Sized,
-{
- TypeTraitObject {
- dyn_token: (node.dyn_token).map(|it| Token![dyn](tokens_helper(f, &it.span))),
- bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_type_tuple<F>(f: &mut F, node: TypeTuple) -> TypeTuple
-where
- F: Fold + ?Sized,
-{
- TypeTuple {
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- elems: FoldHelper::lift(node.elems, |it| f.fold_type(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_un_op<F>(f: &mut F, node: UnOp) -> UnOp
-where
- F: Fold + ?Sized,
-{
- match node {
- UnOp::Deref(_binding_0) => UnOp::Deref(Token ! [ * ](tokens_helper(f, &_binding_0.spans))),
- UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))),
- UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [ - ](tokens_helper(f, &_binding_0.spans))),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_use_glob<F>(f: &mut F, node: UseGlob) -> UseGlob
-where
- F: Fold + ?Sized,
-{
- UseGlob {
- star_token: Token ! [ * ](tokens_helper(f, &node.star_token.spans)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_use_group<F>(f: &mut F, node: UseGroup) -> UseGroup
-where
- F: Fold + ?Sized,
-{
- UseGroup {
- brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
- items: FoldHelper::lift(node.items, |it| f.fold_use_tree(it)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_use_name<F>(f: &mut F, node: UseName) -> UseName
-where
- F: Fold + ?Sized,
-{
- UseName {
- ident: f.fold_ident(node.ident),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_use_path<F>(f: &mut F, node: UsePath) -> UsePath
-where
- F: Fold + ?Sized,
-{
- UsePath {
- ident: f.fold_ident(node.ident),
- colon2_token: Token ! [ :: ](tokens_helper(f, &node.colon2_token.spans)),
- tree: Box::new(f.fold_use_tree(*node.tree)),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_use_rename<F>(f: &mut F, node: UseRename) -> UseRename
-where
- F: Fold + ?Sized,
-{
- UseRename {
- ident: f.fold_ident(node.ident),
- as_token: Token![as](tokens_helper(f, &node.as_token.span)),
- rename: f.fold_ident(node.rename),
- }
-}
-#[cfg(feature = "full")]
-pub fn fold_use_tree<F>(f: &mut F, node: UseTree) -> UseTree
-where
- F: Fold + ?Sized,
-{
- match node {
- UseTree::Path(_binding_0) => UseTree::Path(f.fold_use_path(_binding_0)),
- UseTree::Name(_binding_0) => UseTree::Name(f.fold_use_name(_binding_0)),
- UseTree::Rename(_binding_0) => UseTree::Rename(f.fold_use_rename(_binding_0)),
- UseTree::Glob(_binding_0) => UseTree::Glob(f.fold_use_glob(_binding_0)),
- UseTree::Group(_binding_0) => UseTree::Group(f.fold_use_group(_binding_0)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_variadic<F>(f: &mut F, node: Variadic) -> Variadic
-where
- F: Fold + ?Sized,
-{
- Variadic {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- dots: Token ! [ ... ](tokens_helper(f, &node.dots.spans)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_variant<F>(f: &mut F, node: Variant) -> Variant
-where
- F: Fold + ?Sized,
-{
- Variant {
- attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
- ident: f.fold_ident(node.ident),
- fields: f.fold_fields(node.fields),
- discriminant: (node.discriminant).map(|it| {
- (
- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
- f.fold_expr((it).1),
- )
- }),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_vis_crate<F>(f: &mut F, node: VisCrate) -> VisCrate
-where
- F: Fold + ?Sized,
-{
- VisCrate {
- crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_vis_public<F>(f: &mut F, node: VisPublic) -> VisPublic
-where
- F: Fold + ?Sized,
-{
- VisPublic {
- pub_token: Token![pub](tokens_helper(f, &node.pub_token.span)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_vis_restricted<F>(f: &mut F, node: VisRestricted) -> VisRestricted
-where
- F: Fold + ?Sized,
-{
- VisRestricted {
- pub_token: Token![pub](tokens_helper(f, &node.pub_token.span)),
- paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
- in_token: (node.in_token).map(|it| Token![in](tokens_helper(f, &it.span))),
- path: Box::new(f.fold_path(*node.path)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_visibility<F>(f: &mut F, node: Visibility) -> Visibility
-where
- F: Fold + ?Sized,
-{
- match node {
- Visibility::Public(_binding_0) => Visibility::Public(f.fold_vis_public(_binding_0)),
- Visibility::Crate(_binding_0) => Visibility::Crate(f.fold_vis_crate(_binding_0)),
- Visibility::Restricted(_binding_0) => {
- Visibility::Restricted(f.fold_vis_restricted(_binding_0))
- }
- Visibility::Inherited => Visibility::Inherited,
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_where_clause<F>(f: &mut F, node: WhereClause) -> WhereClause
-where
- F: Fold + ?Sized,
-{
- WhereClause {
- where_token: Token![where](tokens_helper(f, &node.where_token.span)),
- predicates: FoldHelper::lift(node.predicates, |it| f.fold_where_predicate(it)),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn fold_where_predicate<F>(f: &mut F, node: WherePredicate) -> WherePredicate
-where
- F: Fold + ?Sized,
-{
- match node {
- WherePredicate::Type(_binding_0) => WherePredicate::Type(f.fold_predicate_type(_binding_0)),
- WherePredicate::Lifetime(_binding_0) => {
- WherePredicate::Lifetime(f.fold_predicate_lifetime(_binding_0))
- }
- WherePredicate::Eq(_binding_0) => WherePredicate::Eq(f.fold_predicate_eq(_binding_0)),
- }
-}
diff --git a/syn/src/gen/visit.rs b/syn/src/gen/visit.rs
deleted file mode 100644
index b667f53..0000000
--- a/syn/src/gen/visit.rs
+++ /dev/null
@@ -1,3792 +0,0 @@
-// This file is @generated by syn-internal-codegen.
-// It is not intended for manual editing.
-
-#![allow(unused_variables)]
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::gen::helper::visit::*;
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::punctuated::Punctuated;
-use crate::*;
-use proc_macro2::Span;
-#[cfg(feature = "full")]
-macro_rules! full {
- ($e:expr) => {
- $e
- };
-}
-#[cfg(all(feature = "derive", not(feature = "full")))]
-macro_rules! full {
- ($e:expr) => {
- unreachable!()
- };
-}
-#[cfg(any(feature = "full", feature = "derive"))]
-macro_rules! skip {
- ($($tt:tt)*) => {};
-}
-/// Syntax tree traversal to walk a shared borrow of a syntax tree.
-///
-/// See the [module documentation] for details.
-///
-/// [module documentation]: self
-///
-/// *This trait is available if Syn is built with the `"visit"` feature.*
-pub trait Visit<'ast> {
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_abi(&mut self, i: &'ast Abi) {
- visit_abi(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_angle_bracketed_generic_arguments(&mut self, i: &'ast AngleBracketedGenericArguments) {
- visit_angle_bracketed_generic_arguments(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_arm(&mut self, i: &'ast Arm) {
- visit_arm(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_attr_style(&mut self, i: &'ast AttrStyle) {
- visit_attr_style(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_attribute(&mut self, i: &'ast Attribute) {
- visit_attribute(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_bare_fn_arg(&mut self, i: &'ast BareFnArg) {
- visit_bare_fn_arg(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_bin_op(&mut self, i: &'ast BinOp) {
- visit_bin_op(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_binding(&mut self, i: &'ast Binding) {
- visit_binding(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_block(&mut self, i: &'ast Block) {
- visit_block(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_bound_lifetimes(&mut self, i: &'ast BoundLifetimes) {
- visit_bound_lifetimes(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_const_param(&mut self, i: &'ast ConstParam) {
- visit_const_param(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_constraint(&mut self, i: &'ast Constraint) {
- visit_constraint(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data(&mut self, i: &'ast Data) {
- visit_data(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_enum(&mut self, i: &'ast DataEnum) {
- visit_data_enum(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_struct(&mut self, i: &'ast DataStruct) {
- visit_data_struct(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_union(&mut self, i: &'ast DataUnion) {
- visit_data_union(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_derive_input(&mut self, i: &'ast DeriveInput) {
- visit_derive_input(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr(&mut self, i: &'ast Expr) {
- visit_expr(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_array(&mut self, i: &'ast ExprArray) {
- visit_expr_array(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_assign(&mut self, i: &'ast ExprAssign) {
- visit_expr_assign(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_assign_op(&mut self, i: &'ast ExprAssignOp) {
- visit_expr_assign_op(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_async(&mut self, i: &'ast ExprAsync) {
- visit_expr_async(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_await(&mut self, i: &'ast ExprAwait) {
- visit_expr_await(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_binary(&mut self, i: &'ast ExprBinary) {
- visit_expr_binary(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_block(&mut self, i: &'ast ExprBlock) {
- visit_expr_block(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_box(&mut self, i: &'ast ExprBox) {
- visit_expr_box(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_break(&mut self, i: &'ast ExprBreak) {
- visit_expr_break(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_call(&mut self, i: &'ast ExprCall) {
- visit_expr_call(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_cast(&mut self, i: &'ast ExprCast) {
- visit_expr_cast(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_closure(&mut self, i: &'ast ExprClosure) {
- visit_expr_closure(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_continue(&mut self, i: &'ast ExprContinue) {
- visit_expr_continue(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_field(&mut self, i: &'ast ExprField) {
- visit_expr_field(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_for_loop(&mut self, i: &'ast ExprForLoop) {
- visit_expr_for_loop(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_group(&mut self, i: &'ast ExprGroup) {
- visit_expr_group(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_if(&mut self, i: &'ast ExprIf) {
- visit_expr_if(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_index(&mut self, i: &'ast ExprIndex) {
- visit_expr_index(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_let(&mut self, i: &'ast ExprLet) {
- visit_expr_let(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_lit(&mut self, i: &'ast ExprLit) {
- visit_expr_lit(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_loop(&mut self, i: &'ast ExprLoop) {
- visit_expr_loop(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_macro(&mut self, i: &'ast ExprMacro) {
- visit_expr_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_match(&mut self, i: &'ast ExprMatch) {
- visit_expr_match(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_method_call(&mut self, i: &'ast ExprMethodCall) {
- visit_expr_method_call(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_paren(&mut self, i: &'ast ExprParen) {
- visit_expr_paren(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_path(&mut self, i: &'ast ExprPath) {
- visit_expr_path(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_range(&mut self, i: &'ast ExprRange) {
- visit_expr_range(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_reference(&mut self, i: &'ast ExprReference) {
- visit_expr_reference(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_repeat(&mut self, i: &'ast ExprRepeat) {
- visit_expr_repeat(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_return(&mut self, i: &'ast ExprReturn) {
- visit_expr_return(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_struct(&mut self, i: &'ast ExprStruct) {
- visit_expr_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_try(&mut self, i: &'ast ExprTry) {
- visit_expr_try(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_try_block(&mut self, i: &'ast ExprTryBlock) {
- visit_expr_try_block(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_tuple(&mut self, i: &'ast ExprTuple) {
- visit_expr_tuple(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_type(&mut self, i: &'ast ExprType) {
- visit_expr_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_unary(&mut self, i: &'ast ExprUnary) {
- visit_expr_unary(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_unsafe(&mut self, i: &'ast ExprUnsafe) {
- visit_expr_unsafe(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_while(&mut self, i: &'ast ExprWhile) {
- visit_expr_while(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_yield(&mut self, i: &'ast ExprYield) {
- visit_expr_yield(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_field(&mut self, i: &'ast Field) {
- visit_field(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_field_pat(&mut self, i: &'ast FieldPat) {
- visit_field_pat(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_field_value(&mut self, i: &'ast FieldValue) {
- visit_field_value(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_fields(&mut self, i: &'ast Fields) {
- visit_fields(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_fields_named(&mut self, i: &'ast FieldsNamed) {
- visit_fields_named(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_fields_unnamed(&mut self, i: &'ast FieldsUnnamed) {
- visit_fields_unnamed(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_file(&mut self, i: &'ast File) {
- visit_file(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_fn_arg(&mut self, i: &'ast FnArg) {
- visit_fn_arg(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item(&mut self, i: &'ast ForeignItem) {
- visit_foreign_item(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_fn(&mut self, i: &'ast ForeignItemFn) {
- visit_foreign_item_fn(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_macro(&mut self, i: &'ast ForeignItemMacro) {
- visit_foreign_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_static(&mut self, i: &'ast ForeignItemStatic) {
- visit_foreign_item_static(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_type(&mut self, i: &'ast ForeignItemType) {
- visit_foreign_item_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_generic_argument(&mut self, i: &'ast GenericArgument) {
- visit_generic_argument(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_generic_method_argument(&mut self, i: &'ast GenericMethodArgument) {
- visit_generic_method_argument(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_generic_param(&mut self, i: &'ast GenericParam) {
- visit_generic_param(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_generics(&mut self, i: &'ast Generics) {
- visit_generics(self, i)
- }
- fn visit_ident(&mut self, i: &'ast Ident) {
- visit_ident(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item(&mut self, i: &'ast ImplItem) {
- visit_impl_item(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_const(&mut self, i: &'ast ImplItemConst) {
- visit_impl_item_const(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_macro(&mut self, i: &'ast ImplItemMacro) {
- visit_impl_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_method(&mut self, i: &'ast ImplItemMethod) {
- visit_impl_item_method(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_type(&mut self, i: &'ast ImplItemType) {
- visit_impl_item_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_index(&mut self, i: &'ast Index) {
- visit_index(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item(&mut self, i: &'ast Item) {
- visit_item(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_const(&mut self, i: &'ast ItemConst) {
- visit_item_const(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_enum(&mut self, i: &'ast ItemEnum) {
- visit_item_enum(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_extern_crate(&mut self, i: &'ast ItemExternCrate) {
- visit_item_extern_crate(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_fn(&mut self, i: &'ast ItemFn) {
- visit_item_fn(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_foreign_mod(&mut self, i: &'ast ItemForeignMod) {
- visit_item_foreign_mod(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_impl(&mut self, i: &'ast ItemImpl) {
- visit_item_impl(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_macro(&mut self, i: &'ast ItemMacro) {
- visit_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_macro2(&mut self, i: &'ast ItemMacro2) {
- visit_item_macro2(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_mod(&mut self, i: &'ast ItemMod) {
- visit_item_mod(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_static(&mut self, i: &'ast ItemStatic) {
- visit_item_static(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_struct(&mut self, i: &'ast ItemStruct) {
- visit_item_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_trait(&mut self, i: &'ast ItemTrait) {
- visit_item_trait(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_trait_alias(&mut self, i: &'ast ItemTraitAlias) {
- visit_item_trait_alias(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_type(&mut self, i: &'ast ItemType) {
- visit_item_type(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_union(&mut self, i: &'ast ItemUnion) {
- visit_item_union(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_use(&mut self, i: &'ast ItemUse) {
- visit_item_use(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_label(&mut self, i: &'ast Label) {
- visit_label(self, i)
- }
- fn visit_lifetime(&mut self, i: &'ast Lifetime) {
- visit_lifetime(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) {
- visit_lifetime_def(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit(&mut self, i: &'ast Lit) {
- visit_lit(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_bool(&mut self, i: &'ast LitBool) {
- visit_lit_bool(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_byte(&mut self, i: &'ast LitByte) {
- visit_lit_byte(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_byte_str(&mut self, i: &'ast LitByteStr) {
- visit_lit_byte_str(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_char(&mut self, i: &'ast LitChar) {
- visit_lit_char(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_float(&mut self, i: &'ast LitFloat) {
- visit_lit_float(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_int(&mut self, i: &'ast LitInt) {
- visit_lit_int(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_str(&mut self, i: &'ast LitStr) {
- visit_lit_str(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_local(&mut self, i: &'ast Local) {
- visit_local(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_macro(&mut self, i: &'ast Macro) {
- visit_macro(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_macro_delimiter(&mut self, i: &'ast MacroDelimiter) {
- visit_macro_delimiter(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_member(&mut self, i: &'ast Member) {
- visit_member(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_meta(&mut self, i: &'ast Meta) {
- visit_meta(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_meta_list(&mut self, i: &'ast MetaList) {
- visit_meta_list(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_meta_name_value(&mut self, i: &'ast MetaNameValue) {
- visit_meta_name_value(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_method_turbofish(&mut self, i: &'ast MethodTurbofish) {
- visit_method_turbofish(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_nested_meta(&mut self, i: &'ast NestedMeta) {
- visit_nested_meta(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_parenthesized_generic_arguments(&mut self, i: &'ast ParenthesizedGenericArguments) {
- visit_parenthesized_generic_arguments(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat(&mut self, i: &'ast Pat) {
- visit_pat(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_box(&mut self, i: &'ast PatBox) {
- visit_pat_box(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_ident(&mut self, i: &'ast PatIdent) {
- visit_pat_ident(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_lit(&mut self, i: &'ast PatLit) {
- visit_pat_lit(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_macro(&mut self, i: &'ast PatMacro) {
- visit_pat_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_or(&mut self, i: &'ast PatOr) {
- visit_pat_or(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_path(&mut self, i: &'ast PatPath) {
- visit_pat_path(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_range(&mut self, i: &'ast PatRange) {
- visit_pat_range(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_reference(&mut self, i: &'ast PatReference) {
- visit_pat_reference(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_rest(&mut self, i: &'ast PatRest) {
- visit_pat_rest(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_slice(&mut self, i: &'ast PatSlice) {
- visit_pat_slice(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_struct(&mut self, i: &'ast PatStruct) {
- visit_pat_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_tuple(&mut self, i: &'ast PatTuple) {
- visit_pat_tuple(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_tuple_struct(&mut self, i: &'ast PatTupleStruct) {
- visit_pat_tuple_struct(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_type(&mut self, i: &'ast PatType) {
- visit_pat_type(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_wild(&mut self, i: &'ast PatWild) {
- visit_pat_wild(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_path(&mut self, i: &'ast Path) {
- visit_path(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_path_arguments(&mut self, i: &'ast PathArguments) {
- visit_path_arguments(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_path_segment(&mut self, i: &'ast PathSegment) {
- visit_path_segment(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_predicate_eq(&mut self, i: &'ast PredicateEq) {
- visit_predicate_eq(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_predicate_lifetime(&mut self, i: &'ast PredicateLifetime) {
- visit_predicate_lifetime(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_predicate_type(&mut self, i: &'ast PredicateType) {
- visit_predicate_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_qself(&mut self, i: &'ast QSelf) {
- visit_qself(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_range_limits(&mut self, i: &'ast RangeLimits) {
- visit_range_limits(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_receiver(&mut self, i: &'ast Receiver) {
- visit_receiver(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_return_type(&mut self, i: &'ast ReturnType) {
- visit_return_type(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_signature(&mut self, i: &'ast Signature) {
- visit_signature(self, i)
- }
- fn visit_span(&mut self, i: &Span) {
- visit_span(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_stmt(&mut self, i: &'ast Stmt) {
- visit_stmt(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_trait_bound(&mut self, i: &'ast TraitBound) {
- visit_trait_bound(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_trait_bound_modifier(&mut self, i: &'ast TraitBoundModifier) {
- visit_trait_bound_modifier(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item(&mut self, i: &'ast TraitItem) {
- visit_trait_item(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_const(&mut self, i: &'ast TraitItemConst) {
- visit_trait_item_const(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_macro(&mut self, i: &'ast TraitItemMacro) {
- visit_trait_item_macro(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_method(&mut self, i: &'ast TraitItemMethod) {
- visit_trait_item_method(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_type(&mut self, i: &'ast TraitItemType) {
- visit_trait_item_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type(&mut self, i: &'ast Type) {
- visit_type(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_array(&mut self, i: &'ast TypeArray) {
- visit_type_array(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_bare_fn(&mut self, i: &'ast TypeBareFn) {
- visit_type_bare_fn(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_group(&mut self, i: &'ast TypeGroup) {
- visit_type_group(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_impl_trait(&mut self, i: &'ast TypeImplTrait) {
- visit_type_impl_trait(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_infer(&mut self, i: &'ast TypeInfer) {
- visit_type_infer(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_macro(&mut self, i: &'ast TypeMacro) {
- visit_type_macro(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_never(&mut self, i: &'ast TypeNever) {
- visit_type_never(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_param(&mut self, i: &'ast TypeParam) {
- visit_type_param(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_param_bound(&mut self, i: &'ast TypeParamBound) {
- visit_type_param_bound(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_paren(&mut self, i: &'ast TypeParen) {
- visit_type_paren(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_path(&mut self, i: &'ast TypePath) {
- visit_type_path(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_ptr(&mut self, i: &'ast TypePtr) {
- visit_type_ptr(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_reference(&mut self, i: &'ast TypeReference) {
- visit_type_reference(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_slice(&mut self, i: &'ast TypeSlice) {
- visit_type_slice(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_trait_object(&mut self, i: &'ast TypeTraitObject) {
- visit_type_trait_object(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_tuple(&mut self, i: &'ast TypeTuple) {
- visit_type_tuple(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_un_op(&mut self, i: &'ast UnOp) {
- visit_un_op(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_glob(&mut self, i: &'ast UseGlob) {
- visit_use_glob(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_group(&mut self, i: &'ast UseGroup) {
- visit_use_group(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_name(&mut self, i: &'ast UseName) {
- visit_use_name(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_path(&mut self, i: &'ast UsePath) {
- visit_use_path(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_rename(&mut self, i: &'ast UseRename) {
- visit_use_rename(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_tree(&mut self, i: &'ast UseTree) {
- visit_use_tree(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_variadic(&mut self, i: &'ast Variadic) {
- visit_variadic(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_variant(&mut self, i: &'ast Variant) {
- visit_variant(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_vis_crate(&mut self, i: &'ast VisCrate) {
- visit_vis_crate(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_vis_public(&mut self, i: &'ast VisPublic) {
- visit_vis_public(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_vis_restricted(&mut self, i: &'ast VisRestricted) {
- visit_vis_restricted(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_visibility(&mut self, i: &'ast Visibility) {
- visit_visibility(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_where_clause(&mut self, i: &'ast WhereClause) {
- visit_where_clause(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_where_predicate(&mut self, i: &'ast WherePredicate) {
- visit_where_predicate(self, i)
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_abi<'ast, V>(v: &mut V, node: &'ast Abi)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.extern_token.span);
- if let Some(it) = &node.name {
- v.visit_lit_str(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_angle_bracketed_generic_arguments<'ast, V>(
- v: &mut V,
- node: &'ast AngleBracketedGenericArguments,
-) where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.colon2_token {
- tokens_helper(v, &it.spans)
- };
- tokens_helper(v, &node.lt_token.spans);
- for el in Punctuated::pairs(&node.args) {
- let (it, p) = el.into_tuple();
- v.visit_generic_argument(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- tokens_helper(v, &node.gt_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_arm<'ast, V>(v: &mut V, node: &'ast Arm)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_pat(&node.pat);
- if let Some(it) = &node.guard {
- tokens_helper(v, &(it).0.span);
- v.visit_expr(&*(it).1);
- };
- tokens_helper(v, &node.fat_arrow_token.spans);
- v.visit_expr(&*node.body);
- if let Some(it) = &node.comma {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_attr_style<'ast, V>(v: &mut V, node: &'ast AttrStyle)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- AttrStyle::Outer => {}
- AttrStyle::Inner(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_attribute<'ast, V>(v: &mut V, node: &'ast Attribute)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.pound_token.spans);
- v.visit_attr_style(&node.style);
- tokens_helper(v, &node.bracket_token.span);
- v.visit_path(&node.path);
- skip!(node.tokens);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_bare_fn_arg<'ast, V>(v: &mut V, node: &'ast BareFnArg)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.name {
- v.visit_ident(&(it).0);
- tokens_helper(v, &(it).1.spans);
- };
- v.visit_type(&node.ty);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_bin_op<'ast, V>(v: &mut V, node: &'ast BinOp)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- BinOp::Add(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Sub(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Mul(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Div(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Rem(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::And(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Or(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::BitXor(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::BitAnd(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::BitOr(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Shl(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Shr(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Eq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Lt(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Le(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Ne(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Ge(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::Gt(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::AddEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::SubEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::MulEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::DivEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::RemEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::BitXorEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::BitAndEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::BitOrEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::ShlEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- BinOp::ShrEq(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_binding<'ast, V>(v: &mut V, node: &'ast Binding)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_type(&node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_block<'ast, V>(v: &mut V, node: &'ast Block)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.brace_token.span);
- for it in &node.stmts {
- v.visit_stmt(it)
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_bound_lifetimes<'ast, V>(v: &mut V, node: &'ast BoundLifetimes)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.for_token.span);
- tokens_helper(v, &node.lt_token.spans);
- for el in Punctuated::pairs(&node.lifetimes) {
- let (it, p) = el.into_tuple();
- v.visit_lifetime_def(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- tokens_helper(v, &node.gt_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_const_param<'ast, V>(v: &mut V, node: &'ast ConstParam)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.const_token.span);
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&node.ty);
- if let Some(it) = &node.eq_token {
- tokens_helper(v, &it.spans)
- };
- if let Some(it) = &node.default {
- v.visit_expr(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_constraint<'ast, V>(v: &mut V, node: &'ast Constraint)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "derive")]
-pub fn visit_data<'ast, V>(v: &mut V, node: &'ast Data)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Data::Struct(_binding_0) => {
- v.visit_data_struct(_binding_0);
- }
- Data::Enum(_binding_0) => {
- v.visit_data_enum(_binding_0);
- }
- Data::Union(_binding_0) => {
- v.visit_data_union(_binding_0);
- }
- }
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_enum<'ast, V>(v: &mut V, node: &'ast DataEnum)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.enum_token.span);
- tokens_helper(v, &node.brace_token.span);
- for el in Punctuated::pairs(&node.variants) {
- let (it, p) = el.into_tuple();
- v.visit_variant(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_struct<'ast, V>(v: &mut V, node: &'ast DataStruct)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.struct_token.span);
- v.visit_fields(&node.fields);
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_union<'ast, V>(v: &mut V, node: &'ast DataUnion)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.union_token.span);
- v.visit_fields_named(&node.fields);
-}
-#[cfg(feature = "derive")]
-pub fn visit_derive_input<'ast, V>(v: &mut V, node: &'ast DeriveInput)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- v.visit_data(&node.data);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr<'ast, V>(v: &mut V, node: &'ast Expr)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Expr::Array(_binding_0) => {
- full!(v.visit_expr_array(_binding_0));
- }
- Expr::Assign(_binding_0) => {
- full!(v.visit_expr_assign(_binding_0));
- }
- Expr::AssignOp(_binding_0) => {
- full!(v.visit_expr_assign_op(_binding_0));
- }
- Expr::Async(_binding_0) => {
- full!(v.visit_expr_async(_binding_0));
- }
- Expr::Await(_binding_0) => {
- full!(v.visit_expr_await(_binding_0));
- }
- Expr::Binary(_binding_0) => {
- v.visit_expr_binary(_binding_0);
- }
- Expr::Block(_binding_0) => {
- full!(v.visit_expr_block(_binding_0));
- }
- Expr::Box(_binding_0) => {
- full!(v.visit_expr_box(_binding_0));
- }
- Expr::Break(_binding_0) => {
- full!(v.visit_expr_break(_binding_0));
- }
- Expr::Call(_binding_0) => {
- v.visit_expr_call(_binding_0);
- }
- Expr::Cast(_binding_0) => {
- v.visit_expr_cast(_binding_0);
- }
- Expr::Closure(_binding_0) => {
- full!(v.visit_expr_closure(_binding_0));
- }
- Expr::Continue(_binding_0) => {
- full!(v.visit_expr_continue(_binding_0));
- }
- Expr::Field(_binding_0) => {
- v.visit_expr_field(_binding_0);
- }
- Expr::ForLoop(_binding_0) => {
- full!(v.visit_expr_for_loop(_binding_0));
- }
- Expr::Group(_binding_0) => {
- full!(v.visit_expr_group(_binding_0));
- }
- Expr::If(_binding_0) => {
- full!(v.visit_expr_if(_binding_0));
- }
- Expr::Index(_binding_0) => {
- v.visit_expr_index(_binding_0);
- }
- Expr::Let(_binding_0) => {
- full!(v.visit_expr_let(_binding_0));
- }
- Expr::Lit(_binding_0) => {
- v.visit_expr_lit(_binding_0);
- }
- Expr::Loop(_binding_0) => {
- full!(v.visit_expr_loop(_binding_0));
- }
- Expr::Macro(_binding_0) => {
- full!(v.visit_expr_macro(_binding_0));
- }
- Expr::Match(_binding_0) => {
- full!(v.visit_expr_match(_binding_0));
- }
- Expr::MethodCall(_binding_0) => {
- full!(v.visit_expr_method_call(_binding_0));
- }
- Expr::Paren(_binding_0) => {
- v.visit_expr_paren(_binding_0);
- }
- Expr::Path(_binding_0) => {
- v.visit_expr_path(_binding_0);
- }
- Expr::Range(_binding_0) => {
- full!(v.visit_expr_range(_binding_0));
- }
- Expr::Reference(_binding_0) => {
- full!(v.visit_expr_reference(_binding_0));
- }
- Expr::Repeat(_binding_0) => {
- full!(v.visit_expr_repeat(_binding_0));
- }
- Expr::Return(_binding_0) => {
- full!(v.visit_expr_return(_binding_0));
- }
- Expr::Struct(_binding_0) => {
- full!(v.visit_expr_struct(_binding_0));
- }
- Expr::Try(_binding_0) => {
- full!(v.visit_expr_try(_binding_0));
- }
- Expr::TryBlock(_binding_0) => {
- full!(v.visit_expr_try_block(_binding_0));
- }
- Expr::Tuple(_binding_0) => {
- full!(v.visit_expr_tuple(_binding_0));
- }
- Expr::Type(_binding_0) => {
- full!(v.visit_expr_type(_binding_0));
- }
- Expr::Unary(_binding_0) => {
- v.visit_expr_unary(_binding_0);
- }
- Expr::Unsafe(_binding_0) => {
- full!(v.visit_expr_unsafe(_binding_0));
- }
- Expr::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- Expr::While(_binding_0) => {
- full!(v.visit_expr_while(_binding_0));
- }
- Expr::Yield(_binding_0) => {
- full!(v.visit_expr_yield(_binding_0));
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_array<'ast, V>(v: &mut V, node: &'ast ExprArray)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.bracket_token.span);
- for el in Punctuated::pairs(&node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_expr(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_assign<'ast, V>(v: &mut V, node: &'ast ExprAssign)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.left);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_expr(&*node.right);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_assign_op<'ast, V>(v: &mut V, node: &'ast ExprAssignOp)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.left);
- v.visit_bin_op(&node.op);
- v.visit_expr(&*node.right);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_async<'ast, V>(v: &mut V, node: &'ast ExprAsync)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.async_token.span);
- if let Some(it) = &node.capture {
- tokens_helper(v, &it.span)
- };
- v.visit_block(&node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_await<'ast, V>(v: &mut V, node: &'ast ExprAwait)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.base);
- tokens_helper(v, &node.dot_token.spans);
- tokens_helper(v, &node.await_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_binary<'ast, V>(v: &mut V, node: &'ast ExprBinary)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.left);
- v.visit_bin_op(&node.op);
- v.visit_expr(&*node.right);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_block<'ast, V>(v: &mut V, node: &'ast ExprBlock)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.label {
- v.visit_label(it)
- };
- v.visit_block(&node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_box<'ast, V>(v: &mut V, node: &'ast ExprBox)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.box_token.span);
- v.visit_expr(&*node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_break<'ast, V>(v: &mut V, node: &'ast ExprBreak)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.break_token.span);
- if let Some(it) = &node.label {
- v.visit_lifetime(it)
- };
- if let Some(it) = &node.expr {
- v.visit_expr(&**it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_call<'ast, V>(v: &mut V, node: &'ast ExprCall)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.func);
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.args) {
- let (it, p) = el.into_tuple();
- v.visit_expr(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_cast<'ast, V>(v: &mut V, node: &'ast ExprCast)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.as_token.span);
- v.visit_type(&*node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_closure<'ast, V>(v: &mut V, node: &'ast ExprClosure)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.asyncness {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.movability {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.capture {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.or1_token.spans);
- for el in Punctuated::pairs(&node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_pat(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- tokens_helper(v, &node.or2_token.spans);
- v.visit_return_type(&node.output);
- v.visit_expr(&*node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_continue<'ast, V>(v: &mut V, node: &'ast ExprContinue)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.continue_token.span);
- if let Some(it) = &node.label {
- v.visit_lifetime(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_field<'ast, V>(v: &mut V, node: &'ast ExprField)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.base);
- tokens_helper(v, &node.dot_token.spans);
- v.visit_member(&node.member);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_for_loop<'ast, V>(v: &mut V, node: &'ast ExprForLoop)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.label {
- v.visit_label(it)
- };
- tokens_helper(v, &node.for_token.span);
- v.visit_pat(&node.pat);
- tokens_helper(v, &node.in_token.span);
- v.visit_expr(&*node.expr);
- v.visit_block(&node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_group<'ast, V>(v: &mut V, node: &'ast ExprGroup)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.group_token.span);
- v.visit_expr(&*node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_if<'ast, V>(v: &mut V, node: &'ast ExprIf)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.if_token.span);
- v.visit_expr(&*node.cond);
- v.visit_block(&node.then_branch);
- if let Some(it) = &node.else_branch {
- tokens_helper(v, &(it).0.span);
- v.visit_expr(&*(it).1);
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_index<'ast, V>(v: &mut V, node: &'ast ExprIndex)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.bracket_token.span);
- v.visit_expr(&*node.index);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_let<'ast, V>(v: &mut V, node: &'ast ExprLet)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.let_token.span);
- v.visit_pat(&node.pat);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_expr(&*node.expr);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_lit<'ast, V>(v: &mut V, node: &'ast ExprLit)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_lit(&node.lit);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_loop<'ast, V>(v: &mut V, node: &'ast ExprLoop)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.label {
- v.visit_label(it)
- };
- tokens_helper(v, &node.loop_token.span);
- v.visit_block(&node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_macro<'ast, V>(v: &mut V, node: &'ast ExprMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_macro(&node.mac);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_match<'ast, V>(v: &mut V, node: &'ast ExprMatch)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.match_token.span);
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.brace_token.span);
- for it in &node.arms {
- v.visit_arm(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_method_call<'ast, V>(v: &mut V, node: &'ast ExprMethodCall)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.receiver);
- tokens_helper(v, &node.dot_token.spans);
- v.visit_ident(&node.method);
- if let Some(it) = &node.turbofish {
- v.visit_method_turbofish(it)
- };
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.args) {
- let (it, p) = el.into_tuple();
- v.visit_expr(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_paren<'ast, V>(v: &mut V, node: &'ast ExprParen)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.paren_token.span);
- v.visit_expr(&*node.expr);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_path<'ast, V>(v: &mut V, node: &'ast ExprPath)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.qself {
- v.visit_qself(it)
- };
- v.visit_path(&node.path);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_range<'ast, V>(v: &mut V, node: &'ast ExprRange)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.from {
- v.visit_expr(&**it)
- };
- v.visit_range_limits(&node.limits);
- if let Some(it) = &node.to {
- v.visit_expr(&**it)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_reference<'ast, V>(v: &mut V, node: &'ast ExprReference)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.and_token.spans);
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_expr(&*node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_repeat<'ast, V>(v: &mut V, node: &'ast ExprRepeat)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.bracket_token.span);
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.semi_token.spans);
- v.visit_expr(&*node.len);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_return<'ast, V>(v: &mut V, node: &'ast ExprReturn)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.return_token.span);
- if let Some(it) = &node.expr {
- v.visit_expr(&**it)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_struct<'ast, V>(v: &mut V, node: &'ast ExprStruct)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_path(&node.path);
- tokens_helper(v, &node.brace_token.span);
- for el in Punctuated::pairs(&node.fields) {
- let (it, p) = el.into_tuple();
- v.visit_field_value(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.dot2_token {
- tokens_helper(v, &it.spans)
- };
- if let Some(it) = &node.rest {
- v.visit_expr(&**it)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_try<'ast, V>(v: &mut V, node: &'ast ExprTry)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.question_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_try_block<'ast, V>(v: &mut V, node: &'ast ExprTryBlock)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.try_token.span);
- v.visit_block(&node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_tuple<'ast, V>(v: &mut V, node: &'ast ExprTuple)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_expr(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_type<'ast, V>(v: &mut V, node: &'ast ExprType)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&*node.ty);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_unary<'ast, V>(v: &mut V, node: &'ast ExprUnary)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_un_op(&node.op);
- v.visit_expr(&*node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_unsafe<'ast, V>(v: &mut V, node: &'ast ExprUnsafe)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.unsafe_token.span);
- v.visit_block(&node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_while<'ast, V>(v: &mut V, node: &'ast ExprWhile)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.label {
- v.visit_label(it)
- };
- tokens_helper(v, &node.while_token.span);
- v.visit_expr(&*node.cond);
- v.visit_block(&node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_yield<'ast, V>(v: &mut V, node: &'ast ExprYield)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.yield_token.span);
- if let Some(it) = &node.expr {
- v.visit_expr(&**it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_field<'ast, V>(v: &mut V, node: &'ast Field)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- if let Some(it) = &node.ident {
- v.visit_ident(it)
- };
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- v.visit_type(&node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_field_pat<'ast, V>(v: &mut V, node: &'ast FieldPat)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_member(&node.member);
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- v.visit_pat(&*node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_field_value<'ast, V>(v: &mut V, node: &'ast FieldValue)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_member(&node.member);
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- v.visit_expr(&node.expr);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_fields<'ast, V>(v: &mut V, node: &'ast Fields)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Fields::Named(_binding_0) => {
- v.visit_fields_named(_binding_0);
- }
- Fields::Unnamed(_binding_0) => {
- v.visit_fields_unnamed(_binding_0);
- }
- Fields::Unit => {}
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_fields_named<'ast, V>(v: &mut V, node: &'ast FieldsNamed)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.brace_token.span);
- for el in Punctuated::pairs(&node.named) {
- let (it, p) = el.into_tuple();
- v.visit_field(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_fields_unnamed<'ast, V>(v: &mut V, node: &'ast FieldsUnnamed)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.unnamed) {
- let (it, p) = el.into_tuple();
- v.visit_field(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_file<'ast, V>(v: &mut V, node: &'ast File)
-where
- V: Visit<'ast> + ?Sized,
-{
- skip!(node.shebang);
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- for it in &node.items {
- v.visit_item(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_fn_arg<'ast, V>(v: &mut V, node: &'ast FnArg)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- FnArg::Receiver(_binding_0) => {
- v.visit_receiver(_binding_0);
- }
- FnArg::Typed(_binding_0) => {
- v.visit_pat_type(_binding_0);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item<'ast, V>(v: &mut V, node: &'ast ForeignItem)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- ForeignItem::Fn(_binding_0) => {
- v.visit_foreign_item_fn(_binding_0);
- }
- ForeignItem::Static(_binding_0) => {
- v.visit_foreign_item_static(_binding_0);
- }
- ForeignItem::Type(_binding_0) => {
- v.visit_foreign_item_type(_binding_0);
- }
- ForeignItem::Macro(_binding_0) => {
- v.visit_foreign_item_macro(_binding_0);
- }
- ForeignItem::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_fn<'ast, V>(v: &mut V, node: &'ast ForeignItemFn)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- v.visit_signature(&node.sig);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_macro<'ast, V>(v: &mut V, node: &'ast ForeignItemMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_macro(&node.mac);
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_static<'ast, V>(v: &mut V, node: &'ast ForeignItemStatic)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.static_token.span);
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&*node.ty);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_type<'ast, V>(v: &mut V, node: &'ast ForeignItemType)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.type_token.span);
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_generic_argument<'ast, V>(v: &mut V, node: &'ast GenericArgument)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- GenericArgument::Lifetime(_binding_0) => {
- v.visit_lifetime(_binding_0);
- }
- GenericArgument::Type(_binding_0) => {
- v.visit_type(_binding_0);
- }
- GenericArgument::Binding(_binding_0) => {
- v.visit_binding(_binding_0);
- }
- GenericArgument::Constraint(_binding_0) => {
- v.visit_constraint(_binding_0);
- }
- GenericArgument::Const(_binding_0) => {
- v.visit_expr(_binding_0);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_generic_method_argument<'ast, V>(v: &mut V, node: &'ast GenericMethodArgument)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- GenericMethodArgument::Type(_binding_0) => {
- v.visit_type(_binding_0);
- }
- GenericMethodArgument::Const(_binding_0) => {
- v.visit_expr(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_generic_param<'ast, V>(v: &mut V, node: &'ast GenericParam)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- GenericParam::Type(_binding_0) => {
- v.visit_type_param(_binding_0);
- }
- GenericParam::Lifetime(_binding_0) => {
- v.visit_lifetime_def(_binding_0);
- }
- GenericParam::Const(_binding_0) => {
- v.visit_const_param(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_generics<'ast, V>(v: &mut V, node: &'ast Generics)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.lt_token {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.params) {
- let (it, p) = el.into_tuple();
- v.visit_generic_param(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.gt_token {
- tokens_helper(v, &it.spans)
- };
- if let Some(it) = &node.where_clause {
- v.visit_where_clause(it)
- };
-}
-pub fn visit_ident<'ast, V>(v: &mut V, node: &'ast Ident)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_span(&node.span());
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item<'ast, V>(v: &mut V, node: &'ast ImplItem)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- ImplItem::Const(_binding_0) => {
- v.visit_impl_item_const(_binding_0);
- }
- ImplItem::Method(_binding_0) => {
- v.visit_impl_item_method(_binding_0);
- }
- ImplItem::Type(_binding_0) => {
- v.visit_impl_item_type(_binding_0);
- }
- ImplItem::Macro(_binding_0) => {
- v.visit_impl_item_macro(_binding_0);
- }
- ImplItem::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_const<'ast, V>(v: &mut V, node: &'ast ImplItemConst)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- if let Some(it) = &node.defaultness {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.const_token.span);
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&node.ty);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_expr(&node.expr);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_macro<'ast, V>(v: &mut V, node: &'ast ImplItemMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_macro(&node.mac);
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_method<'ast, V>(v: &mut V, node: &'ast ImplItemMethod)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- if let Some(it) = &node.defaultness {
- tokens_helper(v, &it.span)
- };
- v.visit_signature(&node.sig);
- v.visit_block(&node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_type<'ast, V>(v: &mut V, node: &'ast ImplItemType)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- if let Some(it) = &node.defaultness {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.type_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_type(&node.ty);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_index<'ast, V>(v: &mut V, node: &'ast Index)
-where
- V: Visit<'ast> + ?Sized,
-{
- skip!(node.index);
- v.visit_span(&node.span);
-}
-#[cfg(feature = "full")]
-pub fn visit_item<'ast, V>(v: &mut V, node: &'ast Item)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Item::Const(_binding_0) => {
- v.visit_item_const(_binding_0);
- }
- Item::Enum(_binding_0) => {
- v.visit_item_enum(_binding_0);
- }
- Item::ExternCrate(_binding_0) => {
- v.visit_item_extern_crate(_binding_0);
- }
- Item::Fn(_binding_0) => {
- v.visit_item_fn(_binding_0);
- }
- Item::ForeignMod(_binding_0) => {
- v.visit_item_foreign_mod(_binding_0);
- }
- Item::Impl(_binding_0) => {
- v.visit_item_impl(_binding_0);
- }
- Item::Macro(_binding_0) => {
- v.visit_item_macro(_binding_0);
- }
- Item::Macro2(_binding_0) => {
- v.visit_item_macro2(_binding_0);
- }
- Item::Mod(_binding_0) => {
- v.visit_item_mod(_binding_0);
- }
- Item::Static(_binding_0) => {
- v.visit_item_static(_binding_0);
- }
- Item::Struct(_binding_0) => {
- v.visit_item_struct(_binding_0);
- }
- Item::Trait(_binding_0) => {
- v.visit_item_trait(_binding_0);
- }
- Item::TraitAlias(_binding_0) => {
- v.visit_item_trait_alias(_binding_0);
- }
- Item::Type(_binding_0) => {
- v.visit_item_type(_binding_0);
- }
- Item::Union(_binding_0) => {
- v.visit_item_union(_binding_0);
- }
- Item::Use(_binding_0) => {
- v.visit_item_use(_binding_0);
- }
- Item::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_const<'ast, V>(v: &mut V, node: &'ast ItemConst)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.const_token.span);
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&*node.ty);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_enum<'ast, V>(v: &mut V, node: &'ast ItemEnum)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.enum_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- tokens_helper(v, &node.brace_token.span);
- for el in Punctuated::pairs(&node.variants) {
- let (it, p) = el.into_tuple();
- v.visit_variant(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_extern_crate<'ast, V>(v: &mut V, node: &'ast ItemExternCrate)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.extern_token.span);
- tokens_helper(v, &node.crate_token.span);
- v.visit_ident(&node.ident);
- if let Some(it) = &node.rename {
- tokens_helper(v, &(it).0.span);
- v.visit_ident(&(it).1);
- };
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_fn<'ast, V>(v: &mut V, node: &'ast ItemFn)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- v.visit_signature(&node.sig);
- v.visit_block(&*node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_foreign_mod<'ast, V>(v: &mut V, node: &'ast ItemForeignMod)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_abi(&node.abi);
- tokens_helper(v, &node.brace_token.span);
- for it in &node.items {
- v.visit_foreign_item(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_impl<'ast, V>(v: &mut V, node: &'ast ItemImpl)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.defaultness {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.unsafety {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.impl_token.span);
- v.visit_generics(&node.generics);
- if let Some(it) = &node.trait_ {
- if let Some(it) = &(it).0 {
- tokens_helper(v, &it.spans)
- };
- v.visit_path(&(it).1);
- tokens_helper(v, &(it).2.span);
- };
- v.visit_type(&*node.self_ty);
- tokens_helper(v, &node.brace_token.span);
- for it in &node.items {
- v.visit_impl_item(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_macro<'ast, V>(v: &mut V, node: &'ast ItemMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.ident {
- v.visit_ident(it)
- };
- v.visit_macro(&node.mac);
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_item_macro2<'ast, V>(v: &mut V, node: &'ast ItemMacro2)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.macro_token.span);
- v.visit_ident(&node.ident);
- skip!(node.rules);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_mod<'ast, V>(v: &mut V, node: &'ast ItemMod)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.mod_token.span);
- v.visit_ident(&node.ident);
- if let Some(it) = &node.content {
- tokens_helper(v, &(it).0.span);
- for it in &(it).1 {
- v.visit_item(it)
- }
- };
- if let Some(it) = &node.semi {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_item_static<'ast, V>(v: &mut V, node: &'ast ItemStatic)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.static_token.span);
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&*node.ty);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_expr(&*node.expr);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_struct<'ast, V>(v: &mut V, node: &'ast ItemStruct)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.struct_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- v.visit_fields(&node.fields);
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_item_trait<'ast, V>(v: &mut V, node: &'ast ItemTrait)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- if let Some(it) = &node.unsafety {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.auto_token {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.trait_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.supertraits) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- tokens_helper(v, &node.brace_token.span);
- for it in &node.items {
- v.visit_trait_item(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_trait_alias<'ast, V>(v: &mut V, node: &'ast ItemTraitAlias)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.trait_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- tokens_helper(v, &node.eq_token.spans);
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_type<'ast, V>(v: &mut V, node: &'ast ItemType)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.type_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_type(&*node.ty);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_union<'ast, V>(v: &mut V, node: &'ast ItemUnion)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.union_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- v.visit_fields_named(&node.fields);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_use<'ast, V>(v: &mut V, node: &'ast ItemUse)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_visibility(&node.vis);
- tokens_helper(v, &node.use_token.span);
- if let Some(it) = &node.leading_colon {
- tokens_helper(v, &it.spans)
- };
- v.visit_use_tree(&node.tree);
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_label<'ast, V>(v: &mut V, node: &'ast Label)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_lifetime(&node.name);
- tokens_helper(v, &node.colon_token.spans);
-}
-pub fn visit_lifetime<'ast, V>(v: &mut V, node: &'ast Lifetime)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_span(&node.apostrophe);
- v.visit_ident(&node.ident);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lifetime_def<'ast, V>(v: &mut V, node: &'ast LifetimeDef)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_lifetime(&node.lifetime);
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_lifetime(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit<'ast, V>(v: &mut V, node: &'ast Lit)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Lit::Str(_binding_0) => {
- v.visit_lit_str(_binding_0);
- }
- Lit::ByteStr(_binding_0) => {
- v.visit_lit_byte_str(_binding_0);
- }
- Lit::Byte(_binding_0) => {
- v.visit_lit_byte(_binding_0);
- }
- Lit::Char(_binding_0) => {
- v.visit_lit_char(_binding_0);
- }
- Lit::Int(_binding_0) => {
- v.visit_lit_int(_binding_0);
- }
- Lit::Float(_binding_0) => {
- v.visit_lit_float(_binding_0);
- }
- Lit::Bool(_binding_0) => {
- v.visit_lit_bool(_binding_0);
- }
- Lit::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_bool<'ast, V>(v: &mut V, node: &'ast LitBool)
-where
- V: Visit<'ast> + ?Sized,
-{
- skip!(node.value);
- v.visit_span(&node.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_byte<'ast, V>(v: &mut V, node: &'ast LitByte)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_byte_str<'ast, V>(v: &mut V, node: &'ast LitByteStr)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_char<'ast, V>(v: &mut V, node: &'ast LitChar)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_float<'ast, V>(v: &mut V, node: &'ast LitFloat)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_int<'ast, V>(v: &mut V, node: &'ast LitInt)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_str<'ast, V>(v: &mut V, node: &'ast LitStr)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(feature = "full")]
-pub fn visit_local<'ast, V>(v: &mut V, node: &'ast Local)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.let_token.span);
- v.visit_pat(&node.pat);
- if let Some(it) = &node.init {
- tokens_helper(v, &(it).0.spans);
- v.visit_expr(&*(it).1);
- };
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_macro<'ast, V>(v: &mut V, node: &'ast Macro)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_path(&node.path);
- tokens_helper(v, &node.bang_token.spans);
- v.visit_macro_delimiter(&node.delimiter);
- skip!(node.tokens);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_macro_delimiter<'ast, V>(v: &mut V, node: &'ast MacroDelimiter)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- MacroDelimiter::Paren(_binding_0) => {
- tokens_helper(v, &_binding_0.span);
- }
- MacroDelimiter::Brace(_binding_0) => {
- tokens_helper(v, &_binding_0.span);
- }
- MacroDelimiter::Bracket(_binding_0) => {
- tokens_helper(v, &_binding_0.span);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_member<'ast, V>(v: &mut V, node: &'ast Member)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Member::Named(_binding_0) => {
- v.visit_ident(_binding_0);
- }
- Member::Unnamed(_binding_0) => {
- v.visit_index(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_meta<'ast, V>(v: &mut V, node: &'ast Meta)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Meta::Path(_binding_0) => {
- v.visit_path(_binding_0);
- }
- Meta::List(_binding_0) => {
- v.visit_meta_list(_binding_0);
- }
- Meta::NameValue(_binding_0) => {
- v.visit_meta_name_value(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_meta_list<'ast, V>(v: &mut V, node: &'ast MetaList)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_path(&node.path);
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.nested) {
- let (it, p) = el.into_tuple();
- v.visit_nested_meta(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_meta_name_value<'ast, V>(v: &mut V, node: &'ast MetaNameValue)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_path(&node.path);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_lit(&node.lit);
-}
-#[cfg(feature = "full")]
-pub fn visit_method_turbofish<'ast, V>(v: &mut V, node: &'ast MethodTurbofish)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.colon2_token.spans);
- tokens_helper(v, &node.lt_token.spans);
- for el in Punctuated::pairs(&node.args) {
- let (it, p) = el.into_tuple();
- v.visit_generic_method_argument(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- tokens_helper(v, &node.gt_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_nested_meta<'ast, V>(v: &mut V, node: &'ast NestedMeta)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- NestedMeta::Meta(_binding_0) => {
- v.visit_meta(_binding_0);
- }
- NestedMeta::Lit(_binding_0) => {
- v.visit_lit(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_parenthesized_generic_arguments<'ast, V>(
- v: &mut V,
- node: &'ast ParenthesizedGenericArguments,
-) where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_type(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- v.visit_return_type(&node.output);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat<'ast, V>(v: &mut V, node: &'ast Pat)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Pat::Box(_binding_0) => {
- v.visit_pat_box(_binding_0);
- }
- Pat::Ident(_binding_0) => {
- v.visit_pat_ident(_binding_0);
- }
- Pat::Lit(_binding_0) => {
- v.visit_pat_lit(_binding_0);
- }
- Pat::Macro(_binding_0) => {
- v.visit_pat_macro(_binding_0);
- }
- Pat::Or(_binding_0) => {
- v.visit_pat_or(_binding_0);
- }
- Pat::Path(_binding_0) => {
- v.visit_pat_path(_binding_0);
- }
- Pat::Range(_binding_0) => {
- v.visit_pat_range(_binding_0);
- }
- Pat::Reference(_binding_0) => {
- v.visit_pat_reference(_binding_0);
- }
- Pat::Rest(_binding_0) => {
- v.visit_pat_rest(_binding_0);
- }
- Pat::Slice(_binding_0) => {
- v.visit_pat_slice(_binding_0);
- }
- Pat::Struct(_binding_0) => {
- v.visit_pat_struct(_binding_0);
- }
- Pat::Tuple(_binding_0) => {
- v.visit_pat_tuple(_binding_0);
- }
- Pat::TupleStruct(_binding_0) => {
- v.visit_pat_tuple_struct(_binding_0);
- }
- Pat::Type(_binding_0) => {
- v.visit_pat_type(_binding_0);
- }
- Pat::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- Pat::Wild(_binding_0) => {
- v.visit_pat_wild(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_box<'ast, V>(v: &mut V, node: &'ast PatBox)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.box_token.span);
- v.visit_pat(&*node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_ident<'ast, V>(v: &mut V, node: &'ast PatIdent)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.by_ref {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_ident(&node.ident);
- if let Some(it) = &node.subpat {
- tokens_helper(v, &(it).0.spans);
- v.visit_pat(&*(it).1);
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_lit<'ast, V>(v: &mut V, node: &'ast PatLit)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_macro<'ast, V>(v: &mut V, node: &'ast PatMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_macro(&node.mac);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_or<'ast, V>(v: &mut V, node: &'ast PatOr)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.leading_vert {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.cases) {
- let (it, p) = el.into_tuple();
- v.visit_pat(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_path<'ast, V>(v: &mut V, node: &'ast PatPath)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.qself {
- v.visit_qself(it)
- };
- v.visit_path(&node.path);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_range<'ast, V>(v: &mut V, node: &'ast PatRange)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_expr(&*node.lo);
- v.visit_range_limits(&node.limits);
- v.visit_expr(&*node.hi);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_reference<'ast, V>(v: &mut V, node: &'ast PatReference)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.and_token.spans);
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_pat(&*node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_rest<'ast, V>(v: &mut V, node: &'ast PatRest)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.dot2_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_slice<'ast, V>(v: &mut V, node: &'ast PatSlice)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.bracket_token.span);
- for el in Punctuated::pairs(&node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_pat(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_struct<'ast, V>(v: &mut V, node: &'ast PatStruct)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_path(&node.path);
- tokens_helper(v, &node.brace_token.span);
- for el in Punctuated::pairs(&node.fields) {
- let (it, p) = el.into_tuple();
- v.visit_field_pat(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.dot2_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_tuple<'ast, V>(v: &mut V, node: &'ast PatTuple)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_pat(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_tuple_struct<'ast, V>(v: &mut V, node: &'ast PatTupleStruct)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_path(&node.path);
- v.visit_pat_tuple(&node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_type<'ast, V>(v: &mut V, node: &'ast PatType)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_pat(&*node.pat);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&*node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_wild<'ast, V>(v: &mut V, node: &'ast PatWild)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.underscore_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_path<'ast, V>(v: &mut V, node: &'ast Path)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.leading_colon {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.segments) {
- let (it, p) = el.into_tuple();
- v.visit_path_segment(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_path_arguments<'ast, V>(v: &mut V, node: &'ast PathArguments)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- PathArguments::None => {}
- PathArguments::AngleBracketed(_binding_0) => {
- v.visit_angle_bracketed_generic_arguments(_binding_0);
- }
- PathArguments::Parenthesized(_binding_0) => {
- v.visit_parenthesized_generic_arguments(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_path_segment<'ast, V>(v: &mut V, node: &'ast PathSegment)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_ident(&node.ident);
- v.visit_path_arguments(&node.arguments);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_predicate_eq<'ast, V>(v: &mut V, node: &'ast PredicateEq)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_type(&node.lhs_ty);
- tokens_helper(v, &node.eq_token.spans);
- v.visit_type(&node.rhs_ty);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_predicate_lifetime<'ast, V>(v: &mut V, node: &'ast PredicateLifetime)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_lifetime(&node.lifetime);
- tokens_helper(v, &node.colon_token.spans);
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_lifetime(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_predicate_type<'ast, V>(v: &mut V, node: &'ast PredicateType)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.lifetimes {
- v.visit_bound_lifetimes(it)
- };
- v.visit_type(&node.bounded_ty);
- tokens_helper(v, &node.colon_token.spans);
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_qself<'ast, V>(v: &mut V, node: &'ast QSelf)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.lt_token.spans);
- v.visit_type(&*node.ty);
- skip!(node.position);
- if let Some(it) = &node.as_token {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.gt_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_range_limits<'ast, V>(v: &mut V, node: &'ast RangeLimits)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- RangeLimits::HalfOpen(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- RangeLimits::Closed(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_receiver<'ast, V>(v: &mut V, node: &'ast Receiver)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- if let Some(it) = &node.reference {
- tokens_helper(v, &(it).0.spans);
- if let Some(it) = &(it).1 {
- v.visit_lifetime(it)
- };
- };
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- tokens_helper(v, &node.self_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_return_type<'ast, V>(v: &mut V, node: &'ast ReturnType)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- ReturnType::Default => {}
- ReturnType::Type(_binding_0, _binding_1) => {
- tokens_helper(v, &_binding_0.spans);
- v.visit_type(&**_binding_1);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_signature<'ast, V>(v: &mut V, node: &'ast Signature)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.constness {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.asyncness {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.unsafety {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.abi {
- v.visit_abi(it)
- };
- tokens_helper(v, &node.fn_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_fn_arg(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.variadic {
- v.visit_variadic(it)
- };
- v.visit_return_type(&node.output);
-}
-pub fn visit_span<'ast, V>(v: &mut V, node: &Span)
-where
- V: Visit<'ast> + ?Sized,
-{
-}
-#[cfg(feature = "full")]
-pub fn visit_stmt<'ast, V>(v: &mut V, node: &'ast Stmt)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Stmt::Local(_binding_0) => {
- v.visit_local(_binding_0);
- }
- Stmt::Item(_binding_0) => {
- v.visit_item(_binding_0);
- }
- Stmt::Expr(_binding_0) => {
- v.visit_expr(_binding_0);
- }
- Stmt::Semi(_binding_0, _binding_1) => {
- v.visit_expr(_binding_0);
- tokens_helper(v, &_binding_1.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_trait_bound<'ast, V>(v: &mut V, node: &'ast TraitBound)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.paren_token {
- tokens_helper(v, &it.span)
- };
- v.visit_trait_bound_modifier(&node.modifier);
- if let Some(it) = &node.lifetimes {
- v.visit_bound_lifetimes(it)
- };
- v.visit_path(&node.path);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_trait_bound_modifier<'ast, V>(v: &mut V, node: &'ast TraitBoundModifier)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- TraitBoundModifier::None => {}
- TraitBoundModifier::Maybe(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item<'ast, V>(v: &mut V, node: &'ast TraitItem)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- TraitItem::Const(_binding_0) => {
- v.visit_trait_item_const(_binding_0);
- }
- TraitItem::Method(_binding_0) => {
- v.visit_trait_item_method(_binding_0);
- }
- TraitItem::Type(_binding_0) => {
- v.visit_trait_item_type(_binding_0);
- }
- TraitItem::Macro(_binding_0) => {
- v.visit_trait_item_macro(_binding_0);
- }
- TraitItem::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_const<'ast, V>(v: &mut V, node: &'ast TraitItemConst)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.const_token.span);
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon_token.spans);
- v.visit_type(&node.ty);
- if let Some(it) = &node.default {
- tokens_helper(v, &(it).0.spans);
- v.visit_expr(&(it).1);
- };
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_macro<'ast, V>(v: &mut V, node: &'ast TraitItemMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_macro(&node.mac);
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_method<'ast, V>(v: &mut V, node: &'ast TraitItemMethod)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_signature(&node.sig);
- if let Some(it) = &node.default {
- v.visit_block(it)
- };
- if let Some(it) = &node.semi_token {
- tokens_helper(v, &it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_type<'ast, V>(v: &mut V, node: &'ast TraitItemType)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.type_token.span);
- v.visit_ident(&node.ident);
- v.visit_generics(&node.generics);
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.default {
- tokens_helper(v, &(it).0.spans);
- v.visit_type(&(it).1);
- };
- tokens_helper(v, &node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type<'ast, V>(v: &mut V, node: &'ast Type)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Type::Array(_binding_0) => {
- v.visit_type_array(_binding_0);
- }
- Type::BareFn(_binding_0) => {
- v.visit_type_bare_fn(_binding_0);
- }
- Type::Group(_binding_0) => {
- v.visit_type_group(_binding_0);
- }
- Type::ImplTrait(_binding_0) => {
- v.visit_type_impl_trait(_binding_0);
- }
- Type::Infer(_binding_0) => {
- v.visit_type_infer(_binding_0);
- }
- Type::Macro(_binding_0) => {
- v.visit_type_macro(_binding_0);
- }
- Type::Never(_binding_0) => {
- v.visit_type_never(_binding_0);
- }
- Type::Paren(_binding_0) => {
- v.visit_type_paren(_binding_0);
- }
- Type::Path(_binding_0) => {
- v.visit_type_path(_binding_0);
- }
- Type::Ptr(_binding_0) => {
- v.visit_type_ptr(_binding_0);
- }
- Type::Reference(_binding_0) => {
- v.visit_type_reference(_binding_0);
- }
- Type::Slice(_binding_0) => {
- v.visit_type_slice(_binding_0);
- }
- Type::TraitObject(_binding_0) => {
- v.visit_type_trait_object(_binding_0);
- }
- Type::Tuple(_binding_0) => {
- v.visit_type_tuple(_binding_0);
- }
- Type::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_array<'ast, V>(v: &mut V, node: &'ast TypeArray)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.bracket_token.span);
- v.visit_type(&*node.elem);
- tokens_helper(v, &node.semi_token.spans);
- v.visit_expr(&node.len);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_bare_fn<'ast, V>(v: &mut V, node: &'ast TypeBareFn)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.lifetimes {
- v.visit_bound_lifetimes(it)
- };
- if let Some(it) = &node.unsafety {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.abi {
- v.visit_abi(it)
- };
- tokens_helper(v, &node.fn_token.span);
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_bare_fn_arg(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.variadic {
- v.visit_variadic(it)
- };
- v.visit_return_type(&node.output);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_group<'ast, V>(v: &mut V, node: &'ast TypeGroup)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.group_token.span);
- v.visit_type(&*node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_impl_trait<'ast, V>(v: &mut V, node: &'ast TypeImplTrait)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.impl_token.span);
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_infer<'ast, V>(v: &mut V, node: &'ast TypeInfer)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.underscore_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_macro<'ast, V>(v: &mut V, node: &'ast TypeMacro)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_macro(&node.mac);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_never<'ast, V>(v: &mut V, node: &'ast TypeNever)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.bang_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_param<'ast, V>(v: &mut V, node: &'ast TypeParam)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_ident(&node.ident);
- if let Some(it) = &node.colon_token {
- tokens_helper(v, &it.spans)
- };
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
- if let Some(it) = &node.eq_token {
- tokens_helper(v, &it.spans)
- };
- if let Some(it) = &node.default {
- v.visit_type(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_param_bound<'ast, V>(v: &mut V, node: &'ast TypeParamBound)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- TypeParamBound::Trait(_binding_0) => {
- v.visit_trait_bound(_binding_0);
- }
- TypeParamBound::Lifetime(_binding_0) => {
- v.visit_lifetime(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_paren<'ast, V>(v: &mut V, node: &'ast TypeParen)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.paren_token.span);
- v.visit_type(&*node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_path<'ast, V>(v: &mut V, node: &'ast TypePath)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.qself {
- v.visit_qself(it)
- };
- v.visit_path(&node.path);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_ptr<'ast, V>(v: &mut V, node: &'ast TypePtr)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.star_token.spans);
- if let Some(it) = &node.const_token {
- tokens_helper(v, &it.span)
- };
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_type(&*node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_reference<'ast, V>(v: &mut V, node: &'ast TypeReference)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.and_token.spans);
- if let Some(it) = &node.lifetime {
- v.visit_lifetime(it)
- };
- if let Some(it) = &node.mutability {
- tokens_helper(v, &it.span)
- };
- v.visit_type(&*node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_slice<'ast, V>(v: &mut V, node: &'ast TypeSlice)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.bracket_token.span);
- v.visit_type(&*node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_trait_object<'ast, V>(v: &mut V, node: &'ast TypeTraitObject)
-where
- V: Visit<'ast> + ?Sized,
-{
- if let Some(it) = &node.dyn_token {
- tokens_helper(v, &it.span)
- };
- for el in Punctuated::pairs(&node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_tuple<'ast, V>(v: &mut V, node: &'ast TypeTuple)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.paren_token.span);
- for el in Punctuated::pairs(&node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_type(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_un_op<'ast, V>(v: &mut V, node: &'ast UnOp)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- UnOp::Deref(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- UnOp::Not(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- UnOp::Neg(_binding_0) => {
- tokens_helper(v, &_binding_0.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_use_glob<'ast, V>(v: &mut V, node: &'ast UseGlob)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.star_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_group<'ast, V>(v: &mut V, node: &'ast UseGroup)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.brace_token.span);
- for el in Punctuated::pairs(&node.items) {
- let (it, p) = el.into_tuple();
- v.visit_use_tree(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_use_name<'ast, V>(v: &mut V, node: &'ast UseName)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_ident(&node.ident);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_path<'ast, V>(v: &mut V, node: &'ast UsePath)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.colon2_token.spans);
- v.visit_use_tree(&*node.tree);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_rename<'ast, V>(v: &mut V, node: &'ast UseRename)
-where
- V: Visit<'ast> + ?Sized,
-{
- v.visit_ident(&node.ident);
- tokens_helper(v, &node.as_token.span);
- v.visit_ident(&node.rename);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_tree<'ast, V>(v: &mut V, node: &'ast UseTree)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- UseTree::Path(_binding_0) => {
- v.visit_use_path(_binding_0);
- }
- UseTree::Name(_binding_0) => {
- v.visit_use_name(_binding_0);
- }
- UseTree::Rename(_binding_0) => {
- v.visit_use_rename(_binding_0);
- }
- UseTree::Glob(_binding_0) => {
- v.visit_use_glob(_binding_0);
- }
- UseTree::Group(_binding_0) => {
- v.visit_use_group(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_variadic<'ast, V>(v: &mut V, node: &'ast Variadic)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- tokens_helper(v, &node.dots.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_variant<'ast, V>(v: &mut V, node: &'ast Variant)
-where
- V: Visit<'ast> + ?Sized,
-{
- for it in &node.attrs {
- v.visit_attribute(it)
- }
- v.visit_ident(&node.ident);
- v.visit_fields(&node.fields);
- if let Some(it) = &node.discriminant {
- tokens_helper(v, &(it).0.spans);
- v.visit_expr(&(it).1);
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_vis_crate<'ast, V>(v: &mut V, node: &'ast VisCrate)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.crate_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_vis_public<'ast, V>(v: &mut V, node: &'ast VisPublic)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.pub_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_vis_restricted<'ast, V>(v: &mut V, node: &'ast VisRestricted)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.pub_token.span);
- tokens_helper(v, &node.paren_token.span);
- if let Some(it) = &node.in_token {
- tokens_helper(v, &it.span)
- };
- v.visit_path(&*node.path);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_visibility<'ast, V>(v: &mut V, node: &'ast Visibility)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- Visibility::Public(_binding_0) => {
- v.visit_vis_public(_binding_0);
- }
- Visibility::Crate(_binding_0) => {
- v.visit_vis_crate(_binding_0);
- }
- Visibility::Restricted(_binding_0) => {
- v.visit_vis_restricted(_binding_0);
- }
- Visibility::Inherited => {}
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_where_clause<'ast, V>(v: &mut V, node: &'ast WhereClause)
-where
- V: Visit<'ast> + ?Sized,
-{
- tokens_helper(v, &node.where_token.span);
- for el in Punctuated::pairs(&node.predicates) {
- let (it, p) = el.into_tuple();
- v.visit_where_predicate(it);
- if let Some(p) = p {
- tokens_helper(v, &p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_where_predicate<'ast, V>(v: &mut V, node: &'ast WherePredicate)
-where
- V: Visit<'ast> + ?Sized,
-{
- match node {
- WherePredicate::Type(_binding_0) => {
- v.visit_predicate_type(_binding_0);
- }
- WherePredicate::Lifetime(_binding_0) => {
- v.visit_predicate_lifetime(_binding_0);
- }
- WherePredicate::Eq(_binding_0) => {
- v.visit_predicate_eq(_binding_0);
- }
- }
-}
diff --git a/syn/src/gen/visit_mut.rs b/syn/src/gen/visit_mut.rs
deleted file mode 100644
index 5cddb82..0000000
--- a/syn/src/gen/visit_mut.rs
+++ /dev/null
@@ -1,3798 +0,0 @@
-// This file is @generated by syn-internal-codegen.
-// It is not intended for manual editing.
-
-#![allow(unused_variables)]
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::gen::helper::visit_mut::*;
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::punctuated::Punctuated;
-use crate::*;
-use proc_macro2::Span;
-#[cfg(feature = "full")]
-macro_rules! full {
- ($e:expr) => {
- $e
- };
-}
-#[cfg(all(feature = "derive", not(feature = "full")))]
-macro_rules! full {
- ($e:expr) => {
- unreachable!()
- };
-}
-#[cfg(any(feature = "full", feature = "derive"))]
-macro_rules! skip {
- ($($tt:tt)*) => {};
-}
-/// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in
-/// place.
-///
-/// See the [module documentation] for details.
-///
-/// [module documentation]: self
-///
-/// *This trait is available if Syn is built with the `"visit-mut"` feature.*
-pub trait VisitMut {
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_abi_mut(&mut self, i: &mut Abi) {
- visit_abi_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_angle_bracketed_generic_arguments_mut(
- &mut self,
- i: &mut AngleBracketedGenericArguments,
- ) {
- visit_angle_bracketed_generic_arguments_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_arm_mut(&mut self, i: &mut Arm) {
- visit_arm_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_attr_style_mut(&mut self, i: &mut AttrStyle) {
- visit_attr_style_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_attribute_mut(&mut self, i: &mut Attribute) {
- visit_attribute_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_bare_fn_arg_mut(&mut self, i: &mut BareFnArg) {
- visit_bare_fn_arg_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_bin_op_mut(&mut self, i: &mut BinOp) {
- visit_bin_op_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_binding_mut(&mut self, i: &mut Binding) {
- visit_binding_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_block_mut(&mut self, i: &mut Block) {
- visit_block_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_bound_lifetimes_mut(&mut self, i: &mut BoundLifetimes) {
- visit_bound_lifetimes_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_const_param_mut(&mut self, i: &mut ConstParam) {
- visit_const_param_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_constraint_mut(&mut self, i: &mut Constraint) {
- visit_constraint_mut(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_mut(&mut self, i: &mut Data) {
- visit_data_mut(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_enum_mut(&mut self, i: &mut DataEnum) {
- visit_data_enum_mut(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_struct_mut(&mut self, i: &mut DataStruct) {
- visit_data_struct_mut(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_data_union_mut(&mut self, i: &mut DataUnion) {
- visit_data_union_mut(self, i)
- }
- #[cfg(feature = "derive")]
- fn visit_derive_input_mut(&mut self, i: &mut DeriveInput) {
- visit_derive_input_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_mut(&mut self, i: &mut Expr) {
- visit_expr_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_array_mut(&mut self, i: &mut ExprArray) {
- visit_expr_array_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_assign_mut(&mut self, i: &mut ExprAssign) {
- visit_expr_assign_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_assign_op_mut(&mut self, i: &mut ExprAssignOp) {
- visit_expr_assign_op_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_async_mut(&mut self, i: &mut ExprAsync) {
- visit_expr_async_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_await_mut(&mut self, i: &mut ExprAwait) {
- visit_expr_await_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_binary_mut(&mut self, i: &mut ExprBinary) {
- visit_expr_binary_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_block_mut(&mut self, i: &mut ExprBlock) {
- visit_expr_block_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_box_mut(&mut self, i: &mut ExprBox) {
- visit_expr_box_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_break_mut(&mut self, i: &mut ExprBreak) {
- visit_expr_break_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_call_mut(&mut self, i: &mut ExprCall) {
- visit_expr_call_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_cast_mut(&mut self, i: &mut ExprCast) {
- visit_expr_cast_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_closure_mut(&mut self, i: &mut ExprClosure) {
- visit_expr_closure_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_continue_mut(&mut self, i: &mut ExprContinue) {
- visit_expr_continue_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_field_mut(&mut self, i: &mut ExprField) {
- visit_expr_field_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_for_loop_mut(&mut self, i: &mut ExprForLoop) {
- visit_expr_for_loop_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_group_mut(&mut self, i: &mut ExprGroup) {
- visit_expr_group_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_if_mut(&mut self, i: &mut ExprIf) {
- visit_expr_if_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_index_mut(&mut self, i: &mut ExprIndex) {
- visit_expr_index_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_let_mut(&mut self, i: &mut ExprLet) {
- visit_expr_let_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_lit_mut(&mut self, i: &mut ExprLit) {
- visit_expr_lit_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_loop_mut(&mut self, i: &mut ExprLoop) {
- visit_expr_loop_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_macro_mut(&mut self, i: &mut ExprMacro) {
- visit_expr_macro_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_match_mut(&mut self, i: &mut ExprMatch) {
- visit_expr_match_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_method_call_mut(&mut self, i: &mut ExprMethodCall) {
- visit_expr_method_call_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_paren_mut(&mut self, i: &mut ExprParen) {
- visit_expr_paren_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_path_mut(&mut self, i: &mut ExprPath) {
- visit_expr_path_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_range_mut(&mut self, i: &mut ExprRange) {
- visit_expr_range_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_reference_mut(&mut self, i: &mut ExprReference) {
- visit_expr_reference_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_repeat_mut(&mut self, i: &mut ExprRepeat) {
- visit_expr_repeat_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_return_mut(&mut self, i: &mut ExprReturn) {
- visit_expr_return_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_struct_mut(&mut self, i: &mut ExprStruct) {
- visit_expr_struct_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_try_mut(&mut self, i: &mut ExprTry) {
- visit_expr_try_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_try_block_mut(&mut self, i: &mut ExprTryBlock) {
- visit_expr_try_block_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_tuple_mut(&mut self, i: &mut ExprTuple) {
- visit_expr_tuple_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_type_mut(&mut self, i: &mut ExprType) {
- visit_expr_type_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_expr_unary_mut(&mut self, i: &mut ExprUnary) {
- visit_expr_unary_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_unsafe_mut(&mut self, i: &mut ExprUnsafe) {
- visit_expr_unsafe_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_while_mut(&mut self, i: &mut ExprWhile) {
- visit_expr_while_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_expr_yield_mut(&mut self, i: &mut ExprYield) {
- visit_expr_yield_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_field_mut(&mut self, i: &mut Field) {
- visit_field_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_field_pat_mut(&mut self, i: &mut FieldPat) {
- visit_field_pat_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_field_value_mut(&mut self, i: &mut FieldValue) {
- visit_field_value_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_fields_mut(&mut self, i: &mut Fields) {
- visit_fields_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_fields_named_mut(&mut self, i: &mut FieldsNamed) {
- visit_fields_named_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_fields_unnamed_mut(&mut self, i: &mut FieldsUnnamed) {
- visit_fields_unnamed_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_file_mut(&mut self, i: &mut File) {
- visit_file_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_fn_arg_mut(&mut self, i: &mut FnArg) {
- visit_fn_arg_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_mut(&mut self, i: &mut ForeignItem) {
- visit_foreign_item_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_fn_mut(&mut self, i: &mut ForeignItemFn) {
- visit_foreign_item_fn_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_macro_mut(&mut self, i: &mut ForeignItemMacro) {
- visit_foreign_item_macro_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_static_mut(&mut self, i: &mut ForeignItemStatic) {
- visit_foreign_item_static_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_foreign_item_type_mut(&mut self, i: &mut ForeignItemType) {
- visit_foreign_item_type_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_generic_argument_mut(&mut self, i: &mut GenericArgument) {
- visit_generic_argument_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_generic_method_argument_mut(&mut self, i: &mut GenericMethodArgument) {
- visit_generic_method_argument_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_generic_param_mut(&mut self, i: &mut GenericParam) {
- visit_generic_param_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_generics_mut(&mut self, i: &mut Generics) {
- visit_generics_mut(self, i)
- }
- fn visit_ident_mut(&mut self, i: &mut Ident) {
- visit_ident_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_mut(&mut self, i: &mut ImplItem) {
- visit_impl_item_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_const_mut(&mut self, i: &mut ImplItemConst) {
- visit_impl_item_const_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_macro_mut(&mut self, i: &mut ImplItemMacro) {
- visit_impl_item_macro_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_method_mut(&mut self, i: &mut ImplItemMethod) {
- visit_impl_item_method_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_impl_item_type_mut(&mut self, i: &mut ImplItemType) {
- visit_impl_item_type_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_index_mut(&mut self, i: &mut Index) {
- visit_index_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_mut(&mut self, i: &mut Item) {
- visit_item_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_const_mut(&mut self, i: &mut ItemConst) {
- visit_item_const_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_enum_mut(&mut self, i: &mut ItemEnum) {
- visit_item_enum_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_extern_crate_mut(&mut self, i: &mut ItemExternCrate) {
- visit_item_extern_crate_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_fn_mut(&mut self, i: &mut ItemFn) {
- visit_item_fn_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_foreign_mod_mut(&mut self, i: &mut ItemForeignMod) {
- visit_item_foreign_mod_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_impl_mut(&mut self, i: &mut ItemImpl) {
- visit_item_impl_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_macro_mut(&mut self, i: &mut ItemMacro) {
- visit_item_macro_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_macro2_mut(&mut self, i: &mut ItemMacro2) {
- visit_item_macro2_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_mod_mut(&mut self, i: &mut ItemMod) {
- visit_item_mod_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_static_mut(&mut self, i: &mut ItemStatic) {
- visit_item_static_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_struct_mut(&mut self, i: &mut ItemStruct) {
- visit_item_struct_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_trait_mut(&mut self, i: &mut ItemTrait) {
- visit_item_trait_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_trait_alias_mut(&mut self, i: &mut ItemTraitAlias) {
- visit_item_trait_alias_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_type_mut(&mut self, i: &mut ItemType) {
- visit_item_type_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_union_mut(&mut self, i: &mut ItemUnion) {
- visit_item_union_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_item_use_mut(&mut self, i: &mut ItemUse) {
- visit_item_use_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_label_mut(&mut self, i: &mut Label) {
- visit_label_mut(self, i)
- }
- fn visit_lifetime_mut(&mut self, i: &mut Lifetime) {
- visit_lifetime_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lifetime_def_mut(&mut self, i: &mut LifetimeDef) {
- visit_lifetime_def_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_mut(&mut self, i: &mut Lit) {
- visit_lit_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_bool_mut(&mut self, i: &mut LitBool) {
- visit_lit_bool_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_byte_mut(&mut self, i: &mut LitByte) {
- visit_lit_byte_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_byte_str_mut(&mut self, i: &mut LitByteStr) {
- visit_lit_byte_str_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_char_mut(&mut self, i: &mut LitChar) {
- visit_lit_char_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_float_mut(&mut self, i: &mut LitFloat) {
- visit_lit_float_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_int_mut(&mut self, i: &mut LitInt) {
- visit_lit_int_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_lit_str_mut(&mut self, i: &mut LitStr) {
- visit_lit_str_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_local_mut(&mut self, i: &mut Local) {
- visit_local_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_macro_mut(&mut self, i: &mut Macro) {
- visit_macro_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_macro_delimiter_mut(&mut self, i: &mut MacroDelimiter) {
- visit_macro_delimiter_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_member_mut(&mut self, i: &mut Member) {
- visit_member_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_meta_mut(&mut self, i: &mut Meta) {
- visit_meta_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_meta_list_mut(&mut self, i: &mut MetaList) {
- visit_meta_list_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_meta_name_value_mut(&mut self, i: &mut MetaNameValue) {
- visit_meta_name_value_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_method_turbofish_mut(&mut self, i: &mut MethodTurbofish) {
- visit_method_turbofish_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_nested_meta_mut(&mut self, i: &mut NestedMeta) {
- visit_nested_meta_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_parenthesized_generic_arguments_mut(&mut self, i: &mut ParenthesizedGenericArguments) {
- visit_parenthesized_generic_arguments_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_mut(&mut self, i: &mut Pat) {
- visit_pat_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_box_mut(&mut self, i: &mut PatBox) {
- visit_pat_box_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_ident_mut(&mut self, i: &mut PatIdent) {
- visit_pat_ident_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_lit_mut(&mut self, i: &mut PatLit) {
- visit_pat_lit_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_macro_mut(&mut self, i: &mut PatMacro) {
- visit_pat_macro_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_or_mut(&mut self, i: &mut PatOr) {
- visit_pat_or_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_path_mut(&mut self, i: &mut PatPath) {
- visit_pat_path_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_range_mut(&mut self, i: &mut PatRange) {
- visit_pat_range_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_reference_mut(&mut self, i: &mut PatReference) {
- visit_pat_reference_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_rest_mut(&mut self, i: &mut PatRest) {
- visit_pat_rest_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_slice_mut(&mut self, i: &mut PatSlice) {
- visit_pat_slice_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_struct_mut(&mut self, i: &mut PatStruct) {
- visit_pat_struct_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_tuple_mut(&mut self, i: &mut PatTuple) {
- visit_pat_tuple_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_tuple_struct_mut(&mut self, i: &mut PatTupleStruct) {
- visit_pat_tuple_struct_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_type_mut(&mut self, i: &mut PatType) {
- visit_pat_type_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_pat_wild_mut(&mut self, i: &mut PatWild) {
- visit_pat_wild_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_path_mut(&mut self, i: &mut Path) {
- visit_path_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_path_arguments_mut(&mut self, i: &mut PathArguments) {
- visit_path_arguments_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_path_segment_mut(&mut self, i: &mut PathSegment) {
- visit_path_segment_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_predicate_eq_mut(&mut self, i: &mut PredicateEq) {
- visit_predicate_eq_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_predicate_lifetime_mut(&mut self, i: &mut PredicateLifetime) {
- visit_predicate_lifetime_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_predicate_type_mut(&mut self, i: &mut PredicateType) {
- visit_predicate_type_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_qself_mut(&mut self, i: &mut QSelf) {
- visit_qself_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_range_limits_mut(&mut self, i: &mut RangeLimits) {
- visit_range_limits_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_receiver_mut(&mut self, i: &mut Receiver) {
- visit_receiver_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_return_type_mut(&mut self, i: &mut ReturnType) {
- visit_return_type_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_signature_mut(&mut self, i: &mut Signature) {
- visit_signature_mut(self, i)
- }
- fn visit_span_mut(&mut self, i: &mut Span) {
- visit_span_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_stmt_mut(&mut self, i: &mut Stmt) {
- visit_stmt_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_trait_bound_mut(&mut self, i: &mut TraitBound) {
- visit_trait_bound_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_trait_bound_modifier_mut(&mut self, i: &mut TraitBoundModifier) {
- visit_trait_bound_modifier_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_mut(&mut self, i: &mut TraitItem) {
- visit_trait_item_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_const_mut(&mut self, i: &mut TraitItemConst) {
- visit_trait_item_const_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_macro_mut(&mut self, i: &mut TraitItemMacro) {
- visit_trait_item_macro_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_method_mut(&mut self, i: &mut TraitItemMethod) {
- visit_trait_item_method_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_trait_item_type_mut(&mut self, i: &mut TraitItemType) {
- visit_trait_item_type_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_mut(&mut self, i: &mut Type) {
- visit_type_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_array_mut(&mut self, i: &mut TypeArray) {
- visit_type_array_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_bare_fn_mut(&mut self, i: &mut TypeBareFn) {
- visit_type_bare_fn_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_group_mut(&mut self, i: &mut TypeGroup) {
- visit_type_group_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_impl_trait_mut(&mut self, i: &mut TypeImplTrait) {
- visit_type_impl_trait_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_infer_mut(&mut self, i: &mut TypeInfer) {
- visit_type_infer_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_macro_mut(&mut self, i: &mut TypeMacro) {
- visit_type_macro_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_never_mut(&mut self, i: &mut TypeNever) {
- visit_type_never_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_param_mut(&mut self, i: &mut TypeParam) {
- visit_type_param_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_param_bound_mut(&mut self, i: &mut TypeParamBound) {
- visit_type_param_bound_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_paren_mut(&mut self, i: &mut TypeParen) {
- visit_type_paren_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_path_mut(&mut self, i: &mut TypePath) {
- visit_type_path_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_ptr_mut(&mut self, i: &mut TypePtr) {
- visit_type_ptr_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_reference_mut(&mut self, i: &mut TypeReference) {
- visit_type_reference_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_slice_mut(&mut self, i: &mut TypeSlice) {
- visit_type_slice_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_trait_object_mut(&mut self, i: &mut TypeTraitObject) {
- visit_type_trait_object_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_type_tuple_mut(&mut self, i: &mut TypeTuple) {
- visit_type_tuple_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_un_op_mut(&mut self, i: &mut UnOp) {
- visit_un_op_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_glob_mut(&mut self, i: &mut UseGlob) {
- visit_use_glob_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_group_mut(&mut self, i: &mut UseGroup) {
- visit_use_group_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_name_mut(&mut self, i: &mut UseName) {
- visit_use_name_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_path_mut(&mut self, i: &mut UsePath) {
- visit_use_path_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_rename_mut(&mut self, i: &mut UseRename) {
- visit_use_rename_mut(self, i)
- }
- #[cfg(feature = "full")]
- fn visit_use_tree_mut(&mut self, i: &mut UseTree) {
- visit_use_tree_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_variadic_mut(&mut self, i: &mut Variadic) {
- visit_variadic_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_variant_mut(&mut self, i: &mut Variant) {
- visit_variant_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_vis_crate_mut(&mut self, i: &mut VisCrate) {
- visit_vis_crate_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_vis_public_mut(&mut self, i: &mut VisPublic) {
- visit_vis_public_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_vis_restricted_mut(&mut self, i: &mut VisRestricted) {
- visit_vis_restricted_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_visibility_mut(&mut self, i: &mut Visibility) {
- visit_visibility_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_where_clause_mut(&mut self, i: &mut WhereClause) {
- visit_where_clause_mut(self, i)
- }
- #[cfg(any(feature = "derive", feature = "full"))]
- fn visit_where_predicate_mut(&mut self, i: &mut WherePredicate) {
- visit_where_predicate_mut(self, i)
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_abi_mut<V>(v: &mut V, node: &mut Abi)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.extern_token.span);
- if let Some(it) = &mut node.name {
- v.visit_lit_str_mut(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_angle_bracketed_generic_arguments_mut<V>(
- v: &mut V,
- node: &mut AngleBracketedGenericArguments,
-) where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.colon2_token {
- tokens_helper(v, &mut it.spans)
- };
- tokens_helper(v, &mut node.lt_token.spans);
- for el in Punctuated::pairs_mut(&mut node.args) {
- let (it, p) = el.into_tuple();
- v.visit_generic_argument_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- tokens_helper(v, &mut node.gt_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_arm_mut<V>(v: &mut V, node: &mut Arm)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_pat_mut(&mut node.pat);
- if let Some(it) = &mut node.guard {
- tokens_helper(v, &mut (it).0.span);
- v.visit_expr_mut(&mut *(it).1);
- };
- tokens_helper(v, &mut node.fat_arrow_token.spans);
- v.visit_expr_mut(&mut *node.body);
- if let Some(it) = &mut node.comma {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_attr_style_mut<V>(v: &mut V, node: &mut AttrStyle)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- AttrStyle::Outer => {}
- AttrStyle::Inner(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_attribute_mut<V>(v: &mut V, node: &mut Attribute)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.pound_token.spans);
- v.visit_attr_style_mut(&mut node.style);
- tokens_helper(v, &mut node.bracket_token.span);
- v.visit_path_mut(&mut node.path);
- skip!(node.tokens);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_bare_fn_arg_mut<V>(v: &mut V, node: &mut BareFnArg)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.name {
- v.visit_ident_mut(&mut (it).0);
- tokens_helper(v, &mut (it).1.spans);
- };
- v.visit_type_mut(&mut node.ty);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_bin_op_mut<V>(v: &mut V, node: &mut BinOp)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- BinOp::Add(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Sub(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Mul(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Div(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Rem(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::And(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Or(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::BitXor(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::BitAnd(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::BitOr(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Shl(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Shr(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Eq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Lt(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Le(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Ne(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Ge(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::Gt(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::AddEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::SubEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::MulEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::DivEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::RemEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::BitXorEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::BitAndEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::BitOrEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::ShlEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- BinOp::ShrEq(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_binding_mut<V>(v: &mut V, node: &mut Binding)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_type_mut(&mut node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_block_mut<V>(v: &mut V, node: &mut Block)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.brace_token.span);
- for it in &mut node.stmts {
- v.visit_stmt_mut(it)
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_bound_lifetimes_mut<V>(v: &mut V, node: &mut BoundLifetimes)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.for_token.span);
- tokens_helper(v, &mut node.lt_token.spans);
- for el in Punctuated::pairs_mut(&mut node.lifetimes) {
- let (it, p) = el.into_tuple();
- v.visit_lifetime_def_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- tokens_helper(v, &mut node.gt_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_const_param_mut<V>(v: &mut V, node: &mut ConstParam)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.const_token.span);
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut node.ty);
- if let Some(it) = &mut node.eq_token {
- tokens_helper(v, &mut it.spans)
- };
- if let Some(it) = &mut node.default {
- v.visit_expr_mut(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_constraint_mut<V>(v: &mut V, node: &mut Constraint)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_mut<V>(v: &mut V, node: &mut Data)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Data::Struct(_binding_0) => {
- v.visit_data_struct_mut(_binding_0);
- }
- Data::Enum(_binding_0) => {
- v.visit_data_enum_mut(_binding_0);
- }
- Data::Union(_binding_0) => {
- v.visit_data_union_mut(_binding_0);
- }
- }
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_enum_mut<V>(v: &mut V, node: &mut DataEnum)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.enum_token.span);
- tokens_helper(v, &mut node.brace_token.span);
- for el in Punctuated::pairs_mut(&mut node.variants) {
- let (it, p) = el.into_tuple();
- v.visit_variant_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_struct_mut<V>(v: &mut V, node: &mut DataStruct)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.struct_token.span);
- v.visit_fields_mut(&mut node.fields);
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "derive")]
-pub fn visit_data_union_mut<V>(v: &mut V, node: &mut DataUnion)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.union_token.span);
- v.visit_fields_named_mut(&mut node.fields);
-}
-#[cfg(feature = "derive")]
-pub fn visit_derive_input_mut<V>(v: &mut V, node: &mut DeriveInput)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- v.visit_data_mut(&mut node.data);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_mut<V>(v: &mut V, node: &mut Expr)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Expr::Array(_binding_0) => {
- full!(v.visit_expr_array_mut(_binding_0));
- }
- Expr::Assign(_binding_0) => {
- full!(v.visit_expr_assign_mut(_binding_0));
- }
- Expr::AssignOp(_binding_0) => {
- full!(v.visit_expr_assign_op_mut(_binding_0));
- }
- Expr::Async(_binding_0) => {
- full!(v.visit_expr_async_mut(_binding_0));
- }
- Expr::Await(_binding_0) => {
- full!(v.visit_expr_await_mut(_binding_0));
- }
- Expr::Binary(_binding_0) => {
- v.visit_expr_binary_mut(_binding_0);
- }
- Expr::Block(_binding_0) => {
- full!(v.visit_expr_block_mut(_binding_0));
- }
- Expr::Box(_binding_0) => {
- full!(v.visit_expr_box_mut(_binding_0));
- }
- Expr::Break(_binding_0) => {
- full!(v.visit_expr_break_mut(_binding_0));
- }
- Expr::Call(_binding_0) => {
- v.visit_expr_call_mut(_binding_0);
- }
- Expr::Cast(_binding_0) => {
- v.visit_expr_cast_mut(_binding_0);
- }
- Expr::Closure(_binding_0) => {
- full!(v.visit_expr_closure_mut(_binding_0));
- }
- Expr::Continue(_binding_0) => {
- full!(v.visit_expr_continue_mut(_binding_0));
- }
- Expr::Field(_binding_0) => {
- v.visit_expr_field_mut(_binding_0);
- }
- Expr::ForLoop(_binding_0) => {
- full!(v.visit_expr_for_loop_mut(_binding_0));
- }
- Expr::Group(_binding_0) => {
- full!(v.visit_expr_group_mut(_binding_0));
- }
- Expr::If(_binding_0) => {
- full!(v.visit_expr_if_mut(_binding_0));
- }
- Expr::Index(_binding_0) => {
- v.visit_expr_index_mut(_binding_0);
- }
- Expr::Let(_binding_0) => {
- full!(v.visit_expr_let_mut(_binding_0));
- }
- Expr::Lit(_binding_0) => {
- v.visit_expr_lit_mut(_binding_0);
- }
- Expr::Loop(_binding_0) => {
- full!(v.visit_expr_loop_mut(_binding_0));
- }
- Expr::Macro(_binding_0) => {
- full!(v.visit_expr_macro_mut(_binding_0));
- }
- Expr::Match(_binding_0) => {
- full!(v.visit_expr_match_mut(_binding_0));
- }
- Expr::MethodCall(_binding_0) => {
- full!(v.visit_expr_method_call_mut(_binding_0));
- }
- Expr::Paren(_binding_0) => {
- v.visit_expr_paren_mut(_binding_0);
- }
- Expr::Path(_binding_0) => {
- v.visit_expr_path_mut(_binding_0);
- }
- Expr::Range(_binding_0) => {
- full!(v.visit_expr_range_mut(_binding_0));
- }
- Expr::Reference(_binding_0) => {
- full!(v.visit_expr_reference_mut(_binding_0));
- }
- Expr::Repeat(_binding_0) => {
- full!(v.visit_expr_repeat_mut(_binding_0));
- }
- Expr::Return(_binding_0) => {
- full!(v.visit_expr_return_mut(_binding_0));
- }
- Expr::Struct(_binding_0) => {
- full!(v.visit_expr_struct_mut(_binding_0));
- }
- Expr::Try(_binding_0) => {
- full!(v.visit_expr_try_mut(_binding_0));
- }
- Expr::TryBlock(_binding_0) => {
- full!(v.visit_expr_try_block_mut(_binding_0));
- }
- Expr::Tuple(_binding_0) => {
- full!(v.visit_expr_tuple_mut(_binding_0));
- }
- Expr::Type(_binding_0) => {
- full!(v.visit_expr_type_mut(_binding_0));
- }
- Expr::Unary(_binding_0) => {
- v.visit_expr_unary_mut(_binding_0);
- }
- Expr::Unsafe(_binding_0) => {
- full!(v.visit_expr_unsafe_mut(_binding_0));
- }
- Expr::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- Expr::While(_binding_0) => {
- full!(v.visit_expr_while_mut(_binding_0));
- }
- Expr::Yield(_binding_0) => {
- full!(v.visit_expr_yield_mut(_binding_0));
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_array_mut<V>(v: &mut V, node: &mut ExprArray)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.bracket_token.span);
- for el in Punctuated::pairs_mut(&mut node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_expr_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_assign_mut<V>(v: &mut V, node: &mut ExprAssign)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.left);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_expr_mut(&mut *node.right);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_assign_op_mut<V>(v: &mut V, node: &mut ExprAssignOp)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.left);
- v.visit_bin_op_mut(&mut node.op);
- v.visit_expr_mut(&mut *node.right);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_async_mut<V>(v: &mut V, node: &mut ExprAsync)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.async_token.span);
- if let Some(it) = &mut node.capture {
- tokens_helper(v, &mut it.span)
- };
- v.visit_block_mut(&mut node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_await_mut<V>(v: &mut V, node: &mut ExprAwait)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.base);
- tokens_helper(v, &mut node.dot_token.spans);
- tokens_helper(v, &mut node.await_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_binary_mut<V>(v: &mut V, node: &mut ExprBinary)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.left);
- v.visit_bin_op_mut(&mut node.op);
- v.visit_expr_mut(&mut *node.right);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_block_mut<V>(v: &mut V, node: &mut ExprBlock)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.label {
- v.visit_label_mut(it)
- };
- v.visit_block_mut(&mut node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_box_mut<V>(v: &mut V, node: &mut ExprBox)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.box_token.span);
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_break_mut<V>(v: &mut V, node: &mut ExprBreak)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.break_token.span);
- if let Some(it) = &mut node.label {
- v.visit_lifetime_mut(it)
- };
- if let Some(it) = &mut node.expr {
- v.visit_expr_mut(&mut **it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_call_mut<V>(v: &mut V, node: &mut ExprCall)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.func);
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.args) {
- let (it, p) = el.into_tuple();
- v.visit_expr_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_cast_mut<V>(v: &mut V, node: &mut ExprCast)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.as_token.span);
- v.visit_type_mut(&mut *node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_closure_mut<V>(v: &mut V, node: &mut ExprClosure)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.asyncness {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.movability {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.capture {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.or1_token.spans);
- for el in Punctuated::pairs_mut(&mut node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_pat_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- tokens_helper(v, &mut node.or2_token.spans);
- v.visit_return_type_mut(&mut node.output);
- v.visit_expr_mut(&mut *node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_continue_mut<V>(v: &mut V, node: &mut ExprContinue)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.continue_token.span);
- if let Some(it) = &mut node.label {
- v.visit_lifetime_mut(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_field_mut<V>(v: &mut V, node: &mut ExprField)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.base);
- tokens_helper(v, &mut node.dot_token.spans);
- v.visit_member_mut(&mut node.member);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_for_loop_mut<V>(v: &mut V, node: &mut ExprForLoop)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.label {
- v.visit_label_mut(it)
- };
- tokens_helper(v, &mut node.for_token.span);
- v.visit_pat_mut(&mut node.pat);
- tokens_helper(v, &mut node.in_token.span);
- v.visit_expr_mut(&mut *node.expr);
- v.visit_block_mut(&mut node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_group_mut<V>(v: &mut V, node: &mut ExprGroup)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.group_token.span);
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_if_mut<V>(v: &mut V, node: &mut ExprIf)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.if_token.span);
- v.visit_expr_mut(&mut *node.cond);
- v.visit_block_mut(&mut node.then_branch);
- if let Some(it) = &mut node.else_branch {
- tokens_helper(v, &mut (it).0.span);
- v.visit_expr_mut(&mut *(it).1);
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_index_mut<V>(v: &mut V, node: &mut ExprIndex)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.bracket_token.span);
- v.visit_expr_mut(&mut *node.index);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_let_mut<V>(v: &mut V, node: &mut ExprLet)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.let_token.span);
- v.visit_pat_mut(&mut node.pat);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_lit_mut<V>(v: &mut V, node: &mut ExprLit)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_lit_mut(&mut node.lit);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_loop_mut<V>(v: &mut V, node: &mut ExprLoop)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.label {
- v.visit_label_mut(it)
- };
- tokens_helper(v, &mut node.loop_token.span);
- v.visit_block_mut(&mut node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_macro_mut<V>(v: &mut V, node: &mut ExprMacro)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_macro_mut(&mut node.mac);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_match_mut<V>(v: &mut V, node: &mut ExprMatch)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.match_token.span);
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.brace_token.span);
- for it in &mut node.arms {
- v.visit_arm_mut(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_method_call_mut<V>(v: &mut V, node: &mut ExprMethodCall)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.receiver);
- tokens_helper(v, &mut node.dot_token.spans);
- v.visit_ident_mut(&mut node.method);
- if let Some(it) = &mut node.turbofish {
- v.visit_method_turbofish_mut(it)
- };
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.args) {
- let (it, p) = el.into_tuple();
- v.visit_expr_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_paren_mut<V>(v: &mut V, node: &mut ExprParen)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.paren_token.span);
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_path_mut<V>(v: &mut V, node: &mut ExprPath)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.qself {
- v.visit_qself_mut(it)
- };
- v.visit_path_mut(&mut node.path);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_range_mut<V>(v: &mut V, node: &mut ExprRange)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.from {
- v.visit_expr_mut(&mut **it)
- };
- v.visit_range_limits_mut(&mut node.limits);
- if let Some(it) = &mut node.to {
- v.visit_expr_mut(&mut **it)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_reference_mut<V>(v: &mut V, node: &mut ExprReference)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.and_token.spans);
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_repeat_mut<V>(v: &mut V, node: &mut ExprRepeat)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.bracket_token.span);
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.semi_token.spans);
- v.visit_expr_mut(&mut *node.len);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_return_mut<V>(v: &mut V, node: &mut ExprReturn)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.return_token.span);
- if let Some(it) = &mut node.expr {
- v.visit_expr_mut(&mut **it)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_struct_mut<V>(v: &mut V, node: &mut ExprStruct)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_path_mut(&mut node.path);
- tokens_helper(v, &mut node.brace_token.span);
- for el in Punctuated::pairs_mut(&mut node.fields) {
- let (it, p) = el.into_tuple();
- v.visit_field_value_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.dot2_token {
- tokens_helper(v, &mut it.spans)
- };
- if let Some(it) = &mut node.rest {
- v.visit_expr_mut(&mut **it)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_try_mut<V>(v: &mut V, node: &mut ExprTry)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.question_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_try_block_mut<V>(v: &mut V, node: &mut ExprTryBlock)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.try_token.span);
- v.visit_block_mut(&mut node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_tuple_mut<V>(v: &mut V, node: &mut ExprTuple)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_expr_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_type_mut<V>(v: &mut V, node: &mut ExprType)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut *node.ty);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_expr_unary_mut<V>(v: &mut V, node: &mut ExprUnary)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_un_op_mut(&mut node.op);
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_unsafe_mut<V>(v: &mut V, node: &mut ExprUnsafe)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.unsafe_token.span);
- v.visit_block_mut(&mut node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_while_mut<V>(v: &mut V, node: &mut ExprWhile)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.label {
- v.visit_label_mut(it)
- };
- tokens_helper(v, &mut node.while_token.span);
- v.visit_expr_mut(&mut *node.cond);
- v.visit_block_mut(&mut node.body);
-}
-#[cfg(feature = "full")]
-pub fn visit_expr_yield_mut<V>(v: &mut V, node: &mut ExprYield)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.yield_token.span);
- if let Some(it) = &mut node.expr {
- v.visit_expr_mut(&mut **it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_field_mut<V>(v: &mut V, node: &mut Field)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- if let Some(it) = &mut node.ident {
- v.visit_ident_mut(it)
- };
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- v.visit_type_mut(&mut node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_field_pat_mut<V>(v: &mut V, node: &mut FieldPat)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_member_mut(&mut node.member);
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- v.visit_pat_mut(&mut *node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_field_value_mut<V>(v: &mut V, node: &mut FieldValue)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_member_mut(&mut node.member);
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- v.visit_expr_mut(&mut node.expr);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_fields_mut<V>(v: &mut V, node: &mut Fields)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Fields::Named(_binding_0) => {
- v.visit_fields_named_mut(_binding_0);
- }
- Fields::Unnamed(_binding_0) => {
- v.visit_fields_unnamed_mut(_binding_0);
- }
- Fields::Unit => {}
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_fields_named_mut<V>(v: &mut V, node: &mut FieldsNamed)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.brace_token.span);
- for el in Punctuated::pairs_mut(&mut node.named) {
- let (it, p) = el.into_tuple();
- v.visit_field_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_fields_unnamed_mut<V>(v: &mut V, node: &mut FieldsUnnamed)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.unnamed) {
- let (it, p) = el.into_tuple();
- v.visit_field_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_file_mut<V>(v: &mut V, node: &mut File)
-where
- V: VisitMut + ?Sized,
-{
- skip!(node.shebang);
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- for it in &mut node.items {
- v.visit_item_mut(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_fn_arg_mut<V>(v: &mut V, node: &mut FnArg)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- FnArg::Receiver(_binding_0) => {
- v.visit_receiver_mut(_binding_0);
- }
- FnArg::Typed(_binding_0) => {
- v.visit_pat_type_mut(_binding_0);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_mut<V>(v: &mut V, node: &mut ForeignItem)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- ForeignItem::Fn(_binding_0) => {
- v.visit_foreign_item_fn_mut(_binding_0);
- }
- ForeignItem::Static(_binding_0) => {
- v.visit_foreign_item_static_mut(_binding_0);
- }
- ForeignItem::Type(_binding_0) => {
- v.visit_foreign_item_type_mut(_binding_0);
- }
- ForeignItem::Macro(_binding_0) => {
- v.visit_foreign_item_macro_mut(_binding_0);
- }
- ForeignItem::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_fn_mut<V>(v: &mut V, node: &mut ForeignItemFn)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- v.visit_signature_mut(&mut node.sig);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_macro_mut<V>(v: &mut V, node: &mut ForeignItemMacro)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_macro_mut(&mut node.mac);
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_static_mut<V>(v: &mut V, node: &mut ForeignItemStatic)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.static_token.span);
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut *node.ty);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_foreign_item_type_mut<V>(v: &mut V, node: &mut ForeignItemType)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.type_token.span);
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_generic_argument_mut<V>(v: &mut V, node: &mut GenericArgument)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- GenericArgument::Lifetime(_binding_0) => {
- v.visit_lifetime_mut(_binding_0);
- }
- GenericArgument::Type(_binding_0) => {
- v.visit_type_mut(_binding_0);
- }
- GenericArgument::Binding(_binding_0) => {
- v.visit_binding_mut(_binding_0);
- }
- GenericArgument::Constraint(_binding_0) => {
- v.visit_constraint_mut(_binding_0);
- }
- GenericArgument::Const(_binding_0) => {
- v.visit_expr_mut(_binding_0);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_generic_method_argument_mut<V>(v: &mut V, node: &mut GenericMethodArgument)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- GenericMethodArgument::Type(_binding_0) => {
- v.visit_type_mut(_binding_0);
- }
- GenericMethodArgument::Const(_binding_0) => {
- v.visit_expr_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_generic_param_mut<V>(v: &mut V, node: &mut GenericParam)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- GenericParam::Type(_binding_0) => {
- v.visit_type_param_mut(_binding_0);
- }
- GenericParam::Lifetime(_binding_0) => {
- v.visit_lifetime_def_mut(_binding_0);
- }
- GenericParam::Const(_binding_0) => {
- v.visit_const_param_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_generics_mut<V>(v: &mut V, node: &mut Generics)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.lt_token {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.params) {
- let (it, p) = el.into_tuple();
- v.visit_generic_param_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.gt_token {
- tokens_helper(v, &mut it.spans)
- };
- if let Some(it) = &mut node.where_clause {
- v.visit_where_clause_mut(it)
- };
-}
-pub fn visit_ident_mut<V>(v: &mut V, node: &mut Ident)
-where
- V: VisitMut + ?Sized,
-{
- let mut span = node.span();
- v.visit_span_mut(&mut span);
- node.set_span(span);
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_mut<V>(v: &mut V, node: &mut ImplItem)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- ImplItem::Const(_binding_0) => {
- v.visit_impl_item_const_mut(_binding_0);
- }
- ImplItem::Method(_binding_0) => {
- v.visit_impl_item_method_mut(_binding_0);
- }
- ImplItem::Type(_binding_0) => {
- v.visit_impl_item_type_mut(_binding_0);
- }
- ImplItem::Macro(_binding_0) => {
- v.visit_impl_item_macro_mut(_binding_0);
- }
- ImplItem::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_const_mut<V>(v: &mut V, node: &mut ImplItemConst)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- if let Some(it) = &mut node.defaultness {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.const_token.span);
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut node.ty);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_expr_mut(&mut node.expr);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_macro_mut<V>(v: &mut V, node: &mut ImplItemMacro)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_macro_mut(&mut node.mac);
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_method_mut<V>(v: &mut V, node: &mut ImplItemMethod)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- if let Some(it) = &mut node.defaultness {
- tokens_helper(v, &mut it.span)
- };
- v.visit_signature_mut(&mut node.sig);
- v.visit_block_mut(&mut node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_impl_item_type_mut<V>(v: &mut V, node: &mut ImplItemType)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- if let Some(it) = &mut node.defaultness {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.type_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_type_mut(&mut node.ty);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_index_mut<V>(v: &mut V, node: &mut Index)
-where
- V: VisitMut + ?Sized,
-{
- skip!(node.index);
- v.visit_span_mut(&mut node.span);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_mut<V>(v: &mut V, node: &mut Item)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Item::Const(_binding_0) => {
- v.visit_item_const_mut(_binding_0);
- }
- Item::Enum(_binding_0) => {
- v.visit_item_enum_mut(_binding_0);
- }
- Item::ExternCrate(_binding_0) => {
- v.visit_item_extern_crate_mut(_binding_0);
- }
- Item::Fn(_binding_0) => {
- v.visit_item_fn_mut(_binding_0);
- }
- Item::ForeignMod(_binding_0) => {
- v.visit_item_foreign_mod_mut(_binding_0);
- }
- Item::Impl(_binding_0) => {
- v.visit_item_impl_mut(_binding_0);
- }
- Item::Macro(_binding_0) => {
- v.visit_item_macro_mut(_binding_0);
- }
- Item::Macro2(_binding_0) => {
- v.visit_item_macro2_mut(_binding_0);
- }
- Item::Mod(_binding_0) => {
- v.visit_item_mod_mut(_binding_0);
- }
- Item::Static(_binding_0) => {
- v.visit_item_static_mut(_binding_0);
- }
- Item::Struct(_binding_0) => {
- v.visit_item_struct_mut(_binding_0);
- }
- Item::Trait(_binding_0) => {
- v.visit_item_trait_mut(_binding_0);
- }
- Item::TraitAlias(_binding_0) => {
- v.visit_item_trait_alias_mut(_binding_0);
- }
- Item::Type(_binding_0) => {
- v.visit_item_type_mut(_binding_0);
- }
- Item::Union(_binding_0) => {
- v.visit_item_union_mut(_binding_0);
- }
- Item::Use(_binding_0) => {
- v.visit_item_use_mut(_binding_0);
- }
- Item::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_const_mut<V>(v: &mut V, node: &mut ItemConst)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.const_token.span);
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut *node.ty);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_enum_mut<V>(v: &mut V, node: &mut ItemEnum)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.enum_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- tokens_helper(v, &mut node.brace_token.span);
- for el in Punctuated::pairs_mut(&mut node.variants) {
- let (it, p) = el.into_tuple();
- v.visit_variant_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_extern_crate_mut<V>(v: &mut V, node: &mut ItemExternCrate)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.extern_token.span);
- tokens_helper(v, &mut node.crate_token.span);
- v.visit_ident_mut(&mut node.ident);
- if let Some(it) = &mut node.rename {
- tokens_helper(v, &mut (it).0.span);
- v.visit_ident_mut(&mut (it).1);
- };
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_fn_mut<V>(v: &mut V, node: &mut ItemFn)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- v.visit_signature_mut(&mut node.sig);
- v.visit_block_mut(&mut *node.block);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_foreign_mod_mut<V>(v: &mut V, node: &mut ItemForeignMod)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_abi_mut(&mut node.abi);
- tokens_helper(v, &mut node.brace_token.span);
- for it in &mut node.items {
- v.visit_foreign_item_mut(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_impl_mut<V>(v: &mut V, node: &mut ItemImpl)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.defaultness {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.unsafety {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.impl_token.span);
- v.visit_generics_mut(&mut node.generics);
- if let Some(it) = &mut node.trait_ {
- if let Some(it) = &mut (it).0 {
- tokens_helper(v, &mut it.spans)
- };
- v.visit_path_mut(&mut (it).1);
- tokens_helper(v, &mut (it).2.span);
- };
- v.visit_type_mut(&mut *node.self_ty);
- tokens_helper(v, &mut node.brace_token.span);
- for it in &mut node.items {
- v.visit_impl_item_mut(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_macro_mut<V>(v: &mut V, node: &mut ItemMacro)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.ident {
- v.visit_ident_mut(it)
- };
- v.visit_macro_mut(&mut node.mac);
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_item_macro2_mut<V>(v: &mut V, node: &mut ItemMacro2)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.macro_token.span);
- v.visit_ident_mut(&mut node.ident);
- skip!(node.rules);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_mod_mut<V>(v: &mut V, node: &mut ItemMod)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.mod_token.span);
- v.visit_ident_mut(&mut node.ident);
- if let Some(it) = &mut node.content {
- tokens_helper(v, &mut (it).0.span);
- for it in &mut (it).1 {
- v.visit_item_mut(it)
- }
- };
- if let Some(it) = &mut node.semi {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_item_static_mut<V>(v: &mut V, node: &mut ItemStatic)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.static_token.span);
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut *node.ty);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_expr_mut(&mut *node.expr);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_struct_mut<V>(v: &mut V, node: &mut ItemStruct)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.struct_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- v.visit_fields_mut(&mut node.fields);
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_item_trait_mut<V>(v: &mut V, node: &mut ItemTrait)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- if let Some(it) = &mut node.unsafety {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.auto_token {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.trait_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.supertraits) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- tokens_helper(v, &mut node.brace_token.span);
- for it in &mut node.items {
- v.visit_trait_item_mut(it)
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_item_trait_alias_mut<V>(v: &mut V, node: &mut ItemTraitAlias)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.trait_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- tokens_helper(v, &mut node.eq_token.spans);
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_type_mut<V>(v: &mut V, node: &mut ItemType)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.type_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_type_mut(&mut *node.ty);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_union_mut<V>(v: &mut V, node: &mut ItemUnion)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.union_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- v.visit_fields_named_mut(&mut node.fields);
-}
-#[cfg(feature = "full")]
-pub fn visit_item_use_mut<V>(v: &mut V, node: &mut ItemUse)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_visibility_mut(&mut node.vis);
- tokens_helper(v, &mut node.use_token.span);
- if let Some(it) = &mut node.leading_colon {
- tokens_helper(v, &mut it.spans)
- };
- v.visit_use_tree_mut(&mut node.tree);
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_label_mut<V>(v: &mut V, node: &mut Label)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_lifetime_mut(&mut node.name);
- tokens_helper(v, &mut node.colon_token.spans);
-}
-pub fn visit_lifetime_mut<V>(v: &mut V, node: &mut Lifetime)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_span_mut(&mut node.apostrophe);
- v.visit_ident_mut(&mut node.ident);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lifetime_def_mut<V>(v: &mut V, node: &mut LifetimeDef)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_lifetime_mut(&mut node.lifetime);
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_lifetime_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_mut<V>(v: &mut V, node: &mut Lit)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Lit::Str(_binding_0) => {
- v.visit_lit_str_mut(_binding_0);
- }
- Lit::ByteStr(_binding_0) => {
- v.visit_lit_byte_str_mut(_binding_0);
- }
- Lit::Byte(_binding_0) => {
- v.visit_lit_byte_mut(_binding_0);
- }
- Lit::Char(_binding_0) => {
- v.visit_lit_char_mut(_binding_0);
- }
- Lit::Int(_binding_0) => {
- v.visit_lit_int_mut(_binding_0);
- }
- Lit::Float(_binding_0) => {
- v.visit_lit_float_mut(_binding_0);
- }
- Lit::Bool(_binding_0) => {
- v.visit_lit_bool_mut(_binding_0);
- }
- Lit::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_bool_mut<V>(v: &mut V, node: &mut LitBool)
-where
- V: VisitMut + ?Sized,
-{
- skip!(node.value);
- v.visit_span_mut(&mut node.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_byte_mut<V>(v: &mut V, node: &mut LitByte)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_byte_str_mut<V>(v: &mut V, node: &mut LitByteStr)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_char_mut<V>(v: &mut V, node: &mut LitChar)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_float_mut<V>(v: &mut V, node: &mut LitFloat)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_int_mut<V>(v: &mut V, node: &mut LitInt)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_lit_str_mut<V>(v: &mut V, node: &mut LitStr)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(feature = "full")]
-pub fn visit_local_mut<V>(v: &mut V, node: &mut Local)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.let_token.span);
- v.visit_pat_mut(&mut node.pat);
- if let Some(it) = &mut node.init {
- tokens_helper(v, &mut (it).0.spans);
- v.visit_expr_mut(&mut *(it).1);
- };
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_macro_mut<V>(v: &mut V, node: &mut Macro)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_path_mut(&mut node.path);
- tokens_helper(v, &mut node.bang_token.spans);
- v.visit_macro_delimiter_mut(&mut node.delimiter);
- skip!(node.tokens);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_macro_delimiter_mut<V>(v: &mut V, node: &mut MacroDelimiter)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- MacroDelimiter::Paren(_binding_0) => {
- tokens_helper(v, &mut _binding_0.span);
- }
- MacroDelimiter::Brace(_binding_0) => {
- tokens_helper(v, &mut _binding_0.span);
- }
- MacroDelimiter::Bracket(_binding_0) => {
- tokens_helper(v, &mut _binding_0.span);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_member_mut<V>(v: &mut V, node: &mut Member)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Member::Named(_binding_0) => {
- v.visit_ident_mut(_binding_0);
- }
- Member::Unnamed(_binding_0) => {
- v.visit_index_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_meta_mut<V>(v: &mut V, node: &mut Meta)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Meta::Path(_binding_0) => {
- v.visit_path_mut(_binding_0);
- }
- Meta::List(_binding_0) => {
- v.visit_meta_list_mut(_binding_0);
- }
- Meta::NameValue(_binding_0) => {
- v.visit_meta_name_value_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_meta_list_mut<V>(v: &mut V, node: &mut MetaList)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_path_mut(&mut node.path);
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.nested) {
- let (it, p) = el.into_tuple();
- v.visit_nested_meta_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_meta_name_value_mut<V>(v: &mut V, node: &mut MetaNameValue)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_path_mut(&mut node.path);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_lit_mut(&mut node.lit);
-}
-#[cfg(feature = "full")]
-pub fn visit_method_turbofish_mut<V>(v: &mut V, node: &mut MethodTurbofish)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.colon2_token.spans);
- tokens_helper(v, &mut node.lt_token.spans);
- for el in Punctuated::pairs_mut(&mut node.args) {
- let (it, p) = el.into_tuple();
- v.visit_generic_method_argument_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- tokens_helper(v, &mut node.gt_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_nested_meta_mut<V>(v: &mut V, node: &mut NestedMeta)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- NestedMeta::Meta(_binding_0) => {
- v.visit_meta_mut(_binding_0);
- }
- NestedMeta::Lit(_binding_0) => {
- v.visit_lit_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_parenthesized_generic_arguments_mut<V>(
- v: &mut V,
- node: &mut ParenthesizedGenericArguments,
-) where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_type_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- v.visit_return_type_mut(&mut node.output);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_mut<V>(v: &mut V, node: &mut Pat)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Pat::Box(_binding_0) => {
- v.visit_pat_box_mut(_binding_0);
- }
- Pat::Ident(_binding_0) => {
- v.visit_pat_ident_mut(_binding_0);
- }
- Pat::Lit(_binding_0) => {
- v.visit_pat_lit_mut(_binding_0);
- }
- Pat::Macro(_binding_0) => {
- v.visit_pat_macro_mut(_binding_0);
- }
- Pat::Or(_binding_0) => {
- v.visit_pat_or_mut(_binding_0);
- }
- Pat::Path(_binding_0) => {
- v.visit_pat_path_mut(_binding_0);
- }
- Pat::Range(_binding_0) => {
- v.visit_pat_range_mut(_binding_0);
- }
- Pat::Reference(_binding_0) => {
- v.visit_pat_reference_mut(_binding_0);
- }
- Pat::Rest(_binding_0) => {
- v.visit_pat_rest_mut(_binding_0);
- }
- Pat::Slice(_binding_0) => {
- v.visit_pat_slice_mut(_binding_0);
- }
- Pat::Struct(_binding_0) => {
- v.visit_pat_struct_mut(_binding_0);
- }
- Pat::Tuple(_binding_0) => {
- v.visit_pat_tuple_mut(_binding_0);
- }
- Pat::TupleStruct(_binding_0) => {
- v.visit_pat_tuple_struct_mut(_binding_0);
- }
- Pat::Type(_binding_0) => {
- v.visit_pat_type_mut(_binding_0);
- }
- Pat::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- Pat::Wild(_binding_0) => {
- v.visit_pat_wild_mut(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_box_mut<V>(v: &mut V, node: &mut PatBox)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.box_token.span);
- v.visit_pat_mut(&mut *node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_ident_mut<V>(v: &mut V, node: &mut PatIdent)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.by_ref {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_ident_mut(&mut node.ident);
- if let Some(it) = &mut node.subpat {
- tokens_helper(v, &mut (it).0.spans);
- v.visit_pat_mut(&mut *(it).1);
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_lit_mut<V>(v: &mut V, node: &mut PatLit)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.expr);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_macro_mut<V>(v: &mut V, node: &mut PatMacro)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_macro_mut(&mut node.mac);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_or_mut<V>(v: &mut V, node: &mut PatOr)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.leading_vert {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.cases) {
- let (it, p) = el.into_tuple();
- v.visit_pat_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_path_mut<V>(v: &mut V, node: &mut PatPath)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.qself {
- v.visit_qself_mut(it)
- };
- v.visit_path_mut(&mut node.path);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_range_mut<V>(v: &mut V, node: &mut PatRange)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_expr_mut(&mut *node.lo);
- v.visit_range_limits_mut(&mut node.limits);
- v.visit_expr_mut(&mut *node.hi);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_reference_mut<V>(v: &mut V, node: &mut PatReference)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.and_token.spans);
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_pat_mut(&mut *node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_rest_mut<V>(v: &mut V, node: &mut PatRest)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.dot2_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_slice_mut<V>(v: &mut V, node: &mut PatSlice)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.bracket_token.span);
- for el in Punctuated::pairs_mut(&mut node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_pat_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_struct_mut<V>(v: &mut V, node: &mut PatStruct)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_path_mut(&mut node.path);
- tokens_helper(v, &mut node.brace_token.span);
- for el in Punctuated::pairs_mut(&mut node.fields) {
- let (it, p) = el.into_tuple();
- v.visit_field_pat_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.dot2_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_tuple_mut<V>(v: &mut V, node: &mut PatTuple)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_pat_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_tuple_struct_mut<V>(v: &mut V, node: &mut PatTupleStruct)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_path_mut(&mut node.path);
- v.visit_pat_tuple_mut(&mut node.pat);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_type_mut<V>(v: &mut V, node: &mut PatType)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_pat_mut(&mut *node.pat);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut *node.ty);
-}
-#[cfg(feature = "full")]
-pub fn visit_pat_wild_mut<V>(v: &mut V, node: &mut PatWild)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.underscore_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_path_mut<V>(v: &mut V, node: &mut Path)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.leading_colon {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.segments) {
- let (it, p) = el.into_tuple();
- v.visit_path_segment_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_path_arguments_mut<V>(v: &mut V, node: &mut PathArguments)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- PathArguments::None => {}
- PathArguments::AngleBracketed(_binding_0) => {
- v.visit_angle_bracketed_generic_arguments_mut(_binding_0);
- }
- PathArguments::Parenthesized(_binding_0) => {
- v.visit_parenthesized_generic_arguments_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_path_segment_mut<V>(v: &mut V, node: &mut PathSegment)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_ident_mut(&mut node.ident);
- v.visit_path_arguments_mut(&mut node.arguments);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_predicate_eq_mut<V>(v: &mut V, node: &mut PredicateEq)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_type_mut(&mut node.lhs_ty);
- tokens_helper(v, &mut node.eq_token.spans);
- v.visit_type_mut(&mut node.rhs_ty);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_predicate_lifetime_mut<V>(v: &mut V, node: &mut PredicateLifetime)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_lifetime_mut(&mut node.lifetime);
- tokens_helper(v, &mut node.colon_token.spans);
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_lifetime_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_predicate_type_mut<V>(v: &mut V, node: &mut PredicateType)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.lifetimes {
- v.visit_bound_lifetimes_mut(it)
- };
- v.visit_type_mut(&mut node.bounded_ty);
- tokens_helper(v, &mut node.colon_token.spans);
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_qself_mut<V>(v: &mut V, node: &mut QSelf)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.lt_token.spans);
- v.visit_type_mut(&mut *node.ty);
- skip!(node.position);
- if let Some(it) = &mut node.as_token {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.gt_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_range_limits_mut<V>(v: &mut V, node: &mut RangeLimits)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- RangeLimits::HalfOpen(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- RangeLimits::Closed(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_receiver_mut<V>(v: &mut V, node: &mut Receiver)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- if let Some(it) = &mut node.reference {
- tokens_helper(v, &mut (it).0.spans);
- if let Some(it) = &mut (it).1 {
- v.visit_lifetime_mut(it)
- };
- };
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- tokens_helper(v, &mut node.self_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_return_type_mut<V>(v: &mut V, node: &mut ReturnType)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- ReturnType::Default => {}
- ReturnType::Type(_binding_0, _binding_1) => {
- tokens_helper(v, &mut _binding_0.spans);
- v.visit_type_mut(&mut **_binding_1);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_signature_mut<V>(v: &mut V, node: &mut Signature)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.constness {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.asyncness {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.unsafety {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.abi {
- v.visit_abi_mut(it)
- };
- tokens_helper(v, &mut node.fn_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_fn_arg_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.variadic {
- v.visit_variadic_mut(it)
- };
- v.visit_return_type_mut(&mut node.output);
-}
-pub fn visit_span_mut<V>(v: &mut V, node: &mut Span)
-where
- V: VisitMut + ?Sized,
-{
-}
-#[cfg(feature = "full")]
-pub fn visit_stmt_mut<V>(v: &mut V, node: &mut Stmt)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Stmt::Local(_binding_0) => {
- v.visit_local_mut(_binding_0);
- }
- Stmt::Item(_binding_0) => {
- v.visit_item_mut(_binding_0);
- }
- Stmt::Expr(_binding_0) => {
- v.visit_expr_mut(_binding_0);
- }
- Stmt::Semi(_binding_0, _binding_1) => {
- v.visit_expr_mut(_binding_0);
- tokens_helper(v, &mut _binding_1.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_trait_bound_mut<V>(v: &mut V, node: &mut TraitBound)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.paren_token {
- tokens_helper(v, &mut it.span)
- };
- v.visit_trait_bound_modifier_mut(&mut node.modifier);
- if let Some(it) = &mut node.lifetimes {
- v.visit_bound_lifetimes_mut(it)
- };
- v.visit_path_mut(&mut node.path);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_trait_bound_modifier_mut<V>(v: &mut V, node: &mut TraitBoundModifier)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- TraitBoundModifier::None => {}
- TraitBoundModifier::Maybe(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_mut<V>(v: &mut V, node: &mut TraitItem)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- TraitItem::Const(_binding_0) => {
- v.visit_trait_item_const_mut(_binding_0);
- }
- TraitItem::Method(_binding_0) => {
- v.visit_trait_item_method_mut(_binding_0);
- }
- TraitItem::Type(_binding_0) => {
- v.visit_trait_item_type_mut(_binding_0);
- }
- TraitItem::Macro(_binding_0) => {
- v.visit_trait_item_macro_mut(_binding_0);
- }
- TraitItem::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_const_mut<V>(v: &mut V, node: &mut TraitItemConst)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.const_token.span);
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon_token.spans);
- v.visit_type_mut(&mut node.ty);
- if let Some(it) = &mut node.default {
- tokens_helper(v, &mut (it).0.spans);
- v.visit_expr_mut(&mut (it).1);
- };
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_macro_mut<V>(v: &mut V, node: &mut TraitItemMacro)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_macro_mut(&mut node.mac);
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_method_mut<V>(v: &mut V, node: &mut TraitItemMethod)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_signature_mut(&mut node.sig);
- if let Some(it) = &mut node.default {
- v.visit_block_mut(it)
- };
- if let Some(it) = &mut node.semi_token {
- tokens_helper(v, &mut it.spans)
- };
-}
-#[cfg(feature = "full")]
-pub fn visit_trait_item_type_mut<V>(v: &mut V, node: &mut TraitItemType)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.type_token.span);
- v.visit_ident_mut(&mut node.ident);
- v.visit_generics_mut(&mut node.generics);
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.default {
- tokens_helper(v, &mut (it).0.spans);
- v.visit_type_mut(&mut (it).1);
- };
- tokens_helper(v, &mut node.semi_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_mut<V>(v: &mut V, node: &mut Type)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Type::Array(_binding_0) => {
- v.visit_type_array_mut(_binding_0);
- }
- Type::BareFn(_binding_0) => {
- v.visit_type_bare_fn_mut(_binding_0);
- }
- Type::Group(_binding_0) => {
- v.visit_type_group_mut(_binding_0);
- }
- Type::ImplTrait(_binding_0) => {
- v.visit_type_impl_trait_mut(_binding_0);
- }
- Type::Infer(_binding_0) => {
- v.visit_type_infer_mut(_binding_0);
- }
- Type::Macro(_binding_0) => {
- v.visit_type_macro_mut(_binding_0);
- }
- Type::Never(_binding_0) => {
- v.visit_type_never_mut(_binding_0);
- }
- Type::Paren(_binding_0) => {
- v.visit_type_paren_mut(_binding_0);
- }
- Type::Path(_binding_0) => {
- v.visit_type_path_mut(_binding_0);
- }
- Type::Ptr(_binding_0) => {
- v.visit_type_ptr_mut(_binding_0);
- }
- Type::Reference(_binding_0) => {
- v.visit_type_reference_mut(_binding_0);
- }
- Type::Slice(_binding_0) => {
- v.visit_type_slice_mut(_binding_0);
- }
- Type::TraitObject(_binding_0) => {
- v.visit_type_trait_object_mut(_binding_0);
- }
- Type::Tuple(_binding_0) => {
- v.visit_type_tuple_mut(_binding_0);
- }
- Type::Verbatim(_binding_0) => {
- skip!(_binding_0);
- }
- _ => unreachable!(),
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_array_mut<V>(v: &mut V, node: &mut TypeArray)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.bracket_token.span);
- v.visit_type_mut(&mut *node.elem);
- tokens_helper(v, &mut node.semi_token.spans);
- v.visit_expr_mut(&mut node.len);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_bare_fn_mut<V>(v: &mut V, node: &mut TypeBareFn)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.lifetimes {
- v.visit_bound_lifetimes_mut(it)
- };
- if let Some(it) = &mut node.unsafety {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.abi {
- v.visit_abi_mut(it)
- };
- tokens_helper(v, &mut node.fn_token.span);
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.inputs) {
- let (it, p) = el.into_tuple();
- v.visit_bare_fn_arg_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.variadic {
- v.visit_variadic_mut(it)
- };
- v.visit_return_type_mut(&mut node.output);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_group_mut<V>(v: &mut V, node: &mut TypeGroup)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.group_token.span);
- v.visit_type_mut(&mut *node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_impl_trait_mut<V>(v: &mut V, node: &mut TypeImplTrait)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.impl_token.span);
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_infer_mut<V>(v: &mut V, node: &mut TypeInfer)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.underscore_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_macro_mut<V>(v: &mut V, node: &mut TypeMacro)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_macro_mut(&mut node.mac);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_never_mut<V>(v: &mut V, node: &mut TypeNever)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.bang_token.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_param_mut<V>(v: &mut V, node: &mut TypeParam)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_ident_mut(&mut node.ident);
- if let Some(it) = &mut node.colon_token {
- tokens_helper(v, &mut it.spans)
- };
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
- if let Some(it) = &mut node.eq_token {
- tokens_helper(v, &mut it.spans)
- };
- if let Some(it) = &mut node.default {
- v.visit_type_mut(it)
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_param_bound_mut<V>(v: &mut V, node: &mut TypeParamBound)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- TypeParamBound::Trait(_binding_0) => {
- v.visit_trait_bound_mut(_binding_0);
- }
- TypeParamBound::Lifetime(_binding_0) => {
- v.visit_lifetime_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_paren_mut<V>(v: &mut V, node: &mut TypeParen)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.paren_token.span);
- v.visit_type_mut(&mut *node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_path_mut<V>(v: &mut V, node: &mut TypePath)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.qself {
- v.visit_qself_mut(it)
- };
- v.visit_path_mut(&mut node.path);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_ptr_mut<V>(v: &mut V, node: &mut TypePtr)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.star_token.spans);
- if let Some(it) = &mut node.const_token {
- tokens_helper(v, &mut it.span)
- };
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_type_mut(&mut *node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_reference_mut<V>(v: &mut V, node: &mut TypeReference)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.and_token.spans);
- if let Some(it) = &mut node.lifetime {
- v.visit_lifetime_mut(it)
- };
- if let Some(it) = &mut node.mutability {
- tokens_helper(v, &mut it.span)
- };
- v.visit_type_mut(&mut *node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_slice_mut<V>(v: &mut V, node: &mut TypeSlice)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.bracket_token.span);
- v.visit_type_mut(&mut *node.elem);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_trait_object_mut<V>(v: &mut V, node: &mut TypeTraitObject)
-where
- V: VisitMut + ?Sized,
-{
- if let Some(it) = &mut node.dyn_token {
- tokens_helper(v, &mut it.span)
- };
- for el in Punctuated::pairs_mut(&mut node.bounds) {
- let (it, p) = el.into_tuple();
- v.visit_type_param_bound_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_type_tuple_mut<V>(v: &mut V, node: &mut TypeTuple)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.paren_token.span);
- for el in Punctuated::pairs_mut(&mut node.elems) {
- let (it, p) = el.into_tuple();
- v.visit_type_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_un_op_mut<V>(v: &mut V, node: &mut UnOp)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- UnOp::Deref(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- UnOp::Not(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- UnOp::Neg(_binding_0) => {
- tokens_helper(v, &mut _binding_0.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_use_glob_mut<V>(v: &mut V, node: &mut UseGlob)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.star_token.spans);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_group_mut<V>(v: &mut V, node: &mut UseGroup)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.brace_token.span);
- for el in Punctuated::pairs_mut(&mut node.items) {
- let (it, p) = el.into_tuple();
- v.visit_use_tree_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(feature = "full")]
-pub fn visit_use_name_mut<V>(v: &mut V, node: &mut UseName)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_ident_mut(&mut node.ident);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_path_mut<V>(v: &mut V, node: &mut UsePath)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.colon2_token.spans);
- v.visit_use_tree_mut(&mut *node.tree);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_rename_mut<V>(v: &mut V, node: &mut UseRename)
-where
- V: VisitMut + ?Sized,
-{
- v.visit_ident_mut(&mut node.ident);
- tokens_helper(v, &mut node.as_token.span);
- v.visit_ident_mut(&mut node.rename);
-}
-#[cfg(feature = "full")]
-pub fn visit_use_tree_mut<V>(v: &mut V, node: &mut UseTree)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- UseTree::Path(_binding_0) => {
- v.visit_use_path_mut(_binding_0);
- }
- UseTree::Name(_binding_0) => {
- v.visit_use_name_mut(_binding_0);
- }
- UseTree::Rename(_binding_0) => {
- v.visit_use_rename_mut(_binding_0);
- }
- UseTree::Glob(_binding_0) => {
- v.visit_use_glob_mut(_binding_0);
- }
- UseTree::Group(_binding_0) => {
- v.visit_use_group_mut(_binding_0);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_variadic_mut<V>(v: &mut V, node: &mut Variadic)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- tokens_helper(v, &mut node.dots.spans);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_variant_mut<V>(v: &mut V, node: &mut Variant)
-where
- V: VisitMut + ?Sized,
-{
- for it in &mut node.attrs {
- v.visit_attribute_mut(it)
- }
- v.visit_ident_mut(&mut node.ident);
- v.visit_fields_mut(&mut node.fields);
- if let Some(it) = &mut node.discriminant {
- tokens_helper(v, &mut (it).0.spans);
- v.visit_expr_mut(&mut (it).1);
- };
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_vis_crate_mut<V>(v: &mut V, node: &mut VisCrate)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.crate_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_vis_public_mut<V>(v: &mut V, node: &mut VisPublic)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.pub_token.span);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_vis_restricted_mut<V>(v: &mut V, node: &mut VisRestricted)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.pub_token.span);
- tokens_helper(v, &mut node.paren_token.span);
- if let Some(it) = &mut node.in_token {
- tokens_helper(v, &mut it.span)
- };
- v.visit_path_mut(&mut *node.path);
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_visibility_mut<V>(v: &mut V, node: &mut Visibility)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- Visibility::Public(_binding_0) => {
- v.visit_vis_public_mut(_binding_0);
- }
- Visibility::Crate(_binding_0) => {
- v.visit_vis_crate_mut(_binding_0);
- }
- Visibility::Restricted(_binding_0) => {
- v.visit_vis_restricted_mut(_binding_0);
- }
- Visibility::Inherited => {}
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_where_clause_mut<V>(v: &mut V, node: &mut WhereClause)
-where
- V: VisitMut + ?Sized,
-{
- tokens_helper(v, &mut node.where_token.span);
- for el in Punctuated::pairs_mut(&mut node.predicates) {
- let (it, p) = el.into_tuple();
- v.visit_where_predicate_mut(it);
- if let Some(p) = p {
- tokens_helper(v, &mut p.spans);
- }
- }
-}
-#[cfg(any(feature = "derive", feature = "full"))]
-pub fn visit_where_predicate_mut<V>(v: &mut V, node: &mut WherePredicate)
-where
- V: VisitMut + ?Sized,
-{
- match node {
- WherePredicate::Type(_binding_0) => {
- v.visit_predicate_type_mut(_binding_0);
- }
- WherePredicate::Lifetime(_binding_0) => {
- v.visit_predicate_lifetime_mut(_binding_0);
- }
- WherePredicate::Eq(_binding_0) => {
- v.visit_predicate_eq_mut(_binding_0);
- }
- }
-}
diff --git a/syn/src/gen_helper.rs b/syn/src/gen_helper.rs
deleted file mode 100644
index b279612..0000000
--- a/syn/src/gen_helper.rs
+++ /dev/null
@@ -1,154 +0,0 @@
-#[cfg(feature = "fold")]
-pub mod fold {
- use crate::fold::Fold;
- use crate::punctuated::{Pair, Punctuated};
- use proc_macro2::Span;
-
- pub trait FoldHelper {
- type Item;
- fn lift<F>(self, f: F) -> Self
- where
- F: FnMut(Self::Item) -> Self::Item;
- }
-
- impl<T> FoldHelper for Vec<T> {
- type Item = T;
- fn lift<F>(self, f: F) -> Self
- where
- F: FnMut(Self::Item) -> Self::Item,
- {
- self.into_iter().map(f).collect()
- }
- }
-
- impl<T, U> FoldHelper for Punctuated<T, U> {
- type Item = T;
- fn lift<F>(self, mut f: F) -> Self
- where
- F: FnMut(Self::Item) -> Self::Item,
- {
- self.into_pairs()
- .map(Pair::into_tuple)
- .map(|(t, u)| Pair::new(f(t), u))
- .collect()
- }
- }
-
- pub fn tokens_helper<F: Fold + ?Sized, S: Spans>(folder: &mut F, spans: &S) -> S {
- spans.fold(folder)
- }
-
- pub trait Spans {
- fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self;
- }
-
- impl Spans for Span {
- fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self {
- folder.fold_span(*self)
- }
- }
-
- impl Spans for [Span; 1] {
- fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self {
- [folder.fold_span(self[0])]
- }
- }
-
- impl Spans for [Span; 2] {
- fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self {
- [folder.fold_span(self[0]), folder.fold_span(self[1])]
- }
- }
-
- impl Spans for [Span; 3] {
- fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self {
- [
- folder.fold_span(self[0]),
- folder.fold_span(self[1]),
- folder.fold_span(self[2]),
- ]
- }
- }
-}
-
-#[cfg(feature = "visit")]
-pub mod visit {
- use crate::visit::Visit;
- use proc_macro2::Span;
-
- pub fn tokens_helper<'ast, V: Visit<'ast> + ?Sized, S: Spans>(visitor: &mut V, spans: &S) {
- spans.visit(visitor);
- }
-
- pub trait Spans {
- fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V);
- }
-
- impl Spans for Span {
- fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) {
- visitor.visit_span(self);
- }
- }
-
- impl Spans for [Span; 1] {
- fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) {
- visitor.visit_span(&self[0]);
- }
- }
-
- impl Spans for [Span; 2] {
- fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) {
- visitor.visit_span(&self[0]);
- visitor.visit_span(&self[1]);
- }
- }
-
- impl Spans for [Span; 3] {
- fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) {
- visitor.visit_span(&self[0]);
- visitor.visit_span(&self[1]);
- visitor.visit_span(&self[2]);
- }
- }
-}
-
-#[cfg(feature = "visit-mut")]
-pub mod visit_mut {
- use crate::visit_mut::VisitMut;
- use proc_macro2::Span;
-
- pub fn tokens_helper<V: VisitMut + ?Sized, S: Spans>(visitor: &mut V, spans: &mut S) {
- spans.visit_mut(visitor);
- }
-
- pub trait Spans {
- fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V);
- }
-
- impl Spans for Span {
- fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) {
- visitor.visit_span_mut(self);
- }
- }
-
- impl Spans for [Span; 1] {
- fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) {
- visitor.visit_span_mut(&mut self[0]);
- }
- }
-
- impl Spans for [Span; 2] {
- fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) {
- visitor.visit_span_mut(&mut self[0]);
- visitor.visit_span_mut(&mut self[1]);
- }
- }
-
- impl Spans for [Span; 3] {
- fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) {
- visitor.visit_span_mut(&mut self[0]);
- visitor.visit_span_mut(&mut self[1]);
- visitor.visit_span_mut(&mut self[2]);
- }
- }
-}
diff --git a/syn/src/generics.rs b/syn/src/generics.rs
deleted file mode 100644
index 9feeab9..0000000
--- a/syn/src/generics.rs
+++ /dev/null
@@ -1,1152 +0,0 @@
-use super::*;
-use crate::punctuated::{Iter, IterMut, Punctuated};
-
-ast_struct! {
- /// Lifetimes and type parameters attached to a declaration of a function,
- /// enum, trait, etc.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- #[derive(Default)]
- pub struct Generics {
- pub lt_token: Option<Token![<]>,
- pub params: Punctuated<GenericParam, Token![,]>,
- pub gt_token: Option<Token![>]>,
- pub where_clause: Option<WhereClause>,
- }
-}
-
-ast_enum_of_structs! {
- /// A generic type parameter, lifetime, or const generic: `T: Into<String>`,
- /// `'a: 'b`, `const LEN: usize`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- pub enum GenericParam {
- /// A generic type parameter: `T: Into<String>`.
- Type(TypeParam),
-
- /// A lifetime definition: `'a: 'b + 'c + 'd`.
- Lifetime(LifetimeDef),
-
- /// A const generic parameter: `const LENGTH: usize`.
- Const(ConstParam),
- }
-}
-
-ast_struct! {
- /// A generic type parameter: `T: Into<String>`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeParam {
- pub attrs: Vec<Attribute>,
- pub ident: Ident,
- pub colon_token: Option<Token![:]>,
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- pub eq_token: Option<Token![=]>,
- pub default: Option<Type>,
- }
-}
-
-ast_struct! {
- /// A lifetime definition: `'a: 'b + 'c + 'd`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LifetimeDef {
- pub attrs: Vec<Attribute>,
- pub lifetime: Lifetime,
- pub colon_token: Option<Token![:]>,
- pub bounds: Punctuated<Lifetime, Token![+]>,
- }
-}
-
-ast_struct! {
- /// A const generic parameter: `const LENGTH: usize`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct ConstParam {
- pub attrs: Vec<Attribute>,
- pub const_token: Token![const],
- pub ident: Ident,
- pub colon_token: Token![:],
- pub ty: Type,
- pub eq_token: Option<Token![=]>,
- pub default: Option<Expr>,
- }
-}
-
-impl Generics {
- /// Returns an
- /// <code
- /// style="padding-right:0;">Iterator&lt;Item = &amp;</code><a
- /// href="struct.TypeParam.html"><code
- /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code
- /// style="padding-left:0;">&gt;</code>
- /// over the type parameters in `self.params`.
- pub fn type_params(&self) -> TypeParams {
- TypeParams(self.params.iter())
- }
-
- /// Returns an
- /// <code
- /// style="padding-right:0;">Iterator&lt;Item = &amp;mut </code><a
- /// href="struct.TypeParam.html"><code
- /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code
- /// style="padding-left:0;">&gt;</code>
- /// over the type parameters in `self.params`.
- pub fn type_params_mut(&mut self) -> TypeParamsMut {
- TypeParamsMut(self.params.iter_mut())
- }
-
- /// Returns an
- /// <code
- /// style="padding-right:0;">Iterator&lt;Item = &amp;</code><a
- /// href="struct.LifetimeDef.html"><code
- /// style="padding-left:0;padding-right:0;">LifetimeDef</code></a><code
- /// style="padding-left:0;">&gt;</code>
- /// over the lifetime parameters in `self.params`.
- pub fn lifetimes(&self) -> Lifetimes {
- Lifetimes(self.params.iter())
- }
-
- /// Returns an
- /// <code
- /// style="padding-right:0;">Iterator&lt;Item = &amp;mut </code><a
- /// href="struct.LifetimeDef.html"><code
- /// style="padding-left:0;padding-right:0;">LifetimeDef</code></a><code
- /// style="padding-left:0;">&gt;</code>
- /// over the lifetime parameters in `self.params`.
- pub fn lifetimes_mut(&mut self) -> LifetimesMut {
- LifetimesMut(self.params.iter_mut())
- }
-
- /// Returns an
- /// <code
- /// style="padding-right:0;">Iterator&lt;Item = &amp;</code><a
- /// href="struct.ConstParam.html"><code
- /// style="padding-left:0;padding-right:0;">ConstParam</code></a><code
- /// style="padding-left:0;">&gt;</code>
- /// over the constant parameters in `self.params`.
- pub fn const_params(&self) -> ConstParams {
- ConstParams(self.params.iter())
- }
-
- /// Returns an
- /// <code
- /// style="padding-right:0;">Iterator&lt;Item = &amp;mut </code><a
- /// href="struct.ConstParam.html"><code
- /// style="padding-left:0;padding-right:0;">ConstParam</code></a><code
- /// style="padding-left:0;">&gt;</code>
- /// over the constant parameters in `self.params`.
- pub fn const_params_mut(&mut self) -> ConstParamsMut {
- ConstParamsMut(self.params.iter_mut())
- }
-
- /// Initializes an empty `where`-clause if there is not one present already.
- pub fn make_where_clause(&mut self) -> &mut WhereClause {
- // This is Option::get_or_insert_with in Rust 1.20.
- if self.where_clause.is_none() {
- self.where_clause = Some(WhereClause {
- where_token: <Token![where]>::default(),
- predicates: Punctuated::new(),
- });
- }
- match &mut self.where_clause {
- Some(where_clause) => where_clause,
- None => unreachable!(),
- }
- }
-}
-
-pub struct TypeParams<'a>(Iter<'a, GenericParam>);
-
-impl<'a> Iterator for TypeParams<'a> {
- type Item = &'a TypeParam;
-
- fn next(&mut self) -> Option<Self::Item> {
- let next = match self.0.next() {
- Some(item) => item,
- None => return None,
- };
- if let GenericParam::Type(type_param) = next {
- Some(type_param)
- } else {
- self.next()
- }
- }
-}
-
-pub struct TypeParamsMut<'a>(IterMut<'a, GenericParam>);
-
-impl<'a> Iterator for TypeParamsMut<'a> {
- type Item = &'a mut TypeParam;
-
- fn next(&mut self) -> Option<Self::Item> {
- let next = match self.0.next() {
- Some(item) => item,
- None => return None,
- };
- if let GenericParam::Type(type_param) = next {
- Some(type_param)
- } else {
- self.next()
- }
- }
-}
-
-pub struct Lifetimes<'a>(Iter<'a, GenericParam>);
-
-impl<'a> Iterator for Lifetimes<'a> {
- type Item = &'a LifetimeDef;
-
- fn next(&mut self) -> Option<Self::Item> {
- let next = match self.0.next() {
- Some(item) => item,
- None => return None,
- };
- if let GenericParam::Lifetime(lifetime) = next {
- Some(lifetime)
- } else {
- self.next()
- }
- }
-}
-
-pub struct LifetimesMut<'a>(IterMut<'a, GenericParam>);
-
-impl<'a> Iterator for LifetimesMut<'a> {
- type Item = &'a mut LifetimeDef;
-
- fn next(&mut self) -> Option<Self::Item> {
- let next = match self.0.next() {
- Some(item) => item,
- None => return None,
- };
- if let GenericParam::Lifetime(lifetime) = next {
- Some(lifetime)
- } else {
- self.next()
- }
- }
-}
-
-pub struct ConstParams<'a>(Iter<'a, GenericParam>);
-
-impl<'a> Iterator for ConstParams<'a> {
- type Item = &'a ConstParam;
-
- fn next(&mut self) -> Option<Self::Item> {
- let next = match self.0.next() {
- Some(item) => item,
- None => return None,
- };
- if let GenericParam::Const(const_param) = next {
- Some(const_param)
- } else {
- self.next()
- }
- }
-}
-
-pub struct ConstParamsMut<'a>(IterMut<'a, GenericParam>);
-
-impl<'a> Iterator for ConstParamsMut<'a> {
- type Item = &'a mut ConstParam;
-
- fn next(&mut self) -> Option<Self::Item> {
- let next = match self.0.next() {
- Some(item) => item,
- None => return None,
- };
- if let GenericParam::Const(const_param) = next {
- Some(const_param)
- } else {
- self.next()
- }
- }
-}
-
-/// Returned by `Generics::split_for_impl`.
-///
-/// *This type is available if Syn is built with the `"derive"` or `"full"`
-/// feature and the `"printing"` feature.*
-#[cfg(feature = "printing")]
-#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-pub struct ImplGenerics<'a>(&'a Generics);
-
-/// Returned by `Generics::split_for_impl`.
-///
-/// *This type is available if Syn is built with the `"derive"` or `"full"`
-/// feature and the `"printing"` feature.*
-#[cfg(feature = "printing")]
-#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-pub struct TypeGenerics<'a>(&'a Generics);
-
-/// Returned by `TypeGenerics::as_turbofish`.
-///
-/// *This type is available if Syn is built with the `"derive"` or `"full"`
-/// feature and the `"printing"` feature.*
-#[cfg(feature = "printing")]
-#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-pub struct Turbofish<'a>(&'a Generics);
-
-#[cfg(feature = "printing")]
-impl Generics {
- /// Split a type's generics into the pieces required for impl'ing a trait
- /// for that type.
- ///
- /// ```
- /// # use proc_macro2::{Span, Ident};
- /// # use quote::quote;
- /// #
- /// # let generics: syn::Generics = Default::default();
- /// # let name = Ident::new("MyType", Span::call_site());
- /// #
- /// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
- /// quote! {
- /// impl #impl_generics MyTrait for #name #ty_generics #where_clause {
- /// // ...
- /// }
- /// }
- /// # ;
- /// ```
- ///
- /// *This method is available if Syn is built with the `"derive"` or
- /// `"full"` feature and the `"printing"` feature.*
- pub fn split_for_impl(&self) -> (ImplGenerics, TypeGenerics, Option<&WhereClause>) {
- (
- ImplGenerics(self),
- TypeGenerics(self),
- self.where_clause.as_ref(),
- )
- }
-}
-
-#[cfg(feature = "printing")]
-impl<'a> TypeGenerics<'a> {
- /// Turn a type's generics like `<X, Y>` into a turbofish like `::<X, Y>`.
- ///
- /// *This method is available if Syn is built with the `"derive"` or
- /// `"full"` feature and the `"printing"` feature.*
- pub fn as_turbofish(&self) -> Turbofish {
- Turbofish(self.0)
- }
-}
-
-ast_struct! {
- /// A set of bound lifetimes: `for<'a, 'b, 'c>`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- #[derive(Default)]
- pub struct BoundLifetimes {
- pub for_token: Token![for],
- pub lt_token: Token![<],
- pub lifetimes: Punctuated<LifetimeDef, Token![,]>,
- pub gt_token: Token![>],
- }
-}
-
-impl LifetimeDef {
- pub fn new(lifetime: Lifetime) -> Self {
- LifetimeDef {
- attrs: Vec::new(),
- lifetime,
- colon_token: None,
- bounds: Punctuated::new(),
- }
- }
-}
-
-impl From<Ident> for TypeParam {
- fn from(ident: Ident) -> Self {
- TypeParam {
- attrs: vec![],
- ident,
- colon_token: None,
- bounds: Punctuated::new(),
- eq_token: None,
- default: None,
- }
- }
-}
-
-ast_enum_of_structs! {
- /// A trait or lifetime used as a bound on a type parameter.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub enum TypeParamBound {
- Trait(TraitBound),
- Lifetime(Lifetime),
- }
-}
-
-ast_struct! {
- /// A trait used as a bound on a type parameter.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct TraitBound {
- pub paren_token: Option<token::Paren>,
- pub modifier: TraitBoundModifier,
- /// The `for<'a>` in `for<'a> Foo<&'a T>`
- pub lifetimes: Option<BoundLifetimes>,
- /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>`
- pub path: Path,
- }
-}
-
-ast_enum! {
- /// A modifier on a trait bound, currently only used for the `?` in
- /// `?Sized`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- #[cfg_attr(feature = "clone-impls", derive(Copy))]
- pub enum TraitBoundModifier {
- None,
- Maybe(Token![?]),
- }
-}
-
-ast_struct! {
- /// A `where` clause in a definition: `where T: Deserialize<'de>, D:
- /// 'static`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct WhereClause {
- pub where_token: Token![where],
- pub predicates: Punctuated<WherePredicate, Token![,]>,
- }
-}
-
-ast_enum_of_structs! {
- /// A single predicate in a `where` clause: `T: Deserialize<'de>`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- pub enum WherePredicate {
- /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
- Type(PredicateType),
-
- /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
- Lifetime(PredicateLifetime),
-
- /// An equality predicate in a `where` clause (unsupported).
- Eq(PredicateEq),
- }
-}
-
-ast_struct! {
- /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct PredicateType {
- /// Any lifetimes from a `for` binding
- pub lifetimes: Option<BoundLifetimes>,
- /// The type being bounded
- pub bounded_ty: Type,
- pub colon_token: Token![:],
- /// Trait and lifetime bounds (`Clone+Send+'static`)
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- }
-}
-
-ast_struct! {
- /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct PredicateLifetime {
- pub lifetime: Lifetime,
- pub colon_token: Token![:],
- pub bounds: Punctuated<Lifetime, Token![+]>,
- }
-}
-
-ast_struct! {
- /// An equality predicate in a `where` clause (unsupported).
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct PredicateEq {
- pub lhs_ty: Type,
- pub eq_token: Token![=],
- pub rhs_ty: Type,
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for Generics {
- fn parse(input: ParseStream) -> Result<Self> {
- if !input.peek(Token![<]) {
- return Ok(Generics::default());
- }
-
- let lt_token: Token![<] = input.parse()?;
-
- let mut params = Punctuated::new();
- let mut allow_lifetime_param = true;
- let mut allow_type_param = true;
- loop {
- if input.peek(Token![>]) {
- break;
- }
-
- let attrs = input.call(Attribute::parse_outer)?;
- let lookahead = input.lookahead1();
- if allow_lifetime_param && lookahead.peek(Lifetime) {
- params.push_value(GenericParam::Lifetime(LifetimeDef {
- attrs,
- ..input.parse()?
- }));
- } else if allow_type_param && lookahead.peek(Ident) {
- allow_lifetime_param = false;
- params.push_value(GenericParam::Type(TypeParam {
- attrs,
- ..input.parse()?
- }));
- } else if lookahead.peek(Token![const]) {
- allow_lifetime_param = false;
- allow_type_param = false;
- params.push_value(GenericParam::Const(ConstParam {
- attrs,
- ..input.parse()?
- }));
- } else {
- return Err(lookahead.error());
- }
-
- if input.peek(Token![>]) {
- break;
- }
- let punct = input.parse()?;
- params.push_punct(punct);
- }
-
- let gt_token: Token![>] = input.parse()?;
-
- Ok(Generics {
- lt_token: Some(lt_token),
- params,
- gt_token: Some(gt_token),
- where_clause: None,
- })
- }
- }
-
- impl Parse for GenericParam {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
-
- let lookahead = input.lookahead1();
- if lookahead.peek(Ident) {
- Ok(GenericParam::Type(TypeParam {
- attrs,
- ..input.parse()?
- }))
- } else if lookahead.peek(Lifetime) {
- Ok(GenericParam::Lifetime(LifetimeDef {
- attrs,
- ..input.parse()?
- }))
- } else if lookahead.peek(Token![const]) {
- Ok(GenericParam::Const(ConstParam {
- attrs,
- ..input.parse()?
- }))
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- impl Parse for LifetimeDef {
- fn parse(input: ParseStream) -> Result<Self> {
- let has_colon;
- Ok(LifetimeDef {
- attrs: input.call(Attribute::parse_outer)?,
- lifetime: input.parse()?,
- colon_token: {
- if input.peek(Token![:]) {
- has_colon = true;
- Some(input.parse()?)
- } else {
- has_colon = false;
- None
- }
- },
- bounds: {
- let mut bounds = Punctuated::new();
- if has_colon {
- loop {
- if input.peek(Token![,]) || input.peek(Token![>]) {
- break;
- }
- let value = input.parse()?;
- bounds.push_value(value);
- if !input.peek(Token![+]) {
- break;
- }
- let punct = input.parse()?;
- bounds.push_punct(punct);
- }
- }
- bounds
- },
- })
- }
- }
-
- impl Parse for BoundLifetimes {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(BoundLifetimes {
- for_token: input.parse()?,
- lt_token: input.parse()?,
- lifetimes: {
- let mut lifetimes = Punctuated::new();
- while !input.peek(Token![>]) {
- lifetimes.push_value(input.parse()?);
- if input.peek(Token![>]) {
- break;
- }
- lifetimes.push_punct(input.parse()?);
- }
- lifetimes
- },
- gt_token: input.parse()?,
- })
- }
- }
-
- impl Parse for Option<BoundLifetimes> {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![for]) {
- input.parse().map(Some)
- } else {
- Ok(None)
- }
- }
- }
-
- impl Parse for TypeParam {
- fn parse(input: ParseStream) -> Result<Self> {
- let has_colon;
- let has_default;
- Ok(TypeParam {
- attrs: input.call(Attribute::parse_outer)?,
- ident: input.parse()?,
- colon_token: {
- if input.peek(Token![:]) {
- has_colon = true;
- Some(input.parse()?)
- } else {
- has_colon = false;
- None
- }
- },
- bounds: {
- let mut bounds = Punctuated::new();
- if has_colon {
- loop {
- if input.peek(Token![,])
- || input.peek(Token![>])
- || input.peek(Token![=])
- {
- break;
- }
- let value = input.parse()?;
- bounds.push_value(value);
- if !input.peek(Token![+]) {
- break;
- }
- let punct = input.parse()?;
- bounds.push_punct(punct);
- }
- }
- bounds
- },
- eq_token: {
- if input.peek(Token![=]) {
- has_default = true;
- Some(input.parse()?)
- } else {
- has_default = false;
- None
- }
- },
- default: {
- if has_default {
- Some(input.parse()?)
- } else {
- None
- }
- },
- })
- }
- }
-
- impl Parse for TypeParamBound {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Lifetime) {
- return input.parse().map(TypeParamBound::Lifetime);
- }
-
- if input.peek(token::Paren) {
- let content;
- let paren_token = parenthesized!(content in input);
- let mut bound: TraitBound = content.parse()?;
- bound.paren_token = Some(paren_token);
- return Ok(TypeParamBound::Trait(bound));
- }
-
- input.parse().map(TypeParamBound::Trait)
- }
- }
-
- impl Parse for TraitBound {
- fn parse(input: ParseStream) -> Result<Self> {
- let modifier: TraitBoundModifier = input.parse()?;
- let lifetimes: Option<BoundLifetimes> = input.parse()?;
-
- let mut path: Path = input.parse()?;
- if path.segments.last().unwrap().arguments.is_empty() && input.peek(token::Paren) {
- let parenthesized = PathArguments::Parenthesized(input.parse()?);
- path.segments.last_mut().unwrap().arguments = parenthesized;
- }
-
- Ok(TraitBound {
- paren_token: None,
- modifier,
- lifetimes,
- path,
- })
- }
- }
-
- impl Parse for TraitBoundModifier {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![?]) {
- input.parse().map(TraitBoundModifier::Maybe)
- } else {
- Ok(TraitBoundModifier::None)
- }
- }
- }
-
- impl Parse for ConstParam {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut default = None;
- Ok(ConstParam {
- attrs: input.call(Attribute::parse_outer)?,
- const_token: input.parse()?,
- ident: input.parse()?,
- colon_token: input.parse()?,
- ty: input.parse()?,
- eq_token: {
- if input.peek(Token![=]) {
- let eq_token = input.parse()?;
- default = Some(input.parse::<Expr>()?);
- Some(eq_token)
- } else {
- None
- }
- },
- default,
- })
- }
- }
-
- impl Parse for WhereClause {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(WhereClause {
- where_token: input.parse()?,
- predicates: {
- let mut predicates = Punctuated::new();
- loop {
- if input.is_empty()
- || input.peek(token::Brace)
- || input.peek(Token![,])
- || input.peek(Token![;])
- || input.peek(Token![:]) && !input.peek(Token![::])
- || input.peek(Token![=])
- {
- break;
- }
- let value = input.parse()?;
- predicates.push_value(value);
- if !input.peek(Token![,]) {
- break;
- }
- let punct = input.parse()?;
- predicates.push_punct(punct);
- }
- predicates
- },
- })
- }
- }
-
- impl Parse for Option<WhereClause> {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![where]) {
- input.parse().map(Some)
- } else {
- Ok(None)
- }
- }
- }
-
- impl Parse for WherePredicate {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Lifetime) && input.peek2(Token![:]) {
- Ok(WherePredicate::Lifetime(PredicateLifetime {
- lifetime: input.parse()?,
- colon_token: input.parse()?,
- bounds: {
- let mut bounds = Punctuated::new();
- loop {
- if input.is_empty()
- || input.peek(token::Brace)
- || input.peek(Token![,])
- || input.peek(Token![;])
- || input.peek(Token![:])
- || input.peek(Token![=])
- {
- break;
- }
- let value = input.parse()?;
- bounds.push_value(value);
- if !input.peek(Token![+]) {
- break;
- }
- let punct = input.parse()?;
- bounds.push_punct(punct);
- }
- bounds
- },
- }))
- } else {
- Ok(WherePredicate::Type(PredicateType {
- lifetimes: input.parse()?,
- bounded_ty: input.parse()?,
- colon_token: input.parse()?,
- bounds: {
- let mut bounds = Punctuated::new();
- loop {
- if input.is_empty()
- || input.peek(token::Brace)
- || input.peek(Token![,])
- || input.peek(Token![;])
- || input.peek(Token![:]) && !input.peek(Token![::])
- || input.peek(Token![=])
- {
- break;
- }
- let value = input.parse()?;
- bounds.push_value(value);
- if !input.peek(Token![+]) {
- break;
- }
- let punct = input.parse()?;
- bounds.push_punct(punct);
- }
- bounds
- },
- }))
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use crate::attr::FilterAttrs;
- use crate::print::TokensOrDefault;
-
- impl ToTokens for Generics {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if self.params.is_empty() {
- return;
- }
-
- TokensOrDefault(&self.lt_token).to_tokens(tokens);
-
- // Print lifetimes before types and consts, regardless of their
- // order in self.params.
- //
- // TODO: ordering rules for const parameters vs type parameters have
- // not been settled yet. https://github.com/rust-lang/rust/issues/44580
- let mut trailing_or_empty = true;
- for param in self.params.pairs() {
- if let GenericParam::Lifetime(_) = **param.value() {
- param.to_tokens(tokens);
- trailing_or_empty = param.punct().is_some();
- }
- }
- for param in self.params.pairs() {
- match **param.value() {
- GenericParam::Type(_) | GenericParam::Const(_) => {
- if !trailing_or_empty {
- <Token![,]>::default().to_tokens(tokens);
- trailing_or_empty = true;
- }
- param.to_tokens(tokens);
- }
- GenericParam::Lifetime(_) => {}
- }
- }
-
- TokensOrDefault(&self.gt_token).to_tokens(tokens);
- }
- }
-
- impl<'a> ToTokens for ImplGenerics<'a> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if self.0.params.is_empty() {
- return;
- }
-
- TokensOrDefault(&self.0.lt_token).to_tokens(tokens);
-
- // Print lifetimes before types and consts, regardless of their
- // order in self.params.
- //
- // TODO: ordering rules for const parameters vs type parameters have
- // not been settled yet. https://github.com/rust-lang/rust/issues/44580
- let mut trailing_or_empty = true;
- for param in self.0.params.pairs() {
- if let GenericParam::Lifetime(_) = **param.value() {
- param.to_tokens(tokens);
- trailing_or_empty = param.punct().is_some();
- }
- }
- for param in self.0.params.pairs() {
- if let GenericParam::Lifetime(_) = **param.value() {
- continue;
- }
- if !trailing_or_empty {
- <Token![,]>::default().to_tokens(tokens);
- trailing_or_empty = true;
- }
- match *param.value() {
- GenericParam::Lifetime(_) => unreachable!(),
- GenericParam::Type(param) => {
- // Leave off the type parameter defaults
- tokens.append_all(param.attrs.outer());
- param.ident.to_tokens(tokens);
- if !param.bounds.is_empty() {
- TokensOrDefault(&param.colon_token).to_tokens(tokens);
- param.bounds.to_tokens(tokens);
- }
- }
- GenericParam::Const(param) => {
- // Leave off the const parameter defaults
- tokens.append_all(param.attrs.outer());
- param.const_token.to_tokens(tokens);
- param.ident.to_tokens(tokens);
- param.colon_token.to_tokens(tokens);
- param.ty.to_tokens(tokens);
- }
- }
- param.punct().to_tokens(tokens);
- }
-
- TokensOrDefault(&self.0.gt_token).to_tokens(tokens);
- }
- }
-
- impl<'a> ToTokens for TypeGenerics<'a> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if self.0.params.is_empty() {
- return;
- }
-
- TokensOrDefault(&self.0.lt_token).to_tokens(tokens);
-
- // Print lifetimes before types and consts, regardless of their
- // order in self.params.
- //
- // TODO: ordering rules for const parameters vs type parameters have
- // not been settled yet. https://github.com/rust-lang/rust/issues/44580
- let mut trailing_or_empty = true;
- for param in self.0.params.pairs() {
- if let GenericParam::Lifetime(def) = *param.value() {
- // Leave off the lifetime bounds and attributes
- def.lifetime.to_tokens(tokens);
- param.punct().to_tokens(tokens);
- trailing_or_empty = param.punct().is_some();
- }
- }
- for param in self.0.params.pairs() {
- if let GenericParam::Lifetime(_) = **param.value() {
- continue;
- }
- if !trailing_or_empty {
- <Token![,]>::default().to_tokens(tokens);
- trailing_or_empty = true;
- }
- match *param.value() {
- GenericParam::Lifetime(_) => unreachable!(),
- GenericParam::Type(param) => {
- // Leave off the type parameter defaults
- param.ident.to_tokens(tokens);
- }
- GenericParam::Const(param) => {
- // Leave off the const parameter defaults
- param.ident.to_tokens(tokens);
- }
- }
- param.punct().to_tokens(tokens);
- }
-
- TokensOrDefault(&self.0.gt_token).to_tokens(tokens);
- }
- }
-
- impl<'a> ToTokens for Turbofish<'a> {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if !self.0.params.is_empty() {
- <Token![::]>::default().to_tokens(tokens);
- TypeGenerics(self.0).to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for BoundLifetimes {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.for_token.to_tokens(tokens);
- self.lt_token.to_tokens(tokens);
- self.lifetimes.to_tokens(tokens);
- self.gt_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LifetimeDef {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.lifetime.to_tokens(tokens);
- if !self.bounds.is_empty() {
- TokensOrDefault(&self.colon_token).to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for TypeParam {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.ident.to_tokens(tokens);
- if !self.bounds.is_empty() {
- TokensOrDefault(&self.colon_token).to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- if self.default.is_some() {
- TokensOrDefault(&self.eq_token).to_tokens(tokens);
- self.default.to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for TraitBound {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- let to_tokens = |tokens: &mut TokenStream| {
- self.modifier.to_tokens(tokens);
- self.lifetimes.to_tokens(tokens);
- self.path.to_tokens(tokens);
- };
- match &self.paren_token {
- Some(paren) => paren.surround(tokens, to_tokens),
- None => to_tokens(tokens),
- }
- }
- }
-
- impl ToTokens for TraitBoundModifier {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- TraitBoundModifier::None => {}
- TraitBoundModifier::Maybe(t) => t.to_tokens(tokens),
- }
- }
- }
-
- impl ToTokens for ConstParam {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.const_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- if self.default.is_some() {
- TokensOrDefault(&self.eq_token).to_tokens(tokens);
- self.default.to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for WhereClause {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- if !self.predicates.is_empty() {
- self.where_token.to_tokens(tokens);
- self.predicates.to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for PredicateType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.lifetimes.to_tokens(tokens);
- self.bounded_ty.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PredicateLifetime {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.lifetime.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PredicateEq {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.lhs_ty.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.rhs_ty.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/group.rs b/syn/src/group.rs
deleted file mode 100644
index ed5b151..0000000
--- a/syn/src/group.rs
+++ /dev/null
@@ -1,280 +0,0 @@
-use proc_macro2::{Delimiter, Span};
-
-use crate::error::Result;
-use crate::parse::ParseBuffer;
-use crate::token;
-
-// Not public API.
-#[doc(hidden)]
-pub struct Parens<'a> {
- pub token: token::Paren,
- pub content: ParseBuffer<'a>,
-}
-
-// Not public API.
-#[doc(hidden)]
-pub struct Braces<'a> {
- pub token: token::Brace,
- pub content: ParseBuffer<'a>,
-}
-
-// Not public API.
-#[doc(hidden)]
-pub struct Brackets<'a> {
- pub token: token::Bracket,
- pub content: ParseBuffer<'a>,
-}
-
-// Not public API.
-#[cfg(any(feature = "full", feature = "derive"))]
-#[doc(hidden)]
-pub struct Group<'a> {
- pub token: token::Group,
- pub content: ParseBuffer<'a>,
-}
-
-// Not public API.
-#[doc(hidden)]
-pub fn parse_parens<'a>(input: &ParseBuffer<'a>) -> Result<Parens<'a>> {
- parse_delimited(input, Delimiter::Parenthesis).map(|(span, content)| Parens {
- token: token::Paren(span),
- content,
- })
-}
-
-// Not public API.
-#[doc(hidden)]
-pub fn parse_braces<'a>(input: &ParseBuffer<'a>) -> Result<Braces<'a>> {
- parse_delimited(input, Delimiter::Brace).map(|(span, content)| Braces {
- token: token::Brace(span),
- content,
- })
-}
-
-// Not public API.
-#[doc(hidden)]
-pub fn parse_brackets<'a>(input: &ParseBuffer<'a>) -> Result<Brackets<'a>> {
- parse_delimited(input, Delimiter::Bracket).map(|(span, content)| Brackets {
- token: token::Bracket(span),
- content,
- })
-}
-
-#[cfg(any(feature = "full", feature = "derive"))]
-pub(crate) fn parse_group<'a>(input: &ParseBuffer<'a>) -> Result<Group<'a>> {
- parse_delimited(input, Delimiter::None).map(|(span, content)| Group {
- token: token::Group(span),
- content,
- })
-}
-
-fn parse_delimited<'a>(
- input: &ParseBuffer<'a>,
- delimiter: Delimiter,
-) -> Result<(Span, ParseBuffer<'a>)> {
- input.step(|cursor| {
- if let Some((content, span, rest)) = cursor.group(delimiter) {
- let scope = crate::buffer::close_span_of_group(*cursor);
- let nested = crate::parse::advance_step_cursor(cursor, content);
- let unexpected = crate::parse::get_unexpected(input);
- let content = crate::parse::new_parse_buffer(scope, nested, unexpected);
- Ok(((span, content), rest))
- } else {
- let message = match delimiter {
- Delimiter::Parenthesis => "expected parentheses",
- Delimiter::Brace => "expected curly braces",
- Delimiter::Bracket => "expected square brackets",
- Delimiter::None => "expected invisible group",
- };
- Err(cursor.error(message))
- }
- })
-}
-
-/// Parse a set of parentheses and expose their content to subsequent parsers.
-///
-/// # Example
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// use syn::{parenthesized, token, Ident, Result, Token, Type};
-/// use syn::parse::{Parse, ParseStream};
-/// use syn::punctuated::Punctuated;
-///
-/// // Parse a simplified tuple struct syntax like:
-/// //
-/// // struct S(A, B);
-/// struct TupleStruct {
-/// struct_token: Token![struct],
-/// ident: Ident,
-/// paren_token: token::Paren,
-/// fields: Punctuated<Type, Token![,]>,
-/// semi_token: Token![;],
-/// }
-///
-/// impl Parse for TupleStruct {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// let content;
-/// Ok(TupleStruct {
-/// struct_token: input.parse()?,
-/// ident: input.parse()?,
-/// paren_token: parenthesized!(content in input),
-/// fields: content.parse_terminated(Type::parse)?,
-/// semi_token: input.parse()?,
-/// })
-/// }
-/// }
-/// #
-/// # fn main() {
-/// # let input = quote! {
-/// # struct S(A, B);
-/// # };
-/// # syn::parse2::<TupleStruct>(input).unwrap();
-/// # }
-/// ```
-#[macro_export]
-macro_rules! parenthesized {
- ($content:ident in $cursor:expr) => {
- match $crate::group::parse_parens(&$cursor) {
- $crate::export::Ok(parens) => {
- $content = parens.content;
- parens.token
- }
- $crate::export::Err(error) => {
- return $crate::export::Err(error);
- }
- }
- };
-}
-
-/// Parse a set of curly braces and expose their content to subsequent parsers.
-///
-/// # Example
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// use syn::{braced, token, Ident, Result, Token, Type};
-/// use syn::parse::{Parse, ParseStream};
-/// use syn::punctuated::Punctuated;
-///
-/// // Parse a simplified struct syntax like:
-/// //
-/// // struct S {
-/// // a: A,
-/// // b: B,
-/// // }
-/// struct Struct {
-/// struct_token: Token![struct],
-/// ident: Ident,
-/// brace_token: token::Brace,
-/// fields: Punctuated<Field, Token![,]>,
-/// }
-///
-/// struct Field {
-/// name: Ident,
-/// colon_token: Token![:],
-/// ty: Type,
-/// }
-///
-/// impl Parse for Struct {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// let content;
-/// Ok(Struct {
-/// struct_token: input.parse()?,
-/// ident: input.parse()?,
-/// brace_token: braced!(content in input),
-/// fields: content.parse_terminated(Field::parse)?,
-/// })
-/// }
-/// }
-///
-/// impl Parse for Field {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// Ok(Field {
-/// name: input.parse()?,
-/// colon_token: input.parse()?,
-/// ty: input.parse()?,
-/// })
-/// }
-/// }
-/// #
-/// # fn main() {
-/// # let input = quote! {
-/// # struct S {
-/// # a: A,
-/// # b: B,
-/// # }
-/// # };
-/// # syn::parse2::<Struct>(input).unwrap();
-/// # }
-/// ```
-#[macro_export]
-macro_rules! braced {
- ($content:ident in $cursor:expr) => {
- match $crate::group::parse_braces(&$cursor) {
- $crate::export::Ok(braces) => {
- $content = braces.content;
- braces.token
- }
- $crate::export::Err(error) => {
- return $crate::export::Err(error);
- }
- }
- };
-}
-
-/// Parse a set of square brackets and expose their content to subsequent
-/// parsers.
-///
-/// # Example
-///
-/// ```
-/// # use quote::quote;
-/// #
-/// use proc_macro2::TokenStream;
-/// use syn::{bracketed, token, Result, Token};
-/// use syn::parse::{Parse, ParseStream};
-///
-/// // Parse an outer attribute like:
-/// //
-/// // #[repr(C, packed)]
-/// struct OuterAttribute {
-/// pound_token: Token![#],
-/// bracket_token: token::Bracket,
-/// content: TokenStream,
-/// }
-///
-/// impl Parse for OuterAttribute {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// let content;
-/// Ok(OuterAttribute {
-/// pound_token: input.parse()?,
-/// bracket_token: bracketed!(content in input),
-/// content: content.parse()?,
-/// })
-/// }
-/// }
-/// #
-/// # fn main() {
-/// # let input = quote! {
-/// # #[repr(C, packed)]
-/// # };
-/// # syn::parse2::<OuterAttribute>(input).unwrap();
-/// # }
-/// ```
-#[macro_export]
-macro_rules! bracketed {
- ($content:ident in $cursor:expr) => {
- match $crate::group::parse_brackets(&$cursor) {
- $crate::export::Ok(brackets) => {
- $content = brackets.content;
- brackets.token
- }
- $crate::export::Err(error) => {
- return $crate::export::Err(error);
- }
- }
- };
-}
diff --git a/syn/src/ident.rs b/syn/src/ident.rs
deleted file mode 100644
index 4ca7484..0000000
--- a/syn/src/ident.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-#[cfg(feature = "parsing")]
-use crate::buffer::Cursor;
-#[cfg(feature = "parsing")]
-use crate::lookahead;
-#[cfg(feature = "parsing")]
-use crate::parse::{Parse, ParseStream, Result};
-#[cfg(feature = "parsing")]
-use crate::token::Token;
-use unicode_xid::UnicodeXID;
-
-pub use proc_macro2::Ident;
-
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-#[allow(non_snake_case)]
-pub fn Ident(marker: lookahead::TokenMarker) -> Ident {
- match marker {}
-}
-
-#[cfg(feature = "parsing")]
-fn accept_as_ident(ident: &Ident) -> bool {
- match ident.to_string().as_str() {
- "_" |
- // Based on https://doc.rust-lang.org/grammar.html#keywords
- // and https://github.com/rust-lang/rfcs/blob/master/text/2421-unreservations-2018.md
- // and https://github.com/rust-lang/rfcs/blob/master/text/2420-unreserve-proc.md
- "abstract" | "as" | "become" | "box" | "break" | "const" | "continue" |
- "crate" | "do" | "else" | "enum" | "extern" | "false" | "final" | "fn" |
- "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" |
- "mod" | "move" | "mut" | "override" | "priv" | "pub" | "ref" |
- "return" | "Self" | "self" | "static" | "struct" | "super" | "trait" |
- "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" | "virtual" |
- "where" | "while" | "yield" => false,
- _ => true,
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Parse for Ident {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| {
- if let Some((ident, rest)) = cursor.ident() {
- if accept_as_ident(&ident) {
- return Ok((ident, rest));
- }
- }
- Err(cursor.error("expected identifier"))
- })
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Token for Ident {
- fn peek(cursor: Cursor) -> bool {
- if let Some((ident, _rest)) = cursor.ident() {
- accept_as_ident(&ident)
- } else {
- false
- }
- }
-
- fn display() -> &'static str {
- "identifier"
- }
-}
-
-macro_rules! ident_from_token {
- ($token:ident) => {
- impl From<Token![$token]> for Ident {
- fn from(token: Token![$token]) -> Ident {
- Ident::new(stringify!($token), token.span)
- }
- }
- };
-}
-
-ident_from_token!(self);
-ident_from_token!(Self);
-ident_from_token!(super);
-ident_from_token!(crate);
-ident_from_token!(extern);
-
-impl From<Token![_]> for Ident {
- fn from(token: Token![_]) -> Ident {
- Ident::new("_", token.span)
- }
-}
-
-pub fn xid_ok(symbol: &str) -> bool {
- let mut chars = symbol.chars();
- let first = chars.next().unwrap();
- if !(UnicodeXID::is_xid_start(first) || first == '_') {
- return false;
- }
- for ch in chars {
- if !UnicodeXID::is_xid_continue(ch) {
- return false;
- }
- }
- true
-}
diff --git a/syn/src/item.rs b/syn/src/item.rs
deleted file mode 100644
index 67284a2..0000000
--- a/syn/src/item.rs
+++ /dev/null
@@ -1,3104 +0,0 @@
-use super::*;
-use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput};
-use crate::punctuated::Punctuated;
-use proc_macro2::TokenStream;
-
-#[cfg(feature = "extra-traits")]
-use crate::tt::TokenStreamHelper;
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-#[cfg(feature = "parsing")]
-use std::mem;
-
-ast_enum_of_structs! {
- /// Things that can appear directly inside of a module or scope.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Item #manual_extra_traits {
- /// A constant item: `const MAX: u16 = 65535`.
- Const(ItemConst),
-
- /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
- Enum(ItemEnum),
-
- /// An `extern crate` item: `extern crate serde`.
- ExternCrate(ItemExternCrate),
-
- /// A free-standing function: `fn process(n: usize) -> Result<()> { ...
- /// }`.
- Fn(ItemFn),
-
- /// A block of foreign items: `extern "C" { ... }`.
- ForeignMod(ItemForeignMod),
-
- /// An impl block providing trait or associated items: `impl<A> Trait
- /// for Data<A> { ... }`.
- Impl(ItemImpl),
-
- /// A macro invocation, which includes `macro_rules!` definitions.
- Macro(ItemMacro),
-
- /// A 2.0-style declarative macro introduced by the `macro` keyword.
- Macro2(ItemMacro2),
-
- /// A module or module declaration: `mod m` or `mod m { ... }`.
- Mod(ItemMod),
-
- /// A static item: `static BIKE: Shed = Shed(42)`.
- Static(ItemStatic),
-
- /// A struct definition: `struct Foo<A> { x: A }`.
- Struct(ItemStruct),
-
- /// A trait definition: `pub trait Iterator { ... }`.
- Trait(ItemTrait),
-
- /// A trait alias: `pub trait SharableIterator = Iterator + Sync`.
- TraitAlias(ItemTraitAlias),
-
- /// A type alias: `type Result<T> = std::result::Result<T, MyError>`.
- Type(ItemType),
-
- /// A union definition: `union Foo<A, B> { x: A, y: B }`.
- Union(ItemUnion),
-
- /// A use declaration: `use std::collections::HashMap`.
- Use(ItemUse),
-
- /// Tokens forming an item not interpreted by Syn.
- Verbatim(TokenStream),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// A constant item: `const MAX: u16 = 65535`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemConst {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub const_token: Token![const],
- pub ident: Ident,
- pub colon_token: Token![:],
- pub ty: Box<Type>,
- pub eq_token: Token![=],
- pub expr: Box<Expr>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemEnum {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub enum_token: Token![enum],
- pub ident: Ident,
- pub generics: Generics,
- pub brace_token: token::Brace,
- pub variants: Punctuated<Variant, Token![,]>,
- }
-}
-
-ast_struct! {
- /// An `extern crate` item: `extern crate serde`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemExternCrate {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub extern_token: Token![extern],
- pub crate_token: Token![crate],
- pub ident: Ident,
- pub rename: Option<(Token![as], Ident)>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A free-standing function: `fn process(n: usize) -> Result<()> { ...
- /// }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemFn {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub sig: Signature,
- pub block: Box<Block>,
- }
-}
-
-ast_struct! {
- /// A block of foreign items: `extern "C" { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemForeignMod {
- pub attrs: Vec<Attribute>,
- pub abi: Abi,
- pub brace_token: token::Brace,
- pub items: Vec<ForeignItem>,
- }
-}
-
-ast_struct! {
- /// An impl block providing trait or associated items: `impl<A> Trait
- /// for Data<A> { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemImpl {
- pub attrs: Vec<Attribute>,
- pub defaultness: Option<Token![default]>,
- pub unsafety: Option<Token![unsafe]>,
- pub impl_token: Token![impl],
- pub generics: Generics,
- /// Trait this impl implements.
- pub trait_: Option<(Option<Token![!]>, Path, Token![for])>,
- /// The Self type of the impl.
- pub self_ty: Box<Type>,
- pub brace_token: token::Brace,
- pub items: Vec<ImplItem>,
- }
-}
-
-ast_struct! {
- /// A macro invocation, which includes `macro_rules!` definitions.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemMacro {
- pub attrs: Vec<Attribute>,
- /// The `example` in `macro_rules! example { ... }`.
- pub ident: Option<Ident>,
- pub mac: Macro,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-ast_struct! {
- /// A 2.0-style declarative macro introduced by the `macro` keyword.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemMacro2 #manual_extra_traits {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub macro_token: Token![macro],
- pub ident: Ident,
- pub rules: TokenStream,
- }
-}
-
-ast_struct! {
- /// A module or module declaration: `mod m` or `mod m { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemMod {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub mod_token: Token![mod],
- pub ident: Ident,
- pub content: Option<(token::Brace, Vec<Item>)>,
- pub semi: Option<Token![;]>,
- }
-}
-
-ast_struct! {
- /// A static item: `static BIKE: Shed = Shed(42)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemStatic {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub static_token: Token![static],
- pub mutability: Option<Token![mut]>,
- pub ident: Ident,
- pub colon_token: Token![:],
- pub ty: Box<Type>,
- pub eq_token: Token![=],
- pub expr: Box<Expr>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A struct definition: `struct Foo<A> { x: A }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemStruct {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub struct_token: Token![struct],
- pub ident: Ident,
- pub generics: Generics,
- pub fields: Fields,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-ast_struct! {
- /// A trait definition: `pub trait Iterator { ... }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemTrait {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub unsafety: Option<Token![unsafe]>,
- pub auto_token: Option<Token![auto]>,
- pub trait_token: Token![trait],
- pub ident: Ident,
- pub generics: Generics,
- pub colon_token: Option<Token![:]>,
- pub supertraits: Punctuated<TypeParamBound, Token![+]>,
- pub brace_token: token::Brace,
- pub items: Vec<TraitItem>,
- }
-}
-
-ast_struct! {
- /// A trait alias: `pub trait SharableIterator = Iterator + Sync`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemTraitAlias {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub trait_token: Token![trait],
- pub ident: Ident,
- pub generics: Generics,
- pub eq_token: Token![=],
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A type alias: `type Result<T> = std::result::Result<T, MyError>`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemType {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub type_token: Token![type],
- pub ident: Ident,
- pub generics: Generics,
- pub eq_token: Token![=],
- pub ty: Box<Type>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A union definition: `union Foo<A, B> { x: A, y: B }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemUnion {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub union_token: Token![union],
- pub ident: Ident,
- pub generics: Generics,
- pub fields: FieldsNamed,
- }
-}
-
-ast_struct! {
- /// A use declaration: `use std::collections::HashMap`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ItemUse {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub use_token: Token![use],
- pub leading_colon: Option<Token![::]>,
- pub tree: UseTree,
- pub semi_token: Token![;],
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Item {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Item {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (Item::Const(this), Item::Const(other)) => this == other,
- (Item::Enum(this), Item::Enum(other)) => this == other,
- (Item::ExternCrate(this), Item::ExternCrate(other)) => this == other,
- (Item::Fn(this), Item::Fn(other)) => this == other,
- (Item::ForeignMod(this), Item::ForeignMod(other)) => this == other,
- (Item::Impl(this), Item::Impl(other)) => this == other,
- (Item::Macro(this), Item::Macro(other)) => this == other,
- (Item::Macro2(this), Item::Macro2(other)) => this == other,
- (Item::Mod(this), Item::Mod(other)) => this == other,
- (Item::Static(this), Item::Static(other)) => this == other,
- (Item::Struct(this), Item::Struct(other)) => this == other,
- (Item::Trait(this), Item::Trait(other)) => this == other,
- (Item::TraitAlias(this), Item::TraitAlias(other)) => this == other,
- (Item::Type(this), Item::Type(other)) => this == other,
- (Item::Union(this), Item::Union(other)) => this == other,
- (Item::Use(this), Item::Use(other)) => this == other,
- (Item::Verbatim(this), Item::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Item {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- match self {
- Item::Const(item) => {
- state.write_u8(0);
- item.hash(state);
- }
- Item::Enum(item) => {
- state.write_u8(1);
- item.hash(state);
- }
- Item::ExternCrate(item) => {
- state.write_u8(2);
- item.hash(state);
- }
- Item::Fn(item) => {
- state.write_u8(3);
- item.hash(state);
- }
- Item::ForeignMod(item) => {
- state.write_u8(4);
- item.hash(state);
- }
- Item::Impl(item) => {
- state.write_u8(5);
- item.hash(state);
- }
- Item::Macro(item) => {
- state.write_u8(6);
- item.hash(state);
- }
- Item::Macro2(item) => {
- state.write_u8(7);
- item.hash(state);
- }
- Item::Mod(item) => {
- state.write_u8(8);
- item.hash(state);
- }
- Item::Static(item) => {
- state.write_u8(9);
- item.hash(state);
- }
- Item::Struct(item) => {
- state.write_u8(10);
- item.hash(state);
- }
- Item::Trait(item) => {
- state.write_u8(11);
- item.hash(state);
- }
- Item::TraitAlias(item) => {
- state.write_u8(12);
- item.hash(state);
- }
- Item::Type(item) => {
- state.write_u8(13);
- item.hash(state);
- }
- Item::Union(item) => {
- state.write_u8(14);
- item.hash(state);
- }
- Item::Use(item) => {
- state.write_u8(15);
- item.hash(state);
- }
- Item::Verbatim(item) => {
- state.write_u8(16);
- TokenStreamHelper(item).hash(state);
- }
- Item::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-impl Item {
- #[cfg(feature = "parsing")]
- pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> {
- match self {
- Item::ExternCrate(ItemExternCrate { attrs, .. })
- | Item::Use(ItemUse { attrs, .. })
- | Item::Static(ItemStatic { attrs, .. })
- | Item::Const(ItemConst { attrs, .. })
- | Item::Fn(ItemFn { attrs, .. })
- | Item::Mod(ItemMod { attrs, .. })
- | Item::ForeignMod(ItemForeignMod { attrs, .. })
- | Item::Type(ItemType { attrs, .. })
- | Item::Struct(ItemStruct { attrs, .. })
- | Item::Enum(ItemEnum { attrs, .. })
- | Item::Union(ItemUnion { attrs, .. })
- | Item::Trait(ItemTrait { attrs, .. })
- | Item::TraitAlias(ItemTraitAlias { attrs, .. })
- | Item::Impl(ItemImpl { attrs, .. })
- | Item::Macro(ItemMacro { attrs, .. })
- | Item::Macro2(ItemMacro2 { attrs, .. }) => mem::replace(attrs, new),
- Item::Verbatim(_) => Vec::new(),
- Item::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for ItemMacro2 {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for ItemMacro2 {
- fn eq(&self, other: &Self) -> bool {
- self.attrs == other.attrs
- && self.vis == other.vis
- && self.macro_token == other.macro_token
- && self.ident == other.ident
- && TokenStreamHelper(&self.rules) == TokenStreamHelper(&other.rules)
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for ItemMacro2 {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- self.attrs.hash(state);
- self.vis.hash(state);
- self.macro_token.hash(state);
- self.ident.hash(state);
- TokenStreamHelper(&self.rules).hash(state);
- }
-}
-
-impl From<DeriveInput> for Item {
- fn from(input: DeriveInput) -> Item {
- match input.data {
- Data::Struct(data) => Item::Struct(ItemStruct {
- attrs: input.attrs,
- vis: input.vis,
- struct_token: data.struct_token,
- ident: input.ident,
- generics: input.generics,
- fields: data.fields,
- semi_token: data.semi_token,
- }),
- Data::Enum(data) => Item::Enum(ItemEnum {
- attrs: input.attrs,
- vis: input.vis,
- enum_token: data.enum_token,
- ident: input.ident,
- generics: input.generics,
- brace_token: data.brace_token,
- variants: data.variants,
- }),
- Data::Union(data) => Item::Union(ItemUnion {
- attrs: input.attrs,
- vis: input.vis,
- union_token: data.union_token,
- ident: input.ident,
- generics: input.generics,
- fields: data.fields,
- }),
- }
- }
-}
-
-impl From<ItemStruct> for DeriveInput {
- fn from(input: ItemStruct) -> DeriveInput {
- DeriveInput {
- attrs: input.attrs,
- vis: input.vis,
- ident: input.ident,
- generics: input.generics,
- data: Data::Struct(DataStruct {
- struct_token: input.struct_token,
- fields: input.fields,
- semi_token: input.semi_token,
- }),
- }
- }
-}
-
-impl From<ItemEnum> for DeriveInput {
- fn from(input: ItemEnum) -> DeriveInput {
- DeriveInput {
- attrs: input.attrs,
- vis: input.vis,
- ident: input.ident,
- generics: input.generics,
- data: Data::Enum(DataEnum {
- enum_token: input.enum_token,
- brace_token: input.brace_token,
- variants: input.variants,
- }),
- }
- }
-}
-
-impl From<ItemUnion> for DeriveInput {
- fn from(input: ItemUnion) -> DeriveInput {
- DeriveInput {
- attrs: input.attrs,
- vis: input.vis,
- ident: input.ident,
- generics: input.generics,
- data: Data::Union(DataUnion {
- union_token: input.union_token,
- fields: input.fields,
- }),
- }
- }
-}
-
-ast_enum_of_structs! {
- /// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum UseTree {
- /// A path prefix of imports in a `use` item: `std::...`.
- Path(UsePath),
-
- /// An identifier imported by a `use` item: `HashMap`.
- Name(UseName),
-
- /// An renamed identifier imported by a `use` item: `HashMap as Map`.
- Rename(UseRename),
-
- /// A glob import in a `use` item: `*`.
- Glob(UseGlob),
-
- /// A braced group of imports in a `use` item: `{A, B, C}`.
- Group(UseGroup),
- }
-}
-
-ast_struct! {
- /// A path prefix of imports in a `use` item: `std::...`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct UsePath {
- pub ident: Ident,
- pub colon2_token: Token![::],
- pub tree: Box<UseTree>,
- }
-}
-
-ast_struct! {
- /// An identifier imported by a `use` item: `HashMap`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct UseName {
- pub ident: Ident,
- }
-}
-
-ast_struct! {
- /// An renamed identifier imported by a `use` item: `HashMap as Map`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct UseRename {
- pub ident: Ident,
- pub as_token: Token![as],
- pub rename: Ident,
- }
-}
-
-ast_struct! {
- /// A glob import in a `use` item: `*`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct UseGlob {
- pub star_token: Token![*],
- }
-}
-
-ast_struct! {
- /// A braced group of imports in a `use` item: `{A, B, C}`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct UseGroup {
- pub brace_token: token::Brace,
- pub items: Punctuated<UseTree, Token![,]>,
- }
-}
-
-ast_enum_of_structs! {
- /// An item within an `extern` block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum ForeignItem #manual_extra_traits {
- /// A foreign function in an `extern` block.
- Fn(ForeignItemFn),
-
- /// A foreign static item in an `extern` block: `static ext: u8`.
- Static(ForeignItemStatic),
-
- /// A foreign type in an `extern` block: `type void`.
- Type(ForeignItemType),
-
- /// A macro invocation within an extern block.
- Macro(ForeignItemMacro),
-
- /// Tokens in an `extern` block not interpreted by Syn.
- Verbatim(TokenStream),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// A foreign function in an `extern` block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ForeignItemFn {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub sig: Signature,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A foreign static item in an `extern` block: `static ext: u8`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ForeignItemStatic {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub static_token: Token![static],
- pub mutability: Option<Token![mut]>,
- pub ident: Ident,
- pub colon_token: Token![:],
- pub ty: Box<Type>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A foreign type in an `extern` block: `type void`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ForeignItemType {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub type_token: Token![type],
- pub ident: Ident,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A macro invocation within an extern block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ForeignItemMacro {
- pub attrs: Vec<Attribute>,
- pub mac: Macro,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for ForeignItem {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for ForeignItem {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (ForeignItem::Fn(this), ForeignItem::Fn(other)) => this == other,
- (ForeignItem::Static(this), ForeignItem::Static(other)) => this == other,
- (ForeignItem::Type(this), ForeignItem::Type(other)) => this == other,
- (ForeignItem::Macro(this), ForeignItem::Macro(other)) => this == other,
- (ForeignItem::Verbatim(this), ForeignItem::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for ForeignItem {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- match self {
- ForeignItem::Fn(item) => {
- state.write_u8(0);
- item.hash(state);
- }
- ForeignItem::Static(item) => {
- state.write_u8(1);
- item.hash(state);
- }
- ForeignItem::Type(item) => {
- state.write_u8(2);
- item.hash(state);
- }
- ForeignItem::Macro(item) => {
- state.write_u8(3);
- item.hash(state);
- }
- ForeignItem::Verbatim(item) => {
- state.write_u8(4);
- TokenStreamHelper(item).hash(state);
- }
- ForeignItem::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-ast_enum_of_structs! {
- /// An item declaration within the definition of a trait.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum TraitItem #manual_extra_traits {
- /// An associated constant within the definition of a trait.
- Const(TraitItemConst),
-
- /// A trait method within the definition of a trait.
- Method(TraitItemMethod),
-
- /// An associated type within the definition of a trait.
- Type(TraitItemType),
-
- /// A macro invocation within the definition of a trait.
- Macro(TraitItemMacro),
-
- /// Tokens within the definition of a trait not interpreted by Syn.
- Verbatim(TokenStream),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// An associated constant within the definition of a trait.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct TraitItemConst {
- pub attrs: Vec<Attribute>,
- pub const_token: Token![const],
- pub ident: Ident,
- pub colon_token: Token![:],
- pub ty: Type,
- pub default: Option<(Token![=], Expr)>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A trait method within the definition of a trait.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct TraitItemMethod {
- pub attrs: Vec<Attribute>,
- pub sig: Signature,
- pub default: Option<Block>,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-ast_struct! {
- /// An associated type within the definition of a trait.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct TraitItemType {
- pub attrs: Vec<Attribute>,
- pub type_token: Token![type],
- pub ident: Ident,
- pub generics: Generics,
- pub colon_token: Option<Token![:]>,
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- pub default: Option<(Token![=], Type)>,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A macro invocation within the definition of a trait.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct TraitItemMacro {
- pub attrs: Vec<Attribute>,
- pub mac: Macro,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for TraitItem {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for TraitItem {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (TraitItem::Const(this), TraitItem::Const(other)) => this == other,
- (TraitItem::Method(this), TraitItem::Method(other)) => this == other,
- (TraitItem::Type(this), TraitItem::Type(other)) => this == other,
- (TraitItem::Macro(this), TraitItem::Macro(other)) => this == other,
- (TraitItem::Verbatim(this), TraitItem::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for TraitItem {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- match self {
- TraitItem::Const(item) => {
- state.write_u8(0);
- item.hash(state);
- }
- TraitItem::Method(item) => {
- state.write_u8(1);
- item.hash(state);
- }
- TraitItem::Type(item) => {
- state.write_u8(2);
- item.hash(state);
- }
- TraitItem::Macro(item) => {
- state.write_u8(3);
- item.hash(state);
- }
- TraitItem::Verbatim(item) => {
- state.write_u8(4);
- TokenStreamHelper(item).hash(state);
- }
- TraitItem::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-ast_enum_of_structs! {
- /// An item within an impl block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum ImplItem #manual_extra_traits {
- /// An associated constant within an impl block.
- Const(ImplItemConst),
-
- /// A method within an impl block.
- Method(ImplItemMethod),
-
- /// An associated type within an impl block.
- Type(ImplItemType),
-
- /// A macro invocation within an impl block.
- Macro(ImplItemMacro),
-
- /// Tokens within an impl block not interpreted by Syn.
- Verbatim(TokenStream),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// An associated constant within an impl block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ImplItemConst {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub defaultness: Option<Token![default]>,
- pub const_token: Token![const],
- pub ident: Ident,
- pub colon_token: Token![:],
- pub ty: Type,
- pub eq_token: Token![=],
- pub expr: Expr,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A method within an impl block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ImplItemMethod {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub defaultness: Option<Token![default]>,
- pub sig: Signature,
- pub block: Block,
- }
-}
-
-ast_struct! {
- /// An associated type within an impl block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ImplItemType {
- pub attrs: Vec<Attribute>,
- pub vis: Visibility,
- pub defaultness: Option<Token![default]>,
- pub type_token: Token![type],
- pub ident: Ident,
- pub generics: Generics,
- pub eq_token: Token![=],
- pub ty: Type,
- pub semi_token: Token![;],
- }
-}
-
-ast_struct! {
- /// A macro invocation within an impl block.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct ImplItemMacro {
- pub attrs: Vec<Attribute>,
- pub mac: Macro,
- pub semi_token: Option<Token![;]>,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for ImplItem {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for ImplItem {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (ImplItem::Const(this), ImplItem::Const(other)) => this == other,
- (ImplItem::Method(this), ImplItem::Method(other)) => this == other,
- (ImplItem::Type(this), ImplItem::Type(other)) => this == other,
- (ImplItem::Macro(this), ImplItem::Macro(other)) => this == other,
- (ImplItem::Verbatim(this), ImplItem::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for ImplItem {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- match self {
- ImplItem::Const(item) => {
- state.write_u8(0);
- item.hash(state);
- }
- ImplItem::Method(item) => {
- state.write_u8(1);
- item.hash(state);
- }
- ImplItem::Type(item) => {
- state.write_u8(2);
- item.hash(state);
- }
- ImplItem::Macro(item) => {
- state.write_u8(3);
- item.hash(state);
- }
- ImplItem::Verbatim(item) => {
- state.write_u8(4);
- TokenStreamHelper(item).hash(state);
- }
- ImplItem::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-ast_struct! {
- /// A function signature in a trait or implementation: `unsafe fn
- /// initialize(&self)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct Signature {
- pub constness: Option<Token![const]>,
- pub asyncness: Option<Token![async]>,
- pub unsafety: Option<Token![unsafe]>,
- pub abi: Option<Abi>,
- pub fn_token: Token![fn],
- pub ident: Ident,
- pub generics: Generics,
- pub paren_token: token::Paren,
- pub inputs: Punctuated<FnArg, Token![,]>,
- pub variadic: Option<Variadic>,
- pub output: ReturnType,
- }
-}
-
-impl Signature {
- /// A method's `self` receiver, such as `&self` or `self: Box<Self>`.
- pub fn receiver(&self) -> Option<&FnArg> {
- let arg = self.inputs.first()?;
- match arg {
- FnArg::Receiver(_) => Some(arg),
- FnArg::Typed(PatType { pat, .. }) => {
- if let Pat::Ident(PatIdent { ident, .. }) = &**pat {
- if ident == "self" {
- return Some(arg);
- }
- }
- None
- }
- }
- }
-}
-
-ast_enum_of_structs! {
- /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub enum FnArg {
- /// The `self` argument of an associated method, whether taken by value
- /// or by reference.
- ///
- /// Note that `self` receivers with a specified type, such as `self:
- /// Box<Self>`, are parsed as a `FnArg::Typed`.
- Receiver(Receiver),
-
- /// A function argument accepted by pattern and type.
- Typed(PatType),
- }
-}
-
-ast_struct! {
- /// The `self` argument of an associated method, whether taken by value
- /// or by reference.
- ///
- /// Note that `self` receivers with a specified type, such as `self:
- /// Box<Self>`, are parsed as a `FnArg::Typed`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct Receiver {
- pub attrs: Vec<Attribute>,
- pub reference: Option<(Token![&], Option<Lifetime>)>,
- pub mutability: Option<Token![mut]>,
- pub self_token: Token![self],
- }
-}
-
-impl Receiver {
- pub fn lifetime(&self) -> Option<&Lifetime> {
- self.reference.as_ref()?.1.as_ref()
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::ext::IdentExt;
- use crate::parse::discouraged::Speculative;
- use crate::parse::{Parse, ParseStream, Result};
- use crate::token::Brace;
- use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenTree};
- use std::iter::{self, FromIterator};
-
- crate::custom_keyword!(existential);
-
- impl Parse for Item {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut attrs = input.call(Attribute::parse_outer)?;
- let ahead = input.fork();
- let vis: Visibility = ahead.parse()?;
-
- let lookahead = ahead.lookahead1();
- let mut item = if lookahead.peek(Token![extern]) {
- ahead.parse::<Token![extern]>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(Token![crate]) {
- input.parse().map(Item::ExternCrate)
- } else if lookahead.peek(Token![fn]) {
- input.parse().map(Item::Fn)
- } else if lookahead.peek(token::Brace) {
- input.parse().map(Item::ForeignMod)
- } else if lookahead.peek(LitStr) {
- ahead.parse::<LitStr>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(token::Brace) {
- input.parse().map(Item::ForeignMod)
- } else if lookahead.peek(Token![fn]) {
- input.parse().map(Item::Fn)
- } else {
- Err(lookahead.error())
- }
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(Token![use]) {
- input.parse().map(Item::Use)
- } else if lookahead.peek(Token![static]) {
- input.parse().map(Item::Static)
- } else if lookahead.peek(Token![const]) {
- ahead.parse::<Token![const]>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
- input.parse().map(Item::Const)
- } else if lookahead.peek(Token![unsafe])
- || lookahead.peek(Token![async])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![fn])
- {
- input.parse().map(Item::Fn)
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(Token![unsafe]) {
- ahead.parse::<Token![unsafe]>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(Token![trait])
- || lookahead.peek(Token![auto]) && ahead.peek2(Token![trait])
- {
- input.parse().map(Item::Trait)
- } else if lookahead.peek(Token![impl]) {
- input.parse().map(Item::Impl)
- } else if lookahead.peek(Token![async])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![fn])
- {
- input.parse().map(Item::Fn)
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(Token![async]) || lookahead.peek(Token![fn]) {
- input.parse().map(Item::Fn)
- } else if lookahead.peek(Token![mod]) {
- input.parse().map(Item::Mod)
- } else if lookahead.peek(Token![type]) {
- input.parse().map(Item::Type)
- } else if lookahead.peek(existential) {
- input.call(item_existential).map(Item::Verbatim)
- } else if lookahead.peek(Token![struct]) {
- input.parse().map(Item::Struct)
- } else if lookahead.peek(Token![enum]) {
- input.parse().map(Item::Enum)
- } else if lookahead.peek(Token![union]) && ahead.peek2(Ident) {
- input.parse().map(Item::Union)
- } else if lookahead.peek(Token![trait]) {
- input.call(parse_trait_or_trait_alias)
- } else if lookahead.peek(Token![auto]) && ahead.peek2(Token![trait]) {
- input.parse().map(Item::Trait)
- } else if lookahead.peek(Token![impl])
- || lookahead.peek(Token![default]) && !ahead.peek2(Token![!])
- {
- input.parse().map(Item::Impl)
- } else if lookahead.peek(Token![macro]) {
- input.parse().map(Item::Macro2)
- } else if vis.is_inherited()
- && (lookahead.peek(Ident)
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![crate])
- || lookahead.peek(Token![::]))
- {
- input.parse().map(Item::Macro)
- } else {
- Err(lookahead.error())
- }?;
-
- attrs.extend(item.replace_attrs(Vec::new()));
- item.replace_attrs(attrs);
- Ok(item)
- }
- }
-
- impl Parse for ItemMacro {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let path = input.call(Path::parse_mod_style)?;
- let bang_token: Token![!] = input.parse()?;
- let ident: Option<Ident> = input.parse()?;
- let (delimiter, tokens) = input.call(mac::parse_delimiter)?;
- let semi_token: Option<Token![;]> = if !delimiter.is_brace() {
- Some(input.parse()?)
- } else {
- None
- };
- Ok(ItemMacro {
- attrs,
- ident,
- mac: Macro {
- path,
- bang_token,
- delimiter,
- tokens,
- },
- semi_token,
- })
- }
- }
-
- impl Parse for ItemMacro2 {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let macro_token: Token![macro] = input.parse()?;
- let ident: Ident = input.parse()?;
- let mut rules = TokenStream::new();
-
- let mut lookahead = input.lookahead1();
- if lookahead.peek(token::Paren) {
- let paren_content;
- let paren_token = parenthesized!(paren_content in input);
- let args: TokenStream = paren_content.parse()?;
- let mut args = Group::new(Delimiter::Parenthesis, args);
- args.set_span(paren_token.span);
- rules.extend(iter::once(TokenTree::Group(args)));
- lookahead = input.lookahead1();
- }
-
- if lookahead.peek(token::Brace) {
- let brace_content;
- let brace_token = braced!(brace_content in input);
- let body: TokenStream = brace_content.parse()?;
- let mut body = Group::new(Delimiter::Brace, body);
- body.set_span(brace_token.span);
- rules.extend(iter::once(TokenTree::Group(body)));
- } else {
- return Err(lookahead.error());
- }
-
- Ok(ItemMacro2 {
- attrs,
- vis,
- macro_token,
- ident,
- rules,
- })
- }
- }
-
- impl Parse for ItemExternCrate {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ItemExternCrate {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- extern_token: input.parse()?,
- crate_token: input.parse()?,
- ident: {
- if input.peek(Token![self]) {
- input.call(Ident::parse_any)?
- } else {
- input.parse()?
- }
- },
- rename: {
- if input.peek(Token![as]) {
- let as_token: Token![as] = input.parse()?;
- let rename: Ident = if input.peek(Token![_]) {
- Ident::from(input.parse::<Token![_]>()?)
- } else {
- input.parse()?
- };
- Some((as_token, rename))
- } else {
- None
- }
- },
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ItemUse {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ItemUse {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- use_token: input.parse()?,
- leading_colon: input.parse()?,
- tree: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for UseTree {
- fn parse(input: ParseStream) -> Result<UseTree> {
- let lookahead = input.lookahead1();
- if lookahead.peek(Ident)
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![crate])
- || lookahead.peek(Token![extern])
- {
- let ident = input.call(Ident::parse_any)?;
- if input.peek(Token![::]) {
- Ok(UseTree::Path(UsePath {
- ident,
- colon2_token: input.parse()?,
- tree: Box::new(input.parse()?),
- }))
- } else if input.peek(Token![as]) {
- Ok(UseTree::Rename(UseRename {
- ident,
- as_token: input.parse()?,
- rename: {
- if input.peek(Ident) {
- input.parse()?
- } else if input.peek(Token![_]) {
- Ident::from(input.parse::<Token![_]>()?)
- } else {
- return Err(input.error("expected identifier or underscore"));
- }
- },
- }))
- } else {
- Ok(UseTree::Name(UseName { ident }))
- }
- } else if lookahead.peek(Token![*]) {
- Ok(UseTree::Glob(UseGlob {
- star_token: input.parse()?,
- }))
- } else if lookahead.peek(token::Brace) {
- let content;
- Ok(UseTree::Group(UseGroup {
- brace_token: braced!(content in input),
- items: content.parse_terminated(UseTree::parse)?,
- }))
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- impl Parse for ItemStatic {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ItemStatic {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- static_token: input.parse()?,
- mutability: input.parse()?,
- ident: input.parse()?,
- colon_token: input.parse()?,
- ty: input.parse()?,
- eq_token: input.parse()?,
- expr: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ItemConst {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ItemConst {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- const_token: input.parse()?,
- ident: {
- let lookahead = input.lookahead1();
- if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
- input.call(Ident::parse_any)?
- } else {
- return Err(lookahead.error());
- }
- },
- colon_token: input.parse()?,
- ty: input.parse()?,
- eq_token: input.parse()?,
- expr: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ItemFn {
- fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let constness: Option<Token![const]> = input.parse()?;
- let asyncness: Option<Token![async]> = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let abi: Option<Abi> = input.parse()?;
- let fn_token: Token![fn] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
-
- let content;
- let paren_token = parenthesized!(content in input);
- let inputs = parse_fn_args(&content)?;
- let variadic = inputs.last().as_ref().and_then(get_variadic);
-
- fn get_variadic(input: &&FnArg) -> Option<Variadic> {
- if let FnArg::Typed(PatType { ty, .. }) = input {
- if let Type::Verbatim(tokens) = &**ty {
- if let Ok(dots) = parse2(tokens.clone()) {
- return Some(Variadic {
- attrs: Vec::new(),
- dots,
- });
- }
- }
- }
- None
- }
-
- let output: ReturnType = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
-
- Ok(ItemFn {
- attrs: private::attrs(outer_attrs, inner_attrs),
- vis,
- sig: Signature {
- constness,
- asyncness,
- unsafety,
- abi,
- fn_token,
- ident,
- paren_token,
- inputs,
- output,
- variadic,
- generics: Generics {
- where_clause,
- ..generics
- },
- },
- block: Box::new(Block { brace_token, stmts }),
- })
- }
- }
-
- impl Parse for FnArg {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
-
- let ahead = input.fork();
- if let Ok(mut receiver) = ahead.parse::<Receiver>() {
- if !ahead.peek(Token![:]) {
- input.advance_to(&ahead);
- receiver.attrs = attrs;
- return Ok(FnArg::Receiver(receiver));
- }
- }
-
- let mut typed = input.call(fn_arg_typed)?;
- typed.attrs = attrs;
- Ok(FnArg::Typed(typed))
- }
- }
-
- impl Parse for Receiver {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(Receiver {
- attrs: Vec::new(),
- reference: {
- if input.peek(Token![&]) {
- Some((input.parse()?, input.parse()?))
- } else {
- None
- }
- },
- mutability: input.parse()?,
- self_token: input.parse()?,
- })
- }
- }
-
- fn parse_fn_args(input: ParseStream) -> Result<Punctuated<FnArg, Token![,]>> {
- let mut args = Punctuated::new();
- let mut has_receiver = false;
- loop {
- if input.is_empty() {
- break;
- }
- let arg: FnArg = input.parse()?;
- if let FnArg::Receiver(receiver) = &arg {
- if has_receiver {
- return Err(Error::new(
- receiver.self_token.span,
- "unexpected second method receiver",
- ));
- } else if !args.is_empty() {
- return Err(Error::new(
- receiver.self_token.span,
- "unexpected method receiver",
- ));
- }
- has_receiver = true;
- }
- args.push_value(arg);
- if input.is_empty() {
- break;
- }
- let comma: Token![,] = input.parse()?;
- args.push_punct(comma);
- }
- Ok(args)
- }
-
- fn fn_arg_typed(input: ParseStream) -> Result<PatType> {
- // Hack to parse pre-2018 syntax in
- // test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs
- // because the rest of the test case is valuable.
- if input.peek(Ident) && input.peek2(Token![<]) {
- let span = input.fork().parse::<Ident>()?.span();
- return Ok(PatType {
- attrs: Vec::new(),
- pat: Box::new(Pat::Wild(PatWild {
- attrs: Vec::new(),
- underscore_token: Token![_](span),
- })),
- colon_token: Token![:](span),
- ty: input.parse()?,
- });
- }
-
- Ok(PatType {
- attrs: Vec::new(),
- pat: input.parse()?,
- colon_token: input.parse()?,
- ty: Box::new(match input.parse::<Option<Token![...]>>()? {
- Some(dot3) => {
- let args = vec![
- TokenTree::Punct(Punct::new('.', Spacing::Joint)),
- TokenTree::Punct(Punct::new('.', Spacing::Joint)),
- TokenTree::Punct(Punct::new('.', Spacing::Alone)),
- ];
- let tokens = TokenStream::from_iter(args.into_iter().zip(&dot3.spans).map(
- |(mut arg, span)| {
- arg.set_span(*span);
- arg
- },
- ));
- Type::Verbatim(tokens)
- }
- None => input.parse()?,
- }),
- })
- }
-
- impl Parse for ItemMod {
- fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let mod_token: Token![mod] = input.parse()?;
- let ident: Ident = input.parse()?;
-
- let lookahead = input.lookahead1();
- if lookahead.peek(Token![;]) {
- Ok(ItemMod {
- attrs: outer_attrs,
- vis,
- mod_token,
- ident,
- content: None,
- semi: Some(input.parse()?),
- })
- } else if lookahead.peek(token::Brace) {
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
-
- let mut items = Vec::new();
- while !content.is_empty() {
- items.push(content.parse()?);
- }
-
- Ok(ItemMod {
- attrs: private::attrs(outer_attrs, inner_attrs),
- vis,
- mod_token,
- ident,
- content: Some((brace_token, items)),
- semi: None,
- })
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- impl Parse for ItemForeignMod {
- fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
- let abi: Abi = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let mut items = Vec::new();
- while !content.is_empty() {
- items.push(content.parse()?);
- }
-
- Ok(ItemForeignMod {
- attrs: private::attrs(outer_attrs, inner_attrs),
- abi,
- brace_token,
- items,
- })
- }
- }
-
- impl Parse for ForeignItem {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut attrs = input.call(Attribute::parse_outer)?;
- let ahead = input.fork();
- let vis: Visibility = ahead.parse()?;
-
- let lookahead = ahead.lookahead1();
- let mut item = if lookahead.peek(Token![fn]) {
- input.parse().map(ForeignItem::Fn)
- } else if lookahead.peek(Token![static]) {
- input.parse().map(ForeignItem::Static)
- } else if lookahead.peek(Token![type]) {
- input.parse().map(ForeignItem::Type)
- } else if vis.is_inherited()
- && (lookahead.peek(Ident)
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![crate])
- || lookahead.peek(Token![::]))
- {
- input.parse().map(ForeignItem::Macro)
- } else {
- Err(lookahead.error())
- }?;
-
- {
- let item_attrs = match &mut item {
- ForeignItem::Fn(item) => &mut item.attrs,
- ForeignItem::Static(item) => &mut item.attrs,
- ForeignItem::Type(item) => &mut item.attrs,
- ForeignItem::Macro(item) => &mut item.attrs,
- ForeignItem::Verbatim(_) | ForeignItem::__Nonexhaustive => unreachable!(),
- };
- attrs.extend(item_attrs.drain(..));
- *item_attrs = attrs;
- }
-
- Ok(item)
- }
- }
-
- impl Parse for ForeignItemFn {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let fn_token: Token![fn] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
-
- let content;
- let paren_token = parenthesized!(content in input);
- let mut inputs = Punctuated::new();
- let mut variadic = None;
- while !content.is_empty() {
- let attrs = content.call(Attribute::parse_outer)?;
-
- if let Some(dots) = content.parse()? {
- variadic = Some(Variadic { attrs, dots });
- break;
- }
-
- let mut arg = content.call(fn_arg_typed)?;
- arg.attrs = attrs;
- inputs.push_value(FnArg::Typed(arg));
- if content.is_empty() {
- break;
- }
-
- inputs.push_punct(content.parse()?);
- }
-
- let output: ReturnType = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
- let semi_token: Token![;] = input.parse()?;
-
- Ok(ForeignItemFn {
- attrs,
- vis,
- sig: Signature {
- constness: None,
- asyncness: None,
- unsafety: None,
- abi: None,
- fn_token,
- ident,
- paren_token,
- inputs,
- output,
- variadic,
- generics: Generics {
- where_clause,
- ..generics
- },
- },
- semi_token,
- })
- }
- }
-
- impl Parse for ForeignItemStatic {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ForeignItemStatic {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- static_token: input.parse()?,
- mutability: input.parse()?,
- ident: input.parse()?,
- colon_token: input.parse()?,
- ty: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ForeignItemType {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ForeignItemType {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- type_token: input.parse()?,
- ident: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ForeignItemMacro {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let mac: Macro = input.parse()?;
- let semi_token: Option<Token![;]> = if mac.delimiter.is_brace() {
- None
- } else {
- Some(input.parse()?)
- };
- Ok(ForeignItemMacro {
- attrs,
- mac,
- semi_token,
- })
- }
- }
-
- impl Parse for ItemType {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ItemType {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- type_token: input.parse()?,
- ident: input.parse()?,
- generics: {
- let mut generics: Generics = input.parse()?;
- generics.where_clause = input.parse()?;
- generics
- },
- eq_token: input.parse()?,
- ty: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- #[cfg(not(feature = "printing"))]
- fn item_existential(input: ParseStream) -> Result<TokenStream> {
- Err(input.error("existential type is not supported"))
- }
-
- #[cfg(feature = "printing")]
- fn item_existential(input: ParseStream) -> Result<TokenStream> {
- use crate::attr::FilterAttrs;
- use quote::{ToTokens, TokenStreamExt};
-
- let attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let existential_token: existential = input.parse()?;
- let type_token: Token![type] = input.parse()?;
- let ident: Ident = input.parse()?;
-
- let mut generics: Generics = input.parse()?;
- generics.where_clause = input.parse()?;
-
- let colon_token: Token![:] = input.parse()?;
-
- let mut bounds = Punctuated::new();
- while !input.peek(Token![;]) {
- if !bounds.is_empty() {
- bounds.push_punct(input.parse::<Token![+]>()?);
- }
- bounds.push_value(input.parse::<TypeParamBound>()?);
- }
-
- let semi_token: Token![;] = input.parse()?;
-
- let mut tokens = TokenStream::new();
- tokens.append_all(attrs.outer());
- vis.to_tokens(&mut tokens);
- existential_token.to_tokens(&mut tokens);
- type_token.to_tokens(&mut tokens);
- ident.to_tokens(&mut tokens);
- generics.to_tokens(&mut tokens);
- generics.where_clause.to_tokens(&mut tokens);
- if !bounds.is_empty() {
- colon_token.to_tokens(&mut tokens);
- bounds.to_tokens(&mut tokens);
- }
- semi_token.to_tokens(&mut tokens);
- Ok(tokens)
- }
-
- impl Parse for ItemStruct {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis = input.parse::<Visibility>()?;
- let struct_token = input.parse::<Token![struct]>()?;
- let ident = input.parse::<Ident>()?;
- let generics = input.parse::<Generics>()?;
- let (where_clause, fields, semi_token) = derive::parsing::data_struct(input)?;
- Ok(ItemStruct {
- attrs,
- vis,
- struct_token,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- fields,
- semi_token,
- })
- }
- }
-
- impl Parse for ItemEnum {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis = input.parse::<Visibility>()?;
- let enum_token = input.parse::<Token![enum]>()?;
- let ident = input.parse::<Ident>()?;
- let generics = input.parse::<Generics>()?;
- let (where_clause, brace_token, variants) = derive::parsing::data_enum(input)?;
- Ok(ItemEnum {
- attrs,
- vis,
- enum_token,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- brace_token,
- variants,
- })
- }
- }
-
- impl Parse for ItemUnion {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis = input.parse::<Visibility>()?;
- let union_token = input.parse::<Token![union]>()?;
- let ident = input.parse::<Ident>()?;
- let generics = input.parse::<Generics>()?;
- let (where_clause, fields) = derive::parsing::data_union(input)?;
- Ok(ItemUnion {
- attrs,
- vis,
- union_token,
- ident,
- generics: Generics {
- where_clause,
- ..generics
- },
- fields,
- })
- }
- }
-
- fn parse_trait_or_trait_alias(input: ParseStream) -> Result<Item> {
- let (attrs, vis, trait_token, ident, generics) = parse_start_of_trait_alias(input)?;
- let lookahead = input.lookahead1();
- if lookahead.peek(token::Brace)
- || lookahead.peek(Token![:])
- || lookahead.peek(Token![where])
- {
- let unsafety = None;
- let auto_token = None;
- parse_rest_of_trait(
- input,
- attrs,
- vis,
- unsafety,
- auto_token,
- trait_token,
- ident,
- generics,
- )
- .map(Item::Trait)
- } else if lookahead.peek(Token![=]) {
- parse_rest_of_trait_alias(input, attrs, vis, trait_token, ident, generics)
- .map(Item::TraitAlias)
- } else {
- Err(lookahead.error())
- }
- }
-
- impl Parse for ItemTrait {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let auto_token: Option<Token![auto]> = input.parse()?;
- let trait_token: Token![trait] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
- parse_rest_of_trait(
- input,
- attrs,
- vis,
- unsafety,
- auto_token,
- trait_token,
- ident,
- generics,
- )
- }
- }
-
- fn parse_rest_of_trait(
- input: ParseStream,
- attrs: Vec<Attribute>,
- vis: Visibility,
- unsafety: Option<Token![unsafe]>,
- auto_token: Option<Token![auto]>,
- trait_token: Token![trait],
- ident: Ident,
- mut generics: Generics,
- ) -> Result<ItemTrait> {
- let colon_token: Option<Token![:]> = input.parse()?;
-
- let mut supertraits = Punctuated::new();
- if colon_token.is_some() {
- loop {
- supertraits.push_value(input.parse()?);
- if input.peek(Token![where]) || input.peek(token::Brace) {
- break;
- }
- supertraits.push_punct(input.parse()?);
- if input.peek(Token![where]) || input.peek(token::Brace) {
- break;
- }
- }
- }
-
- generics.where_clause = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let mut items = Vec::new();
- while !content.is_empty() {
- items.push(content.parse()?);
- }
-
- Ok(ItemTrait {
- attrs,
- vis,
- unsafety,
- auto_token,
- trait_token,
- ident,
- generics,
- colon_token,
- supertraits,
- brace_token,
- items,
- })
- }
-
- impl Parse for ItemTraitAlias {
- fn parse(input: ParseStream) -> Result<Self> {
- let (attrs, vis, trait_token, ident, generics) = parse_start_of_trait_alias(input)?;
- parse_rest_of_trait_alias(input, attrs, vis, trait_token, ident, generics)
- }
- }
-
- fn parse_start_of_trait_alias(
- input: ParseStream,
- ) -> Result<(Vec<Attribute>, Visibility, Token![trait], Ident, Generics)> {
- let attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let trait_token: Token![trait] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
- Ok((attrs, vis, trait_token, ident, generics))
- }
-
- fn parse_rest_of_trait_alias(
- input: ParseStream,
- attrs: Vec<Attribute>,
- vis: Visibility,
- trait_token: Token![trait],
- ident: Ident,
- mut generics: Generics,
- ) -> Result<ItemTraitAlias> {
- let eq_token: Token![=] = input.parse()?;
-
- let mut bounds = Punctuated::new();
- loop {
- if input.peek(Token![where]) || input.peek(Token![;]) {
- break;
- }
- bounds.push_value(input.parse()?);
- if input.peek(Token![where]) || input.peek(Token![;]) {
- break;
- }
- bounds.push_punct(input.parse()?);
- }
-
- generics.where_clause = input.parse()?;
- let semi_token: Token![;] = input.parse()?;
-
- Ok(ItemTraitAlias {
- attrs,
- vis,
- trait_token,
- ident,
- generics,
- eq_token,
- bounds,
- semi_token,
- })
- }
-
- impl Parse for TraitItem {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut attrs = input.call(Attribute::parse_outer)?;
- let ahead = input.fork();
-
- let lookahead = ahead.lookahead1();
- let mut item = if lookahead.peek(Token![const]) {
- ahead.parse::<Token![const]>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(Ident) {
- input.parse().map(TraitItem::Const)
- } else if lookahead.peek(Token![async])
- || lookahead.peek(Token![unsafe])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![fn])
- {
- input.parse().map(TraitItem::Method)
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(Token![async])
- || lookahead.peek(Token![unsafe])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![fn])
- {
- input.parse().map(TraitItem::Method)
- } else if lookahead.peek(Token![type]) {
- input.parse().map(TraitItem::Type)
- } else if lookahead.peek(Ident)
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![crate])
- || lookahead.peek(Token![::])
- {
- input.parse().map(TraitItem::Macro)
- } else {
- Err(lookahead.error())
- }?;
-
- {
- let item_attrs = match &mut item {
- TraitItem::Const(item) => &mut item.attrs,
- TraitItem::Method(item) => &mut item.attrs,
- TraitItem::Type(item) => &mut item.attrs,
- TraitItem::Macro(item) => &mut item.attrs,
- TraitItem::Verbatim(_) | TraitItem::__Nonexhaustive => unreachable!(),
- };
- attrs.extend(item_attrs.drain(..));
- *item_attrs = attrs;
- }
-
- Ok(item)
- }
- }
-
- impl Parse for TraitItemConst {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(TraitItemConst {
- attrs: input.call(Attribute::parse_outer)?,
- const_token: input.parse()?,
- ident: input.parse()?,
- colon_token: input.parse()?,
- ty: input.parse()?,
- default: {
- if input.peek(Token![=]) {
- let eq_token: Token![=] = input.parse()?;
- let default: Expr = input.parse()?;
- Some((eq_token, default))
- } else {
- None
- }
- },
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for TraitItemMethod {
- fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
- let constness: Option<Token![const]> = input.parse()?;
- let asyncness: Option<Token![async]> = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let abi: Option<Abi> = input.parse()?;
- let fn_token: Token![fn] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
-
- let content;
- let paren_token = parenthesized!(content in input);
- let inputs = parse_fn_args(&content)?;
-
- let output: ReturnType = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
-
- let lookahead = input.lookahead1();
- let (brace_token, inner_attrs, stmts, semi_token) = if lookahead.peek(token::Brace) {
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
- let stmts = content.call(Block::parse_within)?;
- (Some(brace_token), inner_attrs, stmts, None)
- } else if lookahead.peek(Token![;]) {
- let semi_token: Token![;] = input.parse()?;
- (None, Vec::new(), Vec::new(), Some(semi_token))
- } else {
- return Err(lookahead.error());
- };
-
- Ok(TraitItemMethod {
- attrs: private::attrs(outer_attrs, inner_attrs),
- sig: Signature {
- constness,
- asyncness,
- unsafety,
- abi,
- fn_token,
- ident,
- paren_token,
- inputs,
- output,
- variadic: None,
- generics: Generics {
- where_clause,
- ..generics
- },
- },
- default: brace_token.map(|brace_token| Block { brace_token, stmts }),
- semi_token,
- })
- }
- }
-
- impl Parse for TraitItemType {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let type_token: Token![type] = input.parse()?;
- let ident: Ident = input.parse()?;
- let mut generics: Generics = input.parse()?;
- let colon_token: Option<Token![:]> = input.parse()?;
-
- let mut bounds = Punctuated::new();
- if colon_token.is_some() {
- while !input.peek(Token![where]) && !input.peek(Token![=]) && !input.peek(Token![;])
- {
- if !bounds.is_empty() {
- bounds.push_punct(input.parse()?);
- }
- bounds.push_value(input.parse()?);
- }
- }
-
- generics.where_clause = input.parse()?;
- let default = if input.peek(Token![=]) {
- let eq_token: Token![=] = input.parse()?;
- let default: Type = input.parse()?;
- Some((eq_token, default))
- } else {
- None
- };
- let semi_token: Token![;] = input.parse()?;
-
- Ok(TraitItemType {
- attrs,
- type_token,
- ident,
- generics,
- colon_token,
- bounds,
- default,
- semi_token,
- })
- }
- }
-
- impl Parse for TraitItemMacro {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let mac: Macro = input.parse()?;
- let semi_token: Option<Token![;]> = if mac.delimiter.is_brace() {
- None
- } else {
- Some(input.parse()?)
- };
- Ok(TraitItemMacro {
- attrs,
- mac,
- semi_token,
- })
- }
- }
-
- impl Parse for ItemImpl {
- fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
- let defaultness: Option<Token![default]> = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let impl_token: Token![impl] = input.parse()?;
-
- let has_generics = input.peek(Token![<])
- && (input.peek2(Token![>])
- || input.peek2(Token![#])
- || (input.peek2(Ident) || input.peek2(Lifetime))
- && (input.peek3(Token![:])
- || input.peek3(Token![,])
- || input.peek3(Token![>])));
- let generics: Generics = if has_generics {
- input.parse()?
- } else {
- Generics::default()
- };
-
- let trait_ = (|| -> Option<_> {
- let ahead = input.fork();
- let polarity: Option<Token![!]> = ahead.parse().ok()?;
- let path: Path = ahead.parse().ok()?;
- let for_token: Token![for] = ahead.parse().ok()?;
- input.advance_to(&ahead);
- Some((polarity, path, for_token))
- })();
- let self_ty: Type = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
-
- let content;
- let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
-
- let mut items = Vec::new();
- while !content.is_empty() {
- items.push(content.parse()?);
- }
-
- Ok(ItemImpl {
- attrs: private::attrs(outer_attrs, inner_attrs),
- defaultness,
- unsafety,
- impl_token,
- generics: Generics {
- where_clause,
- ..generics
- },
- trait_,
- self_ty: Box::new(self_ty),
- brace_token,
- items,
- })
- }
- }
-
- impl Parse for ImplItem {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut attrs = input.call(Attribute::parse_outer)?;
- let ahead = input.fork();
- let vis: Visibility = ahead.parse()?;
-
- let mut lookahead = ahead.lookahead1();
- let defaultness = if lookahead.peek(Token![default]) && !ahead.peek2(Token![!]) {
- let defaultness: Token![default] = ahead.parse()?;
- lookahead = ahead.lookahead1();
- Some(defaultness)
- } else {
- None
- };
-
- let mut item = if lookahead.peek(Token![const]) {
- ahead.parse::<Token![const]>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(Ident) {
- input.parse().map(ImplItem::Const)
- } else if lookahead.peek(Token![unsafe])
- || lookahead.peek(Token![async])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![fn])
- {
- input.parse().map(ImplItem::Method)
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(Token![unsafe])
- || lookahead.peek(Token![async])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![fn])
- {
- input.parse().map(ImplItem::Method)
- } else if lookahead.peek(Token![type]) {
- input.parse().map(ImplItem::Type)
- } else if vis.is_inherited() && defaultness.is_none() && lookahead.peek(existential) {
- input.call(item_existential).map(ImplItem::Verbatim)
- } else if vis.is_inherited()
- && defaultness.is_none()
- && (lookahead.peek(Ident)
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![crate])
- || lookahead.peek(Token![::]))
- {
- input.parse().map(ImplItem::Macro)
- } else {
- Err(lookahead.error())
- }?;
-
- {
- let item_attrs = match &mut item {
- ImplItem::Const(item) => &mut item.attrs,
- ImplItem::Method(item) => &mut item.attrs,
- ImplItem::Type(item) => &mut item.attrs,
- ImplItem::Macro(item) => &mut item.attrs,
- ImplItem::Verbatim(_) => return Ok(item),
- ImplItem::__Nonexhaustive => unreachable!(),
- };
- attrs.extend(item_attrs.drain(..));
- *item_attrs = attrs;
- }
-
- Ok(item)
- }
- }
-
- impl Parse for ImplItemConst {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ImplItemConst {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- defaultness: input.parse()?,
- const_token: input.parse()?,
- ident: input.parse()?,
- colon_token: input.parse()?,
- ty: input.parse()?,
- eq_token: input.parse()?,
- expr: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ImplItemMethod {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut attrs = input.call(Attribute::parse_outer)?;
- let vis: Visibility = input.parse()?;
- let defaultness: Option<Token![default]> = input.parse()?;
- let constness: Option<Token![const]> = input.parse()?;
- let asyncness: Option<Token![async]> = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let abi: Option<Abi> = input.parse()?;
- let fn_token: Token![fn] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
-
- let content;
- let paren_token = parenthesized!(content in input);
- let inputs = parse_fn_args(&content)?;
-
- let output: ReturnType = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
-
- let block = if let Some(semi) = input.parse::<Option<Token![;]>>()? {
- // Accept methods without a body in an impl block because
- // rustc's *parser* does not reject them (the compilation error
- // is emitted later than parsing) and it can be useful for macro
- // DSLs.
- let mut punct = Punct::new(';', Spacing::Alone);
- punct.set_span(semi.span);
- let tokens = TokenStream::from_iter(vec![TokenTree::Punct(punct)]);
- Block {
- brace_token: Brace::default(),
- stmts: vec![Stmt::Item(Item::Verbatim(tokens))],
- }
- } else {
- let content;
- let brace_token = braced!(content in input);
- attrs.extend(content.call(Attribute::parse_inner)?);
- Block {
- brace_token,
- stmts: content.call(Block::parse_within)?,
- }
- };
-
- Ok(ImplItemMethod {
- attrs,
- vis,
- defaultness,
- sig: Signature {
- constness,
- asyncness,
- unsafety,
- abi,
- fn_token,
- ident,
- paren_token,
- inputs,
- output,
- variadic: None,
- generics: Generics {
- where_clause,
- ..generics
- },
- },
- block,
- })
- }
- }
-
- impl Parse for ImplItemType {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(ImplItemType {
- attrs: input.call(Attribute::parse_outer)?,
- vis: input.parse()?,
- defaultness: input.parse()?,
- type_token: input.parse()?,
- ident: input.parse()?,
- generics: {
- let mut generics: Generics = input.parse()?;
- generics.where_clause = input.parse()?;
- generics
- },
- eq_token: input.parse()?,
- ty: input.parse()?,
- semi_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ImplItemMacro {
- fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
- let mac: Macro = input.parse()?;
- let semi_token: Option<Token![;]> = if mac.delimiter.is_brace() {
- None
- } else {
- Some(input.parse()?)
- };
- Ok(ImplItemMacro {
- attrs,
- mac,
- semi_token,
- })
- }
- }
-
- impl Visibility {
- fn is_inherited(&self) -> bool {
- match *self {
- Visibility::Inherited => true,
- _ => false,
- }
- }
- }
-
- impl MacroDelimiter {
- fn is_brace(&self) -> bool {
- match *self {
- MacroDelimiter::Brace(_) => true,
- MacroDelimiter::Paren(_) | MacroDelimiter::Bracket(_) => false,
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use crate::attr::FilterAttrs;
- use crate::print::TokensOrDefault;
-
- impl ToTokens for ItemExternCrate {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.extern_token.to_tokens(tokens);
- self.crate_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- if let Some((as_token, rename)) = &self.rename {
- as_token.to_tokens(tokens);
- rename.to_tokens(tokens);
- }
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemUse {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.use_token.to_tokens(tokens);
- self.leading_colon.to_tokens(tokens);
- self.tree.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemStatic {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.static_token.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemConst {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.const_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemFn {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.sig.to_tokens(tokens);
- self.block.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(&self.block.stmts);
- });
- }
- }
-
- impl ToTokens for ItemMod {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.mod_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- if let Some((brace, items)) = &self.content {
- brace.surround(tokens, |tokens| {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(items);
- });
- } else {
- TokensOrDefault(&self.semi).to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for ItemForeignMod {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.abi.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(&self.items);
- });
- }
- }
-
- impl ToTokens for ItemType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.type_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemEnum {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.enum_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- self.variants.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for ItemStruct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.struct_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- match &self.fields {
- Fields::Named(fields) => {
- self.generics.where_clause.to_tokens(tokens);
- fields.to_tokens(tokens);
- }
- Fields::Unnamed(fields) => {
- fields.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- TokensOrDefault(&self.semi_token).to_tokens(tokens);
- }
- Fields::Unit => {
- self.generics.where_clause.to_tokens(tokens);
- TokensOrDefault(&self.semi_token).to_tokens(tokens);
- }
- }
- }
- }
-
- impl ToTokens for ItemUnion {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.union_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.fields.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemTrait {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.unsafety.to_tokens(tokens);
- self.auto_token.to_tokens(tokens);
- self.trait_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- if !self.supertraits.is_empty() {
- TokensOrDefault(&self.colon_token).to_tokens(tokens);
- self.supertraits.to_tokens(tokens);
- }
- self.generics.where_clause.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- tokens.append_all(&self.items);
- });
- }
- }
-
- impl ToTokens for ItemTraitAlias {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.trait_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemImpl {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.defaultness.to_tokens(tokens);
- self.unsafety.to_tokens(tokens);
- self.impl_token.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- if let Some((polarity, path, for_token)) = &self.trait_ {
- polarity.to_tokens(tokens);
- path.to_tokens(tokens);
- for_token.to_tokens(tokens);
- }
- self.self_ty.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(&self.items);
- });
- }
- }
-
- impl ToTokens for ItemMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.mac.path.to_tokens(tokens);
- self.mac.bang_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- match &self.mac.delimiter {
- MacroDelimiter::Paren(paren) => {
- paren.surround(tokens, |tokens| self.mac.tokens.to_tokens(tokens));
- }
- MacroDelimiter::Brace(brace) => {
- brace.surround(tokens, |tokens| self.mac.tokens.to_tokens(tokens));
- }
- MacroDelimiter::Bracket(bracket) => {
- bracket.surround(tokens, |tokens| self.mac.tokens.to_tokens(tokens));
- }
- }
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ItemMacro2 {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.macro_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.rules.to_tokens(tokens);
- }
- }
-
- impl ToTokens for UsePath {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.ident.to_tokens(tokens);
- self.colon2_token.to_tokens(tokens);
- self.tree.to_tokens(tokens);
- }
- }
-
- impl ToTokens for UseName {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.ident.to_tokens(tokens);
- }
- }
-
- impl ToTokens for UseRename {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.ident.to_tokens(tokens);
- self.as_token.to_tokens(tokens);
- self.rename.to_tokens(tokens);
- }
- }
-
- impl ToTokens for UseGlob {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.star_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for UseGroup {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.brace_token.surround(tokens, |tokens| {
- self.items.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for TraitItemConst {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.const_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- if let Some((eq_token, default)) = &self.default {
- eq_token.to_tokens(tokens);
- default.to_tokens(tokens);
- }
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TraitItemMethod {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.sig.to_tokens(tokens);
- match &self.default {
- Some(block) => {
- block.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(&block.stmts);
- });
- }
- None => {
- TokensOrDefault(&self.semi_token).to_tokens(tokens);
- }
- }
- }
- }
-
- impl ToTokens for TraitItemType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.type_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- if !self.bounds.is_empty() {
- TokensOrDefault(&self.colon_token).to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- self.generics.where_clause.to_tokens(tokens);
- if let Some((eq_token, default)) = &self.default {
- eq_token.to_tokens(tokens);
- default.to_tokens(tokens);
- }
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TraitItemMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.mac.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ImplItemConst {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.defaultness.to_tokens(tokens);
- self.const_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.expr.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ImplItemMethod {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.defaultness.to_tokens(tokens);
- self.sig.to_tokens(tokens);
- if self.block.stmts.len() == 1 {
- if let Stmt::Item(Item::Verbatim(verbatim)) = &self.block.stmts[0] {
- if verbatim.to_string() == ";" {
- verbatim.to_tokens(tokens);
- return;
- }
- }
- }
- self.block.brace_token.surround(tokens, |tokens| {
- tokens.append_all(self.attrs.inner());
- tokens.append_all(&self.block.stmts);
- });
- }
- }
-
- impl ToTokens for ImplItemType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.defaultness.to_tokens(tokens);
- self.type_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ImplItemMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.mac.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ForeignItemFn {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.sig.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ForeignItemStatic {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.static_token.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ForeignItemType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.vis.to_tokens(tokens);
- self.type_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ForeignItemMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.mac.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- }
- }
-
- fn has_variadic(inputs: &Punctuated<FnArg, Token![,]>) -> bool {
- let last = match inputs.last() {
- Some(last) => last,
- None => return false,
- };
-
- let pat = match last {
- FnArg::Typed(pat) => pat,
- FnArg::Receiver(_) => return false,
- };
-
- let tokens = match pat.ty.as_ref() {
- Type::Verbatim(tokens) => tokens,
- _ => return false,
- };
-
- tokens.to_string() == "..."
- }
-
- impl ToTokens for Signature {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.constness.to_tokens(tokens);
- self.asyncness.to_tokens(tokens);
- self.unsafety.to_tokens(tokens);
- self.abi.to_tokens(tokens);
- self.fn_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- self.generics.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- self.inputs.to_tokens(tokens);
- if self.variadic.is_some() && !has_variadic(&self.inputs) {
- if !self.inputs.empty_or_trailing() {
- <Token![,]>::default().to_tokens(tokens);
- }
- self.variadic.to_tokens(tokens);
- }
- });
- self.output.to_tokens(tokens);
- self.generics.where_clause.to_tokens(tokens);
- }
- }
-
- impl ToTokens for Receiver {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- if let Some((ampersand, lifetime)) = &self.reference {
- ampersand.to_tokens(tokens);
- lifetime.to_tokens(tokens);
- }
- self.mutability.to_tokens(tokens);
- self.self_token.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/keyword.rs b/syn/src/keyword.rs
deleted file mode 100644
index e69de29..0000000
--- a/syn/src/keyword.rs
+++ /dev/null
diff --git a/syn/src/lib.rs b/syn/src/lib.rs
deleted file mode 100644
index 0f71014..0000000
--- a/syn/src/lib.rs
+++ /dev/null
@@ -1,947 +0,0 @@
-//! Syn is a parsing library for parsing a stream of Rust tokens into a syntax
-//! tree of Rust source code.
-//!
-//! Currently this library is geared toward use in Rust procedural macros, but
-//! contains some APIs that may be useful more generally.
-//!
-//! - **Data structures** — Syn provides a complete syntax tree that can
-//! represent any valid Rust source code. The syntax tree is rooted at
-//! [`syn::File`] which represents a full source file, but there are other
-//! entry points that may be useful to procedural macros including
-//! [`syn::Item`], [`syn::Expr`] and [`syn::Type`].
-//!
-//! - **Derives** — Of particular interest to derive macros is
-//! [`syn::DeriveInput`] which is any of the three legal input items to a
-//! derive macro. An example below shows using this type in a library that can
-//! derive implementations of a user-defined trait.
-//!
-//! - **Parsing** — Parsing in Syn is built around [parser functions] with the
-//! signature `fn(ParseStream) -> Result<T>`. Every syntax tree node defined
-//! by Syn is individually parsable and may be used as a building block for
-//! custom syntaxes, or you may dream up your own brand new syntax without
-//! involving any of our syntax tree types.
-//!
-//! - **Location information** — Every token parsed by Syn is associated with a
-//! `Span` that tracks line and column information back to the source of that
-//! token. These spans allow a procedural macro to display detailed error
-//! messages pointing to all the right places in the user's code. There is an
-//! example of this below.
-//!
-//! - **Feature flags** — Functionality is aggressively feature gated so your
-//! procedural macros enable only what they need, and do not pay in compile
-//! time for all the rest.
-//!
-//! [`syn::File`]: struct.File.html
-//! [`syn::Item`]: enum.Item.html
-//! [`syn::Expr`]: enum.Expr.html
-//! [`syn::Type`]: enum.Type.html
-//! [`syn::DeriveInput`]: struct.DeriveInput.html
-//! [parser functions]: parse/index.html
-//!
-//! <br>
-//!
-//! # Example of a derive macro
-//!
-//! The canonical derive macro using Syn looks like this. We write an ordinary
-//! Rust function tagged with a `proc_macro_derive` attribute and the name of
-//! the trait we are deriving. Any time that derive appears in the user's code,
-//! the Rust compiler passes their data structure as tokens into our macro. We
-//! get to execute arbitrary Rust code to figure out what to do with those
-//! tokens, then hand some tokens back to the compiler to compile into the
-//! user's crate.
-//!
-//! [`TokenStream`]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html
-//!
-//! ```toml
-//! [dependencies]
-//! syn = "1.0"
-//! quote = "1.0"
-//!
-//! [lib]
-//! proc-macro = true
-//! ```
-//!
-//! ```
-//! extern crate proc_macro;
-//!
-//! use proc_macro::TokenStream;
-//! use quote::quote;
-//! use syn::{parse_macro_input, DeriveInput};
-//!
-//! # const IGNORE_TOKENS: &str = stringify! {
-//! #[proc_macro_derive(MyMacro)]
-//! # };
-//! pub fn my_macro(input: TokenStream) -> TokenStream {
-//! // Parse the input tokens into a syntax tree
-//! let input = parse_macro_input!(input as DeriveInput);
-//!
-//! // Build the output, possibly using quasi-quotation
-//! let expanded = quote! {
-//! // ...
-//! };
-//!
-//! // Hand the output tokens back to the compiler
-//! TokenStream::from(expanded)
-//! }
-//! ```
-//!
-//! The [`heapsize`] example directory shows a complete working implementation
-//! of a derive macro. It works on any Rust compiler 1.31+. The example derives
-//! a `HeapSize` trait which computes an estimate of the amount of heap memory
-//! owned by a value.
-//!
-//! [`heapsize`]: https://github.com/dtolnay/syn/tree/master/examples/heapsize
-//!
-//! ```
-//! pub trait HeapSize {
-//! /// Total number of bytes of heap memory owned by `self`.
-//! fn heap_size_of_children(&self) -> usize;
-//! }
-//! ```
-//!
-//! The derive macro allows users to write `#[derive(HeapSize)]` on data
-//! structures in their program.
-//!
-//! ```
-//! # const IGNORE_TOKENS: &str = stringify! {
-//! #[derive(HeapSize)]
-//! # };
-//! struct Demo<'a, T: ?Sized> {
-//! a: Box<T>,
-//! b: u8,
-//! c: &'a str,
-//! d: String,
-//! }
-//! ```
-//!
-//! <p><br></p>
-//!
-//! # Spans and error reporting
-//!
-//! The token-based procedural macro API provides great control over where the
-//! compiler's error messages are displayed in user code. Consider the error the
-//! user sees if one of their field types does not implement `HeapSize`.
-//!
-//! ```
-//! # const IGNORE_TOKENS: &str = stringify! {
-//! #[derive(HeapSize)]
-//! # };
-//! struct Broken {
-//! ok: String,
-//! bad: std::thread::Thread,
-//! }
-//! ```
-//!
-//! By tracking span information all the way through the expansion of a
-//! procedural macro as shown in the `heapsize` example, token-based macros in
-//! Syn are able to trigger errors that directly pinpoint the source of the
-//! problem.
-//!
-//! ```text
-//! error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied
-//! --> src/main.rs:7:5
-//! |
-//! 7 | bad: std::thread::Thread,
-//! | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `Thread`
-//! ```
-//!
-//! <br>
-//!
-//! # Parsing a custom syntax
-//!
-//! The [`lazy-static`] example directory shows the implementation of a
-//! `functionlike!(...)` procedural macro in which the input tokens are parsed
-//! using Syn's parsing API.
-//!
-//! [`lazy-static`]: https://github.com/dtolnay/syn/tree/master/examples/lazy-static
-//!
-//! The example reimplements the popular `lazy_static` crate from crates.io as a
-//! procedural macro.
-//!
-//! ```
-//! # macro_rules! lazy_static {
-//! # ($($tt:tt)*) => {}
-//! # }
-//! #
-//! lazy_static! {
-//! static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap();
-//! }
-//! ```
-//!
-//! The implementation shows how to trigger custom warnings and error messages
-//! on the macro input.
-//!
-//! ```text
-//! warning: come on, pick a more creative name
-//! --> src/main.rs:10:16
-//! |
-//! 10 | static ref FOO: String = "lazy_static".to_owned();
-//! | ^^^
-//! ```
-//!
-//! <br>
-//!
-//! # Testing
-//!
-//! When testing macros, we often care not just that the macro can be used
-//! successfully but also that when the macro is provided with invalid input it
-//! produces maximally helpful error messages. Consider using the [`trybuild`]
-//! crate to write tests for errors that are emitted by your macro or errors
-//! detected by the Rust compiler in the expanded code following misuse of the
-//! macro. Such tests help avoid regressions from later refactors that
-//! mistakenly make an error no longer trigger or be less helpful than it used
-//! to be.
-//!
-//! [`trybuild`]: https://github.com/dtolnay/trybuild
-//!
-//! <br>
-//!
-//! # Debugging
-//!
-//! When developing a procedural macro it can be helpful to look at what the
-//! generated code looks like. Use `cargo rustc -- -Zunstable-options
-//! --pretty=expanded` or the [`cargo expand`] subcommand.
-//!
-//! [`cargo expand`]: https://github.com/dtolnay/cargo-expand
-//!
-//! To show the expanded code for some crate that uses your procedural macro,
-//! run `cargo expand` from that crate. To show the expanded code for one of
-//! your own test cases, run `cargo expand --test the_test_case` where the last
-//! argument is the name of the test file without the `.rs` extension.
-//!
-//! This write-up by Brandon W Maister discusses debugging in more detail:
-//! [Debugging Rust's new Custom Derive system][debugging].
-//!
-//! [debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/
-//!
-//! <br>
-//!
-//! # Optional features
-//!
-//! Syn puts a lot of functionality behind optional features in order to
-//! optimize compile time for the most common use cases. The following features
-//! are available.
-//!
-//! - **`derive`** *(enabled by default)* — Data structures for representing the
-//! possible input to a derive macro, including structs and enums and types.
-//! - **`full`** — Data structures for representing the syntax tree of all valid
-//! Rust source code, including items and expressions.
-//! - **`parsing`** *(enabled by default)* — Ability to parse input tokens into
-//! a syntax tree node of a chosen type.
-//! - **`printing`** *(enabled by default)* — Ability to print a syntax tree
-//! node as tokens of Rust source code.
-//! - **`visit`** — Trait for traversing a syntax tree.
-//! - **`visit-mut`** — Trait for traversing and mutating in place a syntax
-//! tree.
-//! - **`fold`** — Trait for transforming an owned syntax tree.
-//! - **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree
-//! types.
-//! - **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree
-//! types.
-//! - **`proc-macro`** *(enabled by default)* — Runtime dependency on the
-//! dynamic library libproc_macro from rustc toolchain.
-
-// Syn types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/syn/1.0.12")]
-#![deny(clippy::all, clippy::pedantic)]
-// Ignored clippy lints.
-#![allow(
- clippy::block_in_if_condition_stmt,
- clippy::cognitive_complexity,
- clippy::doc_markdown,
- clippy::eval_order_dependence,
- clippy::inherent_to_string,
- clippy::large_enum_variant,
- clippy::needless_doctest_main,
- clippy::needless_pass_by_value,
- clippy::never_loop,
- clippy::suspicious_op_assign_impl,
- clippy::too_many_arguments,
- clippy::trivially_copy_pass_by_ref
-)]
-// Ignored clippy_pedantic lints.
-#![allow(
- clippy::cast_possible_truncation,
- clippy::empty_enum,
- clippy::if_not_else,
- clippy::items_after_statements,
- clippy::missing_errors_doc,
- clippy::module_name_repetitions,
- clippy::must_use_candidate,
- clippy::shadow_unrelated,
- clippy::similar_names,
- clippy::single_match_else,
- clippy::too_many_lines,
- clippy::unseparated_literal_suffix,
- clippy::use_self,
- clippy::used_underscore_binding
-)]
-
-#[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "proc-macro"
-))]
-extern crate proc_macro;
-extern crate proc_macro2;
-extern crate unicode_xid;
-
-#[cfg(feature = "printing")]
-extern crate quote;
-
-#[cfg(any(feature = "full", feature = "derive"))]
-#[macro_use]
-mod macros;
-
-// Not public API.
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-#[macro_use]
-pub mod group;
-
-#[macro_use]
-pub mod token;
-
-mod ident;
-pub use crate::ident::Ident;
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod attr;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::attr::{
- AttrStyle, Attribute, AttributeArgs, Meta, MetaList, MetaNameValue, NestedMeta,
-};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod bigint;
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod data;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::data::{
- Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted,
- Visibility,
-};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod expr;
-#[cfg(feature = "full")]
-pub use crate::expr::{
- Arm, FieldValue, GenericMethodArgument, Label, MethodTurbofish, RangeLimits,
-};
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::expr::{
- Expr, ExprArray, ExprAssign, ExprAssignOp, ExprAsync, ExprAwait, ExprBinary, ExprBlock,
- ExprBox, ExprBreak, ExprCall, ExprCast, ExprClosure, ExprContinue, ExprField, ExprForLoop,
- ExprGroup, ExprIf, ExprIndex, ExprLet, ExprLit, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall,
- ExprParen, ExprPath, ExprRange, ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry,
- ExprTryBlock, ExprTuple, ExprType, ExprUnary, ExprUnsafe, ExprWhile, ExprYield, Index, Member,
-};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod generics;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::generics::{
- BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeDef, PredicateEq,
- PredicateLifetime, PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound,
- WhereClause, WherePredicate,
-};
-#[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
-pub use crate::generics::{ImplGenerics, Turbofish, TypeGenerics};
-
-#[cfg(feature = "full")]
-mod item;
-#[cfg(feature = "full")]
-pub use crate::item::{
- FnArg, ForeignItem, ForeignItemFn, ForeignItemMacro, ForeignItemStatic, ForeignItemType,
- ImplItem, ImplItemConst, ImplItemMacro, ImplItemMethod, ImplItemType, Item, ItemConst,
- ItemEnum, ItemExternCrate, ItemFn, ItemForeignMod, ItemImpl, ItemMacro, ItemMacro2, ItemMod,
- ItemStatic, ItemStruct, ItemTrait, ItemTraitAlias, ItemType, ItemUnion, ItemUse, Receiver,
- Signature, TraitItem, TraitItemConst, TraitItemMacro, TraitItemMethod, TraitItemType, UseGlob,
- UseGroup, UseName, UsePath, UseRename, UseTree,
-};
-
-#[cfg(feature = "full")]
-mod file;
-#[cfg(feature = "full")]
-pub use crate::file::File;
-
-mod lifetime;
-pub use crate::lifetime::Lifetime;
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod lit;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::lit::{
- Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle,
-};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod mac;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::mac::{Macro, MacroDelimiter};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod derive;
-#[cfg(feature = "derive")]
-pub use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod op;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::op::{BinOp, UnOp};
-
-#[cfg(feature = "full")]
-mod stmt;
-#[cfg(feature = "full")]
-pub use crate::stmt::{Block, Local, Stmt};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod ty;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::ty::{
- Abi, BareFnArg, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, TypeImplTrait, TypeInfer,
- TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, TypeSlice, TypeTraitObject,
- TypeTuple, Variadic,
-};
-
-#[cfg(feature = "full")]
-mod pat;
-#[cfg(feature = "full")]
-pub use crate::pat::{
- FieldPat, Pat, PatBox, PatIdent, PatLit, PatMacro, PatOr, PatPath, PatRange, PatReference,
- PatRest, PatSlice, PatStruct, PatTuple, PatTupleStruct, PatType, PatWild,
-};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-mod path;
-#[cfg(any(feature = "full", feature = "derive"))]
-pub use crate::path::{
- AngleBracketedGenericArguments, Binding, Constraint, GenericArgument,
- ParenthesizedGenericArguments, Path, PathArguments, PathSegment, QSelf,
-};
-
-#[cfg(feature = "parsing")]
-pub mod buffer;
-#[cfg(feature = "parsing")]
-pub mod ext;
-pub mod punctuated;
-#[cfg(all(any(feature = "full", feature = "derive"), feature = "extra-traits"))]
-mod tt;
-
-// Not public API except the `parse_quote!` macro.
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-pub mod parse_quote;
-
-// Not public API except the `parse_macro_input!` macro.
-#[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "parsing",
- feature = "proc-macro"
-))]
-#[doc(hidden)]
-pub mod parse_macro_input;
-
-#[cfg(all(feature = "parsing", feature = "printing"))]
-pub mod spanned;
-
-mod gen {
- /// Syntax tree traversal to walk a shared borrow of a syntax tree.
- ///
- /// Each method of the [`Visit`] trait is a hook that can be overridden to
- /// customize the behavior when visiting the corresponding type of node. By
- /// default, every method recursively visits the substructure of the input
- /// by invoking the right visitor method of each of its fields.
- ///
- /// [`Visit`]: visit::Visit
- ///
- /// ```
- /// # use syn::{Attribute, BinOp, Expr, ExprBinary};
- /// #
- /// pub trait Visit<'ast> {
- /// /* ... */
- ///
- /// fn visit_expr_binary(&mut self, node: &'ast ExprBinary) {
- /// visit_expr_binary(self, node);
- /// }
- ///
- /// /* ... */
- /// # fn visit_attribute(&mut self, node: &'ast Attribute);
- /// # fn visit_expr(&mut self, node: &'ast Expr);
- /// # fn visit_bin_op(&mut self, node: &'ast BinOp);
- /// }
- ///
- /// pub fn visit_expr_binary<'ast, V>(v: &mut V, node: &'ast ExprBinary)
- /// where
- /// V: Visit<'ast> + ?Sized,
- /// {
- /// for attr in &node.attrs {
- /// v.visit_attribute(attr);
- /// }
- /// v.visit_expr(&*node.left);
- /// v.visit_bin_op(&node.op);
- /// v.visit_expr(&*node.right);
- /// }
- ///
- /// /* ... */
- /// ```
- ///
- /// *This module is available if Syn is built with the `"visit"` feature.*
- ///
- /// <br>
- ///
- /// # Example
- ///
- /// This visitor will print the name of every freestanding function in the
- /// syntax tree, including nested functions.
- ///
- /// ```
- /// // [dependencies]
- /// // quote = "1.0"
- /// // syn = { version = "1.0", features = ["full", "visit"] }
- ///
- /// use quote::quote;
- /// use syn::visit::{self, Visit};
- /// use syn::{File, ItemFn};
- ///
- /// struct FnVisitor;
- ///
- /// impl<'ast> Visit<'ast> for FnVisitor {
- /// fn visit_item_fn(&mut self, node: &'ast ItemFn) {
- /// println!("Function with name={}", node.sig.ident);
- ///
- /// // Delegate to the default impl to visit any nested functions.
- /// visit::visit_item_fn(self, node);
- /// }
- /// }
- ///
- /// fn main() {
- /// let code = quote! {
- /// pub fn f() {
- /// fn g() {}
- /// }
- /// };
- ///
- /// let syntax_tree: File = syn::parse2(code).unwrap();
- /// FnVisitor.visit_file(&syntax_tree);
- /// }
- /// ```
- ///
- /// The `'ast` lifetime on the input references means that the syntax tree
- /// outlives the complete recursive visit call, so the visitor is allowed to
- /// hold on to references into the syntax tree.
- ///
- /// ```
- /// use quote::quote;
- /// use syn::visit::{self, Visit};
- /// use syn::{File, ItemFn};
- ///
- /// struct FnVisitor<'ast> {
- /// functions: Vec<&'ast ItemFn>,
- /// }
- ///
- /// impl<'ast> Visit<'ast> for FnVisitor<'ast> {
- /// fn visit_item_fn(&mut self, node: &'ast ItemFn) {
- /// self.functions.push(node);
- /// visit::visit_item_fn(self, node);
- /// }
- /// }
- ///
- /// fn main() {
- /// let code = quote! {
- /// pub fn f() {
- /// fn g() {}
- /// }
- /// };
- ///
- /// let syntax_tree: File = syn::parse2(code).unwrap();
- /// let mut visitor = FnVisitor { functions: Vec::new() };
- /// visitor.visit_file(&syntax_tree);
- /// for f in visitor.functions {
- /// println!("Function with name={}", f.sig.ident);
- /// }
- /// }
- /// ```
- #[cfg(feature = "visit")]
- #[rustfmt::skip]
- pub mod visit;
-
- /// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in
- /// place.
- ///
- /// Each method of the [`VisitMut`] trait is a hook that can be overridden
- /// to customize the behavior when mutating the corresponding type of node.
- /// By default, every method recursively visits the substructure of the
- /// input by invoking the right visitor method of each of its fields.
- ///
- /// [`VisitMut`]: visit_mut::VisitMut
- ///
- /// ```
- /// # use syn::{Attribute, BinOp, Expr, ExprBinary};
- /// #
- /// pub trait VisitMut {
- /// /* ... */
- ///
- /// fn visit_expr_binary_mut(&mut self, node: &mut ExprBinary) {
- /// visit_expr_binary_mut(self, node);
- /// }
- ///
- /// /* ... */
- /// # fn visit_attribute_mut(&mut self, node: &mut Attribute);
- /// # fn visit_expr_mut(&mut self, node: &mut Expr);
- /// # fn visit_bin_op_mut(&mut self, node: &mut BinOp);
- /// }
- ///
- /// pub fn visit_expr_binary_mut<V>(v: &mut V, node: &mut ExprBinary)
- /// where
- /// V: VisitMut + ?Sized,
- /// {
- /// for attr in &mut node.attrs {
- /// v.visit_attribute_mut(attr);
- /// }
- /// v.visit_expr_mut(&mut *node.left);
- /// v.visit_bin_op_mut(&mut node.op);
- /// v.visit_expr_mut(&mut *node.right);
- /// }
- ///
- /// /* ... */
- /// ```
- ///
- /// *This module is available if Syn is built with the `"visit-mut"`
- /// feature.*
- ///
- /// <br>
- ///
- /// # Example
- ///
- /// This mut visitor replace occurrences of u256 suffixed integer literals
- /// like `999u256` with a macro invocation `bigint::u256!(999)`.
- ///
- /// ```
- /// // [dependencies]
- /// // quote = "1.0"
- /// // syn = { version = "1.0", features = ["full", "visit-mut"] }
- ///
- /// use quote::quote;
- /// use syn::visit_mut::{self, VisitMut};
- /// use syn::{parse_quote, Expr, File, Lit, LitInt};
- ///
- /// struct BigintReplace;
- ///
- /// impl VisitMut for BigintReplace {
- /// fn visit_expr_mut(&mut self, node: &mut Expr) {
- /// if let Expr::Lit(expr) = &node {
- /// if let Lit::Int(int) = &expr.lit {
- /// if int.suffix() == "u256" {
- /// let digits = int.base10_digits();
- /// let unsuffixed: LitInt = syn::parse_str(digits).unwrap();
- /// *node = parse_quote!(bigint::u256!(#unsuffixed));
- /// return;
- /// }
- /// }
- /// }
- ///
- /// // Delegate to the default impl to visit nested expressions.
- /// visit_mut::visit_expr_mut(self, node);
- /// }
- /// }
- ///
- /// fn main() {
- /// let code = quote! {
- /// fn main() {
- /// let _ = 999u256;
- /// }
- /// };
- ///
- /// let mut syntax_tree: File = syn::parse2(code).unwrap();
- /// BigintReplace.visit_file_mut(&mut syntax_tree);
- /// println!("{}", quote!(#syntax_tree));
- /// }
- /// ```
- #[cfg(feature = "visit-mut")]
- #[rustfmt::skip]
- pub mod visit_mut;
-
- /// Syntax tree traversal to transform the nodes of an owned syntax tree.
- ///
- /// Each method of the [`Fold`] trait is a hook that can be overridden to
- /// customize the behavior when transforming the corresponding type of node.
- /// By default, every method recursively visits the substructure of the
- /// input by invoking the right visitor method of each of its fields.
- ///
- /// [`Fold`]: fold::Fold
- ///
- /// ```
- /// # use syn::{Attribute, BinOp, Expr, ExprBinary};
- /// #
- /// pub trait Fold {
- /// /* ... */
- ///
- /// fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary {
- /// fold_expr_binary(self, node)
- /// }
- ///
- /// /* ... */
- /// # fn fold_attribute(&mut self, node: Attribute) -> Attribute;
- /// # fn fold_expr(&mut self, node: Expr) -> Expr;
- /// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp;
- /// }
- ///
- /// pub fn fold_expr_binary<V>(v: &mut V, node: ExprBinary) -> ExprBinary
- /// where
- /// V: Fold + ?Sized,
- /// {
- /// ExprBinary {
- /// attrs: node
- /// .attrs
- /// .into_iter()
- /// .map(|attr| v.fold_attribute(attr))
- /// .collect(),
- /// left: Box::new(v.fold_expr(*node.left)),
- /// op: v.fold_bin_op(node.op),
- /// right: Box::new(v.fold_expr(*node.right)),
- /// }
- /// }
- ///
- /// /* ... */
- /// ```
- ///
- /// *This module is available if Syn is built with the `"fold"` feature.*
- ///
- /// <br>
- ///
- /// # Example
- ///
- /// This fold inserts parentheses to fully parenthesizes any expression.
- ///
- /// ```
- /// // [dependencies]
- /// // quote = "1.0"
- /// // syn = { version = "1.0", features = ["fold", "full"] }
- ///
- /// use quote::quote;
- /// use syn::fold::{fold_expr, Fold};
- /// use syn::{token, Expr, ExprParen};
- ///
- /// struct ParenthesizeEveryExpr;
- ///
- /// impl Fold for ParenthesizeEveryExpr {
- /// fn fold_expr(&mut self, expr: Expr) -> Expr {
- /// Expr::Paren(ExprParen {
- /// attrs: Vec::new(),
- /// expr: Box::new(fold_expr(self, expr)),
- /// paren_token: token::Paren::default(),
- /// })
- /// }
- /// }
- ///
- /// fn main() {
- /// let code = quote! { a() + b(1) * c.d };
- /// let expr: Expr = syn::parse2(code).unwrap();
- /// let parenthesized = ParenthesizeEveryExpr.fold_expr(expr);
- /// println!("{}", quote!(#parenthesized));
- ///
- /// // Output: (((a)()) + (((b)((1))) * ((c).d)))
- /// }
- /// ```
- #[cfg(feature = "fold")]
- #[rustfmt::skip]
- pub mod fold;
-
- #[cfg(any(feature = "full", feature = "derive"))]
- #[path = "../gen_helper.rs"]
- mod helper;
-}
-pub use crate::gen::*;
-
-// Not public API.
-#[doc(hidden)]
-pub mod export;
-
-mod custom_keyword;
-mod custom_punctuation;
-mod sealed;
-
-#[cfg(feature = "parsing")]
-mod lookahead;
-
-#[cfg(feature = "parsing")]
-pub mod parse;
-
-mod span;
-
-#[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
-mod print;
-
-mod thread;
-
-////////////////////////////////////////////////////////////////////////////////
-
-#[allow(dead_code, non_camel_case_types)]
-struct private;
-
-// https://github.com/rust-lang/rust/issues/62830
-#[cfg(feature = "parsing")]
-mod rustdoc_workaround {
- pub use crate::parse::{self as parse_module};
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-mod error;
-pub use crate::error::{Error, Result};
-
-/// Parse tokens of source code into the chosen syntax tree node.
-///
-/// This is preferred over parsing a string because tokens are able to preserve
-/// information about where in the user's code they were originally written (the
-/// "span" of the token), possibly allowing the compiler to produce better error
-/// messages.
-///
-/// This function parses a `proc_macro::TokenStream` which is the type used for
-/// interop with the compiler in a procedural macro. To parse a
-/// `proc_macro2::TokenStream`, use [`syn::parse2`] instead.
-///
-/// [`syn::parse2`]: parse2
-///
-/// *This function is available if Syn is built with both the `"parsing"` and
-/// `"proc-macro"` features.*
-///
-/// # Examples
-///
-/// ```
-/// extern crate proc_macro;
-///
-/// use proc_macro::TokenStream;
-/// use quote::quote;
-/// use syn::DeriveInput;
-///
-/// # const IGNORE_TOKENS: &str = stringify! {
-/// #[proc_macro_derive(MyMacro)]
-/// # };
-/// pub fn my_macro(input: TokenStream) -> TokenStream {
-/// // Parse the tokens into a syntax tree
-/// let ast: DeriveInput = syn::parse(input).unwrap();
-///
-/// // Build the output, possibly using quasi-quotation
-/// let expanded = quote! {
-/// /* ... */
-/// };
-///
-/// // Convert into a token stream and return it
-/// expanded.into()
-/// }
-/// ```
-#[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "parsing",
- feature = "proc-macro"
-))]
-pub fn parse<T: parse::Parse>(tokens: proc_macro::TokenStream) -> Result<T> {
- parse::Parser::parse(T::parse, tokens)
-}
-
-/// Parse a proc-macro2 token stream into the chosen syntax tree node.
-///
-/// This function parses a `proc_macro2::TokenStream` which is commonly useful
-/// when the input comes from a node of the Syn syntax tree, for example the
-/// body tokens of a [`Macro`] node. When in a procedural macro parsing the
-/// `proc_macro::TokenStream` provided by the compiler, use [`syn::parse`]
-/// instead.
-///
-/// [`syn::parse`]: parse()
-///
-/// *This function is available if Syn is built with the `"parsing"` feature.*
-#[cfg(feature = "parsing")]
-pub fn parse2<T: parse::Parse>(tokens: proc_macro2::TokenStream) -> Result<T> {
- parse::Parser::parse2(T::parse, tokens)
-}
-
-/// Parse a string of Rust code into the chosen syntax tree node.
-///
-/// *This function is available if Syn is built with the `"parsing"` feature.*
-///
-/// # Hygiene
-///
-/// Every span in the resulting syntax tree will be set to resolve at the macro
-/// call site.
-///
-/// # Examples
-///
-/// ```
-/// use syn::{Expr, Result};
-///
-/// fn run() -> Result<()> {
-/// let code = "assert_eq!(u8::max_value(), 255)";
-/// let expr = syn::parse_str::<Expr>(code)?;
-/// println!("{:#?}", expr);
-/// Ok(())
-/// }
-/// #
-/// # run().unwrap();
-/// ```
-#[cfg(feature = "parsing")]
-pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> {
- parse::Parser::parse_str(T::parse, s)
-}
-
-// FIXME the name parse_file makes it sound like you might pass in a path to a
-// file, rather than the content.
-/// Parse the content of a file of Rust code.
-///
-/// This is different from `syn::parse_str::<File>(content)` in two ways:
-///
-/// - It discards a leading byte order mark `\u{FEFF}` if the file has one.
-/// - It preserves the shebang line of the file, such as `#!/usr/bin/env rustx`.
-///
-/// If present, either of these would be an error using `from_str`.
-///
-/// *This function is available if Syn is built with the `"parsing"` and
-/// `"full"` features.*
-///
-/// # Examples
-///
-/// ```no_run
-/// use std::error::Error;
-/// use std::fs::File;
-/// use std::io::Read;
-///
-/// fn run() -> Result<(), Box<Error>> {
-/// let mut file = File::open("path/to/code.rs")?;
-/// let mut content = String::new();
-/// file.read_to_string(&mut content)?;
-///
-/// let ast = syn::parse_file(&content)?;
-/// if let Some(shebang) = ast.shebang {
-/// println!("{}", shebang);
-/// }
-/// println!("{} items", ast.items.len());
-///
-/// Ok(())
-/// }
-/// #
-/// # run().unwrap();
-/// ```
-#[cfg(all(feature = "parsing", feature = "full"))]
-pub fn parse_file(mut content: &str) -> Result<File> {
- // Strip the BOM if it is present
- const BOM: &str = "\u{feff}";
- if content.starts_with(BOM) {
- content = &content[BOM.len()..];
- }
-
- let mut shebang = None;
- if content.starts_with("#!") && !content.starts_with("#![") {
- if let Some(idx) = content.find('\n') {
- shebang = Some(content[..idx].to_string());
- content = &content[idx..];
- } else {
- shebang = Some(content.to_string());
- content = "";
- }
- }
-
- let mut file: File = parse_str(content)?;
- file.shebang = shebang;
- Ok(file)
-}
diff --git a/syn/src/lifetime.rs b/syn/src/lifetime.rs
deleted file mode 100644
index d51c48e..0000000
--- a/syn/src/lifetime.rs
+++ /dev/null
@@ -1,140 +0,0 @@
-use std::cmp::Ordering;
-use std::fmt::{self, Display};
-use std::hash::{Hash, Hasher};
-
-use proc_macro2::{Ident, Span};
-
-#[cfg(feature = "parsing")]
-use crate::lookahead;
-
-/// A Rust lifetime: `'a`.
-///
-/// Lifetime names must conform to the following rules:
-///
-/// - Must start with an apostrophe.
-/// - Must not consist of just an apostrophe: `'`.
-/// - Character after the apostrophe must be `_` or a Unicode code point with
-/// the XID_Start property.
-/// - All following characters must be Unicode code points with the XID_Continue
-/// property.
-///
-/// *This type is available if Syn is built with the `"derive"` or `"full"`
-/// feature.*
-#[cfg_attr(feature = "extra-traits", derive(Debug))]
-#[derive(Clone)]
-pub struct Lifetime {
- pub apostrophe: Span,
- pub ident: Ident,
-}
-
-impl Lifetime {
- /// # Panics
- ///
- /// Panics if the lifetime does not conform to the bulleted rules above.
- ///
- /// # Invocation
- ///
- /// ```
- /// # use proc_macro2::Span;
- /// # use syn::Lifetime;
- /// #
- /// # fn f() -> Lifetime {
- /// Lifetime::new("'a", Span::call_site())
- /// # }
- /// ```
- pub fn new(symbol: &str, span: Span) -> Self {
- if !symbol.starts_with('\'') {
- panic!(
- "lifetime name must start with apostrophe as in \"'a\", got {:?}",
- symbol
- );
- }
-
- if symbol == "'" {
- panic!("lifetime name must not be empty");
- }
-
- if !crate::ident::xid_ok(&symbol[1..]) {
- panic!("{:?} is not a valid lifetime name", symbol);
- }
-
- Lifetime {
- apostrophe: span,
- ident: Ident::new(&symbol[1..], span),
- }
- }
-}
-
-impl Display for Lifetime {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- "'".fmt(formatter)?;
- self.ident.fmt(formatter)
- }
-}
-
-impl PartialEq for Lifetime {
- fn eq(&self, other: &Lifetime) -> bool {
- self.ident.eq(&other.ident)
- }
-}
-
-impl Eq for Lifetime {}
-
-impl PartialOrd for Lifetime {
- fn partial_cmp(&self, other: &Lifetime) -> Option<Ordering> {
- Some(self.cmp(other))
- }
-}
-
-impl Ord for Lifetime {
- fn cmp(&self, other: &Lifetime) -> Ordering {
- self.ident.cmp(&other.ident)
- }
-}
-
-impl Hash for Lifetime {
- fn hash<H: Hasher>(&self, h: &mut H) {
- self.ident.hash(h)
- }
-}
-
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-#[allow(non_snake_case)]
-pub fn Lifetime(marker: lookahead::TokenMarker) -> Lifetime {
- match marker {}
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for Lifetime {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| {
- cursor
- .lifetime()
- .ok_or_else(|| cursor.error("expected lifetime"))
- })
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::{Punct, Spacing, TokenStream};
- use quote::{ToTokens, TokenStreamExt};
-
- impl ToTokens for Lifetime {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- let mut apostrophe = Punct::new('\'', Spacing::Joint);
- apostrophe.set_span(self.apostrophe);
- tokens.append(apostrophe);
- self.ident.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/lit.rs b/syn/src/lit.rs
deleted file mode 100644
index abc4ec2..0000000
--- a/syn/src/lit.rs
+++ /dev/null
@@ -1,1382 +0,0 @@
-use proc_macro2::{Literal, Span};
-use std::fmt::{self, Display};
-use std::str::{self, FromStr};
-
-#[cfg(feature = "printing")]
-use proc_macro2::Ident;
-
-#[cfg(feature = "parsing")]
-use proc_macro2::TokenStream;
-
-use proc_macro2::TokenTree;
-
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-
-#[cfg(feature = "parsing")]
-use crate::lookahead;
-#[cfg(feature = "parsing")]
-use crate::parse::{Parse, Parser};
-use crate::{Error, Result};
-
-ast_enum_of_structs! {
- /// A Rust literal such as a string or integer or boolean.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Lit #manual_extra_traits {
- /// A UTF-8 string literal: `"foo"`.
- Str(LitStr),
-
- /// A byte string literal: `b"foo"`.
- ByteStr(LitByteStr),
-
- /// A byte literal: `b'f'`.
- Byte(LitByte),
-
- /// A character literal: `'a'`.
- Char(LitChar),
-
- /// An integer literal: `1` or `1u16`.
- Int(LitInt),
-
- /// A floating point literal: `1f64` or `1.0e10f64`.
- ///
- /// Must be finite. May not be infinte or NaN.
- Float(LitFloat),
-
- /// A boolean literal: `true` or `false`.
- Bool(LitBool),
-
- /// A raw token literal not interpreted by Syn.
- Verbatim(Literal),
- }
-}
-
-ast_struct! {
- /// A UTF-8 string literal: `"foo"`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitStr #manual_extra_traits_debug {
- repr: Box<LitStrRepr>,
- }
-}
-
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-struct LitStrRepr {
- token: Literal,
- suffix: Box<str>,
-}
-
-ast_struct! {
- /// A byte string literal: `b"foo"`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitByteStr #manual_extra_traits_debug {
- token: Literal,
- }
-}
-
-ast_struct! {
- /// A byte literal: `b'f'`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitByte #manual_extra_traits_debug {
- token: Literal,
- }
-}
-
-ast_struct! {
- /// A character literal: `'a'`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitChar #manual_extra_traits_debug {
- token: Literal,
- }
-}
-
-ast_struct! {
- /// An integer literal: `1` or `1u16`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitInt #manual_extra_traits_debug {
- repr: Box<LitIntRepr>,
- }
-}
-
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-struct LitIntRepr {
- token: Literal,
- digits: Box<str>,
- suffix: Box<str>,
-}
-
-ast_struct! {
- /// A floating point literal: `1f64` or `1.0e10f64`.
- ///
- /// Must be finite. May not be infinte or NaN.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitFloat #manual_extra_traits_debug {
- repr: Box<LitFloatRepr>,
- }
-}
-
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-struct LitFloatRepr {
- token: Literal,
- digits: Box<str>,
- suffix: Box<str>,
-}
-
-ast_struct! {
- /// A boolean literal: `true` or `false`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct LitBool #manual_extra_traits_debug {
- pub value: bool,
- pub span: Span,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Lit {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Lit {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (Lit::Str(this), Lit::Str(other)) => this == other,
- (Lit::ByteStr(this), Lit::ByteStr(other)) => this == other,
- (Lit::Byte(this), Lit::Byte(other)) => this == other,
- (Lit::Char(this), Lit::Char(other)) => this == other,
- (Lit::Int(this), Lit::Int(other)) => this == other,
- (Lit::Float(this), Lit::Float(other)) => this == other,
- (Lit::Bool(this), Lit::Bool(other)) => this == other,
- (Lit::Verbatim(this), Lit::Verbatim(other)) => this.to_string() == other.to_string(),
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Lit {
- fn hash<H>(&self, hash: &mut H)
- where
- H: Hasher,
- {
- match self {
- Lit::Str(lit) => {
- hash.write_u8(0);
- lit.hash(hash);
- }
- Lit::ByteStr(lit) => {
- hash.write_u8(1);
- lit.hash(hash);
- }
- Lit::Byte(lit) => {
- hash.write_u8(2);
- lit.hash(hash);
- }
- Lit::Char(lit) => {
- hash.write_u8(3);
- lit.hash(hash);
- }
- Lit::Int(lit) => {
- hash.write_u8(4);
- lit.hash(hash);
- }
- Lit::Float(lit) => {
- hash.write_u8(5);
- lit.hash(hash);
- }
- Lit::Bool(lit) => {
- hash.write_u8(6);
- lit.hash(hash);
- }
- Lit::Verbatim(lit) => {
- hash.write_u8(7);
- lit.to_string().hash(hash);
- }
- }
- }
-}
-
-impl LitStr {
- pub fn new(value: &str, span: Span) -> Self {
- let mut lit = Literal::string(value);
- lit.set_span(span);
- LitStr {
- repr: Box::new(LitStrRepr {
- token: lit,
- suffix: Box::<str>::default(),
- }),
- }
- }
-
- pub fn value(&self) -> String {
- let (value, _) = value::parse_lit_str(&self.repr.token.to_string());
- String::from(value)
- }
-
- /// Parse a syntax tree node from the content of this string literal.
- ///
- /// All spans in the syntax tree will point to the span of this `LitStr`.
- ///
- /// # Example
- ///
- /// ```
- /// use proc_macro2::Span;
- /// use syn::{Attribute, Error, Ident, Lit, Meta, MetaNameValue, Path, Result};
- ///
- /// // Parses the path from an attribute that looks like:
- /// //
- /// // #[path = "a::b::c"]
- /// //
- /// // or returns `None` if the input is some other attribute.
- /// fn get_path(attr: &Attribute) -> Result<Option<Path>> {
- /// if !attr.path.is_ident("path") {
- /// return Ok(None);
- /// }
- ///
- /// match attr.parse_meta()? {
- /// Meta::NameValue(MetaNameValue { lit: Lit::Str(lit_str), .. }) => {
- /// lit_str.parse().map(Some)
- /// }
- /// _ => {
- /// let message = "expected #[path = \"...\"]";
- /// Err(Error::new_spanned(attr, message))
- /// }
- /// }
- /// }
- /// ```
- #[cfg(feature = "parsing")]
- pub fn parse<T: Parse>(&self) -> Result<T> {
- self.parse_with(T::parse)
- }
-
- /// Invoke parser on the content of this string literal.
- ///
- /// All spans in the syntax tree will point to the span of this `LitStr`.
- ///
- /// # Example
- ///
- /// ```
- /// # use proc_macro2::Span;
- /// # use syn::{LitStr, Result};
- /// #
- /// # fn main() -> Result<()> {
- /// # let lit_str = LitStr::new("a::b::c", Span::call_site());
- /// #
- /// # const IGNORE: &str = stringify! {
- /// let lit_str: LitStr = /* ... */;
- /// # };
- ///
- /// // Parse a string literal like "a::b::c" into a Path, not allowing
- /// // generic arguments on any of the path segments.
- /// let basic_path = lit_str.parse_with(syn::Path::parse_mod_style)?;
- /// #
- /// # Ok(())
- /// # }
- /// ```
- #[cfg(feature = "parsing")]
- pub fn parse_with<F: Parser>(&self, parser: F) -> Result<F::Output> {
- use proc_macro2::Group;
-
- // Token stream with every span replaced by the given one.
- fn respan_token_stream(stream: TokenStream, span: Span) -> TokenStream {
- stream
- .into_iter()
- .map(|token| respan_token_tree(token, span))
- .collect()
- }
-
- // Token tree with every span replaced by the given one.
- fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree {
- match &mut token {
- TokenTree::Group(g) => {
- let stream = respan_token_stream(g.stream(), span);
- *g = Group::new(g.delimiter(), stream);
- g.set_span(span);
- }
- other => other.set_span(span),
- }
- token
- }
-
- // Parse string literal into a token stream with every span equal to the
- // original literal's span.
- let mut tokens = crate::parse_str(&self.value())?;
- tokens = respan_token_stream(tokens, self.span());
-
- parser.parse2(tokens)
- }
-
- pub fn span(&self) -> Span {
- self.repr.token.span()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.repr.token.set_span(span)
- }
-
- pub fn suffix(&self) -> &str {
- &self.repr.suffix
- }
-}
-
-impl LitByteStr {
- pub fn new(value: &[u8], span: Span) -> Self {
- let mut token = Literal::byte_string(value);
- token.set_span(span);
- LitByteStr { token }
- }
-
- pub fn value(&self) -> Vec<u8> {
- value::parse_lit_byte_str(&self.token.to_string())
- }
-
- pub fn span(&self) -> Span {
- self.token.span()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.token.set_span(span)
- }
-}
-
-impl LitByte {
- pub fn new(value: u8, span: Span) -> Self {
- let mut token = Literal::u8_suffixed(value);
- token.set_span(span);
- LitByte { token }
- }
-
- pub fn value(&self) -> u8 {
- value::parse_lit_byte(&self.token.to_string())
- }
-
- pub fn span(&self) -> Span {
- self.token.span()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.token.set_span(span)
- }
-}
-
-impl LitChar {
- pub fn new(value: char, span: Span) -> Self {
- let mut token = Literal::character(value);
- token.set_span(span);
- LitChar { token }
- }
-
- pub fn value(&self) -> char {
- value::parse_lit_char(&self.token.to_string())
- }
-
- pub fn span(&self) -> Span {
- self.token.span()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.token.set_span(span)
- }
-}
-
-impl LitInt {
- pub fn new(repr: &str, span: Span) -> Self {
- if let Some((digits, suffix)) = value::parse_lit_int(repr) {
- let mut token = value::to_literal(repr);
- token.set_span(span);
- LitInt {
- repr: Box::new(LitIntRepr {
- token,
- digits,
- suffix,
- }),
- }
- } else {
- panic!("Not an integer literal: `{}`", repr);
- }
- }
-
- pub fn base10_digits(&self) -> &str {
- &self.repr.digits
- }
-
- /// Parses the literal into a selected number type.
- ///
- /// This is equivalent to `lit.base10_digits().parse()` except that the
- /// resulting errors will be correctly spanned to point to the literal token
- /// in the macro input.
- ///
- /// ```
- /// use syn::LitInt;
- /// use syn::parse::{Parse, ParseStream, Result};
- ///
- /// struct Port {
- /// value: u16,
- /// }
- ///
- /// impl Parse for Port {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let lit: LitInt = input.parse()?;
- /// let value = lit.base10_parse::<u16>()?;
- /// Ok(Port { value })
- /// }
- /// }
- /// ```
- pub fn base10_parse<N>(&self) -> Result<N>
- where
- N: FromStr,
- N::Err: Display,
- {
- self.base10_digits()
- .parse()
- .map_err(|err| Error::new(self.span(), err))
- }
-
- pub fn suffix(&self) -> &str {
- &self.repr.suffix
- }
-
- pub fn span(&self) -> Span {
- self.repr.token.span()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.repr.token.set_span(span)
- }
-}
-
-impl From<Literal> for LitInt {
- fn from(token: Literal) -> Self {
- let repr = token.to_string();
- if let Some((digits, suffix)) = value::parse_lit_int(&repr) {
- LitInt {
- repr: Box::new(LitIntRepr {
- token,
- digits,
- suffix,
- }),
- }
- } else {
- panic!("Not an integer literal: `{}`", repr);
- }
- }
-}
-
-impl Display for LitInt {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- self.repr.token.fmt(formatter)
- }
-}
-
-impl LitFloat {
- pub fn new(repr: &str, span: Span) -> Self {
- if let Some((digits, suffix)) = value::parse_lit_float(repr) {
- let mut token = value::to_literal(repr);
- token.set_span(span);
- LitFloat {
- repr: Box::new(LitFloatRepr {
- token,
- digits,
- suffix,
- }),
- }
- } else {
- panic!("Not a float literal: `{}`", repr);
- }
- }
-
- pub fn base10_digits(&self) -> &str {
- &self.repr.digits
- }
-
- pub fn base10_parse<N>(&self) -> Result<N>
- where
- N: FromStr,
- N::Err: Display,
- {
- self.base10_digits()
- .parse()
- .map_err(|err| Error::new(self.span(), err))
- }
-
- pub fn suffix(&self) -> &str {
- &self.repr.suffix
- }
-
- pub fn span(&self) -> Span {
- self.repr.token.span()
- }
-
- pub fn set_span(&mut self, span: Span) {
- self.repr.token.set_span(span)
- }
-}
-
-impl From<Literal> for LitFloat {
- fn from(token: Literal) -> Self {
- let repr = token.to_string();
- if let Some((digits, suffix)) = value::parse_lit_float(&repr) {
- LitFloat {
- repr: Box::new(LitFloatRepr {
- token,
- digits,
- suffix,
- }),
- }
- } else {
- panic!("Not a float literal: `{}`", repr);
- }
- }
-}
-
-impl Display for LitFloat {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- self.repr.token.fmt(formatter)
- }
-}
-
-#[cfg(feature = "extra-traits")]
-mod debug_impls {
- use super::*;
- use std::fmt::{self, Debug};
-
- impl Debug for LitStr {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitStr")
- .field("token", &format_args!("{}", self.repr.token))
- .finish()
- }
- }
-
- impl Debug for LitByteStr {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitByteStr")
- .field("token", &format_args!("{}", self.token))
- .finish()
- }
- }
-
- impl Debug for LitByte {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitByte")
- .field("token", &format_args!("{}", self.token))
- .finish()
- }
- }
-
- impl Debug for LitChar {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitChar")
- .field("token", &format_args!("{}", self.token))
- .finish()
- }
- }
-
- impl Debug for LitInt {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitInt")
- .field("token", &format_args!("{}", self.repr.token))
- .finish()
- }
- }
-
- impl Debug for LitFloat {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitFloat")
- .field("token", &format_args!("{}", self.repr.token))
- .finish()
- }
- }
-
- impl Debug for LitBool {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_struct("LitBool")
- .field("value", &self.value)
- .finish()
- }
- }
-}
-
-macro_rules! lit_extra_traits {
- ($ty:ident, $($field:ident).+) => {
- #[cfg(feature = "extra-traits")]
- impl Eq for $ty {}
-
- #[cfg(feature = "extra-traits")]
- impl PartialEq for $ty {
- fn eq(&self, other: &Self) -> bool {
- self.$($field).+.to_string() == other.$($field).+.to_string()
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Hash for $ty {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- self.$($field).+.to_string().hash(state);
- }
- }
-
- #[cfg(feature = "parsing")]
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn $ty(marker: lookahead::TokenMarker) -> $ty {
- match marker {}
- }
- };
-}
-
-lit_extra_traits!(LitStr, repr.token);
-lit_extra_traits!(LitByteStr, token);
-lit_extra_traits!(LitByte, token);
-lit_extra_traits!(LitChar, token);
-lit_extra_traits!(LitInt, repr.token);
-lit_extra_traits!(LitFloat, repr.token);
-lit_extra_traits!(LitBool, value);
-
-ast_enum! {
- /// The style of a string literal, either plain quoted or a raw string like
- /// `r##"data"##`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub enum StrStyle #no_visit {
- /// An ordinary string like `"data"`.
- Cooked,
- /// A raw string like `r##"data"##`.
- ///
- /// The unsigned integer is the number of `#` symbols used.
- Raw(usize),
- }
-}
-
-#[cfg(feature = "parsing")]
-#[doc(hidden)]
-#[allow(non_snake_case)]
-pub fn Lit(marker: lookahead::TokenMarker) -> Lit {
- match marker {}
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for Lit {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| {
- if let Some((lit, rest)) = cursor.literal() {
- return Ok((Lit::new(lit), rest));
- }
- while let Some((ident, rest)) = cursor.ident() {
- let value = if ident == "true" {
- true
- } else if ident == "false" {
- false
- } else {
- break;
- };
- let lit_bool = LitBool {
- value,
- span: ident.span(),
- };
- return Ok((Lit::Bool(lit_bool), rest));
- }
- Err(cursor.error("expected literal"))
- })
- }
- }
-
- impl Parse for LitStr {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::Str(lit) => Ok(lit),
- _ => Err(head.error("expected string literal")),
- }
- }
- }
-
- impl Parse for LitByteStr {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::ByteStr(lit) => Ok(lit),
- _ => Err(head.error("expected byte string literal")),
- }
- }
- }
-
- impl Parse for LitByte {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::Byte(lit) => Ok(lit),
- _ => Err(head.error("expected byte literal")),
- }
- }
- }
-
- impl Parse for LitChar {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::Char(lit) => Ok(lit),
- _ => Err(head.error("expected character literal")),
- }
- }
- }
-
- impl Parse for LitInt {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::Int(lit) => Ok(lit),
- _ => Err(head.error("expected integer literal")),
- }
- }
- }
-
- impl Parse for LitFloat {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::Float(lit) => Ok(lit),
- _ => Err(head.error("expected floating point literal")),
- }
- }
- }
-
- impl Parse for LitBool {
- fn parse(input: ParseStream) -> Result<Self> {
- let head = input.fork();
- match input.parse()? {
- Lit::Bool(lit) => Ok(lit),
- _ => Err(head.error("expected boolean literal")),
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- impl ToTokens for LitStr {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.repr.token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LitByteStr {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LitByte {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LitChar {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LitInt {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.repr.token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LitFloat {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.repr.token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for LitBool {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- let s = if self.value { "true" } else { "false" };
- tokens.append(Ident::new(s, self.span));
- }
- }
-}
-
-mod value {
- use super::*;
- use crate::bigint::BigInt;
- use proc_macro2::TokenStream;
- use std::char;
- use std::ops::{Index, RangeFrom};
-
- impl Lit {
- /// Interpret a Syn literal from a proc-macro2 literal.
- pub fn new(token: Literal) -> Self {
- let repr = token.to_string();
-
- match byte(&repr, 0) {
- b'"' | b'r' => {
- let (_, suffix) = parse_lit_str(&repr);
- return Lit::Str(LitStr {
- repr: Box::new(LitStrRepr { token, suffix }),
- });
- }
- b'b' => match byte(&repr, 1) {
- b'"' | b'r' => {
- return Lit::ByteStr(LitByteStr { token });
- }
- b'\'' => {
- return Lit::Byte(LitByte { token });
- }
- _ => {}
- },
- b'\'' => {
- return Lit::Char(LitChar { token });
- }
- b'0'..=b'9' | b'-' => {
- if !(repr.ends_with("f32") || repr.ends_with("f64")) {
- if let Some((digits, suffix)) = parse_lit_int(&repr) {
- return Lit::Int(LitInt {
- repr: Box::new(LitIntRepr {
- token,
- digits,
- suffix,
- }),
- });
- }
- }
- if let Some((digits, suffix)) = parse_lit_float(&repr) {
- return Lit::Float(LitFloat {
- repr: Box::new(LitFloatRepr {
- token,
- digits,
- suffix,
- }),
- });
- }
- }
- b't' | b'f' => {
- if repr == "true" || repr == "false" {
- return Lit::Bool(LitBool {
- value: repr == "true",
- span: token.span(),
- });
- }
- }
- _ => {}
- }
-
- panic!("Unrecognized literal: `{}`", repr);
- }
- }
-
- /// Get the byte at offset idx, or a default of `b'\0'` if we're looking
- /// past the end of the input buffer.
- pub fn byte<S: AsRef<[u8]> + ?Sized>(s: &S, idx: usize) -> u8 {
- let s = s.as_ref();
- if idx < s.len() {
- s[idx]
- } else {
- 0
- }
- }
-
- fn next_chr(s: &str) -> char {
- s.chars().next().unwrap_or('\0')
- }
-
- // Returns (content, suffix).
- pub fn parse_lit_str(s: &str) -> (Box<str>, Box<str>) {
- match byte(s, 0) {
- b'"' => parse_lit_str_cooked(s),
- b'r' => parse_lit_str_raw(s),
- _ => unreachable!(),
- }
- }
-
- // Clippy false positive
- // https://github.com/rust-lang-nursery/rust-clippy/issues/2329
- #[allow(clippy::needless_continue)]
- fn parse_lit_str_cooked(mut s: &str) -> (Box<str>, Box<str>) {
- assert_eq!(byte(s, 0), b'"');
- s = &s[1..];
-
- let mut content = String::new();
- 'outer: loop {
- let ch = match byte(s, 0) {
- b'"' => break,
- b'\\' => {
- let b = byte(s, 1);
- s = &s[2..];
- match b {
- b'x' => {
- let (byte, rest) = backslash_x(s);
- s = rest;
- assert!(byte <= 0x80, "Invalid \\x byte in string literal");
- char::from_u32(u32::from(byte)).unwrap()
- }
- b'u' => {
- let (chr, rest) = backslash_u(s);
- s = rest;
- chr
- }
- b'n' => '\n',
- b'r' => '\r',
- b't' => '\t',
- b'\\' => '\\',
- b'0' => '\0',
- b'\'' => '\'',
- b'"' => '"',
- b'\r' | b'\n' => loop {
- let ch = next_chr(s);
- if ch.is_whitespace() {
- s = &s[ch.len_utf8()..];
- } else {
- continue 'outer;
- }
- },
- b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
- }
- }
- b'\r' => {
- assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string");
- s = &s[2..];
- '\n'
- }
- _ => {
- let ch = next_chr(s);
- s = &s[ch.len_utf8()..];
- ch
- }
- };
- content.push(ch);
- }
-
- assert!(s.starts_with('"'));
- let content = content.into_boxed_str();
- let suffix = s[1..].to_owned().into_boxed_str();
- (content, suffix)
- }
-
- fn parse_lit_str_raw(mut s: &str) -> (Box<str>, Box<str>) {
- assert_eq!(byte(s, 0), b'r');
- s = &s[1..];
-
- let mut pounds = 0;
- while byte(s, pounds) == b'#' {
- pounds += 1;
- }
- assert_eq!(byte(s, pounds), b'"');
- assert_eq!(byte(s, s.len() - pounds - 1), b'"');
- for end in s[s.len() - pounds..].bytes() {
- assert_eq!(end, b'#');
- }
-
- let content = s[pounds + 1..s.len() - pounds - 1]
- .to_owned()
- .into_boxed_str();
- let suffix = Box::<str>::default(); // todo
- (content, suffix)
- }
-
- pub fn parse_lit_byte_str(s: &str) -> Vec<u8> {
- assert_eq!(byte(s, 0), b'b');
- match byte(s, 1) {
- b'"' => parse_lit_byte_str_cooked(s),
- b'r' => parse_lit_byte_str_raw(s),
- _ => unreachable!(),
- }
- }
-
- // Clippy false positive
- // https://github.com/rust-lang-nursery/rust-clippy/issues/2329
- #[allow(clippy::needless_continue)]
- fn parse_lit_byte_str_cooked(mut s: &str) -> Vec<u8> {
- assert_eq!(byte(s, 0), b'b');
- assert_eq!(byte(s, 1), b'"');
- s = &s[2..];
-
- // We're going to want to have slices which don't respect codepoint boundaries.
- let mut s = s.as_bytes();
-
- let mut out = Vec::new();
- 'outer: loop {
- let byte = match byte(s, 0) {
- b'"' => break,
- b'\\' => {
- let b = byte(s, 1);
- s = &s[2..];
- match b {
- b'x' => {
- let (b, rest) = backslash_x(s);
- s = rest;
- b
- }
- b'n' => b'\n',
- b'r' => b'\r',
- b't' => b'\t',
- b'\\' => b'\\',
- b'0' => b'\0',
- b'\'' => b'\'',
- b'"' => b'"',
- b'\r' | b'\n' => loop {
- let byte = byte(s, 0);
- let ch = char::from_u32(u32::from(byte)).unwrap();
- if ch.is_whitespace() {
- s = &s[1..];
- } else {
- continue 'outer;
- }
- },
- b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
- }
- }
- b'\r' => {
- assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string");
- s = &s[2..];
- b'\n'
- }
- b => {
- s = &s[1..];
- b
- }
- };
- out.push(byte);
- }
-
- assert_eq!(s, b"\"");
- out
- }
-
- fn parse_lit_byte_str_raw(s: &str) -> Vec<u8> {
- assert_eq!(byte(s, 0), b'b');
- String::from(parse_lit_str_raw(&s[1..]).0).into_bytes()
- }
-
- pub fn parse_lit_byte(s: &str) -> u8 {
- assert_eq!(byte(s, 0), b'b');
- assert_eq!(byte(s, 1), b'\'');
-
- // We're going to want to have slices which don't respect codepoint boundaries.
- let mut s = s[2..].as_bytes();
-
- let b = match byte(s, 0) {
- b'\\' => {
- let b = byte(s, 1);
- s = &s[2..];
- match b {
- b'x' => {
- let (b, rest) = backslash_x(s);
- s = rest;
- b
- }
- b'n' => b'\n',
- b'r' => b'\r',
- b't' => b'\t',
- b'\\' => b'\\',
- b'0' => b'\0',
- b'\'' => b'\'',
- b'"' => b'"',
- b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
- }
- }
- b => {
- s = &s[1..];
- b
- }
- };
-
- assert_eq!(byte(s, 0), b'\'');
- b
- }
-
- pub fn parse_lit_char(mut s: &str) -> char {
- assert_eq!(byte(s, 0), b'\'');
- s = &s[1..];
-
- let ch = match byte(s, 0) {
- b'\\' => {
- let b = byte(s, 1);
- s = &s[2..];
- match b {
- b'x' => {
- let (byte, rest) = backslash_x(s);
- s = rest;
- assert!(byte <= 0x80, "Invalid \\x byte in string literal");
- char::from_u32(u32::from(byte)).unwrap()
- }
- b'u' => {
- let (chr, rest) = backslash_u(s);
- s = rest;
- chr
- }
- b'n' => '\n',
- b'r' => '\r',
- b't' => '\t',
- b'\\' => '\\',
- b'0' => '\0',
- b'\'' => '\'',
- b'"' => '"',
- b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
- }
- }
- _ => {
- let ch = next_chr(s);
- s = &s[ch.len_utf8()..];
- ch
- }
- };
- assert_eq!(s, "\'", "Expected end of char literal");
- ch
- }
-
- fn backslash_x<S>(s: &S) -> (u8, &S)
- where
- S: Index<RangeFrom<usize>, Output = S> + AsRef<[u8]> + ?Sized,
- {
- let mut ch = 0;
- let b0 = byte(s, 0);
- let b1 = byte(s, 1);
- ch += 0x10
- * match b0 {
- b'0'..=b'9' => b0 - b'0',
- b'a'..=b'f' => 10 + (b0 - b'a'),
- b'A'..=b'F' => 10 + (b0 - b'A'),
- _ => panic!("unexpected non-hex character after \\x"),
- };
- ch += match b1 {
- b'0'..=b'9' => b1 - b'0',
- b'a'..=b'f' => 10 + (b1 - b'a'),
- b'A'..=b'F' => 10 + (b1 - b'A'),
- _ => panic!("unexpected non-hex character after \\x"),
- };
- (ch, &s[2..])
- }
-
- fn backslash_u(mut s: &str) -> (char, &str) {
- if byte(s, 0) != b'{' {
- panic!("expected {{ after \\u");
- }
- s = &s[1..];
-
- let mut ch = 0;
- for _ in 0..6 {
- let b = byte(s, 0);
- match b {
- b'0'..=b'9' => {
- ch *= 0x10;
- ch += u32::from(b - b'0');
- s = &s[1..];
- }
- b'a'..=b'f' => {
- ch *= 0x10;
- ch += u32::from(10 + b - b'a');
- s = &s[1..];
- }
- b'A'..=b'F' => {
- ch *= 0x10;
- ch += u32::from(10 + b - b'A');
- s = &s[1..];
- }
- b'}' => break,
- _ => panic!("unexpected non-hex character after \\u"),
- }
- }
- assert!(byte(s, 0) == b'}');
- s = &s[1..];
-
- if let Some(ch) = char::from_u32(ch) {
- (ch, s)
- } else {
- panic!("character code {:x} is not a valid unicode character", ch);
- }
- }
-
- // Returns base 10 digits and suffix.
- pub fn parse_lit_int(mut s: &str) -> Option<(Box<str>, Box<str>)> {
- let negative = byte(s, 0) == b'-';
- if negative {
- s = &s[1..];
- }
-
- let base = match (byte(s, 0), byte(s, 1)) {
- (b'0', b'x') => {
- s = &s[2..];
- 16
- }
- (b'0', b'o') => {
- s = &s[2..];
- 8
- }
- (b'0', b'b') => {
- s = &s[2..];
- 2
- }
- (b'0'..=b'9', _) => 10,
- _ => return None,
- };
-
- let mut value = BigInt::new();
- loop {
- let b = byte(s, 0);
- let digit = match b {
- b'0'..=b'9' => b - b'0',
- b'a'..=b'f' if base > 10 => b - b'a' + 10,
- b'A'..=b'F' if base > 10 => b - b'A' + 10,
- b'_' => {
- s = &s[1..];
- continue;
- }
- // NOTE: Looking at a floating point literal, we don't want to
- // consider these integers.
- b'.' if base == 10 => return None,
- b'e' | b'E' if base == 10 => return None,
- _ => break,
- };
-
- if digit >= base {
- return None;
- }
-
- value *= base;
- value += digit;
- s = &s[1..];
- }
-
- let suffix = s;
- if suffix.is_empty() || crate::ident::xid_ok(&suffix) {
- let mut repr = value.to_string();
- if negative {
- repr.insert(0, '-');
- }
- Some((repr.into_boxed_str(), suffix.to_owned().into_boxed_str()))
- } else {
- None
- }
- }
-
- // Returns base 10 digits and suffix.
- pub fn parse_lit_float(input: &str) -> Option<(Box<str>, Box<str>)> {
- // Rust's floating point literals are very similar to the ones parsed by
- // the standard library, except that rust's literals can contain
- // ignorable underscores. Let's remove those underscores.
-
- let mut bytes = input.to_owned().into_bytes();
-
- let start = (*bytes.get(0)? == b'-') as usize;
- match bytes.get(start)? {
- b'0'..=b'9' => {}
- _ => return None,
- }
-
- let mut read = start;
- let mut write = start;
- let mut has_dot = false;
- let mut has_e = false;
- let mut has_sign = false;
- let mut has_exponent = false;
- while read < bytes.len() {
- match bytes[read] {
- b'_' => {
- // Don't increase write
- read += 1;
- continue;
- }
- b'0'..=b'9' => {
- if has_e {
- has_exponent = true;
- }
- bytes[write] = bytes[read];
- }
- b'.' => {
- if has_e || has_dot {
- return None;
- }
- has_dot = true;
- bytes[write] = b'.';
- }
- b'e' | b'E' => {
- if has_e {
- return None;
- }
- has_e = true;
- bytes[write] = b'e';
- }
- b'-' | b'+' => {
- if has_sign || has_exponent || !has_e {
- return None;
- }
- has_sign = true;
- if bytes[read] == b'-' {
- bytes[write] = bytes[read];
- } else {
- // Omit '+'
- read += 1;
- continue;
- }
- }
- _ => break,
- }
- read += 1;
- write += 1;
- }
-
- if has_e && !has_exponent {
- return None;
- }
-
- let mut digits = String::from_utf8(bytes).unwrap();
- let suffix = digits.split_off(read);
- digits.truncate(write);
- if suffix.is_empty() || crate::ident::xid_ok(&suffix) {
- Some((digits.into_boxed_str(), suffix.into_boxed_str()))
- } else {
- None
- }
- }
-
- pub fn to_literal(s: &str) -> Literal {
- let stream = s.parse::<TokenStream>().unwrap();
- match stream.into_iter().next().unwrap() {
- TokenTree::Literal(l) => l,
- _ => unreachable!(),
- }
- }
-}
diff --git a/syn/src/lookahead.rs b/syn/src/lookahead.rs
deleted file mode 100644
index 6a67909..0000000
--- a/syn/src/lookahead.rs
+++ /dev/null
@@ -1,168 +0,0 @@
-use std::cell::RefCell;
-
-use proc_macro2::{Delimiter, Span};
-
-use crate::buffer::Cursor;
-use crate::error::{self, Error};
-use crate::sealed::lookahead::Sealed;
-use crate::span::IntoSpans;
-use crate::token::Token;
-
-/// Support for checking the next token in a stream to decide how to parse.
-///
-/// An important advantage over [`ParseStream::peek`] is that here we
-/// automatically construct an appropriate error message based on the token
-/// alternatives that get peeked. If you are producing your own error message,
-/// go ahead and use `ParseStream::peek` instead.
-///
-/// Use [`ParseStream::lookahead1`] to construct this object.
-///
-/// [`ParseStream::peek`]: crate::parse::ParseBuffer::peek
-/// [`ParseStream::lookahead1`]: crate::parse::ParseBuffer::lookahead1
-///
-/// # Example
-///
-/// ```
-/// use syn::{ConstParam, Ident, Lifetime, LifetimeDef, Result, Token, TypeParam};
-/// use syn::parse::{Parse, ParseStream};
-///
-/// // A generic parameter, a single one of the comma-separated elements inside
-/// // angle brackets in:
-/// //
-/// // fn f<T: Clone, 'a, 'b: 'a, const N: usize>() { ... }
-/// //
-/// // On invalid input, lookahead gives us a reasonable error message.
-/// //
-/// // error: expected one of: identifier, lifetime, `const`
-/// // |
-/// // 5 | fn f<!Sized>() {}
-/// // | ^
-/// enum GenericParam {
-/// Type(TypeParam),
-/// Lifetime(LifetimeDef),
-/// Const(ConstParam),
-/// }
-///
-/// impl Parse for GenericParam {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// let lookahead = input.lookahead1();
-/// if lookahead.peek(Ident) {
-/// input.parse().map(GenericParam::Type)
-/// } else if lookahead.peek(Lifetime) {
-/// input.parse().map(GenericParam::Lifetime)
-/// } else if lookahead.peek(Token![const]) {
-/// input.parse().map(GenericParam::Const)
-/// } else {
-/// Err(lookahead.error())
-/// }
-/// }
-/// }
-/// ```
-pub struct Lookahead1<'a> {
- scope: Span,
- cursor: Cursor<'a>,
- comparisons: RefCell<Vec<&'static str>>,
-}
-
-pub fn new(scope: Span, cursor: Cursor) -> Lookahead1 {
- Lookahead1 {
- scope,
- cursor,
- comparisons: RefCell::new(Vec::new()),
- }
-}
-
-fn peek_impl(
- lookahead: &Lookahead1,
- peek: fn(Cursor) -> bool,
- display: fn() -> &'static str,
-) -> bool {
- if peek(lookahead.cursor) {
- return true;
- }
- lookahead.comparisons.borrow_mut().push(display());
- false
-}
-
-impl<'a> Lookahead1<'a> {
- /// Looks at the next token in the parse stream to determine whether it
- /// matches the requested type of token.
- ///
- /// # Syntax
- ///
- /// Note that this method does not use turbofish syntax. Pass the peek type
- /// inside of parentheses.
- ///
- /// - `input.peek(Token![struct])`
- /// - `input.peek(Token![==])`
- /// - `input.peek(Ident)`&emsp;*(does not accept keywords)*
- /// - `input.peek(Ident::peek_any)`
- /// - `input.peek(Lifetime)`
- /// - `input.peek(token::Brace)`
- pub fn peek<T: Peek>(&self, token: T) -> bool {
- let _ = token;
- peek_impl(self, T::Token::peek, T::Token::display)
- }
-
- /// Triggers an error at the current position of the parse stream.
- ///
- /// The error message will identify all of the expected token types that
- /// have been peeked against this lookahead instance.
- pub fn error(self) -> Error {
- let comparisons = self.comparisons.borrow();
- match comparisons.len() {
- 0 => {
- if self.cursor.eof() {
- Error::new(self.scope, "unexpected end of input")
- } else {
- Error::new(self.cursor.span(), "unexpected token")
- }
- }
- 1 => {
- let message = format!("expected {}", comparisons[0]);
- error::new_at(self.scope, self.cursor, message)
- }
- 2 => {
- let message = format!("expected {} or {}", comparisons[0], comparisons[1]);
- error::new_at(self.scope, self.cursor, message)
- }
- _ => {
- let join = comparisons.join(", ");
- let message = format!("expected one of: {}", join);
- error::new_at(self.scope, self.cursor, message)
- }
- }
- }
-}
-
-/// Types that can be parsed by looking at just one token.
-///
-/// Use [`ParseStream::peek`] to peek one of these types in a parse stream
-/// without consuming it from the stream.
-///
-/// This trait is sealed and cannot be implemented for types outside of Syn.
-///
-/// [`ParseStream::peek`]: crate::parse::ParseBuffer::peek
-pub trait Peek: Sealed {
- // Not public API.
- #[doc(hidden)]
- type Token: Token;
-}
-
-impl<F: Copy + FnOnce(TokenMarker) -> T, T: Token> Peek for F {
- type Token = T;
-}
-
-pub enum TokenMarker {}
-
-impl<S> IntoSpans<S> for TokenMarker {
- fn into_spans(self) -> S {
- match self {}
- }
-}
-
-pub fn is_delimiter(cursor: Cursor, delimiter: Delimiter) -> bool {
- cursor.group(delimiter).is_some()
-}
-
-impl<F: Copy + FnOnce(TokenMarker) -> T, T: Token> Sealed for F {}
diff --git a/syn/src/mac.rs b/syn/src/mac.rs
deleted file mode 100644
index 6c3dcae..0000000
--- a/syn/src/mac.rs
+++ /dev/null
@@ -1,239 +0,0 @@
-use super::*;
-use crate::token::{Brace, Bracket, Paren};
-use proc_macro2::TokenStream;
-#[cfg(feature = "parsing")]
-use proc_macro2::{Delimiter, Span, TokenTree};
-
-#[cfg(feature = "parsing")]
-use crate::parse::{Parse, ParseStream, Parser, Result};
-#[cfg(feature = "extra-traits")]
-use crate::tt::TokenStreamHelper;
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-
-ast_struct! {
- /// A macro invocation: `println!("{}", mac)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Macro #manual_extra_traits {
- pub path: Path,
- pub bang_token: Token![!],
- pub delimiter: MacroDelimiter,
- pub tokens: TokenStream,
- }
-}
-
-ast_enum! {
- /// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub enum MacroDelimiter {
- Paren(Paren),
- Brace(Brace),
- Bracket(Bracket),
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Macro {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Macro {
- fn eq(&self, other: &Self) -> bool {
- self.path == other.path
- && self.bang_token == other.bang_token
- && self.delimiter == other.delimiter
- && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens)
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Macro {
- fn hash<H>(&self, state: &mut H)
- where
- H: Hasher,
- {
- self.path.hash(state);
- self.bang_token.hash(state);
- self.delimiter.hash(state);
- TokenStreamHelper(&self.tokens).hash(state);
- }
-}
-
-#[cfg(feature = "parsing")]
-fn delimiter_span(delimiter: &MacroDelimiter) -> Span {
- match delimiter {
- MacroDelimiter::Paren(token) => token.span,
- MacroDelimiter::Brace(token) => token.span,
- MacroDelimiter::Bracket(token) => token.span,
- }
-}
-
-impl Macro {
- /// Parse the tokens within the macro invocation's delimiters into a syntax
- /// tree.
- ///
- /// This is equivalent to `syn::parse2::<T>(mac.tokens)` except that it
- /// produces a more useful span when `tokens` is empty.
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{parse_quote, Expr, ExprLit, Ident, Lit, LitStr, Macro, Token};
- /// use syn::ext::IdentExt;
- /// use syn::parse::{Error, Parse, ParseStream, Result};
- /// use syn::punctuated::Punctuated;
- ///
- /// // The arguments expected by libcore's format_args macro, and as a
- /// // result most other formatting and printing macros like println.
- /// //
- /// // println!("{} is {number:.prec$}", "x", prec=5, number=0.01)
- /// struct FormatArgs {
- /// format_string: Expr,
- /// positional_args: Vec<Expr>,
- /// named_args: Vec<(Ident, Expr)>,
- /// }
- ///
- /// impl Parse for FormatArgs {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let format_string: Expr;
- /// let mut positional_args = Vec::new();
- /// let mut named_args = Vec::new();
- ///
- /// format_string = input.parse()?;
- /// while !input.is_empty() {
- /// input.parse::<Token![,]>()?;
- /// if input.is_empty() {
- /// break;
- /// }
- /// if input.peek(Ident::peek_any) && input.peek2(Token![=]) {
- /// while !input.is_empty() {
- /// let name: Ident = input.call(Ident::parse_any)?;
- /// input.parse::<Token![=]>()?;
- /// let value: Expr = input.parse()?;
- /// named_args.push((name, value));
- /// if input.is_empty() {
- /// break;
- /// }
- /// input.parse::<Token![,]>()?;
- /// }
- /// break;
- /// }
- /// positional_args.push(input.parse()?);
- /// }
- ///
- /// Ok(FormatArgs {
- /// format_string,
- /// positional_args,
- /// named_args,
- /// })
- /// }
- /// }
- ///
- /// // Extract the first argument, the format string literal, from an
- /// // invocation of a formatting or printing macro.
- /// fn get_format_string(m: &Macro) -> Result<LitStr> {
- /// let args: FormatArgs = m.parse_body()?;
- /// match args.format_string {
- /// Expr::Lit(ExprLit { lit: Lit::Str(lit), .. }) => Ok(lit),
- /// other => {
- /// // First argument was not a string literal expression.
- /// // Maybe something like: println!(concat!(...), ...)
- /// Err(Error::new_spanned(other, "format string must be a string literal"))
- /// }
- /// }
- /// }
- ///
- /// fn main() {
- /// let invocation = parse_quote! {
- /// println!("{:?}", Instant::now())
- /// };
- /// let lit = get_format_string(&invocation).unwrap();
- /// assert_eq!(lit.value(), "{:?}");
- /// }
- /// ```
- #[cfg(feature = "parsing")]
- pub fn parse_body<T: Parse>(&self) -> Result<T> {
- self.parse_body_with(T::parse)
- }
-
- /// Parse the tokens within the macro invocation's delimiters using the
- /// given parser.
- #[cfg(feature = "parsing")]
- pub fn parse_body_with<F: Parser>(&self, parser: F) -> Result<F::Output> {
- // TODO: see if we can get a group.span_close() span in here as the
- // scope, rather than the span of the whole group.
- let scope = delimiter_span(&self.delimiter);
- crate::parse::parse_scoped(parser, scope, self.tokens.clone())
- }
-}
-
-#[cfg(feature = "parsing")]
-pub fn parse_delimiter(input: ParseStream) -> Result<(MacroDelimiter, TokenStream)> {
- input.step(|cursor| {
- if let Some((TokenTree::Group(g), rest)) = cursor.token_tree() {
- let span = g.span();
- let delimiter = match g.delimiter() {
- Delimiter::Parenthesis => MacroDelimiter::Paren(Paren(span)),
- Delimiter::Brace => MacroDelimiter::Brace(Brace(span)),
- Delimiter::Bracket => MacroDelimiter::Bracket(Bracket(span)),
- Delimiter::None => {
- return Err(cursor.error("expected delimiter"));
- }
- };
- Ok(((delimiter, g.stream()), rest))
- } else {
- Err(cursor.error("expected delimiter"))
- }
- })
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for Macro {
- fn parse(input: ParseStream) -> Result<Self> {
- let tokens;
- Ok(Macro {
- path: input.call(Path::parse_mod_style)?,
- bang_token: input.parse()?,
- delimiter: {
- let (delimiter, content) = parse_delimiter(input)?;
- tokens = content;
- delimiter
- },
- tokens,
- })
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
- use proc_macro2::TokenStream;
- use quote::ToTokens;
-
- impl ToTokens for Macro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.path.to_tokens(tokens);
- self.bang_token.to_tokens(tokens);
- match &self.delimiter {
- MacroDelimiter::Paren(paren) => {
- paren.surround(tokens, |tokens| self.tokens.to_tokens(tokens));
- }
- MacroDelimiter::Brace(brace) => {
- brace.surround(tokens, |tokens| self.tokens.to_tokens(tokens));
- }
- MacroDelimiter::Bracket(bracket) => {
- bracket.surround(tokens, |tokens| self.tokens.to_tokens(tokens));
- }
- }
- }
- }
-}
diff --git a/syn/src/macros.rs b/syn/src/macros.rs
deleted file mode 100644
index 57091c0..0000000
--- a/syn/src/macros.rs
+++ /dev/null
@@ -1,191 +0,0 @@
-macro_rules! ast_struct {
- (
- [$($attrs_pub:tt)*]
- struct $name:ident #full $($rest:tt)*
- ) => {
- #[cfg(feature = "full")]
- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* struct $name $($rest)*
-
- #[cfg(not(feature = "full"))]
- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* struct $name {
- _noconstruct: (),
- }
-
- #[cfg(all(not(feature = "full"), feature = "printing"))]
- impl ::quote::ToTokens for $name {
- fn to_tokens(&self, _: &mut ::proc_macro2::TokenStream) {
- unreachable!()
- }
- }
- };
-
- (
- [$($attrs_pub:tt)*]
- struct $name:ident #manual_extra_traits $($rest:tt)*
- ) => {
- #[cfg_attr(feature = "extra-traits", derive(Debug))]
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* struct $name $($rest)*
- };
-
- (
- [$($attrs_pub:tt)*]
- struct $name:ident #manual_extra_traits_debug $($rest:tt)*
- ) => {
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* struct $name $($rest)*
- };
-
- (
- [$($attrs_pub:tt)*]
- struct $name:ident $($rest:tt)*
- ) => {
- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* struct $name $($rest)*
- };
-
- ($($t:tt)*) => {
- strip_attrs_pub!(ast_struct!($($t)*));
- };
-}
-
-macro_rules! ast_enum {
- // Drop the `#no_visit` attribute, if present.
- (
- [$($attrs_pub:tt)*]
- enum $name:ident #no_visit $($rest:tt)*
- ) => (
- ast_enum!([$($attrs_pub)*] enum $name $($rest)*);
- );
-
- (
- [$($attrs_pub:tt)*]
- enum $name:ident #manual_extra_traits $($rest:tt)*
- ) => (
- #[cfg_attr(feature = "extra-traits", derive(Debug))]
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* enum $name $($rest)*
- );
-
- (
- [$($attrs_pub:tt)*]
- enum $name:ident $($rest:tt)*
- ) => (
- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
- #[cfg_attr(feature = "clone-impls", derive(Clone))]
- $($attrs_pub)* enum $name $($rest)*
- );
-
- ($($t:tt)*) => {
- strip_attrs_pub!(ast_enum!($($t)*));
- };
-}
-
-macro_rules! ast_enum_of_structs {
- (
- $(#[$enum_attr:meta])*
- $pub:ident $enum:ident $name:ident #$tag:ident $body:tt
- $($remaining:tt)*
- ) => {
- ast_enum!($(#[$enum_attr])* $pub $enum $name #$tag $body);
- ast_enum_of_structs_impl!($pub $enum $name $body $($remaining)*);
- };
-
- (
- $(#[$enum_attr:meta])*
- $pub:ident $enum:ident $name:ident $body:tt
- $($remaining:tt)*
- ) => {
- ast_enum!($(#[$enum_attr])* $pub $enum $name $body);
- ast_enum_of_structs_impl!($pub $enum $name $body $($remaining)*);
- };
-}
-
-macro_rules! ast_enum_of_structs_impl {
- (
- $pub:ident $enum:ident $name:ident {
- $(
- $(#[$variant_attr:meta])*
- $variant:ident $( ($member:ident) )*,
- )*
- }
-
- $($remaining:tt)*
- ) => {
- check_keyword_matches!(pub $pub);
- check_keyword_matches!(enum $enum);
-
- $($(
- ast_enum_from_struct!($name::$variant, $member);
- )*)*
-
- #[cfg(feature = "printing")]
- generate_to_tokens! {
- $($remaining)*
- ()
- tokens
- $name { $($variant $($member)*,)* }
- }
- };
-}
-
-macro_rules! ast_enum_from_struct {
- // No From<TokenStream> for verbatim variants.
- ($name:ident::Verbatim, $member:ident) => {};
-
- ($name:ident::$variant:ident, $member:ident) => {
- impl From<$member> for $name {
- fn from(e: $member) -> $name {
- $name::$variant(e)
- }
- }
- };
-}
-
-#[cfg(feature = "printing")]
-macro_rules! generate_to_tokens {
- (do_not_generate_to_tokens $($foo:tt)*) => ();
-
- (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => {
- generate_to_tokens!(
- ($($arms)* $name::$variant => {})
- $tokens $name { $($next)* }
- );
- };
-
- (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident $member:ident, $($next:tt)*}) => {
- generate_to_tokens!(
- ($($arms)* $name::$variant(_e) => _e.to_tokens($tokens),)
- $tokens $name { $($next)* }
- );
- };
-
- (($($arms:tt)*) $tokens:ident $name:ident {}) => {
- impl ::quote::ToTokens for $name {
- fn to_tokens(&self, $tokens: &mut ::proc_macro2::TokenStream) {
- match self {
- $($arms)*
- }
- }
- }
- };
-}
-
-macro_rules! strip_attrs_pub {
- ($mac:ident!($(#[$m:meta])* $pub:ident $($t:tt)*)) => {
- check_keyword_matches!(pub $pub);
-
- $mac!([$(#[$m])* $pub] $($t)*);
- };
-}
-
-macro_rules! check_keyword_matches {
- (struct struct) => {};
- (enum enum) => {};
- (pub pub) => {};
-}
diff --git a/syn/src/op.rs b/syn/src/op.rs
deleted file mode 100644
index 49fb853..0000000
--- a/syn/src/op.rs
+++ /dev/null
@@ -1,231 +0,0 @@
-ast_enum! {
- /// A binary operator: `+`, `+=`, `&`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- #[cfg_attr(feature = "clone-impls", derive(Copy))]
- pub enum BinOp {
- /// The `+` operator (addition)
- Add(Token![+]),
- /// The `-` operator (subtraction)
- Sub(Token![-]),
- /// The `*` operator (multiplication)
- Mul(Token![*]),
- /// The `/` operator (division)
- Div(Token![/]),
- /// The `%` operator (modulus)
- Rem(Token![%]),
- /// The `&&` operator (logical and)
- And(Token![&&]),
- /// The `||` operator (logical or)
- Or(Token![||]),
- /// The `^` operator (bitwise xor)
- BitXor(Token![^]),
- /// The `&` operator (bitwise and)
- BitAnd(Token![&]),
- /// The `|` operator (bitwise or)
- BitOr(Token![|]),
- /// The `<<` operator (shift left)
- Shl(Token![<<]),
- /// The `>>` operator (shift right)
- Shr(Token![>>]),
- /// The `==` operator (equality)
- Eq(Token![==]),
- /// The `<` operator (less than)
- Lt(Token![<]),
- /// The `<=` operator (less than or equal to)
- Le(Token![<=]),
- /// The `!=` operator (not equal to)
- Ne(Token![!=]),
- /// The `>=` operator (greater than or equal to)
- Ge(Token![>=]),
- /// The `>` operator (greater than)
- Gt(Token![>]),
- /// The `+=` operator
- AddEq(Token![+=]),
- /// The `-=` operator
- SubEq(Token![-=]),
- /// The `*=` operator
- MulEq(Token![*=]),
- /// The `/=` operator
- DivEq(Token![/=]),
- /// The `%=` operator
- RemEq(Token![%=]),
- /// The `^=` operator
- BitXorEq(Token![^=]),
- /// The `&=` operator
- BitAndEq(Token![&=]),
- /// The `|=` operator
- BitOrEq(Token![|=]),
- /// The `<<=` operator
- ShlEq(Token![<<=]),
- /// The `>>=` operator
- ShrEq(Token![>>=]),
- }
-}
-
-ast_enum! {
- /// A unary operator: `*`, `!`, `-`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- #[cfg_attr(feature = "clone-impls", derive(Copy))]
- pub enum UnOp {
- /// The `*` operator for dereferencing
- Deref(Token![*]),
- /// The `!` operator for logical inversion
- Not(Token![!]),
- /// The `-` operator for negation
- Neg(Token![-]),
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::{Parse, ParseStream, Result};
-
- fn parse_binop(input: ParseStream) -> Result<BinOp> {
- if input.peek(Token![&&]) {
- input.parse().map(BinOp::And)
- } else if input.peek(Token![||]) {
- input.parse().map(BinOp::Or)
- } else if input.peek(Token![<<]) {
- input.parse().map(BinOp::Shl)
- } else if input.peek(Token![>>]) {
- input.parse().map(BinOp::Shr)
- } else if input.peek(Token![==]) {
- input.parse().map(BinOp::Eq)
- } else if input.peek(Token![<=]) {
- input.parse().map(BinOp::Le)
- } else if input.peek(Token![!=]) {
- input.parse().map(BinOp::Ne)
- } else if input.peek(Token![>=]) {
- input.parse().map(BinOp::Ge)
- } else if input.peek(Token![+]) {
- input.parse().map(BinOp::Add)
- } else if input.peek(Token![-]) {
- input.parse().map(BinOp::Sub)
- } else if input.peek(Token![*]) {
- input.parse().map(BinOp::Mul)
- } else if input.peek(Token![/]) {
- input.parse().map(BinOp::Div)
- } else if input.peek(Token![%]) {
- input.parse().map(BinOp::Rem)
- } else if input.peek(Token![^]) {
- input.parse().map(BinOp::BitXor)
- } else if input.peek(Token![&]) {
- input.parse().map(BinOp::BitAnd)
- } else if input.peek(Token![|]) {
- input.parse().map(BinOp::BitOr)
- } else if input.peek(Token![<]) {
- input.parse().map(BinOp::Lt)
- } else if input.peek(Token![>]) {
- input.parse().map(BinOp::Gt)
- } else {
- Err(input.error("expected binary operator"))
- }
- }
-
- impl Parse for BinOp {
- #[cfg(not(feature = "full"))]
- fn parse(input: ParseStream) -> Result<Self> {
- parse_binop(input)
- }
-
- #[cfg(feature = "full")]
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![+=]) {
- input.parse().map(BinOp::AddEq)
- } else if input.peek(Token![-=]) {
- input.parse().map(BinOp::SubEq)
- } else if input.peek(Token![*=]) {
- input.parse().map(BinOp::MulEq)
- } else if input.peek(Token![/=]) {
- input.parse().map(BinOp::DivEq)
- } else if input.peek(Token![%=]) {
- input.parse().map(BinOp::RemEq)
- } else if input.peek(Token![^=]) {
- input.parse().map(BinOp::BitXorEq)
- } else if input.peek(Token![&=]) {
- input.parse().map(BinOp::BitAndEq)
- } else if input.peek(Token![|=]) {
- input.parse().map(BinOp::BitOrEq)
- } else if input.peek(Token![<<=]) {
- input.parse().map(BinOp::ShlEq)
- } else if input.peek(Token![>>=]) {
- input.parse().map(BinOp::ShrEq)
- } else {
- parse_binop(input)
- }
- }
- }
-
- impl Parse for UnOp {
- fn parse(input: ParseStream) -> Result<Self> {
- let lookahead = input.lookahead1();
- if lookahead.peek(Token![*]) {
- input.parse().map(UnOp::Deref)
- } else if lookahead.peek(Token![!]) {
- input.parse().map(UnOp::Not)
- } else if lookahead.peek(Token![-]) {
- input.parse().map(UnOp::Neg)
- } else {
- Err(lookahead.error())
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
- use proc_macro2::TokenStream;
- use quote::ToTokens;
-
- impl ToTokens for BinOp {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- BinOp::Add(t) => t.to_tokens(tokens),
- BinOp::Sub(t) => t.to_tokens(tokens),
- BinOp::Mul(t) => t.to_tokens(tokens),
- BinOp::Div(t) => t.to_tokens(tokens),
- BinOp::Rem(t) => t.to_tokens(tokens),
- BinOp::And(t) => t.to_tokens(tokens),
- BinOp::Or(t) => t.to_tokens(tokens),
- BinOp::BitXor(t) => t.to_tokens(tokens),
- BinOp::BitAnd(t) => t.to_tokens(tokens),
- BinOp::BitOr(t) => t.to_tokens(tokens),
- BinOp::Shl(t) => t.to_tokens(tokens),
- BinOp::Shr(t) => t.to_tokens(tokens),
- BinOp::Eq(t) => t.to_tokens(tokens),
- BinOp::Lt(t) => t.to_tokens(tokens),
- BinOp::Le(t) => t.to_tokens(tokens),
- BinOp::Ne(t) => t.to_tokens(tokens),
- BinOp::Ge(t) => t.to_tokens(tokens),
- BinOp::Gt(t) => t.to_tokens(tokens),
- BinOp::AddEq(t) => t.to_tokens(tokens),
- BinOp::SubEq(t) => t.to_tokens(tokens),
- BinOp::MulEq(t) => t.to_tokens(tokens),
- BinOp::DivEq(t) => t.to_tokens(tokens),
- BinOp::RemEq(t) => t.to_tokens(tokens),
- BinOp::BitXorEq(t) => t.to_tokens(tokens),
- BinOp::BitAndEq(t) => t.to_tokens(tokens),
- BinOp::BitOrEq(t) => t.to_tokens(tokens),
- BinOp::ShlEq(t) => t.to_tokens(tokens),
- BinOp::ShrEq(t) => t.to_tokens(tokens),
- }
- }
- }
-
- impl ToTokens for UnOp {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- UnOp::Deref(t) => t.to_tokens(tokens),
- UnOp::Not(t) => t.to_tokens(tokens),
- UnOp::Neg(t) => t.to_tokens(tokens),
- }
- }
- }
-}
diff --git a/syn/src/parse.rs b/syn/src/parse.rs
deleted file mode 100644
index 96eecce..0000000
--- a/syn/src/parse.rs
+++ /dev/null
@@ -1,1222 +0,0 @@
-//! Parsing interface for parsing a token stream into a syntax tree node.
-//!
-//! Parsing in Syn is built on parser functions that take in a [`ParseStream`]
-//! and produce a [`Result<T>`] where `T` is some syntax tree node. Underlying
-//! these parser functions is a lower level mechanism built around the
-//! [`Cursor`] type. `Cursor` is a cheaply copyable cursor over a range of
-//! tokens in a token stream.
-//!
-//! [`ParseStream`]: type.ParseStream.html
-//! [`Result<T>`]: type.Result.html
-//! [`Cursor`]: ../buffer/index.html
-//!
-//! # Example
-//!
-//! Here is a snippet of parsing code to get a feel for the style of the
-//! library. We define data structures for a subset of Rust syntax including
-//! enums (not shown) and structs, then provide implementations of the [`Parse`]
-//! trait to parse these syntax tree data structures from a token stream.
-//!
-//! Once `Parse` impls have been defined, they can be called conveniently from a
-//! procedural macro through [`parse_macro_input!`] as shown at the bottom of
-//! the snippet. If the caller provides syntactically invalid input to the
-//! procedural macro, they will receive a helpful compiler error message
-//! pointing out the exact token that triggered the failure to parse.
-//!
-//! [`parse_macro_input!`]: ../macro.parse_macro_input.html
-//!
-//! ```
-//! extern crate proc_macro;
-//!
-//! use proc_macro::TokenStream;
-//! use syn::{braced, parse_macro_input, token, Field, Ident, Result, Token};
-//! use syn::parse::{Parse, ParseStream};
-//! use syn::punctuated::Punctuated;
-//!
-//! enum Item {
-//! Struct(ItemStruct),
-//! Enum(ItemEnum),
-//! }
-//!
-//! struct ItemStruct {
-//! struct_token: Token![struct],
-//! ident: Ident,
-//! brace_token: token::Brace,
-//! fields: Punctuated<Field, Token![,]>,
-//! }
-//! #
-//! # enum ItemEnum {}
-//!
-//! impl Parse for Item {
-//! fn parse(input: ParseStream) -> Result<Self> {
-//! let lookahead = input.lookahead1();
-//! if lookahead.peek(Token![struct]) {
-//! input.parse().map(Item::Struct)
-//! } else if lookahead.peek(Token![enum]) {
-//! input.parse().map(Item::Enum)
-//! } else {
-//! Err(lookahead.error())
-//! }
-//! }
-//! }
-//!
-//! impl Parse for ItemStruct {
-//! fn parse(input: ParseStream) -> Result<Self> {
-//! let content;
-//! Ok(ItemStruct {
-//! struct_token: input.parse()?,
-//! ident: input.parse()?,
-//! brace_token: braced!(content in input),
-//! fields: content.parse_terminated(Field::parse_named)?,
-//! })
-//! }
-//! }
-//! #
-//! # impl Parse for ItemEnum {
-//! # fn parse(input: ParseStream) -> Result<Self> {
-//! # unimplemented!()
-//! # }
-//! # }
-//!
-//! # const IGNORE: &str = stringify! {
-//! #[proc_macro]
-//! # };
-//! pub fn my_macro(tokens: TokenStream) -> TokenStream {
-//! let input = parse_macro_input!(tokens as Item);
-//!
-//! /* ... */
-//! # "".parse().unwrap()
-//! }
-//! ```
-//!
-//! # The `syn::parse*` functions
-//!
-//! The [`syn::parse`], [`syn::parse2`], and [`syn::parse_str`] functions serve
-//! as an entry point for parsing syntax tree nodes that can be parsed in an
-//! obvious default way. These functions can return any syntax tree node that
-//! implements the [`Parse`] trait, which includes most types in Syn.
-//!
-//! [`syn::parse`]: ../fn.parse.html
-//! [`syn::parse2`]: ../fn.parse2.html
-//! [`syn::parse_str`]: ../fn.parse_str.html
-//! [`Parse`]: trait.Parse.html
-//!
-//! ```
-//! use syn::Type;
-//!
-//! # fn run_parser() -> syn::Result<()> {
-//! let t: Type = syn::parse_str("std::collections::HashMap<String, Value>")?;
-//! # Ok(())
-//! # }
-//! #
-//! # run_parser().unwrap();
-//! ```
-//!
-//! The [`parse_quote!`] macro also uses this approach.
-//!
-//! [`parse_quote!`]: ../macro.parse_quote.html
-//!
-//! # The `Parser` trait
-//!
-//! Some types can be parsed in several ways depending on context. For example
-//! an [`Attribute`] can be either "outer" like `#[...]` or "inner" like
-//! `#![...]` and parsing the wrong one would be a bug. Similarly [`Punctuated`]
-//! may or may not allow trailing punctuation, and parsing it the wrong way
-//! would either reject valid input or accept invalid input.
-//!
-//! [`Attribute`]: ../struct.Attribute.html
-//! [`Punctuated`]: ../punctuated/index.html
-//!
-//! The `Parse` trait is not implemented in these cases because there is no good
-//! behavior to consider the default.
-//!
-//! ```compile_fail
-//! # extern crate proc_macro;
-//! #
-//! # use syn::punctuated::Punctuated;
-//! # use syn::{PathSegment, Result, Token};
-//! #
-//! # fn f(tokens: proc_macro::TokenStream) -> Result<()> {
-//! #
-//! // Can't parse `Punctuated` without knowing whether trailing punctuation
-//! // should be allowed in this context.
-//! let path: Punctuated<PathSegment, Token![::]> = syn::parse(tokens)?;
-//! #
-//! # Ok(())
-//! # }
-//! ```
-//!
-//! In these cases the types provide a choice of parser functions rather than a
-//! single `Parse` implementation, and those parser functions can be invoked
-//! through the [`Parser`] trait.
-//!
-//! [`Parser`]: trait.Parser.html
-//!
-//! ```
-//! extern crate proc_macro;
-//!
-//! use proc_macro::TokenStream;
-//! use syn::parse::Parser;
-//! use syn::punctuated::Punctuated;
-//! use syn::{Attribute, Expr, PathSegment, Result, Token};
-//!
-//! fn call_some_parser_methods(input: TokenStream) -> Result<()> {
-//! // Parse a nonempty sequence of path segments separated by `::` punctuation
-//! // with no trailing punctuation.
-//! let tokens = input.clone();
-//! let parser = Punctuated::<PathSegment, Token![::]>::parse_separated_nonempty;
-//! let _path = parser.parse(tokens)?;
-//!
-//! // Parse a possibly empty sequence of expressions terminated by commas with
-//! // an optional trailing punctuation.
-//! let tokens = input.clone();
-//! let parser = Punctuated::<Expr, Token![,]>::parse_terminated;
-//! let _args = parser.parse(tokens)?;
-//!
-//! // Parse zero or more outer attributes but not inner attributes.
-//! let tokens = input.clone();
-//! let parser = Attribute::parse_outer;
-//! let _attrs = parser.parse(tokens)?;
-//!
-//! Ok(())
-//! }
-//! ```
-//!
-//! ---
-//!
-//! *This module is available if Syn is built with the `"parsing"` feature.*
-
-#[path = "discouraged.rs"]
-pub mod discouraged;
-
-use std::cell::Cell;
-use std::fmt::{self, Debug, Display};
-use std::marker::PhantomData;
-use std::mem;
-use std::ops::Deref;
-use std::rc::Rc;
-use std::str::FromStr;
-
-#[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "proc-macro"
-))]
-use crate::proc_macro;
-use proc_macro2::{self, Delimiter, Group, Literal, Punct, Span, TokenStream, TokenTree};
-
-use crate::buffer::{Cursor, TokenBuffer};
-use crate::error;
-use crate::lookahead;
-use crate::punctuated::Punctuated;
-use crate::token::Token;
-
-pub use crate::error::{Error, Result};
-pub use crate::lookahead::{Lookahead1, Peek};
-
-/// Parsing interface implemented by all types that can be parsed in a default
-/// way from a token stream.
-pub trait Parse: Sized {
- fn parse(input: ParseStream) -> Result<Self>;
-}
-
-/// Input to a Syn parser function.
-///
-/// See the methods of this type under the documentation of [`ParseBuffer`]. For
-/// an overview of parsing in Syn, refer to the [module documentation].
-///
-/// [module documentation]: self
-pub type ParseStream<'a> = &'a ParseBuffer<'a>;
-
-/// Cursor position within a buffered token stream.
-///
-/// This type is more commonly used through the type alias [`ParseStream`] which
-/// is an alias for `&ParseBuffer`.
-///
-/// `ParseStream` is the input type for all parser functions in Syn. They have
-/// the signature `fn(ParseStream) -> Result<T>`.
-///
-/// ## Calling a parser function
-///
-/// There is no public way to construct a `ParseBuffer`. Instead, if you are
-/// looking to invoke a parser function that requires `ParseStream` as input,
-/// you will need to go through one of the public parsing entry points.
-///
-/// - The [`parse_macro_input!`] macro if parsing input of a procedural macro;
-/// - One of [the `syn::parse*` functions][syn-parse]; or
-/// - A method of the [`Parser`] trait.
-///
-/// [syn-parse]: index.html#the-synparse-functions
-pub struct ParseBuffer<'a> {
- scope: Span,
- // Instead of Cell<Cursor<'a>> so that ParseBuffer<'a> is covariant in 'a.
- // The rest of the code in this module needs to be careful that only a
- // cursor derived from this `cell` is ever assigned to this `cell`.
- //
- // Cell<Cursor<'a>> cannot be covariant in 'a because then we could take a
- // ParseBuffer<'a>, upcast to ParseBuffer<'short> for some lifetime shorter
- // than 'a, and then assign a Cursor<'short> into the Cell.
- //
- // By extension, it would not be safe to expose an API that accepts a
- // Cursor<'a> and trusts that it lives as long as the cursor currently in
- // the cell.
- cell: Cell<Cursor<'static>>,
- marker: PhantomData<Cursor<'a>>,
- unexpected: Cell<Option<Rc<Cell<Unexpected>>>>,
-}
-
-impl<'a> Drop for ParseBuffer<'a> {
- fn drop(&mut self) {
- if !self.is_empty() {
- let (inner, old_span) = inner_unexpected(self);
- if old_span.is_none() {
- inner.set(Unexpected::Some(self.cursor().span()));
- }
- }
- }
-}
-
-impl<'a> Display for ParseBuffer<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- Display::fmt(&self.cursor().token_stream(), f)
- }
-}
-
-impl<'a> Debug for ParseBuffer<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- Debug::fmt(&self.cursor().token_stream(), f)
- }
-}
-
-/// Cursor state associated with speculative parsing.
-///
-/// This type is the input of the closure provided to [`ParseStream::step`].
-///
-/// [`ParseStream::step`]: ParseBuffer::step
-///
-/// # Example
-///
-/// ```
-/// use proc_macro2::TokenTree;
-/// use syn::Result;
-/// use syn::parse::ParseStream;
-///
-/// // This function advances the stream past the next occurrence of `@`. If
-/// // no `@` is present in the stream, the stream position is unchanged and
-/// // an error is returned.
-/// fn skip_past_next_at(input: ParseStream) -> Result<()> {
-/// input.step(|cursor| {
-/// let mut rest = *cursor;
-/// while let Some((tt, next)) = rest.token_tree() {
-/// match &tt {
-/// TokenTree::Punct(punct) if punct.as_char() == '@' => {
-/// return Ok(((), next));
-/// }
-/// _ => rest = next,
-/// }
-/// }
-/// Err(cursor.error("no `@` was found after this point"))
-/// })
-/// }
-/// #
-/// # fn remainder_after_skipping_past_next_at(
-/// # input: ParseStream,
-/// # ) -> Result<proc_macro2::TokenStream> {
-/// # skip_past_next_at(input)?;
-/// # input.parse()
-/// # }
-/// #
-/// # use syn::parse::Parser;
-/// # let remainder = remainder_after_skipping_past_next_at
-/// # .parse_str("a @ b c")
-/// # .unwrap();
-/// # assert_eq!(remainder.to_string(), "b c");
-/// ```
-#[derive(Copy, Clone)]
-pub struct StepCursor<'c, 'a> {
- scope: Span,
- // This field is covariant in 'c.
- cursor: Cursor<'c>,
- // This field is contravariant in 'c. Together these make StepCursor
- // invariant in 'c. Also covariant in 'a. The user cannot cast 'c to a
- // different lifetime but can upcast into a StepCursor with a shorter
- // lifetime 'a.
- //
- // As long as we only ever construct a StepCursor for which 'c outlives 'a,
- // this means if ever a StepCursor<'c, 'a> exists we are guaranteed that 'c
- // outlives 'a.
- marker: PhantomData<fn(Cursor<'c>) -> Cursor<'a>>,
-}
-
-impl<'c, 'a> Deref for StepCursor<'c, 'a> {
- type Target = Cursor<'c>;
-
- fn deref(&self) -> &Self::Target {
- &self.cursor
- }
-}
-
-impl<'c, 'a> StepCursor<'c, 'a> {
- /// Triggers an error at the current position of the parse stream.
- ///
- /// The `ParseStream::step` invocation will return this same error without
- /// advancing the stream state.
- pub fn error<T: Display>(self, message: T) -> Error {
- error::new_at(self.scope, self.cursor, message)
- }
-}
-
-pub(crate) fn advance_step_cursor<'c, 'a>(proof: StepCursor<'c, 'a>, to: Cursor<'c>) -> Cursor<'a> {
- // Refer to the comments within the StepCursor definition. We use the
- // fact that a StepCursor<'c, 'a> exists as proof that 'c outlives 'a.
- // Cursor is covariant in its lifetime parameter so we can cast a
- // Cursor<'c> to one with the shorter lifetime Cursor<'a>.
- let _ = proof;
- unsafe { mem::transmute::<Cursor<'c>, Cursor<'a>>(to) }
-}
-
-pub(crate) fn new_parse_buffer(
- scope: Span,
- cursor: Cursor,
- unexpected: Rc<Cell<Unexpected>>,
-) -> ParseBuffer {
- ParseBuffer {
- scope,
- // See comment on `cell` in the struct definition.
- cell: Cell::new(unsafe { mem::transmute::<Cursor, Cursor<'static>>(cursor) }),
- marker: PhantomData,
- unexpected: Cell::new(Some(unexpected)),
- }
-}
-
-#[derive(Clone)]
-pub(crate) enum Unexpected {
- None,
- Some(Span),
- Chain(Rc<Cell<Unexpected>>),
-}
-
-impl Default for Unexpected {
- fn default() -> Self {
- Unexpected::None
- }
-}
-
-// We call this on Cell<Unexpected> and Cell<Option<T>> where temporarily
-// swapping in a None is cheap.
-fn cell_clone<T: Default + Clone>(cell: &Cell<T>) -> T {
- let prev = cell.take();
- let ret = prev.clone();
- cell.set(prev);
- ret
-}
-
-fn inner_unexpected(buffer: &ParseBuffer) -> (Rc<Cell<Unexpected>>, Option<Span>) {
- let mut unexpected = get_unexpected(buffer);
- loop {
- match cell_clone(&unexpected) {
- Unexpected::None => return (unexpected, None),
- Unexpected::Some(span) => return (unexpected, Some(span)),
- Unexpected::Chain(next) => unexpected = next,
- }
- }
-}
-
-pub(crate) fn get_unexpected(buffer: &ParseBuffer) -> Rc<Cell<Unexpected>> {
- cell_clone(&buffer.unexpected).unwrap()
-}
-
-impl<'a> ParseBuffer<'a> {
- /// Parses a syntax tree node of type `T`, advancing the position of our
- /// parse stream past it.
- pub fn parse<T: Parse>(&self) -> Result<T> {
- T::parse(self)
- }
-
- /// Calls the given parser function to parse a syntax tree node of type `T`
- /// from this stream.
- ///
- /// # Example
- ///
- /// The parser below invokes [`Attribute::parse_outer`] to parse a vector of
- /// zero or more outer attributes.
- ///
- /// [`Attribute::parse_outer`]: crate::Attribute::parse_outer
- ///
- /// ```
- /// use syn::{Attribute, Ident, Result, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // Parses a unit struct with attributes.
- /// //
- /// // #[path = "s.tmpl"]
- /// // struct S;
- /// struct UnitStruct {
- /// attrs: Vec<Attribute>,
- /// struct_token: Token![struct],
- /// name: Ident,
- /// semi_token: Token![;],
- /// }
- ///
- /// impl Parse for UnitStruct {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// Ok(UnitStruct {
- /// attrs: input.call(Attribute::parse_outer)?,
- /// struct_token: input.parse()?,
- /// name: input.parse()?,
- /// semi_token: input.parse()?,
- /// })
- /// }
- /// }
- /// ```
- pub fn call<T>(&self, function: fn(ParseStream) -> Result<T>) -> Result<T> {
- function(self)
- }
-
- /// Looks at the next token in the parse stream to determine whether it
- /// matches the requested type of token.
- ///
- /// Does not advance the position of the parse stream.
- ///
- /// # Syntax
- ///
- /// Note that this method does not use turbofish syntax. Pass the peek type
- /// inside of parentheses.
- ///
- /// - `input.peek(Token![struct])`
- /// - `input.peek(Token![==])`
- /// - `input.peek(Ident)`&emsp;*(does not accept keywords)*
- /// - `input.peek(Ident::peek_any)`
- /// - `input.peek(Lifetime)`
- /// - `input.peek(token::Brace)`
- ///
- /// # Example
- ///
- /// In this example we finish parsing the list of supertraits when the next
- /// token in the input is either `where` or an opening curly brace.
- ///
- /// ```
- /// use syn::{braced, token, Generics, Ident, Result, Token, TypeParamBound};
- /// use syn::parse::{Parse, ParseStream};
- /// use syn::punctuated::Punctuated;
- ///
- /// // Parses a trait definition containing no associated items.
- /// //
- /// // trait Marker<'de, T>: A + B<'de> where Box<T>: Clone {}
- /// struct MarkerTrait {
- /// trait_token: Token![trait],
- /// ident: Ident,
- /// generics: Generics,
- /// colon_token: Option<Token![:]>,
- /// supertraits: Punctuated<TypeParamBound, Token![+]>,
- /// brace_token: token::Brace,
- /// }
- ///
- /// impl Parse for MarkerTrait {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let trait_token: Token![trait] = input.parse()?;
- /// let ident: Ident = input.parse()?;
- /// let mut generics: Generics = input.parse()?;
- /// let colon_token: Option<Token![:]> = input.parse()?;
- ///
- /// let mut supertraits = Punctuated::new();
- /// if colon_token.is_some() {
- /// loop {
- /// supertraits.push_value(input.parse()?);
- /// if input.peek(Token![where]) || input.peek(token::Brace) {
- /// break;
- /// }
- /// supertraits.push_punct(input.parse()?);
- /// }
- /// }
- ///
- /// generics.where_clause = input.parse()?;
- /// let content;
- /// let empty_brace_token = braced!(content in input);
- ///
- /// Ok(MarkerTrait {
- /// trait_token,
- /// ident,
- /// generics,
- /// colon_token,
- /// supertraits,
- /// brace_token: empty_brace_token,
- /// })
- /// }
- /// }
- /// ```
- pub fn peek<T: Peek>(&self, token: T) -> bool {
- let _ = token;
- T::Token::peek(self.cursor())
- }
-
- /// Looks at the second-next token in the parse stream.
- ///
- /// This is commonly useful as a way to implement contextual keywords.
- ///
- /// # Example
- ///
- /// This example needs to use `peek2` because the symbol `union` is not a
- /// keyword in Rust. We can't use just `peek` and decide to parse a union if
- /// the very next token is `union`, because someone is free to write a `mod
- /// union` and a macro invocation that looks like `union::some_macro! { ...
- /// }`. In other words `union` is a contextual keyword.
- ///
- /// ```
- /// use syn::{Ident, ItemUnion, Macro, Result, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // Parses either a union or a macro invocation.
- /// enum UnionOrMacro {
- /// // union MaybeUninit<T> { uninit: (), value: T }
- /// Union(ItemUnion),
- /// // lazy_static! { ... }
- /// Macro(Macro),
- /// }
- ///
- /// impl Parse for UnionOrMacro {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// if input.peek(Token![union]) && input.peek2(Ident) {
- /// input.parse().map(UnionOrMacro::Union)
- /// } else {
- /// input.parse().map(UnionOrMacro::Macro)
- /// }
- /// }
- /// }
- /// ```
- pub fn peek2<T: Peek>(&self, token: T) -> bool {
- let _ = token;
- self.cursor().skip().map_or(false, T::Token::peek)
- }
-
- /// Looks at the third-next token in the parse stream.
- pub fn peek3<T: Peek>(&self, token: T) -> bool {
- let _ = token;
- self.cursor()
- .skip()
- .and_then(Cursor::skip)
- .map_or(false, T::Token::peek)
- }
-
- /// Parses zero or more occurrences of `T` separated by punctuation of type
- /// `P`, with optional trailing punctuation.
- ///
- /// Parsing continues until the end of this parse stream. The entire content
- /// of this parse stream must consist of `T` and `P`.
- ///
- /// # Example
- ///
- /// ```
- /// # use quote::quote;
- /// #
- /// use syn::{parenthesized, token, Ident, Result, Token, Type};
- /// use syn::parse::{Parse, ParseStream};
- /// use syn::punctuated::Punctuated;
- ///
- /// // Parse a simplified tuple struct syntax like:
- /// //
- /// // struct S(A, B);
- /// struct TupleStruct {
- /// struct_token: Token![struct],
- /// ident: Ident,
- /// paren_token: token::Paren,
- /// fields: Punctuated<Type, Token![,]>,
- /// semi_token: Token![;],
- /// }
- ///
- /// impl Parse for TupleStruct {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let content;
- /// Ok(TupleStruct {
- /// struct_token: input.parse()?,
- /// ident: input.parse()?,
- /// paren_token: parenthesized!(content in input),
- /// fields: content.parse_terminated(Type::parse)?,
- /// semi_token: input.parse()?,
- /// })
- /// }
- /// }
- /// #
- /// # let input = quote! {
- /// # struct S(A, B);
- /// # };
- /// # syn::parse2::<TupleStruct>(input).unwrap();
- /// ```
- pub fn parse_terminated<T, P: Parse>(
- &self,
- parser: fn(ParseStream) -> Result<T>,
- ) -> Result<Punctuated<T, P>> {
- Punctuated::parse_terminated_with(self, parser)
- }
-
- /// Returns whether there are tokens remaining in this stream.
- ///
- /// This method returns true at the end of the content of a set of
- /// delimiters, as well as at the very end of the complete macro input.
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{braced, token, Ident, Item, Result, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // Parses a Rust `mod m { ... }` containing zero or more items.
- /// struct Mod {
- /// mod_token: Token![mod],
- /// name: Ident,
- /// brace_token: token::Brace,
- /// items: Vec<Item>,
- /// }
- ///
- /// impl Parse for Mod {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let content;
- /// Ok(Mod {
- /// mod_token: input.parse()?,
- /// name: input.parse()?,
- /// brace_token: braced!(content in input),
- /// items: {
- /// let mut items = Vec::new();
- /// while !content.is_empty() {
- /// items.push(content.parse()?);
- /// }
- /// items
- /// },
- /// })
- /// }
- /// }
- /// ```
- pub fn is_empty(&self) -> bool {
- self.cursor().eof()
- }
-
- /// Constructs a helper for peeking at the next token in this stream and
- /// building an error message if it is not one of a set of expected tokens.
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{ConstParam, Ident, Lifetime, LifetimeDef, Result, Token, TypeParam};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // A generic parameter, a single one of the comma-separated elements inside
- /// // angle brackets in:
- /// //
- /// // fn f<T: Clone, 'a, 'b: 'a, const N: usize>() { ... }
- /// //
- /// // On invalid input, lookahead gives us a reasonable error message.
- /// //
- /// // error: expected one of: identifier, lifetime, `const`
- /// // |
- /// // 5 | fn f<!Sized>() {}
- /// // | ^
- /// enum GenericParam {
- /// Type(TypeParam),
- /// Lifetime(LifetimeDef),
- /// Const(ConstParam),
- /// }
- ///
- /// impl Parse for GenericParam {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let lookahead = input.lookahead1();
- /// if lookahead.peek(Ident) {
- /// input.parse().map(GenericParam::Type)
- /// } else if lookahead.peek(Lifetime) {
- /// input.parse().map(GenericParam::Lifetime)
- /// } else if lookahead.peek(Token![const]) {
- /// input.parse().map(GenericParam::Const)
- /// } else {
- /// Err(lookahead.error())
- /// }
- /// }
- /// }
- /// ```
- pub fn lookahead1(&self) -> Lookahead1<'a> {
- lookahead::new(self.scope, self.cursor())
- }
-
- /// Forks a parse stream so that parsing tokens out of either the original
- /// or the fork does not advance the position of the other.
- ///
- /// # Performance
- ///
- /// Forking a parse stream is a cheap fixed amount of work and does not
- /// involve copying token buffers. Where you might hit performance problems
- /// is if your macro ends up parsing a large amount of content more than
- /// once.
- ///
- /// ```
- /// # use syn::{Expr, Result};
- /// # use syn::parse::ParseStream;
- /// #
- /// # fn bad(input: ParseStream) -> Result<Expr> {
- /// // Do not do this.
- /// if input.fork().parse::<Expr>().is_ok() {
- /// return input.parse::<Expr>();
- /// }
- /// # unimplemented!()
- /// # }
- /// ```
- ///
- /// As a rule, avoid parsing an unbounded amount of tokens out of a forked
- /// parse stream. Only use a fork when the amount of work performed against
- /// the fork is small and bounded.
- ///
- /// When complex speculative parsing against the forked stream is
- /// unavoidable, use [`parse::discouraged::Speculative`] to advance the
- /// original stream once the fork's parse is determined to have been
- /// successful.
- ///
- /// For a lower level way to perform speculative parsing at the token level,
- /// consider using [`ParseStream::step`] instead.
- ///
- /// [`parse::discouraged::Speculative`]: discouraged::Speculative
- /// [`ParseStream::step`]: ParseBuffer::step
- ///
- /// # Example
- ///
- /// The parse implementation shown here parses possibly restricted `pub`
- /// visibilities.
- ///
- /// - `pub`
- /// - `pub(crate)`
- /// - `pub(self)`
- /// - `pub(super)`
- /// - `pub(in some::path)`
- ///
- /// To handle the case of visibilities inside of tuple structs, the parser
- /// needs to distinguish parentheses that specify visibility restrictions
- /// from parentheses that form part of a tuple type.
- ///
- /// ```
- /// # struct A;
- /// # struct B;
- /// # struct C;
- /// #
- /// struct S(pub(crate) A, pub (B, C));
- /// ```
- ///
- /// In this example input the first tuple struct element of `S` has
- /// `pub(crate)` visibility while the second tuple struct element has `pub`
- /// visibility; the parentheses around `(B, C)` are part of the type rather
- /// than part of a visibility restriction.
- ///
- /// The parser uses a forked parse stream to check the first token inside of
- /// parentheses after the `pub` keyword. This is a small bounded amount of
- /// work performed against the forked parse stream.
- ///
- /// ```
- /// use syn::{parenthesized, token, Ident, Path, Result, Token};
- /// use syn::ext::IdentExt;
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// struct PubVisibility {
- /// pub_token: Token![pub],
- /// restricted: Option<Restricted>,
- /// }
- ///
- /// struct Restricted {
- /// paren_token: token::Paren,
- /// in_token: Option<Token![in]>,
- /// path: Path,
- /// }
- ///
- /// impl Parse for PubVisibility {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let pub_token: Token![pub] = input.parse()?;
- ///
- /// if input.peek(token::Paren) {
- /// let ahead = input.fork();
- /// let mut content;
- /// parenthesized!(content in ahead);
- ///
- /// if content.peek(Token![crate])
- /// || content.peek(Token![self])
- /// || content.peek(Token![super])
- /// {
- /// return Ok(PubVisibility {
- /// pub_token,
- /// restricted: Some(Restricted {
- /// paren_token: parenthesized!(content in input),
- /// in_token: None,
- /// path: Path::from(content.call(Ident::parse_any)?),
- /// }),
- /// });
- /// } else if content.peek(Token![in]) {
- /// return Ok(PubVisibility {
- /// pub_token,
- /// restricted: Some(Restricted {
- /// paren_token: parenthesized!(content in input),
- /// in_token: Some(content.parse()?),
- /// path: content.call(Path::parse_mod_style)?,
- /// }),
- /// });
- /// }
- /// }
- ///
- /// Ok(PubVisibility {
- /// pub_token,
- /// restricted: None,
- /// })
- /// }
- /// }
- /// ```
- pub fn fork(&self) -> Self {
- ParseBuffer {
- scope: self.scope,
- cell: self.cell.clone(),
- marker: PhantomData,
- // Not the parent's unexpected. Nothing cares whether the clone
- // parses all the way unless we `advance_to`.
- unexpected: Cell::new(Some(Rc::new(Cell::new(Unexpected::None)))),
- }
- }
-
- /// Triggers an error at the current position of the parse stream.
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{Expr, Result, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // Some kind of loop: `while` or `for` or `loop`.
- /// struct Loop {
- /// expr: Expr,
- /// }
- ///
- /// impl Parse for Loop {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// if input.peek(Token![while])
- /// || input.peek(Token![for])
- /// || input.peek(Token![loop])
- /// {
- /// Ok(Loop {
- /// expr: input.parse()?,
- /// })
- /// } else {
- /// Err(input.error("expected some kind of loop"))
- /// }
- /// }
- /// }
- /// ```
- pub fn error<T: Display>(&self, message: T) -> Error {
- error::new_at(self.scope, self.cursor(), message)
- }
-
- /// Speculatively parses tokens from this parse stream, advancing the
- /// position of this stream only if parsing succeeds.
- ///
- /// This is a powerful low-level API used for defining the `Parse` impls of
- /// the basic built-in token types. It is not something that will be used
- /// widely outside of the Syn codebase.
- ///
- /// # Example
- ///
- /// ```
- /// use proc_macro2::TokenTree;
- /// use syn::Result;
- /// use syn::parse::ParseStream;
- ///
- /// // This function advances the stream past the next occurrence of `@`. If
- /// // no `@` is present in the stream, the stream position is unchanged and
- /// // an error is returned.
- /// fn skip_past_next_at(input: ParseStream) -> Result<()> {
- /// input.step(|cursor| {
- /// let mut rest = *cursor;
- /// while let Some((tt, next)) = rest.token_tree() {
- /// match &tt {
- /// TokenTree::Punct(punct) if punct.as_char() == '@' => {
- /// return Ok(((), next));
- /// }
- /// _ => rest = next,
- /// }
- /// }
- /// Err(cursor.error("no `@` was found after this point"))
- /// })
- /// }
- /// #
- /// # fn remainder_after_skipping_past_next_at(
- /// # input: ParseStream,
- /// # ) -> Result<proc_macro2::TokenStream> {
- /// # skip_past_next_at(input)?;
- /// # input.parse()
- /// # }
- /// #
- /// # use syn::parse::Parser;
- /// # let remainder = remainder_after_skipping_past_next_at
- /// # .parse_str("a @ b c")
- /// # .unwrap();
- /// # assert_eq!(remainder.to_string(), "b c");
- /// ```
- pub fn step<F, R>(&self, function: F) -> Result<R>
- where
- F: for<'c> FnOnce(StepCursor<'c, 'a>) -> Result<(R, Cursor<'c>)>,
- {
- // Since the user's function is required to work for any 'c, we know
- // that the Cursor<'c> they return is either derived from the input
- // StepCursor<'c, 'a> or from a Cursor<'static>.
- //
- // It would not be legal to write this function without the invariant
- // lifetime 'c in StepCursor<'c, 'a>. If this function were written only
- // in terms of 'a, the user could take our ParseBuffer<'a>, upcast it to
- // a ParseBuffer<'short> which some shorter lifetime than 'a, invoke
- // `step` on their ParseBuffer<'short> with a closure that returns
- // Cursor<'short>, and we would wrongly write that Cursor<'short> into
- // the Cell intended to hold Cursor<'a>.
- //
- // In some cases it may be necessary for R to contain a Cursor<'a>.
- // Within Syn we solve this using `advance_step_cursor` which uses the
- // existence of a StepCursor<'c, 'a> as proof that it is safe to cast
- // from Cursor<'c> to Cursor<'a>. If needed outside of Syn, it would be
- // safe to expose that API as a method on StepCursor.
- let (node, rest) = function(StepCursor {
- scope: self.scope,
- cursor: self.cell.get(),
- marker: PhantomData,
- })?;
- self.cell.set(rest);
- Ok(node)
- }
-
- /// Returns the `Span` of the next token in the parse stream, or
- /// `Span::call_site()` if this parse stream has completely exhausted its
- /// input `TokenStream`.
- pub fn span(&self) -> Span {
- let cursor = self.cursor();
- if cursor.eof() {
- self.scope
- } else {
- crate::buffer::open_span_of_group(cursor)
- }
- }
-
- /// Provides low-level access to the token representation underlying this
- /// parse stream.
- ///
- /// Cursors are immutable so no operations you perform against the cursor
- /// will affect the state of this parse stream.
- pub fn cursor(&self) -> Cursor<'a> {
- self.cell.get()
- }
-
- fn check_unexpected(&self) -> Result<()> {
- match inner_unexpected(self).1 {
- Some(span) => Err(Error::new(span, "unexpected token")),
- None => Ok(()),
- }
- }
-}
-
-impl<T: Parse> Parse for Box<T> {
- fn parse(input: ParseStream) -> Result<Self> {
- input.parse().map(Box::new)
- }
-}
-
-impl<T: Parse + Token> Parse for Option<T> {
- fn parse(input: ParseStream) -> Result<Self> {
- if T::peek(input.cursor()) {
- Ok(Some(input.parse()?))
- } else {
- Ok(None)
- }
- }
-}
-
-impl Parse for TokenStream {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| Ok((cursor.token_stream(), Cursor::empty())))
- }
-}
-
-impl Parse for TokenTree {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| match cursor.token_tree() {
- Some((tt, rest)) => Ok((tt, rest)),
- None => Err(cursor.error("expected token tree")),
- })
- }
-}
-
-impl Parse for Group {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| {
- for delim in &[Delimiter::Parenthesis, Delimiter::Brace, Delimiter::Bracket] {
- if let Some((inside, span, rest)) = cursor.group(*delim) {
- let mut group = Group::new(*delim, inside.token_stream());
- group.set_span(span);
- return Ok((group, rest));
- }
- }
- Err(cursor.error("expected group token"))
- })
- }
-}
-
-impl Parse for Punct {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| match cursor.punct() {
- Some((punct, rest)) => Ok((punct, rest)),
- None => Err(cursor.error("expected punctuation token")),
- })
- }
-}
-
-impl Parse for Literal {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| match cursor.literal() {
- Some((literal, rest)) => Ok((literal, rest)),
- None => Err(cursor.error("expected literal token")),
- })
- }
-}
-
-/// Parser that can parse Rust tokens into a particular syntax tree node.
-///
-/// Refer to the [module documentation] for details about parsing in Syn.
-///
-/// [module documentation]: self
-///
-/// *This trait is available if Syn is built with the `"parsing"` feature.*
-pub trait Parser: Sized {
- type Output;
-
- /// Parse a proc-macro2 token stream into the chosen syntax tree node.
- ///
- /// This function will check that the input is fully parsed. If there are
- /// any unparsed tokens at the end of the stream, an error is returned.
- fn parse2(self, tokens: TokenStream) -> Result<Self::Output>;
-
- /// Parse tokens of source code into the chosen syntax tree node.
- ///
- /// This function will check that the input is fully parsed. If there are
- /// any unparsed tokens at the end of the stream, an error is returned.
- ///
- /// *This method is available if Syn is built with both the `"parsing"` and
- /// `"proc-macro"` features.*
- #[cfg(all(
- not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
- feature = "proc-macro"
- ))]
- fn parse(self, tokens: proc_macro::TokenStream) -> Result<Self::Output> {
- self.parse2(proc_macro2::TokenStream::from(tokens))
- }
-
- /// Parse a string of Rust code into the chosen syntax tree node.
- ///
- /// This function will check that the input is fully parsed. If there are
- /// any unparsed tokens at the end of the string, an error is returned.
- ///
- /// # Hygiene
- ///
- /// Every span in the resulting syntax tree will be set to resolve at the
- /// macro call site.
- fn parse_str(self, s: &str) -> Result<Self::Output> {
- self.parse2(proc_macro2::TokenStream::from_str(s)?)
- }
-
- // Not public API.
- #[doc(hidden)]
- fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
- let _ = scope;
- self.parse2(tokens)
- }
-
- // Not public API.
- #[doc(hidden)]
- fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> {
- input.parse().and_then(|tokens| self.parse2(tokens))
- }
-}
-
-fn tokens_to_parse_buffer(tokens: &TokenBuffer) -> ParseBuffer {
- let scope = Span::call_site();
- let cursor = tokens.begin();
- let unexpected = Rc::new(Cell::new(Unexpected::None));
- new_parse_buffer(scope, cursor, unexpected)
-}
-
-impl<F, T> Parser for F
-where
- F: FnOnce(ParseStream) -> Result<T>,
-{
- type Output = T;
-
- fn parse2(self, tokens: TokenStream) -> Result<T> {
- let buf = TokenBuffer::new2(tokens);
- let state = tokens_to_parse_buffer(&buf);
- let node = self(&state)?;
- state.check_unexpected()?;
- if state.is_empty() {
- Ok(node)
- } else {
- Err(state.error("unexpected token"))
- }
- }
-
- #[doc(hidden)]
- fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
- let buf = TokenBuffer::new2(tokens);
- let cursor = buf.begin();
- let unexpected = Rc::new(Cell::new(Unexpected::None));
- let state = new_parse_buffer(scope, cursor, unexpected);
- let node = self(&state)?;
- state.check_unexpected()?;
- if state.is_empty() {
- Ok(node)
- } else {
- Err(state.error("unexpected token"))
- }
- }
-
- #[doc(hidden)]
- fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> {
- self(input)
- }
-}
-
-pub(crate) fn parse_scoped<F: Parser>(f: F, scope: Span, tokens: TokenStream) -> Result<F::Output> {
- f.__parse_scoped(scope, tokens)
-}
-
-pub(crate) fn parse_stream<F: Parser>(f: F, input: ParseStream) -> Result<F::Output> {
- f.__parse_stream(input)
-}
-
-/// An empty syntax tree node that consumes no tokens when parsed.
-///
-/// This is useful for attribute macros that want to ensure they are not
-/// provided any attribute args.
-///
-/// ```
-/// extern crate proc_macro;
-///
-/// use proc_macro::TokenStream;
-/// use syn::parse_macro_input;
-/// use syn::parse::Nothing;
-///
-/// # const IGNORE: &str = stringify! {
-/// #[proc_macro_attribute]
-/// # };
-/// pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream {
-/// parse_macro_input!(args as Nothing);
-///
-/// /* ... */
-/// # "".parse().unwrap()
-/// }
-/// ```
-///
-/// ```text
-/// error: unexpected token
-/// --> src/main.rs:3:19
-/// |
-/// 3 | #[my_attr(asdf)]
-/// | ^^^^
-/// ```
-pub struct Nothing;
-
-impl Parse for Nothing {
- fn parse(_input: ParseStream) -> Result<Self> {
- Ok(Nothing)
- }
-}
diff --git a/syn/src/parse_macro_input.rs b/syn/src/parse_macro_input.rs
deleted file mode 100644
index d6e0725..0000000
--- a/syn/src/parse_macro_input.rs
+++ /dev/null
@@ -1,110 +0,0 @@
-/// Parse the input TokenStream of a macro, triggering a compile error if the
-/// tokens fail to parse.
-///
-/// Refer to the [`parse` module] documentation for more details about parsing
-/// in Syn.
-///
-/// [`parse` module]: crate::rustdoc_workaround::parse_module
-///
-/// <br>
-///
-/// # Intended usage
-///
-/// This macro must be called from a function that returns
-/// `proc_macro::TokenStream`. Usually this will be your proc macro entry point,
-/// the function that has the #\[proc_macro\] / #\[proc_macro_derive\] /
-/// #\[proc_macro_attribute\] attribute.
-///
-/// ```
-/// extern crate proc_macro;
-///
-/// use proc_macro::TokenStream;
-/// use syn::{parse_macro_input, Result};
-/// use syn::parse::{Parse, ParseStream};
-///
-/// struct MyMacroInput {
-/// /* ... */
-/// }
-///
-/// impl Parse for MyMacroInput {
-/// fn parse(input: ParseStream) -> Result<Self> {
-/// /* ... */
-/// # Ok(MyMacroInput {})
-/// }
-/// }
-///
-/// # const IGNORE: &str = stringify! {
-/// #[proc_macro]
-/// # };
-/// pub fn my_macro(tokens: TokenStream) -> TokenStream {
-/// let input = parse_macro_input!(tokens as MyMacroInput);
-///
-/// /* ... */
-/// # "".parse().unwrap()
-/// }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! parse_macro_input {
- ($tokenstream:ident as $ty:ty) => {
- match $crate::parse_macro_input::parse::<$ty>($tokenstream) {
- $crate::export::Ok(data) => data,
- $crate::export::Err(err) => {
- return $crate::export::TokenStream::from(err.to_compile_error());
- }
- }
- };
- ($tokenstream:ident) => {
- parse_macro_input!($tokenstream as _)
- };
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Can parse any type that implements Parse.
-
-use crate::parse::{Parse, ParseStream, Parser, Result};
-use proc_macro::TokenStream;
-
-// Not public API.
-#[doc(hidden)]
-pub fn parse<T: ParseMacroInput>(token_stream: TokenStream) -> Result<T> {
- T::parse.parse(token_stream)
-}
-
-// Not public API.
-#[doc(hidden)]
-pub trait ParseMacroInput: Sized {
- fn parse(input: ParseStream) -> Result<Self>;
-}
-
-impl<T: Parse> ParseMacroInput for T {
- fn parse(input: ParseStream) -> Result<Self> {
- <T as Parse>::parse(input)
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Any other types that we want `parse_macro_input!` to be able to parse.
-
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::AttributeArgs;
-
-#[cfg(any(feature = "full", feature = "derive"))]
-impl ParseMacroInput for AttributeArgs {
- fn parse(input: ParseStream) -> Result<Self> {
- let mut metas = Vec::new();
-
- loop {
- if input.is_empty() {
- break;
- }
- let value = input.parse()?;
- metas.push(value);
- if input.is_empty() {
- break;
- }
- input.parse::<Token![,]>()?;
- }
-
- Ok(metas)
- }
-}
diff --git a/syn/src/parse_quote.rs b/syn/src/parse_quote.rs
deleted file mode 100644
index 18a47b9..0000000
--- a/syn/src/parse_quote.rs
+++ /dev/null
@@ -1,131 +0,0 @@
-/// Quasi-quotation macro that accepts input like the [`quote!`] macro but uses
-/// type inference to figure out a return type for those tokens.
-///
-/// [`quote!`]: https://docs.rs/quote/1.0/quote/index.html
-///
-/// The return type can be any syntax tree node that implements the [`Parse`]
-/// trait.
-///
-/// [`Parse`]: parse::Parse
-///
-/// ```
-/// use quote::quote;
-/// use syn::{parse_quote, Stmt};
-///
-/// fn main() {
-/// let name = quote!(v);
-/// let ty = quote!(u8);
-///
-/// let stmt: Stmt = parse_quote! {
-/// let #name: #ty = Default::default();
-/// };
-///
-/// println!("{:#?}", stmt);
-/// }
-/// ```
-///
-/// *This macro is available if Syn is built with the `"parsing"` feature,
-/// although interpolation of syntax tree nodes into the quoted tokens is only
-/// supported if Syn is built with the `"printing"` feature as well.*
-///
-/// # Example
-///
-/// The following helper function adds a bound `T: HeapSize` to every type
-/// parameter `T` in the input generics.
-///
-/// ```
-/// use syn::{parse_quote, Generics, GenericParam};
-///
-/// // Add a bound `T: HeapSize` to every type parameter T.
-/// fn add_trait_bounds(mut generics: Generics) -> Generics {
-/// for param in &mut generics.params {
-/// if let GenericParam::Type(type_param) = param {
-/// type_param.bounds.push(parse_quote!(HeapSize));
-/// }
-/// }
-/// generics
-/// }
-/// ```
-///
-/// # Special cases
-///
-/// This macro can parse the following additional types as a special case even
-/// though they do not implement the `Parse` trait.
-///
-/// - [`Attribute`] — parses one attribute, allowing either outer like `#[...]`
-/// or inner like `#![...]`
-/// - [`Punctuated<T, P>`] — parses zero or more `T` separated by punctuation
-/// `P` with optional trailing punctuation
-///
-/// [`Punctuated<T, P>`]: punctuated::Punctuated
-///
-/// # Panics
-///
-/// Panics if the tokens fail to parse as the expected syntax tree type. The
-/// caller is responsible for ensuring that the input tokens are syntactically
-/// valid.
-//
-// TODO: allow Punctuated to be inferred as intra doc link, currently blocked on
-// https://github.com/rust-lang/rust/issues/62834
-#[macro_export(local_inner_macros)]
-macro_rules! parse_quote {
- ($($tt:tt)*) => {
- $crate::parse_quote::parse(
- $crate::export::From::from(
- $crate::export::quote::quote!($($tt)*)
- )
- )
- };
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Can parse any type that implements Parse.
-
-use crate::parse::{Parse, ParseStream, Parser, Result};
-use proc_macro2::TokenStream;
-
-// Not public API.
-#[doc(hidden)]
-pub fn parse<T: ParseQuote>(token_stream: TokenStream) -> T {
- let parser = T::parse;
- match parser.parse2(token_stream) {
- Ok(t) => t,
- Err(err) => panic!("{}", err),
- }
-}
-
-// Not public API.
-#[doc(hidden)]
-pub trait ParseQuote: Sized {
- fn parse(input: ParseStream) -> Result<Self>;
-}
-
-impl<T: Parse> ParseQuote for T {
- fn parse(input: ParseStream) -> Result<Self> {
- <T as Parse>::parse(input)
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Any other types that we want `parse_quote!` to be able to parse.
-
-use crate::punctuated::Punctuated;
-#[cfg(any(feature = "full", feature = "derive"))]
-use crate::{attr, Attribute};
-
-#[cfg(any(feature = "full", feature = "derive"))]
-impl ParseQuote for Attribute {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![#]) && input.peek2(Token![!]) {
- attr::parsing::single_parse_inner(input)
- } else {
- attr::parsing::single_parse_outer(input)
- }
- }
-}
-
-impl<T: Parse, P: Parse> ParseQuote for Punctuated<T, P> {
- fn parse(input: ParseStream) -> Result<Self> {
- Self::parse_terminated(input)
- }
-}
diff --git a/syn/src/pat.rs b/syn/src/pat.rs
deleted file mode 100644
index 262129b..0000000
--- a/syn/src/pat.rs
+++ /dev/null
@@ -1,903 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-#[cfg(feature = "extra-traits")]
-use crate::tt::TokenStreamHelper;
-use proc_macro2::TokenStream;
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-
-ast_enum_of_structs! {
- /// A pattern in a local binding, function signature, match expression, or
- /// various other places.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Pat #manual_extra_traits {
- /// A box pattern: `box v`.
- Box(PatBox),
-
- /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
- Ident(PatIdent),
-
- /// A literal pattern: `0`.
- ///
- /// This holds an `Expr` rather than a `Lit` because negative numbers
- /// are represented as an `Expr::Unary`.
- Lit(PatLit),
-
- /// A macro in pattern position.
- Macro(PatMacro),
-
- /// A pattern that matches any one of a set of cases.
- Or(PatOr),
-
- /// A path pattern like `Color::Red`, optionally qualified with a
- /// self-type.
- ///
- /// Unqualified path patterns can legally refer to variants, structs,
- /// constants or associated constants. Qualified path patterns like
- /// `<A>::B::C` and `<A as Trait>::B::C` can only legally refer to
- /// associated constants.
- Path(PatPath),
-
- /// A range pattern: `1..=2`.
- Range(PatRange),
-
- /// A reference pattern: `&mut var`.
- Reference(PatReference),
-
- /// The dots in a tuple or slice pattern: `[0, 1, ..]`
- Rest(PatRest),
-
- /// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`.
- Slice(PatSlice),
-
- /// A struct or struct variant pattern: `Variant { x, y, .. }`.
- Struct(PatStruct),
-
- /// A tuple pattern: `(a, b)`.
- Tuple(PatTuple),
-
- /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
- TupleStruct(PatTupleStruct),
-
- /// A type ascription pattern: `foo: f64`.
- Type(PatType),
-
- /// Tokens in pattern position not interpreted by Syn.
- Verbatim(TokenStream),
-
- /// A pattern that matches any value: `_`.
- Wild(PatWild),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// A box pattern: `box v`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatBox {
- pub attrs: Vec<Attribute>,
- pub box_token: Token![box],
- pub pat: Box<Pat>,
- }
-}
-
-ast_struct! {
- /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatIdent {
- pub attrs: Vec<Attribute>,
- pub by_ref: Option<Token![ref]>,
- pub mutability: Option<Token![mut]>,
- pub ident: Ident,
- pub subpat: Option<(Token![@], Box<Pat>)>,
- }
-}
-
-ast_struct! {
- /// A literal pattern: `0`.
- ///
- /// This holds an `Expr` rather than a `Lit` because negative numbers
- /// are represented as an `Expr::Unary`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatLit {
- pub attrs: Vec<Attribute>,
- pub expr: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A macro in pattern position.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatMacro {
- pub attrs: Vec<Attribute>,
- pub mac: Macro,
- }
-}
-
-ast_struct! {
- /// A pattern that matches any one of a set of cases.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatOr {
- pub attrs: Vec<Attribute>,
- pub leading_vert: Option<Token![|]>,
- pub cases: Punctuated<Pat, Token![|]>,
- }
-}
-
-ast_struct! {
- /// A path pattern like `Color::Red`, optionally qualified with a
- /// self-type.
- ///
- /// Unqualified path patterns can legally refer to variants, structs,
- /// constants or associated constants. Qualified path patterns like
- /// `<A>::B::C` and `<A as Trait>::B::C` can only legally refer to
- /// associated constants.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatPath {
- pub attrs: Vec<Attribute>,
- pub qself: Option<QSelf>,
- pub path: Path,
- }
-}
-
-ast_struct! {
- /// A range pattern: `1..=2`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatRange {
- pub attrs: Vec<Attribute>,
- pub lo: Box<Expr>,
- pub limits: RangeLimits,
- pub hi: Box<Expr>,
- }
-}
-
-ast_struct! {
- /// A reference pattern: `&mut var`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatReference {
- pub attrs: Vec<Attribute>,
- pub and_token: Token![&],
- pub mutability: Option<Token![mut]>,
- pub pat: Box<Pat>,
- }
-}
-
-ast_struct! {
- /// The dots in a tuple or slice pattern: `[0, 1, ..]`
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatRest {
- pub attrs: Vec<Attribute>,
- pub dot2_token: Token![..],
- }
-}
-
-ast_struct! {
- /// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatSlice {
- pub attrs: Vec<Attribute>,
- pub bracket_token: token::Bracket,
- pub elems: Punctuated<Pat, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A struct or struct variant pattern: `Variant { x, y, .. }`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatStruct {
- pub attrs: Vec<Attribute>,
- pub path: Path,
- pub brace_token: token::Brace,
- pub fields: Punctuated<FieldPat, Token![,]>,
- pub dot2_token: Option<Token![..]>,
- }
-}
-
-ast_struct! {
- /// A tuple pattern: `(a, b)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatTuple {
- pub attrs: Vec<Attribute>,
- pub paren_token: token::Paren,
- pub elems: Punctuated<Pat, Token![,]>,
- }
-}
-
-ast_struct! {
- /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatTupleStruct {
- pub attrs: Vec<Attribute>,
- pub path: Path,
- pub pat: PatTuple,
- }
-}
-
-ast_struct! {
- /// A type ascription pattern: `foo: f64`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatType {
- pub attrs: Vec<Attribute>,
- pub pat: Box<Pat>,
- pub colon_token: Token![:],
- pub ty: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A pattern that matches any value: `_`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct PatWild {
- pub attrs: Vec<Attribute>,
- pub underscore_token: Token![_],
- }
-}
-
-ast_struct! {
- /// A single field in a struct pattern.
- ///
- /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated
- /// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct FieldPat {
- pub attrs: Vec<Attribute>,
- pub member: Member,
- pub colon_token: Option<Token![:]>,
- pub pat: Box<Pat>,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Pat {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Pat {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (Pat::Box(this), Pat::Box(other)) => this == other,
- (Pat::Ident(this), Pat::Ident(other)) => this == other,
- (Pat::Lit(this), Pat::Lit(other)) => this == other,
- (Pat::Macro(this), Pat::Macro(other)) => this == other,
- (Pat::Or(this), Pat::Or(other)) => this == other,
- (Pat::Path(this), Pat::Path(other)) => this == other,
- (Pat::Range(this), Pat::Range(other)) => this == other,
- (Pat::Reference(this), Pat::Reference(other)) => this == other,
- (Pat::Rest(this), Pat::Rest(other)) => this == other,
- (Pat::Slice(this), Pat::Slice(other)) => this == other,
- (Pat::Struct(this), Pat::Struct(other)) => this == other,
- (Pat::Tuple(this), Pat::Tuple(other)) => this == other,
- (Pat::TupleStruct(this), Pat::TupleStruct(other)) => this == other,
- (Pat::Type(this), Pat::Type(other)) => this == other,
- (Pat::Verbatim(this), Pat::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- (Pat::Wild(this), Pat::Wild(other)) => this == other,
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Pat {
- fn hash<H>(&self, hash: &mut H)
- where
- H: Hasher,
- {
- match self {
- Pat::Box(pat) => {
- hash.write_u8(0);
- pat.hash(hash);
- }
- Pat::Ident(pat) => {
- hash.write_u8(1);
- pat.hash(hash);
- }
- Pat::Lit(pat) => {
- hash.write_u8(2);
- pat.hash(hash);
- }
- Pat::Macro(pat) => {
- hash.write_u8(3);
- pat.hash(hash);
- }
- Pat::Or(pat) => {
- hash.write_u8(4);
- pat.hash(hash);
- }
- Pat::Path(pat) => {
- hash.write_u8(5);
- pat.hash(hash);
- }
- Pat::Range(pat) => {
- hash.write_u8(6);
- pat.hash(hash);
- }
- Pat::Reference(pat) => {
- hash.write_u8(7);
- pat.hash(hash);
- }
- Pat::Rest(pat) => {
- hash.write_u8(8);
- pat.hash(hash);
- }
- Pat::Slice(pat) => {
- hash.write_u8(9);
- pat.hash(hash);
- }
- Pat::Struct(pat) => {
- hash.write_u8(10);
- pat.hash(hash);
- }
- Pat::Tuple(pat) => {
- hash.write_u8(11);
- pat.hash(hash);
- }
- Pat::TupleStruct(pat) => {
- hash.write_u8(12);
- pat.hash(hash);
- }
- Pat::Type(pat) => {
- hash.write_u8(13);
- pat.hash(hash);
- }
- Pat::Verbatim(pat) => {
- hash.write_u8(14);
- TokenStreamHelper(pat).hash(hash);
- }
- Pat::Wild(pat) => {
- hash.write_u8(15);
- pat.hash(hash);
- }
- Pat::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-#[cfg(feature = "parsing")]
-mod parsing {
- use super::*;
-
- use crate::ext::IdentExt;
- use crate::parse::{Parse, ParseStream, Result};
- use crate::path;
-
- impl Parse for Pat {
- fn parse(input: ParseStream) -> Result<Self> {
- let lookahead = input.lookahead1();
- if lookahead.peek(Ident)
- && ({
- input.peek2(Token![::])
- || input.peek2(Token![!])
- || input.peek2(token::Brace)
- || input.peek2(token::Paren)
- || input.peek2(Token![..])
- && !{
- let ahead = input.fork();
- ahead.parse::<Ident>()?;
- ahead.parse::<RangeLimits>()?;
- ahead.is_empty() || ahead.peek(Token![,])
- }
- })
- || input.peek(Token![self]) && input.peek2(Token![::])
- || lookahead.peek(Token![::])
- || lookahead.peek(Token![<])
- || input.peek(Token![Self])
- || input.peek(Token![super])
- || input.peek(Token![extern])
- || input.peek(Token![crate])
- {
- pat_path_or_macro_or_struct_or_range(input)
- } else if lookahead.peek(Token![_]) {
- input.call(pat_wild).map(Pat::Wild)
- } else if input.peek(Token![box]) {
- input.call(pat_box).map(Pat::Box)
- } else if input.peek(Token![-]) || lookahead.peek(Lit) {
- pat_lit_or_range(input)
- } else if lookahead.peek(Token![ref])
- || lookahead.peek(Token![mut])
- || input.peek(Token![self])
- || input.peek(Ident)
- {
- input.call(pat_ident).map(Pat::Ident)
- } else if lookahead.peek(Token![&]) {
- input.call(pat_reference).map(Pat::Reference)
- } else if lookahead.peek(token::Paren) {
- input.call(pat_tuple).map(Pat::Tuple)
- } else if lookahead.peek(token::Bracket) {
- input.call(pat_slice).map(Pat::Slice)
- } else if lookahead.peek(Token![..]) && !input.peek(Token![...]) {
- input.call(pat_rest).map(Pat::Rest)
- } else {
- Err(lookahead.error())
- }
- }
- }
-
- fn pat_path_or_macro_or_struct_or_range(input: ParseStream) -> Result<Pat> {
- let (qself, path) = path::parsing::qpath(input, true)?;
-
- if input.peek(Token![..]) {
- return pat_range(input, qself, path).map(Pat::Range);
- }
-
- if qself.is_some() {
- return Ok(Pat::Path(PatPath {
- attrs: Vec::new(),
- qself,
- path,
- }));
- }
-
- if input.peek(Token![!]) && !input.peek(Token![!=]) {
- let mut contains_arguments = false;
- for segment in &path.segments {
- match segment.arguments {
- PathArguments::None => {}
- PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => {
- contains_arguments = true;
- }
- }
- }
-
- if !contains_arguments {
- let bang_token: Token![!] = input.parse()?;
- let (delimiter, tokens) = mac::parse_delimiter(input)?;
- return Ok(Pat::Macro(PatMacro {
- attrs: Vec::new(),
- mac: Macro {
- path,
- bang_token,
- delimiter,
- tokens,
- },
- }));
- }
- }
-
- if input.peek(token::Brace) {
- pat_struct(input, path).map(Pat::Struct)
- } else if input.peek(token::Paren) {
- pat_tuple_struct(input, path).map(Pat::TupleStruct)
- } else if input.peek(Token![..]) {
- pat_range(input, qself, path).map(Pat::Range)
- } else {
- Ok(Pat::Path(PatPath {
- attrs: Vec::new(),
- qself,
- path,
- }))
- }
- }
-
- fn pat_wild(input: ParseStream) -> Result<PatWild> {
- Ok(PatWild {
- attrs: Vec::new(),
- underscore_token: input.parse()?,
- })
- }
-
- fn pat_box(input: ParseStream) -> Result<PatBox> {
- Ok(PatBox {
- attrs: Vec::new(),
- box_token: input.parse()?,
- pat: input.parse()?,
- })
- }
-
- fn pat_ident(input: ParseStream) -> Result<PatIdent> {
- Ok(PatIdent {
- attrs: Vec::new(),
- by_ref: input.parse()?,
- mutability: input.parse()?,
- ident: input.call(Ident::parse_any)?,
- subpat: {
- if input.peek(Token![@]) {
- let at_token: Token![@] = input.parse()?;
- let subpat: Pat = input.parse()?;
- Some((at_token, Box::new(subpat)))
- } else {
- None
- }
- },
- })
- }
-
- fn pat_tuple_struct(input: ParseStream, path: Path) -> Result<PatTupleStruct> {
- Ok(PatTupleStruct {
- attrs: Vec::new(),
- path,
- pat: input.call(pat_tuple)?,
- })
- }
-
- fn pat_struct(input: ParseStream, path: Path) -> Result<PatStruct> {
- let content;
- let brace_token = braced!(content in input);
-
- let mut fields = Punctuated::new();
- while !content.is_empty() && !content.peek(Token![..]) {
- let value = content.call(field_pat)?;
- fields.push_value(value);
- if !content.peek(Token![,]) {
- break;
- }
- let punct: Token![,] = content.parse()?;
- fields.push_punct(punct);
- }
-
- let dot2_token = if fields.empty_or_trailing() && content.peek(Token![..]) {
- Some(content.parse()?)
- } else {
- None
- };
-
- Ok(PatStruct {
- attrs: Vec::new(),
- path,
- brace_token,
- fields,
- dot2_token,
- })
- }
-
- impl Member {
- fn is_unnamed(&self) -> bool {
- match *self {
- Member::Named(_) => false,
- Member::Unnamed(_) => true,
- }
- }
- }
-
- fn field_pat(input: ParseStream) -> Result<FieldPat> {
- let attrs = input.call(Attribute::parse_outer)?;
- let boxed: Option<Token![box]> = input.parse()?;
- let by_ref: Option<Token![ref]> = input.parse()?;
- let mutability: Option<Token![mut]> = input.parse()?;
- let member: Member = input.parse()?;
-
- if boxed.is_none() && by_ref.is_none() && mutability.is_none() && input.peek(Token![:])
- || member.is_unnamed()
- {
- return Ok(FieldPat {
- attrs,
- member,
- colon_token: input.parse()?,
- pat: input.parse()?,
- });
- }
-
- let ident = match member {
- Member::Named(ident) => ident,
- Member::Unnamed(_) => unreachable!(),
- };
-
- let mut pat = Pat::Ident(PatIdent {
- attrs: Vec::new(),
- by_ref,
- mutability,
- ident: ident.clone(),
- subpat: None,
- });
-
- if let Some(boxed) = boxed {
- pat = Pat::Box(PatBox {
- attrs: Vec::new(),
- box_token: boxed,
- pat: Box::new(pat),
- });
- }
-
- Ok(FieldPat {
- attrs,
- member: Member::Named(ident),
- colon_token: None,
- pat: Box::new(pat),
- })
- }
-
- fn pat_range(input: ParseStream, qself: Option<QSelf>, path: Path) -> Result<PatRange> {
- Ok(PatRange {
- attrs: Vec::new(),
- lo: Box::new(Expr::Path(ExprPath {
- attrs: Vec::new(),
- qself,
- path,
- })),
- limits: input.parse()?,
- hi: input.call(pat_lit_expr)?,
- })
- }
-
- fn pat_tuple(input: ParseStream) -> Result<PatTuple> {
- let content;
- let paren_token = parenthesized!(content in input);
-
- let mut elems = Punctuated::new();
- while !content.is_empty() {
- let value: Pat = content.parse()?;
- elems.push_value(value);
- if content.is_empty() {
- break;
- }
- let punct = content.parse()?;
- elems.push_punct(punct);
- }
-
- Ok(PatTuple {
- attrs: Vec::new(),
- paren_token,
- elems,
- })
- }
-
- fn pat_reference(input: ParseStream) -> Result<PatReference> {
- Ok(PatReference {
- attrs: Vec::new(),
- and_token: input.parse()?,
- mutability: input.parse()?,
- pat: input.parse()?,
- })
- }
-
- fn pat_lit_or_range(input: ParseStream) -> Result<Pat> {
- let lo = input.call(pat_lit_expr)?;
- if input.peek(Token![..]) {
- Ok(Pat::Range(PatRange {
- attrs: Vec::new(),
- lo,
- limits: input.parse()?,
- hi: input.call(pat_lit_expr)?,
- }))
- } else {
- Ok(Pat::Lit(PatLit {
- attrs: Vec::new(),
- expr: lo,
- }))
- }
- }
-
- fn pat_lit_expr(input: ParseStream) -> Result<Box<Expr>> {
- let neg: Option<Token![-]> = input.parse()?;
-
- let lookahead = input.lookahead1();
- let expr = if lookahead.peek(Lit) {
- Expr::Lit(input.parse()?)
- } else if lookahead.peek(Ident)
- || lookahead.peek(Token![::])
- || lookahead.peek(Token![<])
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![Self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![extern])
- || lookahead.peek(Token![crate])
- {
- Expr::Path(input.parse()?)
- } else {
- return Err(lookahead.error());
- };
-
- Ok(Box::new(if let Some(neg) = neg {
- Expr::Unary(ExprUnary {
- attrs: Vec::new(),
- op: UnOp::Neg(neg),
- expr: Box::new(expr),
- })
- } else {
- expr
- }))
- }
-
- fn pat_slice(input: ParseStream) -> Result<PatSlice> {
- let content;
- let bracket_token = bracketed!(content in input);
-
- let mut elems = Punctuated::new();
- while !content.is_empty() {
- let value: Pat = content.parse()?;
- elems.push_value(value);
- if content.is_empty() {
- break;
- }
- let punct = content.parse()?;
- elems.push_punct(punct);
- }
-
- Ok(PatSlice {
- attrs: Vec::new(),
- bracket_token,
- elems,
- })
- }
-
- fn pat_rest(input: ParseStream) -> Result<PatRest> {
- Ok(PatRest {
- attrs: Vec::new(),
- dot2_token: input.parse()?,
- })
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use crate::attr::FilterAttrs;
-
- impl ToTokens for PatWild {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.underscore_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatIdent {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.by_ref.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.ident.to_tokens(tokens);
- if let Some((at_token, subpat)) = &self.subpat {
- at_token.to_tokens(tokens);
- subpat.to_tokens(tokens);
- }
- }
- }
-
- impl ToTokens for PatStruct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.path.to_tokens(tokens);
- self.brace_token.surround(tokens, |tokens| {
- self.fields.to_tokens(tokens);
- // NOTE: We need a comma before the dot2 token if it is present.
- if !self.fields.empty_or_trailing() && self.dot2_token.is_some() {
- <Token![,]>::default().to_tokens(tokens);
- }
- self.dot2_token.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for PatTupleStruct {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.path.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.pat.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatPath {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- private::print_path(tokens, &self.qself, &self.path);
- }
- }
-
- impl ToTokens for PatTuple {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.paren_token.surround(tokens, |tokens| {
- self.elems.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for PatBox {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.box_token.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatReference {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.and_token.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatRest {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.dot2_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatLit {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.expr.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatRange {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.lo.to_tokens(tokens);
- match &self.limits {
- RangeLimits::HalfOpen(t) => t.to_tokens(tokens),
- RangeLimits::Closed(t) => t.to_tokens(tokens),
- }
- self.hi.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatSlice {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.bracket_token.surround(tokens, |tokens| {
- self.elems.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for PatMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.mac.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PatOr {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.leading_vert.to_tokens(tokens);
- self.cases.to_tokens(tokens);
- }
- }
-
- impl ToTokens for FieldPat {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- if let Some(colon_token) = &self.colon_token {
- self.member.to_tokens(tokens);
- colon_token.to_tokens(tokens);
- }
- self.pat.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/path.rs b/syn/src/path.rs
deleted file mode 100644
index 8dda43e..0000000
--- a/syn/src/path.rs
+++ /dev/null
@@ -1,744 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-
-ast_struct! {
- /// A path at which a named item is exported: `std::collections::HashMap`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Path {
- pub leading_colon: Option<Token![::]>,
- pub segments: Punctuated<PathSegment, Token![::]>,
- }
-}
-
-impl<T> From<T> for Path
-where
- T: Into<PathSegment>,
-{
- fn from(segment: T) -> Self {
- let mut path = Path {
- leading_colon: None,
- segments: Punctuated::new(),
- };
- path.segments.push_value(segment.into());
- path
- }
-}
-
-ast_struct! {
- /// A segment of a path together with any path arguments on that segment.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct PathSegment {
- pub ident: Ident,
- pub arguments: PathArguments,
- }
-}
-
-impl<T> From<T> for PathSegment
-where
- T: Into<Ident>,
-{
- fn from(ident: T) -> Self {
- PathSegment {
- ident: ident.into(),
- arguments: PathArguments::None,
- }
- }
-}
-
-ast_enum! {
- /// Angle bracketed or parenthesized arguments of a path segment.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// ## Angle bracketed
- ///
- /// The `<'a, T>` in `std::slice::iter<'a, T>`.
- ///
- /// ## Parenthesized
- ///
- /// The `(A, B) -> C` in `Fn(A, B) -> C`.
- pub enum PathArguments {
- None,
- /// The `<'a, T>` in `std::slice::iter<'a, T>`.
- AngleBracketed(AngleBracketedGenericArguments),
- /// The `(A, B) -> C` in `Fn(A, B) -> C`.
- Parenthesized(ParenthesizedGenericArguments),
- }
-}
-
-impl Default for PathArguments {
- fn default() -> Self {
- PathArguments::None
- }
-}
-
-impl PathArguments {
- pub fn is_empty(&self) -> bool {
- match self {
- PathArguments::None => true,
- PathArguments::AngleBracketed(bracketed) => bracketed.args.is_empty(),
- PathArguments::Parenthesized(_) => false,
- }
- }
-
- #[cfg(feature = "parsing")]
- fn is_none(&self) -> bool {
- match *self {
- PathArguments::None => true,
- PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => false,
- }
- }
-}
-
-ast_enum! {
- /// An individual generic argument, like `'a`, `T`, or `Item = T`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub enum GenericArgument {
- /// A lifetime argument.
- Lifetime(Lifetime),
- /// A type argument.
- Type(Type),
- /// A binding (equality constraint) on an associated type: the `Item =
- /// u8` in `Iterator<Item = u8>`.
- Binding(Binding),
- /// An associated type bound: `Iterator<Item: Display>`.
- Constraint(Constraint),
- /// A const expression. Must be inside of a block.
- ///
- /// NOTE: Identity expressions are represented as Type arguments, as
- /// they are indistinguishable syntactically.
- Const(Expr),
- }
-}
-
-ast_struct! {
- /// Angle bracketed arguments of a path segment: the `<K, V>` in `HashMap<K,
- /// V>`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct AngleBracketedGenericArguments {
- pub colon2_token: Option<Token![::]>,
- pub lt_token: Token![<],
- pub args: Punctuated<GenericArgument, Token![,]>,
- pub gt_token: Token![>],
- }
-}
-
-ast_struct! {
- /// A binding (equality constraint) on an associated type: `Item = u8`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Binding {
- pub ident: Ident,
- pub eq_token: Token![=],
- pub ty: Type,
- }
-}
-
-ast_struct! {
- /// An associated type bound: `Iterator<Item: Display>`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Constraint {
- pub ident: Ident,
- pub colon_token: Token![:],
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- }
-}
-
-ast_struct! {
- /// Arguments of a function path segment: the `(A, B) -> C` in `Fn(A,B) ->
- /// C`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct ParenthesizedGenericArguments {
- pub paren_token: token::Paren,
- /// `(A, B)`
- pub inputs: Punctuated<Type, Token![,]>,
- /// `C`
- pub output: ReturnType,
- }
-}
-
-ast_struct! {
- /// The explicit Self type in a qualified path: the `T` in `<T as
- /// Display>::fmt`.
- ///
- /// The actual path, including the trait and the associated item, is stored
- /// separately. The `position` field represents the index of the associated
- /// item qualified with this Self type.
- ///
- /// ```text
- /// <Vec<T> as a::b::Trait>::AssociatedItem
- /// ^~~~~~ ~~~~~~~~~~~~~~^
- /// ty position = 3
- ///
- /// <Vec<T>>::AssociatedItem
- /// ^~~~~~ ^
- /// ty position = 0
- /// ```
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct QSelf {
- pub lt_token: Token![<],
- pub ty: Box<Type>,
- pub position: usize,
- pub as_token: Option<Token![as]>,
- pub gt_token: Token![>],
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- #[cfg(feature = "full")]
- use crate::expr;
- use crate::ext::IdentExt;
- use crate::parse::{Parse, ParseStream, Result};
-
- impl Parse for Path {
- fn parse(input: ParseStream) -> Result<Self> {
- Self::parse_helper(input, false)
- }
- }
-
- impl Parse for GenericArgument {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Lifetime) && !input.peek2(Token![+]) {
- return Ok(GenericArgument::Lifetime(input.parse()?));
- }
-
- if input.peek(Ident) && input.peek2(Token![=]) {
- return Ok(GenericArgument::Binding(input.parse()?));
- }
-
- #[cfg(feature = "full")]
- {
- if input.peek(Ident) && input.peek2(Token![:]) && !input.peek2(Token![::]) {
- return Ok(GenericArgument::Constraint(input.parse()?));
- }
-
- if input.peek(Lit) {
- let lit = input.parse()?;
- return Ok(GenericArgument::Const(Expr::Lit(lit)));
- }
-
- if input.peek(token::Brace) {
- let block = input.call(expr::parsing::expr_block)?;
- return Ok(GenericArgument::Const(Expr::Block(block)));
- }
- }
-
- input.parse().map(GenericArgument::Type)
- }
- }
-
- impl Parse for AngleBracketedGenericArguments {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(AngleBracketedGenericArguments {
- colon2_token: input.parse()?,
- lt_token: input.parse()?,
- args: {
- let mut args = Punctuated::new();
- loop {
- if input.peek(Token![>]) {
- break;
- }
- let value = input.parse()?;
- args.push_value(value);
- if input.peek(Token![>]) {
- break;
- }
- let punct = input.parse()?;
- args.push_punct(punct);
- }
- args
- },
- gt_token: input.parse()?,
- })
- }
- }
-
- impl Parse for ParenthesizedGenericArguments {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- Ok(ParenthesizedGenericArguments {
- paren_token: parenthesized!(content in input),
- inputs: content.parse_terminated(Type::parse)?,
- output: input.call(ReturnType::without_plus)?,
- })
- }
- }
-
- impl Parse for PathSegment {
- fn parse(input: ParseStream) -> Result<Self> {
- Self::parse_helper(input, false)
- }
- }
-
- impl PathSegment {
- fn parse_helper(input: ParseStream, expr_style: bool) -> Result<Self> {
- if input.peek(Token![super])
- || input.peek(Token![self])
- || input.peek(Token![crate])
- || input.peek(Token![extern])
- {
- let ident = input.call(Ident::parse_any)?;
- return Ok(PathSegment::from(ident));
- }
-
- let ident = if input.peek(Token![Self]) {
- input.call(Ident::parse_any)?
- } else {
- input.parse()?
- };
-
- if !expr_style && input.peek(Token![<]) && !input.peek(Token![<=])
- || input.peek(Token![::]) && input.peek3(Token![<])
- {
- Ok(PathSegment {
- ident,
- arguments: PathArguments::AngleBracketed(input.parse()?),
- })
- } else {
- Ok(PathSegment::from(ident))
- }
- }
- }
-
- impl Parse for Binding {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(Binding {
- ident: input.parse()?,
- eq_token: input.parse()?,
- ty: input.parse()?,
- })
- }
- }
-
- #[cfg(feature = "full")]
- impl Parse for Constraint {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(Constraint {
- ident: input.parse()?,
- colon_token: input.parse()?,
- bounds: {
- let mut bounds = Punctuated::new();
- loop {
- if input.peek(Token![,]) || input.peek(Token![>]) {
- break;
- }
- let value = input.parse()?;
- bounds.push_value(value);
- if !input.peek(Token![+]) {
- break;
- }
- let punct = input.parse()?;
- bounds.push_punct(punct);
- }
- bounds
- },
- })
- }
- }
-
- impl Path {
- /// Parse a `Path` containing no path arguments on any of its segments.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{Path, Result, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // A simplified single `use` statement like:
- /// //
- /// // use std::collections::HashMap;
- /// //
- /// // Note that generic parameters are not allowed in a `use` statement
- /// // so the following must not be accepted.
- /// //
- /// // use a::<b>::c;
- /// struct SingleUse {
- /// use_token: Token![use],
- /// path: Path,
- /// }
- ///
- /// impl Parse for SingleUse {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// Ok(SingleUse {
- /// use_token: input.parse()?,
- /// path: input.call(Path::parse_mod_style)?,
- /// })
- /// }
- /// }
- /// ```
- pub fn parse_mod_style(input: ParseStream) -> Result<Self> {
- Ok(Path {
- leading_colon: input.parse()?,
- segments: {
- let mut segments = Punctuated::new();
- loop {
- if !input.peek(Ident)
- && !input.peek(Token![super])
- && !input.peek(Token![self])
- && !input.peek(Token![Self])
- && !input.peek(Token![crate])
- && !input.peek(Token![extern])
- {
- break;
- }
- let ident = Ident::parse_any(input)?;
- segments.push_value(PathSegment::from(ident));
- if !input.peek(Token![::]) {
- break;
- }
- let punct = input.parse()?;
- segments.push_punct(punct);
- }
- if segments.is_empty() {
- return Err(input.error("expected path"));
- } else if segments.trailing_punct() {
- return Err(input.error("expected path segment"));
- }
- segments
- },
- })
- }
-
- /// Determines whether this is a path of length 1 equal to the given
- /// ident.
- ///
- /// For them to compare equal, it must be the case that:
- ///
- /// - the path has no leading colon,
- /// - the number of path segments is 1,
- /// - the first path segment has no angle bracketed or parenthesized
- /// path arguments, and
- /// - the ident of the first path segment is equal to the given one.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{Attribute, Error, Meta, NestedMeta, Result};
- /// # use std::iter::FromIterator;
- ///
- /// fn get_serde_meta_items(attr: &Attribute) -> Result<Vec<NestedMeta>> {
- /// if attr.path.is_ident("serde") {
- /// match attr.parse_meta()? {
- /// Meta::List(meta) => Ok(Vec::from_iter(meta.nested)),
- /// bad => Err(Error::new_spanned(bad, "unrecognized attribute")),
- /// }
- /// } else {
- /// Ok(Vec::new())
- /// }
- /// }
- /// ```
- pub fn is_ident<I: ?Sized>(&self, ident: &I) -> bool
- where
- Ident: PartialEq<I>,
- {
- match self.get_ident() {
- Some(id) => id == ident,
- None => false,
- }
- }
-
- /// If this path consists of a single ident, returns the ident.
- ///
- /// A path is considered an ident if:
- ///
- /// - the path has no leading colon,
- /// - the number of path segments is 1, and
- /// - the first path segment has no angle bracketed or parenthesized
- /// path arguments.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- pub fn get_ident(&self) -> Option<&Ident> {
- if self.leading_colon.is_none()
- && self.segments.len() == 1
- && self.segments[0].arguments.is_none()
- {
- Some(&self.segments[0].ident)
- } else {
- None
- }
- }
-
- fn parse_helper(input: ParseStream, expr_style: bool) -> Result<Self> {
- Ok(Path {
- leading_colon: input.parse()?,
- segments: {
- let mut segments = Punctuated::new();
- let value = PathSegment::parse_helper(input, expr_style)?;
- segments.push_value(value);
- while input.peek(Token![::]) {
- let punct: Token![::] = input.parse()?;
- segments.push_punct(punct);
- let value = PathSegment::parse_helper(input, expr_style)?;
- segments.push_value(value);
- }
- segments
- },
- })
- }
- }
-
- pub fn qpath(input: ParseStream, expr_style: bool) -> Result<(Option<QSelf>, Path)> {
- if input.peek(Token![<]) {
- let lt_token: Token![<] = input.parse()?;
- let this: Type = input.parse()?;
- let path = if input.peek(Token![as]) {
- let as_token: Token![as] = input.parse()?;
- let path: Path = input.parse()?;
- Some((as_token, path))
- } else {
- None
- };
- let gt_token: Token![>] = input.parse()?;
- let colon2_token: Token![::] = input.parse()?;
- let mut rest = Punctuated::new();
- loop {
- let path = PathSegment::parse_helper(input, expr_style)?;
- rest.push_value(path);
- if !input.peek(Token![::]) {
- break;
- }
- let punct: Token![::] = input.parse()?;
- rest.push_punct(punct);
- }
- let (position, as_token, path) = match path {
- Some((as_token, mut path)) => {
- let pos = path.segments.len();
- path.segments.push_punct(colon2_token);
- path.segments.extend(rest.into_pairs());
- (pos, Some(as_token), path)
- }
- None => {
- let path = Path {
- leading_colon: Some(colon2_token),
- segments: rest,
- };
- (0, None, path)
- }
- };
- let qself = QSelf {
- lt_token,
- ty: Box::new(this),
- position,
- as_token,
- gt_token,
- };
- Ok((Some(qself), path))
- } else {
- let path = Path::parse_helper(input, expr_style)?;
- Ok((None, path))
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::ToTokens;
-
- use crate::print::TokensOrDefault;
-
- impl ToTokens for Path {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.leading_colon.to_tokens(tokens);
- self.segments.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PathSegment {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.ident.to_tokens(tokens);
- self.arguments.to_tokens(tokens);
- }
- }
-
- impl ToTokens for PathArguments {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- PathArguments::None => {}
- PathArguments::AngleBracketed(arguments) => {
- arguments.to_tokens(tokens);
- }
- PathArguments::Parenthesized(arguments) => {
- arguments.to_tokens(tokens);
- }
- }
- }
- }
-
- impl ToTokens for GenericArgument {
- #[allow(clippy::match_same_arms)]
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- GenericArgument::Lifetime(lt) => lt.to_tokens(tokens),
- GenericArgument::Type(ty) => ty.to_tokens(tokens),
- GenericArgument::Binding(tb) => tb.to_tokens(tokens),
- GenericArgument::Constraint(tc) => tc.to_tokens(tokens),
- GenericArgument::Const(e) => match *e {
- Expr::Lit(_) => e.to_tokens(tokens),
-
- // NOTE: We should probably support parsing blocks with only
- // expressions in them without the full feature for const
- // generics.
- #[cfg(feature = "full")]
- Expr::Block(_) => e.to_tokens(tokens),
-
- // ERROR CORRECTION: Add braces to make sure that the
- // generated code is valid.
- _ => token::Brace::default().surround(tokens, |tokens| {
- e.to_tokens(tokens);
- }),
- },
- }
- }
- }
-
- impl ToTokens for AngleBracketedGenericArguments {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.colon2_token.to_tokens(tokens);
- self.lt_token.to_tokens(tokens);
-
- // Print lifetimes before types and consts, all before bindings,
- // regardless of their order in self.args.
- //
- // TODO: ordering rules for const arguments vs type arguments have
- // not been settled yet. https://github.com/rust-lang/rust/issues/44580
- let mut trailing_or_empty = true;
- for param in self.args.pairs() {
- match **param.value() {
- GenericArgument::Lifetime(_) => {
- param.to_tokens(tokens);
- trailing_or_empty = param.punct().is_some();
- }
- GenericArgument::Type(_)
- | GenericArgument::Binding(_)
- | GenericArgument::Constraint(_)
- | GenericArgument::Const(_) => {}
- }
- }
- for param in self.args.pairs() {
- match **param.value() {
- GenericArgument::Type(_) | GenericArgument::Const(_) => {
- if !trailing_or_empty {
- <Token![,]>::default().to_tokens(tokens);
- }
- param.to_tokens(tokens);
- trailing_or_empty = param.punct().is_some();
- }
- GenericArgument::Lifetime(_)
- | GenericArgument::Binding(_)
- | GenericArgument::Constraint(_) => {}
- }
- }
- for param in self.args.pairs() {
- match **param.value() {
- GenericArgument::Binding(_) | GenericArgument::Constraint(_) => {
- if !trailing_or_empty {
- <Token![,]>::default().to_tokens(tokens);
- trailing_or_empty = true;
- }
- param.to_tokens(tokens);
- }
- GenericArgument::Lifetime(_)
- | GenericArgument::Type(_)
- | GenericArgument::Const(_) => {}
- }
- }
-
- self.gt_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for Binding {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.ident.to_tokens(tokens);
- self.eq_token.to_tokens(tokens);
- self.ty.to_tokens(tokens);
- }
- }
-
- impl ToTokens for Constraint {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.ident.to_tokens(tokens);
- self.colon_token.to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ParenthesizedGenericArguments {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.paren_token.surround(tokens, |tokens| {
- self.inputs.to_tokens(tokens);
- });
- self.output.to_tokens(tokens);
- }
- }
-
- impl private {
- pub fn print_path(tokens: &mut TokenStream, qself: &Option<QSelf>, path: &Path) {
- let qself = match qself {
- Some(qself) => qself,
- None => {
- path.to_tokens(tokens);
- return;
- }
- };
- qself.lt_token.to_tokens(tokens);
- qself.ty.to_tokens(tokens);
-
- let pos = if qself.position > 0 && qself.position >= path.segments.len() {
- path.segments.len() - 1
- } else {
- qself.position
- };
- let mut segments = path.segments.pairs();
- if pos > 0 {
- TokensOrDefault(&qself.as_token).to_tokens(tokens);
- path.leading_colon.to_tokens(tokens);
- for (i, segment) in segments.by_ref().take(pos).enumerate() {
- if i + 1 == pos {
- segment.value().to_tokens(tokens);
- qself.gt_token.to_tokens(tokens);
- segment.punct().to_tokens(tokens);
- } else {
- segment.to_tokens(tokens);
- }
- }
- } else {
- qself.gt_token.to_tokens(tokens);
- path.leading_colon.to_tokens(tokens);
- }
- for segment in segments {
- segment.to_tokens(tokens);
- }
- }
- }
-}
diff --git a/syn/src/print.rs b/syn/src/print.rs
deleted file mode 100644
index da4e07e..0000000
--- a/syn/src/print.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-use proc_macro2::TokenStream;
-use quote::ToTokens;
-
-pub struct TokensOrDefault<'a, T: 'a>(pub &'a Option<T>);
-
-impl<'a, T> ToTokens for TokensOrDefault<'a, T>
-where
- T: ToTokens + Default,
-{
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self.0 {
- Some(t) => t.to_tokens(tokens),
- None => T::default().to_tokens(tokens),
- }
- }
-}
diff --git a/syn/src/punctuated.rs b/syn/src/punctuated.rs
deleted file mode 100644
index 38c7bf4..0000000
--- a/syn/src/punctuated.rs
+++ /dev/null
@@ -1,918 +0,0 @@
-//! A punctuated sequence of syntax tree nodes separated by punctuation.
-//!
-//! Lots of things in Rust are punctuated sequences.
-//!
-//! - The fields of a struct are `Punctuated<Field, Token![,]>`.
-//! - The segments of a path are `Punctuated<PathSegment, Token![::]>`.
-//! - The bounds on a generic parameter are `Punctuated<TypeParamBound,
-//! Token![+]>`.
-//! - The arguments to a function call are `Punctuated<Expr, Token![,]>`.
-//!
-//! This module provides a common representation for these punctuated sequences
-//! in the form of the [`Punctuated<T, P>`] type. We store a vector of pairs of
-//! syntax tree node + punctuation, where every node in the sequence is followed
-//! by punctuation except for possibly the final one.
-//!
-//! [`Punctuated<T, P>`]: struct.Punctuated.html
-//!
-//! ```text
-//! a_function_call(arg1, arg2, arg3);
-//! ~~~~^ ~~~~^ ~~~~
-//! ```
-
-#[cfg(feature = "extra-traits")]
-use std::fmt::{self, Debug};
-#[cfg(any(feature = "full", feature = "derive"))]
-use std::iter;
-use std::iter::FromIterator;
-use std::ops::{Index, IndexMut};
-use std::option;
-use std::slice;
-use std::vec;
-
-#[cfg(feature = "parsing")]
-use crate::parse::{Parse, ParseStream, Result};
-#[cfg(feature = "parsing")]
-use crate::token::Token;
-
-/// A punctuated sequence of syntax tree nodes of type `T` separated by
-/// punctuation of type `P`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-#[cfg_attr(feature = "extra-traits", derive(Eq, PartialEq, Hash))]
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-pub struct Punctuated<T, P> {
- inner: Vec<(T, P)>,
- last: Option<Box<T>>,
-}
-
-impl<T, P> Punctuated<T, P> {
- /// Creates an empty punctuated sequence.
- pub fn new() -> Punctuated<T, P> {
- Punctuated {
- inner: Vec::new(),
- last: None,
- }
- }
-
- /// Determines whether this punctuated sequence is empty, meaning it
- /// contains no syntax tree nodes or punctuation.
- pub fn is_empty(&self) -> bool {
- self.inner.len() == 0 && self.last.is_none()
- }
-
- /// Returns the number of syntax tree nodes in this punctuated sequence.
- ///
- /// This is the number of nodes of type `T`, not counting the punctuation of
- /// type `P`.
- pub fn len(&self) -> usize {
- self.inner.len() + if self.last.is_some() { 1 } else { 0 }
- }
-
- /// Borrows the first element in this sequence.
- pub fn first(&self) -> Option<&T> {
- self.iter().next()
- }
-
- /// Borrows the last element in this sequence.
- pub fn last(&self) -> Option<&T> {
- if self.last.is_some() {
- self.last.as_ref().map(Box::as_ref)
- } else {
- self.inner.last().map(|pair| &pair.0)
- }
- }
-
- /// Mutably borrows the last element in this sequence.
- pub fn last_mut(&mut self) -> Option<&mut T> {
- if self.last.is_some() {
- self.last.as_mut().map(Box::as_mut)
- } else {
- self.inner.last_mut().map(|pair| &mut pair.0)
- }
- }
-
- /// Returns an iterator over borrowed syntax tree nodes of type `&T`.
- pub fn iter(&self) -> Iter<T> {
- Iter {
- inner: Box::new(PrivateIter {
- inner: self.inner.iter(),
- last: self.last.as_ref().map(Box::as_ref).into_iter(),
- }),
- }
- }
-
- /// Returns an iterator over mutably borrowed syntax tree nodes of type
- /// `&mut T`.
- pub fn iter_mut(&mut self) -> IterMut<T> {
- IterMut {
- inner: Box::new(PrivateIterMut {
- inner: self.inner.iter_mut(),
- last: self.last.as_mut().map(Box::as_mut).into_iter(),
- }),
- }
- }
-
- /// Returns an iterator over the contents of this sequence as borrowed
- /// punctuated pairs.
- pub fn pairs(&self) -> Pairs<T, P> {
- Pairs {
- inner: self.inner.iter(),
- last: self.last.as_ref().map(Box::as_ref).into_iter(),
- }
- }
-
- /// Returns an iterator over the contents of this sequence as mutably
- /// borrowed punctuated pairs.
- pub fn pairs_mut(&mut self) -> PairsMut<T, P> {
- PairsMut {
- inner: self.inner.iter_mut(),
- last: self.last.as_mut().map(Box::as_mut).into_iter(),
- }
- }
-
- /// Returns an iterator over the contents of this sequence as owned
- /// punctuated pairs.
- pub fn into_pairs(self) -> IntoPairs<T, P> {
- IntoPairs {
- inner: self.inner.into_iter(),
- last: self.last.map(|t| *t).into_iter(),
- }
- }
-
- /// Appends a syntax tree node onto the end of this punctuated sequence. The
- /// sequence must previously have a trailing punctuation.
- ///
- /// Use [`push`] instead if the punctuated sequence may or may not already
- /// have trailing punctuation.
- ///
- /// [`push`]: Punctuated::push
- ///
- /// # Panics
- ///
- /// Panics if the sequence does not already have a trailing punctuation when
- /// this method is called.
- pub fn push_value(&mut self, value: T) {
- assert!(self.empty_or_trailing());
- self.last = Some(Box::new(value));
- }
-
- /// Appends a trailing punctuation onto the end of this punctuated sequence.
- /// The sequence must be non-empty and must not already have trailing
- /// punctuation.
- ///
- /// # Panics
- ///
- /// Panics if the sequence is empty or already has a trailing punctuation.
- pub fn push_punct(&mut self, punctuation: P) {
- assert!(self.last.is_some());
- let last = self.last.take().unwrap();
- self.inner.push((*last, punctuation));
- }
-
- /// Removes the last punctuated pair from this sequence, or `None` if the
- /// sequence is empty.
- pub fn pop(&mut self) -> Option<Pair<T, P>> {
- if self.last.is_some() {
- self.last.take().map(|t| Pair::End(*t))
- } else {
- self.inner.pop().map(|(t, d)| Pair::Punctuated(t, d))
- }
- }
-
- /// Determines whether this punctuated sequence ends with a trailing
- /// punctuation.
- pub fn trailing_punct(&self) -> bool {
- self.last.is_none() && !self.is_empty()
- }
-
- /// Returns true if either this `Punctuated` is empty, or it has a trailing
- /// punctuation.
- ///
- /// Equivalent to `punctuated.is_empty() || punctuated.trailing_punct()`.
- pub fn empty_or_trailing(&self) -> bool {
- self.last.is_none()
- }
-
- /// Appends a syntax tree node onto the end of this punctuated sequence.
- ///
- /// If there is not a trailing punctuation in this sequence when this method
- /// is called, the default value of punctuation type `P` is inserted before
- /// the given value of type `T`.
- pub fn push(&mut self, value: T)
- where
- P: Default,
- {
- if !self.empty_or_trailing() {
- self.push_punct(Default::default());
- }
- self.push_value(value);
- }
-
- /// Inserts an element at position `index`.
- ///
- /// # Panics
- ///
- /// Panics if `index` is greater than the number of elements previously in
- /// this punctuated sequence.
- pub fn insert(&mut self, index: usize, value: T)
- where
- P: Default,
- {
- assert!(index <= self.len());
-
- if index == self.len() {
- self.push(value);
- } else {
- self.inner.insert(index, (value, Default::default()));
- }
- }
-
- /// Parses zero or more occurrences of `T` separated by punctuation of type
- /// `P`, with optional trailing punctuation.
- ///
- /// Parsing continues until the end of this parse stream. The entire content
- /// of this parse stream must consist of `T` and `P`.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_terminated(input: ParseStream) -> Result<Self>
- where
- T: Parse,
- P: Parse,
- {
- Self::parse_terminated_with(input, T::parse)
- }
-
- /// Parses zero or more occurrences of `T` using the given parse function,
- /// separated by punctuation of type `P`, with optional trailing
- /// punctuation.
- ///
- /// Like [`parse_terminated`], the entire content of this stream is expected
- /// to be parsed.
- ///
- /// [`parse_terminated`]: Punctuated::parse_terminated
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_terminated_with(
- input: ParseStream,
- parser: fn(ParseStream) -> Result<T>,
- ) -> Result<Self>
- where
- P: Parse,
- {
- let mut punctuated = Punctuated::new();
-
- loop {
- if input.is_empty() {
- break;
- }
- let value = parser(input)?;
- punctuated.push_value(value);
- if input.is_empty() {
- break;
- }
- let punct = input.parse()?;
- punctuated.push_punct(punct);
- }
-
- Ok(punctuated)
- }
-
- /// Parses one or more occurrences of `T` separated by punctuation of type
- /// `P`, not accepting trailing punctuation.
- ///
- /// Parsing continues as long as punctuation `P` is present at the head of
- /// the stream. This method returns upon parsing a `T` and observing that it
- /// is not followed by a `P`, even if there are remaining tokens in the
- /// stream.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_separated_nonempty(input: ParseStream) -> Result<Self>
- where
- T: Parse,
- P: Token + Parse,
- {
- Self::parse_separated_nonempty_with(input, T::parse)
- }
-
- /// Parses one or more occurrences of `T` using the given parse function,
- /// separated by punctuation of type `P`, not accepting trailing
- /// punctuation.
- ///
- /// Like [`parse_separated_nonempty`], may complete early without parsing
- /// the entire content of this stream.
- ///
- /// [`parse_separated_nonempty`]: Punctuated::parse_separated_nonempty
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- #[cfg(feature = "parsing")]
- pub fn parse_separated_nonempty_with(
- input: ParseStream,
- parser: fn(ParseStream) -> Result<T>,
- ) -> Result<Self>
- where
- P: Token + Parse,
- {
- let mut punctuated = Punctuated::new();
-
- loop {
- let value = parser(input)?;
- punctuated.push_value(value);
- if !P::peek(input.cursor()) {
- break;
- }
- let punct = input.parse()?;
- punctuated.push_punct(punct);
- }
-
- Ok(punctuated)
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl<T: Debug, P: Debug> Debug for Punctuated<T, P> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let mut list = f.debug_list();
- for (t, p) in &self.inner {
- list.entry(t);
- list.entry(p);
- }
- if let Some(last) = &self.last {
- list.entry(last);
- }
- list.finish()
- }
-}
-
-impl<T, P> FromIterator<T> for Punctuated<T, P>
-where
- P: Default,
-{
- fn from_iter<I: IntoIterator<Item = T>>(i: I) -> Self {
- let mut ret = Punctuated::new();
- ret.extend(i);
- ret
- }
-}
-
-impl<T, P> Extend<T> for Punctuated<T, P>
-where
- P: Default,
-{
- fn extend<I: IntoIterator<Item = T>>(&mut self, i: I) {
- for value in i {
- self.push(value);
- }
- }
-}
-
-impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P> {
- fn from_iter<I: IntoIterator<Item = Pair<T, P>>>(i: I) -> Self {
- let mut ret = Punctuated::new();
- ret.extend(i);
- ret
- }
-}
-
-impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P> {
- fn extend<I: IntoIterator<Item = Pair<T, P>>>(&mut self, i: I) {
- assert!(self.empty_or_trailing());
- let mut nomore = false;
- for pair in i {
- if nomore {
- panic!("Punctuated extended with items after a Pair::End");
- }
- match pair {
- Pair::Punctuated(a, b) => self.inner.push((a, b)),
- Pair::End(a) => {
- self.last = Some(Box::new(a));
- nomore = true;
- }
- }
- }
- }
-}
-
-impl<T, P> IntoIterator for Punctuated<T, P> {
- type Item = T;
- type IntoIter = IntoIter<T>;
-
- fn into_iter(self) -> Self::IntoIter {
- let mut elements = Vec::with_capacity(self.len());
- elements.extend(self.inner.into_iter().map(|pair| pair.0));
- elements.extend(self.last.map(|t| *t));
-
- IntoIter {
- inner: elements.into_iter(),
- }
- }
-}
-
-impl<'a, T, P> IntoIterator for &'a Punctuated<T, P> {
- type Item = &'a T;
- type IntoIter = Iter<'a, T>;
-
- fn into_iter(self) -> Self::IntoIter {
- Punctuated::iter(self)
- }
-}
-
-impl<'a, T, P> IntoIterator for &'a mut Punctuated<T, P> {
- type Item = &'a mut T;
- type IntoIter = IterMut<'a, T>;
-
- fn into_iter(self) -> Self::IntoIter {
- Punctuated::iter_mut(self)
- }
-}
-
-impl<T, P> Default for Punctuated<T, P> {
- fn default() -> Self {
- Punctuated::new()
- }
-}
-
-/// An iterator over borrowed pairs of type `Pair<&T, &P>`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-pub struct Pairs<'a, T: 'a, P: 'a> {
- inner: slice::Iter<'a, (T, P)>,
- last: option::IntoIter<&'a T>,
-}
-
-impl<'a, T, P> Iterator for Pairs<'a, T, P> {
- type Item = Pair<&'a T, &'a P>;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner
- .next()
- .map(|(t, p)| Pair::Punctuated(t, p))
- .or_else(|| self.last.next().map(Pair::End))
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.len(), Some(self.len()))
- }
-}
-
-impl<'a, T, P> DoubleEndedIterator for Pairs<'a, T, P> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.last
- .next()
- .map(Pair::End)
- .or_else(|| self.inner.next_back().map(|(t, p)| Pair::Punctuated(t, p)))
- }
-}
-
-impl<'a, T, P> ExactSizeIterator for Pairs<'a, T, P> {
- fn len(&self) -> usize {
- self.inner.len() + self.last.len()
- }
-}
-
-// No Clone bound on T or P.
-impl<'a, T, P> Clone for Pairs<'a, T, P> {
- fn clone(&self) -> Self {
- Pairs {
- inner: self.inner.clone(),
- last: self.last.clone(),
- }
- }
-}
-
-/// An iterator over mutably borrowed pairs of type `Pair<&mut T, &mut P>`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-pub struct PairsMut<'a, T: 'a, P: 'a> {
- inner: slice::IterMut<'a, (T, P)>,
- last: option::IntoIter<&'a mut T>,
-}
-
-impl<'a, T, P> Iterator for PairsMut<'a, T, P> {
- type Item = Pair<&'a mut T, &'a mut P>;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner
- .next()
- .map(|(t, p)| Pair::Punctuated(t, p))
- .or_else(|| self.last.next().map(Pair::End))
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.len(), Some(self.len()))
- }
-}
-
-impl<'a, T, P> DoubleEndedIterator for PairsMut<'a, T, P> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.last
- .next()
- .map(Pair::End)
- .or_else(|| self.inner.next_back().map(|(t, p)| Pair::Punctuated(t, p)))
- }
-}
-
-impl<'a, T, P> ExactSizeIterator for PairsMut<'a, T, P> {
- fn len(&self) -> usize {
- self.inner.len() + self.last.len()
- }
-}
-
-/// An iterator over owned pairs of type `Pair<T, P>`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-#[derive(Clone)]
-pub struct IntoPairs<T, P> {
- inner: vec::IntoIter<(T, P)>,
- last: option::IntoIter<T>,
-}
-
-impl<T, P> Iterator for IntoPairs<T, P> {
- type Item = Pair<T, P>;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner
- .next()
- .map(|(t, p)| Pair::Punctuated(t, p))
- .or_else(|| self.last.next().map(Pair::End))
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.len(), Some(self.len()))
- }
-}
-
-impl<T, P> DoubleEndedIterator for IntoPairs<T, P> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.last
- .next()
- .map(Pair::End)
- .or_else(|| self.inner.next_back().map(|(t, p)| Pair::Punctuated(t, p)))
- }
-}
-
-impl<T, P> ExactSizeIterator for IntoPairs<T, P> {
- fn len(&self) -> usize {
- self.inner.len() + self.last.len()
- }
-}
-
-/// An iterator over owned values of type `T`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-#[derive(Clone)]
-pub struct IntoIter<T> {
- inner: vec::IntoIter<T>,
-}
-
-impl<T> Iterator for IntoIter<T> {
- type Item = T;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner.next()
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.len(), Some(self.len()))
- }
-}
-
-impl<T> DoubleEndedIterator for IntoIter<T> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.inner.next_back()
- }
-}
-
-impl<T> ExactSizeIterator for IntoIter<T> {
- fn len(&self) -> usize {
- self.inner.len()
- }
-}
-
-/// An iterator over borrowed values of type `&T`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-pub struct Iter<'a, T: 'a> {
- // The `Item = &'a T` needs to be specified to support rustc 1.31 and older.
- // On modern compilers we would be able to write just IterTrait<'a, T> where
- // Item can be inferred unambiguously from the supertrait.
- inner: Box<dyn IterTrait<'a, T, Item = &'a T> + 'a>,
-}
-
-trait IterTrait<'a, T: 'a>:
- DoubleEndedIterator<Item = &'a T> + ExactSizeIterator<Item = &'a T>
-{
- fn clone_box(&self) -> Box<dyn IterTrait<'a, T, Item = &'a T> + 'a>;
-}
-
-struct PrivateIter<'a, T: 'a, P: 'a> {
- inner: slice::Iter<'a, (T, P)>,
- last: option::IntoIter<&'a T>,
-}
-
-#[cfg(any(feature = "full", feature = "derive"))]
-pub(crate) fn empty_punctuated_iter<'a, T>() -> Iter<'a, T> {
- Iter {
- inner: Box::new(iter::empty()),
- }
-}
-
-// No Clone bound on T.
-impl<'a, T> Clone for Iter<'a, T> {
- fn clone(&self) -> Self {
- Iter {
- inner: self.inner.clone_box(),
- }
- }
-}
-
-impl<'a, T> Iterator for Iter<'a, T> {
- type Item = &'a T;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner.next()
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.len(), Some(self.len()))
- }
-}
-
-impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.inner.next_back()
- }
-}
-
-impl<'a, T> ExactSizeIterator for Iter<'a, T> {
- fn len(&self) -> usize {
- self.inner.len()
- }
-}
-
-impl<'a, T, P> Iterator for PrivateIter<'a, T, P> {
- type Item = &'a T;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner
- .next()
- .map(|pair| &pair.0)
- .or_else(|| self.last.next())
- }
-}
-
-impl<'a, T, P> DoubleEndedIterator for PrivateIter<'a, T, P> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.last
- .next()
- .or_else(|| self.inner.next_back().map(|pair| &pair.0))
- }
-}
-
-impl<'a, T, P> ExactSizeIterator for PrivateIter<'a, T, P> {
- fn len(&self) -> usize {
- self.inner.len() + self.last.len()
- }
-}
-
-// No Clone bound on T or P.
-impl<'a, T, P> Clone for PrivateIter<'a, T, P> {
- fn clone(&self) -> Self {
- PrivateIter {
- inner: self.inner.clone(),
- last: self.last.clone(),
- }
- }
-}
-
-impl<'a, T: 'a, I: 'a> IterTrait<'a, T> for I
-where
- I: DoubleEndedIterator<Item = &'a T> + ExactSizeIterator<Item = &'a T> + Clone,
-{
- fn clone_box(&self) -> Box<dyn IterTrait<'a, T, Item = &'a T> + 'a> {
- Box::new(self.clone())
- }
-}
-
-/// An iterator over mutably borrowed values of type `&mut T`.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-pub struct IterMut<'a, T: 'a> {
- inner: Box<dyn IterMutTrait<'a, T, Item = &'a mut T> + 'a>,
-}
-
-trait IterMutTrait<'a, T: 'a>:
- DoubleEndedIterator<Item = &'a mut T> + ExactSizeIterator<Item = &'a mut T>
-{
-}
-
-struct PrivateIterMut<'a, T: 'a, P: 'a> {
- inner: slice::IterMut<'a, (T, P)>,
- last: option::IntoIter<&'a mut T>,
-}
-
-#[cfg(any(feature = "full", feature = "derive"))]
-pub(crate) fn empty_punctuated_iter_mut<'a, T>() -> IterMut<'a, T> {
- IterMut {
- inner: Box::new(iter::empty()),
- }
-}
-
-impl<'a, T> Iterator for IterMut<'a, T> {
- type Item = &'a mut T;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner.next()
- }
-
- fn size_hint(&self) -> (usize, Option<usize>) {
- (self.len(), Some(self.len()))
- }
-}
-
-impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.inner.next_back()
- }
-}
-
-impl<'a, T> ExactSizeIterator for IterMut<'a, T> {
- fn len(&self) -> usize {
- self.inner.len()
- }
-}
-
-impl<'a, T, P> Iterator for PrivateIterMut<'a, T, P> {
- type Item = &'a mut T;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.inner
- .next()
- .map(|pair| &mut pair.0)
- .or_else(|| self.last.next())
- }
-}
-
-impl<'a, T, P> DoubleEndedIterator for PrivateIterMut<'a, T, P> {
- fn next_back(&mut self) -> Option<Self::Item> {
- self.last
- .next()
- .or_else(|| self.inner.next_back().map(|pair| &mut pair.0))
- }
-}
-
-impl<'a, T, P> ExactSizeIterator for PrivateIterMut<'a, T, P> {
- fn len(&self) -> usize {
- self.inner.len() + self.last.len()
- }
-}
-
-impl<'a, T: 'a, I: 'a> IterMutTrait<'a, T> for I where
- I: DoubleEndedIterator<Item = &'a mut T> + ExactSizeIterator<Item = &'a mut T>
-{
-}
-
-/// A single syntax tree node of type `T` followed by its trailing punctuation
-/// of type `P` if any.
-///
-/// Refer to the [module documentation] for details about punctuated sequences.
-///
-/// [module documentation]: self
-#[cfg_attr(feature = "clone-impls", derive(Clone))]
-pub enum Pair<T, P> {
- Punctuated(T, P),
- End(T),
-}
-
-impl<T, P> Pair<T, P> {
- /// Extracts the syntax tree node from this punctuated pair, discarding the
- /// following punctuation.
- pub fn into_value(self) -> T {
- match self {
- Pair::Punctuated(t, _) | Pair::End(t) => t,
- }
- }
-
- /// Borrows the syntax tree node from this punctuated pair.
- pub fn value(&self) -> &T {
- match self {
- Pair::Punctuated(t, _) | Pair::End(t) => t,
- }
- }
-
- /// Mutably borrows the syntax tree node from this punctuated pair.
- pub fn value_mut(&mut self) -> &mut T {
- match self {
- Pair::Punctuated(t, _) | Pair::End(t) => t,
- }
- }
-
- /// Borrows the punctuation from this punctuated pair, unless this pair is
- /// the final one and there is no trailing punctuation.
- pub fn punct(&self) -> Option<&P> {
- match self {
- Pair::Punctuated(_, d) => Some(d),
- Pair::End(_) => None,
- }
- }
-
- /// Creates a punctuated pair out of a syntax tree node and an optional
- /// following punctuation.
- pub fn new(t: T, d: Option<P>) -> Self {
- match d {
- Some(d) => Pair::Punctuated(t, d),
- None => Pair::End(t),
- }
- }
-
- /// Produces this punctuated pair as a tuple of syntax tree node and
- /// optional following punctuation.
- pub fn into_tuple(self) -> (T, Option<P>) {
- match self {
- Pair::Punctuated(t, d) => (t, Some(d)),
- Pair::End(t) => (t, None),
- }
- }
-}
-
-impl<T, P> Index<usize> for Punctuated<T, P> {
- type Output = T;
-
- fn index(&self, index: usize) -> &Self::Output {
- if index == self.len() - 1 {
- match &self.last {
- Some(t) => t,
- None => &self.inner[index].0,
- }
- } else {
- &self.inner[index].0
- }
- }
-}
-
-impl<T, P> IndexMut<usize> for Punctuated<T, P> {
- fn index_mut(&mut self, index: usize) -> &mut Self::Output {
- if index == self.len() - 1 {
- match &mut self.last {
- Some(t) => t,
- None => &mut self.inner[index].0,
- }
- } else {
- &mut self.inner[index].0
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- impl<T, P> ToTokens for Punctuated<T, P>
- where
- T: ToTokens,
- P: ToTokens,
- {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.pairs())
- }
- }
-
- impl<T, P> ToTokens for Pair<T, P>
- where
- T: ToTokens,
- P: ToTokens,
- {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- Pair::Punctuated(a, b) => {
- a.to_tokens(tokens);
- b.to_tokens(tokens);
- }
- Pair::End(a) => a.to_tokens(tokens),
- }
- }
- }
-}
diff --git a/syn/src/sealed.rs b/syn/src/sealed.rs
deleted file mode 100644
index 0b11bc9..0000000
--- a/syn/src/sealed.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-#[cfg(feature = "parsing")]
-pub mod lookahead {
- pub trait Sealed: Copy {}
-}
diff --git a/syn/src/span.rs b/syn/src/span.rs
deleted file mode 100644
index 27a7fe8..0000000
--- a/syn/src/span.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-use proc_macro2::Span;
-
-pub trait IntoSpans<S> {
- fn into_spans(self) -> S;
-}
-
-impl IntoSpans<[Span; 1]> for Span {
- fn into_spans(self) -> [Span; 1] {
- [self]
- }
-}
-
-impl IntoSpans<[Span; 2]> for Span {
- fn into_spans(self) -> [Span; 2] {
- [self, self]
- }
-}
-
-impl IntoSpans<[Span; 3]> for Span {
- fn into_spans(self) -> [Span; 3] {
- [self, self, self]
- }
-}
-
-impl IntoSpans<[Span; 1]> for [Span; 1] {
- fn into_spans(self) -> [Span; 1] {
- self
- }
-}
-
-impl IntoSpans<[Span; 2]> for [Span; 2] {
- fn into_spans(self) -> [Span; 2] {
- self
- }
-}
-
-impl IntoSpans<[Span; 3]> for [Span; 3] {
- fn into_spans(self) -> [Span; 3] {
- self
- }
-}
-
-#[cfg(feature = "parsing")]
-pub trait FromSpans: Sized {
- fn from_spans(spans: &[Span]) -> Self;
-}
-
-#[cfg(feature = "parsing")]
-impl FromSpans for [Span; 1] {
- fn from_spans(spans: &[Span]) -> Self {
- [spans[0]]
- }
-}
-
-#[cfg(feature = "parsing")]
-impl FromSpans for [Span; 2] {
- fn from_spans(spans: &[Span]) -> Self {
- [spans[0], spans[1]]
- }
-}
-
-#[cfg(feature = "parsing")]
-impl FromSpans for [Span; 3] {
- fn from_spans(spans: &[Span]) -> Self {
- [spans[0], spans[1], spans[2]]
- }
-}
diff --git a/syn/src/spanned.rs b/syn/src/spanned.rs
deleted file mode 100644
index 71ffe26..0000000
--- a/syn/src/spanned.rs
+++ /dev/null
@@ -1,114 +0,0 @@
-//! A trait that can provide the `Span` of the complete contents of a syntax
-//! tree node.
-//!
-//! *This module is available if Syn is built with both the `"parsing"` and
-//! `"printing"` features.*
-//!
-//! <br>
-//!
-//! # Example
-//!
-//! Suppose in a procedural macro we have a [`Type`] that we want to assert
-//! implements the [`Sync`] trait. Maybe this is the type of one of the fields
-//! of a struct for which we are deriving a trait implementation, and we need to
-//! be able to pass a reference to one of those fields across threads.
-//!
-//! [`Type`]: ../enum.Type.html
-//! [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
-//!
-//! If the field type does *not* implement `Sync` as required, we want the
-//! compiler to report an error pointing out exactly which type it was.
-//!
-//! The following macro code takes a variable `ty` of type `Type` and produces a
-//! static assertion that `Sync` is implemented for that type.
-//!
-//! ```
-//! # extern crate proc_macro;
-//! #
-//! use proc_macro::TokenStream;
-//! use proc_macro2::Span;
-//! use quote::quote_spanned;
-//! use syn::Type;
-//! use syn::spanned::Spanned;
-//!
-//! # const IGNORE_TOKENS: &str = stringify! {
-//! #[proc_macro_derive(MyMacro)]
-//! # };
-//! pub fn my_macro(input: TokenStream) -> TokenStream {
-//! # let ty = get_a_type();
-//! /* ... */
-//!
-//! let assert_sync = quote_spanned! {ty.span()=>
-//! struct _AssertSync where #ty: Sync;
-//! };
-//!
-//! /* ... */
-//! # input
-//! }
-//! #
-//! # fn get_a_type() -> Type {
-//! # unimplemented!()
-//! # }
-//! ```
-//!
-//! By inserting this `assert_sync` fragment into the output code generated by
-//! our macro, the user's code will fail to compile if `ty` does not implement
-//! `Sync`. The errors they would see look like the following.
-//!
-//! ```text
-//! error[E0277]: the trait bound `*const i32: std::marker::Sync` is not satisfied
-//! --> src/main.rs:10:21
-//! |
-//! 10 | bad_field: *const i32,
-//! | ^^^^^^^^^^ `*const i32` cannot be shared between threads safely
-//! ```
-//!
-//! In this technique, using the `Type`'s span for the error message makes the
-//! error appear in the correct place underlining the right type.
-//!
-//! <br>
-//!
-//! # Limitations
-//!
-//! The underlying [`proc_macro::Span::join`] method is nightly-only. When
-//! called from within a procedural macro in a nightly compiler, `Spanned` will
-//! use `join` to produce the intended span. When not using a nightly compiler,
-//! only the span of the *first token* of the syntax tree node is returned.
-//!
-//! In the common case of wanting to use the joined span as the span of a
-//! `syn::Error`, consider instead using [`syn::Error::new_spanned`] which is
-//! able to span the error correctly under the complete syntax tree node without
-//! needing the unstable `join`.
-//!
-//! [`syn::Error::new_spanned`]: crate::Error::new_spanned
-
-use proc_macro2::Span;
-use quote::spanned::Spanned as ToTokens;
-
-/// A trait that can provide the `Span` of the complete contents of a syntax
-/// tree node.
-///
-/// This trait is automatically implemented for all types that implement
-/// [`ToTokens`] from the `quote` crate, as well as for `Span` itself.
-///
-/// [`ToTokens`]: quote::ToTokens
-///
-/// See the [module documentation] for an example.
-///
-/// [module documentation]: self
-///
-/// *This trait is available if Syn is built with both the `"parsing"` and
-/// `"printing"` features.*
-pub trait Spanned {
- /// Returns a `Span` covering the complete contents of this syntax tree
- /// node, or [`Span::call_site()`] if this node is empty.
- ///
- /// [`Span::call_site()`]: proc_macro2::Span::call_site
- fn span(&self) -> Span;
-}
-
-impl<T: ?Sized + ToTokens> Spanned for T {
- fn span(&self) -> Span {
- self.__span()
- }
-}
diff --git a/syn/src/stmt.rs b/syn/src/stmt.rs
deleted file mode 100644
index acee5a3..0000000
--- a/syn/src/stmt.rs
+++ /dev/null
@@ -1,333 +0,0 @@
-use super::*;
-
-ast_struct! {
- /// A braced block containing Rust statements.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct Block {
- pub brace_token: token::Brace,
- /// Statements in a block
- pub stmts: Vec<Stmt>,
- }
-}
-
-ast_enum! {
- /// A statement, usually ending in a semicolon.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub enum Stmt {
- /// A local (let) binding.
- Local(Local),
-
- /// An item definition.
- Item(Item),
-
- /// Expr without trailing semicolon.
- Expr(Expr),
-
- /// Expression with trailing semicolon.
- Semi(Expr, Token![;]),
- }
-}
-
-ast_struct! {
- /// A local `let` binding: `let x: u64 = s.parse()?`.
- ///
- /// *This type is available if Syn is built with the `"full"` feature.*
- pub struct Local {
- pub attrs: Vec<Attribute>,
- pub let_token: Token![let],
- pub pat: Pat,
- pub init: Option<(Token![=], Box<Expr>)>,
- pub semi_token: Token![;],
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::parse::discouraged::Speculative;
- use crate::parse::{Parse, ParseStream, Result};
- use crate::punctuated::Punctuated;
- use proc_macro2::TokenStream;
-
- impl Block {
- /// Parse the body of a block as zero or more statements, possibly
- /// including one trailing expression.
- ///
- /// *This function is available if Syn is built with the `"parsing"`
- /// feature.*
- ///
- /// # Example
- ///
- /// ```
- /// use syn::{braced, token, Attribute, Block, Ident, Result, Stmt, Token};
- /// use syn::parse::{Parse, ParseStream};
- ///
- /// // Parse a function with no generics or parameter list.
- /// //
- /// // fn playground {
- /// // let mut x = 1;
- /// // x += 1;
- /// // println!("{}", x);
- /// // }
- /// struct MiniFunction {
- /// attrs: Vec<Attribute>,
- /// fn_token: Token![fn],
- /// name: Ident,
- /// brace_token: token::Brace,
- /// stmts: Vec<Stmt>,
- /// }
- ///
- /// impl Parse for MiniFunction {
- /// fn parse(input: ParseStream) -> Result<Self> {
- /// let outer_attrs = input.call(Attribute::parse_outer)?;
- /// let fn_token: Token![fn] = input.parse()?;
- /// let name: Ident = input.parse()?;
- ///
- /// let content;
- /// let brace_token = braced!(content in input);
- /// let inner_attrs = content.call(Attribute::parse_inner)?;
- /// let stmts = content.call(Block::parse_within)?;
- ///
- /// Ok(MiniFunction {
- /// attrs: {
- /// let mut attrs = outer_attrs;
- /// attrs.extend(inner_attrs);
- /// attrs
- /// },
- /// fn_token,
- /// name,
- /// brace_token,
- /// stmts,
- /// })
- /// }
- /// }
- /// ```
- pub fn parse_within(input: ParseStream) -> Result<Vec<Stmt>> {
- let mut stmts = Vec::new();
- loop {
- while let Some(semi) = input.parse::<Option<Token![;]>>()? {
- stmts.push(Stmt::Semi(Expr::Verbatim(TokenStream::new()), semi));
- }
- if input.is_empty() {
- break;
- }
- let s = parse_stmt(input, true)?;
- let requires_semicolon = if let Stmt::Expr(s) = &s {
- expr::requires_terminator(s)
- } else {
- false
- };
- stmts.push(s);
- if input.is_empty() {
- break;
- } else if requires_semicolon {
- return Err(input.error("unexpected token"));
- }
- }
- Ok(stmts)
- }
- }
-
- impl Parse for Block {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- Ok(Block {
- brace_token: braced!(content in input),
- stmts: content.call(Block::parse_within)?,
- })
- }
- }
-
- impl Parse for Stmt {
- fn parse(input: ParseStream) -> Result<Self> {
- parse_stmt(input, false)
- }
- }
-
- fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> {
- let mut attrs = input.call(Attribute::parse_outer)?;
-
- // brace-style macros; paren and bracket macros get parsed as
- // expression statements.
- let ahead = input.fork();
- if let Ok(path) = ahead.call(Path::parse_mod_style) {
- if ahead.peek(Token![!]) && (ahead.peek2(token::Brace) || ahead.peek2(Ident)) {
- input.advance_to(&ahead);
- return stmt_mac(input, attrs, path);
- }
- }
-
- if input.peek(Token![let]) {
- stmt_local(input, attrs).map(Stmt::Local)
- } else if input.peek(Token![pub])
- || input.peek(Token![crate]) && !input.peek2(Token![::])
- || input.peek(Token![extern]) && !input.peek2(Token![::])
- || input.peek(Token![use])
- || input.peek(Token![static]) && (input.peek2(Token![mut]) || input.peek2(Ident))
- || input.peek(Token![const])
- || input.peek(Token![unsafe]) && !input.peek2(token::Brace)
- || input.peek(Token![async])
- && (input.peek2(Token![unsafe])
- || input.peek2(Token![extern])
- || input.peek2(Token![fn]))
- || input.peek(Token![fn])
- || input.peek(Token![mod])
- || input.peek(Token![type])
- || input.peek(item::parsing::existential) && input.peek2(Token![type])
- || input.peek(Token![struct])
- || input.peek(Token![enum])
- || input.peek(Token![union]) && input.peek2(Ident)
- || input.peek(Token![auto]) && input.peek2(Token![trait])
- || input.peek(Token![trait])
- || input.peek(Token![default])
- && (input.peek2(Token![unsafe]) || input.peek2(Token![impl]))
- || input.peek(Token![impl])
- || input.peek(Token![macro])
- {
- let mut item: Item = input.parse()?;
- attrs.extend(item.replace_attrs(Vec::new()));
- item.replace_attrs(attrs);
- Ok(Stmt::Item(item))
- } else {
- stmt_expr(input, allow_nosemi, attrs)
- }
- }
-
- fn stmt_mac(input: ParseStream, attrs: Vec<Attribute>, path: Path) -> Result<Stmt> {
- let bang_token: Token![!] = input.parse()?;
- let ident: Option<Ident> = input.parse()?;
- let (delimiter, tokens) = mac::parse_delimiter(input)?;
- let semi_token: Option<Token![;]> = input.parse()?;
-
- Ok(Stmt::Item(Item::Macro(ItemMacro {
- attrs,
- ident,
- mac: Macro {
- path,
- bang_token,
- delimiter,
- tokens,
- },
- semi_token,
- })))
- }
-
- fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Local> {
- Ok(Local {
- attrs,
- let_token: input.parse()?,
- pat: {
- let leading_vert: Option<Token![|]> = input.parse()?;
- let mut pat: Pat = input.parse()?;
- if leading_vert.is_some()
- || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=])
- {
- let mut cases = Punctuated::new();
- cases.push_value(pat);
- while input.peek(Token![|])
- && !input.peek(Token![||])
- && !input.peek(Token![|=])
- {
- let punct = input.parse()?;
- cases.push_punct(punct);
- let pat: Pat = input.parse()?;
- cases.push_value(pat);
- }
- pat = Pat::Or(PatOr {
- attrs: Vec::new(),
- leading_vert,
- cases,
- });
- }
- if input.peek(Token![:]) {
- let colon_token: Token![:] = input.parse()?;
- let ty: Type = input.parse()?;
- pat = Pat::Type(PatType {
- attrs: Vec::new(),
- pat: Box::new(pat),
- colon_token,
- ty: Box::new(ty),
- });
- }
- pat
- },
- init: {
- if input.peek(Token![=]) {
- let eq_token: Token![=] = input.parse()?;
- let init: Expr = input.parse()?;
- Some((eq_token, Box::new(init)))
- } else {
- None
- }
- },
- semi_token: input.parse()?,
- })
- }
-
- fn stmt_expr(
- input: ParseStream,
- allow_nosemi: bool,
- mut attrs: Vec<Attribute>,
- ) -> Result<Stmt> {
- let mut e = expr::parsing::expr_early(input)?;
-
- attrs.extend(e.replace_attrs(Vec::new()));
- e.replace_attrs(attrs);
-
- if input.peek(Token![;]) {
- return Ok(Stmt::Semi(e, input.parse()?));
- }
-
- if allow_nosemi || !expr::requires_terminator(&e) {
- Ok(Stmt::Expr(e))
- } else {
- Err(input.error("expected semicolon"))
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- impl ToTokens for Block {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.brace_token.surround(tokens, |tokens| {
- tokens.append_all(&self.stmts);
- });
- }
- }
-
- impl ToTokens for Stmt {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- Stmt::Local(local) => local.to_tokens(tokens),
- Stmt::Item(item) => item.to_tokens(tokens),
- Stmt::Expr(expr) => expr.to_tokens(tokens),
- Stmt::Semi(expr, semi) => {
- expr.to_tokens(tokens);
- semi.to_tokens(tokens);
- }
- }
- }
- }
-
- impl ToTokens for Local {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- expr::printing::outer_attrs_to_tokens(&self.attrs, tokens);
- self.let_token.to_tokens(tokens);
- self.pat.to_tokens(tokens);
- if let Some((eq_token, init)) = &self.init {
- eq_token.to_tokens(tokens);
- init.to_tokens(tokens);
- }
- self.semi_token.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/src/thread.rs b/syn/src/thread.rs
deleted file mode 100644
index 9e5d8ad..0000000
--- a/syn/src/thread.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-use std::fmt::{self, Debug};
-use std::thread::{self, ThreadId};
-
-/// ThreadBound is a Sync-maker and Send-maker that allows accessing a value
-/// of type T only from the original thread on which the ThreadBound was
-/// constructed.
-pub struct ThreadBound<T> {
- value: T,
- thread_id: ThreadId,
-}
-
-unsafe impl<T> Sync for ThreadBound<T> {}
-
-// Send bound requires Copy, as otherwise Drop could run in the wrong place.
-unsafe impl<T: Copy> Send for ThreadBound<T> {}
-
-impl<T> ThreadBound<T> {
- pub fn new(value: T) -> Self {
- ThreadBound {
- value,
- thread_id: thread::current().id(),
- }
- }
-
- pub fn get(&self) -> Option<&T> {
- if thread::current().id() == self.thread_id {
- Some(&self.value)
- } else {
- None
- }
- }
-}
-
-impl<T: Debug> Debug for ThreadBound<T> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match self.get() {
- Some(value) => Debug::fmt(value, formatter),
- None => formatter.write_str("unknown"),
- }
- }
-}
diff --git a/syn/src/token.rs b/syn/src/token.rs
deleted file mode 100644
index a9f787a..0000000
--- a/syn/src/token.rs
+++ /dev/null
@@ -1,956 +0,0 @@
-//! Tokens representing Rust punctuation, keywords, and delimiters.
-//!
-//! The type names in this module can be difficult to keep straight, so we
-//! prefer to use the [`Token!`] macro instead. This is a type-macro that
-//! expands to the token type of the given token.
-//!
-//! [`Token!`]: ../macro.Token.html
-//!
-//! # Example
-//!
-//! The [`ItemStatic`] syntax tree node is defined like this.
-//!
-//! [`ItemStatic`]: ../struct.ItemStatic.html
-//!
-//! ```
-//! # use syn::{Attribute, Expr, Ident, Token, Type, Visibility};
-//! #
-//! pub struct ItemStatic {
-//! pub attrs: Vec<Attribute>,
-//! pub vis: Visibility,
-//! pub static_token: Token![static],
-//! pub mutability: Option<Token![mut]>,
-//! pub ident: Ident,
-//! pub colon_token: Token![:],
-//! pub ty: Box<Type>,
-//! pub eq_token: Token![=],
-//! pub expr: Box<Expr>,
-//! pub semi_token: Token![;],
-//! }
-//! ```
-//!
-//! # Parsing
-//!
-//! Keywords and punctuation can be parsed through the [`ParseStream::parse`]
-//! method. Delimiter tokens are parsed using the [`parenthesized!`],
-//! [`bracketed!`] and [`braced!`] macros.
-//!
-//! [`ParseStream::parse`]: ../parse/struct.ParseBuffer.html#method.parse
-//! [`parenthesized!`]: ../macro.parenthesized.html
-//! [`bracketed!`]: ../macro.bracketed.html
-//! [`braced!`]: ../macro.braced.html
-//!
-//! ```
-//! use syn::{Attribute, Result};
-//! use syn::parse::{Parse, ParseStream};
-//! #
-//! # enum ItemStatic {}
-//!
-//! // Parse the ItemStatic struct shown above.
-//! impl Parse for ItemStatic {
-//! fn parse(input: ParseStream) -> Result<Self> {
-//! # use syn::ItemStatic;
-//! # fn parse(input: ParseStream) -> Result<ItemStatic> {
-//! Ok(ItemStatic {
-//! attrs: input.call(Attribute::parse_outer)?,
-//! vis: input.parse()?,
-//! static_token: input.parse()?,
-//! mutability: input.parse()?,
-//! ident: input.parse()?,
-//! colon_token: input.parse()?,
-//! ty: input.parse()?,
-//! eq_token: input.parse()?,
-//! expr: input.parse()?,
-//! semi_token: input.parse()?,
-//! })
-//! # }
-//! # unimplemented!()
-//! }
-//! }
-//! ```
-//!
-//! # Other operations
-//!
-//! Every keyword and punctuation token supports the following operations.
-//!
-//! - [Peeking] — `input.peek(Token![...])`
-//!
-//! - [Parsing] — `input.parse::<Token![...]>()?`
-//!
-//! - [Printing] — `quote!( ... #the_token ... )`
-//!
-//! - Construction from a [`Span`] — `let the_token = Token![...](sp)`
-//!
-//! - Field access to its span — `let sp = the_token.span`
-//!
-//! [Peeking]: ../parse/struct.ParseBuffer.html#method.peek
-//! [Parsing]: ../parse/struct.ParseBuffer.html#method.parse
-//! [Printing]: https://docs.rs/quote/1.0/quote/trait.ToTokens.html
-//! [`Span`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.Span.html
-
-use std;
-#[cfg(feature = "extra-traits")]
-use std::cmp;
-#[cfg(feature = "extra-traits")]
-use std::fmt::{self, Debug};
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-use std::ops::{Deref, DerefMut};
-
-#[cfg(feature = "parsing")]
-use proc_macro2::Delimiter;
-#[cfg(any(feature = "parsing", feature = "printing"))]
-use proc_macro2::Ident;
-use proc_macro2::Span;
-#[cfg(feature = "printing")]
-use proc_macro2::TokenStream;
-#[cfg(feature = "printing")]
-use quote::{ToTokens, TokenStreamExt};
-
-use self::private::WithSpan;
-#[cfg(feature = "parsing")]
-use crate::buffer::Cursor;
-#[cfg(feature = "parsing")]
-use crate::error::Result;
-#[cfg(any(feature = "full", feature = "derive"))]
-#[cfg(feature = "parsing")]
-use crate::lifetime::Lifetime;
-#[cfg(any(feature = "full", feature = "derive"))]
-#[cfg(feature = "parsing")]
-use crate::lit::{Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr};
-#[cfg(feature = "parsing")]
-use crate::lookahead;
-#[cfg(feature = "parsing")]
-use crate::parse::{Parse, ParseStream};
-use crate::span::IntoSpans;
-
-/// Marker trait for types that represent single tokens.
-///
-/// This trait is sealed and cannot be implemented for types outside of Syn.
-#[cfg(feature = "parsing")]
-pub trait Token: private::Sealed {
- // Not public API.
- #[doc(hidden)]
- fn peek(cursor: Cursor) -> bool;
-
- // Not public API.
- #[doc(hidden)]
- fn display() -> &'static str;
-}
-
-mod private {
- use proc_macro2::Span;
-
- #[cfg(feature = "parsing")]
- pub trait Sealed {}
-
- /// Support writing `token.span` rather than `token.spans[0]` on tokens that
- /// hold a single span.
- #[repr(C)]
- pub struct WithSpan {
- pub span: Span,
- }
-}
-
-#[cfg(feature = "parsing")]
-impl private::Sealed for Ident {}
-
-#[cfg(any(feature = "full", feature = "derive"))]
-#[cfg(feature = "parsing")]
-fn peek_impl(cursor: Cursor, peek: fn(ParseStream) -> bool) -> bool {
- use crate::parse::Unexpected;
- use std::cell::Cell;
- use std::rc::Rc;
-
- let scope = Span::call_site();
- let unexpected = Rc::new(Cell::new(Unexpected::None));
- let buffer = crate::parse::new_parse_buffer(scope, cursor, unexpected);
- peek(&buffer)
-}
-
-#[cfg(any(feature = "full", feature = "derive"))]
-macro_rules! impl_token {
- ($name:ident $display:expr) => {
- #[cfg(feature = "parsing")]
- impl Token for $name {
- fn peek(cursor: Cursor) -> bool {
- fn peek(input: ParseStream) -> bool {
- <$name as Parse>::parse(input).is_ok()
- }
- peek_impl(cursor, peek)
- }
-
- fn display() -> &'static str {
- $display
- }
- }
-
- #[cfg(feature = "parsing")]
- impl private::Sealed for $name {}
- };
-}
-
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(Lifetime "lifetime");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(Lit "literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitStr "string literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitByteStr "byte string literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitByte "byte literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitChar "character literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitInt "integer literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitFloat "floating point literal");
-#[cfg(any(feature = "full", feature = "derive"))]
-impl_token!(LitBool "boolean literal");
-
-// Not public API.
-#[doc(hidden)]
-#[cfg(feature = "parsing")]
-pub trait CustomToken {
- fn peek(cursor: Cursor) -> bool;
- fn display() -> &'static str;
-}
-
-#[cfg(feature = "parsing")]
-impl<T: CustomToken> private::Sealed for T {}
-
-#[cfg(feature = "parsing")]
-impl<T: CustomToken> Token for T {
- fn peek(cursor: Cursor) -> bool {
- <Self as CustomToken>::peek(cursor)
- }
-
- fn display() -> &'static str {
- <Self as CustomToken>::display()
- }
-}
-
-macro_rules! define_keywords {
- ($($token:tt pub struct $name:ident #[$doc:meta])*) => {
- $(
- #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
- #[$doc]
- ///
- /// Don't try to remember the name of this type &mdash; use the
- /// [`Token!`] macro instead.
- ///
- /// [`Token!`]: crate::token
- pub struct $name {
- pub span: Span,
- }
-
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn $name<S: IntoSpans<[Span; 1]>>(span: S) -> $name {
- $name {
- span: span.into_spans()[0],
- }
- }
-
- impl std::default::Default for $name {
- fn default() -> Self {
- $name {
- span: Span::call_site(),
- }
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Debug for $name {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str(stringify!($name))
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl cmp::Eq for $name {}
-
- #[cfg(feature = "extra-traits")]
- impl PartialEq for $name {
- fn eq(&self, _other: &$name) -> bool {
- true
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Hash for $name {
- fn hash<H: Hasher>(&self, _state: &mut H) {}
- }
-
- #[cfg(feature = "printing")]
- impl ToTokens for $name {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- printing::keyword($token, self.span, tokens);
- }
- }
-
- #[cfg(feature = "parsing")]
- impl Parse for $name {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok($name {
- span: parsing::keyword(input, $token)?,
- })
- }
- }
-
- #[cfg(feature = "parsing")]
- impl Token for $name {
- fn peek(cursor: Cursor) -> bool {
- parsing::peek_keyword(cursor, $token)
- }
-
- fn display() -> &'static str {
- concat!("`", $token, "`")
- }
- }
-
- #[cfg(feature = "parsing")]
- impl private::Sealed for $name {}
- )*
- };
-}
-
-macro_rules! impl_deref_if_len_is_1 {
- ($name:ident/1) => {
- impl Deref for $name {
- type Target = WithSpan;
-
- fn deref(&self) -> &Self::Target {
- unsafe { &*(self as *const Self as *const WithSpan) }
- }
- }
-
- impl DerefMut for $name {
- fn deref_mut(&mut self) -> &mut Self::Target {
- unsafe { &mut *(self as *mut Self as *mut WithSpan) }
- }
- }
- };
-
- ($name:ident/$len:tt) => {};
-}
-
-macro_rules! define_punctuation_structs {
- ($($token:tt pub struct $name:ident/$len:tt #[$doc:meta])*) => {
- $(
- #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
- #[repr(C)]
- #[$doc]
- ///
- /// Don't try to remember the name of this type &mdash; use the
- /// [`Token!`] macro instead.
- ///
- /// [`Token!`]: crate::token
- pub struct $name {
- pub spans: [Span; $len],
- }
-
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn $name<S: IntoSpans<[Span; $len]>>(spans: S) -> $name {
- $name {
- spans: spans.into_spans(),
- }
- }
-
- impl std::default::Default for $name {
- fn default() -> Self {
- $name {
- spans: [Span::call_site(); $len],
- }
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Debug for $name {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str(stringify!($name))
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl cmp::Eq for $name {}
-
- #[cfg(feature = "extra-traits")]
- impl PartialEq for $name {
- fn eq(&self, _other: &$name) -> bool {
- true
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Hash for $name {
- fn hash<H: Hasher>(&self, _state: &mut H) {}
- }
-
- impl_deref_if_len_is_1!($name/$len);
- )*
- };
-}
-
-macro_rules! define_punctuation {
- ($($token:tt pub struct $name:ident/$len:tt #[$doc:meta])*) => {
- $(
- define_punctuation_structs! {
- $token pub struct $name/$len #[$doc]
- }
-
- #[cfg(feature = "printing")]
- impl ToTokens for $name {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- printing::punct($token, &self.spans, tokens);
- }
- }
-
- #[cfg(feature = "parsing")]
- impl Parse for $name {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok($name {
- spans: parsing::punct(input, $token)?,
- })
- }
- }
-
- #[cfg(feature = "parsing")]
- impl Token for $name {
- fn peek(cursor: Cursor) -> bool {
- parsing::peek_punct(cursor, $token)
- }
-
- fn display() -> &'static str {
- concat!("`", $token, "`")
- }
- }
-
- #[cfg(feature = "parsing")]
- impl private::Sealed for $name {}
- )*
- };
-}
-
-macro_rules! define_delimiters {
- ($($token:tt pub struct $name:ident #[$doc:meta])*) => {
- $(
- #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
- #[$doc]
- pub struct $name {
- pub span: Span,
- }
-
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn $name<S: IntoSpans<[Span; 1]>>(span: S) -> $name {
- $name {
- span: span.into_spans()[0],
- }
- }
-
- impl std::default::Default for $name {
- fn default() -> Self {
- $name {
- span: Span::call_site(),
- }
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Debug for $name {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str(stringify!($name))
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl cmp::Eq for $name {}
-
- #[cfg(feature = "extra-traits")]
- impl PartialEq for $name {
- fn eq(&self, _other: &$name) -> bool {
- true
- }
- }
-
- #[cfg(feature = "extra-traits")]
- impl Hash for $name {
- fn hash<H: Hasher>(&self, _state: &mut H) {}
- }
-
- impl $name {
- #[cfg(feature = "printing")]
- pub fn surround<F>(&self, tokens: &mut TokenStream, f: F)
- where
- F: FnOnce(&mut TokenStream),
- {
- printing::delim($token, self.span, tokens, f);
- }
- }
-
- #[cfg(feature = "parsing")]
- impl private::Sealed for $name {}
- )*
- };
-}
-
-define_punctuation_structs! {
- "_" pub struct Underscore/1 /// `_`
-}
-
-#[cfg(feature = "printing")]
-impl ToTokens for Underscore {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append(Ident::new("_", self.span));
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Parse for Underscore {
- fn parse(input: ParseStream) -> Result<Self> {
- input.step(|cursor| {
- if let Some((ident, rest)) = cursor.ident() {
- if ident == "_" {
- return Ok((Underscore(ident.span()), rest));
- }
- }
- if let Some((punct, rest)) = cursor.punct() {
- if punct.as_char() == '_' {
- return Ok((Underscore(punct.span()), rest));
- }
- }
- Err(cursor.error("expected `_`"))
- })
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Token for Underscore {
- fn peek(cursor: Cursor) -> bool {
- if let Some((ident, _rest)) = cursor.ident() {
- return ident == "_";
- }
- if let Some((punct, _rest)) = cursor.punct() {
- return punct.as_char() == '_';
- }
- false
- }
-
- fn display() -> &'static str {
- "`_`"
- }
-}
-
-#[cfg(feature = "parsing")]
-impl private::Sealed for Underscore {}
-
-#[cfg(feature = "parsing")]
-impl Token for Paren {
- fn peek(cursor: Cursor) -> bool {
- lookahead::is_delimiter(cursor, Delimiter::Parenthesis)
- }
-
- fn display() -> &'static str {
- "parentheses"
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Token for Brace {
- fn peek(cursor: Cursor) -> bool {
- lookahead::is_delimiter(cursor, Delimiter::Brace)
- }
-
- fn display() -> &'static str {
- "curly braces"
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Token for Bracket {
- fn peek(cursor: Cursor) -> bool {
- lookahead::is_delimiter(cursor, Delimiter::Bracket)
- }
-
- fn display() -> &'static str {
- "square brackets"
- }
-}
-
-#[cfg(feature = "parsing")]
-impl Token for Group {
- fn peek(cursor: Cursor) -> bool {
- lookahead::is_delimiter(cursor, Delimiter::None)
- }
-
- fn display() -> &'static str {
- "invisible group"
- }
-}
-
-define_keywords! {
- "abstract" pub struct Abstract /// `abstract`
- "as" pub struct As /// `as`
- "async" pub struct Async /// `async`
- "auto" pub struct Auto /// `auto`
- "await" pub struct Await /// `await`
- "become" pub struct Become /// `become`
- "box" pub struct Box /// `box`
- "break" pub struct Break /// `break`
- "const" pub struct Const /// `const`
- "continue" pub struct Continue /// `continue`
- "crate" pub struct Crate /// `crate`
- "default" pub struct Default /// `default`
- "do" pub struct Do /// `do`
- "dyn" pub struct Dyn /// `dyn`
- "else" pub struct Else /// `else`
- "enum" pub struct Enum /// `enum`
- "extern" pub struct Extern /// `extern`
- "final" pub struct Final /// `final`
- "fn" pub struct Fn /// `fn`
- "for" pub struct For /// `for`
- "if" pub struct If /// `if`
- "impl" pub struct Impl /// `impl`
- "in" pub struct In /// `in`
- "let" pub struct Let /// `let`
- "loop" pub struct Loop /// `loop`
- "macro" pub struct Macro /// `macro`
- "match" pub struct Match /// `match`
- "mod" pub struct Mod /// `mod`
- "move" pub struct Move /// `move`
- "mut" pub struct Mut /// `mut`
- "override" pub struct Override /// `override`
- "priv" pub struct Priv /// `priv`
- "pub" pub struct Pub /// `pub`
- "ref" pub struct Ref /// `ref`
- "return" pub struct Return /// `return`
- "Self" pub struct SelfType /// `Self`
- "self" pub struct SelfValue /// `self`
- "static" pub struct Static /// `static`
- "struct" pub struct Struct /// `struct`
- "super" pub struct Super /// `super`
- "trait" pub struct Trait /// `trait`
- "try" pub struct Try /// `try`
- "type" pub struct Type /// `type`
- "typeof" pub struct Typeof /// `typeof`
- "union" pub struct Union /// `union`
- "unsafe" pub struct Unsafe /// `unsafe`
- "unsized" pub struct Unsized /// `unsized`
- "use" pub struct Use /// `use`
- "virtual" pub struct Virtual /// `virtual`
- "where" pub struct Where /// `where`
- "while" pub struct While /// `while`
- "yield" pub struct Yield /// `yield`
-}
-
-define_punctuation! {
- "+" pub struct Add/1 /// `+`
- "+=" pub struct AddEq/2 /// `+=`
- "&" pub struct And/1 /// `&`
- "&&" pub struct AndAnd/2 /// `&&`
- "&=" pub struct AndEq/2 /// `&=`
- "@" pub struct At/1 /// `@`
- "!" pub struct Bang/1 /// `!`
- "^" pub struct Caret/1 /// `^`
- "^=" pub struct CaretEq/2 /// `^=`
- ":" pub struct Colon/1 /// `:`
- "::" pub struct Colon2/2 /// `::`
- "," pub struct Comma/1 /// `,`
- "/" pub struct Div/1 /// `/`
- "/=" pub struct DivEq/2 /// `/=`
- "$" pub struct Dollar/1 /// `$`
- "." pub struct Dot/1 /// `.`
- ".." pub struct Dot2/2 /// `..`
- "..." pub struct Dot3/3 /// `...`
- "..=" pub struct DotDotEq/3 /// `..=`
- "=" pub struct Eq/1 /// `=`
- "==" pub struct EqEq/2 /// `==`
- ">=" pub struct Ge/2 /// `>=`
- ">" pub struct Gt/1 /// `>`
- "<=" pub struct Le/2 /// `<=`
- "<" pub struct Lt/1 /// `<`
- "*=" pub struct MulEq/2 /// `*=`
- "!=" pub struct Ne/2 /// `!=`
- "|" pub struct Or/1 /// `|`
- "|=" pub struct OrEq/2 /// `|=`
- "||" pub struct OrOr/2 /// `||`
- "#" pub struct Pound/1 /// `#`
- "?" pub struct Question/1 /// `?`
- "->" pub struct RArrow/2 /// `->`
- "<-" pub struct LArrow/2 /// `<-`
- "%" pub struct Rem/1 /// `%`
- "%=" pub struct RemEq/2 /// `%=`
- "=>" pub struct FatArrow/2 /// `=>`
- ";" pub struct Semi/1 /// `;`
- "<<" pub struct Shl/2 /// `<<`
- "<<=" pub struct ShlEq/3 /// `<<=`
- ">>" pub struct Shr/2 /// `>>`
- ">>=" pub struct ShrEq/3 /// `>>=`
- "*" pub struct Star/1 /// `*`
- "-" pub struct Sub/1 /// `-`
- "-=" pub struct SubEq/2 /// `-=`
- "~" pub struct Tilde/1 /// `~`
-}
-
-define_delimiters! {
- "{" pub struct Brace /// `{...}`
- "[" pub struct Bracket /// `[...]`
- "(" pub struct Paren /// `(...)`
- " " pub struct Group /// None-delimited group
-}
-
-macro_rules! export_token_macro {
- ($($await_rule:tt)*) => {
- /// A type-macro that expands to the name of the Rust type representation of a
- /// given token.
- ///
- /// See the [token module] documentation for details and examples.
- ///
- /// [token module]: crate::token
- // Unfortunate duplication due to a rustdoc bug.
- // https://github.com/rust-lang/rust/issues/45939
- #[macro_export]
- macro_rules! Token {
- (abstract) => { $crate::token::Abstract };
- (as) => { $crate::token::As };
- (async) => { $crate::token::Async };
- (auto) => { $crate::token::Auto };
- $($await_rule => { $crate::token::Await };)*
- (become) => { $crate::token::Become };
- (box) => { $crate::token::Box };
- (break) => { $crate::token::Break };
- (const) => { $crate::token::Const };
- (continue) => { $crate::token::Continue };
- (crate) => { $crate::token::Crate };
- (default) => { $crate::token::Default };
- (do) => { $crate::token::Do };
- (dyn) => { $crate::token::Dyn };
- (else) => { $crate::token::Else };
- (enum) => { $crate::token::Enum };
- (extern) => { $crate::token::Extern };
- (final) => { $crate::token::Final };
- (fn) => { $crate::token::Fn };
- (for) => { $crate::token::For };
- (if) => { $crate::token::If };
- (impl) => { $crate::token::Impl };
- (in) => { $crate::token::In };
- (let) => { $crate::token::Let };
- (loop) => { $crate::token::Loop };
- (macro) => { $crate::token::Macro };
- (match) => { $crate::token::Match };
- (mod) => { $crate::token::Mod };
- (move) => { $crate::token::Move };
- (mut) => { $crate::token::Mut };
- (override) => { $crate::token::Override };
- (priv) => { $crate::token::Priv };
- (pub) => { $crate::token::Pub };
- (ref) => { $crate::token::Ref };
- (return) => { $crate::token::Return };
- (Self) => { $crate::token::SelfType };
- (self) => { $crate::token::SelfValue };
- (static) => { $crate::token::Static };
- (struct) => { $crate::token::Struct };
- (super) => { $crate::token::Super };
- (trait) => { $crate::token::Trait };
- (try) => { $crate::token::Try };
- (type) => { $crate::token::Type };
- (typeof) => { $crate::token::Typeof };
- (union) => { $crate::token::Union };
- (unsafe) => { $crate::token::Unsafe };
- (unsized) => { $crate::token::Unsized };
- (use) => { $crate::token::Use };
- (virtual) => { $crate::token::Virtual };
- (where) => { $crate::token::Where };
- (while) => { $crate::token::While };
- (yield) => { $crate::token::Yield };
- (+) => { $crate::token::Add };
- (+=) => { $crate::token::AddEq };
- (&) => { $crate::token::And };
- (&&) => { $crate::token::AndAnd };
- (&=) => { $crate::token::AndEq };
- (@) => { $crate::token::At };
- (!) => { $crate::token::Bang };
- (^) => { $crate::token::Caret };
- (^=) => { $crate::token::CaretEq };
- (:) => { $crate::token::Colon };
- (::) => { $crate::token::Colon2 };
- (,) => { $crate::token::Comma };
- (/) => { $crate::token::Div };
- (/=) => { $crate::token::DivEq };
- ($) => { $crate::token::Dollar };
- (.) => { $crate::token::Dot };
- (..) => { $crate::token::Dot2 };
- (...) => { $crate::token::Dot3 };
- (..=) => { $crate::token::DotDotEq };
- (=) => { $crate::token::Eq };
- (==) => { $crate::token::EqEq };
- (>=) => { $crate::token::Ge };
- (>) => { $crate::token::Gt };
- (<=) => { $crate::token::Le };
- (<) => { $crate::token::Lt };
- (*=) => { $crate::token::MulEq };
- (!=) => { $crate::token::Ne };
- (|) => { $crate::token::Or };
- (|=) => { $crate::token::OrEq };
- (||) => { $crate::token::OrOr };
- (#) => { $crate::token::Pound };
- (?) => { $crate::token::Question };
- (->) => { $crate::token::RArrow };
- (<-) => { $crate::token::LArrow };
- (%) => { $crate::token::Rem };
- (%=) => { $crate::token::RemEq };
- (=>) => { $crate::token::FatArrow };
- (;) => { $crate::token::Semi };
- (<<) => { $crate::token::Shl };
- (<<=) => { $crate::token::ShlEq };
- (>>) => { $crate::token::Shr };
- (>>=) => { $crate::token::ShrEq };
- (*) => { $crate::token::Star };
- (-) => { $crate::token::Sub };
- (-=) => { $crate::token::SubEq };
- (~) => { $crate::token::Tilde };
- (_) => { $crate::token::Underscore };
- }
- };
-}
-
-// Old rustc does not permit `await` appearing anywhere in the source file.
-// https://github.com/rust-lang/rust/issues/57919
-// We put the Token![await] rule in a place that is not lexed by old rustc.
-#[cfg(not(syn_omit_await_from_token_macro))]
-include!("await.rs"); // export_token_macro![(await)];
-#[cfg(syn_omit_await_from_token_macro)]
-export_token_macro![];
-
-// Not public API.
-#[doc(hidden)]
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use proc_macro2::{Spacing, Span};
-
- use crate::buffer::Cursor;
- use crate::error::{Error, Result};
- use crate::parse::ParseStream;
- use crate::span::FromSpans;
-
- pub fn keyword(input: ParseStream, token: &str) -> Result<Span> {
- input.step(|cursor| {
- if let Some((ident, rest)) = cursor.ident() {
- if ident == token {
- return Ok((ident.span(), rest));
- }
- }
- Err(cursor.error(format!("expected `{}`", token)))
- })
- }
-
- pub fn peek_keyword(cursor: Cursor, token: &str) -> bool {
- if let Some((ident, _rest)) = cursor.ident() {
- ident == token
- } else {
- false
- }
- }
-
- pub fn punct<S: FromSpans>(input: ParseStream, token: &str) -> Result<S> {
- let mut spans = [input.span(); 3];
- punct_helper(input, token, &mut spans)?;
- Ok(S::from_spans(&spans))
- }
-
- fn punct_helper(input: ParseStream, token: &str, spans: &mut [Span; 3]) -> Result<()> {
- input.step(|cursor| {
- let mut cursor = *cursor;
- assert!(token.len() <= spans.len());
-
- for (i, ch) in token.chars().enumerate() {
- match cursor.punct() {
- Some((punct, rest)) => {
- spans[i] = punct.span();
- if punct.as_char() != ch {
- break;
- } else if i == token.len() - 1 {
- return Ok(((), rest));
- } else if punct.spacing() != Spacing::Joint {
- break;
- }
- cursor = rest;
- }
- None => break,
- }
- }
-
- Err(Error::new(spans[0], format!("expected `{}`", token)))
- })
- }
-
- pub fn peek_punct(mut cursor: Cursor, token: &str) -> bool {
- for (i, ch) in token.chars().enumerate() {
- match cursor.punct() {
- Some((punct, rest)) => {
- if punct.as_char() != ch {
- break;
- } else if i == token.len() - 1 {
- return true;
- } else if punct.spacing() != Spacing::Joint {
- break;
- }
- cursor = rest;
- }
- None => break,
- }
- }
- false
- }
-}
-
-// Not public API.
-#[doc(hidden)]
-#[cfg(feature = "printing")]
-pub mod printing {
- use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream};
- use quote::TokenStreamExt;
-
- pub fn punct(s: &str, spans: &[Span], tokens: &mut TokenStream) {
- assert_eq!(s.len(), spans.len());
-
- let mut chars = s.chars();
- let mut spans = spans.iter();
- let ch = chars.next_back().unwrap();
- let span = spans.next_back().unwrap();
- for (ch, span) in chars.zip(spans) {
- let mut op = Punct::new(ch, Spacing::Joint);
- op.set_span(*span);
- tokens.append(op);
- }
-
- let mut op = Punct::new(ch, Spacing::Alone);
- op.set_span(*span);
- tokens.append(op);
- }
-
- pub fn keyword(s: &str, span: Span, tokens: &mut TokenStream) {
- tokens.append(Ident::new(s, span));
- }
-
- pub fn delim<F>(s: &str, span: Span, tokens: &mut TokenStream, f: F)
- where
- F: FnOnce(&mut TokenStream),
- {
- let delim = match s {
- "(" => Delimiter::Parenthesis,
- "[" => Delimiter::Bracket,
- "{" => Delimiter::Brace,
- " " => Delimiter::None,
- _ => panic!("unknown delimiter: {}", s),
- };
- let mut inner = TokenStream::new();
- f(&mut inner);
- let mut g = Group::new(delim, inner);
- g.set_span(span);
- tokens.append(g);
- }
-}
diff --git a/syn/src/tt.rs b/syn/src/tt.rs
deleted file mode 100644
index 8dba062..0000000
--- a/syn/src/tt.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-use std::hash::{Hash, Hasher};
-
-use proc_macro2::{Delimiter, TokenStream, TokenTree};
-
-pub struct TokenTreeHelper<'a>(pub &'a TokenTree);
-
-impl<'a> PartialEq for TokenTreeHelper<'a> {
- fn eq(&self, other: &Self) -> bool {
- use proc_macro2::Spacing;
-
- match (self.0, other.0) {
- (TokenTree::Group(g1), TokenTree::Group(g2)) => {
- match (g1.delimiter(), g2.delimiter()) {
- (Delimiter::Parenthesis, Delimiter::Parenthesis)
- | (Delimiter::Brace, Delimiter::Brace)
- | (Delimiter::Bracket, Delimiter::Bracket)
- | (Delimiter::None, Delimiter::None) => {}
- _ => return false,
- }
-
- let s1 = g1.stream().into_iter();
- let mut s2 = g2.stream().into_iter();
-
- for item1 in s1 {
- let item2 = match s2.next() {
- Some(item) => item,
- None => return false,
- };
- if TokenTreeHelper(&item1) != TokenTreeHelper(&item2) {
- return false;
- }
- }
- s2.next().is_none()
- }
- (TokenTree::Punct(o1), TokenTree::Punct(o2)) => {
- o1.as_char() == o2.as_char()
- && match (o1.spacing(), o2.spacing()) {
- (Spacing::Alone, Spacing::Alone) | (Spacing::Joint, Spacing::Joint) => true,
- _ => false,
- }
- }
- (TokenTree::Literal(l1), TokenTree::Literal(l2)) => l1.to_string() == l2.to_string(),
- (TokenTree::Ident(s1), TokenTree::Ident(s2)) => s1 == s2,
- _ => false,
- }
- }
-}
-
-impl<'a> Hash for TokenTreeHelper<'a> {
- fn hash<H: Hasher>(&self, h: &mut H) {
- use proc_macro2::Spacing;
-
- match self.0 {
- TokenTree::Group(g) => {
- 0u8.hash(h);
- match g.delimiter() {
- Delimiter::Parenthesis => 0u8.hash(h),
- Delimiter::Brace => 1u8.hash(h),
- Delimiter::Bracket => 2u8.hash(h),
- Delimiter::None => 3u8.hash(h),
- }
-
- for item in g.stream() {
- TokenTreeHelper(&item).hash(h);
- }
- 0xffu8.hash(h); // terminator w/ a variant we don't normally hash
- }
- TokenTree::Punct(op) => {
- 1u8.hash(h);
- op.as_char().hash(h);
- match op.spacing() {
- Spacing::Alone => 0u8.hash(h),
- Spacing::Joint => 1u8.hash(h),
- }
- }
- TokenTree::Literal(lit) => (2u8, lit.to_string()).hash(h),
- TokenTree::Ident(word) => (3u8, word).hash(h),
- }
- }
-}
-
-pub struct TokenStreamHelper<'a>(pub &'a TokenStream);
-
-impl<'a> PartialEq for TokenStreamHelper<'a> {
- fn eq(&self, other: &Self) -> bool {
- let left = self.0.clone().into_iter().collect::<Vec<_>>();
- let right = other.0.clone().into_iter().collect::<Vec<_>>();
- if left.len() != right.len() {
- return false;
- }
- for (a, b) in left.into_iter().zip(right) {
- if TokenTreeHelper(&a) != TokenTreeHelper(&b) {
- return false;
- }
- }
- true
- }
-}
-
-impl<'a> Hash for TokenStreamHelper<'a> {
- fn hash<H: Hasher>(&self, state: &mut H) {
- let tts = self.0.clone().into_iter().collect::<Vec<_>>();
- tts.len().hash(state);
- for tt in tts {
- TokenTreeHelper(&tt).hash(state);
- }
- }
-}
diff --git a/syn/src/ty.rs b/syn/src/ty.rs
deleted file mode 100644
index b2e086b..0000000
--- a/syn/src/ty.rs
+++ /dev/null
@@ -1,1178 +0,0 @@
-use super::*;
-use crate::punctuated::Punctuated;
-#[cfg(feature = "extra-traits")]
-use crate::tt::TokenStreamHelper;
-use proc_macro2::TokenStream;
-#[cfg(feature = "extra-traits")]
-use std::hash::{Hash, Hasher};
-
-ast_enum_of_structs! {
- /// The possible types that a Rust value could have.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- /// # Syntax tree enum
- ///
- /// This type is a [syntax tree enum].
- ///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
- pub enum Type #manual_extra_traits {
- /// A fixed size array type: `[T; n]`.
- Array(TypeArray),
-
- /// A bare function type: `fn(usize) -> bool`.
- BareFn(TypeBareFn),
-
- /// A type contained within invisible delimiters.
- Group(TypeGroup),
-
- /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or
- /// a lifetime.
- ImplTrait(TypeImplTrait),
-
- /// Indication that a type should be inferred by the compiler: `_`.
- Infer(TypeInfer),
-
- /// A macro in the type position.
- Macro(TypeMacro),
-
- /// The never type: `!`.
- Never(TypeNever),
-
- /// A parenthesized type equivalent to the inner type.
- Paren(TypeParen),
-
- /// A path like `std::slice::Iter`, optionally qualified with a
- /// self-type as in `<Vec<T> as SomeTrait>::Associated`.
- Path(TypePath),
-
- /// A raw pointer type: `*const T` or `*mut T`.
- Ptr(TypePtr),
-
- /// A reference type: `&'a T` or `&'a mut T`.
- Reference(TypeReference),
-
- /// A dynamically sized slice type: `[T]`.
- Slice(TypeSlice),
-
- /// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a
- /// trait or a lifetime.
- TraitObject(TypeTraitObject),
-
- /// A tuple type: `(A, B, C, String)`.
- Tuple(TypeTuple),
-
- /// Tokens in type position not interpreted by Syn.
- Verbatim(TokenStream),
-
- #[doc(hidden)]
- __Nonexhaustive,
- }
-}
-
-ast_struct! {
- /// A fixed size array type: `[T; n]`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeArray {
- pub bracket_token: token::Bracket,
- pub elem: Box<Type>,
- pub semi_token: Token![;],
- pub len: Expr,
- }
-}
-
-ast_struct! {
- /// A bare function type: `fn(usize) -> bool`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeBareFn {
- pub lifetimes: Option<BoundLifetimes>,
- pub unsafety: Option<Token![unsafe]>,
- pub abi: Option<Abi>,
- pub fn_token: Token![fn],
- pub paren_token: token::Paren,
- pub inputs: Punctuated<BareFnArg, Token![,]>,
- pub variadic: Option<Variadic>,
- pub output: ReturnType,
- }
-}
-
-ast_struct! {
- /// A type contained within invisible delimiters.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeGroup {
- pub group_token: token::Group,
- pub elem: Box<Type>,
- }
-}
-
-ast_struct! {
- /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or
- /// a lifetime.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeImplTrait {
- pub impl_token: Token![impl],
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- }
-}
-
-ast_struct! {
- /// Indication that a type should be inferred by the compiler: `_`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeInfer {
- pub underscore_token: Token![_],
- }
-}
-
-ast_struct! {
- /// A macro in the type position.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeMacro {
- pub mac: Macro,
- }
-}
-
-ast_struct! {
- /// The never type: `!`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeNever {
- pub bang_token: Token![!],
- }
-}
-
-ast_struct! {
- /// A parenthesized type equivalent to the inner type.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeParen {
- pub paren_token: token::Paren,
- pub elem: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A path like `std::slice::Iter`, optionally qualified with a
- /// self-type as in `<Vec<T> as SomeTrait>::Associated`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypePath {
- pub qself: Option<QSelf>,
- pub path: Path,
- }
-}
-
-ast_struct! {
- /// A raw pointer type: `*const T` or `*mut T`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypePtr {
- pub star_token: Token![*],
- pub const_token: Option<Token![const]>,
- pub mutability: Option<Token![mut]>,
- pub elem: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A reference type: `&'a T` or `&'a mut T`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeReference {
- pub and_token: Token![&],
- pub lifetime: Option<Lifetime>,
- pub mutability: Option<Token![mut]>,
- pub elem: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A dynamically sized slice type: `[T]`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeSlice {
- pub bracket_token: token::Bracket,
- pub elem: Box<Type>,
- }
-}
-
-ast_struct! {
- /// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a
- /// trait or a lifetime.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeTraitObject {
- pub dyn_token: Option<Token![dyn]>,
- pub bounds: Punctuated<TypeParamBound, Token![+]>,
- }
-}
-
-ast_struct! {
- /// A tuple type: `(A, B, C, String)`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or
- /// `"full"` feature.*
- pub struct TypeTuple {
- pub paren_token: token::Paren,
- pub elems: Punctuated<Type, Token![,]>,
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Eq for Type {}
-
-#[cfg(feature = "extra-traits")]
-impl PartialEq for Type {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (Type::Array(this), Type::Array(other)) => this == other,
- (Type::BareFn(this), Type::BareFn(other)) => this == other,
- (Type::Group(this), Type::Group(other)) => this == other,
- (Type::ImplTrait(this), Type::ImplTrait(other)) => this == other,
- (Type::Infer(this), Type::Infer(other)) => this == other,
- (Type::Macro(this), Type::Macro(other)) => this == other,
- (Type::Never(this), Type::Never(other)) => this == other,
- (Type::Paren(this), Type::Paren(other)) => this == other,
- (Type::Path(this), Type::Path(other)) => this == other,
- (Type::Ptr(this), Type::Ptr(other)) => this == other,
- (Type::Reference(this), Type::Reference(other)) => this == other,
- (Type::Slice(this), Type::Slice(other)) => this == other,
- (Type::TraitObject(this), Type::TraitObject(other)) => this == other,
- (Type::Tuple(this), Type::Tuple(other)) => this == other,
- (Type::Verbatim(this), Type::Verbatim(other)) => {
- TokenStreamHelper(this) == TokenStreamHelper(other)
- }
- _ => false,
- }
- }
-}
-
-#[cfg(feature = "extra-traits")]
-impl Hash for Type {
- fn hash<H>(&self, hash: &mut H)
- where
- H: Hasher,
- {
- match self {
- Type::Array(ty) => {
- hash.write_u8(0);
- ty.hash(hash);
- }
- Type::BareFn(ty) => {
- hash.write_u8(1);
- ty.hash(hash);
- }
- Type::Group(ty) => {
- hash.write_u8(2);
- ty.hash(hash);
- }
- Type::ImplTrait(ty) => {
- hash.write_u8(3);
- ty.hash(hash);
- }
- Type::Infer(ty) => {
- hash.write_u8(4);
- ty.hash(hash);
- }
- Type::Macro(ty) => {
- hash.write_u8(5);
- ty.hash(hash);
- }
- Type::Never(ty) => {
- hash.write_u8(6);
- ty.hash(hash);
- }
- Type::Paren(ty) => {
- hash.write_u8(7);
- ty.hash(hash);
- }
- Type::Path(ty) => {
- hash.write_u8(8);
- ty.hash(hash);
- }
- Type::Ptr(ty) => {
- hash.write_u8(9);
- ty.hash(hash);
- }
- Type::Reference(ty) => {
- hash.write_u8(10);
- ty.hash(hash);
- }
- Type::Slice(ty) => {
- hash.write_u8(11);
- ty.hash(hash);
- }
- Type::TraitObject(ty) => {
- hash.write_u8(12);
- ty.hash(hash);
- }
- Type::Tuple(ty) => {
- hash.write_u8(13);
- ty.hash(hash);
- }
- Type::Verbatim(ty) => {
- hash.write_u8(14);
- TokenStreamHelper(ty).hash(hash);
- }
- Type::__Nonexhaustive => unreachable!(),
- }
- }
-}
-
-ast_struct! {
- /// The binary interface of a function: `extern "C"`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Abi {
- pub extern_token: Token![extern],
- pub name: Option<LitStr>,
- }
-}
-
-ast_struct! {
- /// An argument in a function type: the `usize` in `fn(usize) -> bool`.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct BareFnArg {
- pub attrs: Vec<Attribute>,
- pub name: Option<(Ident, Token![:])>,
- pub ty: Type,
- }
-}
-
-ast_struct! {
- /// The variadic argument of a foreign function.
- ///
- /// ```rust
- /// # struct c_char;
- /// # struct c_int;
- /// #
- /// extern "C" {
- /// fn printf(format: *const c_char, ...) -> c_int;
- /// // ^^^
- /// }
- /// ```
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub struct Variadic {
- pub attrs: Vec<Attribute>,
- pub dots: Token![...],
- }
-}
-
-ast_enum! {
- /// Return type of a function signature.
- ///
- /// *This type is available if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- pub enum ReturnType {
- /// Return type is not specified.
- ///
- /// Functions default to `()` and closures default to type inference.
- Default,
- /// A particular type is returned.
- Type(Token![->], Box<Type>),
- }
-}
-
-#[cfg(feature = "parsing")]
-pub mod parsing {
- use super::*;
-
- use crate::ext::IdentExt;
- use crate::parse::{Parse, ParseStream, Result};
- use crate::path;
- use proc_macro2::{Punct, Spacing, TokenTree};
- use std::iter::FromIterator;
-
- impl Parse for Type {
- fn parse(input: ParseStream) -> Result<Self> {
- ambig_ty(input, true)
- }
- }
-
- impl Type {
- /// In some positions, types may not contain the `+` character, to
- /// disambiguate them. For example in the expression `1 as T`, T may not
- /// contain a `+` character.
- ///
- /// This parser does not allow a `+`, while the default parser does.
- pub fn without_plus(input: ParseStream) -> Result<Self> {
- ambig_ty(input, false)
- }
- }
-
- fn ambig_ty(input: ParseStream, allow_plus: bool) -> Result<Type> {
- if input.peek(token::Group) {
- return input.parse().map(Type::Group);
- }
-
- let mut lifetimes = None::<BoundLifetimes>;
- let mut lookahead = input.lookahead1();
- if lookahead.peek(Token![for]) {
- lifetimes = input.parse()?;
- lookahead = input.lookahead1();
- if !lookahead.peek(Ident)
- && !lookahead.peek(Token![fn])
- && !lookahead.peek(Token![unsafe])
- && !lookahead.peek(Token![extern])
- && !lookahead.peek(Token![super])
- && !lookahead.peek(Token![self])
- && !lookahead.peek(Token![Self])
- && !lookahead.peek(Token![crate])
- {
- return Err(lookahead.error());
- }
- }
-
- if lookahead.peek(token::Paren) {
- let content;
- let paren_token = parenthesized!(content in input);
- if content.is_empty() {
- return Ok(Type::Tuple(TypeTuple {
- paren_token,
- elems: Punctuated::new(),
- }));
- }
- if content.peek(Lifetime) {
- return Ok(Type::Paren(TypeParen {
- paren_token,
- elem: Box::new(Type::TraitObject(content.parse()?)),
- }));
- }
- if content.peek(Token![?]) {
- return Ok(Type::TraitObject(TypeTraitObject {
- dyn_token: None,
- bounds: {
- let mut bounds = Punctuated::new();
- bounds.push_value(TypeParamBound::Trait(TraitBound {
- paren_token: Some(paren_token),
- ..content.parse()?
- }));
- while let Some(plus) = input.parse()? {
- bounds.push_punct(plus);
- bounds.push_value(input.parse()?);
- }
- bounds
- },
- }));
- }
- let mut first: Type = content.parse()?;
- if content.peek(Token![,]) {
- return Ok(Type::Tuple(TypeTuple {
- paren_token,
- elems: {
- let mut elems = Punctuated::new();
- elems.push_value(first);
- elems.push_punct(content.parse()?);
- let rest: Punctuated<Type, Token![,]> =
- content.parse_terminated(Parse::parse)?;
- elems.extend(rest);
- elems
- },
- }));
- }
- if allow_plus && input.peek(Token![+]) {
- loop {
- let first = match first {
- Type::Path(TypePath { qself: None, path }) => {
- TypeParamBound::Trait(TraitBound {
- paren_token: Some(paren_token),
- modifier: TraitBoundModifier::None,
- lifetimes: None,
- path,
- })
- }
- Type::TraitObject(TypeTraitObject {
- dyn_token: None,
- bounds,
- }) => {
- if bounds.len() > 1 || bounds.trailing_punct() {
- first = Type::TraitObject(TypeTraitObject {
- dyn_token: None,
- bounds,
- });
- break;
- }
- match bounds.into_iter().next().unwrap() {
- TypeParamBound::Trait(trait_bound) => {
- TypeParamBound::Trait(TraitBound {
- paren_token: Some(paren_token),
- ..trait_bound
- })
- }
- other => other,
- }
- }
- _ => break,
- };
- return Ok(Type::TraitObject(TypeTraitObject {
- dyn_token: None,
- bounds: {
- let mut bounds = Punctuated::new();
- bounds.push_value(first);
- while let Some(plus) = input.parse()? {
- bounds.push_punct(plus);
- bounds.push_value(input.parse()?);
- }
- bounds
- },
- }));
- }
- }
- Ok(Type::Paren(TypeParen {
- paren_token,
- elem: Box::new(first),
- }))
- } else if lookahead.peek(Token![fn])
- || lookahead.peek(Token![unsafe])
- || lookahead.peek(Token![extern]) && !input.peek2(Token![::])
- {
- let mut bare_fn: TypeBareFn = input.parse()?;
- bare_fn.lifetimes = lifetimes;
- Ok(Type::BareFn(bare_fn))
- } else if lookahead.peek(Ident)
- || input.peek(Token![super])
- || input.peek(Token![self])
- || input.peek(Token![Self])
- || input.peek(Token![crate])
- || input.peek(Token![extern])
- || lookahead.peek(Token![::])
- || lookahead.peek(Token![<])
- {
- if input.peek(Token![dyn]) {
- let mut trait_object: TypeTraitObject = input.parse()?;
- if lifetimes.is_some() {
- match trait_object.bounds.iter_mut().next().unwrap() {
- TypeParamBound::Trait(trait_bound) => {
- trait_bound.lifetimes = lifetimes;
- }
- TypeParamBound::Lifetime(_) => unreachable!(),
- }
- }
- return Ok(Type::TraitObject(trait_object));
- }
-
- let ty: TypePath = input.parse()?;
- if ty.qself.is_some() {
- return Ok(Type::Path(ty));
- }
-
- if input.peek(Token![!]) && !input.peek(Token![!=]) {
- let mut contains_arguments = false;
- for segment in &ty.path.segments {
- match segment.arguments {
- PathArguments::None => {}
- PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => {
- contains_arguments = true;
- }
- }
- }
-
- if !contains_arguments {
- let bang_token: Token![!] = input.parse()?;
- let (delimiter, tokens) = mac::parse_delimiter(input)?;
- return Ok(Type::Macro(TypeMacro {
- mac: Macro {
- path: ty.path,
- bang_token,
- delimiter,
- tokens,
- },
- }));
- }
- }
-
- if lifetimes.is_some() || allow_plus && input.peek(Token![+]) {
- let mut bounds = Punctuated::new();
- bounds.push_value(TypeParamBound::Trait(TraitBound {
- paren_token: None,
- modifier: TraitBoundModifier::None,
- lifetimes,
- path: ty.path,
- }));
- if allow_plus {
- while input.peek(Token![+]) {
- bounds.push_punct(input.parse()?);
- if input.peek(Token![>]) {
- break;
- }
- bounds.push_value(input.parse()?);
- }
- }
- return Ok(Type::TraitObject(TypeTraitObject {
- dyn_token: None,
- bounds,
- }));
- }
-
- Ok(Type::Path(ty))
- } else if lookahead.peek(token::Bracket) {
- let content;
- let bracket_token = bracketed!(content in input);
- let elem: Type = content.parse()?;
- if content.peek(Token![;]) {
- Ok(Type::Array(TypeArray {
- bracket_token,
- elem: Box::new(elem),
- semi_token: content.parse()?,
- len: content.parse()?,
- }))
- } else {
- Ok(Type::Slice(TypeSlice {
- bracket_token,
- elem: Box::new(elem),
- }))
- }
- } else if lookahead.peek(Token![*]) {
- input.parse().map(Type::Ptr)
- } else if lookahead.peek(Token![&]) {
- input.parse().map(Type::Reference)
- } else if lookahead.peek(Token![!]) && !input.peek(Token![=]) {
- input.parse().map(Type::Never)
- } else if lookahead.peek(Token![impl]) {
- input.parse().map(Type::ImplTrait)
- } else if lookahead.peek(Token![_]) {
- input.parse().map(Type::Infer)
- } else if lookahead.peek(Lifetime) {
- input.parse().map(Type::TraitObject)
- } else {
- Err(lookahead.error())
- }
- }
-
- impl Parse for TypeSlice {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- Ok(TypeSlice {
- bracket_token: bracketed!(content in input),
- elem: content.parse()?,
- })
- }
- }
-
- impl Parse for TypeArray {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- Ok(TypeArray {
- bracket_token: bracketed!(content in input),
- elem: content.parse()?,
- semi_token: content.parse()?,
- len: content.parse()?,
- })
- }
- }
-
- impl Parse for TypePtr {
- fn parse(input: ParseStream) -> Result<Self> {
- let star_token: Token![*] = input.parse()?;
-
- let lookahead = input.lookahead1();
- let (const_token, mutability) = if lookahead.peek(Token![const]) {
- (Some(input.parse()?), None)
- } else if lookahead.peek(Token![mut]) {
- (None, Some(input.parse()?))
- } else {
- return Err(lookahead.error());
- };
-
- Ok(TypePtr {
- star_token,
- const_token,
- mutability,
- elem: Box::new(input.call(Type::without_plus)?),
- })
- }
- }
-
- impl Parse for TypeReference {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(TypeReference {
- and_token: input.parse()?,
- lifetime: input.parse()?,
- mutability: input.parse()?,
- // & binds tighter than +, so we don't allow + here.
- elem: Box::new(input.call(Type::without_plus)?),
- })
- }
- }
-
- impl Parse for TypeBareFn {
- fn parse(input: ParseStream) -> Result<Self> {
- let args;
- let mut variadic = None;
- Ok(TypeBareFn {
- lifetimes: input.parse()?,
- unsafety: input.parse()?,
- abi: input.parse()?,
- fn_token: input.parse()?,
- paren_token: parenthesized!(args in input),
- inputs: {
- let mut inputs = Punctuated::new();
-
- while !args.is_empty() {
- let attrs = args.call(Attribute::parse_outer)?;
-
- if inputs.empty_or_trailing() && args.peek(Token![...]) {
- variadic = Some(Variadic {
- attrs,
- dots: args.parse()?,
- });
- break;
- }
-
- inputs.push_value(BareFnArg {
- attrs,
- ..args.parse()?
- });
- if args.is_empty() {
- break;
- }
-
- inputs.push_punct(args.parse()?);
- }
-
- inputs
- },
- variadic,
- output: input.call(ReturnType::without_plus)?,
- })
- }
- }
-
- impl Parse for TypeNever {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(TypeNever {
- bang_token: input.parse()?,
- })
- }
- }
-
- impl Parse for TypeInfer {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(TypeInfer {
- underscore_token: input.parse()?,
- })
- }
- }
-
- impl Parse for TypeTuple {
- fn parse(input: ParseStream) -> Result<Self> {
- let content;
- let paren_token = parenthesized!(content in input);
-
- if content.is_empty() {
- return Ok(TypeTuple {
- paren_token,
- elems: Punctuated::new(),
- });
- }
-
- let first: Type = content.parse()?;
- Ok(TypeTuple {
- paren_token,
- elems: {
- let mut elems = Punctuated::new();
- elems.push_value(first);
- elems.push_punct(content.parse()?);
- let rest: Punctuated<Type, Token![,]> =
- content.parse_terminated(Parse::parse)?;
- elems.extend(rest);
- elems
- },
- })
- }
- }
-
- impl Parse for TypeMacro {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(TypeMacro {
- mac: input.parse()?,
- })
- }
- }
-
- impl Parse for TypePath {
- fn parse(input: ParseStream) -> Result<Self> {
- let (qself, mut path) = path::parsing::qpath(input, false)?;
-
- if path.segments.last().unwrap().arguments.is_empty() && input.peek(token::Paren) {
- let args: ParenthesizedGenericArguments = input.parse()?;
- let parenthesized = PathArguments::Parenthesized(args);
- path.segments.last_mut().unwrap().arguments = parenthesized;
- }
-
- Ok(TypePath { qself, path })
- }
- }
-
- impl ReturnType {
- pub fn without_plus(input: ParseStream) -> Result<Self> {
- Self::parse(input, false)
- }
-
- pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
- if input.peek(Token![->]) {
- let arrow = input.parse()?;
- let ty = ambig_ty(input, allow_plus)?;
- Ok(ReturnType::Type(arrow, Box::new(ty)))
- } else {
- Ok(ReturnType::Default)
- }
- }
- }
-
- impl Parse for ReturnType {
- fn parse(input: ParseStream) -> Result<Self> {
- Self::parse(input, true)
- }
- }
-
- impl Parse for TypeTraitObject {
- fn parse(input: ParseStream) -> Result<Self> {
- Self::parse(input, true)
- }
- }
-
- fn at_least_one_type(bounds: &Punctuated<TypeParamBound, Token![+]>) -> bool {
- for bound in bounds {
- if let TypeParamBound::Trait(_) = *bound {
- return true;
- }
- }
- false
- }
-
- impl TypeTraitObject {
- pub fn without_plus(input: ParseStream) -> Result<Self> {
- Self::parse(input, false)
- }
-
- // Only allow multiple trait references if allow_plus is true.
- pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
- Ok(TypeTraitObject {
- dyn_token: input.parse()?,
- bounds: {
- let mut bounds = Punctuated::new();
- if allow_plus {
- loop {
- bounds.push_value(input.parse()?);
- if !input.peek(Token![+]) {
- break;
- }
- bounds.push_punct(input.parse()?);
- if input.peek(Token![>]) {
- break;
- }
- }
- } else {
- bounds.push_value(input.parse()?);
- }
- // Just lifetimes like `'a + 'b` is not a TraitObject.
- if !at_least_one_type(&bounds) {
- return Err(input.error("expected at least one type"));
- }
- bounds
- },
- })
- }
- }
-
- impl Parse for TypeImplTrait {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(TypeImplTrait {
- impl_token: input.parse()?,
- // NOTE: rust-lang/rust#34511 includes discussion about whether
- // or not + should be allowed in ImplTrait directly without ().
- bounds: {
- let mut bounds = Punctuated::new();
- loop {
- bounds.push_value(input.parse()?);
- if !input.peek(Token![+]) {
- break;
- }
- bounds.push_punct(input.parse()?);
- }
- bounds
- },
- })
- }
- }
-
- impl Parse for TypeGroup {
- fn parse(input: ParseStream) -> Result<Self> {
- let group = crate::group::parse_group(input)?;
- Ok(TypeGroup {
- group_token: group.token,
- elem: group.content.parse()?,
- })
- }
- }
-
- impl Parse for TypeParen {
- fn parse(input: ParseStream) -> Result<Self> {
- Self::parse(input, false)
- }
- }
-
- impl TypeParen {
- fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
- let content;
- Ok(TypeParen {
- paren_token: parenthesized!(content in input),
- elem: Box::new(ambig_ty(&content, allow_plus)?),
- })
- }
- }
-
- impl Parse for BareFnArg {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(BareFnArg {
- attrs: input.call(Attribute::parse_outer)?,
- name: {
- if (input.peek(Ident) || input.peek(Token![_]))
- && input.peek2(Token![:])
- && !input.peek2(Token![::])
- {
- let name = input.call(Ident::parse_any)?;
- let colon: Token![:] = input.parse()?;
- Some((name, colon))
- } else {
- None
- }
- },
- ty: match input.parse::<Option<Token![...]>>()? {
- Some(dot3) => {
- let args = vec![
- TokenTree::Punct(Punct::new('.', Spacing::Joint)),
- TokenTree::Punct(Punct::new('.', Spacing::Joint)),
- TokenTree::Punct(Punct::new('.', Spacing::Alone)),
- ];
- let tokens = TokenStream::from_iter(args.into_iter().zip(&dot3.spans).map(
- |(mut arg, span)| {
- arg.set_span(*span);
- arg
- },
- ));
- Type::Verbatim(tokens)
- }
- None => input.parse()?,
- },
- })
- }
- }
-
- impl Parse for Abi {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(Abi {
- extern_token: input.parse()?,
- name: input.parse()?,
- })
- }
- }
-
- impl Parse for Option<Abi> {
- fn parse(input: ParseStream) -> Result<Self> {
- if input.peek(Token![extern]) {
- input.parse().map(Some)
- } else {
- Ok(None)
- }
- }
- }
-}
-
-#[cfg(feature = "printing")]
-mod printing {
- use super::*;
-
- use proc_macro2::TokenStream;
- use quote::{ToTokens, TokenStreamExt};
-
- use crate::attr::FilterAttrs;
- use crate::print::TokensOrDefault;
-
- impl ToTokens for TypeSlice {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.bracket_token.surround(tokens, |tokens| {
- self.elem.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for TypeArray {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.bracket_token.surround(tokens, |tokens| {
- self.elem.to_tokens(tokens);
- self.semi_token.to_tokens(tokens);
- self.len.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for TypePtr {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.star_token.to_tokens(tokens);
- match &self.mutability {
- Some(tok) => tok.to_tokens(tokens),
- None => {
- TokensOrDefault(&self.const_token).to_tokens(tokens);
- }
- }
- self.elem.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeReference {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.and_token.to_tokens(tokens);
- self.lifetime.to_tokens(tokens);
- self.mutability.to_tokens(tokens);
- self.elem.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeBareFn {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.lifetimes.to_tokens(tokens);
- self.unsafety.to_tokens(tokens);
- self.abi.to_tokens(tokens);
- self.fn_token.to_tokens(tokens);
- self.paren_token.surround(tokens, |tokens| {
- self.inputs.to_tokens(tokens);
- if let Some(variadic) = &self.variadic {
- if !self.inputs.empty_or_trailing() {
- let span = variadic.dots.spans[0];
- Token![,](span).to_tokens(tokens);
- }
- variadic.to_tokens(tokens);
- }
- });
- self.output.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeNever {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.bang_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeTuple {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.paren_token.surround(tokens, |tokens| {
- self.elems.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for TypePath {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- private::print_path(tokens, &self.qself, &self.path);
- }
- }
-
- impl ToTokens for TypeTraitObject {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.dyn_token.to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeImplTrait {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.impl_token.to_tokens(tokens);
- self.bounds.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeGroup {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.group_token.surround(tokens, |tokens| {
- self.elem.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for TypeParen {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.paren_token.surround(tokens, |tokens| {
- self.elem.to_tokens(tokens);
- });
- }
- }
-
- impl ToTokens for TypeInfer {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.underscore_token.to_tokens(tokens);
- }
- }
-
- impl ToTokens for TypeMacro {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.mac.to_tokens(tokens);
- }
- }
-
- impl ToTokens for ReturnType {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- match self {
- ReturnType::Default => {}
- ReturnType::Type(arrow, ty) => {
- arrow.to_tokens(tokens);
- ty.to_tokens(tokens);
- }
- }
- }
- }
-
- impl ToTokens for BareFnArg {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- if let Some((name, colon)) = &self.name {
- name.to_tokens(tokens);
- colon.to_tokens(tokens);
- }
- self.ty.to_tokens(tokens);
- }
- }
-
- impl ToTokens for Variadic {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- tokens.append_all(self.attrs.outer());
- self.dots.to_tokens(tokens);
- }
- }
-
- impl ToTokens for Abi {
- fn to_tokens(&self, tokens: &mut TokenStream) {
- self.extern_token.to_tokens(tokens);
- self.name.to_tokens(tokens);
- }
- }
-}
diff --git a/syn/syn.json b/syn/syn.json
deleted file mode 100644
index c600700..0000000
--- a/syn/syn.json
+++ /dev/null
@@ -1,5616 +0,0 @@
-{
- "version": "1.0.12",
- "types": [
- {
- "ident": "Abi",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "extern_token": {
- "token": "Extern"
- },
- "name": {
- "option": {
- "syn": "LitStr"
- }
- }
- }
- },
- {
- "ident": "AngleBracketedGenericArguments",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "colon2_token": {
- "option": {
- "token": "Colon2"
- }
- },
- "lt_token": {
- "token": "Lt"
- },
- "args": {
- "punctuated": {
- "element": {
- "syn": "GenericArgument"
- },
- "punct": "Comma"
- }
- },
- "gt_token": {
- "token": "Gt"
- }
- }
- },
- {
- "ident": "Arm",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "pat": {
- "syn": "Pat"
- },
- "guard": {
- "option": {
- "tuple": [
- {
- "token": "If"
- },
- {
- "box": {
- "syn": "Expr"
- }
- }
- ]
- }
- },
- "fat_arrow_token": {
- "token": "FatArrow"
- },
- "body": {
- "box": {
- "syn": "Expr"
- }
- },
- "comma": {
- "option": {
- "token": "Comma"
- }
- }
- }
- },
- {
- "ident": "AttrStyle",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Outer": [],
- "Inner": [
- {
- "token": "Bang"
- }
- ]
- }
- },
- {
- "ident": "Attribute",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "pound_token": {
- "token": "Pound"
- },
- "style": {
- "syn": "AttrStyle"
- },
- "bracket_token": {
- "group": "Bracket"
- },
- "path": {
- "syn": "Path"
- },
- "tokens": {
- "proc_macro2": "TokenStream"
- }
- }
- },
- {
- "ident": "BareFnArg",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "name": {
- "option": {
- "tuple": [
- {
- "proc_macro2": "Ident"
- },
- {
- "token": "Colon"
- }
- ]
- }
- },
- "ty": {
- "syn": "Type"
- }
- }
- },
- {
- "ident": "BinOp",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Add": [
- {
- "token": "Add"
- }
- ],
- "Sub": [
- {
- "token": "Sub"
- }
- ],
- "Mul": [
- {
- "token": "Star"
- }
- ],
- "Div": [
- {
- "token": "Div"
- }
- ],
- "Rem": [
- {
- "token": "Rem"
- }
- ],
- "And": [
- {
- "token": "AndAnd"
- }
- ],
- "Or": [
- {
- "token": "OrOr"
- }
- ],
- "BitXor": [
- {
- "token": "Caret"
- }
- ],
- "BitAnd": [
- {
- "token": "And"
- }
- ],
- "BitOr": [
- {
- "token": "Or"
- }
- ],
- "Shl": [
- {
- "token": "Shl"
- }
- ],
- "Shr": [
- {
- "token": "Shr"
- }
- ],
- "Eq": [
- {
- "token": "EqEq"
- }
- ],
- "Lt": [
- {
- "token": "Lt"
- }
- ],
- "Le": [
- {
- "token": "Le"
- }
- ],
- "Ne": [
- {
- "token": "Ne"
- }
- ],
- "Ge": [
- {
- "token": "Ge"
- }
- ],
- "Gt": [
- {
- "token": "Gt"
- }
- ],
- "AddEq": [
- {
- "token": "AddEq"
- }
- ],
- "SubEq": [
- {
- "token": "SubEq"
- }
- ],
- "MulEq": [
- {
- "token": "MulEq"
- }
- ],
- "DivEq": [
- {
- "token": "DivEq"
- }
- ],
- "RemEq": [
- {
- "token": "RemEq"
- }
- ],
- "BitXorEq": [
- {
- "token": "CaretEq"
- }
- ],
- "BitAndEq": [
- {
- "token": "AndEq"
- }
- ],
- "BitOrEq": [
- {
- "token": "OrEq"
- }
- ],
- "ShlEq": [
- {
- "token": "ShlEq"
- }
- ],
- "ShrEq": [
- {
- "token": "ShrEq"
- }
- ]
- }
- },
- {
- "ident": "Binding",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "ident": {
- "proc_macro2": "Ident"
- },
- "eq_token": {
- "token": "Eq"
- },
- "ty": {
- "syn": "Type"
- }
- }
- },
- {
- "ident": "Block",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "brace_token": {
- "group": "Brace"
- },
- "stmts": {
- "vec": {
- "syn": "Stmt"
- }
- }
- }
- },
- {
- "ident": "BoundLifetimes",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "for_token": {
- "token": "For"
- },
- "lt_token": {
- "token": "Lt"
- },
- "lifetimes": {
- "punctuated": {
- "element": {
- "syn": "LifetimeDef"
- },
- "punct": "Comma"
- }
- },
- "gt_token": {
- "token": "Gt"
- }
- }
- },
- {
- "ident": "ConstParam",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "const_token": {
- "token": "Const"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "syn": "Type"
- },
- "eq_token": {
- "option": {
- "token": "Eq"
- }
- },
- "default": {
- "option": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "Constraint",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- }
- }
- },
- {
- "ident": "Data",
- "features": {
- "any": [
- "derive"
- ]
- },
- "variants": {
- "Struct": [
- {
- "syn": "DataStruct"
- }
- ],
- "Enum": [
- {
- "syn": "DataEnum"
- }
- ],
- "Union": [
- {
- "syn": "DataUnion"
- }
- ]
- }
- },
- {
- "ident": "DataEnum",
- "features": {
- "any": [
- "derive"
- ]
- },
- "fields": {
- "enum_token": {
- "token": "Enum"
- },
- "brace_token": {
- "group": "Brace"
- },
- "variants": {
- "punctuated": {
- "element": {
- "syn": "Variant"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "DataStruct",
- "features": {
- "any": [
- "derive"
- ]
- },
- "fields": {
- "struct_token": {
- "token": "Struct"
- },
- "fields": {
- "syn": "Fields"
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "DataUnion",
- "features": {
- "any": [
- "derive"
- ]
- },
- "fields": {
- "union_token": {
- "token": "Union"
- },
- "fields": {
- "syn": "FieldsNamed"
- }
- }
- },
- {
- "ident": "DeriveInput",
- "features": {
- "any": [
- "derive"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "data": {
- "syn": "Data"
- }
- }
- },
- {
- "ident": "Expr",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Array": [
- {
- "syn": "ExprArray"
- }
- ],
- "Assign": [
- {
- "syn": "ExprAssign"
- }
- ],
- "AssignOp": [
- {
- "syn": "ExprAssignOp"
- }
- ],
- "Async": [
- {
- "syn": "ExprAsync"
- }
- ],
- "Await": [
- {
- "syn": "ExprAwait"
- }
- ],
- "Binary": [
- {
- "syn": "ExprBinary"
- }
- ],
- "Block": [
- {
- "syn": "ExprBlock"
- }
- ],
- "Box": [
- {
- "syn": "ExprBox"
- }
- ],
- "Break": [
- {
- "syn": "ExprBreak"
- }
- ],
- "Call": [
- {
- "syn": "ExprCall"
- }
- ],
- "Cast": [
- {
- "syn": "ExprCast"
- }
- ],
- "Closure": [
- {
- "syn": "ExprClosure"
- }
- ],
- "Continue": [
- {
- "syn": "ExprContinue"
- }
- ],
- "Field": [
- {
- "syn": "ExprField"
- }
- ],
- "ForLoop": [
- {
- "syn": "ExprForLoop"
- }
- ],
- "Group": [
- {
- "syn": "ExprGroup"
- }
- ],
- "If": [
- {
- "syn": "ExprIf"
- }
- ],
- "Index": [
- {
- "syn": "ExprIndex"
- }
- ],
- "Let": [
- {
- "syn": "ExprLet"
- }
- ],
- "Lit": [
- {
- "syn": "ExprLit"
- }
- ],
- "Loop": [
- {
- "syn": "ExprLoop"
- }
- ],
- "Macro": [
- {
- "syn": "ExprMacro"
- }
- ],
- "Match": [
- {
- "syn": "ExprMatch"
- }
- ],
- "MethodCall": [
- {
- "syn": "ExprMethodCall"
- }
- ],
- "Paren": [
- {
- "syn": "ExprParen"
- }
- ],
- "Path": [
- {
- "syn": "ExprPath"
- }
- ],
- "Range": [
- {
- "syn": "ExprRange"
- }
- ],
- "Reference": [
- {
- "syn": "ExprReference"
- }
- ],
- "Repeat": [
- {
- "syn": "ExprRepeat"
- }
- ],
- "Return": [
- {
- "syn": "ExprReturn"
- }
- ],
- "Struct": [
- {
- "syn": "ExprStruct"
- }
- ],
- "Try": [
- {
- "syn": "ExprTry"
- }
- ],
- "TryBlock": [
- {
- "syn": "ExprTryBlock"
- }
- ],
- "Tuple": [
- {
- "syn": "ExprTuple"
- }
- ],
- "Type": [
- {
- "syn": "ExprType"
- }
- ],
- "Unary": [
- {
- "syn": "ExprUnary"
- }
- ],
- "Unsafe": [
- {
- "syn": "ExprUnsafe"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ],
- "While": [
- {
- "syn": "ExprWhile"
- }
- ],
- "Yield": [
- {
- "syn": "ExprYield"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "ExprArray",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "bracket_token": {
- "group": "Bracket"
- },
- "elems": {
- "punctuated": {
- "element": {
- "syn": "Expr"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "ExprAssign",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "left": {
- "box": {
- "syn": "Expr"
- }
- },
- "eq_token": {
- "token": "Eq"
- },
- "right": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprAssignOp",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "left": {
- "box": {
- "syn": "Expr"
- }
- },
- "op": {
- "syn": "BinOp"
- },
- "right": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprAsync",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "async_token": {
- "token": "Async"
- },
- "capture": {
- "option": {
- "token": "Move"
- }
- },
- "block": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprAwait",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "base": {
- "box": {
- "syn": "Expr"
- }
- },
- "dot_token": {
- "token": "Dot"
- },
- "await_token": {
- "token": "Await"
- }
- }
- },
- {
- "ident": "ExprBinary",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "left": {
- "box": {
- "syn": "Expr"
- }
- },
- "op": {
- "syn": "BinOp"
- },
- "right": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprBlock",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "label": {
- "option": {
- "syn": "Label"
- }
- },
- "block": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprBox",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "box_token": {
- "token": "Box"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprBreak",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "break_token": {
- "token": "Break"
- },
- "label": {
- "option": {
- "syn": "Lifetime"
- }
- },
- "expr": {
- "option": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- }
- },
- {
- "ident": "ExprCall",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "func": {
- "box": {
- "syn": "Expr"
- }
- },
- "paren_token": {
- "group": "Paren"
- },
- "args": {
- "punctuated": {
- "element": {
- "syn": "Expr"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "ExprCast",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "as_token": {
- "token": "As"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "ExprClosure",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "asyncness": {
- "option": {
- "token": "Async"
- }
- },
- "movability": {
- "option": {
- "token": "Static"
- }
- },
- "capture": {
- "option": {
- "token": "Move"
- }
- },
- "or1_token": {
- "token": "Or"
- },
- "inputs": {
- "punctuated": {
- "element": {
- "syn": "Pat"
- },
- "punct": "Comma"
- }
- },
- "or2_token": {
- "token": "Or"
- },
- "output": {
- "syn": "ReturnType"
- },
- "body": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprContinue",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "continue_token": {
- "token": "Continue"
- },
- "label": {
- "option": {
- "syn": "Lifetime"
- }
- }
- }
- },
- {
- "ident": "ExprField",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "base": {
- "box": {
- "syn": "Expr"
- }
- },
- "dot_token": {
- "token": "Dot"
- },
- "member": {
- "syn": "Member"
- }
- }
- },
- {
- "ident": "ExprForLoop",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "label": {
- "option": {
- "syn": "Label"
- }
- },
- "for_token": {
- "token": "For"
- },
- "pat": {
- "syn": "Pat"
- },
- "in_token": {
- "token": "In"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "body": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprGroup",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "group_token": {
- "group": "Group"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprIf",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "if_token": {
- "token": "If"
- },
- "cond": {
- "box": {
- "syn": "Expr"
- }
- },
- "then_branch": {
- "syn": "Block"
- },
- "else_branch": {
- "option": {
- "tuple": [
- {
- "token": "Else"
- },
- {
- "box": {
- "syn": "Expr"
- }
- }
- ]
- }
- }
- }
- },
- {
- "ident": "ExprIndex",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "bracket_token": {
- "group": "Bracket"
- },
- "index": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprLet",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "let_token": {
- "token": "Let"
- },
- "pat": {
- "syn": "Pat"
- },
- "eq_token": {
- "token": "Eq"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprLit",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "lit": {
- "syn": "Lit"
- }
- }
- },
- {
- "ident": "ExprLoop",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "label": {
- "option": {
- "syn": "Label"
- }
- },
- "loop_token": {
- "token": "Loop"
- },
- "body": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprMacro",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "mac": {
- "syn": "Macro"
- }
- }
- },
- {
- "ident": "ExprMatch",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "match_token": {
- "token": "Match"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "brace_token": {
- "group": "Brace"
- },
- "arms": {
- "vec": {
- "syn": "Arm"
- }
- }
- }
- },
- {
- "ident": "ExprMethodCall",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "receiver": {
- "box": {
- "syn": "Expr"
- }
- },
- "dot_token": {
- "token": "Dot"
- },
- "method": {
- "proc_macro2": "Ident"
- },
- "turbofish": {
- "option": {
- "syn": "MethodTurbofish"
- }
- },
- "paren_token": {
- "group": "Paren"
- },
- "args": {
- "punctuated": {
- "element": {
- "syn": "Expr"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "ExprParen",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "paren_token": {
- "group": "Paren"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprPath",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "qself": {
- "option": {
- "syn": "QSelf"
- }
- },
- "path": {
- "syn": "Path"
- }
- }
- },
- {
- "ident": "ExprRange",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "from": {
- "option": {
- "box": {
- "syn": "Expr"
- }
- }
- },
- "limits": {
- "syn": "RangeLimits"
- },
- "to": {
- "option": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- }
- },
- {
- "ident": "ExprReference",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "and_token": {
- "token": "And"
- },
- "raw": {
- "syn": "Reserved"
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprRepeat",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "bracket_token": {
- "group": "Bracket"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "semi_token": {
- "token": "Semi"
- },
- "len": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprReturn",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "return_token": {
- "token": "Return"
- },
- "expr": {
- "option": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- }
- },
- {
- "ident": "ExprStruct",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "path": {
- "syn": "Path"
- },
- "brace_token": {
- "group": "Brace"
- },
- "fields": {
- "punctuated": {
- "element": {
- "syn": "FieldValue"
- },
- "punct": "Comma"
- }
- },
- "dot2_token": {
- "option": {
- "token": "Dot2"
- }
- },
- "rest": {
- "option": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- }
- },
- {
- "ident": "ExprTry",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "question_token": {
- "token": "Question"
- }
- }
- },
- {
- "ident": "ExprTryBlock",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "try_token": {
- "token": "Try"
- },
- "block": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprTuple",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "paren_token": {
- "group": "Paren"
- },
- "elems": {
- "punctuated": {
- "element": {
- "syn": "Expr"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "ExprType",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "ExprUnary",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "op": {
- "syn": "UnOp"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "ExprUnsafe",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "unsafe_token": {
- "token": "Unsafe"
- },
- "block": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprWhile",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "label": {
- "option": {
- "syn": "Label"
- }
- },
- "while_token": {
- "token": "While"
- },
- "cond": {
- "box": {
- "syn": "Expr"
- }
- },
- "body": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ExprYield",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "yield_token": {
- "token": "Yield"
- },
- "expr": {
- "option": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- }
- },
- {
- "ident": "Field",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "ident": {
- "option": {
- "proc_macro2": "Ident"
- }
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "ty": {
- "syn": "Type"
- }
- }
- },
- {
- "ident": "FieldPat",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "member": {
- "syn": "Member"
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "pat": {
- "box": {
- "syn": "Pat"
- }
- }
- }
- },
- {
- "ident": "FieldValue",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "member": {
- "syn": "Member"
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "expr": {
- "syn": "Expr"
- }
- }
- },
- {
- "ident": "Fields",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Named": [
- {
- "syn": "FieldsNamed"
- }
- ],
- "Unnamed": [
- {
- "syn": "FieldsUnnamed"
- }
- ],
- "Unit": []
- }
- },
- {
- "ident": "FieldsNamed",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "brace_token": {
- "group": "Brace"
- },
- "named": {
- "punctuated": {
- "element": {
- "syn": "Field"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "FieldsUnnamed",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "paren_token": {
- "group": "Paren"
- },
- "unnamed": {
- "punctuated": {
- "element": {
- "syn": "Field"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "File",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "shebang": {
- "option": {
- "std": "String"
- }
- },
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "items": {
- "vec": {
- "syn": "Item"
- }
- }
- }
- },
- {
- "ident": "FnArg",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Receiver": [
- {
- "syn": "Receiver"
- }
- ],
- "Typed": [
- {
- "syn": "PatType"
- }
- ]
- }
- },
- {
- "ident": "ForeignItem",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Fn": [
- {
- "syn": "ForeignItemFn"
- }
- ],
- "Static": [
- {
- "syn": "ForeignItemStatic"
- }
- ],
- "Type": [
- {
- "syn": "ForeignItemType"
- }
- ],
- "Macro": [
- {
- "syn": "ForeignItemMacro"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "ForeignItemFn",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "sig": {
- "syn": "Signature"
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ForeignItemMacro",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "mac": {
- "syn": "Macro"
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "ForeignItemStatic",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "static_token": {
- "token": "Static"
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ForeignItemType",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "type_token": {
- "token": "Type"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "GenericArgument",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Lifetime": [
- {
- "syn": "Lifetime"
- }
- ],
- "Type": [
- {
- "syn": "Type"
- }
- ],
- "Binding": [
- {
- "syn": "Binding"
- }
- ],
- "Constraint": [
- {
- "syn": "Constraint"
- }
- ],
- "Const": [
- {
- "syn": "Expr"
- }
- ]
- }
- },
- {
- "ident": "GenericMethodArgument",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Type": [
- {
- "syn": "Type"
- }
- ],
- "Const": [
- {
- "syn": "Expr"
- }
- ]
- }
- },
- {
- "ident": "GenericParam",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Type": [
- {
- "syn": "TypeParam"
- }
- ],
- "Lifetime": [
- {
- "syn": "LifetimeDef"
- }
- ],
- "Const": [
- {
- "syn": "ConstParam"
- }
- ]
- }
- },
- {
- "ident": "Generics",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "lt_token": {
- "option": {
- "token": "Lt"
- }
- },
- "params": {
- "punctuated": {
- "element": {
- "syn": "GenericParam"
- },
- "punct": "Comma"
- }
- },
- "gt_token": {
- "option": {
- "token": "Gt"
- }
- },
- "where_clause": {
- "option": {
- "syn": "WhereClause"
- }
- }
- }
- },
- {
- "ident": "ImplItem",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Const": [
- {
- "syn": "ImplItemConst"
- }
- ],
- "Method": [
- {
- "syn": "ImplItemMethod"
- }
- ],
- "Type": [
- {
- "syn": "ImplItemType"
- }
- ],
- "Macro": [
- {
- "syn": "ImplItemMacro"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "ImplItemConst",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "defaultness": {
- "option": {
- "token": "Default"
- }
- },
- "const_token": {
- "token": "Const"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "syn": "Type"
- },
- "eq_token": {
- "token": "Eq"
- },
- "expr": {
- "syn": "Expr"
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ImplItemMacro",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "mac": {
- "syn": "Macro"
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "ImplItemMethod",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "defaultness": {
- "option": {
- "token": "Default"
- }
- },
- "sig": {
- "syn": "Signature"
- },
- "block": {
- "syn": "Block"
- }
- }
- },
- {
- "ident": "ImplItemType",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "defaultness": {
- "option": {
- "token": "Default"
- }
- },
- "type_token": {
- "token": "Type"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "eq_token": {
- "token": "Eq"
- },
- "ty": {
- "syn": "Type"
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "Index",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "index": {
- "std": "u32"
- },
- "span": {
- "proc_macro2": "Span"
- }
- }
- },
- {
- "ident": "Item",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Const": [
- {
- "syn": "ItemConst"
- }
- ],
- "Enum": [
- {
- "syn": "ItemEnum"
- }
- ],
- "ExternCrate": [
- {
- "syn": "ItemExternCrate"
- }
- ],
- "Fn": [
- {
- "syn": "ItemFn"
- }
- ],
- "ForeignMod": [
- {
- "syn": "ItemForeignMod"
- }
- ],
- "Impl": [
- {
- "syn": "ItemImpl"
- }
- ],
- "Macro": [
- {
- "syn": "ItemMacro"
- }
- ],
- "Macro2": [
- {
- "syn": "ItemMacro2"
- }
- ],
- "Mod": [
- {
- "syn": "ItemMod"
- }
- ],
- "Static": [
- {
- "syn": "ItemStatic"
- }
- ],
- "Struct": [
- {
- "syn": "ItemStruct"
- }
- ],
- "Trait": [
- {
- "syn": "ItemTrait"
- }
- ],
- "TraitAlias": [
- {
- "syn": "ItemTraitAlias"
- }
- ],
- "Type": [
- {
- "syn": "ItemType"
- }
- ],
- "Union": [
- {
- "syn": "ItemUnion"
- }
- ],
- "Use": [
- {
- "syn": "ItemUse"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "ItemConst",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "const_token": {
- "token": "Const"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- },
- "eq_token": {
- "token": "Eq"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ItemEnum",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "enum_token": {
- "token": "Enum"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "brace_token": {
- "group": "Brace"
- },
- "variants": {
- "punctuated": {
- "element": {
- "syn": "Variant"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "ItemExternCrate",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "extern_token": {
- "token": "Extern"
- },
- "crate_token": {
- "token": "Crate"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "rename": {
- "option": {
- "tuple": [
- {
- "token": "As"
- },
- {
- "proc_macro2": "Ident"
- }
- ]
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ItemFn",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "sig": {
- "syn": "Signature"
- },
- "block": {
- "box": {
- "syn": "Block"
- }
- }
- }
- },
- {
- "ident": "ItemForeignMod",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "abi": {
- "syn": "Abi"
- },
- "brace_token": {
- "group": "Brace"
- },
- "items": {
- "vec": {
- "syn": "ForeignItem"
- }
- }
- }
- },
- {
- "ident": "ItemImpl",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "defaultness": {
- "option": {
- "token": "Default"
- }
- },
- "unsafety": {
- "option": {
- "token": "Unsafe"
- }
- },
- "impl_token": {
- "token": "Impl"
- },
- "generics": {
- "syn": "Generics"
- },
- "trait_": {
- "option": {
- "tuple": [
- {
- "option": {
- "token": "Bang"
- }
- },
- {
- "syn": "Path"
- },
- {
- "token": "For"
- }
- ]
- }
- },
- "self_ty": {
- "box": {
- "syn": "Type"
- }
- },
- "brace_token": {
- "group": "Brace"
- },
- "items": {
- "vec": {
- "syn": "ImplItem"
- }
- }
- }
- },
- {
- "ident": "ItemMacro",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "ident": {
- "option": {
- "proc_macro2": "Ident"
- }
- },
- "mac": {
- "syn": "Macro"
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "ItemMacro2",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "macro_token": {
- "token": "Macro"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "rules": {
- "proc_macro2": "TokenStream"
- }
- }
- },
- {
- "ident": "ItemMod",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "mod_token": {
- "token": "Mod"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "content": {
- "option": {
- "tuple": [
- {
- "group": "Brace"
- },
- {
- "vec": {
- "syn": "Item"
- }
- }
- ]
- }
- },
- "semi": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "ItemStatic",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "static_token": {
- "token": "Static"
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- },
- "eq_token": {
- "token": "Eq"
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ItemStruct",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "struct_token": {
- "token": "Struct"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "fields": {
- "syn": "Fields"
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "ItemTrait",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "unsafety": {
- "option": {
- "token": "Unsafe"
- }
- },
- "auto_token": {
- "option": {
- "token": "Auto"
- }
- },
- "trait_token": {
- "token": "Trait"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "supertraits": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- },
- "brace_token": {
- "group": "Brace"
- },
- "items": {
- "vec": {
- "syn": "TraitItem"
- }
- }
- }
- },
- {
- "ident": "ItemTraitAlias",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "trait_token": {
- "token": "Trait"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "eq_token": {
- "token": "Eq"
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ItemType",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "type_token": {
- "token": "Type"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "eq_token": {
- "token": "Eq"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "ItemUnion",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "union_token": {
- "token": "Union"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "fields": {
- "syn": "FieldsNamed"
- }
- }
- },
- {
- "ident": "ItemUse",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "vis": {
- "syn": "Visibility"
- },
- "use_token": {
- "token": "Use"
- },
- "leading_colon": {
- "option": {
- "token": "Colon2"
- }
- },
- "tree": {
- "syn": "UseTree"
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "Label",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "name": {
- "syn": "Lifetime"
- },
- "colon_token": {
- "token": "Colon"
- }
- }
- },
- {
- "ident": "Lifetime",
- "features": {
- "any": []
- },
- "fields": {
- "apostrophe": {
- "proc_macro2": "Span"
- },
- "ident": {
- "proc_macro2": "Ident"
- }
- }
- },
- {
- "ident": "LifetimeDef",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "lifetime": {
- "syn": "Lifetime"
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "Lifetime"
- },
- "punct": "Add"
- }
- }
- }
- },
- {
- "ident": "Lit",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Str": [
- {
- "syn": "LitStr"
- }
- ],
- "ByteStr": [
- {
- "syn": "LitByteStr"
- }
- ],
- "Byte": [
- {
- "syn": "LitByte"
- }
- ],
- "Char": [
- {
- "syn": "LitChar"
- }
- ],
- "Int": [
- {
- "syn": "LitInt"
- }
- ],
- "Float": [
- {
- "syn": "LitFloat"
- }
- ],
- "Bool": [
- {
- "syn": "LitBool"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "Literal"
- }
- ]
- }
- },
- {
- "ident": "LitBool",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "value": {
- "std": "bool"
- },
- "span": {
- "proc_macro2": "Span"
- }
- }
- },
- {
- "ident": "LitByte",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- }
- },
- {
- "ident": "LitByteStr",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- }
- },
- {
- "ident": "LitChar",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- }
- },
- {
- "ident": "LitFloat",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- }
- },
- {
- "ident": "LitInt",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- }
- },
- {
- "ident": "LitStr",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- }
- },
- {
- "ident": "Local",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "let_token": {
- "token": "Let"
- },
- "pat": {
- "syn": "Pat"
- },
- "init": {
- "option": {
- "tuple": [
- {
- "token": "Eq"
- },
- {
- "box": {
- "syn": "Expr"
- }
- }
- ]
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "Macro",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "path": {
- "syn": "Path"
- },
- "bang_token": {
- "token": "Bang"
- },
- "delimiter": {
- "syn": "MacroDelimiter"
- },
- "tokens": {
- "proc_macro2": "TokenStream"
- }
- }
- },
- {
- "ident": "MacroDelimiter",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Paren": [
- {
- "group": "Paren"
- }
- ],
- "Brace": [
- {
- "group": "Brace"
- }
- ],
- "Bracket": [
- {
- "group": "Bracket"
- }
- ]
- }
- },
- {
- "ident": "Member",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Named": [
- {
- "proc_macro2": "Ident"
- }
- ],
- "Unnamed": [
- {
- "syn": "Index"
- }
- ]
- }
- },
- {
- "ident": "Meta",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Path": [
- {
- "syn": "Path"
- }
- ],
- "List": [
- {
- "syn": "MetaList"
- }
- ],
- "NameValue": [
- {
- "syn": "MetaNameValue"
- }
- ]
- }
- },
- {
- "ident": "MetaList",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "path": {
- "syn": "Path"
- },
- "paren_token": {
- "group": "Paren"
- },
- "nested": {
- "punctuated": {
- "element": {
- "syn": "NestedMeta"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "MetaNameValue",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "path": {
- "syn": "Path"
- },
- "eq_token": {
- "token": "Eq"
- },
- "lit": {
- "syn": "Lit"
- }
- }
- },
- {
- "ident": "MethodTurbofish",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "colon2_token": {
- "token": "Colon2"
- },
- "lt_token": {
- "token": "Lt"
- },
- "args": {
- "punctuated": {
- "element": {
- "syn": "GenericMethodArgument"
- },
- "punct": "Comma"
- }
- },
- "gt_token": {
- "token": "Gt"
- }
- }
- },
- {
- "ident": "NestedMeta",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Meta": [
- {
- "syn": "Meta"
- }
- ],
- "Lit": [
- {
- "syn": "Lit"
- }
- ]
- }
- },
- {
- "ident": "ParenthesizedGenericArguments",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "paren_token": {
- "group": "Paren"
- },
- "inputs": {
- "punctuated": {
- "element": {
- "syn": "Type"
- },
- "punct": "Comma"
- }
- },
- "output": {
- "syn": "ReturnType"
- }
- }
- },
- {
- "ident": "Pat",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Box": [
- {
- "syn": "PatBox"
- }
- ],
- "Ident": [
- {
- "syn": "PatIdent"
- }
- ],
- "Lit": [
- {
- "syn": "PatLit"
- }
- ],
- "Macro": [
- {
- "syn": "PatMacro"
- }
- ],
- "Or": [
- {
- "syn": "PatOr"
- }
- ],
- "Path": [
- {
- "syn": "PatPath"
- }
- ],
- "Range": [
- {
- "syn": "PatRange"
- }
- ],
- "Reference": [
- {
- "syn": "PatReference"
- }
- ],
- "Rest": [
- {
- "syn": "PatRest"
- }
- ],
- "Slice": [
- {
- "syn": "PatSlice"
- }
- ],
- "Struct": [
- {
- "syn": "PatStruct"
- }
- ],
- "Tuple": [
- {
- "syn": "PatTuple"
- }
- ],
- "TupleStruct": [
- {
- "syn": "PatTupleStruct"
- }
- ],
- "Type": [
- {
- "syn": "PatType"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ],
- "Wild": [
- {
- "syn": "PatWild"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "PatBox",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "box_token": {
- "token": "Box"
- },
- "pat": {
- "box": {
- "syn": "Pat"
- }
- }
- }
- },
- {
- "ident": "PatIdent",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "by_ref": {
- "option": {
- "token": "Ref"
- }
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "subpat": {
- "option": {
- "tuple": [
- {
- "token": "At"
- },
- {
- "box": {
- "syn": "Pat"
- }
- }
- ]
- }
- }
- }
- },
- {
- "ident": "PatLit",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "expr": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "PatMacro",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "mac": {
- "syn": "Macro"
- }
- }
- },
- {
- "ident": "PatOr",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "leading_vert": {
- "option": {
- "token": "Or"
- }
- },
- "cases": {
- "punctuated": {
- "element": {
- "syn": "Pat"
- },
- "punct": "Or"
- }
- }
- }
- },
- {
- "ident": "PatPath",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "qself": {
- "option": {
- "syn": "QSelf"
- }
- },
- "path": {
- "syn": "Path"
- }
- }
- },
- {
- "ident": "PatRange",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "lo": {
- "box": {
- "syn": "Expr"
- }
- },
- "limits": {
- "syn": "RangeLimits"
- },
- "hi": {
- "box": {
- "syn": "Expr"
- }
- }
- }
- },
- {
- "ident": "PatReference",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "and_token": {
- "token": "And"
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "pat": {
- "box": {
- "syn": "Pat"
- }
- }
- }
- },
- {
- "ident": "PatRest",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "dot2_token": {
- "token": "Dot2"
- }
- }
- },
- {
- "ident": "PatSlice",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "bracket_token": {
- "group": "Bracket"
- },
- "elems": {
- "punctuated": {
- "element": {
- "syn": "Pat"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "PatStruct",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "path": {
- "syn": "Path"
- },
- "brace_token": {
- "group": "Brace"
- },
- "fields": {
- "punctuated": {
- "element": {
- "syn": "FieldPat"
- },
- "punct": "Comma"
- }
- },
- "dot2_token": {
- "option": {
- "token": "Dot2"
- }
- }
- }
- },
- {
- "ident": "PatTuple",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "paren_token": {
- "group": "Paren"
- },
- "elems": {
- "punctuated": {
- "element": {
- "syn": "Pat"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "PatTupleStruct",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "path": {
- "syn": "Path"
- },
- "pat": {
- "syn": "PatTuple"
- }
- }
- },
- {
- "ident": "PatType",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "pat": {
- "box": {
- "syn": "Pat"
- }
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "PatWild",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "underscore_token": {
- "token": "Underscore"
- }
- }
- },
- {
- "ident": "Path",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "leading_colon": {
- "option": {
- "token": "Colon2"
- }
- },
- "segments": {
- "punctuated": {
- "element": {
- "syn": "PathSegment"
- },
- "punct": "Colon2"
- }
- }
- }
- },
- {
- "ident": "PathArguments",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "None": [],
- "AngleBracketed": [
- {
- "syn": "AngleBracketedGenericArguments"
- }
- ],
- "Parenthesized": [
- {
- "syn": "ParenthesizedGenericArguments"
- }
- ]
- }
- },
- {
- "ident": "PathSegment",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "ident": {
- "proc_macro2": "Ident"
- },
- "arguments": {
- "syn": "PathArguments"
- }
- }
- },
- {
- "ident": "PredicateEq",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "lhs_ty": {
- "syn": "Type"
- },
- "eq_token": {
- "token": "Eq"
- },
- "rhs_ty": {
- "syn": "Type"
- }
- }
- },
- {
- "ident": "PredicateLifetime",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "lifetime": {
- "syn": "Lifetime"
- },
- "colon_token": {
- "token": "Colon"
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "Lifetime"
- },
- "punct": "Add"
- }
- }
- }
- },
- {
- "ident": "PredicateType",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "lifetimes": {
- "option": {
- "syn": "BoundLifetimes"
- }
- },
- "bounded_ty": {
- "syn": "Type"
- },
- "colon_token": {
- "token": "Colon"
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- }
- }
- },
- {
- "ident": "QSelf",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "lt_token": {
- "token": "Lt"
- },
- "ty": {
- "box": {
- "syn": "Type"
- }
- },
- "position": {
- "std": "usize"
- },
- "as_token": {
- "option": {
- "token": "As"
- }
- },
- "gt_token": {
- "token": "Gt"
- }
- }
- },
- {
- "ident": "RangeLimits",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "HalfOpen": [
- {
- "token": "Dot2"
- }
- ],
- "Closed": [
- {
- "token": "DotDotEq"
- }
- ]
- }
- },
- {
- "ident": "Receiver",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "reference": {
- "option": {
- "tuple": [
- {
- "token": "And"
- },
- {
- "option": {
- "syn": "Lifetime"
- }
- }
- ]
- }
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "self_token": {
- "token": "SelfValue"
- }
- }
- },
- {
- "ident": "ReturnType",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Default": [],
- "Type": [
- {
- "token": "RArrow"
- },
- {
- "box": {
- "syn": "Type"
- }
- }
- ]
- }
- },
- {
- "ident": "Signature",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "constness": {
- "option": {
- "token": "Const"
- }
- },
- "asyncness": {
- "option": {
- "token": "Async"
- }
- },
- "unsafety": {
- "option": {
- "token": "Unsafe"
- }
- },
- "abi": {
- "option": {
- "syn": "Abi"
- }
- },
- "fn_token": {
- "token": "Fn"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "paren_token": {
- "group": "Paren"
- },
- "inputs": {
- "punctuated": {
- "element": {
- "syn": "FnArg"
- },
- "punct": "Comma"
- }
- },
- "variadic": {
- "option": {
- "syn": "Variadic"
- }
- },
- "output": {
- "syn": "ReturnType"
- }
- }
- },
- {
- "ident": "Stmt",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Local": [
- {
- "syn": "Local"
- }
- ],
- "Item": [
- {
- "syn": "Item"
- }
- ],
- "Expr": [
- {
- "syn": "Expr"
- }
- ],
- "Semi": [
- {
- "syn": "Expr"
- },
- {
- "token": "Semi"
- }
- ]
- }
- },
- {
- "ident": "TraitBound",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "paren_token": {
- "option": {
- "group": "Paren"
- }
- },
- "modifier": {
- "syn": "TraitBoundModifier"
- },
- "lifetimes": {
- "option": {
- "syn": "BoundLifetimes"
- }
- },
- "path": {
- "syn": "Path"
- }
- }
- },
- {
- "ident": "TraitBoundModifier",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "None": [],
- "Maybe": [
- {
- "token": "Question"
- }
- ]
- }
- },
- {
- "ident": "TraitItem",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Const": [
- {
- "syn": "TraitItemConst"
- }
- ],
- "Method": [
- {
- "syn": "TraitItemMethod"
- }
- ],
- "Type": [
- {
- "syn": "TraitItemType"
- }
- ],
- "Macro": [
- {
- "syn": "TraitItemMacro"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "TraitItemConst",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "const_token": {
- "token": "Const"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "token": "Colon"
- },
- "ty": {
- "syn": "Type"
- },
- "default": {
- "option": {
- "tuple": [
- {
- "token": "Eq"
- },
- {
- "syn": "Expr"
- }
- ]
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "TraitItemMacro",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "mac": {
- "syn": "Macro"
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "TraitItemMethod",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "sig": {
- "syn": "Signature"
- },
- "default": {
- "option": {
- "syn": "Block"
- }
- },
- "semi_token": {
- "option": {
- "token": "Semi"
- }
- }
- }
- },
- {
- "ident": "TraitItemType",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "type_token": {
- "token": "Type"
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "generics": {
- "syn": "Generics"
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- },
- "default": {
- "option": {
- "tuple": [
- {
- "token": "Eq"
- },
- {
- "syn": "Type"
- }
- ]
- }
- },
- "semi_token": {
- "token": "Semi"
- }
- }
- },
- {
- "ident": "Type",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Array": [
- {
- "syn": "TypeArray"
- }
- ],
- "BareFn": [
- {
- "syn": "TypeBareFn"
- }
- ],
- "Group": [
- {
- "syn": "TypeGroup"
- }
- ],
- "ImplTrait": [
- {
- "syn": "TypeImplTrait"
- }
- ],
- "Infer": [
- {
- "syn": "TypeInfer"
- }
- ],
- "Macro": [
- {
- "syn": "TypeMacro"
- }
- ],
- "Never": [
- {
- "syn": "TypeNever"
- }
- ],
- "Paren": [
- {
- "syn": "TypeParen"
- }
- ],
- "Path": [
- {
- "syn": "TypePath"
- }
- ],
- "Ptr": [
- {
- "syn": "TypePtr"
- }
- ],
- "Reference": [
- {
- "syn": "TypeReference"
- }
- ],
- "Slice": [
- {
- "syn": "TypeSlice"
- }
- ],
- "TraitObject": [
- {
- "syn": "TypeTraitObject"
- }
- ],
- "Tuple": [
- {
- "syn": "TypeTuple"
- }
- ],
- "Verbatim": [
- {
- "proc_macro2": "TokenStream"
- }
- ]
- },
- "exhaustive": false
- },
- {
- "ident": "TypeArray",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "bracket_token": {
- "group": "Bracket"
- },
- "elem": {
- "box": {
- "syn": "Type"
- }
- },
- "semi_token": {
- "token": "Semi"
- },
- "len": {
- "syn": "Expr"
- }
- }
- },
- {
- "ident": "TypeBareFn",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "lifetimes": {
- "option": {
- "syn": "BoundLifetimes"
- }
- },
- "unsafety": {
- "option": {
- "token": "Unsafe"
- }
- },
- "abi": {
- "option": {
- "syn": "Abi"
- }
- },
- "fn_token": {
- "token": "Fn"
- },
- "paren_token": {
- "group": "Paren"
- },
- "inputs": {
- "punctuated": {
- "element": {
- "syn": "BareFnArg"
- },
- "punct": "Comma"
- }
- },
- "variadic": {
- "option": {
- "syn": "Variadic"
- }
- },
- "output": {
- "syn": "ReturnType"
- }
- }
- },
- {
- "ident": "TypeGroup",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "group_token": {
- "group": "Group"
- },
- "elem": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "TypeImplTrait",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "impl_token": {
- "token": "Impl"
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- }
- }
- },
- {
- "ident": "TypeInfer",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "underscore_token": {
- "token": "Underscore"
- }
- }
- },
- {
- "ident": "TypeMacro",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "mac": {
- "syn": "Macro"
- }
- }
- },
- {
- "ident": "TypeNever",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "bang_token": {
- "token": "Bang"
- }
- }
- },
- {
- "ident": "TypeParam",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon_token": {
- "option": {
- "token": "Colon"
- }
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- },
- "eq_token": {
- "option": {
- "token": "Eq"
- }
- },
- "default": {
- "option": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "TypeParamBound",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Trait": [
- {
- "syn": "TraitBound"
- }
- ],
- "Lifetime": [
- {
- "syn": "Lifetime"
- }
- ]
- }
- },
- {
- "ident": "TypeParen",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "paren_token": {
- "group": "Paren"
- },
- "elem": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "TypePath",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "qself": {
- "option": {
- "syn": "QSelf"
- }
- },
- "path": {
- "syn": "Path"
- }
- }
- },
- {
- "ident": "TypePtr",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "star_token": {
- "token": "Star"
- },
- "const_token": {
- "option": {
- "token": "Const"
- }
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "elem": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "TypeReference",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "and_token": {
- "token": "And"
- },
- "lifetime": {
- "option": {
- "syn": "Lifetime"
- }
- },
- "mutability": {
- "option": {
- "token": "Mut"
- }
- },
- "elem": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "TypeSlice",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "bracket_token": {
- "group": "Bracket"
- },
- "elem": {
- "box": {
- "syn": "Type"
- }
- }
- }
- },
- {
- "ident": "TypeTraitObject",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "dyn_token": {
- "option": {
- "token": "Dyn"
- }
- },
- "bounds": {
- "punctuated": {
- "element": {
- "syn": "TypeParamBound"
- },
- "punct": "Add"
- }
- }
- }
- },
- {
- "ident": "TypeTuple",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "paren_token": {
- "group": "Paren"
- },
- "elems": {
- "punctuated": {
- "element": {
- "syn": "Type"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "UnOp",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Deref": [
- {
- "token": "Star"
- }
- ],
- "Not": [
- {
- "token": "Bang"
- }
- ],
- "Neg": [
- {
- "token": "Sub"
- }
- ]
- }
- },
- {
- "ident": "UseGlob",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "star_token": {
- "token": "Star"
- }
- }
- },
- {
- "ident": "UseGroup",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "brace_token": {
- "group": "Brace"
- },
- "items": {
- "punctuated": {
- "element": {
- "syn": "UseTree"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "UseName",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "ident": {
- "proc_macro2": "Ident"
- }
- }
- },
- {
- "ident": "UsePath",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "ident": {
- "proc_macro2": "Ident"
- },
- "colon2_token": {
- "token": "Colon2"
- },
- "tree": {
- "box": {
- "syn": "UseTree"
- }
- }
- }
- },
- {
- "ident": "UseRename",
- "features": {
- "any": [
- "full"
- ]
- },
- "fields": {
- "ident": {
- "proc_macro2": "Ident"
- },
- "as_token": {
- "token": "As"
- },
- "rename": {
- "proc_macro2": "Ident"
- }
- }
- },
- {
- "ident": "UseTree",
- "features": {
- "any": [
- "full"
- ]
- },
- "variants": {
- "Path": [
- {
- "syn": "UsePath"
- }
- ],
- "Name": [
- {
- "syn": "UseName"
- }
- ],
- "Rename": [
- {
- "syn": "UseRename"
- }
- ],
- "Glob": [
- {
- "syn": "UseGlob"
- }
- ],
- "Group": [
- {
- "syn": "UseGroup"
- }
- ]
- }
- },
- {
- "ident": "Variadic",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "dots": {
- "token": "Dot3"
- }
- }
- },
- {
- "ident": "Variant",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "attrs": {
- "vec": {
- "syn": "Attribute"
- }
- },
- "ident": {
- "proc_macro2": "Ident"
- },
- "fields": {
- "syn": "Fields"
- },
- "discriminant": {
- "option": {
- "tuple": [
- {
- "token": "Eq"
- },
- {
- "syn": "Expr"
- }
- ]
- }
- }
- }
- },
- {
- "ident": "VisCrate",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "crate_token": {
- "token": "Crate"
- }
- }
- },
- {
- "ident": "VisPublic",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "pub_token": {
- "token": "Pub"
- }
- }
- },
- {
- "ident": "VisRestricted",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "pub_token": {
- "token": "Pub"
- },
- "paren_token": {
- "group": "Paren"
- },
- "in_token": {
- "option": {
- "token": "In"
- }
- },
- "path": {
- "box": {
- "syn": "Path"
- }
- }
- }
- },
- {
- "ident": "Visibility",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Public": [
- {
- "syn": "VisPublic"
- }
- ],
- "Crate": [
- {
- "syn": "VisCrate"
- }
- ],
- "Restricted": [
- {
- "syn": "VisRestricted"
- }
- ],
- "Inherited": []
- }
- },
- {
- "ident": "WhereClause",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "fields": {
- "where_token": {
- "token": "Where"
- },
- "predicates": {
- "punctuated": {
- "element": {
- "syn": "WherePredicate"
- },
- "punct": "Comma"
- }
- }
- }
- },
- {
- "ident": "WherePredicate",
- "features": {
- "any": [
- "derive",
- "full"
- ]
- },
- "variants": {
- "Type": [
- {
- "syn": "PredicateType"
- }
- ],
- "Lifetime": [
- {
- "syn": "PredicateLifetime"
- }
- ],
- "Eq": [
- {
- "syn": "PredicateEq"
- }
- ]
- }
- }
- ],
- "tokens": {
- "Abstract": "abstract",
- "Add": "+",
- "AddEq": "+=",
- "And": "&",
- "AndAnd": "&&",
- "AndEq": "&=",
- "As": "as",
- "Async": "async",
- "At": "@",
- "Auto": "auto",
- "Await": "await",
- "Bang": "!",
- "Become": "become",
- "Box": "box",
- "Break": "break",
- "Caret": "^",
- "CaretEq": "^=",
- "Colon": ":",
- "Colon2": "::",
- "Comma": ",",
- "Const": "const",
- "Continue": "continue",
- "Crate": "crate",
- "Default": "default",
- "Div": "/",
- "DivEq": "/=",
- "Do": "do",
- "Dollar": "$",
- "Dot": ".",
- "Dot2": "..",
- "Dot3": "...",
- "DotDotEq": "..=",
- "Dyn": "dyn",
- "Else": "else",
- "Enum": "enum",
- "Eq": "=",
- "EqEq": "==",
- "Extern": "extern",
- "FatArrow": "=>",
- "Final": "final",
- "Fn": "fn",
- "For": "for",
- "Ge": ">=",
- "Gt": ">",
- "If": "if",
- "Impl": "impl",
- "In": "in",
- "LArrow": "<-",
- "Le": "<=",
- "Let": "let",
- "Loop": "loop",
- "Lt": "<",
- "Macro": "macro",
- "Match": "match",
- "Mod": "mod",
- "Move": "move",
- "MulEq": "*=",
- "Mut": "mut",
- "Ne": "!=",
- "Or": "|",
- "OrEq": "|=",
- "OrOr": "||",
- "Override": "override",
- "Pound": "#",
- "Priv": "priv",
- "Pub": "pub",
- "Question": "?",
- "RArrow": "->",
- "Ref": "ref",
- "Rem": "%",
- "RemEq": "%=",
- "Return": "return",
- "SelfType": "Self",
- "SelfValue": "self",
- "Semi": ";",
- "Shl": "<<",
- "ShlEq": "<<=",
- "Shr": ">>",
- "ShrEq": ">>=",
- "Star": "*",
- "Static": "static",
- "Struct": "struct",
- "Sub": "-",
- "SubEq": "-=",
- "Super": "super",
- "Tilde": "~",
- "Trait": "trait",
- "Try": "try",
- "Type": "type",
- "Typeof": "typeof",
- "Underscore": "_",
- "Union": "union",
- "Unsafe": "unsafe",
- "Unsized": "unsized",
- "Use": "use",
- "Virtual": "virtual",
- "Where": "where",
- "While": "while",
- "Yield": "yield"
- }
-}
diff --git a/syn/tests/common/eq.rs b/syn/tests/common/eq.rs
deleted file mode 100644
index 098f833..0000000
--- a/syn/tests/common/eq.rs
+++ /dev/null
@@ -1,459 +0,0 @@
-extern crate rustc_data_structures;
-extern crate rustc_span;
-extern crate rustc_target;
-extern crate syntax;
-
-use std::mem;
-
-use rustc_data_structures::sync::Lrc;
-use rustc_data_structures::thin_vec::ThinVec;
-use rustc_span::{Span, SyntaxContext, DUMMY_SP};
-use syntax::ast::{
- AngleBracketedArgs, AnonConst, Arm, AsmDialect, AssocItem, AssocItemKind, AssocTyConstraint,
- AssocTyConstraintKind, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy, BinOpKind,
- BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Constness, Crate, CrateSugar,
- Defaultness, EnumDef, Expr, ExprKind, Extern, Field, FieldPat, FloatTy, FnDecl, FnHeader,
- FnSig, ForeignItem, ForeignItemKind, ForeignMod, FunctionRetTy, GenericArg, GenericArgs,
- GenericBound, GenericParam, GenericParamKind, Generics, GlobalAsm, Ident, ImplPolarity,
- InlineAsm, InlineAsmOutput, IntTy, IsAsync, IsAuto, Item, ItemKind, Label, Lifetime, Lit,
- LitFloatType, LitIntType, LitKind, Local, Mac, MacArgs, MacDelimiter, MacStmtStyle, MacroDef,
- Mod, Movability, MutTy, Mutability, NodeId, Param, ParenthesizedArgs, Pat, PatKind, Path,
- PathSegment, PolyTraitRef, QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt, StmtKind, StrLit,
- StrStyle, StructField, TraitBoundModifier, TraitObjectSyntax, TraitRef, Ty, TyKind, UintTy,
- UnOp, UnsafeSource, Unsafety, UseTree, UseTreeKind, Variant, VariantData, VisibilityKind,
- WhereBoundPredicate, WhereClause, WhereEqPredicate, WherePredicate, WhereRegionPredicate,
-};
-use syntax::ptr::P;
-use syntax::source_map::Spanned;
-use syntax::symbol::{sym, Symbol};
-use syntax::token::{self, DelimToken, Token, TokenKind};
-use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};
-use syntax::util::comments;
-
-pub trait SpanlessEq {
- fn eq(&self, other: &Self) -> bool;
-}
-
-impl<T: SpanlessEq> SpanlessEq for P<T> {
- fn eq(&self, other: &Self) -> bool {
- SpanlessEq::eq(&**self, &**other)
- }
-}
-
-impl<T: SpanlessEq> SpanlessEq for Lrc<T> {
- fn eq(&self, other: &Self) -> bool {
- SpanlessEq::eq(&**self, &**other)
- }
-}
-
-impl<T: SpanlessEq> SpanlessEq for Option<T> {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (None, None) => true,
- (Some(this), Some(other)) => SpanlessEq::eq(this, other),
- _ => false,
- }
- }
-}
-
-impl<T: SpanlessEq> SpanlessEq for Vec<T> {
- fn eq(&self, other: &Self) -> bool {
- self.len() == other.len() && self.iter().zip(other).all(|(a, b)| SpanlessEq::eq(a, b))
- }
-}
-
-impl<T: SpanlessEq> SpanlessEq for ThinVec<T> {
- fn eq(&self, other: &Self) -> bool {
- self.len() == other.len()
- && self
- .iter()
- .zip(other.iter())
- .all(|(a, b)| SpanlessEq::eq(a, b))
- }
-}
-
-impl<T: SpanlessEq> SpanlessEq for Spanned<T> {
- fn eq(&self, other: &Self) -> bool {
- SpanlessEq::eq(&self.node, &other.node)
- }
-}
-
-impl<A: SpanlessEq, B: SpanlessEq> SpanlessEq for (A, B) {
- fn eq(&self, other: &Self) -> bool {
- SpanlessEq::eq(&self.0, &other.0) && SpanlessEq::eq(&self.1, &other.1)
- }
-}
-
-impl<A: SpanlessEq, B: SpanlessEq, C: SpanlessEq> SpanlessEq for (A, B, C) {
- fn eq(&self, other: &Self) -> bool {
- SpanlessEq::eq(&self.0, &other.0)
- && SpanlessEq::eq(&self.1, &other.1)
- && SpanlessEq::eq(&self.2, &other.2)
- }
-}
-
-macro_rules! spanless_eq_true {
- ($name:ident) => {
- impl SpanlessEq for $name {
- fn eq(&self, _other: &Self) -> bool {
- true
- }
- }
- };
-}
-
-spanless_eq_true!(Span);
-spanless_eq_true!(DelimSpan);
-spanless_eq_true!(AttrId);
-spanless_eq_true!(NodeId);
-spanless_eq_true!(SyntaxContext);
-
-macro_rules! spanless_eq_partial_eq {
- ($name:ident) => {
- impl SpanlessEq for $name {
- fn eq(&self, other: &Self) -> bool {
- PartialEq::eq(self, other)
- }
- }
- };
-}
-
-spanless_eq_partial_eq!(bool);
-spanless_eq_partial_eq!(u8);
-spanless_eq_partial_eq!(u16);
-spanless_eq_partial_eq!(u128);
-spanless_eq_partial_eq!(usize);
-spanless_eq_partial_eq!(char);
-spanless_eq_partial_eq!(Symbol);
-spanless_eq_partial_eq!(DelimToken);
-
-macro_rules! spanless_eq_struct {
- {
- $name:ident;
- $([$field:ident $other:ident])*
- $(![$ignore:ident])*
- } => {
- impl SpanlessEq for $name {
- fn eq(&self, other: &Self) -> bool {
- let $name { $($field,)* $($ignore: _,)* } = self;
- let $name { $($field: $other,)* $($ignore: _,)* } = other;
- $(SpanlessEq::eq($field, $other))&&*
- }
- }
- };
-
- {
- $name:ident;
- $([$field:ident $other:ident])*
- $next:ident
- $($rest:ident)*
- $(!$ignore:ident)*
- } => {
- spanless_eq_struct! {
- $name;
- $([$field $other])*
- [$next other]
- $($rest)*
- $(!$ignore)*
- }
- };
-
- {
- $name:ident;
- $([$field:ident $other:ident])*
- $(![$ignore:ident])*
- !$next:ident
- $(!$rest:ident)*
- } => {
- spanless_eq_struct! {
- $name;
- $([$field $other])*
- $(![$ignore])*
- ![$next]
- $(!$rest)*
- }
- };
-}
-
-macro_rules! spanless_eq_enum {
- {
- $name:ident;
- $([$variant:ident $([$field:tt $this:ident $other:ident])*])*
- } => {
- impl SpanlessEq for $name {
- fn eq(&self, other: &Self) -> bool {
- match self {
- $(
- $name::$variant { .. } => {}
- )*
- }
- #[allow(unreachable_patterns)]
- match (self, other) {
- $(
- (
- $name::$variant { $($field: $this),* },
- $name::$variant { $($field: $other),* },
- ) => {
- true $(&& SpanlessEq::eq($this, $other))*
- }
- )*
- _ => false,
- }
- }
- }
- };
-
- {
- $name:ident;
- $([$variant:ident $($fields:tt)*])*
- $next:ident [$($named:tt)*] ( $i:tt $($field:tt)* )
- $($rest:tt)*
- } => {
- spanless_eq_enum! {
- $name;
- $([$variant $($fields)*])*
- $next [$($named)* [$i this other]] ( $($field)* )
- $($rest)*
- }
- };
-
- {
- $name:ident;
- $([$variant:ident $($fields:tt)*])*
- $next:ident [$($named:tt)*] ()
- $($rest:tt)*
- } => {
- spanless_eq_enum! {
- $name;
- $([$variant $($fields)*])*
- [$next $($named)*]
- $($rest)*
- }
- };
-
- {
- $name:ident;
- $([$variant:ident $($fields:tt)*])*
- $next:ident ( $($field:tt)* )
- $($rest:tt)*
- } => {
- spanless_eq_enum! {
- $name;
- $([$variant $($fields)*])*
- $next [] ( $($field)* )
- $($rest)*
- }
- };
-
- {
- $name:ident;
- $([$variant:ident $($fields:tt)*])*
- $next:ident
- $($rest:tt)*
- } => {
- spanless_eq_enum! {
- $name;
- $([$variant $($fields)*])*
- [$next]
- $($rest)*
- }
- };
-}
-
-spanless_eq_struct!(AngleBracketedArgs; span args constraints);
-spanless_eq_struct!(AnonConst; id value);
-spanless_eq_struct!(Arm; attrs pat guard body span id is_placeholder);
-spanless_eq_struct!(AssocItem; attrs id span vis ident defaultness generics kind !tokens);
-spanless_eq_struct!(AssocTyConstraint; id ident kind span);
-spanless_eq_struct!(AttrItem; path args);
-spanless_eq_struct!(Attribute; kind id style span);
-spanless_eq_struct!(BareFnTy; unsafety ext generic_params decl);
-spanless_eq_struct!(Block; stmts id rules span);
-spanless_eq_struct!(Crate; module attrs span);
-spanless_eq_struct!(EnumDef; variants);
-spanless_eq_struct!(Expr; id kind span attrs);
-spanless_eq_struct!(Field; attrs id span ident expr is_shorthand is_placeholder);
-spanless_eq_struct!(FieldPat; ident pat is_shorthand attrs id span is_placeholder);
-spanless_eq_struct!(FnDecl; inputs output);
-spanless_eq_struct!(FnHeader; constness asyncness unsafety ext);
-spanless_eq_struct!(FnSig; header decl);
-spanless_eq_struct!(ForeignItem; attrs id span vis ident kind tokens);
-spanless_eq_struct!(ForeignMod; abi items);
-spanless_eq_struct!(GenericParam; id ident attrs bounds is_placeholder kind);
-spanless_eq_struct!(Generics; params where_clause span);
-spanless_eq_struct!(GlobalAsm; asm);
-spanless_eq_struct!(InlineAsm; asm asm_str_style outputs inputs clobbers volatile alignstack dialect);
-spanless_eq_struct!(InlineAsmOutput; constraint expr is_rw is_indirect);
-spanless_eq_struct!(Item; attrs id span vis ident kind !tokens);
-spanless_eq_struct!(Label; ident);
-spanless_eq_struct!(Lifetime; id ident);
-spanless_eq_struct!(Lit; token kind span);
-spanless_eq_struct!(Local; pat ty init id span attrs);
-spanless_eq_struct!(Mac; path args prior_type_ascription);
-spanless_eq_struct!(MacroDef; body legacy);
-spanless_eq_struct!(Mod; inner items inline);
-spanless_eq_struct!(MutTy; ty mutbl);
-spanless_eq_struct!(Param; attrs ty pat id span is_placeholder);
-spanless_eq_struct!(ParenthesizedArgs; span inputs output);
-spanless_eq_struct!(Pat; id kind span);
-spanless_eq_struct!(Path; span segments);
-spanless_eq_struct!(PathSegment; ident id args);
-spanless_eq_struct!(PolyTraitRef; bound_generic_params trait_ref span);
-spanless_eq_struct!(QSelf; ty path_span position);
-spanless_eq_struct!(Stmt; id kind span);
-spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped);
-spanless_eq_struct!(StructField; attrs id span vis ident ty is_placeholder);
-spanless_eq_struct!(Token; kind span);
-spanless_eq_struct!(TraitRef; path ref_id);
-spanless_eq_struct!(Ty; id kind span);
-spanless_eq_struct!(UseTree; prefix kind span);
-spanless_eq_struct!(Variant; attrs id span vis ident data disr_expr is_placeholder);
-spanless_eq_struct!(WhereBoundPredicate; span bound_generic_params bounded_ty bounds);
-spanless_eq_struct!(WhereClause; predicates span);
-spanless_eq_struct!(WhereEqPredicate; id span lhs_ty rhs_ty);
-spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds);
-spanless_eq_enum!(AsmDialect; Att Intel);
-spanless_eq_enum!(AssocItemKind; Const(0 1) Fn(0 1) TyAlias(0 1) Macro(0));
-spanless_eq_enum!(AssocTyConstraintKind; Equality(ty) Bound(bounds));
-spanless_eq_enum!(AttrKind; Normal(0) DocComment(0));
-spanless_eq_enum!(AttrStyle; Outer Inner);
-spanless_eq_enum!(BinOpKind; Add Sub Mul Div Rem And Or BitXor BitAnd BitOr Shl Shr Eq Lt Le Ne Ge Gt);
-spanless_eq_enum!(BindingMode; ByRef(0) ByValue(0));
-spanless_eq_enum!(BlockCheckMode; Default Unsafe(0));
-spanless_eq_enum!(BorrowKind; Ref Raw);
-spanless_eq_enum!(CaptureBy; Value Ref);
-spanless_eq_enum!(Constness; Const NotConst);
-spanless_eq_enum!(CrateSugar; PubCrate JustCrate);
-spanless_eq_enum!(Defaultness; Default Final);
-spanless_eq_enum!(Extern; None Implicit Explicit(0));
-spanless_eq_enum!(FloatTy; F32 F64);
-spanless_eq_enum!(ForeignItemKind; Fn(0 1) Static(0 1) Ty Macro(0));
-spanless_eq_enum!(FunctionRetTy; Default(0) Ty(0));
-spanless_eq_enum!(GenericArg; Lifetime(0) Type(0) Const(0));
-spanless_eq_enum!(GenericArgs; AngleBracketed(0) Parenthesized(0));
-spanless_eq_enum!(GenericBound; Trait(0 1) Outlives(0));
-spanless_eq_enum!(GenericParamKind; Lifetime Type(default) Const(ty));
-spanless_eq_enum!(ImplPolarity; Positive Negative);
-spanless_eq_enum!(IntTy; Isize I8 I16 I32 I64 I128);
-spanless_eq_enum!(IsAsync; Async(closure_id return_impl_trait_id) NotAsync);
-spanless_eq_enum!(IsAuto; Yes No);
-spanless_eq_enum!(LitFloatType; Suffixed(0) Unsuffixed);
-spanless_eq_enum!(LitIntType; Signed(0) Unsigned(0) Unsuffixed);
-spanless_eq_enum!(MacArgs; Empty Delimited(0 1 2) Eq(0 1));
-spanless_eq_enum!(MacDelimiter; Parenthesis Bracket Brace);
-spanless_eq_enum!(MacStmtStyle; Semicolon Braces NoBraces);
-spanless_eq_enum!(Movability; Static Movable);
-spanless_eq_enum!(Mutability; Mut Not);
-spanless_eq_enum!(RangeEnd; Included(0) Excluded);
-spanless_eq_enum!(RangeLimits; HalfOpen Closed);
-spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Mac(0));
-spanless_eq_enum!(StrStyle; Cooked Raw(0));
-spanless_eq_enum!(TokenTree; Token(0) Delimited(0 1 2));
-spanless_eq_enum!(TraitBoundModifier; None Maybe);
-spanless_eq_enum!(TraitObjectSyntax; Dyn None);
-spanless_eq_enum!(UintTy; Usize U8 U16 U32 U64 U128);
-spanless_eq_enum!(UnOp; Deref Not Neg);
-spanless_eq_enum!(UnsafeSource; CompilerGenerated UserProvided);
-spanless_eq_enum!(Unsafety; Unsafe Normal);
-spanless_eq_enum!(UseTreeKind; Simple(0 1 2) Nested(0) Glob);
-spanless_eq_enum!(VariantData; Struct(0 1) Tuple(0 1) Unit(0));
-spanless_eq_enum!(VisibilityKind; Public Crate(0) Restricted(path id) Inherited);
-spanless_eq_enum!(WherePredicate; BoundPredicate(0) RegionPredicate(0) EqPredicate(0));
-spanless_eq_enum!(ExprKind; Box(0) Array(0) Call(0 1) MethodCall(0 1) Tup(0)
- Binary(0 1 2) Unary(0 1) Lit(0) Cast(0 1) Type(0 1) Let(0 1) If(0 1 2)
- While(0 1 2) ForLoop(0 1 2 3) Loop(0 1) Match(0 1) Closure(0 1 2 3 4 5)
- Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2)
- Field(0 1) Index(0 1) Range(0 1 2) Path(0 1) AddrOf(0 1 2) Break(0 1)
- Continue(0) Ret(0) InlineAsm(0) Mac(0) Struct(0 1 2) Repeat(0 1) Paren(0)
- Try(0) Yield(0) Err);
-spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1)
- Fn(0 1 2) Mod(0) ForeignMod(0) GlobalAsm(0) TyAlias(0 1) Enum(0 1)
- Struct(0 1) Union(0 1) Trait(0 1 2 3 4) TraitAlias(0 1) Impl(0 1 2 3 4 5 6)
- Mac(0) MacroDef(0));
-spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0) Byte(0) Char(0) Int(0 1)
- Float(0 1) Bool(0) Err(0));
-spanless_eq_enum!(PatKind; Wild Ident(0 1 2) Struct(0 1 2) TupleStruct(0 1)
- Or(0) Path(0 1) Tuple(0) Box(0) Ref(0 1) Lit(0) Range(0 1 2) Slice(0) Rest
- Paren(0) Mac(0));
-spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Rptr(0 1) BareFn(0) Never
- Tup(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer
- ImplicitSelf Mac(0) Err CVarArgs);
-
-impl SpanlessEq for Ident {
- fn eq(&self, other: &Self) -> bool {
- self.as_str() == other.as_str()
- }
-}
-
-// Give up on comparing literals inside of macros because there are so many
-// equivalent representations of the same literal; they are tested elsewhere
-impl SpanlessEq for token::Lit {
- fn eq(&self, other: &Self) -> bool {
- mem::discriminant(self) == mem::discriminant(other)
- }
-}
-
-impl SpanlessEq for RangeSyntax {
- fn eq(&self, _other: &Self) -> bool {
- match self {
- RangeSyntax::DotDotDot | RangeSyntax::DotDotEq => true,
- }
- }
-}
-
-impl SpanlessEq for TokenKind {
- fn eq(&self, other: &Self) -> bool {
- match (self, other) {
- (TokenKind::Literal(this), TokenKind::Literal(other)) => SpanlessEq::eq(this, other),
- (TokenKind::DotDotEq, _) | (TokenKind::DotDotDot, _) => match other {
- TokenKind::DotDotEq | TokenKind::DotDotDot => true,
- _ => false,
- },
- _ => self == other,
- }
- }
-}
-
-impl SpanlessEq for TokenStream {
- fn eq(&self, other: &Self) -> bool {
- SpanlessEq::eq(&expand_tts(self), &expand_tts(other))
- }
-}
-
-fn expand_tts(tts: &TokenStream) -> Vec<TokenTree> {
- let mut tokens = Vec::new();
- for tt in tts.clone().into_trees() {
- let c = match tt {
- TokenTree::Token(Token {
- kind: TokenKind::DocComment(c),
- ..
- }) => c,
- _ => {
- tokens.push(tt);
- continue;
- }
- };
- let contents = comments::strip_doc_comment_decoration(&c.as_str());
- let style = comments::doc_comment_style(&c.as_str());
- tokens.push(TokenTree::token(TokenKind::Pound, DUMMY_SP));
- if style == AttrStyle::Inner {
- tokens.push(TokenTree::token(TokenKind::Not, DUMMY_SP));
- }
- let lit = token::Lit {
- kind: token::LitKind::Str,
- symbol: Symbol::intern(&contents),
- suffix: None,
- };
- let tts = vec![
- TokenTree::token(TokenKind::Ident(sym::doc, false), DUMMY_SP),
- TokenTree::token(TokenKind::Eq, DUMMY_SP),
- TokenTree::token(TokenKind::Literal(lit), DUMMY_SP),
- ];
- tokens.push(TokenTree::Delimited(
- DelimSpan::dummy(),
- DelimToken::Bracket,
- tts.into_iter().collect::<TokenStream>().into(),
- ));
- }
- tokens
-}
diff --git a/syn/tests/common/mod.rs b/syn/tests/common/mod.rs
deleted file mode 100644
index 3dd2552..0000000
--- a/syn/tests/common/mod.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#![allow(dead_code)]
-
-use std::env;
-
-pub mod eq;
-pub mod parse;
-
-/// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it.
-pub fn abort_after() -> usize {
- match env::var("ABORT_AFTER_FAILURE") {
- Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"),
- Err(_) => usize::max_value(),
- }
-}
-
-/// Are we running in travis-ci.org.
-pub fn travis_ci() -> bool {
- env::var_os("TRAVIS").is_some()
-}
diff --git a/syn/tests/common/parse.rs b/syn/tests/common/parse.rs
deleted file mode 100644
index fc3bb96..0000000
--- a/syn/tests/common/parse.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-extern crate rustc_expand;
-extern crate rustc_parse as parse;
-extern crate rustc_span;
-extern crate syntax;
-
-use rustc_span::FileName;
-use syntax::ast;
-use syntax::ptr::P;
-use syntax::sess::ParseSess;
-use syntax::source_map::FilePathMapping;
-
-use std::panic;
-
-pub fn libsyntax_expr(input: &str) -> Option<P<ast::Expr>> {
- match panic::catch_unwind(|| {
- let sess = ParseSess::new(FilePathMapping::empty());
- sess.span_diagnostic.set_continue_after_error(false);
- let e = parse::new_parser_from_source_str(
- &sess,
- FileName::Custom("test_precedence".to_string()),
- input.to_string(),
- )
- .parse_expr();
- match e {
- Ok(expr) => Some(expr),
- Err(mut diagnostic) => {
- diagnostic.emit();
- None
- }
- }
- }) {
- Ok(Some(e)) => Some(e),
- Ok(None) => None,
- Err(_) => {
- errorf!("libsyntax panicked\n");
- None
- }
- }
-}
-
-pub fn syn_expr(input: &str) -> Option<syn::Expr> {
- match syn::parse_str(input) {
- Ok(e) => Some(e),
- Err(msg) => {
- errorf!("syn failed to parse\n{:?}\n", msg);
- None
- }
- }
-}
diff --git a/syn/tests/debug/gen.rs b/syn/tests/debug/gen.rs
deleted file mode 100644
index 8450c09..0000000
--- a/syn/tests/debug/gen.rs
+++ /dev/null
@@ -1,5633 +0,0 @@
-// This file is @generated by syn-internal-codegen.
-// It is not intended for manual editing.
-
-use super::{Lite, RefCast};
-use std::fmt::{self, Debug};
-impl Debug for Lite<syn::Abi> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Abi");
- if let Some(val) = &_val.name {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::LitStr);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("name", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::AngleBracketedGenericArguments> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("AngleBracketedGenericArguments");
- if let Some(val) = &_val.colon2_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon2_token", Print::ref_cast(val));
- }
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Arm> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Arm");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- if let Some(val) = &_val.guard {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::If, Box<syn::Expr>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("guard", Print::ref_cast(val));
- }
- formatter.field("body", Lite(&_val.body));
- if let Some(val) = &_val.comma {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Comma);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("comma", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::AttrStyle> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::AttrStyle::Outer => formatter.write_str("Outer"),
- syn::AttrStyle::Inner(_val) => {
- formatter.write_str("Inner")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Attribute> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Attribute");
- formatter.field("style", Lite(&_val.style));
- formatter.field("path", Lite(&_val.path));
- formatter.field("tokens", Lite(&_val.tokens));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::BareFnArg> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("BareFnArg");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.name {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((proc_macro2::Ident, syn::token::Colon));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.0), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("name", Print::ref_cast(val));
- }
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::BinOp> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::BinOp::Add(_val) => {
- formatter.write_str("Add")?;
- Ok(())
- }
- syn::BinOp::Sub(_val) => {
- formatter.write_str("Sub")?;
- Ok(())
- }
- syn::BinOp::Mul(_val) => {
- formatter.write_str("Mul")?;
- Ok(())
- }
- syn::BinOp::Div(_val) => {
- formatter.write_str("Div")?;
- Ok(())
- }
- syn::BinOp::Rem(_val) => {
- formatter.write_str("Rem")?;
- Ok(())
- }
- syn::BinOp::And(_val) => {
- formatter.write_str("And")?;
- Ok(())
- }
- syn::BinOp::Or(_val) => {
- formatter.write_str("Or")?;
- Ok(())
- }
- syn::BinOp::BitXor(_val) => {
- formatter.write_str("BitXor")?;
- Ok(())
- }
- syn::BinOp::BitAnd(_val) => {
- formatter.write_str("BitAnd")?;
- Ok(())
- }
- syn::BinOp::BitOr(_val) => {
- formatter.write_str("BitOr")?;
- Ok(())
- }
- syn::BinOp::Shl(_val) => {
- formatter.write_str("Shl")?;
- Ok(())
- }
- syn::BinOp::Shr(_val) => {
- formatter.write_str("Shr")?;
- Ok(())
- }
- syn::BinOp::Eq(_val) => {
- formatter.write_str("Eq")?;
- Ok(())
- }
- syn::BinOp::Lt(_val) => {
- formatter.write_str("Lt")?;
- Ok(())
- }
- syn::BinOp::Le(_val) => {
- formatter.write_str("Le")?;
- Ok(())
- }
- syn::BinOp::Ne(_val) => {
- formatter.write_str("Ne")?;
- Ok(())
- }
- syn::BinOp::Ge(_val) => {
- formatter.write_str("Ge")?;
- Ok(())
- }
- syn::BinOp::Gt(_val) => {
- formatter.write_str("Gt")?;
- Ok(())
- }
- syn::BinOp::AddEq(_val) => {
- formatter.write_str("AddEq")?;
- Ok(())
- }
- syn::BinOp::SubEq(_val) => {
- formatter.write_str("SubEq")?;
- Ok(())
- }
- syn::BinOp::MulEq(_val) => {
- formatter.write_str("MulEq")?;
- Ok(())
- }
- syn::BinOp::DivEq(_val) => {
- formatter.write_str("DivEq")?;
- Ok(())
- }
- syn::BinOp::RemEq(_val) => {
- formatter.write_str("RemEq")?;
- Ok(())
- }
- syn::BinOp::BitXorEq(_val) => {
- formatter.write_str("BitXorEq")?;
- Ok(())
- }
- syn::BinOp::BitAndEq(_val) => {
- formatter.write_str("BitAndEq")?;
- Ok(())
- }
- syn::BinOp::BitOrEq(_val) => {
- formatter.write_str("BitOrEq")?;
- Ok(())
- }
- syn::BinOp::ShlEq(_val) => {
- formatter.write_str("ShlEq")?;
- Ok(())
- }
- syn::BinOp::ShrEq(_val) => {
- formatter.write_str("ShrEq")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Binding> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Binding");
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Block> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Block");
- if !_val.stmts.is_empty() {
- formatter.field("stmts", Lite(&_val.stmts));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::BoundLifetimes> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("BoundLifetimes");
- if !_val.lifetimes.is_empty() {
- formatter.field("lifetimes", Lite(&_val.lifetimes));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ConstParam> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ConstParam");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- if let Some(val) = &_val.eq_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Eq);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("eq_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Expr);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Constraint> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Constraint");
- formatter.field("ident", Lite(&_val.ident));
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Data> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Data::Struct(_val) => {
- let mut formatter = formatter.debug_struct("Data::Struct");
- formatter.field("fields", Lite(&_val.fields));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Data::Enum(_val) => {
- let mut formatter = formatter.debug_struct("Data::Enum");
- if !_val.variants.is_empty() {
- formatter.field("variants", Lite(&_val.variants));
- }
- formatter.finish()
- }
- syn::Data::Union(_val) => {
- let mut formatter = formatter.debug_struct("Data::Union");
- formatter.field("fields", Lite(&_val.fields));
- formatter.finish()
- }
- }
- }
-}
-impl Debug for Lite<syn::DataEnum> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("DataEnum");
- if !_val.variants.is_empty() {
- formatter.field("variants", Lite(&_val.variants));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::DataStruct> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("DataStruct");
- formatter.field("fields", Lite(&_val.fields));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::DataUnion> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("DataUnion");
- formatter.field("fields", Lite(&_val.fields));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::DeriveInput> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("DeriveInput");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("data", Lite(&_val.data));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Expr> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Expr::Array(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Array");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
- syn::Expr::Assign(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Assign");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("left", Lite(&_val.left));
- formatter.field("right", Lite(&_val.right));
- formatter.finish()
- }
- syn::Expr::AssignOp(_val) => {
- let mut formatter = formatter.debug_struct("Expr::AssignOp");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("left", Lite(&_val.left));
- formatter.field("op", Lite(&_val.op));
- formatter.field("right", Lite(&_val.right));
- formatter.finish()
- }
- syn::Expr::Async(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Async");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.capture {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Move);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("capture", Print::ref_cast(val));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
- syn::Expr::Await(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Await");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("base", Lite(&_val.base));
- formatter.finish()
- }
- syn::Expr::Binary(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Binary");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("left", Lite(&_val.left));
- formatter.field("op", Lite(&_val.op));
- formatter.field("right", Lite(&_val.right));
- formatter.finish()
- }
- syn::Expr::Block(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Block");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
- syn::Expr::Box(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Box");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::Break(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Break");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Lifetime);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- if let Some(val) = &_val.expr {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("expr", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Expr::Call(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Call");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("func", Lite(&_val.func));
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
- syn::Expr::Cast(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Cast");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
- syn::Expr::Closure(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Closure");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.asyncness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Async);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("asyncness", Print::ref_cast(val));
- }
- if let Some(val) = &_val.movability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Static);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("movability", Print::ref_cast(val));
- }
- if let Some(val) = &_val.capture {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Move);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("capture", Print::ref_cast(val));
- }
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
- syn::Expr::Continue(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Continue");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Lifetime);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Expr::Field(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Field");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("base", Lite(&_val.base));
- formatter.field("member", Lite(&_val.member));
- formatter.finish()
- }
- syn::Expr::ForLoop(_val) => {
- let mut formatter = formatter.debug_struct("Expr::ForLoop");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
- syn::Expr::Group(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Group");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::If(_val) => {
- let mut formatter = formatter.debug_struct("Expr::If");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("cond", Lite(&_val.cond));
- formatter.field("then_branch", Lite(&_val.then_branch));
- if let Some(val) = &_val.else_branch {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Else, Box<syn::Expr>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("else_branch", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Expr::Index(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Index");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("index", Lite(&_val.index));
- formatter.finish()
- }
- syn::Expr::Let(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Let");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::Lit(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Lit");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("lit", Lite(&_val.lit));
- formatter.finish()
- }
- syn::Expr::Loop(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Loop");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
- syn::Expr::Macro(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Macro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- formatter.finish()
- }
- syn::Expr::Match(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Match");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- if !_val.arms.is_empty() {
- formatter.field("arms", Lite(&_val.arms));
- }
- formatter.finish()
- }
- syn::Expr::MethodCall(_val) => {
- let mut formatter = formatter.debug_struct("Expr::MethodCall");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("receiver", Lite(&_val.receiver));
- formatter.field("method", Lite(&_val.method));
- if let Some(val) = &_val.turbofish {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::MethodTurbofish);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("turbofish", Print::ref_cast(val));
- }
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
- syn::Expr::Paren(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Paren");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::Path(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Path");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.qself {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::QSelf);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("qself", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
- syn::Expr::Range(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Range");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.from {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("from", Print::ref_cast(val));
- }
- formatter.field("limits", Lite(&_val.limits));
- if let Some(val) = &_val.to {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("to", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Expr::Reference(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Reference");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::Repeat(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Repeat");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("len", Lite(&_val.len));
- formatter.finish()
- }
- syn::Expr::Return(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Return");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.expr {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("expr", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Expr::Struct(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Struct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("path", Lite(&_val.path));
- if !_val.fields.is_empty() {
- formatter.field("fields", Lite(&_val.fields));
- }
- if let Some(val) = &_val.dot2_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Dot2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("dot2_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.rest {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("rest", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Expr::Try(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Try");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::TryBlock(_val) => {
- let mut formatter = formatter.debug_struct("Expr::TryBlock");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
- syn::Expr::Tuple(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Tuple");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
- syn::Expr::Type(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Type");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
- syn::Expr::Unary(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Unary");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("op", Lite(&_val.op));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Expr::Unsafe(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Unsafe");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
- syn::Expr::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Expr::While(_val) => {
- let mut formatter = formatter.debug_struct("Expr::While");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("cond", Lite(&_val.cond));
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
- syn::Expr::Yield(_val) => {
- let mut formatter = formatter.debug_struct("Expr::Yield");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.expr {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("expr", Print::ref_cast(val));
- }
- formatter.finish()
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::ExprArray> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprArray");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprAssign> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprAssign");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("left", Lite(&_val.left));
- formatter.field("right", Lite(&_val.right));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprAssignOp> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprAssignOp");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("left", Lite(&_val.left));
- formatter.field("op", Lite(&_val.op));
- formatter.field("right", Lite(&_val.right));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprAsync> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprAsync");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.capture {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Move);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("capture", Print::ref_cast(val));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprAwait> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprAwait");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("base", Lite(&_val.base));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprBinary> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprBinary");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("left", Lite(&_val.left));
- formatter.field("op", Lite(&_val.op));
- formatter.field("right", Lite(&_val.right));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprBlock> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprBlock");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprBox> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprBox");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprBreak> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprBreak");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Lifetime);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- if let Some(val) = &_val.expr {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("expr", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprCall> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprCall");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("func", Lite(&_val.func));
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprCast> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprCast");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprClosure> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprClosure");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.asyncness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Async);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("asyncness", Print::ref_cast(val));
- }
- if let Some(val) = &_val.movability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Static);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("movability", Print::ref_cast(val));
- }
- if let Some(val) = &_val.capture {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Move);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("capture", Print::ref_cast(val));
- }
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprContinue> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprContinue");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Lifetime);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprField> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprField");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("base", Lite(&_val.base));
- formatter.field("member", Lite(&_val.member));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprForLoop> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprForLoop");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprGroup> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprGroup");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprIf> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprIf");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("cond", Lite(&_val.cond));
- formatter.field("then_branch", Lite(&_val.then_branch));
- if let Some(val) = &_val.else_branch {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Else, Box<syn::Expr>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("else_branch", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprIndex> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprIndex");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("index", Lite(&_val.index));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprLet> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprLet");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprLit> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprLit");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("lit", Lite(&_val.lit));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprLoop> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprLoop");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprMacro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprMatch> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprMatch");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- if !_val.arms.is_empty() {
- formatter.field("arms", Lite(&_val.arms));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprMethodCall> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprMethodCall");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("receiver", Lite(&_val.receiver));
- formatter.field("method", Lite(&_val.method));
- if let Some(val) = &_val.turbofish {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::MethodTurbofish);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("turbofish", Print::ref_cast(val));
- }
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprParen> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprParen");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprPath> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprPath");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.qself {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::QSelf);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("qself", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprRange> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprRange");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.from {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("from", Print::ref_cast(val));
- }
- formatter.field("limits", Lite(&_val.limits));
- if let Some(val) = &_val.to {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("to", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprReference> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprReference");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprRepeat> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprRepeat");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("len", Lite(&_val.len));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprReturn> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprReturn");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.expr {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("expr", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprStruct> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprStruct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("path", Lite(&_val.path));
- if !_val.fields.is_empty() {
- formatter.field("fields", Lite(&_val.fields));
- }
- if let Some(val) = &_val.dot2_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Dot2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("dot2_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.rest {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("rest", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprTry> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprTry");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprTryBlock> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprTryBlock");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprTuple> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprTuple");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprType");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprUnary> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprUnary");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("op", Lite(&_val.op));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprUnsafe> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprUnsafe");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprWhile> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprWhile");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.label {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Label);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("label", Print::ref_cast(val));
- }
- formatter.field("cond", Lite(&_val.cond));
- formatter.field("body", Lite(&_val.body));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ExprYield> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ExprYield");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.expr {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Box<syn::Expr>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("expr", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Field> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Field");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.ident {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(proc_macro2::Ident);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("ident", Print::ref_cast(val));
- }
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::FieldPat> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("FieldPat");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("member", Lite(&_val.member));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::FieldValue> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("FieldValue");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("member", Lite(&_val.member));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Fields> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Fields::Named(_val) => {
- let mut formatter = formatter.debug_struct("Fields::Named");
- if !_val.named.is_empty() {
- formatter.field("named", Lite(&_val.named));
- }
- formatter.finish()
- }
- syn::Fields::Unnamed(_val) => {
- let mut formatter = formatter.debug_struct("Fields::Unnamed");
- if !_val.unnamed.is_empty() {
- formatter.field("unnamed", Lite(&_val.unnamed));
- }
- formatter.finish()
- }
- syn::Fields::Unit => formatter.write_str("Unit"),
- }
- }
-}
-impl Debug for Lite<syn::FieldsNamed> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("FieldsNamed");
- if !_val.named.is_empty() {
- formatter.field("named", Lite(&_val.named));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::FieldsUnnamed> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("FieldsUnnamed");
- if !_val.unnamed.is_empty() {
- formatter.field("unnamed", Lite(&_val.unnamed));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::File> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("File");
- if let Some(val) = &_val.shebang {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(String);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("shebang", Print::ref_cast(val));
- }
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::FnArg> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::FnArg::Receiver(_val) => {
- formatter.write_str("Receiver")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::FnArg::Typed(_val) => {
- formatter.write_str("Typed")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::ForeignItem> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::ForeignItem::Fn(_val) => {
- let mut formatter = formatter.debug_struct("ForeignItem::Fn");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("sig", Lite(&_val.sig));
- formatter.finish()
- }
- syn::ForeignItem::Static(_val) => {
- let mut formatter = formatter.debug_struct("ForeignItem::Static");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
- syn::ForeignItem::Type(_val) => {
- let mut formatter = formatter.debug_struct("ForeignItem::Type");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.finish()
- }
- syn::ForeignItem::Macro(_val) => {
- let mut formatter = formatter.debug_struct("ForeignItem::Macro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::ForeignItem::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::ForeignItemFn> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ForeignItemFn");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("sig", Lite(&_val.sig));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ForeignItemMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ForeignItemMacro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ForeignItemStatic> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ForeignItemStatic");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ForeignItemType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ForeignItemType");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::GenericArgument> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::GenericArgument::Lifetime(_val) => {
- formatter.write_str("Lifetime")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericArgument::Type(_val) => {
- formatter.write_str("Type")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericArgument::Binding(_val) => {
- formatter.write_str("Binding")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericArgument::Constraint(_val) => {
- formatter.write_str("Constraint")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericArgument::Const(_val) => {
- formatter.write_str("Const")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::GenericMethodArgument> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::GenericMethodArgument::Type(_val) => {
- formatter.write_str("Type")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericMethodArgument::Const(_val) => {
- formatter.write_str("Const")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::GenericParam> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::GenericParam::Type(_val) => {
- formatter.write_str("Type")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericParam::Lifetime(_val) => {
- formatter.write_str("Lifetime")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::GenericParam::Const(_val) => {
- formatter.write_str("Const")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Generics> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Generics");
- if let Some(val) = &_val.lt_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Lt);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("lt_token", Print::ref_cast(val));
- }
- if !_val.params.is_empty() {
- formatter.field("params", Lite(&_val.params));
- }
- if let Some(val) = &_val.gt_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Gt);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("gt_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.where_clause {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::WhereClause);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("where_clause", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ImplItem> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::ImplItem::Const(_val) => {
- let mut formatter = formatter.debug_struct("ImplItem::Const");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::ImplItem::Method(_val) => {
- let mut formatter = formatter.debug_struct("ImplItem::Method");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- formatter.field("sig", Lite(&_val.sig));
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
- syn::ImplItem::Type(_val) => {
- let mut formatter = formatter.debug_struct("ImplItem::Type");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
- syn::ImplItem::Macro(_val) => {
- let mut formatter = formatter.debug_struct("ImplItem::Macro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::ImplItem::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::ImplItemConst> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ImplItemConst");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ImplItemMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ImplItemMacro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ImplItemMethod> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ImplItemMethod");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- formatter.field("sig", Lite(&_val.sig));
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ImplItemType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ImplItemType");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Index> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Index");
- formatter.field("index", Lite(&_val.index));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Item> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Item::Const(_val) => {
- let mut formatter = formatter.debug_struct("Item::Const");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Item::Enum(_val) => {
- let mut formatter = formatter.debug_struct("Item::Enum");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if !_val.variants.is_empty() {
- formatter.field("variants", Lite(&_val.variants));
- }
- formatter.finish()
- }
- syn::Item::ExternCrate(_val) => {
- let mut formatter = formatter.debug_struct("Item::ExternCrate");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.rename {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::As, proc_macro2::Ident));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("rename", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Item::Fn(_val) => {
- let mut formatter = formatter.debug_struct("Item::Fn");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("sig", Lite(&_val.sig));
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
- syn::Item::ForeignMod(_val) => {
- let mut formatter = formatter.debug_struct("Item::ForeignMod");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("abi", Lite(&_val.abi));
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
- syn::Item::Impl(_val) => {
- let mut formatter = formatter.debug_struct("Item::Impl");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- formatter.field("generics", Lite(&_val.generics));
- if let Some(val) = &_val.trait_ {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((Option<syn::token::Bang>, syn::Path, syn::token::For));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(
- &(
- {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Option<syn::token::Bang>);
- impl Debug for Print {
- fn fmt(
- &self,
- formatter: &mut fmt::Formatter,
- ) -> fmt::Result
- {
- match &self.0 {
- Some(_val) => {
- formatter.write_str("Some")?;
- Ok(())
- }
- None => formatter.write_str("None"),
- }
- }
- }
- Print::ref_cast(&_val.0)
- },
- Lite(&_val.1),
- ),
- formatter,
- )?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("trait_", Print::ref_cast(val));
- }
- formatter.field("self_ty", Lite(&_val.self_ty));
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
- syn::Item::Macro(_val) => {
- let mut formatter = formatter.debug_struct("Item::Macro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.ident {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(proc_macro2::Ident);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("ident", Print::ref_cast(val));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Item::Macro2(_val) => {
- let mut formatter = formatter.debug_struct("Item::Macro2");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("rules", Lite(&_val.rules));
- formatter.finish()
- }
- syn::Item::Mod(_val) => {
- let mut formatter = formatter.debug_struct("Item::Mod");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.content {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Brace, Vec<syn::Item>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("content", Print::ref_cast(val));
- }
- if let Some(val) = &_val.semi {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Item::Static(_val) => {
- let mut formatter = formatter.debug_struct("Item::Static");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Item::Struct(_val) => {
- let mut formatter = formatter.debug_struct("Item::Struct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("fields", Lite(&_val.fields));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Item::Trait(_val) => {
- let mut formatter = formatter.debug_struct("Item::Trait");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- if let Some(val) = &_val.auto_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Auto);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("auto_token", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- if !_val.supertraits.is_empty() {
- formatter.field("supertraits", Lite(&_val.supertraits));
- }
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
- syn::Item::TraitAlias(_val) => {
- let mut formatter = formatter.debug_struct("Item::TraitAlias");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
- syn::Item::Type(_val) => {
- let mut formatter = formatter.debug_struct("Item::Type");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
- syn::Item::Union(_val) => {
- let mut formatter = formatter.debug_struct("Item::Union");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("fields", Lite(&_val.fields));
- formatter.finish()
- }
- syn::Item::Use(_val) => {
- let mut formatter = formatter.debug_struct("Item::Use");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.leading_colon {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("leading_colon", Print::ref_cast(val));
- }
- formatter.field("tree", Lite(&_val.tree));
- formatter.finish()
- }
- syn::Item::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::ItemConst> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemConst");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemEnum> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemEnum");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if !_val.variants.is_empty() {
- formatter.field("variants", Lite(&_val.variants));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemExternCrate> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemExternCrate");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.rename {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::As, proc_macro2::Ident));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("rename", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemFn> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemFn");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("sig", Lite(&_val.sig));
- formatter.field("block", Lite(&_val.block));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemForeignMod> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemForeignMod");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("abi", Lite(&_val.abi));
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemImpl> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemImpl");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.defaultness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Default);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("defaultness", Print::ref_cast(val));
- }
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- formatter.field("generics", Lite(&_val.generics));
- if let Some(val) = &_val.trait_ {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((Option<syn::token::Bang>, syn::Path, syn::token::For));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(
- &(
- {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Option<syn::token::Bang>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match &self.0 {
- Some(_val) => {
- formatter.write_str("Some")?;
- Ok(())
- }
- None => formatter.write_str("None"),
- }
- }
- }
- Print::ref_cast(&_val.0)
- },
- Lite(&_val.1),
- ),
- formatter,
- )?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("trait_", Print::ref_cast(val));
- }
- formatter.field("self_ty", Lite(&_val.self_ty));
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemMacro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.ident {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(proc_macro2::Ident);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("ident", Print::ref_cast(val));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemMacro2> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemMacro2");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("rules", Lite(&_val.rules));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemMod> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemMod");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.content {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Brace, Vec<syn::Item>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("content", Print::ref_cast(val));
- }
- if let Some(val) = &_val.semi {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemStatic> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemStatic");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemStruct> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemStruct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("fields", Lite(&_val.fields));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemTrait> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemTrait");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- if let Some(val) = &_val.auto_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Auto);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("auto_token", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- if !_val.supertraits.is_empty() {
- formatter.field("supertraits", Lite(&_val.supertraits));
- }
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemTraitAlias> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemTraitAlias");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemType");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemUnion> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemUnion");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- formatter.field("fields", Lite(&_val.fields));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ItemUse> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ItemUse");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("vis", Lite(&_val.vis));
- if let Some(val) = &_val.leading_colon {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("leading_colon", Print::ref_cast(val));
- }
- formatter.field("tree", Lite(&_val.tree));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Label> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Label");
- formatter.field("name", Lite(&_val.name));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Lifetime> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Lifetime");
- formatter.field("ident", Lite(&_val.ident));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::LifetimeDef> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("LifetimeDef");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("lifetime", Lite(&_val.lifetime));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Lit> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Lit::Str(_val) => write!(formatter, "{:?}", _val.value()),
- syn::Lit::ByteStr(_val) => write!(formatter, "{:?}", _val.value()),
- syn::Lit::Byte(_val) => write!(formatter, "{:?}", _val.value()),
- syn::Lit::Char(_val) => write!(formatter, "{:?}", _val.value()),
- syn::Lit::Int(_val) => write!(formatter, "{}", _val),
- syn::Lit::Float(_val) => write!(formatter, "{}", _val),
- syn::Lit::Bool(_val) => {
- let mut formatter = formatter.debug_struct("Lit::Bool");
- formatter.field("value", Lite(&_val.value));
- formatter.finish()
- }
- syn::Lit::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::LitBool> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("LitBool");
- formatter.field("value", Lite(&_val.value));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::LitByte> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- write!(formatter, "{:?}", _val.value())
- }
-}
-impl Debug for Lite<syn::LitByteStr> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- write!(formatter, "{:?}", _val.value())
- }
-}
-impl Debug for Lite<syn::LitChar> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- write!(formatter, "{:?}", _val.value())
- }
-}
-impl Debug for Lite<syn::LitFloat> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- write!(formatter, "{}", _val)
- }
-}
-impl Debug for Lite<syn::LitInt> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- write!(formatter, "{}", _val)
- }
-}
-impl Debug for Lite<syn::LitStr> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- write!(formatter, "{:?}", _val.value())
- }
-}
-impl Debug for Lite<syn::Local> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Local");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- if let Some(val) = &_val.init {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Eq, Box<syn::Expr>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("init", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Macro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Macro");
- formatter.field("path", Lite(&_val.path));
- formatter.field("delimiter", Lite(&_val.delimiter));
- formatter.field("tokens", Lite(&_val.tokens));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::MacroDelimiter> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::MacroDelimiter::Paren(_val) => {
- formatter.write_str("Paren")?;
- Ok(())
- }
- syn::MacroDelimiter::Brace(_val) => {
- formatter.write_str("Brace")?;
- Ok(())
- }
- syn::MacroDelimiter::Bracket(_val) => {
- formatter.write_str("Bracket")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Member> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Member::Named(_val) => {
- formatter.write_str("Named")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Member::Unnamed(_val) => {
- formatter.write_str("Unnamed")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Meta> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Meta::Path(_val) => {
- formatter.write_str("Path")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Meta::List(_val) => {
- let mut formatter = formatter.debug_struct("Meta::List");
- formatter.field("path", Lite(&_val.path));
- if !_val.nested.is_empty() {
- formatter.field("nested", Lite(&_val.nested));
- }
- formatter.finish()
- }
- syn::Meta::NameValue(_val) => {
- let mut formatter = formatter.debug_struct("Meta::NameValue");
- formatter.field("path", Lite(&_val.path));
- formatter.field("lit", Lite(&_val.lit));
- formatter.finish()
- }
- }
- }
-}
-impl Debug for Lite<syn::MetaList> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("MetaList");
- formatter.field("path", Lite(&_val.path));
- if !_val.nested.is_empty() {
- formatter.field("nested", Lite(&_val.nested));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::MetaNameValue> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("MetaNameValue");
- formatter.field("path", Lite(&_val.path));
- formatter.field("lit", Lite(&_val.lit));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::MethodTurbofish> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("MethodTurbofish");
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::NestedMeta> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::NestedMeta::Meta(_val) => {
- formatter.write_str("Meta")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::NestedMeta::Lit(_val) => {
- formatter.write_str("Lit")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::ParenthesizedGenericArguments> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments");
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Pat> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Pat::Box(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Box");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
- syn::Pat::Ident(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Ident");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.by_ref {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Ref);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("by_ref", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.subpat {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::At, Box<syn::Pat>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("subpat", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Pat::Lit(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Lit");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
- syn::Pat::Macro(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Macro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- formatter.finish()
- }
- syn::Pat::Or(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Or");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.leading_vert {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Or);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("leading_vert", Print::ref_cast(val));
- }
- if !_val.cases.is_empty() {
- formatter.field("cases", Lite(&_val.cases));
- }
- formatter.finish()
- }
- syn::Pat::Path(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Path");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.qself {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::QSelf);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("qself", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
- syn::Pat::Range(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Range");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("lo", Lite(&_val.lo));
- formatter.field("limits", Lite(&_val.limits));
- formatter.field("hi", Lite(&_val.hi));
- formatter.finish()
- }
- syn::Pat::Reference(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Reference");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
- syn::Pat::Rest(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Rest");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.finish()
- }
- syn::Pat::Slice(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Slice");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
- syn::Pat::Struct(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Struct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("path", Lite(&_val.path));
- if !_val.fields.is_empty() {
- formatter.field("fields", Lite(&_val.fields));
- }
- if let Some(val) = &_val.dot2_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Dot2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("dot2_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::Pat::Tuple(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Tuple");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
- syn::Pat::TupleStruct(_val) => {
- let mut formatter = formatter.debug_struct("Pat::TupleStruct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
- syn::Pat::Type(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Type");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
- syn::Pat::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Pat::Wild(_val) => {
- let mut formatter = formatter.debug_struct("Pat::Wild");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.finish()
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::PatBox> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatBox");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatIdent> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatIdent");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.by_ref {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Ref);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("by_ref", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.subpat {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::At, Box<syn::Pat>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("subpat", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatLit> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatLit");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("expr", Lite(&_val.expr));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatMacro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatOr> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatOr");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.leading_vert {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Or);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("leading_vert", Print::ref_cast(val));
- }
- if !_val.cases.is_empty() {
- formatter.field("cases", Lite(&_val.cases));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatPath> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatPath");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.qself {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::QSelf);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("qself", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatRange> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatRange");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("lo", Lite(&_val.lo));
- formatter.field("limits", Lite(&_val.limits));
- formatter.field("hi", Lite(&_val.hi));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatReference> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatReference");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatRest> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatRest");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatSlice> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatSlice");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatStruct> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatStruct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("path", Lite(&_val.path));
- if !_val.fields.is_empty() {
- formatter.field("fields", Lite(&_val.fields));
- }
- if let Some(val) = &_val.dot2_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Dot2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("dot2_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatTuple> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatTuple");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatTupleStruct> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatTupleStruct");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.field("pat", Lite(&_val.pat));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatType");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("pat", Lite(&_val.pat));
- formatter.field("ty", Lite(&_val.ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PatWild> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PatWild");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Path> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Path");
- if let Some(val) = &_val.leading_colon {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("leading_colon", Print::ref_cast(val));
- }
- if !_val.segments.is_empty() {
- formatter.field("segments", Lite(&_val.segments));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PathArguments> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::PathArguments::None => formatter.write_str("None"),
- syn::PathArguments::AngleBracketed(_val) => {
- let mut formatter = formatter.debug_struct("PathArguments::AngleBracketed");
- if let Some(val) = &_val.colon2_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon2);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon2_token", Print::ref_cast(val));
- }
- if !_val.args.is_empty() {
- formatter.field("args", Lite(&_val.args));
- }
- formatter.finish()
- }
- syn::PathArguments::Parenthesized(_val) => {
- let mut formatter = formatter.debug_struct("PathArguments::Parenthesized");
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.finish()
- }
- }
- }
-}
-impl Debug for Lite<syn::PathSegment> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PathSegment");
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("arguments", Lite(&_val.arguments));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PredicateEq> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PredicateEq");
- formatter.field("lhs_ty", Lite(&_val.lhs_ty));
- formatter.field("rhs_ty", Lite(&_val.rhs_ty));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PredicateLifetime> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PredicateLifetime");
- formatter.field("lifetime", Lite(&_val.lifetime));
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::PredicateType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("PredicateType");
- if let Some(val) = &_val.lifetimes {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::BoundLifetimes);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("lifetimes", Print::ref_cast(val));
- }
- formatter.field("bounded_ty", Lite(&_val.bounded_ty));
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::QSelf> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("QSelf");
- formatter.field("ty", Lite(&_val.ty));
- formatter.field("position", Lite(&_val.position));
- if let Some(val) = &_val.as_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::As);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("as_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::RangeLimits> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::RangeLimits::HalfOpen(_val) => {
- formatter.write_str("HalfOpen")?;
- Ok(())
- }
- syn::RangeLimits::Closed(_val) => {
- formatter.write_str("Closed")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Receiver> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Receiver");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- if let Some(val) = &_val.reference {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::And, Option<syn::Lifetime>));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(
- {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(Option<syn::Lifetime>);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- match &self.0 {
- Some(_val) => {
- formatter.write_str("Some")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- None => formatter.write_str("None"),
- }
- }
- }
- Print::ref_cast(&_val.1)
- },
- formatter,
- )?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("reference", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::ReturnType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::ReturnType::Default => formatter.write_str("Default"),
- syn::ReturnType::Type(_v0, _v1) => {
- let mut formatter = formatter.debug_tuple("Type");
- formatter.field(Lite(_v1));
- formatter.finish()
- }
- }
- }
-}
-impl Debug for Lite<syn::Signature> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Signature");
- if let Some(val) = &_val.constness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Const);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("constness", Print::ref_cast(val));
- }
- if let Some(val) = &_val.asyncness {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Async);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("asyncness", Print::ref_cast(val));
- }
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- if let Some(val) = &_val.abi {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Abi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("abi", Print::ref_cast(val));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- if let Some(val) = &_val.variadic {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Variadic);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("variadic", Print::ref_cast(val));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Stmt> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Stmt::Local(_val) => {
- formatter.write_str("Local")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Stmt::Item(_val) => {
- formatter.write_str("Item")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Stmt::Expr(_val) => {
- formatter.write_str("Expr")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::Stmt::Semi(_v0, _v1) => {
- let mut formatter = formatter.debug_tuple("Semi");
- formatter.field(Lite(_v0));
- formatter.finish()
- }
- }
- }
-}
-impl Debug for Lite<syn::TraitBound> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TraitBound");
- if let Some(val) = &_val.paren_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Paren);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("paren_token", Print::ref_cast(val));
- }
- formatter.field("modifier", Lite(&_val.modifier));
- if let Some(val) = &_val.lifetimes {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::BoundLifetimes);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("lifetimes", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TraitBoundModifier> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::TraitBoundModifier::None => formatter.write_str("None"),
- syn::TraitBoundModifier::Maybe(_val) => {
- formatter.write_str("Maybe")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::TraitItem> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::TraitItem::Const(_val) => {
- let mut formatter = formatter.debug_struct("TraitItem::Const");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Eq, syn::Expr));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::TraitItem::Method(_val) => {
- let mut formatter = formatter.debug_struct("TraitItem::Method");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("sig", Lite(&_val.sig));
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Block);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::TraitItem::Type(_val) => {
- let mut formatter = formatter.debug_struct("TraitItem::Type");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Eq, syn::Type));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::TraitItem::Macro(_val) => {
- let mut formatter = formatter.debug_struct("TraitItem::Macro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
- syn::TraitItem::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::TraitItemConst> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TraitItemConst");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("ty", Lite(&_val.ty));
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Eq, syn::Expr));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TraitItemMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TraitItemMacro");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("mac", Lite(&_val.mac));
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TraitItemMethod> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TraitItemMethod");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("sig", Lite(&_val.sig));
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Block);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- if let Some(val) = &_val.semi_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Semi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("semi_token", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TraitItemType> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TraitItemType");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("generics", Lite(&_val.generics));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Eq, syn::Type));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Type> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Type::Array(_val) => {
- let mut formatter = formatter.debug_struct("Type::Array");
- formatter.field("elem", Lite(&_val.elem));
- formatter.field("len", Lite(&_val.len));
- formatter.finish()
- }
- syn::Type::BareFn(_val) => {
- let mut formatter = formatter.debug_struct("Type::BareFn");
- if let Some(val) = &_val.lifetimes {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::BoundLifetimes);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("lifetimes", Print::ref_cast(val));
- }
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- if let Some(val) = &_val.abi {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Abi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("abi", Print::ref_cast(val));
- }
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- if let Some(val) = &_val.variadic {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Variadic);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("variadic", Print::ref_cast(val));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.finish()
- }
- syn::Type::Group(_val) => {
- let mut formatter = formatter.debug_struct("Type::Group");
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
- syn::Type::ImplTrait(_val) => {
- let mut formatter = formatter.debug_struct("Type::ImplTrait");
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
- syn::Type::Infer(_val) => {
- let mut formatter = formatter.debug_struct("Type::Infer");
- formatter.finish()
- }
- syn::Type::Macro(_val) => {
- let mut formatter = formatter.debug_struct("Type::Macro");
- formatter.field("mac", Lite(&_val.mac));
- formatter.finish()
- }
- syn::Type::Never(_val) => {
- let mut formatter = formatter.debug_struct("Type::Never");
- formatter.finish()
- }
- syn::Type::Paren(_val) => {
- let mut formatter = formatter.debug_struct("Type::Paren");
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
- syn::Type::Path(_val) => {
- let mut formatter = formatter.debug_struct("Type::Path");
- if let Some(val) = &_val.qself {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::QSelf);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("qself", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
- syn::Type::Ptr(_val) => {
- let mut formatter = formatter.debug_struct("Type::Ptr");
- if let Some(val) = &_val.const_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Const);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("const_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
- syn::Type::Reference(_val) => {
- let mut formatter = formatter.debug_struct("Type::Reference");
- if let Some(val) = &_val.lifetime {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Lifetime);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("lifetime", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
- syn::Type::Slice(_val) => {
- let mut formatter = formatter.debug_struct("Type::Slice");
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
- syn::Type::TraitObject(_val) => {
- let mut formatter = formatter.debug_struct("Type::TraitObject");
- if let Some(val) = &_val.dyn_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Dyn);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("dyn_token", Print::ref_cast(val));
- }
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
- syn::Type::Tuple(_val) => {
- let mut formatter = formatter.debug_struct("Type::Tuple");
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
- syn::Type::Verbatim(_val) => {
- formatter.write_str("Verbatim")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- _ => unreachable!(),
- }
- }
-}
-impl Debug for Lite<syn::TypeArray> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeArray");
- formatter.field("elem", Lite(&_val.elem));
- formatter.field("len", Lite(&_val.len));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeBareFn> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeBareFn");
- if let Some(val) = &_val.lifetimes {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::BoundLifetimes);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("lifetimes", Print::ref_cast(val));
- }
- if let Some(val) = &_val.unsafety {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Unsafe);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("unsafety", Print::ref_cast(val));
- }
- if let Some(val) = &_val.abi {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Abi);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("abi", Print::ref_cast(val));
- }
- if !_val.inputs.is_empty() {
- formatter.field("inputs", Lite(&_val.inputs));
- }
- if let Some(val) = &_val.variadic {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Variadic);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("variadic", Print::ref_cast(val));
- }
- formatter.field("output", Lite(&_val.output));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeGroup> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeGroup");
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeImplTrait> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeImplTrait");
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeInfer> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeInfer");
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeMacro> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeMacro");
- formatter.field("mac", Lite(&_val.mac));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeNever> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeNever");
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeParam> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeParam");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- if let Some(val) = &_val.colon_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Colon);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("colon_token", Print::ref_cast(val));
- }
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- if let Some(val) = &_val.eq_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Eq);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("eq_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.default {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Type);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("default", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeParamBound> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::TypeParamBound::Trait(_val) => {
- formatter.write_str("Trait")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::TypeParamBound::Lifetime(_val) => {
- formatter.write_str("Lifetime")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::TypeParen> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeParen");
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypePath> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypePath");
- if let Some(val) = &_val.qself {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::QSelf);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("qself", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypePtr> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypePtr");
- if let Some(val) = &_val.const_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Const);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("const_token", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeReference> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeReference");
- if let Some(val) = &_val.lifetime {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::Lifetime);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("lifetime", Print::ref_cast(val));
- }
- if let Some(val) = &_val.mutability {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Mut);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("mutability", Print::ref_cast(val));
- }
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeSlice> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeSlice");
- formatter.field("elem", Lite(&_val.elem));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeTraitObject> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeTraitObject");
- if let Some(val) = &_val.dyn_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::Dyn);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("dyn_token", Print::ref_cast(val));
- }
- if !_val.bounds.is_empty() {
- formatter.field("bounds", Lite(&_val.bounds));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::TypeTuple> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("TypeTuple");
- if !_val.elems.is_empty() {
- formatter.field("elems", Lite(&_val.elems));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::UnOp> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::UnOp::Deref(_val) => {
- formatter.write_str("Deref")?;
- Ok(())
- }
- syn::UnOp::Not(_val) => {
- formatter.write_str("Not")?;
- Ok(())
- }
- syn::UnOp::Neg(_val) => {
- formatter.write_str("Neg")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::UseGlob> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("UseGlob");
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::UseGroup> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("UseGroup");
- if !_val.items.is_empty() {
- formatter.field("items", Lite(&_val.items));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::UseName> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("UseName");
- formatter.field("ident", Lite(&_val.ident));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::UsePath> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("UsePath");
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("tree", Lite(&_val.tree));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::UseRename> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("UseRename");
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("rename", Lite(&_val.rename));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::UseTree> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::UseTree::Path(_val) => {
- formatter.write_str("Path")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::UseTree::Name(_val) => {
- formatter.write_str("Name")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::UseTree::Rename(_val) => {
- formatter.write_str("Rename")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::UseTree::Glob(_val) => {
- formatter.write_str("Glob")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::UseTree::Group(_val) => {
- formatter.write_str("Group")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
-impl Debug for Lite<syn::Variadic> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Variadic");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Variant> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("Variant");
- if !_val.attrs.is_empty() {
- formatter.field("attrs", Lite(&_val.attrs));
- }
- formatter.field("ident", Lite(&_val.ident));
- formatter.field("fields", Lite(&_val.fields));
- if let Some(val) = &_val.discriminant {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print((syn::token::Eq, syn::Expr));
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- let _val = &self.0;
- formatter.write_str("(")?;
- Debug::fmt(Lite(&_val.1), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- formatter.field("discriminant", Print::ref_cast(val));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::VisCrate> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("VisCrate");
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::VisPublic> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("VisPublic");
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::VisRestricted> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("VisRestricted");
- if let Some(val) = &_val.in_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::In);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("in_token", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::Visibility> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::Visibility::Public(_val) => {
- let mut formatter = formatter.debug_struct("Visibility::Public");
- formatter.finish()
- }
- syn::Visibility::Crate(_val) => {
- let mut formatter = formatter.debug_struct("Visibility::Crate");
- formatter.finish()
- }
- syn::Visibility::Restricted(_val) => {
- let mut formatter = formatter.debug_struct("Visibility::Restricted");
- if let Some(val) = &_val.in_token {
- #[derive(RefCast)]
- #[repr(transparent)]
- struct Print(syn::token::In);
- impl Debug for Print {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("Some")?;
- Ok(())
- }
- }
- formatter.field("in_token", Print::ref_cast(val));
- }
- formatter.field("path", Lite(&_val.path));
- formatter.finish()
- }
- syn::Visibility::Inherited => formatter.write_str("Inherited"),
- }
- }
-}
-impl Debug for Lite<syn::WhereClause> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- let mut formatter = formatter.debug_struct("WhereClause");
- if !_val.predicates.is_empty() {
- formatter.field("predicates", Lite(&_val.predicates));
- }
- formatter.finish()
- }
-}
-impl Debug for Lite<syn::WherePredicate> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- let _val = &self.value;
- match _val {
- syn::WherePredicate::Type(_val) => {
- formatter.write_str("Type")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::WherePredicate::Lifetime(_val) => {
- formatter.write_str("Lifetime")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- syn::WherePredicate::Eq(_val) => {
- formatter.write_str("Eq")?;
- formatter.write_str("(")?;
- Debug::fmt(Lite(_val), formatter)?;
- formatter.write_str(")")?;
- Ok(())
- }
- }
- }
-}
diff --git a/syn/tests/debug/mod.rs b/syn/tests/debug/mod.rs
deleted file mode 100644
index 9c80e2c..0000000
--- a/syn/tests/debug/mod.rs
+++ /dev/null
@@ -1,110 +0,0 @@
-mod gen;
-
-use proc_macro2::{Ident, Literal, TokenStream};
-use ref_cast::RefCast;
-use std::fmt::{self, Debug};
-use std::ops::Deref;
-use syn::punctuated::Punctuated;
-
-#[derive(RefCast)]
-#[repr(transparent)]
-pub struct Lite<T: ?Sized> {
- value: T,
-}
-
-#[allow(non_snake_case)]
-pub fn Lite<T: ?Sized>(value: &T) -> &Lite<T> {
- Lite::ref_cast(value)
-}
-
-impl<T: ?Sized> Deref for Lite<T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- &self.value
- }
-}
-
-impl Debug for Lite<bool> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "{}", self.value)
- }
-}
-
-impl Debug for Lite<u32> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "{}", self.value)
- }
-}
-
-impl Debug for Lite<usize> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "{}", self.value)
- }
-}
-
-impl Debug for Lite<String> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "{:?}", self.value)
- }
-}
-
-impl Debug for Lite<Ident> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "{:?}", self.value.to_string())
- }
-}
-
-impl Debug for Lite<Literal> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "{}", self.value)
- }
-}
-
-impl Debug for Lite<TokenStream> {
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- write!(formatter, "`{}`", self.value)
- }
-}
-
-impl<'a, T> Debug for Lite<&'a T>
-where
- Lite<T>: Debug,
-{
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- Debug::fmt(Lite(&*self.value), formatter)
- }
-}
-
-impl<T> Debug for Lite<Box<T>>
-where
- Lite<T>: Debug,
-{
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- Debug::fmt(Lite(&*self.value), formatter)
- }
-}
-
-impl<T> Debug for Lite<Vec<T>>
-where
- Lite<T>: Debug,
-{
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_list()
- .entries(self.value.iter().map(Lite))
- .finish()
- }
-}
-
-impl<T, P> Debug for Lite<Punctuated<T, P>>
-where
- Lite<T>: Debug,
-{
- fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter
- .debug_list()
- .entries(self.value.iter().map(Lite))
- .finish()
- }
-}
diff --git a/syn/tests/features/error.rs b/syn/tests/features/error.rs
deleted file mode 100644
index 10ac889..0000000
--- a/syn/tests/features/error.rs
+++ /dev/null
@@ -1 +0,0 @@
-"Hello! You want: cargo test --release --all-features"
diff --git a/syn/tests/features/mod.rs b/syn/tests/features/mod.rs
deleted file mode 100644
index 83fbe13..0000000
--- a/syn/tests/features/mod.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#[allow(unused_macros)]
-macro_rules! hide_from_rustfmt {
- ($mod:item) => {
- $mod
- };
-}
-
-#[cfg(not(all(
- feature = "derive",
- feature = "full",
- feature = "parsing",
- feature = "printing",
- feature = "visit",
- feature = "visit-mut",
- feature = "fold",
- feature = "clone-impls",
- feature = "extra-traits",
- feature = "proc-macro",
-)))]
-hide_from_rustfmt! {
- mod error;
-}
diff --git a/syn/tests/macros/mod.rs b/syn/tests/macros/mod.rs
deleted file mode 100644
index 3994615..0000000
--- a/syn/tests/macros/mod.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-#[path = "../debug/mod.rs"]
-pub mod debug;
-
-use syn;
-use syn::parse::{Parse, Result};
-
-#[macro_export]
-macro_rules! errorf {
- ($($tt:tt)*) => {{
- use ::std::io::Write;
- let stderr = ::std::io::stderr();
- write!(stderr.lock(), $($tt)*).unwrap();
- }};
-}
-
-#[macro_export]
-macro_rules! punctuated {
- ($($e:expr,)+) => {{
- let mut seq = ::syn::punctuated::Punctuated::new();
- $(
- seq.push($e);
- )+
- seq
- }};
-
- ($($e:expr),+) => {
- punctuated!($($e,)+)
- };
-}
-
-#[macro_export]
-macro_rules! snapshot {
- ($($args:tt)*) => {
- snapshot_impl!(() $($args)*)
- };
-}
-
-#[macro_export]
-macro_rules! snapshot_impl {
- (($expr:ident) as $t:ty, @$snapshot:literal) => {
- let $expr = crate::macros::Tokens::parse::<$t>($expr).unwrap();
- let debug = crate::macros::debug::Lite(&$expr);
- insta::assert_debug_snapshot!(debug, @$snapshot);
- };
- (($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{
- let syntax_tree = crate::macros::Tokens::parse::<$t>($($expr)*).unwrap();
- let debug = crate::macros::debug::Lite(&syntax_tree);
- insta::assert_debug_snapshot!(debug, @$snapshot);
- syntax_tree
- }};
- (($($expr:tt)*) , @$snapshot:literal) => {{
- let syntax_tree = $($expr)*;
- let debug = crate::macros::debug::Lite(&syntax_tree);
- insta::assert_debug_snapshot!(debug, @$snapshot);
- syntax_tree
- }};
- (($($expr:tt)*) $next:tt $($rest:tt)*) => {
- snapshot_impl!(($($expr)* $next) $($rest)*)
- };
-}
-
-pub trait Tokens {
- fn parse<T: Parse>(self) -> Result<T>;
-}
-
-impl<'a> Tokens for &'a str {
- fn parse<T: Parse>(self) -> Result<T> {
- syn::parse_str(self)
- }
-}
-
-impl Tokens for proc_macro2::TokenStream {
- fn parse<T: Parse>(self) -> Result<T> {
- syn::parse2(self)
- }
-}
diff --git a/syn/tests/repo/mod.rs b/syn/tests/repo/mod.rs
deleted file mode 100644
index 681615c..0000000
--- a/syn/tests/repo/mod.rs
+++ /dev/null
@@ -1,109 +0,0 @@
-mod progress;
-
-use self::progress::Progress;
-use crate::common;
-use anyhow::Result;
-use flate2::read::GzDecoder;
-use std::fs;
-use std::path::Path;
-use tar::Archive;
-use walkdir::DirEntry;
-
-const REVISION: &str = "7979016aff545f7b41cc517031026020b340989d";
-
-pub fn base_dir_filter(entry: &DirEntry) -> bool {
- let path = entry.path();
- if path.is_dir() {
- return true; // otherwise walkdir does not visit the files
- }
- if path.extension().map(|e| e != "rs").unwrap_or(true) {
- return false;
- }
- let path_string = path.to_string_lossy();
- let path_string = if cfg!(windows) {
- path_string.replace('\\', "/").into()
- } else {
- path_string
- };
- // TODO assert that parsing fails on the parse-fail cases
- if path_string.starts_with("tests/rust/src/test/parse-fail")
- || path_string.starts_with("tests/rust/src/test/compile-fail")
- || path_string.starts_with("tests/rust/src/test/rustfix")
- {
- return false;
- }
-
- if path_string.starts_with("tests/rust/src/test/ui") {
- let stderr_path = path.with_extension("stderr");
- if stderr_path.exists() {
- // Expected to fail in some way
- return false;
- }
- }
-
- match path_string.as_ref() {
- // Deprecated placement syntax
- "tests/rust/src/test/ui/obsolete-in-place/bad.rs" |
- // Deprecated anonymous parameter syntax in traits
- "tests/rust/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs" |
- "tests/rust/src/test/ui/issues/issue-13105.rs" |
- "tests/rust/src/test/ui/issues/issue-13775.rs" |
- "tests/rust/src/test/ui/issues/issue-34074.rs" |
- // Deprecated await macro syntax
- "tests/rust/src/test/ui/async-await/await-macro.rs" |
- // 2015-style dyn that libsyntax rejects
- "tests/rust/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs" |
- // not actually test cases
- "tests/rust/src/test/ui/include-single-expr-helper.rs" |
- "tests/rust/src/test/ui/include-single-expr-helper-1.rs" |
- "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" |
- "tests/rust/src/test/ui/macros/auxiliary/macro-comma-support.rs" |
- "tests/rust/src/test/ui/macros/auxiliary/macro-include-items-expr.rs" => false,
- _ => true,
- }
-}
-
-pub fn clone_rust() {
- let needs_clone = match fs::read_to_string("tests/rust/COMMIT") {
- Err(_) => true,
- Ok(contents) => contents.trim() != REVISION,
- };
- if needs_clone {
- download_and_unpack().unwrap();
- }
-}
-
-fn download_and_unpack() -> Result<()> {
- let url = format!(
- "https://github.com/rust-lang/rust/archive/{}.tar.gz",
- REVISION
- );
- let response = reqwest::blocking::get(&url)?.error_for_status()?;
- let progress = Progress::new(response);
- let decoder = GzDecoder::new(progress);
- let mut archive = Archive::new(decoder);
- let prefix = format!("rust-{}", REVISION);
-
- let tests_rust = Path::new("tests/rust");
- if tests_rust.exists() {
- fs::remove_dir_all(tests_rust)?;
- }
-
- for entry in archive.entries()? {
- let mut entry = entry?;
- let path = entry.path()?;
- if path == Path::new("pax_global_header") {
- continue;
- }
- let relative = path.strip_prefix(&prefix)?;
- let out = tests_rust.join(relative);
- entry.unpack(&out)?;
- if common::travis_ci() {
- // Something about this makes the travis build not deadlock...
- errorf!(".");
- }
- }
-
- fs::write("tests/rust/COMMIT", REVISION)?;
- Ok(())
-}
diff --git a/syn/tests/repo/progress.rs b/syn/tests/repo/progress.rs
deleted file mode 100644
index 28c8a44..0000000
--- a/syn/tests/repo/progress.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-use std::io::{Read, Result};
-use std::time::{Duration, Instant};
-
-pub struct Progress<R> {
- bytes: usize,
- tick: Instant,
- stream: R,
-}
-
-impl<R> Progress<R> {
- pub fn new(stream: R) -> Self {
- Progress {
- bytes: 0,
- tick: Instant::now() + Duration::from_millis(2000),
- stream,
- }
- }
-}
-
-impl<R: Read> Read for Progress<R> {
- fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
- let num = self.stream.read(buf)?;
- self.bytes += num;
- let now = Instant::now();
- if now > self.tick {
- self.tick = now + Duration::from_millis(500);
- errorf!("downloading... {} bytes\n", self.bytes);
- }
- Ok(num)
- }
-}
-
-impl<R> Drop for Progress<R> {
- fn drop(&mut self) {
- errorf!("done ({} bytes)\n", self.bytes);
- }
-}
diff --git a/syn/tests/test_asyncness.rs b/syn/tests/test_asyncness.rs
deleted file mode 100644
index e09e816..0000000
--- a/syn/tests/test_asyncness.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use syn::{Expr, Item};
-
-#[test]
-fn test_async_fn() {
- let input = "async fn process() {}";
-
- snapshot!(input as Item, @r###"
- Item::Fn {
- vis: Inherited,
- sig: Signature {
- asyncness: Some,
- ident: "process",
- generics: Generics,
- output: Default,
- },
- block: Block,
- }
- "###);
-}
-
-#[test]
-fn test_async_closure() {
- let input = "async || {}";
-
- snapshot!(input as Expr, @r###"
- Expr::Closure {
- asyncness: Some,
- output: Default,
- body: Expr::Block {
- block: Block,
- },
- }
- "###);
-}
diff --git a/syn/tests/test_attribute.rs b/syn/tests/test_attribute.rs
deleted file mode 100644
index d77c0c0..0000000
--- a/syn/tests/test_attribute.rs
+++ /dev/null
@@ -1,296 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use syn::parse::Parser;
-use syn::{Attribute, Meta};
-
-#[test]
-fn test_meta_item_word() {
- let meta = test("#[foo]");
-
- snapshot!(meta, @r###"
- Path(Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- })
- "###);
-}
-
-#[test]
-fn test_meta_item_name_value() {
- let meta = test("#[foo = 5]");
-
- snapshot!(meta, @r###"
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-}
-
-#[test]
-fn test_meta_item_bool_value() {
- let meta = test("#[foo = true]");
-
- snapshot!(meta, @r###"
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- lit: Lit::Bool {
- value: true,
- },
- }
- "###);
-
- let meta = test("#[foo = false]");
-
- snapshot!(meta, @r###"
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- lit: Lit::Bool {
- value: false,
- },
- }
- "###);
-}
-
-#[test]
-fn test_meta_item_list_lit() {
- let meta = test("#[foo(5)]");
-
- snapshot!(meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Lit(5),
- ],
- }
- "###);
-}
-
-#[test]
-fn test_meta_item_list_word() {
- let meta = test("#[foo(bar)]");
-
- snapshot!(meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "bar",
- arguments: None,
- },
- ],
- })),
- ],
- }
- "###);
-}
-
-#[test]
-fn test_meta_item_list_name_value() {
- let meta = test("#[foo(bar = 5)]");
-
- snapshot!(meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "bar",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }),
- ],
- }
- "###);
-}
-
-#[test]
-fn test_meta_item_list_bool_value() {
- let meta = test("#[foo(bar = true)]");
-
- snapshot!(meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "bar",
- arguments: None,
- },
- ],
- },
- lit: Lit::Bool {
- value: true,
- },
- }),
- ],
- }
- "###);
-}
-
-#[test]
-fn test_meta_item_multiple() {
- let meta = test("#[foo(word, name = 5, list(name2 = 6), word2)]");
-
- snapshot!(meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "word",
- arguments: None,
- },
- ],
- })),
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }),
- Meta(Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "list",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name2",
- arguments: None,
- },
- ],
- },
- lit: 6,
- }),
- ],
- }),
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "word2",
- arguments: None,
- },
- ],
- })),
- ],
- }
- "###);
-}
-
-#[test]
-fn test_bool_lit() {
- let meta = test("#[foo(true)]");
-
- snapshot!(meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Lit(Lit::Bool {
- value: true,
- }),
- ],
- }
- "###);
-}
-
-fn test(input: &str) -> Meta {
- let attrs = Attribute::parse_outer.parse_str(input).unwrap();
-
- assert_eq!(attrs.len(), 1);
- let attr = attrs.into_iter().next().unwrap();
-
- attr.parse_meta().unwrap()
-}
diff --git a/syn/tests/test_derive_input.rs b/syn/tests/test_derive_input.rs
deleted file mode 100644
index e3685ae..0000000
--- a/syn/tests/test_derive_input.rs
+++ /dev/null
@@ -1,894 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use quote::quote;
-use syn::{Data, DeriveInput};
-
-#[test]
-fn test_unit() {
- let input = quote! {
- struct Unit;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "Unit",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-}
-
-#[test]
-fn test_struct() {
- let input = quote! {
- #[derive(Debug, Clone)]
- pub struct Item {
- pub ident: Ident,
- pub attrs: Vec<Attribute>
- }
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- attrs: [
- Attribute {
- style: Outer,
- path: Path {
- segments: [
- PathSegment {
- ident: "derive",
- arguments: None,
- },
- ],
- },
- tokens: `( Debug , Clone )`,
- },
- ],
- vis: Visibility::Public,
- ident: "Item",
- generics: Generics,
- data: Data::Struct {
- fields: Fields::Named {
- named: [
- Field {
- vis: Visibility::Public,
- ident: Some("ident"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "Ident",
- arguments: None,
- },
- ],
- },
- },
- },
- Field {
- vis: Visibility::Public,
- ident: Some("attrs"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "Vec",
- arguments: PathArguments::AngleBracketed {
- args: [
- Type(Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "Attribute",
- arguments: None,
- },
- ],
- },
- }),
- ],
- },
- },
- ],
- },
- },
- },
- ],
- },
- },
- }
- "###);
-
- snapshot!(input.attrs[0].parse_meta().unwrap(), @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "derive",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "Debug",
- arguments: None,
- },
- ],
- })),
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "Clone",
- arguments: None,
- },
- ],
- })),
- ],
- }
- "###);
-}
-
-#[test]
-fn test_union() {
- let input = quote! {
- union MaybeUninit<T> {
- uninit: (),
- value: T
- }
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "MaybeUninit",
- generics: Generics {
- lt_token: Some,
- params: [
- Type(TypeParam {
- ident: "T",
- }),
- ],
- gt_token: Some,
- },
- data: Data::Union {
- fields: FieldsNamed {
- named: [
- Field {
- vis: Inherited,
- ident: Some("uninit"),
- colon_token: Some,
- ty: Type::Tuple,
- },
- Field {
- vis: Inherited,
- ident: Some("value"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "T",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- },
- }
- "###);
-}
-
-#[test]
-#[cfg(feature = "full")]
-fn test_enum() {
- let input = quote! {
- /// See the std::result module documentation for details.
- #[must_use]
- pub enum Result<T, E> {
- Ok(T),
- Err(E),
- Surprise = 0isize,
-
- // Smuggling data into a proc_macro_derive,
- // in the style of https://github.com/dtolnay/proc-macro-hack
- ProcMacroHack = (0, "data").0
- }
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- attrs: [
- Attribute {
- style: Outer,
- path: Path {
- segments: [
- PathSegment {
- ident: "doc",
- arguments: None,
- },
- ],
- },
- tokens: `= r" See the std::result module documentation for details."`,
- },
- Attribute {
- style: Outer,
- path: Path {
- segments: [
- PathSegment {
- ident: "must_use",
- arguments: None,
- },
- ],
- },
- tokens: ``,
- },
- ],
- vis: Visibility::Public,
- ident: "Result",
- generics: Generics {
- lt_token: Some,
- params: [
- Type(TypeParam {
- ident: "T",
- }),
- Type(TypeParam {
- ident: "E",
- }),
- ],
- gt_token: Some,
- },
- data: Data::Enum {
- variants: [
- Variant {
- ident: "Ok",
- fields: Fields::Unnamed {
- unnamed: [
- Field {
- vis: Inherited,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "T",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- },
- Variant {
- ident: "Err",
- fields: Fields::Unnamed {
- unnamed: [
- Field {
- vis: Inherited,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "E",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- },
- Variant {
- ident: "Surprise",
- fields: Unit,
- discriminant: Some(Expr::Lit {
- lit: 0isize,
- }),
- },
- Variant {
- ident: "ProcMacroHack",
- fields: Unit,
- discriminant: Some(Expr::Field {
- base: Expr::Tuple {
- elems: [
- Expr::Lit {
- lit: 0,
- },
- Expr::Lit {
- lit: "data",
- },
- ],
- },
- member: Unnamed(Index {
- index: 0,
- }),
- }),
- },
- ],
- },
- }
- "###);
-
- let meta_items: Vec<_> = input
- .attrs
- .into_iter()
- .map(|attr| attr.parse_meta().unwrap())
- .collect();
-
- snapshot!(meta_items, @r###"
- [
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "doc",
- arguments: None,
- },
- ],
- },
- lit: " See the std::result module documentation for details.",
- },
- Path(Path {
- segments: [
- PathSegment {
- ident: "must_use",
- arguments: None,
- },
- ],
- }),
- ]
- "###);
-}
-
-#[test]
-fn test_attr_with_path() {
- let input = quote! {
- #[::attr_args::identity
- fn main() { assert_eq!(foo(), "Hello, world!"); }]
- struct Dummy;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- attrs: [
- Attribute {
- style: Outer,
- path: Path {
- leading_colon: Some,
- segments: [
- PathSegment {
- ident: "attr_args",
- arguments: None,
- },
- PathSegment {
- ident: "identity",
- arguments: None,
- },
- ],
- },
- tokens: `fn main ( ) { assert_eq ! ( foo ( ) , "Hello, world!" ) ; }`,
- },
- ],
- vis: Inherited,
- ident: "Dummy",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-
- assert!(input.attrs[0].parse_meta().is_err());
-}
-
-#[test]
-fn test_attr_with_non_mod_style_path() {
- let input = quote! {
- #[inert <T>]
- struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- attrs: [
- Attribute {
- style: Outer,
- path: Path {
- segments: [
- PathSegment {
- ident: "inert",
- arguments: None,
- },
- ],
- },
- tokens: `< T >`,
- },
- ],
- vis: Inherited,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-
- assert!(input.attrs[0].parse_meta().is_err());
-}
-
-#[test]
-fn test_attr_with_mod_style_path_with_self() {
- let input = quote! {
- #[foo::self]
- struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- attrs: [
- Attribute {
- style: Outer,
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- PathSegment {
- ident: "self",
- arguments: None,
- },
- ],
- },
- tokens: ``,
- },
- ],
- vis: Inherited,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-
- snapshot!(input.attrs[0].parse_meta().unwrap(), @r###"
- Path(Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- PathSegment {
- ident: "self",
- arguments: None,
- },
- ],
- })
- "###);
-}
-
-#[test]
-fn test_pub_restricted() {
- // Taken from tests/rust/src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs
- let input = quote! {
- pub(in m) struct Z(pub(in m::n) u8);
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Visibility::Restricted {
- in_token: Some,
- path: Path {
- segments: [
- PathSegment {
- ident: "m",
- arguments: None,
- },
- ],
- },
- },
- ident: "Z",
- generics: Generics,
- data: Data::Struct {
- fields: Fields::Unnamed {
- unnamed: [
- Field {
- vis: Visibility::Restricted {
- in_token: Some,
- path: Path {
- segments: [
- PathSegment {
- ident: "m",
- arguments: None,
- },
- PathSegment {
- ident: "n",
- arguments: None,
- },
- ],
- },
- },
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "u8",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- semi_token: Some,
- },
- }
- "###);
-}
-
-#[test]
-fn test_vis_crate() {
- let input = quote! {
- crate struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Visibility::Crate,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-}
-
-#[test]
-fn test_pub_restricted_crate() {
- let input = quote! {
- pub(crate) struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Visibility::Restricted {
- path: Path {
- segments: [
- PathSegment {
- ident: "crate",
- arguments: None,
- },
- ],
- },
- },
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-}
-
-#[test]
-fn test_pub_restricted_super() {
- let input = quote! {
- pub(super) struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Visibility::Restricted {
- path: Path {
- segments: [
- PathSegment {
- ident: "super",
- arguments: None,
- },
- ],
- },
- },
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-}
-
-#[test]
-fn test_pub_restricted_in_super() {
- let input = quote! {
- pub(in super) struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Visibility::Restricted {
- in_token: Some,
- path: Path {
- segments: [
- PathSegment {
- ident: "super",
- arguments: None,
- },
- ],
- },
- },
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-}
-
-#[test]
-fn test_fields_on_unit_struct() {
- let input = quote! {
- struct S;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-
- let data = match input.data {
- Data::Struct(data) => data,
- _ => panic!("expected a struct"),
- };
-
- assert_eq!(0, data.fields.iter().count());
-}
-
-#[test]
-fn test_fields_on_named_struct() {
- let input = quote! {
- struct S {
- foo: i32,
- pub bar: String,
- }
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Fields::Named {
- named: [
- Field {
- vis: Inherited,
- ident: Some("foo"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "i32",
- arguments: None,
- },
- ],
- },
- },
- },
- Field {
- vis: Visibility::Public,
- ident: Some("bar"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "String",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- },
- }
- "###);
-
- let data = match input.data {
- Data::Struct(data) => data,
- _ => panic!("expected a struct"),
- };
-
- snapshot!(data.fields.into_iter().collect::<Vec<_>>(), @r###"
- [
- Field {
- vis: Inherited,
- ident: Some("foo"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "i32",
- arguments: None,
- },
- ],
- },
- },
- },
- Field {
- vis: Visibility::Public,
- ident: Some("bar"),
- colon_token: Some,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "String",
- arguments: None,
- },
- ],
- },
- },
- },
- ]
- "###);
-}
-
-#[test]
-fn test_fields_on_tuple_struct() {
- let input = quote! {
- struct S(i32, pub String);
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Fields::Unnamed {
- unnamed: [
- Field {
- vis: Inherited,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "i32",
- arguments: None,
- },
- ],
- },
- },
- },
- Field {
- vis: Visibility::Public,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "String",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- semi_token: Some,
- },
- }
- "###);
-
- let data = match input.data {
- Data::Struct(data) => data,
- _ => panic!("expected a struct"),
- };
-
- snapshot!(data.fields.iter().collect::<Vec<_>>(), @r###"
- [
- Field {
- vis: Inherited,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "i32",
- arguments: None,
- },
- ],
- },
- },
- },
- Field {
- vis: Visibility::Public,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "String",
- arguments: None,
- },
- ],
- },
- },
- },
- ]
- "###);
-}
-
-#[test]
-fn test_ambiguous_crate() {
- let input = quote! {
- // The field type is `(crate::X)` not `crate (::X)`.
- struct S(crate::X);
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "S",
- generics: Generics,
- data: Data::Struct {
- fields: Fields::Unnamed {
- unnamed: [
- Field {
- vis: Inherited,
- ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "crate",
- arguments: None,
- },
- PathSegment {
- ident: "X",
- arguments: None,
- },
- ],
- },
- },
- },
- ],
- },
- semi_token: Some,
- },
- }
- "###);
-}
diff --git a/syn/tests/test_expr.rs b/syn/tests/test_expr.rs
deleted file mode 100644
index 0edf6ce..0000000
--- a/syn/tests/test_expr.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#[macro_use]
-mod macros;
-
-use std::str::FromStr;
-
-use proc_macro2::TokenStream;
-use syn::{Expr, ExprRange};
-
-#[test]
-fn test_expr_parse() {
- let code = "..100u32";
- let tt = TokenStream::from_str(code).unwrap();
- let expr: Expr = syn::parse2(tt.clone()).unwrap();
- let expr_range: ExprRange = syn::parse2(tt).unwrap();
- assert_eq!(expr, Expr::Range(expr_range));
-}
-
-#[test]
-fn test_await() {
- // Must not parse as Expr::Field.
- let expr = syn::parse_str::<Expr>("fut.await").unwrap();
-
- snapshot!(expr, @r###"
- Expr::Await {
- base: Expr::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "fut",
- arguments: None,
- },
- ],
- },
- },
- }
- "###);
-}
diff --git a/syn/tests/test_generics.rs b/syn/tests/test_generics.rs
deleted file mode 100644
index e863b77..0000000
--- a/syn/tests/test_generics.rs
+++ /dev/null
@@ -1,285 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use quote::quote;
-use syn::{DeriveInput, ItemFn, TypeParamBound, WhereClause, WherePredicate};
-
-#[test]
-fn test_split_for_impl() {
- let input = quote! {
- struct S<'a, 'b: 'a, #[may_dangle] T: 'a = ()> where T: Debug;
- };
-
- snapshot!(input as DeriveInput, @r###"
- DeriveInput {
- vis: Inherited,
- ident: "S",
- generics: Generics {
- lt_token: Some,
- params: [
- Lifetime(LifetimeDef {
- lifetime: Lifetime {
- ident: "a",
- },
- }),
- Lifetime(LifetimeDef {
- lifetime: Lifetime {
- ident: "b",
- },
- colon_token: Some,
- bounds: [
- Lifetime {
- ident: "a",
- },
- ],
- }),
- Type(TypeParam {
- attrs: [
- Attribute {
- style: Outer,
- path: Path {
- segments: [
- PathSegment {
- ident: "may_dangle",
- arguments: None,
- },
- ],
- },
- tokens: ``,
- },
- ],
- ident: "T",
- colon_token: Some,
- bounds: [
- Lifetime(Lifetime {
- ident: "a",
- }),
- ],
- eq_token: Some,
- default: Some(Type::Tuple),
- }),
- ],
- gt_token: Some,
- where_clause: Some(WhereClause {
- predicates: [
- Type(PredicateType {
- bounded_ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "T",
- arguments: None,
- },
- ],
- },
- },
- bounds: [
- Trait(TraitBound {
- modifier: None,
- path: Path {
- segments: [
- PathSegment {
- ident: "Debug",
- arguments: None,
- },
- ],
- },
- }),
- ],
- }),
- ],
- }),
- },
- data: Data::Struct {
- fields: Unit,
- semi_token: Some,
- },
- }
- "###);
-
- let generics = input.generics;
- let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
-
- let generated = quote! {
- impl #impl_generics MyTrait for Test #ty_generics #where_clause {}
- };
- let expected = quote! {
- impl<'a, 'b: 'a, #[may_dangle] T: 'a> MyTrait
- for Test<'a, 'b, T>
- where
- T: Debug
- {}
- };
- assert_eq!(generated.to_string(), expected.to_string());
-
- let turbofish = ty_generics.as_turbofish();
- let generated = quote! {
- Test #turbofish
- };
- let expected = quote! {
- Test::<'a, 'b, T>
- };
- assert_eq!(generated.to_string(), expected.to_string());
-}
-
-#[test]
-fn test_ty_param_bound() {
- let tokens = quote!('a);
- snapshot!(tokens as TypeParamBound, @r###"
- Lifetime(Lifetime {
- ident: "a",
- })
- "###);
-
- let tokens = quote!('_);
- snapshot!(tokens as TypeParamBound, @r###"
- Lifetime(Lifetime {
- ident: "_",
- })
- "###);
-
- let tokens = quote!(Debug);
- snapshot!(tokens as TypeParamBound, @r###"
- Trait(TraitBound {
- modifier: None,
- path: Path {
- segments: [
- PathSegment {
- ident: "Debug",
- arguments: None,
- },
- ],
- },
- })
- "###);
-
- let tokens = quote!(?Sized);
- snapshot!(tokens as TypeParamBound, @r###"
- Trait(TraitBound {
- modifier: Maybe,
- path: Path {
- segments: [
- PathSegment {
- ident: "Sized",
- arguments: None,
- },
- ],
- },
- })
- "###);
-}
-
-#[test]
-fn test_fn_precedence_in_where_clause() {
- // This should parse as two separate bounds, `FnOnce() -> i32` and `Send` - not
- // `FnOnce() -> (i32 + Send)`.
- let input = quote! {
- fn f<G>()
- where
- G: FnOnce() -> i32 + Send,
- {
- }
- };
-
- snapshot!(input as ItemFn, @r###"
- ItemFn {
- vis: Inherited,
- sig: Signature {
- ident: "f",
- generics: Generics {
- lt_token: Some,
- params: [
- Type(TypeParam {
- ident: "G",
- }),
- ],
- gt_token: Some,
- where_clause: Some(WhereClause {
- predicates: [
- Type(PredicateType {
- bounded_ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "G",
- arguments: None,
- },
- ],
- },
- },
- bounds: [
- Trait(TraitBound {
- modifier: None,
- path: Path {
- segments: [
- PathSegment {
- ident: "FnOnce",
- arguments: PathArguments::Parenthesized {
- output: Type(
- Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "i32",
- arguments: None,
- },
- ],
- },
- },
- ),
- },
- },
- ],
- },
- }),
- Trait(TraitBound {
- modifier: None,
- path: Path {
- segments: [
- PathSegment {
- ident: "Send",
- arguments: None,
- },
- ],
- },
- }),
- ],
- }),
- ],
- }),
- },
- output: Default,
- },
- block: Block,
- }
- "###);
-
- let where_clause = input.sig.generics.where_clause.as_ref().unwrap();
- assert_eq!(where_clause.predicates.len(), 1);
-
- let predicate = match &where_clause.predicates[0] {
- WherePredicate::Type(pred) => pred,
- _ => panic!("wrong predicate kind"),
- };
-
- assert_eq!(predicate.bounds.len(), 2, "{:#?}", predicate.bounds);
-
- let first_bound = &predicate.bounds[0];
- assert_eq!(quote!(#first_bound).to_string(), "FnOnce ( ) -> i32");
-
- let second_bound = &predicate.bounds[1];
- assert_eq!(quote!(#second_bound).to_string(), "Send");
-}
-
-#[test]
-fn test_where_clause_at_end_of_input() {
- let input = quote! {
- where
- };
-
- snapshot!(input as WhereClause, @"WhereClause");
-
- assert_eq!(input.predicates.len(), 0);
-}
diff --git a/syn/tests/test_grouping.rs b/syn/tests/test_grouping.rs
deleted file mode 100644
index 4e43ab8..0000000
--- a/syn/tests/test_grouping.rs
+++ /dev/null
@@ -1,55 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree};
-use syn::Expr;
-
-use std::iter::FromIterator;
-
-#[test]
-fn test_grouping() {
- let tokens: TokenStream = TokenStream::from_iter(vec![
- TokenTree::Literal(Literal::i32_suffixed(1)),
- TokenTree::Punct(Punct::new('+', Spacing::Alone)),
- TokenTree::Group(Group::new(
- Delimiter::None,
- TokenStream::from_iter(vec![
- TokenTree::Literal(Literal::i32_suffixed(2)),
- TokenTree::Punct(Punct::new('+', Spacing::Alone)),
- TokenTree::Literal(Literal::i32_suffixed(3)),
- ]),
- )),
- TokenTree::Punct(Punct::new('*', Spacing::Alone)),
- TokenTree::Literal(Literal::i32_suffixed(4)),
- ]);
-
- assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32");
-
- snapshot!(tokens as Expr, @r###"
- Expr::Binary {
- left: Expr::Lit {
- lit: 1i32,
- },
- op: Add,
- right: Expr::Binary {
- left: Expr::Group {
- expr: Expr::Binary {
- left: Expr::Lit {
- lit: 2i32,
- },
- op: Add,
- right: Expr::Lit {
- lit: 3i32,
- },
- },
- },
- op: Mul,
- right: Expr::Lit {
- lit: 4i32,
- },
- },
- }
- "###);
-}
diff --git a/syn/tests/test_ident.rs b/syn/tests/test_ident.rs
deleted file mode 100644
index 7578381..0000000
--- a/syn/tests/test_ident.rs
+++ /dev/null
@@ -1,87 +0,0 @@
-mod features;
-
-use proc_macro2::{Ident, Span, TokenStream};
-use std::str::FromStr;
-use syn::Result;
-
-fn parse(s: &str) -> Result<Ident> {
- syn::parse2(TokenStream::from_str(s).unwrap())
-}
-
-fn new(s: &str) -> Ident {
- Ident::new(s, Span::call_site())
-}
-
-#[test]
-fn ident_parse() {
- parse("String").unwrap();
-}
-
-#[test]
-fn ident_parse_keyword() {
- parse("abstract").unwrap_err();
-}
-
-#[test]
-fn ident_parse_empty() {
- parse("").unwrap_err();
-}
-
-#[test]
-fn ident_parse_lifetime() {
- parse("'static").unwrap_err();
-}
-
-#[test]
-fn ident_parse_underscore() {
- parse("_").unwrap_err();
-}
-
-#[test]
-fn ident_parse_number() {
- parse("255").unwrap_err();
-}
-
-#[test]
-fn ident_parse_invalid() {
- parse("a#").unwrap_err();
-}
-
-#[test]
-fn ident_new() {
- new("String");
-}
-
-#[test]
-fn ident_new_keyword() {
- new("abstract");
-}
-
-#[test]
-#[should_panic(expected = "use Option<Ident>")]
-fn ident_new_empty() {
- new("");
-}
-
-#[test]
-#[should_panic(expected = "not a valid Ident")]
-fn ident_new_lifetime() {
- new("'static");
-}
-
-#[test]
-fn ident_new_underscore() {
- new("_");
-}
-
-#[test]
-#[should_panic(expected = "use Literal instead")]
-fn ident_new_number() {
- new("255");
-}
-
-#[test]
-#[should_panic(expected = "\"a#\" is not a valid Ident")]
-fn ident_new_invalid() {
- new("a#");
-}
diff --git a/syn/tests/test_iterators.rs b/syn/tests/test_iterators.rs
deleted file mode 100644
index f107297..0000000
--- a/syn/tests/test_iterators.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use syn::punctuated::{Pair, Punctuated};
-use syn::Token;
-
-mod features;
-
-#[macro_use]
-mod macros;
-
-macro_rules! check_exact_size_iterator {
- ($iter:expr) => {{
- let iter = $iter;
- let size_hint = iter.size_hint();
- let len = iter.len();
- let count = iter.count();
- assert_eq!(len, count);
- assert_eq!(size_hint, (count, Some(count)));
- }};
-}
-
-#[test]
-fn pairs() {
- let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4);
-
- check_exact_size_iterator!(p.pairs());
- check_exact_size_iterator!(p.pairs_mut());
- check_exact_size_iterator!(p.into_pairs());
-
- let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4);
-
- assert_eq!(p.pairs().next_back().map(Pair::into_value), Some(&4));
- assert_eq!(
- p.pairs_mut().next_back().map(Pair::into_value),
- Some(&mut 4)
- );
- assert_eq!(p.into_pairs().next_back().map(Pair::into_value), Some(4));
-}
-
-#[test]
-fn iter() {
- let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4);
-
- check_exact_size_iterator!(p.iter());
- check_exact_size_iterator!(p.iter_mut());
- check_exact_size_iterator!(p.into_iter());
-
- let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4);
-
- assert_eq!(p.iter().next_back(), Some(&4));
- assert_eq!(p.iter_mut().next_back(), Some(&mut 4));
- assert_eq!(p.into_iter().next_back(), Some(4));
-}
diff --git a/syn/tests/test_lit.rs b/syn/tests/test_lit.rs
deleted file mode 100644
index 0b300c4..0000000
--- a/syn/tests/test_lit.rs
+++ /dev/null
@@ -1,184 +0,0 @@
-mod features;
-
-use proc_macro2::{TokenStream, TokenTree};
-use quote::ToTokens;
-use std::str::FromStr;
-use syn::Lit;
-
-fn lit(s: &str) -> Lit {
- match TokenStream::from_str(s)
- .unwrap()
- .into_iter()
- .next()
- .unwrap()
- {
- TokenTree::Literal(lit) => Lit::new(lit),
- _ => panic!(),
- }
-}
-
-#[test]
-fn strings() {
- fn test_string(s: &str, value: &str) {
- match lit(s) {
- Lit::Str(lit) => {
- assert_eq!(lit.value(), value);
- let again = lit.into_token_stream().to_string();
- if again != s {
- test_string(&again, value);
- }
- }
- wrong => panic!("{:?}", wrong),
- }
- }
-
- test_string("\"a\"", "a");
- test_string("\"\\n\"", "\n");
- test_string("\"\\r\"", "\r");
- test_string("\"\\t\"", "\t");
- test_string("\"🐕\"", "🐕"); // NOTE: This is an emoji
- test_string("\"\\\"\"", "\"");
- test_string("\"'\"", "'");
- test_string("\"\"", "");
- test_string("\"\\u{1F415}\"", "\u{1F415}");
- test_string(
- "\"contains\nnewlines\\\nescaped newlines\"",
- "contains\nnewlinesescaped newlines",
- );
- test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere");
-}
-
-#[test]
-fn byte_strings() {
- fn test_byte_string(s: &str, value: &[u8]) {
- match lit(s) {
- Lit::ByteStr(lit) => {
- assert_eq!(lit.value(), value);
- let again = lit.into_token_stream().to_string();
- if again != s {
- test_byte_string(&again, value);
- }
- }
- wrong => panic!("{:?}", wrong),
- }
- }
-
- test_byte_string("b\"a\"", b"a");
- test_byte_string("b\"\\n\"", b"\n");
- test_byte_string("b\"\\r\"", b"\r");
- test_byte_string("b\"\\t\"", b"\t");
- test_byte_string("b\"\\\"\"", b"\"");
- test_byte_string("b\"'\"", b"'");
- test_byte_string("b\"\"", b"");
- test_byte_string(
- "b\"contains\nnewlines\\\nescaped newlines\"",
- b"contains\nnewlinesescaped newlines",
- );
- test_byte_string("br\"raw\nstring\\\nhere\"", b"raw\nstring\\\nhere");
-}
-
-#[test]
-fn bytes() {
- fn test_byte(s: &str, value: u8) {
- match lit(s) {
- Lit::Byte(lit) => {
- assert_eq!(lit.value(), value);
- let again = lit.into_token_stream().to_string();
- assert_eq!(again, s);
- }
- wrong => panic!("{:?}", wrong),
- }
- }
-
- test_byte("b'a'", b'a');
- test_byte("b'\\n'", b'\n');
- test_byte("b'\\r'", b'\r');
- test_byte("b'\\t'", b'\t');
- test_byte("b'\\''", b'\'');
- test_byte("b'\"'", b'"');
-}
-
-#[test]
-fn chars() {
- fn test_char(s: &str, value: char) {
- match lit(s) {
- Lit::Char(lit) => {
- assert_eq!(lit.value(), value);
- let again = lit.into_token_stream().to_string();
- if again != s {
- test_char(&again, value);
- }
- }
- wrong => panic!("{:?}", wrong),
- }
- }
-
- test_char("'a'", 'a');
- test_char("'\\n'", '\n');
- test_char("'\\r'", '\r');
- test_char("'\\t'", '\t');
- test_char("'🐕'", '🐕'); // NOTE: This is an emoji
- test_char("'\\''", '\'');
- test_char("'\"'", '"');
- test_char("'\\u{1F415}'", '\u{1F415}');
-}
-
-#[test]
-fn ints() {
- fn test_int(s: &str, value: u64, suffix: &str) {
- match lit(s) {
- Lit::Int(lit) => {
- assert_eq!(lit.base10_digits().parse::<u64>().unwrap(), value);
- assert_eq!(lit.suffix(), suffix);
- let again = lit.into_token_stream().to_string();
- if again != s {
- test_int(&again, value, suffix);
- }
- }
- wrong => panic!("{:?}", wrong),
- }
- }
-
- test_int("5", 5, "");
- test_int("5u32", 5, "u32");
- test_int("5_0", 50, "");
- test_int("5_____0_____", 50, "");
- test_int("0x7f", 127, "");
- test_int("0x7F", 127, "");
- test_int("0b1001", 9, "");
- test_int("0o73", 59, "");
- test_int("0x7Fu8", 127, "u8");
- test_int("0b1001i8", 9, "i8");
- test_int("0o73u32", 59, "u32");
- test_int("0x__7___f_", 127, "");
- test_int("0x__7___F_", 127, "");
- test_int("0b_1_0__01", 9, "");
- test_int("0o_7__3", 59, "");
- test_int("0x_7F__u8", 127, "u8");
- test_int("0b__10__0_1i8", 9, "i8");
- test_int("0o__7__________________3u32", 59, "u32");
-}
-
-#[test]
-fn floats() {
- #[cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
- fn test_float(s: &str, value: f64, suffix: &str) {
- match lit(s) {
- Lit::Float(lit) => {
- assert_eq!(lit.base10_digits().parse::<f64>().unwrap(), value);
- assert_eq!(lit.suffix(), suffix);
- let again = lit.into_token_stream().to_string();
- if again != s {
- test_float(&again, value, suffix);
- }
- }
- wrong => panic!("{:?}", wrong),
- }
- }
-
- test_float("5.5", 5.5, "");
- test_float("5.5E12", 5.5e12, "");
- test_float("5.5e12", 5.5e12, "");
- test_float("1.0__3e-12", 1.03e-12, "");
- test_float("1.03e+12", 1.03e12, "");
-}
diff --git a/syn/tests/test_meta.rs b/syn/tests/test_meta.rs
deleted file mode 100644
index 618296e..0000000
--- a/syn/tests/test_meta.rs
+++ /dev/null
@@ -1,341 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use syn::{Meta, MetaList, MetaNameValue, NestedMeta};
-
-#[test]
-fn test_parse_meta_item_word() {
- let input = "hello";
-
- snapshot!(input as Meta, @r###"
- Path(Path {
- segments: [
- PathSegment {
- ident: "hello",
- arguments: None,
- },
- ],
- })
- "###);
-}
-
-#[test]
-fn test_parse_meta_name_value() {
- let input = "foo = 5";
- let (inner, meta) = (input, input);
-
- snapshot!(inner as MetaNameValue, @r###"
- MetaNameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-
- snapshot!(meta as Meta, @r###"
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-
- assert_eq!(meta, inner.into());
-}
-
-#[test]
-fn test_parse_meta_name_value_with_keyword() {
- let input = "static = 5";
- let (inner, meta) = (input, input);
-
- snapshot!(inner as MetaNameValue, @r###"
- MetaNameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "static",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-
- snapshot!(meta as Meta, @r###"
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "static",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-
- assert_eq!(meta, inner.into());
-}
-
-#[test]
-fn test_parse_meta_name_value_with_bool() {
- let input = "true = 5";
- let (inner, meta) = (input, input);
-
- snapshot!(inner as MetaNameValue, @r###"
- MetaNameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "true",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-
- snapshot!(meta as Meta, @r###"
- Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "true",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }
- "###);
-
- assert_eq!(meta, inner.into());
-}
-
-#[test]
-fn test_parse_meta_item_list_lit() {
- let input = "foo(5)";
- let (inner, meta) = (input, input);
-
- snapshot!(inner as MetaList, @r###"
- MetaList {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Lit(5),
- ],
- }
- "###);
-
- snapshot!(meta as Meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Lit(5),
- ],
- }
- "###);
-
- assert_eq!(meta, inner.into());
-}
-
-#[test]
-fn test_parse_meta_item_multiple() {
- let input = "foo(word, name = 5, list(name2 = 6), word2)";
- let (inner, meta) = (input, input);
-
- snapshot!(inner as MetaList, @r###"
- MetaList {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "word",
- arguments: None,
- },
- ],
- })),
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }),
- Meta(Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "list",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name2",
- arguments: None,
- },
- ],
- },
- lit: 6,
- }),
- ],
- }),
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "word2",
- arguments: None,
- },
- ],
- })),
- ],
- }
- "###);
-
- snapshot!(meta as Meta, @r###"
- Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "foo",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "word",
- arguments: None,
- },
- ],
- })),
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name",
- arguments: None,
- },
- ],
- },
- lit: 5,
- }),
- Meta(Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "list",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name2",
- arguments: None,
- },
- ],
- },
- lit: 6,
- }),
- ],
- }),
- Meta(Path(Path {
- segments: [
- PathSegment {
- ident: "word2",
- arguments: None,
- },
- ],
- })),
- ],
- }
- "###);
-
- assert_eq!(meta, inner.into());
-}
-
-#[test]
-fn test_parse_nested_meta() {
- let input = "5";
- snapshot!(input as NestedMeta, @"Lit(5)");
-
- let input = "list(name2 = 6)";
- snapshot!(input as NestedMeta, @r###"
- Meta(Meta::List {
- path: Path {
- segments: [
- PathSegment {
- ident: "list",
- arguments: None,
- },
- ],
- },
- nested: [
- Meta(Meta::NameValue {
- path: Path {
- segments: [
- PathSegment {
- ident: "name2",
- arguments: None,
- },
- ],
- },
- lit: 6,
- }),
- ],
- })
- "###);
-}
diff --git a/syn/tests/test_parse_buffer.rs b/syn/tests/test_parse_buffer.rs
deleted file mode 100644
index d3f10c0..0000000
--- a/syn/tests/test_parse_buffer.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use syn::parenthesized;
-use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result};
-
-#[test]
-#[should_panic(expected = "Fork was not derived from the advancing parse stream")]
-fn smuggled_speculative_cursor_between_sources() {
- struct BreakRules;
- impl Parse for BreakRules {
- fn parse(input1: ParseStream) -> Result<Self> {
- let nested = |input2: ParseStream| {
- input1.advance_to(&input2);
- Ok(Self)
- };
- nested.parse_str("")
- }
- }
-
- syn::parse_str::<BreakRules>("").unwrap();
-}
-
-#[test]
-#[should_panic(expected = "Fork was not derived from the advancing parse stream")]
-fn smuggled_speculative_cursor_between_brackets() {
- struct BreakRules;
- impl Parse for BreakRules {
- fn parse(input: ParseStream) -> Result<Self> {
- let a;
- let b;
- parenthesized!(a in input);
- parenthesized!(b in input);
- a.advance_to(&b);
- Ok(Self)
- }
- }
-
- syn::parse_str::<BreakRules>("()()").unwrap();
-}
-
-#[test]
-#[should_panic(expected = "Fork was not derived from the advancing parse stream")]
-fn smuggled_speculative_cursor_into_brackets() {
- struct BreakRules;
- impl Parse for BreakRules {
- fn parse(input: ParseStream) -> Result<Self> {
- let a;
- parenthesized!(a in input);
- input.advance_to(&a);
- Ok(Self)
- }
- }
-
- syn::parse_str::<BreakRules>("()").unwrap();
-}
diff --git a/syn/tests/test_pat.rs b/syn/tests/test_pat.rs
deleted file mode 100644
index cce4b80..0000000
--- a/syn/tests/test_pat.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-mod features;
-
-use quote::quote;
-use syn::Pat;
-
-#[test]
-fn test_pat_ident() {
- match syn::parse2(quote!(self)).unwrap() {
- Pat::Ident(_) => (),
- value => panic!("expected PatIdent, got {:?}", value),
- }
-}
-
-#[test]
-fn test_pat_path() {
- match syn::parse2(quote!(self::CONST)).unwrap() {
- Pat::Path(_) => (),
- value => panic!("expected PatPath, got {:?}", value),
- }
-}
diff --git a/syn/tests/test_precedence.rs b/syn/tests/test_precedence.rs
deleted file mode 100644
index 3529c06..0000000
--- a/syn/tests/test_precedence.rs
+++ /dev/null
@@ -1,394 +0,0 @@
-#![cfg(not(syn_disable_nightly_tests))]
-#![recursion_limit = "1024"]
-#![feature(rustc_private)]
-
-//! The tests in this module do the following:
-//!
-//! 1. Parse a given expression in both `syn` and `libsyntax`.
-//! 2. Fold over the expression adding brackets around each subexpression (with
-//! some complications - see the `syn_brackets` and `libsyntax_brackets`
-//! methods).
-//! 3. Serialize the `syn` expression back into a string, and re-parse it with
-//! `libsyntax`.
-//! 4. Respan all of the expressions, replacing the spans with the default
-//! spans.
-//! 5. Compare the expressions with one another, if they are not equal fail.
-
-extern crate rustc_data_structures;
-extern crate rustc_span;
-extern crate syntax;
-
-mod features;
-
-use quote::quote;
-use rayon::iter::{IntoParallelIterator, ParallelIterator};
-use regex::Regex;
-use rustc_span::edition::Edition;
-use syntax::ast;
-use syntax::ptr::P;
-use walkdir::{DirEntry, WalkDir};
-
-use std::fs::File;
-use std::io::Read;
-use std::process;
-use std::sync::atomic::{AtomicUsize, Ordering};
-
-use common::eq::SpanlessEq;
-use common::parse;
-
-#[macro_use]
-mod macros;
-
-#[allow(dead_code)]
-mod common;
-
-mod repo;
-
-/// Test some pre-set expressions chosen by us.
-#[test]
-fn test_simple_precedence() {
- const EXPRS: &[&str] = &[
- "1 + 2 * 3 + 4",
- "1 + 2 * ( 3 + 4 )",
- "{ for i in r { } *some_ptr += 1; }",
- "{ loop { break 5; } }",
- "{ if true { () }.mthd() }",
- "{ for i in unsafe { 20 } { } }",
- ];
-
- let mut failed = 0;
-
- for input in EXPRS {
- let expr = if let Some(expr) = parse::syn_expr(input) {
- expr
- } else {
- failed += 1;
- continue;
- };
-
- let pf = match test_expressions(vec![expr]) {
- (1, 0) => "passed",
- (0, 1) => {
- failed += 1;
- "failed"
- }
- _ => unreachable!(),
- };
- errorf!("=== {}: {}\n", input, pf);
- }
-
- if failed > 0 {
- panic!("Failed {} tests", failed);
- }
-}
-
-/// Test expressions from rustc, like in `test_round_trip`.
-#[test]
-fn test_rustc_precedence() {
- repo::clone_rust();
- let abort_after = common::abort_after();
- if abort_after == 0 {
- panic!("Skipping all precedence tests");
- }
-
- let passed = AtomicUsize::new(0);
- let failed = AtomicUsize::new(0);
-
- // 2018 edition is hard
- let edition_regex = Regex::new(r"\b(async|try)[!(]").unwrap();
-
- WalkDir::new("tests/rust")
- .sort_by(|a, b| a.file_name().cmp(b.file_name()))
- .into_iter()
- .filter_entry(repo::base_dir_filter)
- .collect::<Result<Vec<DirEntry>, walkdir::Error>>()
- .unwrap()
- .into_par_iter()
- .for_each(|entry| {
- let path = entry.path();
- if path.is_dir() {
- return;
- }
-
- // Our version of `libsyntax` can't parse this tests
- if path
- .to_str()
- .unwrap()
- .ends_with("optional_comma_in_match_arm.rs")
- {
- return;
- }
-
- let mut file = File::open(path).unwrap();
- let mut content = String::new();
- file.read_to_string(&mut content).unwrap();
- let content = edition_regex.replace_all(&content, "_$0");
-
- let (l_passed, l_failed) = match syn::parse_file(&content) {
- Ok(file) => {
- let exprs = collect_exprs(file);
- test_expressions(exprs)
- }
- Err(msg) => {
- errorf!("syn failed to parse\n{:?}\n", msg);
- (0, 1)
- }
- };
-
- errorf!(
- "=== {}: {} passed | {} failed\n",
- path.display(),
- l_passed,
- l_failed
- );
-
- passed.fetch_add(l_passed, Ordering::SeqCst);
- let prev_failed = failed.fetch_add(l_failed, Ordering::SeqCst);
-
- if prev_failed + l_failed >= abort_after {
- process::exit(1);
- }
- });
-
- let passed = passed.load(Ordering::SeqCst);
- let failed = failed.load(Ordering::SeqCst);
-
- errorf!("\n===== Precedence Test Results =====\n");
- errorf!("{} passed | {} failed\n", passed, failed);
-
- if failed > 0 {
- panic!("{} failures", failed);
- }
-}
-
-fn test_expressions(exprs: Vec<syn::Expr>) -> (usize, usize) {
- let mut passed = 0;
- let mut failed = 0;
-
- syntax::with_globals(Edition::Edition2018, || {
- for expr in exprs {
- let raw = quote!(#expr).to_string();
-
- let libsyntax_ast = if let Some(e) = libsyntax_parse_and_rewrite(&raw) {
- e
- } else {
- failed += 1;
- errorf!("\nFAIL - libsyntax failed to parse raw\n");
- continue;
- };
-
- let syn_expr = syn_brackets(expr);
- let syn_ast = if let Some(e) = parse::libsyntax_expr(&quote!(#syn_expr).to_string()) {
- e
- } else {
- failed += 1;
- errorf!("\nFAIL - libsyntax failed to parse bracketed\n");
- continue;
- };
-
- if SpanlessEq::eq(&syn_ast, &libsyntax_ast) {
- passed += 1;
- } else {
- failed += 1;
- errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, libsyntax_ast);
- }
- }
- });
-
- (passed, failed)
-}
-
-fn libsyntax_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> {
- parse::libsyntax_expr(input).and_then(libsyntax_brackets)
-}
-
-/// Wrap every expression which is not already wrapped in parens with parens, to
-/// reveal the precidence of the parsed expressions, and produce a stringified
-/// form of the resulting expression.
-///
-/// This method operates on libsyntax objects.
-fn libsyntax_brackets(mut libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
- use rustc_data_structures::thin_vec::ThinVec;
- use rustc_span::DUMMY_SP;
- use std::mem;
- use syntax::ast::{Block, Expr, ExprKind, Field, Mac, Pat, Stmt, StmtKind, Ty};
- use syntax::mut_visit::MutVisitor;
- use syntax::util::map_in_place::MapInPlace;
-
- struct BracketsVisitor {
- failed: bool,
- };
-
- fn flat_map_field<T: MutVisitor>(mut f: Field, vis: &mut T) -> Vec<Field> {
- if f.is_shorthand {
- noop_visit_expr(&mut f.expr, vis);
- } else {
- vis.visit_expr(&mut f.expr);
- }
- vec![f]
- }
-
- fn flat_map_stmt<T: MutVisitor>(stmt: Stmt, vis: &mut T) -> Vec<Stmt> {
- let kind = match stmt.kind {
- // Don't wrap toplevel expressions in statements.
- StmtKind::Expr(mut e) => {
- noop_visit_expr(&mut e, vis);
- StmtKind::Expr(e)
- }
- StmtKind::Semi(mut e) => {
- noop_visit_expr(&mut e, vis);
- StmtKind::Semi(e)
- }
- s => s,
- };
-
- vec![Stmt { kind, ..stmt }]
- }
-
- fn noop_visit_expr<T: MutVisitor>(e: &mut Expr, vis: &mut T) {
- use syntax::mut_visit::{noop_visit_expr, visit_opt, visit_thin_attrs};
- match &mut e.kind {
- ExprKind::Struct(path, fields, expr) => {
- vis.visit_path(path);
- fields.flat_map_in_place(|field| flat_map_field(field, vis));
- visit_opt(expr, |expr| vis.visit_expr(expr));
- vis.visit_id(&mut e.id);
- vis.visit_span(&mut e.span);
- visit_thin_attrs(&mut e.attrs, vis);
- }
- _ => noop_visit_expr(e, vis),
- }
- }
-
- impl MutVisitor for BracketsVisitor {
- fn visit_expr(&mut self, e: &mut P<Expr>) {
- noop_visit_expr(e, self);
- match e.kind {
- ExprKind::If(..) | ExprKind::Block(..) | ExprKind::Let(..) => {}
- _ => {
- let inner = mem::replace(
- e,
- P(Expr {
- id: ast::DUMMY_NODE_ID,
- kind: ExprKind::Err,
- span: DUMMY_SP,
- attrs: ThinVec::new(),
- }),
- );
- e.kind = ExprKind::Paren(inner);
- }
- }
- }
-
- fn visit_block(&mut self, block: &mut P<Block>) {
- self.visit_id(&mut block.id);
- block
- .stmts
- .flat_map_in_place(|stmt| flat_map_stmt(stmt, self));
- self.visit_span(&mut block.span);
- }
-
- // We don't want to look at expressions that might appear in patterns or
- // types yet. We'll look into comparing those in the future. For now
- // focus on expressions appearing in other places.
- fn visit_pat(&mut self, pat: &mut P<Pat>) {
- let _ = pat;
- }
-
- fn visit_ty(&mut self, ty: &mut P<Ty>) {
- let _ = ty;
- }
-
- fn visit_mac(&mut self, mac: &mut Mac) {
- // By default when folding over macros, libsyntax panics. This is
- // because it's usually not what you want, you want to run after
- // macro expansion. We do want to do that (syn doesn't do macro
- // expansion), so we implement visit_mac to just return the macro
- // unchanged.
- let _ = mac;
- }
- }
-
- let mut folder = BracketsVisitor { failed: false };
- folder.visit_expr(&mut libsyntax_expr);
- if folder.failed {
- None
- } else {
- Some(libsyntax_expr)
- }
-}
-
-/// Wrap every expression which is not already wrapped in parens with parens, to
-/// reveal the precedence of the parsed expressions, and produce a stringified
-/// form of the resulting expression.
-fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr {
- use syn::fold::*;
- use syn::*;
-
- struct ParenthesizeEveryExpr;
- impl Fold for ParenthesizeEveryExpr {
- fn fold_expr(&mut self, expr: Expr) -> Expr {
- match expr {
- Expr::Group(_) => unreachable!(),
- Expr::If(..) | Expr::Unsafe(..) | Expr::Block(..) | Expr::Let(..) => {
- fold_expr(self, expr)
- }
- _ => Expr::Paren(ExprParen {
- attrs: Vec::new(),
- expr: Box::new(fold_expr(self, expr)),
- paren_token: token::Paren::default(),
- }),
- }
- }
-
- fn fold_stmt(&mut self, stmt: Stmt) -> Stmt {
- match stmt {
- // Don't wrap toplevel expressions in statements.
- Stmt::Expr(e) => Stmt::Expr(fold_expr(self, e)),
- Stmt::Semi(e, semi) => Stmt::Semi(fold_expr(self, e), semi),
- s => s,
- }
- }
-
- // We don't want to look at expressions that might appear in patterns or
- // types yet. We'll look into comparing those in the future. For now
- // focus on expressions appearing in other places.
- fn fold_pat(&mut self, pat: Pat) -> Pat {
- pat
- }
-
- fn fold_type(&mut self, ty: Type) -> Type {
- ty
- }
- }
-
- let mut folder = ParenthesizeEveryExpr;
- folder.fold_expr(syn_expr)
-}
-
-/// Walk through a crate collecting all expressions we can find in it.
-fn collect_exprs(file: syn::File) -> Vec<syn::Expr> {
- use syn::fold::*;
- use syn::punctuated::Punctuated;
- use syn::*;
-
- struct CollectExprs(Vec<Expr>);
- impl Fold for CollectExprs {
- fn fold_expr(&mut self, expr: Expr) -> Expr {
- match expr {
- Expr::Verbatim(tokens) if tokens.is_empty() => {}
- _ => self.0.push(expr),
- }
-
- Expr::Tuple(ExprTuple {
- attrs: vec![],
- elems: Punctuated::new(),
- paren_token: token::Paren::default(),
- })
- }
- }
-
- let mut folder = CollectExprs(vec![]);
- folder.fold_file(file);
- folder.0
-}
diff --git a/syn/tests/test_receiver.rs b/syn/tests/test_receiver.rs
deleted file mode 100644
index 168db8f..0000000
--- a/syn/tests/test_receiver.rs
+++ /dev/null
@@ -1,109 +0,0 @@
-mod features;
-
-use syn::{FnArg, Receiver, TraitItemMethod};
-
-#[test]
-fn test_by_value() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn by_value(self: Self););
- match sig.receiver() {
- Some(FnArg::Typed(_)) => (),
- value => panic!("expected FnArg::Typed, got {:?}", value),
- }
-}
-
-#[test]
-fn test_by_mut_value() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn by_mut(mut self: Self););
- match sig.receiver() {
- Some(FnArg::Typed(_)) => (),
- value => panic!("expected FnArg::Typed, got {:?}", value),
- }
-}
-
-#[test]
-fn test_by_ref() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn by_ref(self: &Self););
- match sig.receiver() {
- Some(FnArg::Typed(_)) => (),
- value => panic!("expected FnArg::Typed, got {:?}", value),
- }
-}
-
-#[test]
-fn test_by_box() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn by_box(self: Box<Self>););
- match sig.receiver() {
- Some(FnArg::Typed(_)) => (),
- value => panic!("expected FnArg::Typed, got {:?}", value),
- }
-}
-
-#[test]
-fn test_by_pin() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn by_pin(self: Pin<Self>););
- match sig.receiver() {
- Some(FnArg::Typed(_)) => (),
- value => panic!("expected FnArg::Typed, got {:?}", value),
- }
-}
-
-#[test]
-fn test_explicit_type() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn explicit_type(self: Pin<MyType>););
- match sig.receiver() {
- Some(FnArg::Typed(_)) => (),
- value => panic!("expected FnArg::Typed, got {:?}", value),
- }
-}
-
-#[test]
-fn test_value_shorthand() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn value_shorthand(self););
- match sig.receiver() {
- Some(FnArg::Receiver(Receiver {
- reference: None,
- mutability: None,
- ..
- })) => (),
- value => panic!("expected FnArg::Receiver without ref/mut, got {:?}", value),
- }
-}
-
-#[test]
-fn test_mut_value_shorthand() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn mut_value_shorthand(mut self););
- match sig.receiver() {
- Some(FnArg::Receiver(Receiver {
- reference: None,
- mutability: Some(_),
- ..
- })) => (),
- value => panic!("expected FnArg::Receiver with mut, got {:?}", value),
- }
-}
-
-#[test]
-fn test_ref_shorthand() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn ref_shorthand(&self););
- match sig.receiver() {
- Some(FnArg::Receiver(Receiver {
- reference: Some(_),
- mutability: None,
- ..
- })) => (),
- value => panic!("expected FnArg::Receiver with ref, got {:?}", value),
- }
-}
-
-#[test]
-fn test_ref_mut_shorthand() {
- let TraitItemMethod { sig, .. } = syn::parse_quote!(fn ref_mut_shorthand(&mut self););
- match sig.receiver() {
- Some(FnArg::Receiver(Receiver {
- reference: Some(_),
- mutability: Some(_),
- ..
- })) => (),
- value => panic!("expected FnArg::Receiver with ref+mut, got {:?}", value),
- }
-}
diff --git a/syn/tests/test_round_trip.rs b/syn/tests/test_round_trip.rs
deleted file mode 100644
index 435bd6a..0000000
--- a/syn/tests/test_round_trip.rs
+++ /dev/null
@@ -1,151 +0,0 @@
-#![cfg(not(syn_disable_nightly_tests))]
-#![recursion_limit = "1024"]
-#![feature(rustc_private)]
-
-extern crate rustc_expand;
-extern crate rustc_parse as parse;
-extern crate rustc_span;
-extern crate syntax;
-
-mod features;
-
-use quote::quote;
-use rayon::iter::{IntoParallelIterator, ParallelIterator};
-use rustc_span::edition::Edition;
-use rustc_span::FileName;
-use syntax::ast;
-use syntax::errors::PResult;
-use syntax::sess::ParseSess;
-use syntax::source_map::FilePathMapping;
-use walkdir::{DirEntry, WalkDir};
-
-use std::fs::File;
-use std::io::Read;
-use std::panic;
-use std::process;
-use std::sync::atomic::{AtomicUsize, Ordering};
-use std::time::Instant;
-
-#[macro_use]
-mod macros;
-
-#[allow(dead_code)]
-mod common;
-
-mod repo;
-
-use common::eq::SpanlessEq;
-
-#[test]
-fn test_round_trip() {
- repo::clone_rust();
- let abort_after = common::abort_after();
- if abort_after == 0 {
- panic!("Skipping all round_trip tests");
- }
-
- let failed = AtomicUsize::new(0);
-
- WalkDir::new("tests/rust")
- .sort_by(|a, b| a.file_name().cmp(b.file_name()))
- .into_iter()
- .filter_entry(repo::base_dir_filter)
- .collect::<Result<Vec<DirEntry>, walkdir::Error>>()
- .unwrap()
- .into_par_iter()
- .for_each(|entry| {
- let path = entry.path();
- if path.is_dir() {
- return;
- }
-
- let mut file = File::open(path).unwrap();
- let mut content = String::new();
- file.read_to_string(&mut content).unwrap();
-
- let start = Instant::now();
- let (krate, elapsed) = match syn::parse_file(&content) {
- Ok(krate) => (krate, start.elapsed()),
- Err(msg) => {
- errorf!("=== {}: syn failed to parse\n{:?}\n", path.display(), msg);
- let prev_failed = failed.fetch_add(1, Ordering::SeqCst);
- if prev_failed + 1 >= abort_after {
- process::exit(1);
- }
- return;
- }
- };
- let back = quote!(#krate).to_string();
-
- let equal = panic::catch_unwind(|| {
- syntax::with_globals(Edition::Edition2018, || {
- let sess = ParseSess::new(FilePathMapping::empty());
- let before = match libsyntax_parse(content, &sess) {
- Ok(before) => before,
- Err(mut diagnostic) => {
- diagnostic.cancel();
- if diagnostic
- .message()
- .starts_with("file not found for module")
- {
- errorf!("=== {}: ignore\n", path.display());
- } else {
- errorf!(
- "=== {}: ignore - libsyntax failed to parse original content: {}\n",
- path.display(),
- diagnostic.message()
- );
- }
- return true;
- }
- };
- let after = match libsyntax_parse(back, &sess) {
- Ok(after) => after,
- Err(mut diagnostic) => {
- errorf!("=== {}: libsyntax failed to parse", path.display());
- diagnostic.emit();
- return false;
- }
- };
-
- if SpanlessEq::eq(&before, &after) {
- errorf!(
- "=== {}: pass in {}ms\n",
- path.display(),
- elapsed.as_secs() * 1000
- + u64::from(elapsed.subsec_nanos()) / 1_000_000
- );
- true
- } else {
- errorf!(
- "=== {}: FAIL\nbefore: {:#?}\nafter: {:#?}\n",
- path.display(),
- before,
- after,
- );
- false
- }
- })
- });
- match equal {
- Err(_) => errorf!("=== {}: ignoring libsyntax panic\n", path.display()),
- Ok(true) => {}
- Ok(false) => {
- let prev_failed = failed.fetch_add(1, Ordering::SeqCst);
- if prev_failed + 1 >= abort_after {
- process::exit(1);
- }
- }
- }
- });
-
- let failed = failed.load(Ordering::SeqCst);
- if failed > 0 {
- panic!("{} failures", failed);
- }
-}
-
-fn libsyntax_parse(content: String, sess: &ParseSess) -> PResult<ast::Crate> {
- let name = FileName::Custom("test_round_trip".to_string());
- parse::parse_crate_from_source_str(name, content, sess)
-}
diff --git a/syn/tests/test_should_parse.rs b/syn/tests/test_should_parse.rs
deleted file mode 100644
index d4f7ac3..0000000
--- a/syn/tests/test_should_parse.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-mod features;
-
-macro_rules! should_parse {
- ($name:ident, { $($in:tt)* }) => {
- #[test]
- fn $name() {
- // Make sure we can parse the file!
- syn::parse_file(stringify!($($in)*)).unwrap();
- }
- }
-}
-
-should_parse!(generic_associated_type, {
- impl Foo {
- type Item = &'a i32;
- fn foo<'a>(&'a self) -> Self::Item<'a> {}
- }
-});
-
-#[rustfmt::skip]
-should_parse!(const_generics_use, {
- type X = Foo<5>;
- type Y = Foo<"foo">;
- type Z = Foo<X>;
- type W = Foo<{ X + 10 }>;
-});
-
-should_parse!(trailing_plus_type, {
- type A = Box<Foo>;
- type A = Box<Foo + 'a>;
- type A = Box<'a + Foo>;
-});
-
-should_parse!(generic_associated_type_where, {
- trait Foo {
- type Item;
- fn foo<T>(&self, t: T) -> Self::Item<T>;
- }
-});
-
-should_parse!(match_with_block_expr, {
- fn main() {
- match false {
- _ => {}.a(),
- }
- }
-});
diff --git a/syn/tests/test_size.rs b/syn/tests/test_size.rs
deleted file mode 100644
index 386d4df..0000000
--- a/syn/tests/test_size.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-#![cfg(target_pointer_width = "64")]
-
-mod features;
-
-use std::mem;
-use syn::*;
-
-#[test]
-fn test_expr_size() {
- assert_eq!(mem::size_of::<Expr>(), 280);
-}
-
-#[test]
-fn test_item_size() {
- assert_eq!(mem::size_of::<Item>(), 344);
-}
-
-#[test]
-fn test_type_size() {
- assert_eq!(mem::size_of::<Type>(), 304);
-}
-
-#[test]
-fn test_pat_size() {
- assert_eq!(mem::size_of::<Pat>(), 144);
-}
-
-#[test]
-fn test_lit_size() {
- assert_eq!(mem::size_of::<Lit>(), 40);
-}
diff --git a/syn/tests/test_token_trees.rs b/syn/tests/test_token_trees.rs
deleted file mode 100644
index 5d7610b..0000000
--- a/syn/tests/test_token_trees.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-mod features;
-
-#[macro_use]
-mod macros;
-
-use proc_macro2::TokenStream;
-use quote::quote;
-use syn::Lit;
-
-#[test]
-fn test_struct() {
- let input = "
- #[derive(Debug, Clone)]
- pub struct Item {
- pub ident: Ident,
- pub attrs: Vec<Attribute>,
- }
- ";
-
- snapshot!(input as TokenStream, @"`# [ derive ( Debug , Clone ) ] pub struct Item { pub ident : Ident , pub attrs : Vec < Attribute >, }`");
-}
-
-#[test]
-fn test_literal_mangling() {
- let code = "0_4";
- let parsed: Lit = syn::parse_str(code).unwrap();
- assert_eq!(code, quote!(#parsed).to_string());
-}
diff --git a/syn/tests/test_visibility.rs b/syn/tests/test_visibility.rs
deleted file mode 100644
index 21c49c9..0000000
--- a/syn/tests/test_visibility.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-mod features;
-
-use proc_macro2::TokenStream;
-use syn::parse::{Parse, ParseStream};
-use syn::{Result, Visibility};
-
-#[derive(Debug)]
-struct VisRest {
- vis: Visibility,
- rest: TokenStream,
-}
-
-impl Parse for VisRest {
- fn parse(input: ParseStream) -> Result<Self> {
- Ok(VisRest {
- vis: input.parse()?,
- rest: input.parse()?,
- })
- }
-}
-
-macro_rules! assert_vis_parse {
- ($input:expr, Ok($p:pat)) => {
- assert_vis_parse!($input, Ok($p) + "");
- };
-
- ($input:expr, Ok($p:pat) + $rest:expr) => {
- let expected = $rest.parse::<TokenStream>().unwrap();
- let parse: VisRest = syn::parse_str($input).unwrap();
-
- match parse.vis {
- $p => {}
- _ => panic!("Expected {}, got {:?}", stringify!($p), parse.vis),
- }
-
- // NOTE: Round-trips through `to_string` to avoid potential whitespace
- // diffs.
- assert_eq!(parse.rest.to_string(), expected.to_string());
- };
-
- ($input:expr, Err) => {
- syn::parse2::<VisRest>($input.parse().unwrap()).unwrap_err();
- };
-}
-
-#[test]
-fn test_pub() {
- assert_vis_parse!("pub", Ok(Visibility::Public(_)));
-}
-
-#[test]
-fn test_crate() {
- assert_vis_parse!("crate", Ok(Visibility::Crate(_)));
-}
-
-#[test]
-fn test_inherited() {
- assert_vis_parse!("", Ok(Visibility::Inherited));
-}
-
-#[test]
-fn test_in() {
- assert_vis_parse!("pub(in foo::bar)", Ok(Visibility::Restricted(_)));
-}
-
-#[test]
-fn test_pub_crate() {
- assert_vis_parse!("pub(crate)", Ok(Visibility::Restricted(_)));
-}
-
-#[test]
-fn test_pub_self() {
- assert_vis_parse!("pub(self)", Ok(Visibility::Restricted(_)));
-}
-
-#[test]
-fn test_pub_super() {
- assert_vis_parse!("pub(super)", Ok(Visibility::Restricted(_)));
-}
-
-#[test]
-fn test_missing_in() {
- assert_vis_parse!("pub(foo::bar)", Ok(Visibility::Public(_)) + "(foo::bar)");
-}
-
-#[test]
-fn test_missing_in_path() {
- assert_vis_parse!("pub(in)", Err);
-}
-
-#[test]
-fn test_crate_path() {
- assert_vis_parse!("pub(crate::A, crate::B)", Ok(Visibility::Public(_)) + "(crate::A, crate::B)");
-}
-
-#[test]
-fn test_junk_after_in() {
- assert_vis_parse!("pub(in some::path @@garbage)", Err);
-}
diff --git a/syn/tests/zzz_stable.rs b/syn/tests/zzz_stable.rs
deleted file mode 100644
index 6c768f2..0000000
--- a/syn/tests/zzz_stable.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-#![cfg(syn_disable_nightly_tests)]
-
-use std::io::{self, Write};
-use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
-
-const MSG: &str = "\
-‖
-‖ WARNING:
-‖ This is not a nightly compiler so not all tests were able to
-‖ run. Syn includes tests that compare Syn's parser against the
-‖ compiler's parser, which requires access to unstable libsyntax
-‖ data structures and a nightly compiler.
-‖
-";
-
-#[test]
-fn notice() -> io::Result<()> {
- let header = "WARNING";
- let index_of_header = MSG.find(header).unwrap();
- let before = &MSG[..index_of_header];
- let after = &MSG[index_of_header + header.len()..];
-
- let mut stderr = StandardStream::stderr(ColorChoice::Auto);
- stderr.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))?;
- write!(&mut stderr, "{}", before)?;
- stderr.set_color(ColorSpec::new().set_bold(true).set_fg(Some(Color::Yellow)))?;
- write!(&mut stderr, "{}", header)?;
- stderr.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))?;
- write!(&mut stderr, "{}", after)?;
- stderr.reset()?;
-
- Ok(())
-}
diff --git a/textwrap/.appveyor.yml b/textwrap/.appveyor.yml
deleted file mode 100644
index 3555d73..0000000
--- a/textwrap/.appveyor.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-environment:
- matrix:
- - TOOLCHAIN: stable
- - TOOLCHAIN: nightly
-
-matrix:
- allow_failures:
- - TOOLCHAIN: nightly
-
-install:
- - ps: Start-FileDownload 'https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe'
- - rustup-init.exe -y --default-toolchain %TOOLCHAIN%
- - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
-
-build_script:
- - cargo build --verbose --all-features
-
-test_script:
- - cargo test --verbose --all-features
-
-cache:
- - '%USERPROFILE%\.cargo'
- - target
diff --git a/textwrap/.circleci/config.yml b/textwrap/.circleci/config.yml
deleted file mode 100644
index 4f928a6..0000000
--- a/textwrap/.circleci/config.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-version: 2
-jobs:
- build:
- docker:
- - image: xd009642/tarpaulin
- steps:
- - checkout
- - run:
- name: Generate coverage report
- command: cargo tarpaulin --out Xml --all-features
- - run:
- name: Upload to codecov.io
- command: bash <(curl -s https://codecov.io/bash) -Z -f cobertura.xml
diff --git a/textwrap/.codecov.yml b/textwrap/.codecov.yml
deleted file mode 100644
index a9b0bd2..0000000
--- a/textwrap/.codecov.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-codecov:
- # Do not wait for these CI providers since they will not upload any
- # coverage reports.
- ci:
- - !appveyor
- - !travis
-
-coverage:
- status:
- project:
- default:
- # Allow a 5% drop in overall project coverage on a PR.
- threshold: 5%
diff --git a/textwrap/.dir-locals.el b/textwrap/.dir-locals.el
deleted file mode 100644
index 0faa664..0000000
--- a/textwrap/.dir-locals.el
+++ /dev/null
@@ -1,3 +0,0 @@
-((nil
- (bug-reference-bug-regexp . "#\\(?2:[0-9]+\\)")
- (bug-reference-url-format . "https://github.com/mgeisler/textwrap/issues/%s")))
diff --git a/textwrap/.gitignore b/textwrap/.gitignore
deleted file mode 100644
index 6513848..0000000
--- a/textwrap/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-Cargo.lock
-target/
-
-*~
-*.orig
diff --git a/textwrap/.travis.yml b/textwrap/.travis.yml
deleted file mode 100644
index 156418b..0000000
--- a/textwrap/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-language: rust
-
-rust:
- - stable
- - beta
- - nightly
- - 1.22.0
-
-cache: cargo
-
-script:
- - cargo build --verbose --all-features
- - cargo test --verbose --all-features
-
-matrix:
- allow_failures:
- - rust: nightly
diff --git a/textwrap/Cargo.toml b/textwrap/Cargo.toml
deleted file mode 100644
index 9d82ca5..0000000
--- a/textwrap/Cargo.toml
+++ /dev/null
@@ -1,38 +0,0 @@
-[package]
-name = "textwrap"
-version = "0.11.0"
-authors = ["Martin Geisler <martin@geisler.net>"]
-description = """
-Textwrap is a small library for word wrapping, indenting, and
-dedenting strings.
-
-You can use it to format strings (such as help and error messages) for
-display in commandline applications. It is designed to be efficient
-and handle Unicode characters correctly.
-"""
-documentation = "https://docs.rs/textwrap/"
-repository = "https://github.com/mgeisler/textwrap"
-readme = "README.md"
-keywords = ["text", "formatting", "wrap", "typesetting", "hyphenation"]
-categories = ["text-processing", "command-line-interface"]
-license = "MIT"
-exclude = [".dir-locals.el"]
-
-[package.metadata.docs.rs]
-all-features = true
-
-[badges]
-travis-ci = { repository = "mgeisler/textwrap" }
-appveyor = { repository = "mgeisler/textwrap" }
-codecov = { repository = "mgeisler/textwrap" }
-
-[dependencies]
-unicode-width = "0.1.3"
-term_size = { version = "0.3.0", optional = true }
-hyphenation = { version = "0.7.1", optional = true, features = ["embed_all"] }
-
-[dev-dependencies]
-lipsum = "0.6"
-rand = "0.6"
-rand_xorshift = "0.1"
-version-sync = "0.6"
diff --git a/textwrap/LICENSE b/textwrap/LICENSE
deleted file mode 100644
index 0d37ec3..0000000
--- a/textwrap/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2016 Martin Geisler
-
-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/textwrap/README.md b/textwrap/README.md
deleted file mode 100644
index 23a5439..0000000
--- a/textwrap/README.md
+++ /dev/null
@@ -1,337 +0,0 @@
-# Textwrap
-
-[![](https://img.shields.io/crates/v/textwrap.svg)][crates-io]
-[![](https://docs.rs/textwrap/badge.svg)][api-docs]
-[![](https://travis-ci.org/mgeisler/textwrap.svg?branch=master)][travis-ci]
-[![](https://ci.appveyor.com/api/projects/status/github/mgeisler/textwrap?branch=master&svg=true)][appveyor]
-[![](https://codecov.io/gh/mgeisler/textwrap/branch/master/graph/badge.svg)][codecov]
-
-Textwrap is a small Rust crate for word wrapping text. You can use it
-to format strings for display in commandline applications. The crate
-name and interface is inspired by
-the [Python textwrap module][py-textwrap].
-
-## Usage
-
-Add this to your `Cargo.toml`:
-```toml
-[dependencies]
-textwrap = "0.11"
-```
-
-and this to your crate root:
-```rust
-extern crate textwrap;
-```
-
-If you would like to have automatic hyphenation, specify the
-dependency as:
-```toml
-[dependencies]
-textwrap = { version = "0.11", features = ["hyphenation"] }
-```
-
-To conveniently wrap text at the current terminal width, enable the
-`term_size` feature:
-
-```toml
-[dependencies]
-textwrap = { version = "0.11", features = ["term_size"] }
-```
-
-## Documentation
-
-**[API documentation][api-docs]**
-
-## Getting Started
-
-Word wrapping single strings is easy using the `fill` function:
-```rust
-extern crate textwrap;
-use textwrap::fill;
-
-fn main() {
- let text = "textwrap: a small library for wrapping text.";
- println!("{}", fill(text, 18));
-}
-```
-The output is
-```
-textwrap: a small
-library for
-wrapping text.
-```
-
-With the `hyphenation` feature, you can get automatic hyphenation
-for [about 70 languages][patterns]. Your program must load and
-configure the hyphenation patterns to use:
-```rust
-extern crate hyphenation;
-extern crate textwrap;
-
-use hyphenation::{Language, Load, Standard};
-use textwrap::Wrapper;
-
-fn main() {
- let hyphenator = Standard::from_embedded(Language::EnglishUS).unwrap();
- let wrapper = Wrapper::with_splitter(18, hyphenator);
- let text = "textwrap: a small library for wrapping text.";
- println!("{}", wrapper.fill(text))
-}
-```
-
-The output now looks like this:
-```
-textwrap: a small
-library for wrap-
-ping text.
-```
-
-The hyphenation uses high-quality TeX hyphenation patterns.
-
-## Examples
-
-The library comes with some small example programs that shows various
-features.
-
-### Layout Example
-
-The `layout` example shows how a fixed example string is wrapped at
-different widths. Run the example with:
-
-```shell
-$ cargo run --features hyphenation --example layout
-```
-
-The program will use the following string:
-
-> Memory safety without garbage collection. Concurrency without data
-> races. Zero-cost abstractions.
-
-The string is wrapped at all widths between 15 and 60 columns. With
-narrow columns the output looks like this:
-
-```
-.--- Width: 15 ---.
-| Memory safety |
-| without garbage |
-| collection. |
-| Concurrency |
-| without data |
-| races. Zero- |
-| cost abstrac- |
-| tions. |
-.--- Width: 16 ----.
-| Memory safety |
-| without garbage |
-| collection. Con- |
-| currency without |
-| data races. Ze- |
-| ro-cost abstrac- |
-| tions. |
-```
-
-Later, longer lines are used and the output now looks like this:
-
-```
-.-------------------- Width: 49 --------------------.
-| Memory safety without garbage collection. Concur- |
-| rency without data races. Zero-cost abstractions. |
-.---------------------- Width: 53 ----------------------.
-| Memory safety without garbage collection. Concurrency |
-| without data races. Zero-cost abstractions. |
-.------------------------- Width: 59 -------------------------.
-| Memory safety without garbage collection. Concurrency with- |
-| out data races. Zero-cost abstractions. |
-```
-
-Notice how words are split at hyphens (such as "zero-cost") but also
-how words are hyphenated using automatic/machine hyphenation.
-
-### Terminal Width Example
-
-The `termwidth` example simply shows how the width can be set
-automatically to the current terminal width. Run it with this command:
-
-```
-$ cargo run --example termwidth
-```
-
-If you run it in a narrow terminal, you'll see output like this:
-```
-Formatted in within 60 columns:
-----
-Memory safety without garbage collection. Concurrency
-without data races. Zero-cost abstractions.
-----
-```
-
-If `stdout` is not connected to the terminal, the program will use a
-default of 80 columns for the width:
-
-```
-$ cargo run --example termwidth | cat
-Formatted in within 80 columns:
-----
-Memory safety without garbage collection. Concurrency without data races. Zero-
-cost abstractions.
-----
-```
-
-## Release History
-
-This section lists the largest changes per release.
-
-### Version 0.11.0 — December 9th, 2018
-
-Due to our dependencies bumping their minimum supported version of
-Rust, the minimum version of Rust we test against is now 1.22.0.
-
-* Merged [#141][issue-141]: Fix `dedent` handling of empty lines and
- trailing newlines. Thanks @bbqsrc!
-* Fixed [#151][issue-151]: Release of version with hyphenation 0.7.
-
-### Version 0.10.0 — April 28th, 2018
-
-Due to our dependencies bumping their minimum supported version of
-Rust, the minimum version of Rust we test against is now 1.17.0.
-
-* Fixed [#99][issue-99]: Word broken even though it would fit on line.
-* Fixed [#107][issue-107]: Automatic hyphenation is off by one.
-* Fixed [#122][issue-122]: Take newlines into account when wrapping.
-* Fixed [#129][issue-129]: Panic on string with em-dash.
-
-### Version 0.9.0 — October 5th, 2017
-
-The dependency on `term_size` is now optional, and by default this
-feature is not enabled. This is a *breaking change* for users of
-`Wrapper::with_termwidth`. Enable the `term_size` feature to restore
-the old functionality.
-
-Added a regression test for the case where `width` is set to
-`usize::MAX`, thanks @Fraser999! All public structs now implement
-`Debug`, thanks @hcpl!
-
-* Fixed [#101][issue-101]: Make `term_size` an optional dependency.
-
-### Version 0.8.0 — September 4th, 2017
-
-The `Wrapper` stuct is now generic over the type of word splitter
-being used. This means less boxing and a nicer API. The
-`Wrapper::word_splitter` method has been removed. This is a *breaking
-API change* if you used the method to change the word splitter.
-
-The `Wrapper` struct has two new methods that will wrap the input text
-lazily: `Wrapper::wrap_iter` and `Wrapper::into_wrap_iter`. Use those
-if you will be iterating over the wrapped lines one by one.
-
-* Fixed [#59][issue-59]: `wrap` could return an iterator. Thanks
- @hcpl!
-* Fixed [#81][issue-81]: Set `html_root_url`.
-
-### Version 0.7.0 — July 20th, 2017
-
-Version 0.7.0 changes the return type of `Wrapper::wrap` from
-`Vec<String>` to `Vec<Cow<'a, str>>`. This means that the output lines
-borrow data from the input string. This is a *breaking API change* if
-you relied on the exact return type of `Wrapper::wrap`. Callers of the
-`textwrap::fill` convenience function will see no breakage.
-
-The above change and other optimizations makes version 0.7.0 roughly
-15-30% faster than version 0.6.0.
-
-The `squeeze_whitespace` option has been removed since it was
-complicating the above optimization. Let us know if this option is
-important for you so we can provide a work around.
-
-* Fixed [#58][issue-58]: Add a "fast_wrap" function.
-* Fixed [#61][issue-61]: Documentation errors.
-
-### Version 0.6.0 — May 22nd, 2017
-
-Version 0.6.0 adds builder methods to `Wrapper` for easy one-line
-initialization and configuration:
-
-```rust
-let wrapper = Wrapper::new(60).break_words(false);
-```
-
-It also add a new `NoHyphenation` word splitter that will never split
-words, not even at existing hyphens.
-
-* Fixed [#28][issue-28]: Support not squeezing whitespace.
-
-### Version 0.5.0 — May 15th, 2017
-
-Version 0.5.0 has *breaking API changes*. However, this only affects
-code using the hyphenation feature. The feature is now optional, so
-you will first need to enable the `hyphenation` feature as described
-above. Afterwards, please change your code from
-```rust
-wrapper.corpus = Some(&corpus);
-```
-to
-```rust
-wrapper.splitter = Box::new(corpus);
-```
-
-Other changes include optimizations, so version 0.5.0 is roughly
-10-15% faster than version 0.4.0.
-
-* Fixed [#19][issue-19]: Add support for finding terminal size.
-* Fixed [#25][issue-25]: Handle words longer than `self.width`.
-* Fixed [#26][issue-26]: Support custom indentation.
-* Fixed [#36][issue-36]: Support building without `hyphenation`.
-* Fixed [#39][issue-39]: Respect non-breaking spaces.
-
-### Version 0.4.0 — January 24th, 2017
-
-Documented complexities and tested these via `cargo bench`.
-
-* Fixed [#13][issue-13]: Immediatedly add word if it fits.
-* Fixed [#14][issue-14]: Avoid splitting on initial hyphens.
-
-### Version 0.3.0 — January 7th, 2017
-
-Added support for automatic hyphenation.
-
-### Version 0.2.0 — December 28th, 2016
-
-Introduced `Wrapper` struct. Added support for wrapping on hyphens.
-
-### Version 0.1.0 — December 17th, 2016
-
-First public release with support for wrapping strings on whitespace.
-
-## License
-
-Textwrap can be distributed according to the [MIT license][mit].
-Contributions will be accepted under the same license.
-
-[crates-io]: https://crates.io/crates/textwrap
-[travis-ci]: https://travis-ci.org/mgeisler/textwrap
-[appveyor]: https://ci.appveyor.com/project/mgeisler/textwrap
-[codecov]: https://codecov.io/gh/mgeisler/textwrap
-[py-textwrap]: https://docs.python.org/library/textwrap
-[patterns]: https://github.com/tapeinosyne/hyphenation/tree/master/patterns-tex
-[api-docs]: https://docs.rs/textwrap/
-[issue-13]: https://github.com/mgeisler/textwrap/issues/13
-[issue-14]: https://github.com/mgeisler/textwrap/issues/14
-[issue-19]: https://github.com/mgeisler/textwrap/issues/19
-[issue-25]: https://github.com/mgeisler/textwrap/issues/25
-[issue-26]: https://github.com/mgeisler/textwrap/issues/26
-[issue-28]: https://github.com/mgeisler/textwrap/issues/28
-[issue-36]: https://github.com/mgeisler/textwrap/issues/36
-[issue-39]: https://github.com/mgeisler/textwrap/issues/39
-[issue-58]: https://github.com/mgeisler/textwrap/issues/58
-[issue-59]: https://github.com/mgeisler/textwrap/issues/59
-[issue-61]: https://github.com/mgeisler/textwrap/issues/61
-[issue-81]: https://github.com/mgeisler/textwrap/issues/81
-[issue-99]: https://github.com/mgeisler/textwrap/issues/99
-[issue-101]: https://github.com/mgeisler/textwrap/issues/101
-[issue-107]: https://github.com/mgeisler/textwrap/issues/107
-[issue-122]: https://github.com/mgeisler/textwrap/issues/122
-[issue-129]: https://github.com/mgeisler/textwrap/issues/129
-[issue-141]: https://github.com/mgeisler/textwrap/issues/141
-[issue-151]: https://github.com/mgeisler/textwrap/issues/151
-[mit]: LICENSE
diff --git a/textwrap/benches/linear.rs b/textwrap/benches/linear.rs
deleted file mode 100644
index 104398a..0000000
--- a/textwrap/benches/linear.rs
+++ /dev/null
@@ -1,122 +0,0 @@
-#![feature(test)]
-
-// The benchmarks here verify that the complexity grows as O(*n*)
-// where *n* is the number of characters in the text to be wrapped.
-
-#[cfg(feature = "hyphenation")]
-extern crate hyphenation;
-extern crate lipsum;
-extern crate rand;
-extern crate rand_xorshift;
-extern crate test;
-extern crate textwrap;
-
-#[cfg(feature = "hyphenation")]
-use hyphenation::{Language, Load, Standard};
-use lipsum::MarkovChain;
-use rand::SeedableRng;
-use rand_xorshift::XorShiftRng;
-use test::Bencher;
-#[cfg(feature = "hyphenation")]
-use textwrap::Wrapper;
-
-const LINE_LENGTH: usize = 60;
-
-/// Generate a lorem ipsum text with the given number of characters.
-fn lorem_ipsum(length: usize) -> String {
- // The average word length in the lorem ipsum text is somewhere
- // between 6 and 7. So we conservatively divide by 5 to have a
- // long enough text that we can truncate below.
- let rng = XorShiftRng::seed_from_u64(0);
- let mut chain = MarkovChain::new_with_rng(rng);
- chain.learn(lipsum::LOREM_IPSUM);
- chain.learn(lipsum::LIBER_PRIMUS);
-
- let mut text = chain.generate_from(length / 5, ("Lorem", "ipsum"));
- text.truncate(length);
- text
-}
-
-#[bench]
-fn fill_100(b: &mut Bencher) {
- let text = &lorem_ipsum(100);
- b.iter(|| textwrap::fill(text, LINE_LENGTH))
-}
-
-#[bench]
-fn fill_200(b: &mut Bencher) {
- let text = &lorem_ipsum(200);
- b.iter(|| textwrap::fill(text, LINE_LENGTH))
-}
-
-#[bench]
-fn fill_400(b: &mut Bencher) {
- let text = &lorem_ipsum(400);
- b.iter(|| textwrap::fill(text, LINE_LENGTH))
-}
-
-#[bench]
-fn fill_800(b: &mut Bencher) {
- let text = &lorem_ipsum(800);
- b.iter(|| textwrap::fill(text, LINE_LENGTH))
-}
-
-#[bench]
-fn wrap_100(b: &mut Bencher) {
- let text = &lorem_ipsum(100);
- b.iter(|| textwrap::wrap(text, LINE_LENGTH))
-}
-
-#[bench]
-fn wrap_200(b: &mut Bencher) {
- let text = &lorem_ipsum(200);
- b.iter(|| textwrap::wrap(text, LINE_LENGTH))
-}
-
-#[bench]
-fn wrap_400(b: &mut Bencher) {
- let text = &lorem_ipsum(400);
- b.iter(|| textwrap::wrap(text, LINE_LENGTH))
-}
-
-#[bench]
-fn wrap_800(b: &mut Bencher) {
- let text = &lorem_ipsum(800);
- b.iter(|| textwrap::wrap(text, LINE_LENGTH))
-}
-
-#[bench]
-#[cfg(feature = "hyphenation")]
-fn hyphenation_fill_100(b: &mut Bencher) {
- let text = &lorem_ipsum(100);
- let dictionary = Standard::from_embedded(Language::Latin).unwrap();
- let wrapper = Wrapper::with_splitter(LINE_LENGTH, dictionary);
- b.iter(|| wrapper.fill(text))
-}
-
-#[bench]
-#[cfg(feature = "hyphenation")]
-fn hyphenation_fill_200(b: &mut Bencher) {
- let text = &lorem_ipsum(200);
- let dictionary = Standard::from_embedded(Language::Latin).unwrap();
- let wrapper = Wrapper::with_splitter(LINE_LENGTH, dictionary);
- b.iter(|| wrapper.fill(text))
-}
-
-#[bench]
-#[cfg(feature = "hyphenation")]
-fn hyphenation_fill_400(b: &mut Bencher) {
- let text = &lorem_ipsum(400);
- let dictionary = Standard::from_embedded(Language::Latin).unwrap();
- let wrapper = Wrapper::with_splitter(LINE_LENGTH, dictionary);
- b.iter(|| wrapper.fill(text))
-}
-
-#[bench]
-#[cfg(feature = "hyphenation")]
-fn hyphenation_fill_800(b: &mut Bencher) {
- let text = &lorem_ipsum(800);
- let dictionary = Standard::from_embedded(Language::Latin).unwrap();
- let wrapper = Wrapper::with_splitter(LINE_LENGTH, dictionary);
- b.iter(|| wrapper.fill(text))
-}
diff --git a/textwrap/examples/layout.rs b/textwrap/examples/layout.rs
deleted file mode 100644
index d36cb3a..0000000
--- a/textwrap/examples/layout.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-#[cfg(feature = "hyphenation")]
-extern crate hyphenation;
-extern crate textwrap;
-
-#[cfg(feature = "hyphenation")]
-use hyphenation::{Language, Load};
-use textwrap::Wrapper;
-
-#[cfg(not(feature = "hyphenation"))]
-fn new_wrapper<'a>() -> Wrapper<'a, textwrap::HyphenSplitter> {
- Wrapper::new(0)
-}
-
-#[cfg(feature = "hyphenation")]
-fn new_wrapper<'a>() -> Wrapper<'a, hyphenation::Standard> {
- let dictionary = hyphenation::Standard::from_embedded(Language::EnglishUS).unwrap();
- Wrapper::with_splitter(0, dictionary)
-}
-
-fn main() {
- let example = "Memory safety without garbage collection. \
- Concurrency without data races. \
- Zero-cost abstractions.";
- let mut prev_lines = vec![];
- let mut wrapper = new_wrapper();
- for width in 15..60 {
- wrapper.width = width;
- let lines = wrapper.wrap(example);
- if lines != prev_lines {
- let title = format!(" Width: {} ", width);
- println!(".{:-^1$}.", title, width + 2);
- for line in &lines {
- println!("| {:1$} |", line, width);
- }
- prev_lines = lines;
- }
- }
-}
diff --git a/textwrap/examples/termwidth.rs b/textwrap/examples/termwidth.rs
deleted file mode 100644
index 75db3aa..0000000
--- a/textwrap/examples/termwidth.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-#[cfg(feature = "hyphenation")]
-extern crate hyphenation;
-extern crate textwrap;
-
-#[cfg(feature = "hyphenation")]
-use hyphenation::{Language, Load, Standard};
-#[cfg(feature = "term_size")]
-use textwrap::Wrapper;
-
-#[cfg(not(feature = "term_size"))]
-fn main() {
- println!("Please enable the term_size feature to run this example.");
-}
-
-#[cfg(feature = "term_size")]
-fn main() {
- #[cfg(not(feature = "hyphenation"))]
- fn new_wrapper<'a>() -> (&'static str, Wrapper<'a, textwrap::HyphenSplitter>) {
- ("without hyphenation", Wrapper::with_termwidth())
- }
-
- #[cfg(feature = "hyphenation")]
- fn new_wrapper<'a>() -> (&'static str, Wrapper<'a, Standard>) {
- let dictionary = Standard::from_embedded(Language::EnglishUS).unwrap();
- (
- "with hyphenation",
- Wrapper::with_splitter(textwrap::termwidth(), dictionary),
- )
- }
-
- let example = "Memory safety without garbage collection. \
- Concurrency without data races. \
- Zero-cost abstractions.";
- // Create a new Wrapper -- automatically set the width to the
- // current terminal width.
- let (msg, wrapper) = new_wrapper();
- println!("Formatted {} in {} columns:", msg, wrapper.width);
- println!("----");
- println!("{}", wrapper.fill(example));
- println!("----");
-}
diff --git a/textwrap/src/indentation.rs b/textwrap/src/indentation.rs
deleted file mode 100644
index 276ba10..0000000
--- a/textwrap/src/indentation.rs
+++ /dev/null
@@ -1,294 +0,0 @@
-//! Functions related to adding and removing indentation from lines of
-//! text.
-//!
-//! The functions here can be used to uniformly indent or dedent
-//! (unindent) word wrapped lines of text.
-
-/// Add prefix to each non-empty line.
-///
-/// ```
-/// use textwrap::indent;
-///
-/// assert_eq!(indent("
-/// Foo
-/// Bar
-/// ", " "), "
-/// Foo
-/// Bar
-/// ");
-/// ```
-///
-/// Empty lines (lines consisting only of whitespace) are not indented
-/// and the whitespace is replaced by a single newline (`\n`):
-///
-/// ```
-/// use textwrap::indent;
-///
-/// assert_eq!(indent("
-/// Foo
-///
-/// Bar
-/// \t
-/// Baz
-/// ", "->"), "
-/// ->Foo
-///
-/// ->Bar
-///
-/// ->Baz
-/// ");
-/// ```
-///
-/// Leading and trailing whitespace on non-empty lines is kept
-/// unchanged:
-///
-/// ```
-/// use textwrap::indent;
-///
-/// assert_eq!(indent(" \t Foo ", "->"), "-> \t Foo \n");
-/// ```
-pub fn indent(s: &str, prefix: &str) -> String {
- let mut result = String::new();
- for line in s.lines() {
- if line.chars().any(|c| !c.is_whitespace()) {
- result.push_str(prefix);
- result.push_str(line);
- }
- result.push('\n');
- }
- result
-}
-
-/// Removes common leading whitespace from each line.
-///
-/// This function will look at each non-empty line and determine the
-/// maximum amount of whitespace that can be removed from all lines:
-///
-/// ```
-/// use textwrap::dedent;
-///
-/// assert_eq!(dedent("
-/// 1st line
-/// 2nd line
-/// 3rd line
-/// "), "
-/// 1st line
-/// 2nd line
-/// 3rd line
-/// ");
-/// ```
-pub fn dedent(s: &str) -> String {
- let mut prefix = "";
- let mut lines = s.lines();
-
- // We first search for a non-empty line to find a prefix.
- for line in &mut lines {
- let mut whitespace_idx = line.len();
- for (idx, ch) in line.char_indices() {
- if !ch.is_whitespace() {
- whitespace_idx = idx;
- break;
- }
- }
-
- // Check if the line had anything but whitespace
- if whitespace_idx < line.len() {
- prefix = &line[..whitespace_idx];
- break;
- }
- }
-
- // We then continue looking through the remaining lines to
- // possibly shorten the prefix.
- for line in &mut lines {
- let mut whitespace_idx = line.len();
- for ((idx, a), b) in line.char_indices().zip(prefix.chars()) {
- if a != b {
- whitespace_idx = idx;
- break;
- }
- }
-
- // Check if the line had anything but whitespace and if we
- // have found a shorter prefix
- if whitespace_idx < line.len() && whitespace_idx < prefix.len() {
- prefix = &line[..whitespace_idx];
- }
- }
-
- // We now go over the lines a second time to build the result.
- let mut result = String::new();
- for line in s.lines() {
- if line.starts_with(&prefix) && line.chars().any(|c| !c.is_whitespace()) {
- let (_, tail) = line.split_at(prefix.len());
- result.push_str(tail);
- }
- result.push('\n');
- }
-
- if result.ends_with('\n') && !s.ends_with('\n') {
- let new_len = result.len() - 1;
- result.truncate(new_len);
- }
-
- result
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- /// Add newlines. Ensures that the final line in the vector also
- /// has a newline.
- fn add_nl(lines: &[&str]) -> String {
- lines.join("\n") + "\n"
- }
-
- #[test]
- fn indent_empty() {
- assert_eq!(indent("\n", " "), "\n");
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn indent_nonempty() {
- let x = vec![" foo",
- "bar",
- " baz"];
- let y = vec!["// foo",
- "//bar",
- "// baz"];
- assert_eq!(indent(&add_nl(&x), "//"), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn indent_empty_line() {
- let x = vec![" foo",
- "bar",
- "",
- " baz"];
- let y = vec!["// foo",
- "//bar",
- "",
- "// baz"];
- assert_eq!(indent(&add_nl(&x), "//"), add_nl(&y));
- }
-
- #[test]
- fn dedent_empty() {
- assert_eq!(dedent(""), "");
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_multi_line() {
- let x = vec![" foo",
- " bar",
- " baz"];
- let y = vec![" foo",
- "bar",
- " baz"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_empty_line() {
- let x = vec![" foo",
- " bar",
- " ",
- " baz"];
- let y = vec![" foo",
- "bar",
- "",
- " baz"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_blank_line() {
- let x = vec![" foo",
- "",
- " bar",
- " foo",
- " bar",
- " baz"];
- let y = vec!["foo",
- "",
- " bar",
- " foo",
- " bar",
- " baz"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_whitespace_line() {
- let x = vec![" foo",
- " ",
- " bar",
- " foo",
- " bar",
- " baz"];
- let y = vec!["foo",
- "",
- " bar",
- " foo",
- " bar",
- " baz"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_mixed_whitespace() {
- let x = vec!["\tfoo",
- " bar"];
- let y = vec!["\tfoo",
- " bar"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_tabbed_whitespace() {
- let x = vec!["\t\tfoo",
- "\t\t\tbar"];
- let y = vec!["foo",
- "\tbar"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_mixed_tabbed_whitespace() {
- let x = vec!["\t \tfoo",
- "\t \t\tbar"];
- let y = vec!["foo",
- "\tbar"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_mixed_tabbed_whitespace2() {
- let x = vec!["\t \tfoo",
- "\t \tbar"];
- let y = vec!["\tfoo",
- " \tbar"];
- assert_eq!(dedent(&add_nl(&x)), add_nl(&y));
- }
-
- #[test]
- #[cfg_attr(rustfmt, rustfmt_skip)]
- fn dedent_preserve_no_terminating_newline() {
- let x = vec![" foo",
- " bar"].join("\n");
- let y = vec!["foo",
- " bar"].join("\n");
- assert_eq!(dedent(&x), y);
- }
-}
diff --git a/textwrap/src/lib.rs b/textwrap/src/lib.rs
deleted file mode 100644
index 2f82325..0000000
--- a/textwrap/src/lib.rs
+++ /dev/null
@@ -1,987 +0,0 @@
-//! `textwrap` provides functions for word wrapping and filling text.
-//!
-//! Wrapping text can be very useful in commandline programs where you
-//! want to format dynamic output nicely so it looks good in a
-//! terminal. A quick example:
-//!
-//! ```no_run
-//! extern crate textwrap;
-//! use textwrap::fill;
-//!
-//! fn main() {
-//! let text = "textwrap: a small library for wrapping text.";
-//! println!("{}", fill(text, 18));
-//! }
-//! ```
-//!
-//! This will display the following output:
-//!
-//! ```text
-//! textwrap: a small
-//! library for
-//! wrapping text.
-//! ```
-//!
-//! # Displayed Width vs Byte Size
-//!
-//! To word wrap text, one must know the width of each word so one can
-//! know when to break lines. This library measures the width of text
-//! using the [displayed width][unicode-width], not the size in bytes.
-//!
-//! This is important for non-ASCII text. ASCII characters such as `a`
-//! and `!` are simple and take up one column each. This means that
-//! the displayed width is equal to the string length in bytes.
-//! However, non-ASCII characters and symbols take up more than one
-//! byte when UTF-8 encoded: `é` is `0xc3 0xa9` (two bytes) and `⚙` is
-//! `0xe2 0x9a 0x99` (three bytes) in UTF-8, respectively.
-//!
-//! This is why we take care to use the displayed width instead of the
-//! byte count when computing line lengths. All functions in this
-//! library handle Unicode characters like this.
-//!
-//! [unicode-width]: https://docs.rs/unicode-width/
-
-#![doc(html_root_url = "https://docs.rs/textwrap/0.11.0")]
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-
-#[cfg(feature = "hyphenation")]
-extern crate hyphenation;
-#[cfg(feature = "term_size")]
-extern crate term_size;
-extern crate unicode_width;
-
-use std::borrow::Cow;
-use std::str::CharIndices;
-
-use unicode_width::UnicodeWidthChar;
-use unicode_width::UnicodeWidthStr;
-
-/// A non-breaking space.
-const NBSP: char = '\u{a0}';
-
-mod indentation;
-pub use indentation::dedent;
-pub use indentation::indent;
-
-mod splitting;
-pub use splitting::{HyphenSplitter, NoHyphenation, WordSplitter};
-
-/// A Wrapper holds settings for wrapping and filling text. Use it
-/// when the convenience [`wrap_iter`], [`wrap`] and [`fill`] functions
-/// are not flexible enough.
-///
-/// [`wrap_iter`]: fn.wrap_iter.html
-/// [`wrap`]: fn.wrap.html
-/// [`fill`]: fn.fill.html
-///
-/// The algorithm used by the `WrapIter` iterator (returned from the
-/// `wrap_iter` method) works by doing successive partial scans over
-/// words in the input string (where each single scan yields a single
-/// line) so that the overall time and memory complexity is O(*n*) where
-/// *n* is the length of the input string.
-#[derive(Clone, Debug)]
-pub struct Wrapper<'a, S: WordSplitter> {
- /// The width in columns at which the text will be wrapped.
- pub width: usize,
- /// Indentation used for the first line of output.
- pub initial_indent: &'a str,
- /// Indentation used for subsequent lines of output.
- pub subsequent_indent: &'a str,
- /// Allow long words to be broken if they cannot fit on a line.
- /// When set to `false`, some lines may be longer than
- /// `self.width`.
- pub break_words: bool,
- /// The method for splitting words. If the `hyphenation` feature
- /// is enabled, you can use a `hyphenation::Standard` dictionary
- /// here to get language-aware hyphenation.
- pub splitter: S,
-}
-
-impl<'a> Wrapper<'a, HyphenSplitter> {
- /// Create a new Wrapper for wrapping at the specified width. By
- /// default, we allow words longer than `width` to be broken. A
- /// [`HyphenSplitter`] will be used by default for splitting
- /// words. See the [`WordSplitter`] trait for other options.
- ///
- /// [`HyphenSplitter`]: struct.HyphenSplitter.html
- /// [`WordSplitter`]: trait.WordSplitter.html
- pub fn new(width: usize) -> Wrapper<'a, HyphenSplitter> {
- Wrapper::with_splitter(width, HyphenSplitter)
- }
-
- /// Create a new Wrapper for wrapping text at the current terminal
- /// width. If the terminal width cannot be determined (typically
- /// because the standard input and output is not connected to a
- /// terminal), a width of 80 characters will be used. Other
- /// settings use the same defaults as `Wrapper::new`.
- ///
- /// Equivalent to:
- ///
- /// ```no_run
- /// # #![allow(unused_variables)]
- /// use textwrap::{Wrapper, termwidth};
- ///
- /// let wrapper = Wrapper::new(termwidth());
- /// ```
- #[cfg(feature = "term_size")]
- pub fn with_termwidth() -> Wrapper<'a, HyphenSplitter> {
- Wrapper::new(termwidth())
- }
-}
-
-impl<'a, S: WordSplitter> Wrapper<'a, S> {
- /// Use the given [`WordSplitter`] to create a new Wrapper for
- /// wrapping at the specified width. By default, we allow words
- /// longer than `width` to be broken.
- ///
- /// [`WordSplitter`]: trait.WordSplitter.html
- pub fn with_splitter(width: usize, splitter: S) -> Wrapper<'a, S> {
- Wrapper {
- width: width,
- initial_indent: "",
- subsequent_indent: "",
- break_words: true,
- splitter: splitter,
- }
- }
-
- /// Change [`self.initial_indent`]. The initial indentation is
- /// used on the very first line of output.
- ///
- /// # Examples
- ///
- /// Classic paragraph indentation can be achieved by specifying an
- /// initial indentation and wrapping each paragraph by itself:
- ///
- /// ```no_run
- /// # #![allow(unused_variables)]
- /// use textwrap::Wrapper;
- ///
- /// let wrapper = Wrapper::new(15).initial_indent(" ");
- /// ```
- ///
- /// [`self.initial_indent`]: #structfield.initial_indent
- pub fn initial_indent(self, indent: &'a str) -> Wrapper<'a, S> {
- Wrapper {
- initial_indent: indent,
- ..self
- }
- }
-
- /// Change [`self.subsequent_indent`]. The subsequent indentation
- /// is used on lines following the first line of output.
- ///
- /// # Examples
- ///
- /// Combining initial and subsequent indentation lets you format a
- /// single paragraph as a bullet list:
- ///
- /// ```no_run
- /// # #![allow(unused_variables)]
- /// use textwrap::Wrapper;
- ///
- /// let wrapper = Wrapper::new(15)
- /// .initial_indent("* ")
- /// .subsequent_indent(" ");
- /// ```
- ///
- /// [`self.subsequent_indent`]: #structfield.subsequent_indent
- pub fn subsequent_indent(self, indent: &'a str) -> Wrapper<'a, S> {
- Wrapper {
- subsequent_indent: indent,
- ..self
- }
- }
-
- /// Change [`self.break_words`]. This controls if words longer
- /// than `self.width` can be broken, or if they will be left
- /// sticking out into the right margin.
- ///
- /// [`self.break_words`]: #structfield.break_words
- pub fn break_words(self, setting: bool) -> Wrapper<'a, S> {
- Wrapper {
- break_words: setting,
- ..self
- }
- }
-
- /// Fill a line of text at `self.width` characters. Strings are
- /// wrapped based on their displayed width, not their size in
- /// bytes.
- ///
- /// The result is a string with newlines between each line. Use
- /// the `wrap` method if you need access to the individual lines.
- ///
- /// # Complexities
- ///
- /// This method simply joins the lines produced by `wrap_iter`. As
- /// such, it inherits the O(*n*) time and memory complexity where
- /// *n* is the input string length.
- ///
- /// # Examples
- ///
- /// ```
- /// use textwrap::Wrapper;
- ///
- /// let wrapper = Wrapper::new(15);
- /// assert_eq!(wrapper.fill("Memory safety without garbage collection."),
- /// "Memory safety\nwithout garbage\ncollection.");
- /// ```
- pub fn fill(&self, s: &str) -> String {
- // This will avoid reallocation in simple cases (no
- // indentation, no hyphenation).
- let mut result = String::with_capacity(s.len());
-
- for (i, line) in self.wrap_iter(s).enumerate() {
- if i > 0 {
- result.push('\n');
- }
- result.push_str(&line);
- }
-
- result
- }
-
- /// Wrap a line of text at `self.width` characters. Strings are
- /// wrapped based on their displayed width, not their size in
- /// bytes.
- ///
- /// # Complexities
- ///
- /// This method simply collects the lines produced by `wrap_iter`.
- /// As such, it inherits the O(*n*) overall time and memory
- /// complexity where *n* is the input string length.
- ///
- /// # Examples
- ///
- /// ```
- /// use textwrap::Wrapper;
- ///
- /// let wrap15 = Wrapper::new(15);
- /// assert_eq!(wrap15.wrap("Concurrency without data races."),
- /// vec!["Concurrency",
- /// "without data",
- /// "races."]);
- ///
- /// let wrap20 = Wrapper::new(20);
- /// assert_eq!(wrap20.wrap("Concurrency without data races."),
- /// vec!["Concurrency without",
- /// "data races."]);
- /// ```
- ///
- /// Notice that newlines in the input are preserved. This means
- /// that they force a line break, regardless of how long the
- /// current line is:
- ///
- /// ```
- /// use textwrap::Wrapper;
- ///
- /// let wrapper = Wrapper::new(40);
- /// assert_eq!(wrapper.wrap("First line.\nSecond line."),
- /// vec!["First line.", "Second line."]);
- /// ```
- ///
- pub fn wrap(&self, s: &'a str) -> Vec<Cow<'a, str>> {
- self.wrap_iter(s).collect::<Vec<_>>()
- }
-
- /// Lazily wrap a line of text at `self.width` characters. Strings
- /// are wrapped based on their displayed width, not their size in
- /// bytes.
- ///
- /// The [`WordSplitter`] stored in [`self.splitter`] is used
- /// whenever when a word is too large to fit on the current line.
- /// By changing the field, different hyphenation strategies can be
- /// implemented.
- ///
- /// # Complexities
- ///
- /// This method returns a [`WrapIter`] iterator which borrows this
- /// `Wrapper`. The algorithm used has a linear complexity, so
- /// getting the next line from the iterator will take O(*w*) time,
- /// where *w* is the wrapping width. Fully processing the iterator
- /// will take O(*n*) time for an input string of length *n*.
- ///
- /// When no indentation is used, each line returned is a slice of
- /// the input string and the memory overhead is thus constant.
- /// Otherwise new memory is allocated for each line returned.
- ///
- /// # Examples
- ///
- /// ```
- /// use std::borrow::Cow;
- /// use textwrap::Wrapper;
- ///
- /// let wrap20 = Wrapper::new(20);
- /// let mut wrap20_iter = wrap20.wrap_iter("Zero-cost abstractions.");
- /// assert_eq!(wrap20_iter.next(), Some(Cow::from("Zero-cost")));
- /// assert_eq!(wrap20_iter.next(), Some(Cow::from("abstractions.")));
- /// assert_eq!(wrap20_iter.next(), None);
- ///
- /// let wrap25 = Wrapper::new(25);
- /// let mut wrap25_iter = wrap25.wrap_iter("Zero-cost abstractions.");
- /// assert_eq!(wrap25_iter.next(), Some(Cow::from("Zero-cost abstractions.")));
- /// assert_eq!(wrap25_iter.next(), None);
- /// ```
- ///
- /// [`self.splitter`]: #structfield.splitter
- /// [`WordSplitter`]: trait.WordSplitter.html
- /// [`WrapIter`]: struct.WrapIter.html
- pub fn wrap_iter<'w>(&'w self, s: &'a str) -> WrapIter<'w, 'a, S> {
- WrapIter {
- wrapper: self,
- inner: WrapIterImpl::new(self, s),
- }
- }
-
- /// Lazily wrap a line of text at `self.width` characters. Strings
- /// are wrapped based on their displayed width, not their size in
- /// bytes.
- ///
- /// The [`WordSplitter`] stored in [`self.splitter`] is used
- /// whenever when a word is too large to fit on the current line.
- /// By changing the field, different hyphenation strategies can be
- /// implemented.
- ///
- /// # Complexities
- ///
- /// This method consumes the `Wrapper` and returns a
- /// [`IntoWrapIter`] iterator. Fully processing the iterator has
- /// the same O(*n*) time complexity as [`wrap_iter`], where *n* is
- /// the length of the input string.
- ///
- /// # Examples
- ///
- /// ```
- /// use std::borrow::Cow;
- /// use textwrap::Wrapper;
- ///
- /// let wrap20 = Wrapper::new(20);
- /// let mut wrap20_iter = wrap20.into_wrap_iter("Zero-cost abstractions.");
- /// assert_eq!(wrap20_iter.next(), Some(Cow::from("Zero-cost")));
- /// assert_eq!(wrap20_iter.next(), Some(Cow::from("abstractions.")));
- /// assert_eq!(wrap20_iter.next(), None);
- /// ```
- ///
- /// [`self.splitter`]: #structfield.splitter
- /// [`WordSplitter`]: trait.WordSplitter.html
- /// [`IntoWrapIter`]: struct.IntoWrapIter.html
- /// [`wrap_iter`]: #method.wrap_iter
- pub fn into_wrap_iter(self, s: &'a str) -> IntoWrapIter<'a, S> {
- let inner = WrapIterImpl::new(&self, s);
-
- IntoWrapIter {
- wrapper: self,
- inner: inner,
- }
- }
-}
-
-/// An iterator over the lines of the input string which owns a
-/// `Wrapper`. An instance of `IntoWrapIter` is typically obtained
-/// through either [`wrap_iter`] or [`Wrapper::into_wrap_iter`].
-///
-/// Each call of `.next()` method yields a line wrapped in `Some` if the
-/// input hasn't been fully processed yet. Otherwise it returns `None`.
-///
-/// [`wrap_iter`]: fn.wrap_iter.html
-/// [`Wrapper::into_wrap_iter`]: struct.Wrapper.html#method.into_wrap_iter
-#[derive(Debug)]
-pub struct IntoWrapIter<'a, S: WordSplitter> {
- wrapper: Wrapper<'a, S>,
- inner: WrapIterImpl<'a>,
-}
-
-impl<'a, S: WordSplitter> Iterator for IntoWrapIter<'a, S> {
- type Item = Cow<'a, str>;
-
- fn next(&mut self) -> Option<Cow<'a, str>> {
- self.inner.next(&self.wrapper)
- }
-}
-
-/// An iterator over the lines of the input string which borrows a
-/// `Wrapper`. An instance of `WrapIter` is typically obtained
-/// through the [`Wrapper::wrap_iter`] method.
-///
-/// Each call of `.next()` method yields a line wrapped in `Some` if the
-/// input hasn't been fully processed yet. Otherwise it returns `None`.
-///
-/// [`Wrapper::wrap_iter`]: struct.Wrapper.html#method.wrap_iter
-#[derive(Debug)]
-pub struct WrapIter<'w, 'a: 'w, S: WordSplitter + 'w> {
- wrapper: &'w Wrapper<'a, S>,
- inner: WrapIterImpl<'a>,
-}
-
-impl<'w, 'a: 'w, S: WordSplitter> Iterator for WrapIter<'w, 'a, S> {
- type Item = Cow<'a, str>;
-
- fn next(&mut self) -> Option<Cow<'a, str>> {
- self.inner.next(self.wrapper)
- }
-}
-
-/// Like `char::is_whitespace`, but non-breaking spaces don't count.
-#[inline]
-fn is_whitespace(ch: char) -> bool {
- ch.is_whitespace() && ch != NBSP
-}
-
-/// Common implementation details for `WrapIter` and `IntoWrapIter`.
-#[derive(Debug)]
-struct WrapIterImpl<'a> {
- // String to wrap.
- source: &'a str,
- // CharIndices iterator over self.source.
- char_indices: CharIndices<'a>,
- // Byte index where the current line starts.
- start: usize,
- // Byte index of the last place where the string can be split.
- split: usize,
- // Size in bytes of the character at self.source[self.split].
- split_len: usize,
- // Width of self.source[self.start..idx].
- line_width: usize,
- // Width of self.source[self.start..self.split].
- line_width_at_split: usize,
- // Tracking runs of whitespace characters.
- in_whitespace: bool,
- // Has iterator finished producing elements?
- finished: bool,
-}
-
-impl<'a> WrapIterImpl<'a> {
- fn new<S: WordSplitter>(wrapper: &Wrapper<'a, S>, s: &'a str) -> WrapIterImpl<'a> {
- WrapIterImpl {
- source: s,
- char_indices: s.char_indices(),
- start: 0,
- split: 0,
- split_len: 0,
- line_width: wrapper.initial_indent.width(),
- line_width_at_split: wrapper.initial_indent.width(),
- in_whitespace: false,
- finished: false,
- }
- }
-
- fn create_result_line<S: WordSplitter>(&self, wrapper: &Wrapper<'a, S>) -> Cow<'a, str> {
- if self.start == 0 {
- Cow::from(wrapper.initial_indent)
- } else {
- Cow::from(wrapper.subsequent_indent)
- }
- }
-
- fn next<S: WordSplitter>(&mut self, wrapper: &Wrapper<'a, S>) -> Option<Cow<'a, str>> {
- if self.finished {
- return None;
- }
-
- while let Some((idx, ch)) = self.char_indices.next() {
- let char_width = ch.width().unwrap_or(0);
- let char_len = ch.len_utf8();
-
- if ch == '\n' {
- self.split = idx;
- self.split_len = char_len;
- self.line_width_at_split = self.line_width;
- self.in_whitespace = false;
-
- // If this is not the final line, return the current line. Otherwise,
- // we will return the line with its line break after exiting the loop
- if self.split + self.split_len < self.source.len() {
- let mut line = self.create_result_line(wrapper);
- line += &self.source[self.start..self.split];
-
- self.start = self.split + self.split_len;
- self.line_width = wrapper.subsequent_indent.width();
-
- return Some(line);
- }
- } else if is_whitespace(ch) {
- // Extend the previous split or create a new one.
- if self.in_whitespace {
- self.split_len += char_len;
- } else {
- self.split = idx;
- self.split_len = char_len;
- }
- self.line_width_at_split = self.line_width + char_width;
- self.in_whitespace = true;
- } else if self.line_width + char_width > wrapper.width {
- // There is no room for this character on the current
- // line. Try to split the final word.
- self.in_whitespace = false;
- let remaining_text = &self.source[self.split + self.split_len..];
- let final_word = match remaining_text.find(is_whitespace) {
- Some(i) => &remaining_text[..i],
- None => remaining_text,
- };
-
- let mut hyphen = "";
- let splits = wrapper.splitter.split(final_word);
- for &(head, hyp, _) in splits.iter().rev() {
- if self.line_width_at_split + head.width() + hyp.width() <= wrapper.width {
- // We can fit head into the current line.
- // Advance the split point by the width of the
- // whitespace and the head length.
- self.split += self.split_len + head.len();
- self.split_len = 0;
- hyphen = hyp;
- break;
- }
- }
-
- if self.start >= self.split {
- // The word is too big to fit on a single line, so we
- // need to split it at the current index.
- if wrapper.break_words {
- // Break work at current index.
- self.split = idx;
- self.split_len = 0;
- self.line_width_at_split = self.line_width;
- } else {
- // Add smallest split.
- self.split = self.start + splits[0].0.len();
- self.split_len = 0;
- self.line_width_at_split = self.line_width;
- }
- }
-
- if self.start < self.split {
- let mut line = self.create_result_line(wrapper);
- line += &self.source[self.start..self.split];
- line += hyphen;
-
- self.start = self.split + self.split_len;
- self.line_width += wrapper.subsequent_indent.width();
- self.line_width -= self.line_width_at_split;
- self.line_width += char_width;
-
- return Some(line);
- }
- } else {
- self.in_whitespace = false;
- }
- self.line_width += char_width;
- }
-
- self.finished = true;
-
- // Add final line.
- if self.start < self.source.len() {
- let mut line = self.create_result_line(wrapper);
- line += &self.source[self.start..];
- return Some(line);
- }
-
- None
- }
-}
-
-/// Return the current terminal width. If the terminal width cannot be
-/// determined (typically because the standard output is not connected
-/// to a terminal), a default width of 80 characters will be used.
-///
-/// # Examples
-///
-/// Create a `Wrapper` for the current terminal with a two column
-/// margin:
-///
-/// ```no_run
-/// # #![allow(unused_variables)]
-/// use textwrap::{Wrapper, NoHyphenation, termwidth};
-///
-/// let width = termwidth() - 4; // Two columns on each side.
-/// let wrapper = Wrapper::with_splitter(width, NoHyphenation)
-/// .initial_indent(" ")
-/// .subsequent_indent(" ");
-/// ```
-#[cfg(feature = "term_size")]
-pub fn termwidth() -> usize {
- term_size::dimensions_stdout().map_or(80, |(w, _)| w)
-}
-
-/// Fill a line of text at `width` characters. Strings are wrapped
-/// based on their displayed width, not their size in bytes.
-///
-/// The result is a string with newlines between each line. Use
-/// [`wrap`] if you need access to the individual lines or
-/// [`wrap_iter`] for its iterator counterpart.
-///
-/// ```
-/// use textwrap::fill;
-///
-/// assert_eq!(fill("Memory safety without garbage collection.", 15),
-/// "Memory safety\nwithout garbage\ncollection.");
-/// ```
-///
-/// This function creates a Wrapper on the fly with default settings.
-/// If you need to set a language corpus for automatic hyphenation, or
-/// need to fill many strings, then it is suggested to create a Wrapper
-/// and call its [`fill` method].
-///
-/// [`wrap`]: fn.wrap.html
-/// [`wrap_iter`]: fn.wrap_iter.html
-/// [`fill` method]: struct.Wrapper.html#method.fill
-pub fn fill(s: &str, width: usize) -> String {
- Wrapper::new(width).fill(s)
-}
-
-/// Wrap a line of text at `width` characters. Strings are wrapped
-/// based on their displayed width, not their size in bytes.
-///
-/// This function creates a Wrapper on the fly with default settings.
-/// If you need to set a language corpus for automatic hyphenation, or
-/// need to wrap many strings, then it is suggested to create a Wrapper
-/// and call its [`wrap` method].
-///
-/// The result is a vector of strings. Use [`wrap_iter`] if you need an
-/// iterator version.
-///
-/// # Examples
-///
-/// ```
-/// use textwrap::wrap;
-///
-/// assert_eq!(wrap("Concurrency without data races.", 15),
-/// vec!["Concurrency",
-/// "without data",
-/// "races."]);
-///
-/// assert_eq!(wrap("Concurrency without data races.", 20),
-/// vec!["Concurrency without",
-/// "data races."]);
-/// ```
-///
-/// [`wrap_iter`]: fn.wrap_iter.html
-/// [`wrap` method]: struct.Wrapper.html#method.wrap
-pub fn wrap(s: &str, width: usize) -> Vec<Cow<str>> {
- Wrapper::new(width).wrap(s)
-}
-
-/// Lazily wrap a line of text at `width` characters. Strings are
-/// wrapped based on their displayed width, not their size in bytes.
-///
-/// This function creates a Wrapper on the fly with default settings.
-/// It then calls the [`into_wrap_iter`] method. Hence, the return
-/// value is an [`IntoWrapIter`], not a [`WrapIter`] as the function
-/// name would otherwise suggest.
-///
-/// If you need to set a language corpus for automatic hyphenation, or
-/// need to wrap many strings, then it is suggested to create a Wrapper
-/// and call its [`wrap_iter`] or [`into_wrap_iter`] methods.
-///
-/// # Examples
-///
-/// ```
-/// use std::borrow::Cow;
-/// use textwrap::wrap_iter;
-///
-/// let mut wrap20_iter = wrap_iter("Zero-cost abstractions.", 20);
-/// assert_eq!(wrap20_iter.next(), Some(Cow::from("Zero-cost")));
-/// assert_eq!(wrap20_iter.next(), Some(Cow::from("abstractions.")));
-/// assert_eq!(wrap20_iter.next(), None);
-///
-/// let mut wrap25_iter = wrap_iter("Zero-cost abstractions.", 25);
-/// assert_eq!(wrap25_iter.next(), Some(Cow::from("Zero-cost abstractions.")));
-/// assert_eq!(wrap25_iter.next(), None);
-/// ```
-///
-/// [`wrap_iter`]: struct.Wrapper.html#method.wrap_iter
-/// [`into_wrap_iter`]: struct.Wrapper.html#method.into_wrap_iter
-/// [`IntoWrapIter`]: struct.IntoWrapIter.html
-/// [`WrapIter`]: struct.WrapIter.html
-pub fn wrap_iter(s: &str, width: usize) -> IntoWrapIter<HyphenSplitter> {
- Wrapper::new(width).into_wrap_iter(s)
-}
-
-#[cfg(test)]
-mod tests {
- #[cfg(feature = "hyphenation")]
- extern crate hyphenation;
-
- use super::*;
- #[cfg(feature = "hyphenation")]
- use hyphenation::{Language, Load, Standard};
-
- #[test]
- fn no_wrap() {
- assert_eq!(wrap("foo", 10), vec!["foo"]);
- }
-
- #[test]
- fn simple() {
- assert_eq!(wrap("foo bar baz", 5), vec!["foo", "bar", "baz"]);
- }
-
- #[test]
- fn multi_word_on_line() {
- assert_eq!(wrap("foo bar baz", 10), vec!["foo bar", "baz"]);
- }
-
- #[test]
- fn long_word() {
- assert_eq!(wrap("foo", 0), vec!["f", "o", "o"]);
- }
-
- #[test]
- fn long_words() {
- assert_eq!(wrap("foo bar", 0), vec!["f", "o", "o", "b", "a", "r"]);
- }
-
- #[test]
- fn max_width() {
- assert_eq!(wrap("foo bar", usize::max_value()), vec!["foo bar"]);
- }
-
- #[test]
- fn leading_whitespace() {
- assert_eq!(wrap(" foo bar", 6), vec![" foo", "bar"]);
- }
-
- #[test]
- fn trailing_whitespace() {
- assert_eq!(wrap("foo bar ", 6), vec!["foo", "bar "]);
- }
-
- #[test]
- fn interior_whitespace() {
- assert_eq!(wrap("foo: bar baz", 10), vec!["foo: bar", "baz"]);
- }
-
- #[test]
- fn extra_whitespace_start_of_line() {
- // Whitespace is only significant inside a line. After a line
- // gets too long and is broken, the first word starts in
- // column zero and is not indented. The line before might end
- // up with trailing whitespace.
- assert_eq!(wrap("foo bar", 5), vec!["foo", "bar"]);
- }
-
- #[test]
- fn issue_99() {
- // We did not reset the in_whitespace flag correctly and did
- // not handle single-character words after a line break.
- assert_eq!(
- wrap("aaabbbccc x yyyzzzwww", 9),
- vec!["aaabbbccc", "x", "yyyzzzwww"]
- );
- }
-
- #[test]
- fn issue_129() {
- // The dash is an em-dash which takes up four bytes. We used
- // to panic since we tried to index into the character.
- assert_eq!(wrap("x – x", 1), vec!["x", "–", "x"]);
- }
-
- #[test]
- fn wide_character_handling() {
- assert_eq!(wrap("Hello, World!", 15), vec!["Hello, World!"]);
- assert_eq!(
- wrap("Hello, World!", 15),
- vec!["Hello,", "World!"]
- );
- }
-
- #[test]
- fn empty_input_not_indented() {
- let wrapper = Wrapper::new(10).initial_indent("!!!");
- assert_eq!(wrapper.fill(""), "");
- }
-
- #[test]
- fn indent_single_line() {
- let wrapper = Wrapper::new(10).initial_indent(">>>"); // No trailing space
- assert_eq!(wrapper.fill("foo"), ">>>foo");
- }
-
- #[test]
- fn indent_multiple_lines() {
- let wrapper = Wrapper::new(6).initial_indent("* ").subsequent_indent(" ");
- assert_eq!(wrapper.wrap("foo bar baz"), vec!["* foo", " bar", " baz"]);
- }
-
- #[test]
- fn indent_break_words() {
- let wrapper = Wrapper::new(5).initial_indent("* ").subsequent_indent(" ");
- assert_eq!(wrapper.wrap("foobarbaz"), vec!["* foo", " bar", " baz"]);
- }
-
- #[test]
- fn hyphens() {
- assert_eq!(wrap("foo-bar", 5), vec!["foo-", "bar"]);
- }
-
- #[test]
- fn trailing_hyphen() {
- let wrapper = Wrapper::new(5).break_words(false);
- assert_eq!(wrapper.wrap("foobar-"), vec!["foobar-"]);
- }
-
- #[test]
- fn multiple_hyphens() {
- assert_eq!(wrap("foo-bar-baz", 5), vec!["foo-", "bar-", "baz"]);
- }
-
- #[test]
- fn hyphens_flag() {
- let wrapper = Wrapper::new(5).break_words(false);
- assert_eq!(
- wrapper.wrap("The --foo-bar flag."),
- vec!["The", "--foo-", "bar", "flag."]
- );
- }
-
- #[test]
- fn repeated_hyphens() {
- let wrapper = Wrapper::new(4).break_words(false);
- assert_eq!(wrapper.wrap("foo--bar"), vec!["foo--bar"]);
- }
-
- #[test]
- fn hyphens_alphanumeric() {
- assert_eq!(wrap("Na2-CH4", 5), vec!["Na2-", "CH4"]);
- }
-
- #[test]
- fn hyphens_non_alphanumeric() {
- let wrapper = Wrapper::new(5).break_words(false);
- assert_eq!(wrapper.wrap("foo(-)bar"), vec!["foo(-)bar"]);
- }
-
- #[test]
- fn multiple_splits() {
- assert_eq!(wrap("foo-bar-baz", 9), vec!["foo-bar-", "baz"]);
- }
-
- #[test]
- fn forced_split() {
- let wrapper = Wrapper::new(5).break_words(false);
- assert_eq!(wrapper.wrap("foobar-baz"), vec!["foobar-", "baz"]);
- }
-
- #[test]
- fn no_hyphenation() {
- let wrapper = Wrapper::with_splitter(8, NoHyphenation);
- assert_eq!(wrapper.wrap("foo bar-baz"), vec!["foo", "bar-baz"]);
- }
-
- #[test]
- #[cfg(feature = "hyphenation")]
- fn auto_hyphenation() {
- let dictionary = Standard::from_embedded(Language::EnglishUS).unwrap();
- let wrapper = Wrapper::new(10);
- assert_eq!(
- wrapper.wrap("Internationalization"),
- vec!["Internatio", "nalization"]
- );
-
- let wrapper = Wrapper::with_splitter(10, dictionary);
- assert_eq!(
- wrapper.wrap("Internationalization"),
- vec!["Interna-", "tionaliza-", "tion"]
- );
- }
-
- #[test]
- #[cfg(feature = "hyphenation")]
- fn split_len_hyphenation() {
- // Test that hyphenation takes the width of the wihtespace
- // into account.
- let dictionary = Standard::from_embedded(Language::EnglishUS).unwrap();
- let wrapper = Wrapper::with_splitter(15, dictionary);
- assert_eq!(
- wrapper.wrap("garbage collection"),
- vec!["garbage col-", "lection"]
- );
- }
-
- #[test]
- #[cfg(feature = "hyphenation")]
- fn borrowed_lines() {
- // Lines that end with an extra hyphen are owned, the final
- // line is borrowed.
- use std::borrow::Cow::{Borrowed, Owned};
- let dictionary = Standard::from_embedded(Language::EnglishUS).unwrap();
- let wrapper = Wrapper::with_splitter(10, dictionary);
- let lines = wrapper.wrap("Internationalization");
- if let Borrowed(s) = lines[0] {
- assert!(false, "should not have been borrowed: {:?}", s);
- }
- if let Borrowed(s) = lines[1] {
- assert!(false, "should not have been borrowed: {:?}", s);
- }
- if let Owned(ref s) = lines[2] {
- assert!(false, "should not have been owned: {:?}", s);
- }
- }
-
- #[test]
- #[cfg(feature = "hyphenation")]
- fn auto_hyphenation_with_hyphen() {
- let dictionary = Standard::from_embedded(Language::EnglishUS).unwrap();
- let wrapper = Wrapper::new(8).break_words(false);
- assert_eq!(wrapper.wrap("over-caffinated"), vec!["over-", "caffinated"]);
-
- let wrapper = Wrapper::with_splitter(8, dictionary).break_words(false);
- assert_eq!(
- wrapper.wrap("over-caffinated"),
- vec!["over-", "caffi-", "nated"]
- );
- }
-
- #[test]
- fn break_words() {
- assert_eq!(wrap("foobarbaz", 3), vec!["foo", "bar", "baz"]);
- }
-
- #[test]
- fn break_words_wide_characters() {
- assert_eq!(wrap("Hello", 5), vec!["He", "ll", "o"]);
- }
-
- #[test]
- fn break_words_zero_width() {
- assert_eq!(wrap("foobar", 0), vec!["f", "o", "o", "b", "a", "r"]);
- }
-
- #[test]
- fn break_words_line_breaks() {
- assert_eq!(fill("ab\ncdefghijkl", 5), "ab\ncdefg\nhijkl");
- assert_eq!(fill("abcdefgh\nijkl", 5), "abcde\nfgh\nijkl");
- }
-
- #[test]
- fn preserve_line_breaks() {
- assert_eq!(fill("test\n", 11), "test\n");
- assert_eq!(fill("test\n\na\n\n", 11), "test\n\na\n\n");
- assert_eq!(fill("1 3 5 7\n1 3 5 7", 7), "1 3 5 7\n1 3 5 7");
- }
-
- #[test]
- fn wrap_preserve_line_breaks() {
- assert_eq!(fill("1 3 5 7\n1 3 5 7", 5), "1 3 5\n7\n1 3 5\n7");
- }
-
- #[test]
- fn non_breaking_space() {
- let wrapper = Wrapper::new(5).break_words(false);
- assert_eq!(wrapper.fill("foo bar baz"), "foo bar baz");
- }
-
- #[test]
- fn non_breaking_hyphen() {
- let wrapper = Wrapper::new(5).break_words(false);
- assert_eq!(wrapper.fill("foo‑bar‑baz"), "foo‑bar‑baz");
- }
-
- #[test]
- fn fill_simple() {
- assert_eq!(fill("foo bar baz", 10), "foo bar\nbaz");
- }
-}
diff --git a/textwrap/src/splitting.rs b/textwrap/src/splitting.rs
deleted file mode 100644
index f6b65af..0000000
--- a/textwrap/src/splitting.rs
+++ /dev/null
@@ -1,139 +0,0 @@
-//! Word splitting functionality.
-//!
-//! To wrap text into lines, long words sometimes need to be split
-//! across lines. The [`WordSplitter`] trait defines this
-//! functionality. [`HyphenSplitter`] is the default implementation of
-//! this treat: it will simply split words on existing hyphens.
-
-#[cfg(feature = "hyphenation")]
-use hyphenation::{Hyphenator, Standard};
-
-/// An interface for splitting words.
-///
-/// When the [`wrap_iter`] method will try to fit text into a line, it
-/// will eventually find a word that it too large the current text
-/// width. It will then call the currently configured `WordSplitter` to
-/// have it attempt to split the word into smaller parts. This trait
-/// describes that functionality via the [`split`] method.
-///
-/// If the `textwrap` crate has been compiled with the `hyphenation`
-/// feature enabled, you will find an implementation of `WordSplitter`
-/// by the `hyphenation::language::Corpus` struct. Use this struct for
-/// language-aware hyphenation. See the [`hyphenation` documentation]
-/// for details.
-///
-/// [`wrap_iter`]: ../struct.Wrapper.html#method.wrap_iter
-/// [`split`]: #tymethod.split
-/// [`hyphenation` documentation]: https://docs.rs/hyphenation/
-pub trait WordSplitter {
- /// Return all possible splits of word. Each split is a triple
- /// with a head, a hyphen, and a tail where `head + &hyphen +
- /// &tail == word`. The hyphen can be empty if there is already a
- /// hyphen in the head.
- ///
- /// The splits should go from smallest to longest and should
- /// include no split at all. So the word "technology" could be
- /// split into
- ///
- /// ```no_run
- /// vec![("tech", "-", "nology"),
- /// ("technol", "-", "ogy"),
- /// ("technolo", "-", "gy"),
- /// ("technology", "", "")];
- /// ```
- fn split<'w>(&self, word: &'w str) -> Vec<(&'w str, &'w str, &'w str)>;
-}
-
-/// Use this as a [`Wrapper.splitter`] to avoid any kind of
-/// hyphenation:
-///
-/// ```
-/// use textwrap::{Wrapper, NoHyphenation};
-///
-/// let wrapper = Wrapper::with_splitter(8, NoHyphenation);
-/// assert_eq!(wrapper.wrap("foo bar-baz"), vec!["foo", "bar-baz"]);
-/// ```
-///
-/// [`Wrapper.splitter`]: ../struct.Wrapper.html#structfield.splitter
-#[derive(Clone, Debug)]
-pub struct NoHyphenation;
-
-/// `NoHyphenation` implements `WordSplitter` by not splitting the
-/// word at all.
-impl WordSplitter for NoHyphenation {
- fn split<'w>(&self, word: &'w str) -> Vec<(&'w str, &'w str, &'w str)> {
- vec![(word, "", "")]
- }
-}
-
-/// Simple and default way to split words: splitting on existing
-/// hyphens only.
-///
-/// You probably don't need to use this type since it's already used
-/// by default by `Wrapper::new`.
-#[derive(Clone, Debug)]
-pub struct HyphenSplitter;
-
-/// `HyphenSplitter` is the default `WordSplitter` used by
-/// `Wrapper::new`. It will split words on any existing hyphens in the
-/// word.
-///
-/// It will only use hyphens that are surrounded by alphanumeric
-/// characters, which prevents a word like "--foo-bar" from being
-/// split on the first or second hyphen.
-impl WordSplitter for HyphenSplitter {
- fn split<'w>(&self, word: &'w str) -> Vec<(&'w str, &'w str, &'w str)> {
- let mut triples = Vec::new();
- // Split on hyphens, smallest split first. We only use hyphens
- // that are surrounded by alphanumeric characters. This is to
- // avoid splitting on repeated hyphens, such as those found in
- // --foo-bar.
- let mut char_indices = word.char_indices();
- // Early return if the word is empty.
- let mut prev = match char_indices.next() {
- None => return vec![(word, "", "")],
- Some((_, ch)) => ch,
- };
-
- // Find current word, or return early if the word only has a
- // single character.
- let (mut idx, mut cur) = match char_indices.next() {
- None => return vec![(word, "", "")],
- Some((idx, cur)) => (idx, cur),
- };
-
- for (i, next) in char_indices {
- if prev.is_alphanumeric() && cur == '-' && next.is_alphanumeric() {
- let (head, tail) = word.split_at(idx + 1);
- triples.push((head, "", tail));
- }
- prev = cur;
- idx = i;
- cur = next;
- }
-
- // Finally option is no split at all.
- triples.push((word, "", ""));
-
- triples
- }
-}
-
-/// A hyphenation dictionary can be used to do language-specific
-/// hyphenation using patterns from the hyphenation crate.
-#[cfg(feature = "hyphenation")]
-impl WordSplitter for Standard {
- fn split<'w>(&self, word: &'w str) -> Vec<(&'w str, &'w str, &'w str)> {
- // Find splits based on language dictionary.
- let mut triples = Vec::new();
- for n in self.hyphenate(word).breaks {
- let (head, tail) = word.split_at(n);
- let hyphen = if head.ends_with('-') { "" } else { "-" };
- triples.push((head, hyphen, tail));
- }
- // Finally option is no split at all.
- triples.push((word, "", ""));
-
- triples
- }
-}
diff --git a/textwrap/tests/version-numbers.rs b/textwrap/tests/version-numbers.rs
deleted file mode 100644
index 85c52e3..0000000
--- a/textwrap/tests/version-numbers.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-#[macro_use]
-extern crate version_sync;
-
-#[test]
-fn test_readme_deps() {
- assert_markdown_deps_updated!("README.md");
-}
-
-#[test]
-fn test_readme_changelog() {
- assert_contains_regex!("README.md", r"^### Version {version} — .* \d\d?.., 20\d\d$");
-}
-
-#[test]
-fn test_html_root_url() {
- assert_html_root_url_updated!("src/lib.rs");
-}
diff --git a/unicode-segmentation/.gitignore b/unicode-segmentation/.gitignore
deleted file mode 100644
index ec1ef20..0000000
--- a/unicode-segmentation/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-target
-Cargo.lock
-scripts/tmp
-*.pyc
-*.txt
diff --git a/unicode-segmentation/.travis.yml b/unicode-segmentation/.travis.yml
deleted file mode 100644
index af011bd..0000000
--- a/unicode-segmentation/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-language: rust
-rust:
- - 1.24.0
- - stable
-os: linux
-script:
- - cargo build --verbose
- - |
- if [ $TRAVIS_RUST_VERSION = stable ]; then cargo test --verbose || travis_terminate 1; fi
- - cargo doc
-after_success: |
- [ $TRAVIS_RUST_VERSION = stable ] &&
- [ $TRAVIS_BRANCH = master ] &&
- [ $TRAVIS_PULL_REQUEST = false ] &&
- echo '<meta http-equiv=refresh content=0;url=unicode_segmentation/index.html>' > target/doc/index.html &&
- pip install ghp-import --user &&
- $HOME/.local/bin/ghp-import -n target/doc &&
- git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
-env:
- global:
- secure: d3xB8MAHhj88le5WjaDmIsharVeZ+eDIbQtuPEkg5VjIsD+ZOc9ZY/y1Nrz3q8Xh3ytjYv78IWmxwn8UsRhimCZbgR4V4xkz8hSgIGn9dFbOvIpbeg6Tfvu2UO2YUOcNc/WtI/uymaMuZ2g8Fcg7K2ITEO2lXAcOFRpnBh2dXmA=
-notifications:
- email:
- on_success: never
diff --git a/unicode-segmentation/COPYRIGHT b/unicode-segmentation/COPYRIGHT
deleted file mode 100644
index b286ec1..0000000
--- a/unicode-segmentation/COPYRIGHT
+++ /dev/null
@@ -1,7 +0,0 @@
-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.
diff --git a/unicode-segmentation/Cargo.toml b/unicode-segmentation/Cargo.toml
deleted file mode 100644
index c513e11..0000000
--- a/unicode-segmentation/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-[package]
-
-name = "unicode-segmentation"
-version = "1.6.0"
-authors = ["kwantam <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"]
-
-homepage = "https://github.com/unicode-rs/unicode-segmentation"
-repository = "https://github.com/unicode-rs/unicode-segmentation"
-documentation = "https://unicode-rs.github.io/unicode-segmentation"
-
-license = "MIT/Apache-2.0"
-keywords = ["text", "unicode", "grapheme", "word", "boundary"]
-readme = "README.md"
-description = """
-This crate provides Grapheme Cluster, Word and Sentence boundaries
-according to Unicode Standard Annex #29 rules.
-"""
-
-exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt" ]
-
-[features]
-no_std = [] # This is a no-op, preserved for backward compatibility only.
-
-[dev-dependencies]
-quickcheck = "0.7"
diff --git a/unicode-segmentation/LICENSE-APACHE b/unicode-segmentation/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/unicode-segmentation/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/unicode-segmentation/LICENSE-MIT b/unicode-segmentation/LICENSE-MIT
deleted file mode 100644
index e69282e..0000000
--- a/unicode-segmentation/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2015 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/unicode-segmentation/README.md b/unicode-segmentation/README.md
deleted file mode 100644
index 08fe6b8..0000000
--- a/unicode-segmentation/README.md
+++ /dev/null
@@ -1,89 +0,0 @@
-Iterators which split strings on Grapheme Cluster or Word boundaries, according
-to the [Unicode Standard Annex #29](http://www.unicode.org/reports/tr29/) rules.
-
-[![Build Status](https://travis-ci.org/unicode-rs/unicode-segmentation.svg)](https://travis-ci.org/unicode-rs/unicode-segmentation)
-
-[Documentation](https://unicode-rs.github.io/unicode-segmentation/unicode_segmentation/index.html)
-
-```rust
-use unicode_segmentation::UnicodeSegmentation;
-
-fn main() {
- let s = "a̐éö̲\r\n";
- let g = UnicodeSegmentation::graphemes(s, true).collect::<Vec<&str>>();
- let b: &[_] = &["a̐", "é", "ö̲", "\r\n"];
- assert_eq!(g, b);
-
- let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
- let w = s.unicode_words().collect::<Vec<&str>>();
- let b: &[_] = &["The", "quick", "brown", "fox", "can't", "jump", "32.3", "feet", "right"];
- assert_eq!(w, b);
-
- let s = "The quick (\"brown\") fox";
- let w = s.split_word_bounds().collect::<Vec<&str>>();
- let b: &[_] = &["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", " ", "fox"];
- assert_eq!(w, b);
-}
-```
-
-# no_std
-
-unicode-segmentation does not depend on libstd, so it can be used in crates
-with the `#![no_std]` attribute.
-
-# crates.io
-
-You can use this package in your project by adding the following
-to your `Cargo.toml`:
-
-```toml
-[dependencies]
-unicode-segmentation = "1.3.0"
-```
-
-# Change Log
-
-## 1.6.0
-
-* [#72](https://github.com/unicode-rs/unicode-segmentation/pull/72) Upgrade to Unicode 12
-
-## 1.5.0
-
-* [#68](https://github.com/unicode-rs/unicode-segmentation/pull/68) Upgrade to Unicode 11
-
-## 1.4.0
-
-* [#56](https://github.com/unicode-rs/unicode-segmentation/pull/56) Upgrade to Unicode 10
-
-## 1.3.0
-
-* [#24](https://github.com/unicode-rs/unicode-segmentation/pull/24) Add support for sentence boundaries
-* [#44](https://github.com/unicode-rs/unicode-segmentation/pull/44) Treat `gc=No` as a subset of `gc=N`
-
-## 1.2.1
-
-* [#37](https://github.com/unicode-rs/unicode-segmentation/pull/37):
- Fix panic in `provide_context`.
-* [#40](https://github.com/unicode-rs/unicode-segmentation/pull/40):
- Fix crash in `prev_boundary`.
-
-## 1.2.0
-
-* New `GraphemeCursor` API allows random access and bidirectional iteration.
-* Fixed incorrect splitting of certain emoji modifier sequences.
-
-## 1.1.0
-
-* Add `as_str` methods to the iterator types.
-
-## 1.0.3
-
-* Code cleanup and additional tests.
-
-## 1.0.1
-
-* Fix a bug affecting some grapheme clusters containing Prepend characters.
-
-## 1.0.0
-
-* Upgrade to Unicode 9.0.0.
diff --git a/unicode-segmentation/scripts/unicode.py b/unicode-segmentation/scripts/unicode.py
deleted file mode 100755
index 580b3c0..0000000
--- a/unicode-segmentation/scripts/unicode.py
+++ /dev/null
@@ -1,375 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011-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.
-
-# This script uses the following Unicode tables:
-# - DerivedCoreProperties.txt
-# - auxiliary/GraphemeBreakProperty.txt
-# - auxiliary/WordBreakProperty.txt
-# - ReadMe.txt
-# - UnicodeData.txt
-#
-# Since this should not require frequent updates, we just store this
-# out-of-line and check the unicode.rs file into git.
-
-import fileinput, re, os, sys
-
-preamble = '''// Copyright 2012-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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
-'''
-
-# Mapping taken from Table 12 from:
-# http://www.unicode.org/reports/tr44/#General_Category_Values
-expanded_categories = {
- 'Lu': ['LC', 'L'], 'Ll': ['LC', 'L'], 'Lt': ['LC', 'L'],
- 'Lm': ['L'], 'Lo': ['L'],
- 'Mn': ['M'], 'Mc': ['M'], 'Me': ['M'],
- 'Nd': ['N'], 'Nl': ['N'], 'No': ['N'],
- 'Pc': ['P'], 'Pd': ['P'], 'Ps': ['P'], 'Pe': ['P'],
- 'Pi': ['P'], 'Pf': ['P'], 'Po': ['P'],
- 'Sm': ['S'], 'Sc': ['S'], 'Sk': ['S'], 'So': ['S'],
- 'Zs': ['Z'], 'Zl': ['Z'], 'Zp': ['Z'],
- 'Cc': ['C'], 'Cf': ['C'], 'Cs': ['C'], 'Co': ['C'], 'Cn': ['C'],
-}
-
-# these are the surrogate codepoints, which are not valid rust characters
-surrogate_codepoints = (0xd800, 0xdfff)
-
-UNICODE_VERSION = (12, 0, 0)
-
-UNICODE_VERSION_NUMBER = "%s.%s.%s" %UNICODE_VERSION
-
-def is_surrogate(n):
- return surrogate_codepoints[0] <= n <= surrogate_codepoints[1]
-
-def fetch(f):
- if not os.path.exists(os.path.basename(f)):
- if "emoji" in f:
- os.system("curl -O https://www.unicode.org/Public/emoji/%s.%s/%s"
- % (UNICODE_VERSION[0], UNICODE_VERSION[1], f))
- else:
- os.system("curl -O http://www.unicode.org/Public/%s/ucd/%s"
- % (UNICODE_VERSION_NUMBER, f))
-
- if not os.path.exists(os.path.basename(f)):
- sys.stderr.write("cannot load %s" % f)
- exit(1)
-
-def load_gencats(f):
- fetch(f)
- gencats = {}
-
- udict = {};
- range_start = -1;
- for line in fileinput.input(f):
- data = line.split(';');
- if len(data) != 15:
- continue
- cp = int(data[0], 16);
- if is_surrogate(cp):
- continue
- if range_start >= 0:
- for i in range(range_start, cp):
- udict[i] = data;
- range_start = -1;
- if data[1].endswith(", First>"):
- range_start = cp;
- continue;
- udict[cp] = data;
-
- for code in udict:
- [code_org, name, gencat, combine, bidi,
- decomp, deci, digit, num, mirror,
- old, iso, upcase, lowcase, titlecase ] = udict[code];
-
- # place letter in categories as appropriate
- for cat in [gencat, "Assigned"] + expanded_categories.get(gencat, []):
- if cat not in gencats:
- gencats[cat] = []
- gencats[cat].append(code)
-
- gencats = group_cats(gencats)
- return gencats
-
-def group_cats(cats):
- cats_out = {}
- for cat in cats:
- cats_out[cat] = group_cat(cats[cat])
- return cats_out
-
-def group_cat(cat):
- cat_out = []
- letters = sorted(set(cat))
- cur_start = letters.pop(0)
- cur_end = cur_start
- for letter in letters:
- assert letter > cur_end, \
- "cur_end: %s, letter: %s" % (hex(cur_end), hex(letter))
- if letter == cur_end + 1:
- cur_end = letter
- else:
- cat_out.append((cur_start, cur_end))
- cur_start = cur_end = letter
- cat_out.append((cur_start, cur_end))
- return cat_out
-
-def ungroup_cat(cat):
- cat_out = []
- for (lo, hi) in cat:
- while lo <= hi:
- cat_out.append(lo)
- lo += 1
- return cat_out
-
-def format_table_content(f, content, indent):
- line = " "*indent
- first = True
- for chunk in content.split(","):
- if len(line) + len(chunk) < 98:
- if first:
- line += chunk
- else:
- line += ", " + chunk
- first = False
- else:
- f.write(line + ",\n")
- line = " "*indent + chunk
- f.write(line)
-
-def load_properties(f, interestingprops):
- fetch(f)
- props = {}
- re1 = re.compile(r"^ *([0-9A-F]+) *; *(\w+)")
- re2 = re.compile(r"^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+)")
-
- for line in fileinput.input(os.path.basename(f)):
- prop = None
- d_lo = 0
- d_hi = 0
- m = re1.match(line)
- if m:
- d_lo = m.group(1)
- d_hi = m.group(1)
- prop = m.group(2)
- else:
- m = re2.match(line)
- if m:
- d_lo = m.group(1)
- d_hi = m.group(2)
- prop = m.group(3)
- else:
- continue
- if interestingprops and prop not in interestingprops:
- continue
- d_lo = int(d_lo, 16)
- d_hi = int(d_hi, 16)
- if prop not in props:
- props[prop] = []
- props[prop].append((d_lo, d_hi))
-
- # optimize if possible
- for prop in props:
- props[prop] = group_cat(ungroup_cat(props[prop]))
-
- return props
-
-def escape_char(c):
- return "'\\u{%x}'" % c
-
-def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
- pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1])), is_const=True):
- pub_string = "const"
- if not is_const:
- pub_string = "let"
- if is_pub:
- pub_string = "pub " + pub_string
- f.write(" %s %s: %s = &[\n" % (pub_string, name, t_type))
- data = ""
- first = True
- for dat in t_data:
- if not first:
- data += ","
- first = False
- data += pfun(dat)
- format_table_content(f, data, 8)
- f.write("\n ];\n\n")
-
-def emit_util_mod(f):
- f.write("""
-pub mod util {
- #[inline]
- pub fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
- use core::cmp::Ordering::{Equal, Less, Greater};
- r.binary_search_by(|&(lo,hi)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }).is_ok()
- }
-
- #[inline]
- fn is_alphabetic(c: char) -> bool {
- match c {
- 'a' ... 'z' | 'A' ... 'Z' => true,
- c if c > '\x7f' => super::derived_property::Alphabetic(c),
- _ => false,
- }
- }
-
- #[inline]
- fn is_numeric(c: char) -> bool {
- match c {
- '0' ... '9' => true,
- c if c > '\x7f' => super::general_category::N(c),
- _ => false,
- }
- }
-
- #[inline]
- pub fn is_alphanumeric(c: char) -> bool {
- is_alphabetic(c) || is_numeric(c)
- }
-}
-
-""")
-
-def emit_property_module(f, mod, tbl, emit):
- f.write("mod %s {\n" % mod)
- for cat in sorted(emit):
- emit_table(f, "%s_table" % cat, tbl[cat], is_pub=False)
- f.write(" #[inline]\n")
- f.write(" pub fn %s(c: char) -> bool {\n" % cat)
- f.write(" super::util::bsearch_range_table(c, %s_table)\n" % cat)
- f.write(" }\n\n")
- f.write("}\n\n")
-
-def emit_break_module(f, break_table, break_cats, name):
- Name = name.capitalize()
- f.write("""pub mod %s {
- use core::result::Result::{Ok, Err};
-
- pub use self::%sCat::*;
-
- #[allow(non_camel_case_types)]
- #[derive(Clone, Copy, PartialEq, Eq, Debug)]
- pub enum %sCat {
-""" % (name, Name, Name))
-
- break_cats.append("Any")
- break_cats.sort()
- for cat in break_cats:
- f.write((" %sC_" % Name[0]) + cat + ",\n")
- f.write(""" }
-
- fn bsearch_range_value_table(c: char, r: &'static [(char, char, %sCat)]) -> %sCat {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, cat) = r[idx];
- cat
- }
- Err(_) => %sC_Any
- }
- }
-
- pub fn %s_category(c: char) -> %sCat {
- bsearch_range_value_table(c, %s_cat_table)
- }
-
-""" % (Name, Name, Name[0], name, Name, name))
-
- emit_table(f, "%s_cat_table" % name, break_table, "&'static [(char, char, %sCat)]" % Name,
- pfun=lambda x: "(%s,%s,%sC_%s)" % (escape_char(x[0]), escape_char(x[1]), Name[0], x[2]),
- is_pub=False, is_const=True)
- f.write("}\n")
-
-if __name__ == "__main__":
- r = "tables.rs"
- if os.path.exists(r):
- os.remove(r)
- with open(r, "w") as rf:
- # write the file's preamble
- rf.write(preamble)
- rf.write("""
-/// The version of [Unicode](http://www.unicode.org/)
-/// that this version of unicode-segmentation is based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
-""" % UNICODE_VERSION)
-
- # download and parse all the data
- gencats = load_gencats("UnicodeData.txt")
- derived = load_properties("DerivedCoreProperties.txt", ["Alphabetic"])
-
- emit_util_mod(rf)
- for (name, cat, pfuns) in ("general_category", gencats, ["N"]), \
- ("derived_property", derived, ["Alphabetic"]):
- emit_property_module(rf, name, cat, pfuns)
-
- ### grapheme cluster module
- # from http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Break_Property_Values
- grapheme_cats = load_properties("auxiliary/GraphemeBreakProperty.txt", [])
-
- # Control
- # Note:
- # This category also includes Cs (surrogate codepoints), but Rust's `char`s are
- # Unicode Scalar Values only, and surrogates are thus invalid `char`s.
- # Thus, we have to remove Cs from the Control category
- grapheme_cats["Control"] = group_cat(list(
- set(ungroup_cat(grapheme_cats["Control"]))
- - set(ungroup_cat([surrogate_codepoints]))))
-
- grapheme_table = []
- for cat in grapheme_cats:
- grapheme_table.extend([(x, y, cat) for (x, y) in grapheme_cats[cat]])
- emoji_props = load_properties("emoji-data.txt", ["Extended_Pictographic"])
- grapheme_table.extend([(x, y, "Extended_Pictographic") for (x, y) in emoji_props["Extended_Pictographic"]])
- grapheme_table.sort(key=lambda w: w[0])
- last = -1
- for chars in grapheme_table:
- if chars[0] <= last:
- raise "Grapheme tables and Extended_Pictographic values overlap; need to store these separately!"
- last = chars[1]
- emit_break_module(rf, grapheme_table, list(grapheme_cats.keys()) + ["Extended_Pictographic"], "grapheme")
- rf.write("\n")
-
- word_cats = load_properties("auxiliary/WordBreakProperty.txt", [])
- word_table = []
- for cat in word_cats:
- word_table.extend([(x, y, cat) for (x, y) in word_cats[cat]])
- word_table.sort(key=lambda w: w[0])
- emit_break_module(rf, word_table, list(word_cats.keys()), "word")
-
- # There are some emoji which are also ALetter, so this needs to be stored separately
- # For efficiency, we could still merge the two tables and produce an ALetterEP state
- emoji_table = [(x, y, "Extended_Pictographic") for (x, y) in emoji_props["Extended_Pictographic"]]
- emit_break_module(rf, emoji_table, ["Extended_Pictographic"], "emoji")
-
- sentence_cats = load_properties("auxiliary/SentenceBreakProperty.txt", [])
- sentence_table = []
- for cat in sentence_cats:
- sentence_table.extend([(x, y, cat) for (x, y) in sentence_cats[cat]])
- sentence_table.sort(key=lambda w: w[0])
- emit_break_module(rf, sentence_table, list(sentence_cats.keys()), "sentence")
diff --git a/unicode-segmentation/scripts/unicode_gen_breaktests.py b/unicode-segmentation/scripts/unicode_gen_breaktests.py
deleted file mode 100755
index 113afa9..0000000
--- a/unicode-segmentation/scripts/unicode_gen_breaktests.py
+++ /dev/null
@@ -1,212 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8
-#
-# 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.
-
-# This script uses the following Unicode tables:
-# - auxiliary/GraphemeBreakTest.txt
-# - auxiliary/WordBreakTest.txt
-#
-# Since this should not require frequent updates, we just store this
-# out-of-line and check the unicode.rs file into git.
-from __future__ import print_function
-
-import unicode, re, os, fileinput
-
-def load_test_data(f, optsplit=[]):
- testRe1 = re.compile(r"^÷\s+([^\s].*[^\s])\s+÷\s+#\s+÷\s+\[0.2\].*?([÷×].*)\s+÷\s+\[0.3\]\s*$")
-
- unicode.fetch(f)
- data = []
- for line in fileinput.input(os.path.basename(f)):
- # lines that include a test start with the ÷ character
- if len(line) < 2 or not line.startswith('÷'):
- continue
-
- m = testRe1.match(line)
- if not m:
- print("error: no match on line where test was expected: %s" % line)
- continue
-
- # process the characters in this test case
- chars = process_split_string(m.group(1))
- # skip test case if it contains invalid characters (viz., surrogates)
- if not chars:
- continue
-
- # now process test cases
- (chars, info) = process_split_info(m.group(2), chars, optsplit)
-
- # make sure that we have break info for each break!
- assert len(chars) - 1 == len(info)
-
- data.append((chars, info))
-
- return data
-
-def process_split_info(s, c, o):
- outcs = []
- outis = []
- workcs = c.pop(0)
-
- # are we on a × or a ÷?
- isX = False
- if s.startswith('×'):
- isX = True
-
- # find each instance of '(÷|×) [x.y] '
- while s:
- # find the currently considered rule number
- sInd = s.index('[') + 1
- eInd = s.index(']')
-
- # if it's '× [a.b]' where 'a.b' is in o, then
- # we consider it a split even though it's not
- # marked as one
- # if it's ÷ then it's always a split
- if not isX or s[sInd:eInd] in o:
- outis.append(s[sInd:eInd])
- outcs.append(workcs)
- workcs = c.pop(0)
- else:
- workcs.extend(c.pop(0))
-
- idx = 1
- while idx < len(s):
- if s[idx:].startswith('×'):
- isX = True
- break
- if s[idx:].startswith('÷'):
- isX = False
- break
- idx += 1
- s = s[idx:]
-
- outcs.append(workcs)
- return (outcs, outis)
-
-def process_split_string(s):
- outls = []
- workls = []
-
- inls = s.split()
-
- for i in inls:
- if i == '÷' or i == '×':
- outls.append(workls)
- workls = []
- continue
-
- ival = int(i,16)
-
- if unicode.is_surrogate(ival):
- return []
-
- workls.append(ival)
-
- if workls:
- outls.append(workls)
-
- return outls
-
-def showfun(x):
- outstr = '("'
- for c in x[0]:
- outstr += "\\u{%x}" % c
- outstr += '",&['
- xfirst = True
- for xx in x[1:]:
- if not xfirst:
- outstr += '],&['
- xfirst = False
- sfirst = True
- for sp in xx:
- if not sfirst:
- outstr += ','
- sfirst = False
- outstr += '"'
- for c in sp:
- outstr += "\\u{%x}" % c
- outstr += '"'
- outstr += '])'
- return outstr
-
-def create_grapheme_data(f):
- # rules 9.1 and 9.2 are for extended graphemes only
- optsplits = ['9.1','9.2']
- d = load_test_data("auxiliary/GraphemeBreakTest.txt", optsplits)
-
- test_same = []
- test_diff = []
-
- for (c, i) in d:
- allchars = [cn for s in c for cn in s]
- extgraphs = []
- extwork = []
-
- extwork.extend(c[0])
- for n in range(0,len(i)):
- if i[n] in optsplits:
- extwork.extend(c[n+1])
- else:
- extgraphs.append(extwork)
- extwork = []
- extwork.extend(c[n+1])
-
- # these are the extended grapheme clusters
- extgraphs.append(extwork)
-
- if extgraphs == c:
- test_same.append((allchars, c))
- else:
- test_diff.append((allchars, extgraphs, c))
-
- stype = "&'static [(&'static str, &'static [&'static str])]"
- dtype = "&'static [(&'static str, &'static [&'static str], &'static [&'static str])]"
- f.write(" // official Unicode test data\n")
- f.write(" // http://www.unicode.org/Public/%s/ucd/auxiliary/GraphemeBreakTest.txt\n" % unicode.UNICODE_VERSION_NUMBER)
- unicode.emit_table(f, "TEST_SAME", test_same, stype, True, showfun, True)
- unicode.emit_table(f, "TEST_DIFF", test_diff, dtype, True, showfun, True)
-
-def create_words_data(f):
- d = load_test_data("auxiliary/WordBreakTest.txt")
-
- test = []
-
- for (c, i) in d:
- allchars = [cn for s in c for cn in s]
- test.append((allchars, c))
-
- wtype = "&'static [(&'static str, &'static [&'static str])]"
- f.write(" // official Unicode test data\n")
- f.write(" // http://www.unicode.org/Public/%s/ucd/auxiliary/WordBreakTest.txt\n" % unicode.UNICODE_VERSION_NUMBER)
- unicode.emit_table(f, "TEST_WORD", test, wtype, True, showfun, True)
-
-def create_sentence_data(f):
- d = load_test_data("auxiliary/SentenceBreakTest.txt")
-
- test = []
-
- for (c, i) in d:
- allchars = [cn for s in c for cn in s]
- test.append((allchars, c))
-
- wtype = "&'static [(&'static str, &'static [&'static str])]"
- f.write(" // official Unicode test data\n")
- f.write(" // http://www.unicode.org/Public/%s/ucd/auxiliary/SentenceBreakTest.txt\n" % unicode.UNICODE_VERSION_NUMBER)
- unicode.emit_table(f, "TEST_SENTENCE", test, wtype, True, showfun, True)
-
-if __name__ == "__main__":
- with open("testdata.rs", "w") as rf:
- rf.write(unicode.preamble)
- create_grapheme_data(rf)
- create_words_data(rf)
- create_sentence_data(rf)
diff --git a/unicode-segmentation/src/grapheme.rs b/unicode-segmentation/src/grapheme.rs
deleted file mode 100644
index cde6526..0000000
--- a/unicode-segmentation/src/grapheme.rs
+++ /dev/null
@@ -1,708 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use core::cmp;
-
-use tables::grapheme::GraphemeCat;
-
-/// External iterator for grapheme clusters and byte offsets.
-#[derive(Clone)]
-pub struct GraphemeIndices<'a> {
- start_offset: usize,
- iter: Graphemes<'a>,
-}
-
-impl<'a> GraphemeIndices<'a> {
- #[inline]
- /// View the underlying data (the part yet to be iterated) as a slice of the original string.
- ///
- /// ```rust
- /// # use unicode_segmentation::UnicodeSegmentation;
- /// let mut iter = "abc".grapheme_indices(true);
- /// assert_eq!(iter.as_str(), "abc");
- /// iter.next();
- /// assert_eq!(iter.as_str(), "bc");
- /// iter.next();
- /// iter.next();
- /// assert_eq!(iter.as_str(), "");
- /// ```
- pub fn as_str(&self) -> &'a str {
- self.iter.as_str()
- }
-}
-
-impl<'a> Iterator for GraphemeIndices<'a> {
- type Item = (usize, &'a str);
-
- #[inline]
- fn next(&mut self) -> Option<(usize, &'a str)> {
- self.iter.next().map(|s| (s.as_ptr() as usize - self.start_offset, s))
- }
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.iter.size_hint()
- }
-}
-
-impl<'a> DoubleEndedIterator for GraphemeIndices<'a> {
- #[inline]
- fn next_back(&mut self) -> Option<(usize, &'a str)> {
- self.iter.next_back().map(|s| (s.as_ptr() as usize - self.start_offset, s))
- }
-}
-
-/// External iterator for a string's
-/// [grapheme clusters](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries).
-#[derive(Clone)]
-pub struct Graphemes<'a> {
- string: &'a str,
- cursor: GraphemeCursor,
- cursor_back: GraphemeCursor,
-}
-
-impl<'a> Graphemes<'a> {
- #[inline]
- /// View the underlying data (the part yet to be iterated) as a slice of the original string.
- ///
- /// ```rust
- /// # use unicode_segmentation::UnicodeSegmentation;
- /// let mut iter = "abc".graphemes(true);
- /// assert_eq!(iter.as_str(), "abc");
- /// iter.next();
- /// assert_eq!(iter.as_str(), "bc");
- /// iter.next();
- /// iter.next();
- /// assert_eq!(iter.as_str(), "");
- /// ```
- pub fn as_str(&self) -> &'a str {
- &self.string[self.cursor.cur_cursor()..self.cursor_back.cur_cursor()]
- }
-}
-
-impl<'a> Iterator for Graphemes<'a> {
- type Item = &'a str;
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- let slen = self.cursor_back.cur_cursor() - self.cursor.cur_cursor();
- (cmp::min(slen, 1), Some(slen))
- }
-
- #[inline]
- fn next(&mut self) -> Option<&'a str> {
- let start = self.cursor.cur_cursor();
- if start == self.cursor_back.cur_cursor() {
- return None;
- }
- let next = self.cursor.next_boundary(self.string, 0).unwrap().unwrap();
- Some(&self.string[start..next])
- }
-}
-
-impl<'a> DoubleEndedIterator for Graphemes<'a> {
- #[inline]
- fn next_back(&mut self) -> Option<&'a str> {
- let end = self.cursor_back.cur_cursor();
- if end == self.cursor.cur_cursor() {
- return None;
- }
- let prev = self.cursor_back.prev_boundary(self.string, 0).unwrap().unwrap();
- Some(&self.string[prev..end])
- }
-}
-
-#[inline]
-pub fn new_graphemes<'b>(s: &'b str, is_extended: bool) -> Graphemes<'b> {
- let len = s.len();
- Graphemes {
- string: s,
- cursor: GraphemeCursor::new(0, len, is_extended),
- cursor_back: GraphemeCursor::new(len, len, is_extended),
- }
-}
-
-#[inline]
-pub fn new_grapheme_indices<'b>(s: &'b str, is_extended: bool) -> GraphemeIndices<'b> {
- GraphemeIndices { start_offset: s.as_ptr() as usize, iter: new_graphemes(s, is_extended) }
-}
-
-// maybe unify with PairResult?
-// An enum describing information about a potential boundary.
-#[derive(PartialEq, Eq, Clone)]
-enum GraphemeState {
- // No information is known.
- Unknown,
- // It is known to not be a boundary.
- NotBreak,
- // It is known to be a boundary.
- Break,
- // The codepoint after is a Regional Indicator Symbol, so a boundary iff
- // it is preceded by an even number of RIS codepoints. (GB12, GB13)
- Regional,
- // The codepoint after is Extended_Pictographic,
- // so whether it's a boundary depends on pre-context according to GB11.
- Emoji,
-}
-
-/// Cursor-based segmenter for grapheme clusters.
-#[derive(Clone)]
-pub struct GraphemeCursor {
- // Current cursor position.
- offset: usize,
- // Total length of the string.
- len: usize,
- // A config flag indicating whether this cursor computes legacy or extended
- // grapheme cluster boundaries (enables GB9a and GB9b if set).
- is_extended: bool,
- // Information about the potential boundary at `offset`
- state: GraphemeState,
- // Category of codepoint immediately preceding cursor, if known.
- cat_before: Option<GraphemeCat>,
- // Category of codepoint immediately after cursor, if known.
- cat_after: Option<GraphemeCat>,
- // If set, at least one more codepoint immediately preceding this offset
- // is needed to resolve whether there's a boundary at `offset`.
- pre_context_offset: Option<usize>,
- // The number of RIS codepoints preceding `offset`. If `pre_context_offset`
- // is set, then counts the number of RIS between that and `offset`, otherwise
- // is an accurate count relative to the string.
- ris_count: Option<usize>,
- // Set if a call to `prev_boundary` or `next_boundary` was suspended due
- // to needing more input.
- resuming: bool,
-}
-
-/// An error return indicating that not enough content was available in the
-/// provided chunk to satisfy the query, and that more content must be provided.
-#[derive(PartialEq, Eq, Debug)]
-pub enum GraphemeIncomplete {
- /// More pre-context is needed. The caller should call `provide_context`
- /// with a chunk ending at the offset given, then retry the query. This
- /// will only be returned if the `chunk_start` parameter is nonzero.
- PreContext(usize),
-
- /// When requesting `prev_boundary`, the cursor is moving past the beginning
- /// of the current chunk, so the chunk before that is requested. This will
- /// only be returned if the `chunk_start` parameter is nonzero.
- PrevChunk,
-
- /// When requesting `next_boundary`, the cursor is moving past the end of the
- /// current chunk, so the chunk after that is requested. This will only be
- /// returned if the chunk ends before the `len` parameter provided on
- /// creation of the cursor.
- NextChunk, // requesting chunk following the one given
-
- /// An error returned when the chunk given does not contain the cursor position.
- InvalidOffset,
-}
-
-// An enum describing the result from lookup of a pair of categories.
-#[derive(PartialEq, Eq)]
-enum PairResult {
- NotBreak, // definitely not a break
- Break, // definitely a break
- Extended, // a break iff not in extended mode
- Regional, // a break if preceded by an even number of RIS
- Emoji, // a break if preceded by emoji base and (Extend)*
-}
-
-fn check_pair(before: GraphemeCat, after: GraphemeCat) -> PairResult {
- use tables::grapheme::GraphemeCat::*;
- use self::PairResult::*;
- match (before, after) {
- (GC_CR, GC_LF) => NotBreak, // GB3
- (GC_Control, _) => Break, // GB4
- (GC_CR, _) => Break, // GB4
- (GC_LF, _) => Break, // GB4
- (_, GC_Control) => Break, // GB5
- (_, GC_CR) => Break, // GB5
- (_, GC_LF) => Break, // GB5
- (GC_L, GC_L) => NotBreak, // GB6
- (GC_L, GC_V) => NotBreak, // GB6
- (GC_L, GC_LV) => NotBreak, // GB6
- (GC_L, GC_LVT) => NotBreak, // GB6
- (GC_LV, GC_V) => NotBreak, // GB7
- (GC_LV, GC_T) => NotBreak, // GB7
- (GC_V, GC_V) => NotBreak, // GB7
- (GC_V, GC_T) => NotBreak, // GB7
- (GC_LVT, GC_T) => NotBreak, // GB8
- (GC_T, GC_T) => NotBreak, // GB8
- (_, GC_Extend) => NotBreak, // GB9
- (_, GC_ZWJ) => NotBreak, // GB9
- (_, GC_SpacingMark) => Extended, // GB9a
- (GC_Prepend, _) => Extended, // GB9b
- (GC_ZWJ, GC_Extended_Pictographic) => Emoji, // GB11
- (GC_Regional_Indicator, GC_Regional_Indicator) => Regional, // GB12, GB13
- (_, _) => Break, // GB999
- }
-}
-
-impl GraphemeCursor {
- /// Create a new cursor. The string and initial offset are given at creation
- /// time, but the contents of the string are not. The `is_extended` parameter
- /// controls whether extended grapheme clusters are selected.
- ///
- /// The `offset` parameter must be on a codepoint boundary.
- ///
- /// ```rust
- /// # use unicode_segmentation::GraphemeCursor;
- /// let s = "हिन्दी";
- /// let mut legacy = GraphemeCursor::new(0, s.len(), false);
- /// assert_eq!(legacy.next_boundary(s, 0), Ok(Some("ह".len())));
- /// let mut extended = GraphemeCursor::new(0, s.len(), true);
- /// assert_eq!(extended.next_boundary(s, 0), Ok(Some("हि".len())));
- /// ```
- pub fn new(offset: usize, len: usize, is_extended: bool) -> GraphemeCursor {
- let state = if offset == 0 || offset == len {
- GraphemeState::Break
- } else {
- GraphemeState::Unknown
- };
- GraphemeCursor {
- offset: offset,
- len: len,
- state: state,
- is_extended: is_extended,
- cat_before: None,
- cat_after: None,
- pre_context_offset: None,
- ris_count: None,
- resuming: false,
- }
- }
-
- // Not sure I'm gonna keep this, the advantage over new() seems thin.
-
- /// Set the cursor to a new location in the same string.
- ///
- /// ```rust
- /// # use unicode_segmentation::GraphemeCursor;
- /// let s = "abcd";
- /// let mut cursor = GraphemeCursor::new(0, s.len(), false);
- /// assert_eq!(cursor.cur_cursor(), 0);
- /// cursor.set_cursor(2);
- /// assert_eq!(cursor.cur_cursor(), 2);
- /// ```
- pub fn set_cursor(&mut self, offset: usize) {
- if offset != self.offset {
- self.offset = offset;
- self.state = if offset == 0 || offset == self.len {
- GraphemeState::Break
- } else {
- GraphemeState::Unknown
- };
- // reset state derived from text around cursor
- self.cat_before = None;
- self.cat_after = None;
- self.ris_count = None;
- }
- }
-
- #[inline]
- /// The current offset of the cursor. Equal to the last value provided to
- /// `new()` or `set_cursor()`, or returned from `next_boundary()` or
- /// `prev_boundary()`.
- ///
- /// ```rust
- /// # use unicode_segmentation::GraphemeCursor;
- /// // Two flags (🇷🇸🇮🇴), each flag is two RIS codepoints, each RIS is 4 bytes.
- /// let flags = "\u{1F1F7}\u{1F1F8}\u{1F1EE}\u{1F1F4}";
- /// let mut cursor = GraphemeCursor::new(4, flags.len(), false);
- /// assert_eq!(cursor.cur_cursor(), 4);
- /// assert_eq!(cursor.next_boundary(flags, 0), Ok(Some(8)));
- /// assert_eq!(cursor.cur_cursor(), 8);
- /// ```
- pub fn cur_cursor(&self) -> usize {
- self.offset
- }
-
- /// Provide additional pre-context when it is needed to decide a boundary.
- /// The end of the chunk must coincide with the value given in the
- /// `GraphemeIncomplete::PreContext` request.
- ///
- /// ```rust
- /// # use unicode_segmentation::{GraphemeCursor, GraphemeIncomplete};
- /// let flags = "\u{1F1F7}\u{1F1F8}\u{1F1EE}\u{1F1F4}";
- /// let mut cursor = GraphemeCursor::new(8, flags.len(), false);
- /// // Not enough pre-context to decide if there's a boundary between the two flags.
- /// assert_eq!(cursor.is_boundary(&flags[8..], 8), Err(GraphemeIncomplete::PreContext(8)));
- /// // Provide one more Regional Indicator Symbol of pre-context
- /// cursor.provide_context(&flags[4..8], 4);
- /// // Still not enough context to decide.
- /// assert_eq!(cursor.is_boundary(&flags[8..], 8), Err(GraphemeIncomplete::PreContext(4)));
- /// // Provide additional requested context.
- /// cursor.provide_context(&flags[0..4], 0);
- /// // That's enough to decide (it always is when context goes to the start of the string)
- /// assert_eq!(cursor.is_boundary(&flags[8..], 8), Ok(true));
- /// ```
- pub fn provide_context(&mut self, chunk: &str, chunk_start: usize) {
- use tables::grapheme as gr;
- assert!(chunk_start + chunk.len() == self.pre_context_offset.unwrap());
- self.pre_context_offset = None;
- if self.is_extended && chunk_start + chunk.len() == self.offset {
- let ch = chunk.chars().rev().next().unwrap();
- if gr::grapheme_category(ch) == gr::GC_Prepend {
- self.decide(false); // GB9b
- return;
- }
- }
- match self.state {
- GraphemeState::Regional => self.handle_regional(chunk, chunk_start),
- GraphemeState::Emoji => self.handle_emoji(chunk, chunk_start),
- _ => if self.cat_before.is_none() && self.offset == chunk.len() + chunk_start {
- let ch = chunk.chars().rev().next().unwrap();
- self.cat_before = Some(gr::grapheme_category(ch));
- },
- }
- }
-
- fn decide(&mut self, is_break: bool) {
- self.state = if is_break {
- GraphemeState::Break
- } else {
- GraphemeState::NotBreak
- };
- }
-
- fn decision(&mut self, is_break: bool) -> Result<bool, GraphemeIncomplete> {
- self.decide(is_break);
- Ok(is_break)
- }
-
- fn is_boundary_result(&self) -> Result<bool, GraphemeIncomplete> {
- if self.state == GraphemeState::Break {
- Ok(true)
- } else if self.state == GraphemeState::NotBreak {
- Ok(false)
- } else if let Some(pre_context_offset) = self.pre_context_offset {
- Err(GraphemeIncomplete::PreContext(pre_context_offset))
- } else {
- unreachable!("inconsistent state");
- }
- }
-
- fn handle_regional(&mut self, chunk: &str, chunk_start: usize) {
- use tables::grapheme as gr;
- let mut ris_count = self.ris_count.unwrap_or(0);
- for ch in chunk.chars().rev() {
- if gr::grapheme_category(ch) != gr::GC_Regional_Indicator {
- self.ris_count = Some(ris_count);
- self.decide((ris_count % 2) == 0);
- return;
- }
- ris_count += 1;
- }
- self.ris_count = Some(ris_count);
- if chunk_start == 0 {
- self.decide((ris_count % 2) == 0);
- return;
- }
- self.pre_context_offset = Some(chunk_start);
- self.state = GraphemeState::Regional;
- }
-
- fn handle_emoji(&mut self, chunk: &str, chunk_start: usize) {
- use tables::grapheme as gr;
- let mut iter = chunk.chars().rev();
- if let Some(ch) = iter.next() {
- if gr::grapheme_category(ch) != gr::GC_ZWJ {
- self.decide(true);
- return;
- }
- }
- for ch in iter {
- match gr::grapheme_category(ch) {
- gr::GC_Extend => (),
- gr::GC_Extended_Pictographic => {
- self.decide(false);
- return;
- }
- _ => {
- self.decide(true);
- return;
- }
- }
- }
- if chunk_start == 0 {
- self.decide(true);
- return;
- }
- self.pre_context_offset = Some(chunk_start);
- self.state = GraphemeState::Emoji;
- }
-
- /// Determine whether the current cursor location is a grapheme cluster boundary.
- /// Only a part of the string need be supplied. If `chunk_start` is nonzero or
- /// the length of `chunk` is not equal to `len` on creation, then this method
- /// may return `GraphemeIncomplete::PreContext`. The caller should then
- /// call `provide_context` with the requested chunk, then retry calling this
- /// method.
- ///
- /// For partial chunks, if the cursor is not at the beginning or end of the
- /// string, the chunk should contain at least the codepoint following the cursor.
- /// If the string is nonempty, the chunk must be nonempty.
- ///
- /// All calls should have consistent chunk contents (ie, if a chunk provides
- /// content for a given slice, all further chunks covering that slice must have
- /// the same content for it).
- ///
- /// ```rust
- /// # use unicode_segmentation::GraphemeCursor;
- /// let flags = "\u{1F1F7}\u{1F1F8}\u{1F1EE}\u{1F1F4}";
- /// let mut cursor = GraphemeCursor::new(8, flags.len(), false);
- /// assert_eq!(cursor.is_boundary(flags, 0), Ok(true));
- /// cursor.set_cursor(12);
- /// assert_eq!(cursor.is_boundary(flags, 0), Ok(false));
- /// ```
- pub fn is_boundary(&mut self, chunk: &str, chunk_start: usize) -> Result<bool, GraphemeIncomplete> {
- use tables::grapheme as gr;
- if self.state == GraphemeState::Break {
- return Ok(true)
- }
- if self.state == GraphemeState::NotBreak {
- return Ok(false)
- }
- if self.offset < chunk_start || self.offset >= chunk_start + chunk.len() {
- if self.offset > chunk_start + chunk.len() || self.cat_after.is_none() {
- return Err(GraphemeIncomplete::InvalidOffset)
- }
- }
- if let Some(pre_context_offset) = self.pre_context_offset {
- return Err(GraphemeIncomplete::PreContext(pre_context_offset));
- }
- let offset_in_chunk = self.offset - chunk_start;
- if self.cat_after.is_none() {
- let ch = chunk[offset_in_chunk..].chars().next().unwrap();
- self.cat_after = Some(gr::grapheme_category(ch));
- }
- if self.offset == chunk_start {
- let mut need_pre_context = true;
- match self.cat_after.unwrap() {
- gr::GC_Regional_Indicator => self.state = GraphemeState::Regional,
- gr::GC_Extended_Pictographic => self.state = GraphemeState::Emoji,
- _ => need_pre_context = self.cat_before.is_none(),
- }
- if need_pre_context {
- self.pre_context_offset = Some(chunk_start);
- return Err(GraphemeIncomplete::PreContext(chunk_start));
- }
- }
- if self.cat_before.is_none() {
- let ch = chunk[..offset_in_chunk].chars().rev().next().unwrap();
- self.cat_before = Some(gr::grapheme_category(ch));
- }
- match check_pair(self.cat_before.unwrap(), self.cat_after.unwrap()) {
- PairResult::NotBreak => return self.decision(false),
- PairResult::Break => return self.decision(true),
- PairResult::Extended => {
- let is_extended = self.is_extended;
- return self.decision(!is_extended);
- }
- PairResult::Regional => {
- if let Some(ris_count) = self.ris_count {
- return self.decision((ris_count % 2) == 0);
- }
- self.handle_regional(&chunk[..offset_in_chunk], chunk_start);
- self.is_boundary_result()
- }
- PairResult::Emoji => {
- self.handle_emoji(&chunk[..offset_in_chunk], chunk_start);
- self.is_boundary_result()
- }
- }
- }
-
- /// Find the next boundary after the current cursor position. Only a part of
- /// the string need be supplied. If the chunk is incomplete, then this
- /// method might return `GraphemeIncomplete::PreContext` or
- /// `GraphemeIncomplete::NextChunk`. In the former case, the caller should
- /// call `provide_context` with the requested chunk, then retry. In the
- /// latter case, the caller should provide the chunk following the one
- /// given, then retry.
- ///
- /// See `is_boundary` for expectations on the provided chunk.
- ///
- /// ```rust
- /// # use unicode_segmentation::GraphemeCursor;
- /// let flags = "\u{1F1F7}\u{1F1F8}\u{1F1EE}\u{1F1F4}";
- /// let mut cursor = GraphemeCursor::new(4, flags.len(), false);
- /// assert_eq!(cursor.next_boundary(flags, 0), Ok(Some(8)));
- /// assert_eq!(cursor.next_boundary(flags, 0), Ok(Some(16)));
- /// assert_eq!(cursor.next_boundary(flags, 0), Ok(None));
- /// ```
- ///
- /// And an example that uses partial strings:
- ///
- /// ```rust
- /// # use unicode_segmentation::{GraphemeCursor, GraphemeIncomplete};
- /// let s = "abcd";
- /// let mut cursor = GraphemeCursor::new(0, s.len(), false);
- /// assert_eq!(cursor.next_boundary(&s[..2], 0), Ok(Some(1)));
- /// assert_eq!(cursor.next_boundary(&s[..2], 0), Err(GraphemeIncomplete::NextChunk));
- /// assert_eq!(cursor.next_boundary(&s[2..4], 2), Ok(Some(2)));
- /// assert_eq!(cursor.next_boundary(&s[2..4], 2), Ok(Some(3)));
- /// assert_eq!(cursor.next_boundary(&s[2..4], 2), Ok(Some(4)));
- /// assert_eq!(cursor.next_boundary(&s[2..4], 2), Ok(None));
- /// ```
- pub fn next_boundary(&mut self, chunk: &str, chunk_start: usize) -> Result<Option<usize>, GraphemeIncomplete> {
- use tables::grapheme as gr;
- if self.offset == self.len {
- return Ok(None);
- }
- let mut iter = chunk[self.offset - chunk_start..].chars();
- let mut ch = iter.next().unwrap();
- loop {
- if self.resuming {
- if self.cat_after.is_none() {
- self.cat_after = Some(gr::grapheme_category(ch));
- }
- } else {
- self.offset += ch.len_utf8();
- self.state = GraphemeState::Unknown;
- self.cat_before = self.cat_after.take();
- if self.cat_before.is_none() {
- self.cat_before = Some(gr::grapheme_category(ch));
- }
- if self.cat_before.unwrap() == GraphemeCat::GC_Regional_Indicator {
- self.ris_count = self.ris_count.map(|c| c + 1);
- } else {
- self.ris_count = Some(0);
- }
- if let Some(next_ch) = iter.next() {
- ch = next_ch;
- self.cat_after = Some(gr::grapheme_category(ch));
- } else if self.offset == self.len {
- self.decide(true);
- } else {
- self.resuming = true;
- return Err(GraphemeIncomplete::NextChunk);
- }
- }
- self.resuming = true;
- if self.is_boundary(chunk, chunk_start)? {
- self.resuming = false;
- return Ok(Some(self.offset));
- }
- self.resuming = false;
- }
- }
-
- /// Find the previous boundary after the current cursor position. Only a part
- /// of the string need be supplied. If the chunk is incomplete, then this
- /// method might return `GraphemeIncomplete::PreContext` or
- /// `GraphemeIncomplete::PrevChunk`. In the former case, the caller should
- /// call `provide_context` with the requested chunk, then retry. In the
- /// latter case, the caller should provide the chunk preceding the one
- /// given, then retry.
- ///
- /// See `is_boundary` for expectations on the provided chunk.
- ///
- /// ```rust
- /// # use unicode_segmentation::GraphemeCursor;
- /// let flags = "\u{1F1F7}\u{1F1F8}\u{1F1EE}\u{1F1F4}";
- /// let mut cursor = GraphemeCursor::new(12, flags.len(), false);
- /// assert_eq!(cursor.prev_boundary(flags, 0), Ok(Some(8)));
- /// assert_eq!(cursor.prev_boundary(flags, 0), Ok(Some(0)));
- /// assert_eq!(cursor.prev_boundary(flags, 0), Ok(None));
- /// ```
- ///
- /// And an example that uses partial strings (note the exact return is not
- /// guaranteed, and may be `PrevChunk` or `PreContext` arbitrarily):
- ///
- /// ```rust
- /// # use unicode_segmentation::{GraphemeCursor, GraphemeIncomplete};
- /// let s = "abcd";
- /// let mut cursor = GraphemeCursor::new(4, s.len(), false);
- /// assert_eq!(cursor.prev_boundary(&s[2..4], 2), Ok(Some(3)));
- /// assert_eq!(cursor.prev_boundary(&s[2..4], 2), Err(GraphemeIncomplete::PrevChunk));
- /// assert_eq!(cursor.prev_boundary(&s[0..2], 0), Ok(Some(2)));
- /// assert_eq!(cursor.prev_boundary(&s[0..2], 0), Ok(Some(1)));
- /// assert_eq!(cursor.prev_boundary(&s[0..2], 0), Ok(Some(0)));
- /// assert_eq!(cursor.prev_boundary(&s[0..2], 0), Ok(None));
- /// ```
- pub fn prev_boundary(&mut self, chunk: &str, chunk_start: usize) -> Result<Option<usize>, GraphemeIncomplete> {
- use tables::grapheme as gr;
- if self.offset == 0 {
- return Ok(None);
- }
- if self.offset == chunk_start {
- return Err(GraphemeIncomplete::PrevChunk);
- }
- let mut iter = chunk[..self.offset - chunk_start].chars().rev();
- let mut ch = iter.next().unwrap();
- loop {
- if self.offset == chunk_start {
- self.resuming = true;
- return Err(GraphemeIncomplete::PrevChunk);
- }
- if self.resuming {
- self.cat_before = Some(gr::grapheme_category(ch));
- } else {
- self.offset -= ch.len_utf8();
- self.cat_after = self.cat_before.take();
- self.state = GraphemeState::Unknown;
- if let Some(ris_count) = self.ris_count {
- self.ris_count = if ris_count > 0 { Some(ris_count - 1) } else { None };
- }
- if let Some(prev_ch) = iter.next() {
- ch = prev_ch;
- self.cat_before = Some(gr::grapheme_category(ch));
- } else if self.offset == 0 {
- self.decide(true);
- } else {
- self.resuming = true;
- self.cat_after = Some(gr::grapheme_category(ch));
- return Err(GraphemeIncomplete::PrevChunk);
- }
- }
- self.resuming = true;
- if self.is_boundary(chunk, chunk_start)? {
- self.resuming = false;
- return Ok(Some(self.offset));
- }
- self.resuming = false;
- }
- }
-}
-
-#[test]
-fn test_grapheme_cursor_ris_precontext() {
- let s = "\u{1f1fa}\u{1f1f8}\u{1f1fa}\u{1f1f8}\u{1f1fa}\u{1f1f8}";
- let mut c = GraphemeCursor::new(8, s.len(), true);
- assert_eq!(c.is_boundary(&s[4..], 4), Err(GraphemeIncomplete::PreContext(4)));
- c.provide_context(&s[..4], 0);
- assert_eq!(c.is_boundary(&s[4..], 4), Ok(true));
-}
-
-#[test]
-fn test_grapheme_cursor_chunk_start_require_precontext() {
- let s = "\r\n";
- let mut c = GraphemeCursor::new(1, s.len(), true);
- assert_eq!(c.is_boundary(&s[1..], 1), Err(GraphemeIncomplete::PreContext(1)));
- c.provide_context(&s[..1], 0);
- assert_eq!(c.is_boundary(&s[1..], 1), Ok(false));
-}
-
-#[test]
-fn test_grapheme_cursor_prev_boundary() {
- let s = "abcd";
- let mut c = GraphemeCursor::new(3, s.len(), true);
- assert_eq!(c.prev_boundary(&s[2..], 2), Err(GraphemeIncomplete::PrevChunk));
- assert_eq!(c.prev_boundary(&s[..2], 0), Ok(Some(2)));
-}
-
-#[test]
-fn test_grapheme_cursor_prev_boundary_chunk_start() {
- let s = "abcd";
- let mut c = GraphemeCursor::new(2, s.len(), true);
- assert_eq!(c.prev_boundary(&s[2..], 2), Err(GraphemeIncomplete::PrevChunk));
- assert_eq!(c.prev_boundary(&s[..2], 0), Ok(Some(1)));
-}
diff --git a/unicode-segmentation/src/lib.rs b/unicode-segmentation/src/lib.rs
deleted file mode 100644
index fce3c52..0000000
--- a/unicode-segmentation/src/lib.rs
+++ /dev/null
@@ -1,242 +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.
-
-//! Iterators which split strings on Grapheme Cluster, Word or Sentence boundaries, according
-//! to the [Unicode Standard Annex #29](http://www.unicode.org/reports/tr29/) rules.
-//!
-//! ```rust
-//! extern crate unicode_segmentation;
-//!
-//! use unicode_segmentation::UnicodeSegmentation;
-//!
-//! fn main() {
-//! let s = "a̐éö̲\r\n";
-//! let g = UnicodeSegmentation::graphemes(s, true).collect::<Vec<&str>>();
-//! let b: &[_] = &["a̐", "é", "ö̲", "\r\n"];
-//! assert_eq!(g, b);
-//!
-//! let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
-//! let w = s.unicode_words().collect::<Vec<&str>>();
-//! let b: &[_] = &["The", "quick", "brown", "fox", "can't", "jump", "32.3", "feet", "right"];
-//! assert_eq!(w, b);
-//!
-//! let s = "The quick (\"brown\") fox";
-//! let w = s.split_word_bounds().collect::<Vec<&str>>();
-//! let b: &[_] = &["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", "fox"];
-//! assert_eq!(w, b);
-//! }
-//! ```
-//!
-//! # no_std
-//!
-//! unicode-segmentation does not depend on libstd, so it can be used in crates
-//! with the `#![no_std]` attribute.
-//!
-//! # crates.io
-//!
-//! You can use this package in your project by adding the following
-//! to your `Cargo.toml`:
-//!
-//! ```toml
-//! [dependencies]
-//! unicode-segmentation = "1.3.0"
-//! ```
-
-#![deny(missing_docs, unsafe_code)]
-#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png",
- html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")]
-
-#![no_std]
-
-#[cfg(test)]
-#[macro_use]
-extern crate std;
-
-#[cfg(test)]
-#[macro_use]
-extern crate quickcheck;
-
-pub use grapheme::{Graphemes, GraphemeIndices};
-pub use grapheme::{GraphemeCursor, GraphemeIncomplete};
-pub use tables::UNICODE_VERSION;
-pub use word::{UWordBounds, UWordBoundIndices, UnicodeWords};
-pub use sentence::{USentenceBounds, USentenceBoundIndices, UnicodeSentences};
-
-mod grapheme;
-mod tables;
-mod word;
-mod sentence;
-
-#[cfg(test)]
-mod test;
-#[cfg(test)]
-mod testdata;
-
-/// Methods for segmenting strings according to
-/// [Unicode Standard Annex #29](http://www.unicode.org/reports/tr29/).
-pub trait UnicodeSegmentation {
- /// Returns an iterator over the [grapheme clusters][graphemes] of `self`.
- ///
- /// [graphemes]: http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
- ///
- /// If `is_extended` is true, the iterator is over the
- /// *extended grapheme clusters*;
- /// otherwise, the iterator is over the *legacy grapheme clusters*.
- /// [UAX#29](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)
- /// recommends extended grapheme cluster boundaries for general processing.
- ///
- /// # Examples
- ///
- /// ```
- /// # use self::unicode_segmentation::UnicodeSegmentation;
- /// let gr1 = UnicodeSegmentation::graphemes("a\u{310}e\u{301}o\u{308}\u{332}", true)
- /// .collect::<Vec<&str>>();
- /// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"];
- ///
- /// assert_eq!(&gr1[..], b);
- ///
- /// let gr2 = UnicodeSegmentation::graphemes("a\r\nb🇷🇺🇸🇹", true).collect::<Vec<&str>>();
- /// let b: &[_] = &["a", "\r\n", "b", "🇷🇺", "🇸🇹"];
- ///
- /// assert_eq!(&gr2[..], b);
- /// ```
- fn graphemes<'a>(&'a self, is_extended: bool) -> Graphemes<'a>;
-
- /// Returns an iterator over the grapheme clusters of `self` and their
- /// byte offsets. See `graphemes()` for more information.
- ///
- /// # Examples
- ///
- /// ```
- /// # use self::unicode_segmentation::UnicodeSegmentation;
- /// let gr_inds = UnicodeSegmentation::grapheme_indices("a̐éö̲\r\n", true)
- /// .collect::<Vec<(usize, &str)>>();
- /// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
- ///
- /// assert_eq!(&gr_inds[..], b);
- /// ```
- fn grapheme_indices<'a>(&'a self, is_extended: bool) -> GraphemeIndices<'a>;
-
- /// Returns an iterator over the words of `self`, separated on
- /// [UAX#29 word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries).
- ///
- /// Here, "words" are just those substrings which, after splitting on
- /// UAX#29 word boundaries, contain any alphanumeric characters. That is, the
- /// substring must contain at least one character with the
- /// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic)
- /// property, or with
- /// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values).
- ///
- /// # Example
- ///
- /// ```
- /// # use self::unicode_segmentation::UnicodeSegmentation;
- /// let uws = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
- /// let uw1 = uws.unicode_words().collect::<Vec<&str>>();
- /// let b: &[_] = &["The", "quick", "brown", "fox", "can't", "jump", "32.3", "feet", "right"];
- ///
- /// assert_eq!(&uw1[..], b);
- /// ```
- fn unicode_words<'a>(&'a self) -> UnicodeWords<'a>;
-
- /// Returns an iterator over substrings of `self` separated on
- /// [UAX#29 word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries).
- ///
- /// The concatenation of the substrings returned by this function is just the original string.
- ///
- /// # Example
- ///
- /// ```
- /// # use self::unicode_segmentation::UnicodeSegmentation;
- /// let swu1 = "The quick (\"brown\") fox".split_word_bounds().collect::<Vec<&str>>();
- /// let b: &[_] = &["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", "fox"];
- ///
- /// assert_eq!(&swu1[..], b);
- /// ```
- fn split_word_bounds<'a>(&'a self) -> UWordBounds<'a>;
-
- /// Returns an iterator over substrings of `self`, split on UAX#29 word boundaries,
- /// and their offsets. See `split_word_bounds()` for more information.
- ///
- /// # Example
- ///
- /// ```
- /// # use self::unicode_segmentation::UnicodeSegmentation;
- /// let swi1 = "Brr, it's 29.3°F!".split_word_bound_indices().collect::<Vec<(usize, &str)>>();
- /// let b: &[_] = &[(0, "Brr"), (3, ","), (4, " "), (5, "it's"), (9, " "), (10, "29.3"),
- /// (14, "°"), (16, "F"), (17, "!")];
- ///
- /// assert_eq!(&swi1[..], b);
- /// ```
- fn split_word_bound_indices<'a>(&'a self) -> UWordBoundIndices<'a>;
-
- /// Returns an iterator over substrings of `self` separated on
- /// [UAX#29 sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries).
- ///
- /// The concatenation of the substrings returned by this function is just the original string.
- fn unicode_sentences<'a>(&'a self) -> UnicodeSentences<'a>;
-
- /// Returns an iterator over substrings of `self` separated on
- /// [UAX#29 sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries).
- ///
- /// Here, "sentences" are just those substrings which, after splitting on
- /// UAX#29 sentence boundaries, contain any alphanumeric characters. That is, the
- /// substring must contain at least one character with the
- /// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic)
- /// property, or with
- /// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values).
- fn split_sentence_bounds<'a>(&'a self) -> USentenceBounds<'a>;
-
- /// Returns an iterator over substrings of `self`, split on UAX#29 sentence boundaries,
- /// and their offsets. See `split_sentence_bounds()` for more information.
- fn split_sentence_bound_indices<'a>(&'a self) -> USentenceBoundIndices<'a>;
-}
-
-impl UnicodeSegmentation for str {
- #[inline]
- fn graphemes(&self, is_extended: bool) -> Graphemes {
- grapheme::new_graphemes(self, is_extended)
- }
-
- #[inline]
- fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
- grapheme::new_grapheme_indices(self, is_extended)
- }
-
- #[inline]
- fn unicode_words(&self) -> UnicodeWords {
- word::new_unicode_words(self)
- }
-
- #[inline]
- fn split_word_bounds(&self) -> UWordBounds {
- word::new_word_bounds(self)
- }
-
- #[inline]
- fn split_word_bound_indices(&self) -> UWordBoundIndices {
- word::new_word_bound_indices(self)
- }
-
- #[inline]
- fn unicode_sentences(&self) -> UnicodeSentences {
- sentence::new_unicode_sentences(self)
- }
-
- #[inline]
- fn split_sentence_bounds(&self) -> USentenceBounds {
- sentence::new_sentence_bounds(self)
- }
-
- #[inline]
- fn split_sentence_bound_indices(&self) -> USentenceBoundIndices {
- sentence::new_sentence_bound_indices(self)
- }
-}
diff --git a/unicode-segmentation/src/sentence.rs b/unicode-segmentation/src/sentence.rs
deleted file mode 100644
index c16c927..0000000
--- a/unicode-segmentation/src/sentence.rs
+++ /dev/null
@@ -1,373 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use core::cmp;
-use core::iter::Filter;
-
-// All of the logic for forward iteration over sentences
-mod fwd {
- use tables::sentence::SentenceCat;
- use core::cmp;
-
- // Describe a parsed part of source string as described in this table:
- // https://unicode.org/reports/tr29/#Default_Sentence_Boundaries
- #[derive(Clone, Copy, PartialEq, Eq)]
- enum StatePart {
- Sot,
- Eot,
- Other,
- CR,
- LF,
- Sep,
- ATerm,
- UpperLower,
- ClosePlus,
- SpPlus,
- STerm
- }
-
- #[derive(Clone, PartialEq, Eq)]
- struct SentenceBreaksState(pub [StatePart; 4]);
-
- const INITIAL_STATE: SentenceBreaksState = SentenceBreaksState([
- StatePart::Sot,
- StatePart::Sot,
- StatePart::Sot,
- StatePart::Sot
- ]);
-
- #[derive(Clone)]
- pub struct SentenceBreaks<'a> {
- pub string: &'a str,
- pos: usize,
- state: SentenceBreaksState
- }
-
- impl SentenceBreaksState {
- // Attempt to advance the internal state by one part
- // Whitespace and some punctutation will be collapsed
- fn next(&self, cat: SentenceCat) -> SentenceBreaksState {
- let &SentenceBreaksState(parts) = self;
- let parts = match (parts[3], cat) {
- (StatePart::ClosePlus, SentenceCat::SC_Close) => parts,
- (StatePart::SpPlus, SentenceCat::SC_Sp) => parts,
- _ => [
- parts[1],
- parts[2],
- parts[3],
- match cat {
- SentenceCat::SC_CR => StatePart::CR,
- SentenceCat::SC_LF => StatePart::LF,
- SentenceCat::SC_Sep => StatePart::Sep,
- SentenceCat::SC_ATerm => StatePart::ATerm,
- SentenceCat::SC_Upper |
- SentenceCat::SC_Lower => StatePart::UpperLower,
- SentenceCat::SC_Close => StatePart::ClosePlus,
- SentenceCat::SC_Sp => StatePart::SpPlus,
- SentenceCat::SC_STerm => StatePart::STerm,
- _ => StatePart::Other
- }
- ]
- };
- SentenceBreaksState(parts)
- }
-
- fn end(&self) -> SentenceBreaksState {
- let &SentenceBreaksState(parts) = self;
- SentenceBreaksState([
- parts[1],
- parts[2],
- parts[3],
- StatePart::Eot
- ])
- }
-
- // Helper function to check if state head matches a single `StatePart`
- fn match1(&self, part: StatePart) -> bool {
- let &SentenceBreaksState(parts) = self;
- part == parts[3]
- }
-
- // Helper function to check if first two `StateParts` in state match
- // the given two
- fn match2(&self, part1: StatePart, part2: StatePart) -> bool {
- let &SentenceBreaksState(parts) = self;
- part1 == parts[2] && part2 == parts[3]
- }
- }
-
- // https://unicode.org/reports/tr29/#SB8
- // TODO cache this, it is currently quadratic
- fn match_sb8(state: &SentenceBreaksState, ahead: &str) -> bool {
- let &SentenceBreaksState(parts) = state;
- let mut idx = if parts[3] == StatePart::SpPlus { 2 } else { 3 };
- if parts[idx] == StatePart::ClosePlus { idx -= 1 }
-
- if parts[idx] == StatePart::ATerm {
- use tables::sentence as se;
-
- for next_char in ahead.chars() {
- //( ¬(OLetter | Upper | Lower | ParaSep | SATerm) )* Lower
- match se::sentence_category(next_char) {
- se::SC_Lower => return true,
- se::SC_OLetter |
- se::SC_Upper |
- se::SC_Sep | se::SC_CR | se::SC_LF |
- se::SC_STerm | se::SC_ATerm => return false,
- _ => continue
- }
- }
- }
-
- false
- }
-
- // https://unicode.org/reports/tr29/#SB8a
- fn match_sb8a(state: &SentenceBreaksState) -> bool {
- // SATerm Close* Sp*
- let &SentenceBreaksState(parts) = state;
- let mut idx = if parts[3] == StatePart::SpPlus { 2 } else { 3 };
- if parts[idx] == StatePart::ClosePlus { idx -= 1 }
- parts[idx] == StatePart::STerm || parts[idx] == StatePart::ATerm
- }
-
- // https://unicode.org/reports/tr29/#SB9
- fn match_sb9(state: &SentenceBreaksState) -> bool {
- // SATerm Close*
- let &SentenceBreaksState(parts) = state;
- let idx = if parts[3] == StatePart::ClosePlus { 2 } else { 3 };
- parts[idx] == StatePart::STerm || parts[idx] == StatePart::ATerm
- }
-
- // https://unicode.org/reports/tr29/#SB11
- fn match_sb11(state: &SentenceBreaksState) -> bool {
- // SATerm Close* Sp* ParaSep?
- let &SentenceBreaksState(parts) = state;
- let mut idx = match parts[3] {
- StatePart::Sep |
- StatePart::CR |
- StatePart::LF => 2,
- _ => 3
- };
-
- if parts[idx] == StatePart::SpPlus { idx -= 1 }
- if parts[idx] == StatePart::ClosePlus { idx -= 1}
-
- parts[idx] == StatePart::STerm || parts[idx] == StatePart::ATerm
- }
-
- impl<'a> Iterator for SentenceBreaks<'a> {
- // Returns the index of the character which follows a break
- type Item = usize;
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- let slen = self.string.len();
- // A sentence could be one character
- (cmp::min(slen, 2), Some(slen + 1))
- }
-
- #[inline]
- fn next(&mut self) -> Option<usize> {
- use tables::sentence as se;
-
- for next_char in self.string[self.pos..].chars() {
- let position_before = self.pos;
- let state_before = self.state.clone();
-
- let next_cat = se::sentence_category(next_char);
-
- self.pos += next_char.len_utf8();
- self.state = self.state.next(next_cat);
-
- match next_cat {
- // SB1 https://unicode.org/reports/tr29/#SB1
- _ if state_before.match1(StatePart::Sot) =>
- return Some(position_before),
-
- // SB2 is handled when inner iterator (chars) is finished
-
- // SB3 https://unicode.org/reports/tr29/#SB3
- SentenceCat::SC_LF if state_before.match1(StatePart::CR) =>
- continue,
-
- // SB4 https://unicode.org/reports/tr29/#SB4
- _ if state_before.match1(StatePart::Sep)
- || state_before.match1(StatePart::CR)
- || state_before.match1(StatePart::LF)
- => return Some(position_before),
-
- // SB5 https://unicode.org/reports/tr29/#SB5
- SentenceCat::SC_Extend |
- SentenceCat::SC_Format => self.state = state_before,
-
- // SB6 https://unicode.org/reports/tr29/#SB6
- SentenceCat::SC_Numeric if state_before.match1(StatePart::ATerm) =>
- continue,
-
- // SB7 https://unicode.org/reports/tr29/#SB7
- SentenceCat::SC_Upper if state_before.match2(StatePart::UpperLower, StatePart::ATerm) =>
- continue,
-
- // SB8 https://unicode.org/reports/tr29/#SB8
- _ if match_sb8(&state_before, &self.string[position_before..]) =>
- continue,
-
- // SB8a https://unicode.org/reports/tr29/#SB8a
- SentenceCat::SC_SContinue |
- SentenceCat::SC_STerm |
- SentenceCat::SC_ATerm if match_sb8a(&state_before) =>
- continue,
-
- // SB9 https://unicode.org/reports/tr29/#SB9
- SentenceCat::SC_Close |
- SentenceCat::SC_Sp |
- SentenceCat::SC_Sep |
- SentenceCat::SC_CR |
- SentenceCat::SC_LF if match_sb9(&state_before) =>
- continue,
-
- // SB10 https://unicode.org/reports/tr29/#SB10
- SentenceCat::SC_Sp |
- SentenceCat::SC_Sep |
- SentenceCat::SC_CR |
- SentenceCat::SC_LF if match_sb8a(&state_before) =>
- continue,
-
- // SB11 https://unicode.org/reports/tr29/#SB11
- _ if match_sb11(&state_before) =>
- return Some(position_before),
-
- // SB998 https://unicode.org/reports/tr29/#SB998
- _ => continue
- }
- }
-
- // SB2 https://unicode.org/reports/tr29/#SB2
- if self.state.match1(StatePart::Sot) {
- None
- } else if self.state.match1(StatePart::Eot) {
- None
- } else {
- self.state = self.state.end();
- Some(self.pos)
- }
- }
- }
-
- pub fn new_sentence_breaks<'a>(source: &'a str) -> SentenceBreaks<'a> {
- SentenceBreaks { string: source, pos: 0, state: INITIAL_STATE }
- }
-
-}
-
-/// An iterator over the substrings of a string which, after splitting the string on
-/// [sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries),
-/// contain any characters with the
-/// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic)
-/// property, or with
-/// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values).
-#[derive(Clone)]
-pub struct UnicodeSentences<'a> {
- inner: Filter<USentenceBounds<'a>, fn(&&str) -> bool>,
-}
-
-/// External iterator for a string's
-/// [sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries).
-#[derive(Clone)]
-pub struct USentenceBounds<'a> {
- iter: fwd::SentenceBreaks<'a>,
- sentence_start: Option<usize>
-}
-
-/// External iterator for sentence boundaries and byte offsets.
-#[derive(Clone)]
-pub struct USentenceBoundIndices<'a> {
- start_offset: usize,
- iter: USentenceBounds<'a>,
-}
-
-#[inline]
-pub fn new_sentence_bounds<'a>(source: &'a str) -> USentenceBounds<'a> {
- USentenceBounds {
- iter: fwd::new_sentence_breaks(source),
- sentence_start: None
- }
-}
-
-#[inline]
-pub fn new_sentence_bound_indices<'a>(source: &'a str) -> USentenceBoundIndices<'a> {
- USentenceBoundIndices {
- start_offset: source.as_ptr() as usize,
- iter: new_sentence_bounds(source)
- }
-}
-
-#[inline]
-pub fn new_unicode_sentences<'b>(s: &'b str) -> UnicodeSentences<'b> {
- use super::UnicodeSegmentation;
- use tables::util::is_alphanumeric;
-
- fn has_alphanumeric(s: &&str) -> bool { s.chars().any(|c| is_alphanumeric(c)) }
- let has_alphanumeric: fn(&&str) -> bool = has_alphanumeric; // coerce to fn pointer
-
- UnicodeSentences { inner: s.split_sentence_bounds().filter(has_alphanumeric) }
-}
-
-impl<'a> Iterator for UnicodeSentences<'a> {
- type Item = &'a str;
-
- #[inline]
- fn next(&mut self) -> Option<&'a str> { self.inner.next() }
-}
-
-impl<'a> Iterator for USentenceBounds<'a> {
- type Item = &'a str;
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- let (lower, upper) = self.iter.size_hint();
- (cmp::max(0, lower - 1), upper.map(|u| cmp::max(0, u - 1)))
- }
-
- #[inline]
- fn next(&mut self) -> Option<&'a str> {
- if self.sentence_start == None {
- if let Some(start_pos) = self.iter.next() {
- self.sentence_start = Some(start_pos)
- } else {
- return None
- }
- }
-
- if let Some(break_pos) = self.iter.next() {
- let start_pos = self.sentence_start.unwrap();
- let sentence = &self.iter.string[start_pos..break_pos];
- self.sentence_start = Some(break_pos);
- Some(sentence)
- } else {
- None
- }
- }
-}
-
-impl<'a> Iterator for USentenceBoundIndices<'a> {
- type Item = (usize, &'a str);
-
- #[inline]
- fn next(&mut self) -> Option<(usize, &'a str)> {
- self.iter.next().map(|s| (s.as_ptr() as usize - self.start_offset, s))
- }
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.iter.size_hint()
- }
-}
diff --git a/unicode-segmentation/src/tables.rs b/unicode-segmentation/src/tables.rs
deleted file mode 100644
index bfd7290..0000000
--- a/unicode-segmentation/src/tables.rs
+++ /dev/null
@@ -1,2523 +0,0 @@
-// Copyright 2012-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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
-
-/// The version of [Unicode](http://www.unicode.org/)
-/// that this version of unicode-segmentation is based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (12, 0, 0);
-
-pub mod util {
- #[inline]
- pub fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
- use core::cmp::Ordering::{Equal, Less, Greater};
- r.binary_search_by(|&(lo,hi)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }).is_ok()
- }
-
- #[inline]
- fn is_alphabetic(c: char) -> bool {
- match c {
- 'a' ... 'z' | 'A' ... 'Z' => true,
- c if c > '' => super::derived_property::Alphabetic(c),
- _ => false,
- }
- }
-
- #[inline]
- fn is_numeric(c: char) -> bool {
- match c {
- '0' ... '9' => true,
- c if c > '' => super::general_category::N(c),
- _ => false,
- }
- }
-
- #[inline]
- pub fn is_alphanumeric(c: char) -> bool {
- is_alphabetic(c) || is_numeric(c)
- }
-}
-
-mod general_category {
- const N_table: &'static [(char, char)] = &[
- ('\u{30}', '\u{39}'), ('\u{b2}', '\u{b3}'), ('\u{b9}', '\u{b9}'), ('\u{bc}', '\u{be}'),
- ('\u{660}', '\u{669}'), ('\u{6f0}', '\u{6f9}'), ('\u{7c0}', '\u{7c9}'), ('\u{966}',
- '\u{96f}'), ('\u{9e6}', '\u{9ef}'), ('\u{9f4}', '\u{9f9}'), ('\u{a66}', '\u{a6f}'),
- ('\u{ae6}', '\u{aef}'), ('\u{b66}', '\u{b6f}'), ('\u{b72}', '\u{b77}'), ('\u{be6}',
- '\u{bf2}'), ('\u{c66}', '\u{c6f}'), ('\u{c78}', '\u{c7e}'), ('\u{ce6}', '\u{cef}'),
- ('\u{d58}', '\u{d5e}'), ('\u{d66}', '\u{d78}'), ('\u{de6}', '\u{def}'), ('\u{e50}',
- '\u{e59}'), ('\u{ed0}', '\u{ed9}'), ('\u{f20}', '\u{f33}'), ('\u{1040}', '\u{1049}'),
- ('\u{1090}', '\u{1099}'), ('\u{1369}', '\u{137c}'), ('\u{16ee}', '\u{16f0}'), ('\u{17e0}',
- '\u{17e9}'), ('\u{17f0}', '\u{17f9}'), ('\u{1810}', '\u{1819}'), ('\u{1946}', '\u{194f}'),
- ('\u{19d0}', '\u{19da}'), ('\u{1a80}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1b50}',
- '\u{1b59}'), ('\u{1bb0}', '\u{1bb9}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c50}', '\u{1c59}'),
- ('\u{2070}', '\u{2070}'), ('\u{2074}', '\u{2079}'), ('\u{2080}', '\u{2089}'), ('\u{2150}',
- '\u{2182}'), ('\u{2185}', '\u{2189}'), ('\u{2460}', '\u{249b}'), ('\u{24ea}', '\u{24ff}'),
- ('\u{2776}', '\u{2793}'), ('\u{2cfd}', '\u{2cfd}'), ('\u{3007}', '\u{3007}'), ('\u{3021}',
- '\u{3029}'), ('\u{3038}', '\u{303a}'), ('\u{3192}', '\u{3195}'), ('\u{3220}', '\u{3229}'),
- ('\u{3248}', '\u{324f}'), ('\u{3251}', '\u{325f}'), ('\u{3280}', '\u{3289}'), ('\u{32b1}',
- '\u{32bf}'), ('\u{a620}', '\u{a629}'), ('\u{a6e6}', '\u{a6ef}'), ('\u{a830}', '\u{a835}'),
- ('\u{a8d0}', '\u{a8d9}'), ('\u{a900}', '\u{a909}'), ('\u{a9d0}', '\u{a9d9}'), ('\u{a9f0}',
- '\u{a9f9}'), ('\u{aa50}', '\u{aa59}'), ('\u{abf0}', '\u{abf9}'), ('\u{ff10}', '\u{ff19}'),
- ('\u{10107}', '\u{10133}'), ('\u{10140}', '\u{10178}'), ('\u{1018a}', '\u{1018b}'),
- ('\u{102e1}', '\u{102fb}'), ('\u{10320}', '\u{10323}'), ('\u{10341}', '\u{10341}'),
- ('\u{1034a}', '\u{1034a}'), ('\u{103d1}', '\u{103d5}'), ('\u{104a0}', '\u{104a9}'),
- ('\u{10858}', '\u{1085f}'), ('\u{10879}', '\u{1087f}'), ('\u{108a7}', '\u{108af}'),
- ('\u{108fb}', '\u{108ff}'), ('\u{10916}', '\u{1091b}'), ('\u{109bc}', '\u{109bd}'),
- ('\u{109c0}', '\u{109cf}'), ('\u{109d2}', '\u{109ff}'), ('\u{10a40}', '\u{10a48}'),
- ('\u{10a7d}', '\u{10a7e}'), ('\u{10a9d}', '\u{10a9f}'), ('\u{10aeb}', '\u{10aef}'),
- ('\u{10b58}', '\u{10b5f}'), ('\u{10b78}', '\u{10b7f}'), ('\u{10ba9}', '\u{10baf}'),
- ('\u{10cfa}', '\u{10cff}'), ('\u{10d30}', '\u{10d39}'), ('\u{10e60}', '\u{10e7e}'),
- ('\u{10f1d}', '\u{10f26}'), ('\u{10f51}', '\u{10f54}'), ('\u{11052}', '\u{1106f}'),
- ('\u{110f0}', '\u{110f9}'), ('\u{11136}', '\u{1113f}'), ('\u{111d0}', '\u{111d9}'),
- ('\u{111e1}', '\u{111f4}'), ('\u{112f0}', '\u{112f9}'), ('\u{11450}', '\u{11459}'),
- ('\u{114d0}', '\u{114d9}'), ('\u{11650}', '\u{11659}'), ('\u{116c0}', '\u{116c9}'),
- ('\u{11730}', '\u{1173b}'), ('\u{118e0}', '\u{118f2}'), ('\u{11c50}', '\u{11c6c}'),
- ('\u{11d50}', '\u{11d59}'), ('\u{11da0}', '\u{11da9}'), ('\u{11fc0}', '\u{11fd4}'),
- ('\u{12400}', '\u{1246e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16b50}', '\u{16b59}'),
- ('\u{16b5b}', '\u{16b61}'), ('\u{16e80}', '\u{16e96}'), ('\u{1d2e0}', '\u{1d2f3}'),
- ('\u{1d360}', '\u{1d378}'), ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1e140}', '\u{1e149}'),
- ('\u{1e2f0}', '\u{1e2f9}'), ('\u{1e8c7}', '\u{1e8cf}'), ('\u{1e950}', '\u{1e959}'),
- ('\u{1ec71}', '\u{1ecab}'), ('\u{1ecad}', '\u{1ecaf}'), ('\u{1ecb1}', '\u{1ecb4}'),
- ('\u{1ed01}', '\u{1ed2d}'), ('\u{1ed2f}', '\u{1ed3d}'), ('\u{1f100}', '\u{1f10c}')
- ];
-
- #[inline]
- pub fn N(c: char) -> bool {
- super::util::bsearch_range_table(c, N_table)
- }
-
-}
-
-mod derived_property {
- const Alphabetic_table: &'static [(char, char)] = &[
- ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'),
- ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'),
- ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}',
- '\u{2ee}'), ('\u{345}', '\u{345}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'),
- ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}',
- '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'),
- ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}',
- '\u{559}'), ('\u{560}', '\u{588}'), ('\u{5b0}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'),
- ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{5d0}',
- '\u{5ea}'), ('\u{5ef}', '\u{5f2}'), ('\u{610}', '\u{61a}'), ('\u{620}', '\u{657}'),
- ('\u{659}', '\u{65f}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), ('\u{6e1}',
- '\u{6e8}'), ('\u{6ed}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'),
- ('\u{710}', '\u{73f}'), ('\u{74d}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}',
- '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{817}'), ('\u{81a}', '\u{82c}'),
- ('\u{840}', '\u{858}'), ('\u{860}', '\u{86a}'), ('\u{8a0}', '\u{8b4}'), ('\u{8b6}',
- '\u{8bd}'), ('\u{8d4}', '\u{8df}'), ('\u{8e3}', '\u{8e9}'), ('\u{8f0}', '\u{93b}'),
- ('\u{93d}', '\u{94c}'), ('\u{94e}', '\u{950}'), ('\u{955}', '\u{963}'), ('\u{971}',
- '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'),
- ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bd}',
- '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9cc}'), ('\u{9ce}', '\u{9ce}'),
- ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9f0}',
- '\u{9f1}'), ('\u{9fc}', '\u{9fc}'), ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'),
- ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}',
- '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3e}', '\u{a42}'),
- ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4c}'), ('\u{a51}', '\u{a51}'), ('\u{a59}',
- '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a70}', '\u{a75}'), ('\u{a81}', '\u{a83}'),
- ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}',
- '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{ac5}'),
- ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acc}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}',
- '\u{ae3}'), ('\u{af9}', '\u{afc}'), ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'),
- ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}',
- '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b44}'), ('\u{b47}', '\u{b48}'),
- ('\u{b4b}', '\u{b4c}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}',
- '\u{b63}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'),
- ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}',
- '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'),
- ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}',
- '\u{bcc}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{c00}', '\u{c03}'),
- ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}',
- '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4c}'),
- ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c80}',
- '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'),
- ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cc4}'), ('\u{cc6}',
- '\u{cc8}'), ('\u{cca}', '\u{ccc}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'),
- ('\u{ce0}', '\u{ce3}'), ('\u{cf1}', '\u{cf2}'), ('\u{d00}', '\u{d03}'), ('\u{d05}',
- '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'),
- ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4c}'), ('\u{d4e}', '\u{d4e}'), ('\u{d54}',
- '\u{d57}'), ('\u{d5f}', '\u{d63}'), ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'),
- ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}',
- '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'),
- ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), ('\u{e40}',
- '\u{e46}'), ('\u{e4d}', '\u{e4d}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'),
- ('\u{e86}', '\u{e8a}'), ('\u{e8c}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}',
- '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'),
- ('\u{ecd}', '\u{ecd}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}',
- '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f81}'), ('\u{f88}', '\u{f97}'),
- ('\u{f99}', '\u{fbc}'), ('\u{1000}', '\u{1036}'), ('\u{1038}', '\u{1038}'), ('\u{103b}',
- '\u{103f}'), ('\u{1050}', '\u{108f}'), ('\u{109a}', '\u{109d}'), ('\u{10a0}', '\u{10c5}'),
- ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}',
- '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'),
- ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}',
- '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'),
- ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}',
- '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'),
- ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}',
- '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'),
- ('\u{170e}', '\u{1713}'), ('\u{1720}', '\u{1733}'), ('\u{1740}', '\u{1753}'), ('\u{1760}',
- '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17b3}'),
- ('\u{17b6}', '\u{17c8}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}',
- '\u{1878}'), ('\u{1880}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'),
- ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{1938}'), ('\u{1950}', '\u{196d}'), ('\u{1970}',
- '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a1b}'),
- ('\u{1a20}', '\u{1a5e}'), ('\u{1a61}', '\u{1a74}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1b00}',
- '\u{1b33}'), ('\u{1b35}', '\u{1b43}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b80}', '\u{1ba9}'),
- ('\u{1bac}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1be7}', '\u{1bf1}'), ('\u{1c00}',
- '\u{1c36}'), ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1c80}', '\u{1c88}'),
- ('\u{1c90}', '\u{1cba}'), ('\u{1cbd}', '\u{1cbf}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}',
- '\u{1cf3}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1cfa}', '\u{1cfa}'), ('\u{1d00}', '\u{1dbf}'),
- ('\u{1de7}', '\u{1df4}'), ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}',
- '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'),
- ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}',
- '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'),
- ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}',
- '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'),
- ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', '\u{2102}'), ('\u{2107}',
- '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'),
- ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}',
- '\u{212d}'), ('\u{212f}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'),
- ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{24b6}', '\u{24e9}'), ('\u{2c00}',
- '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'),
- ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}',
- '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'),
- ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}',
- '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'),
- ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', '\u{2dff}'), ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}',
- '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'),
- ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}',
- '\u{30ff}'), ('\u{3105}', '\u{312f}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'),
- ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fef}'), ('\u{a000}',
- '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'),
- ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a674}', '\u{a67b}'), ('\u{a67f}',
- '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7bf}'),
- ('\u{a7c2}', '\u{a7c6}'), ('\u{a7f7}', '\u{a805}'), ('\u{a807}', '\u{a827}'), ('\u{a840}',
- '\u{a873}'), ('\u{a880}', '\u{a8c3}'), ('\u{a8c5}', '\u{a8c5}'), ('\u{a8f2}', '\u{a8f7}'),
- ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8ff}'), ('\u{a90a}', '\u{a92a}'), ('\u{a930}',
- '\u{a952}'), ('\u{a960}', '\u{a97c}'), ('\u{a980}', '\u{a9b2}'), ('\u{a9b4}', '\u{a9bf}'),
- ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}',
- '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aabe}'),
- ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}',
- '\u{aaef}'), ('\u{aaf2}', '\u{aaf5}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'),
- ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}',
- '\u{ab5a}'), ('\u{ab5c}', '\u{ab67}'), ('\u{ab70}', '\u{abea}'), ('\u{ac00}', '\u{d7a3}'),
- ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}',
- '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'),
- ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}',
- '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'),
- ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}',
- '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'),
- ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}',
- '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}',
- '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}',
- '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}',
- '\u{10174}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}',
- '\u{1031f}'), ('\u{1032d}', '\u{1034a}'), ('\u{10350}', '\u{1037a}'), ('\u{10380}',
- '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}',
- '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{104b0}', '\u{104d3}'), ('\u{104d8}',
- '\u{104fb}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}',
- '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}',
- '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}',
- '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}',
- '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}',
- '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}',
- '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}',
- '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}',
- '\u{10a35}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}',
- '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}',
- '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}',
- '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{10d00}',
- '\u{10d27}'), ('\u{10f00}', '\u{10f1c}'), ('\u{10f27}', '\u{10f27}'), ('\u{10f30}',
- '\u{10f45}'), ('\u{10fe0}', '\u{10ff6}'), ('\u{11000}', '\u{11045}'), ('\u{11082}',
- '\u{110b8}'), ('\u{110d0}', '\u{110e8}'), ('\u{11100}', '\u{11132}'), ('\u{11144}',
- '\u{11146}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11180}',
- '\u{111bf}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{111dc}',
- '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{11234}'), ('\u{11237}',
- '\u{11237}'), ('\u{1123e}', '\u{1123e}'), ('\u{11280}', '\u{11286}'), ('\u{11288}',
- '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}',
- '\u{112a8}'), ('\u{112b0}', '\u{112e8}'), ('\u{11300}', '\u{11303}'), ('\u{11305}',
- '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}',
- '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}',
- '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134c}'), ('\u{11350}',
- '\u{11350}'), ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11400}',
- '\u{11441}'), ('\u{11443}', '\u{11445}'), ('\u{11447}', '\u{1144a}'), ('\u{1145f}',
- '\u{1145f}'), ('\u{11480}', '\u{114c1}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}',
- '\u{114c7}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115be}'), ('\u{115d8}',
- '\u{115dd}'), ('\u{11600}', '\u{1163e}'), ('\u{11640}', '\u{11640}'), ('\u{11644}',
- '\u{11644}'), ('\u{11680}', '\u{116b5}'), ('\u{116b8}', '\u{116b8}'), ('\u{11700}',
- '\u{1171a}'), ('\u{1171d}', '\u{1172a}'), ('\u{11800}', '\u{11838}'), ('\u{118a0}',
- '\u{118df}'), ('\u{118ff}', '\u{118ff}'), ('\u{119a0}', '\u{119a7}'), ('\u{119aa}',
- '\u{119d7}'), ('\u{119da}', '\u{119df}'), ('\u{119e1}', '\u{119e1}'), ('\u{119e3}',
- '\u{119e4}'), ('\u{11a00}', '\u{11a32}'), ('\u{11a35}', '\u{11a3e}'), ('\u{11a50}',
- '\u{11a97}'), ('\u{11a9d}', '\u{11a9d}'), ('\u{11ac0}', '\u{11af8}'), ('\u{11c00}',
- '\u{11c08}'), ('\u{11c0a}', '\u{11c36}'), ('\u{11c38}', '\u{11c3e}'), ('\u{11c40}',
- '\u{11c40}'), ('\u{11c72}', '\u{11c8f}'), ('\u{11c92}', '\u{11ca7}'), ('\u{11ca9}',
- '\u{11cb6}'), ('\u{11d00}', '\u{11d06}'), ('\u{11d08}', '\u{11d09}'), ('\u{11d0b}',
- '\u{11d36}'), ('\u{11d3a}', '\u{11d3a}'), ('\u{11d3c}', '\u{11d3d}'), ('\u{11d3f}',
- '\u{11d41}'), ('\u{11d43}', '\u{11d43}'), ('\u{11d46}', '\u{11d47}'), ('\u{11d60}',
- '\u{11d65}'), ('\u{11d67}', '\u{11d68}'), ('\u{11d6a}', '\u{11d8e}'), ('\u{11d90}',
- '\u{11d91}'), ('\u{11d93}', '\u{11d96}'), ('\u{11d98}', '\u{11d98}'), ('\u{11ee0}',
- '\u{11ef6}'), ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}',
- '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}',
- '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}',
- '\u{16b2f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}',
- '\u{16b8f}'), ('\u{16e40}', '\u{16e7f}'), ('\u{16f00}', '\u{16f4a}'), ('\u{16f4f}',
- '\u{16f87}'), ('\u{16f8f}', '\u{16f9f}'), ('\u{16fe0}', '\u{16fe1}'), ('\u{16fe3}',
- '\u{16fe3}'), ('\u{17000}', '\u{187f7}'), ('\u{18800}', '\u{18af2}'), ('\u{1b000}',
- '\u{1b11e}'), ('\u{1b150}', '\u{1b152}'), ('\u{1b164}', '\u{1b167}'), ('\u{1b170}',
- '\u{1b2fb}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}',
- '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9e}', '\u{1bc9e}'), ('\u{1d400}',
- '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}',
- '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}',
- '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}',
- '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}',
- '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}',
- '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}',
- '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}',
- '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}',
- '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}',
- '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e000}',
- '\u{1e006}'), ('\u{1e008}', '\u{1e018}'), ('\u{1e01b}', '\u{1e021}'), ('\u{1e023}',
- '\u{1e024}'), ('\u{1e026}', '\u{1e02a}'), ('\u{1e100}', '\u{1e12c}'), ('\u{1e137}',
- '\u{1e13d}'), ('\u{1e14e}', '\u{1e14e}'), ('\u{1e2c0}', '\u{1e2eb}'), ('\u{1e800}',
- '\u{1e8c4}'), ('\u{1e900}', '\u{1e943}'), ('\u{1e947}', '\u{1e947}'), ('\u{1e94b}',
- '\u{1e94b}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}',
- '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}',
- '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}',
- '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}',
- '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}',
- '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}',
- '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}',
- '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}',
- '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}',
- '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}',
- '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}',
- '\u{1eebb}'), ('\u{1f130}', '\u{1f149}'), ('\u{1f150}', '\u{1f169}'), ('\u{1f170}',
- '\u{1f189}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}',
- '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2ceb0}', '\u{2ebe0}'), ('\u{2f800}',
- '\u{2fa1d}')
- ];
-
- #[inline]
- pub fn Alphabetic(c: char) -> bool {
- super::util::bsearch_range_table(c, Alphabetic_table)
- }
-
-}
-
-pub mod grapheme {
- use core::result::Result::{Ok, Err};
-
- pub use self::GraphemeCat::*;
-
- #[allow(non_camel_case_types)]
- #[derive(Clone, Copy, PartialEq, Eq, Debug)]
- pub enum GraphemeCat {
- GC_Any,
- GC_CR,
- GC_Control,
- GC_Extend,
- GC_Extended_Pictographic,
- GC_L,
- GC_LF,
- GC_LV,
- GC_LVT,
- GC_Prepend,
- GC_Regional_Indicator,
- GC_SpacingMark,
- GC_T,
- GC_V,
- GC_ZWJ,
- }
-
- fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, cat) = r[idx];
- cat
- }
- Err(_) => GC_Any
- }
- }
-
- pub fn grapheme_category(c: char) -> GraphemeCat {
- bsearch_range_value_table(c, grapheme_cat_table)
- }
-
- const grapheme_cat_table: &'static [(char, char, GraphemeCat)] = &[
- ('\u{0}', '\u{9}', GC_Control), ('\u{a}', '\u{a}', GC_LF), ('\u{b}', '\u{c}', GC_Control),
- ('\u{d}', '\u{d}', GC_CR), ('\u{e}', '\u{1f}', GC_Control), ('\u{7f}', '\u{9f}',
- GC_Control), ('\u{a9}', '\u{a9}', GC_Extended_Pictographic), ('\u{ad}', '\u{ad}',
- GC_Control), ('\u{ae}', '\u{ae}', GC_Extended_Pictographic), ('\u{300}', '\u{36f}',
- GC_Extend), ('\u{483}', '\u{489}', GC_Extend), ('\u{591}', '\u{5bd}', GC_Extend),
- ('\u{5bf}', '\u{5bf}', GC_Extend), ('\u{5c1}', '\u{5c2}', GC_Extend), ('\u{5c4}', '\u{5c5}',
- GC_Extend), ('\u{5c7}', '\u{5c7}', GC_Extend), ('\u{600}', '\u{605}', GC_Prepend),
- ('\u{610}', '\u{61a}', GC_Extend), ('\u{61c}', '\u{61c}', GC_Control), ('\u{64b}',
- '\u{65f}', GC_Extend), ('\u{670}', '\u{670}', GC_Extend), ('\u{6d6}', '\u{6dc}', GC_Extend),
- ('\u{6dd}', '\u{6dd}', GC_Prepend), ('\u{6df}', '\u{6e4}', GC_Extend), ('\u{6e7}',
- '\u{6e8}', GC_Extend), ('\u{6ea}', '\u{6ed}', GC_Extend), ('\u{70f}', '\u{70f}',
- GC_Prepend), ('\u{711}', '\u{711}', GC_Extend), ('\u{730}', '\u{74a}', GC_Extend),
- ('\u{7a6}', '\u{7b0}', GC_Extend), ('\u{7eb}', '\u{7f3}', GC_Extend), ('\u{7fd}', '\u{7fd}',
- GC_Extend), ('\u{816}', '\u{819}', GC_Extend), ('\u{81b}', '\u{823}', GC_Extend),
- ('\u{825}', '\u{827}', GC_Extend), ('\u{829}', '\u{82d}', GC_Extend), ('\u{859}', '\u{85b}',
- GC_Extend), ('\u{8d3}', '\u{8e1}', GC_Extend), ('\u{8e2}', '\u{8e2}', GC_Prepend),
- ('\u{8e3}', '\u{902}', GC_Extend), ('\u{903}', '\u{903}', GC_SpacingMark), ('\u{93a}',
- '\u{93a}', GC_Extend), ('\u{93b}', '\u{93b}', GC_SpacingMark), ('\u{93c}', '\u{93c}',
- GC_Extend), ('\u{93e}', '\u{940}', GC_SpacingMark), ('\u{941}', '\u{948}', GC_Extend),
- ('\u{949}', '\u{94c}', GC_SpacingMark), ('\u{94d}', '\u{94d}', GC_Extend), ('\u{94e}',
- '\u{94f}', GC_SpacingMark), ('\u{951}', '\u{957}', GC_Extend), ('\u{962}', '\u{963}',
- GC_Extend), ('\u{981}', '\u{981}', GC_Extend), ('\u{982}', '\u{983}', GC_SpacingMark),
- ('\u{9bc}', '\u{9bc}', GC_Extend), ('\u{9be}', '\u{9be}', GC_Extend), ('\u{9bf}', '\u{9c0}',
- GC_SpacingMark), ('\u{9c1}', '\u{9c4}', GC_Extend), ('\u{9c7}', '\u{9c8}', GC_SpacingMark),
- ('\u{9cb}', '\u{9cc}', GC_SpacingMark), ('\u{9cd}', '\u{9cd}', GC_Extend), ('\u{9d7}',
- '\u{9d7}', GC_Extend), ('\u{9e2}', '\u{9e3}', GC_Extend), ('\u{9fe}', '\u{9fe}', GC_Extend),
- ('\u{a01}', '\u{a02}', GC_Extend), ('\u{a03}', '\u{a03}', GC_SpacingMark), ('\u{a3c}',
- '\u{a3c}', GC_Extend), ('\u{a3e}', '\u{a40}', GC_SpacingMark), ('\u{a41}', '\u{a42}',
- GC_Extend), ('\u{a47}', '\u{a48}', GC_Extend), ('\u{a4b}', '\u{a4d}', GC_Extend),
- ('\u{a51}', '\u{a51}', GC_Extend), ('\u{a70}', '\u{a71}', GC_Extend), ('\u{a75}', '\u{a75}',
- GC_Extend), ('\u{a81}', '\u{a82}', GC_Extend), ('\u{a83}', '\u{a83}', GC_SpacingMark),
- ('\u{abc}', '\u{abc}', GC_Extend), ('\u{abe}', '\u{ac0}', GC_SpacingMark), ('\u{ac1}',
- '\u{ac5}', GC_Extend), ('\u{ac7}', '\u{ac8}', GC_Extend), ('\u{ac9}', '\u{ac9}',
- GC_SpacingMark), ('\u{acb}', '\u{acc}', GC_SpacingMark), ('\u{acd}', '\u{acd}', GC_Extend),
- ('\u{ae2}', '\u{ae3}', GC_Extend), ('\u{afa}', '\u{aff}', GC_Extend), ('\u{b01}', '\u{b01}',
- GC_Extend), ('\u{b02}', '\u{b03}', GC_SpacingMark), ('\u{b3c}', '\u{b3c}', GC_Extend),
- ('\u{b3e}', '\u{b3f}', GC_Extend), ('\u{b40}', '\u{b40}', GC_SpacingMark), ('\u{b41}',
- '\u{b44}', GC_Extend), ('\u{b47}', '\u{b48}', GC_SpacingMark), ('\u{b4b}', '\u{b4c}',
- GC_SpacingMark), ('\u{b4d}', '\u{b4d}', GC_Extend), ('\u{b56}', '\u{b57}', GC_Extend),
- ('\u{b62}', '\u{b63}', GC_Extend), ('\u{b82}', '\u{b82}', GC_Extend), ('\u{bbe}', '\u{bbe}',
- GC_Extend), ('\u{bbf}', '\u{bbf}', GC_SpacingMark), ('\u{bc0}', '\u{bc0}', GC_Extend),
- ('\u{bc1}', '\u{bc2}', GC_SpacingMark), ('\u{bc6}', '\u{bc8}', GC_SpacingMark), ('\u{bca}',
- '\u{bcc}', GC_SpacingMark), ('\u{bcd}', '\u{bcd}', GC_Extend), ('\u{bd7}', '\u{bd7}',
- GC_Extend), ('\u{c00}', '\u{c00}', GC_Extend), ('\u{c01}', '\u{c03}', GC_SpacingMark),
- ('\u{c04}', '\u{c04}', GC_Extend), ('\u{c3e}', '\u{c40}', GC_Extend), ('\u{c41}', '\u{c44}',
- GC_SpacingMark), ('\u{c46}', '\u{c48}', GC_Extend), ('\u{c4a}', '\u{c4d}', GC_Extend),
- ('\u{c55}', '\u{c56}', GC_Extend), ('\u{c62}', '\u{c63}', GC_Extend), ('\u{c81}', '\u{c81}',
- GC_Extend), ('\u{c82}', '\u{c83}', GC_SpacingMark), ('\u{cbc}', '\u{cbc}', GC_Extend),
- ('\u{cbe}', '\u{cbe}', GC_SpacingMark), ('\u{cbf}', '\u{cbf}', GC_Extend), ('\u{cc0}',
- '\u{cc1}', GC_SpacingMark), ('\u{cc2}', '\u{cc2}', GC_Extend), ('\u{cc3}', '\u{cc4}',
- GC_SpacingMark), ('\u{cc6}', '\u{cc6}', GC_Extend), ('\u{cc7}', '\u{cc8}', GC_SpacingMark),
- ('\u{cca}', '\u{ccb}', GC_SpacingMark), ('\u{ccc}', '\u{ccd}', GC_Extend), ('\u{cd5}',
- '\u{cd6}', GC_Extend), ('\u{ce2}', '\u{ce3}', GC_Extend), ('\u{d00}', '\u{d01}', GC_Extend),
- ('\u{d02}', '\u{d03}', GC_SpacingMark), ('\u{d3b}', '\u{d3c}', GC_Extend), ('\u{d3e}',
- '\u{d3e}', GC_Extend), ('\u{d3f}', '\u{d40}', GC_SpacingMark), ('\u{d41}', '\u{d44}',
- GC_Extend), ('\u{d46}', '\u{d48}', GC_SpacingMark), ('\u{d4a}', '\u{d4c}', GC_SpacingMark),
- ('\u{d4d}', '\u{d4d}', GC_Extend), ('\u{d4e}', '\u{d4e}', GC_Prepend), ('\u{d57}',
- '\u{d57}', GC_Extend), ('\u{d62}', '\u{d63}', GC_Extend), ('\u{d82}', '\u{d83}',
- GC_SpacingMark), ('\u{dca}', '\u{dca}', GC_Extend), ('\u{dcf}', '\u{dcf}', GC_Extend),
- ('\u{dd0}', '\u{dd1}', GC_SpacingMark), ('\u{dd2}', '\u{dd4}', GC_Extend), ('\u{dd6}',
- '\u{dd6}', GC_Extend), ('\u{dd8}', '\u{dde}', GC_SpacingMark), ('\u{ddf}', '\u{ddf}',
- GC_Extend), ('\u{df2}', '\u{df3}', GC_SpacingMark), ('\u{e31}', '\u{e31}', GC_Extend),
- ('\u{e33}', '\u{e33}', GC_SpacingMark), ('\u{e34}', '\u{e3a}', GC_Extend), ('\u{e47}',
- '\u{e4e}', GC_Extend), ('\u{eb1}', '\u{eb1}', GC_Extend), ('\u{eb3}', '\u{eb3}',
- GC_SpacingMark), ('\u{eb4}', '\u{ebc}', GC_Extend), ('\u{ec8}', '\u{ecd}', GC_Extend),
- ('\u{f18}', '\u{f19}', GC_Extend), ('\u{f35}', '\u{f35}', GC_Extend), ('\u{f37}', '\u{f37}',
- GC_Extend), ('\u{f39}', '\u{f39}', GC_Extend), ('\u{f3e}', '\u{f3f}', GC_SpacingMark),
- ('\u{f71}', '\u{f7e}', GC_Extend), ('\u{f7f}', '\u{f7f}', GC_SpacingMark), ('\u{f80}',
- '\u{f84}', GC_Extend), ('\u{f86}', '\u{f87}', GC_Extend), ('\u{f8d}', '\u{f97}', GC_Extend),
- ('\u{f99}', '\u{fbc}', GC_Extend), ('\u{fc6}', '\u{fc6}', GC_Extend), ('\u{102d}',
- '\u{1030}', GC_Extend), ('\u{1031}', '\u{1031}', GC_SpacingMark), ('\u{1032}', '\u{1037}',
- GC_Extend), ('\u{1039}', '\u{103a}', GC_Extend), ('\u{103b}', '\u{103c}', GC_SpacingMark),
- ('\u{103d}', '\u{103e}', GC_Extend), ('\u{1056}', '\u{1057}', GC_SpacingMark), ('\u{1058}',
- '\u{1059}', GC_Extend), ('\u{105e}', '\u{1060}', GC_Extend), ('\u{1071}', '\u{1074}',
- GC_Extend), ('\u{1082}', '\u{1082}', GC_Extend), ('\u{1084}', '\u{1084}', GC_SpacingMark),
- ('\u{1085}', '\u{1086}', GC_Extend), ('\u{108d}', '\u{108d}', GC_Extend), ('\u{109d}',
- '\u{109d}', GC_Extend), ('\u{1100}', '\u{115f}', GC_L), ('\u{1160}', '\u{11a7}', GC_V),
- ('\u{11a8}', '\u{11ff}', GC_T), ('\u{135d}', '\u{135f}', GC_Extend), ('\u{1712}',
- '\u{1714}', GC_Extend), ('\u{1732}', '\u{1734}', GC_Extend), ('\u{1752}', '\u{1753}',
- GC_Extend), ('\u{1772}', '\u{1773}', GC_Extend), ('\u{17b4}', '\u{17b5}', GC_Extend),
- ('\u{17b6}', '\u{17b6}', GC_SpacingMark), ('\u{17b7}', '\u{17bd}', GC_Extend), ('\u{17be}',
- '\u{17c5}', GC_SpacingMark), ('\u{17c6}', '\u{17c6}', GC_Extend), ('\u{17c7}', '\u{17c8}',
- GC_SpacingMark), ('\u{17c9}', '\u{17d3}', GC_Extend), ('\u{17dd}', '\u{17dd}', GC_Extend),
- ('\u{180b}', '\u{180d}', GC_Extend), ('\u{180e}', '\u{180e}', GC_Control), ('\u{1885}',
- '\u{1886}', GC_Extend), ('\u{18a9}', '\u{18a9}', GC_Extend), ('\u{1920}', '\u{1922}',
- GC_Extend), ('\u{1923}', '\u{1926}', GC_SpacingMark), ('\u{1927}', '\u{1928}', GC_Extend),
- ('\u{1929}', '\u{192b}', GC_SpacingMark), ('\u{1930}', '\u{1931}', GC_SpacingMark),
- ('\u{1932}', '\u{1932}', GC_Extend), ('\u{1933}', '\u{1938}', GC_SpacingMark), ('\u{1939}',
- '\u{193b}', GC_Extend), ('\u{1a17}', '\u{1a18}', GC_Extend), ('\u{1a19}', '\u{1a1a}',
- GC_SpacingMark), ('\u{1a1b}', '\u{1a1b}', GC_Extend), ('\u{1a55}', '\u{1a55}',
- GC_SpacingMark), ('\u{1a56}', '\u{1a56}', GC_Extend), ('\u{1a57}', '\u{1a57}',
- GC_SpacingMark), ('\u{1a58}', '\u{1a5e}', GC_Extend), ('\u{1a60}', '\u{1a60}', GC_Extend),
- ('\u{1a62}', '\u{1a62}', GC_Extend), ('\u{1a65}', '\u{1a6c}', GC_Extend), ('\u{1a6d}',
- '\u{1a72}', GC_SpacingMark), ('\u{1a73}', '\u{1a7c}', GC_Extend), ('\u{1a7f}', '\u{1a7f}',
- GC_Extend), ('\u{1ab0}', '\u{1abe}', GC_Extend), ('\u{1b00}', '\u{1b03}', GC_Extend),
- ('\u{1b04}', '\u{1b04}', GC_SpacingMark), ('\u{1b34}', '\u{1b3a}', GC_Extend), ('\u{1b3b}',
- '\u{1b3b}', GC_SpacingMark), ('\u{1b3c}', '\u{1b3c}', GC_Extend), ('\u{1b3d}', '\u{1b41}',
- GC_SpacingMark), ('\u{1b42}', '\u{1b42}', GC_Extend), ('\u{1b43}', '\u{1b44}',
- GC_SpacingMark), ('\u{1b6b}', '\u{1b73}', GC_Extend), ('\u{1b80}', '\u{1b81}', GC_Extend),
- ('\u{1b82}', '\u{1b82}', GC_SpacingMark), ('\u{1ba1}', '\u{1ba1}', GC_SpacingMark),
- ('\u{1ba2}', '\u{1ba5}', GC_Extend), ('\u{1ba6}', '\u{1ba7}', GC_SpacingMark), ('\u{1ba8}',
- '\u{1ba9}', GC_Extend), ('\u{1baa}', '\u{1baa}', GC_SpacingMark), ('\u{1bab}', '\u{1bad}',
- GC_Extend), ('\u{1be6}', '\u{1be6}', GC_Extend), ('\u{1be7}', '\u{1be7}', GC_SpacingMark),
- ('\u{1be8}', '\u{1be9}', GC_Extend), ('\u{1bea}', '\u{1bec}', GC_SpacingMark), ('\u{1bed}',
- '\u{1bed}', GC_Extend), ('\u{1bee}', '\u{1bee}', GC_SpacingMark), ('\u{1bef}', '\u{1bf1}',
- GC_Extend), ('\u{1bf2}', '\u{1bf3}', GC_SpacingMark), ('\u{1c24}', '\u{1c2b}',
- GC_SpacingMark), ('\u{1c2c}', '\u{1c33}', GC_Extend), ('\u{1c34}', '\u{1c35}',
- GC_SpacingMark), ('\u{1c36}', '\u{1c37}', GC_Extend), ('\u{1cd0}', '\u{1cd2}', GC_Extend),
- ('\u{1cd4}', '\u{1ce0}', GC_Extend), ('\u{1ce1}', '\u{1ce1}', GC_SpacingMark), ('\u{1ce2}',
- '\u{1ce8}', GC_Extend), ('\u{1ced}', '\u{1ced}', GC_Extend), ('\u{1cf4}', '\u{1cf4}',
- GC_Extend), ('\u{1cf7}', '\u{1cf7}', GC_SpacingMark), ('\u{1cf8}', '\u{1cf9}', GC_Extend),
- ('\u{1dc0}', '\u{1df9}', GC_Extend), ('\u{1dfb}', '\u{1dff}', GC_Extend), ('\u{200b}',
- '\u{200b}', GC_Control), ('\u{200c}', '\u{200c}', GC_Extend), ('\u{200d}', '\u{200d}',
- GC_ZWJ), ('\u{200e}', '\u{200f}', GC_Control), ('\u{2028}', '\u{202e}', GC_Control),
- ('\u{203c}', '\u{203c}', GC_Extended_Pictographic), ('\u{2049}', '\u{2049}',
- GC_Extended_Pictographic), ('\u{2060}', '\u{206f}', GC_Control), ('\u{20d0}', '\u{20f0}',
- GC_Extend), ('\u{2122}', '\u{2122}', GC_Extended_Pictographic), ('\u{2139}', '\u{2139}',
- GC_Extended_Pictographic), ('\u{2194}', '\u{2199}', GC_Extended_Pictographic), ('\u{21a9}',
- '\u{21aa}', GC_Extended_Pictographic), ('\u{231a}', '\u{231b}', GC_Extended_Pictographic),
- ('\u{2328}', '\u{2328}', GC_Extended_Pictographic), ('\u{2388}', '\u{2388}',
- GC_Extended_Pictographic), ('\u{23cf}', '\u{23cf}', GC_Extended_Pictographic), ('\u{23e9}',
- '\u{23f3}', GC_Extended_Pictographic), ('\u{23f8}', '\u{23fa}', GC_Extended_Pictographic),
- ('\u{24c2}', '\u{24c2}', GC_Extended_Pictographic), ('\u{25aa}', '\u{25ab}',
- GC_Extended_Pictographic), ('\u{25b6}', '\u{25b6}', GC_Extended_Pictographic), ('\u{25c0}',
- '\u{25c0}', GC_Extended_Pictographic), ('\u{25fb}', '\u{25fe}', GC_Extended_Pictographic),
- ('\u{2600}', '\u{2605}', GC_Extended_Pictographic), ('\u{2607}', '\u{2612}',
- GC_Extended_Pictographic), ('\u{2614}', '\u{2685}', GC_Extended_Pictographic), ('\u{2690}',
- '\u{2705}', GC_Extended_Pictographic), ('\u{2708}', '\u{2712}', GC_Extended_Pictographic),
- ('\u{2714}', '\u{2714}', GC_Extended_Pictographic), ('\u{2716}', '\u{2716}',
- GC_Extended_Pictographic), ('\u{271d}', '\u{271d}', GC_Extended_Pictographic), ('\u{2721}',
- '\u{2721}', GC_Extended_Pictographic), ('\u{2728}', '\u{2728}', GC_Extended_Pictographic),
- ('\u{2733}', '\u{2734}', GC_Extended_Pictographic), ('\u{2744}', '\u{2744}',
- GC_Extended_Pictographic), ('\u{2747}', '\u{2747}', GC_Extended_Pictographic), ('\u{274c}',
- '\u{274c}', GC_Extended_Pictographic), ('\u{274e}', '\u{274e}', GC_Extended_Pictographic),
- ('\u{2753}', '\u{2755}', GC_Extended_Pictographic), ('\u{2757}', '\u{2757}',
- GC_Extended_Pictographic), ('\u{2763}', '\u{2767}', GC_Extended_Pictographic), ('\u{2795}',
- '\u{2797}', GC_Extended_Pictographic), ('\u{27a1}', '\u{27a1}', GC_Extended_Pictographic),
- ('\u{27b0}', '\u{27b0}', GC_Extended_Pictographic), ('\u{27bf}', '\u{27bf}',
- GC_Extended_Pictographic), ('\u{2934}', '\u{2935}', GC_Extended_Pictographic), ('\u{2b05}',
- '\u{2b07}', GC_Extended_Pictographic), ('\u{2b1b}', '\u{2b1c}', GC_Extended_Pictographic),
- ('\u{2b50}', '\u{2b50}', GC_Extended_Pictographic), ('\u{2b55}', '\u{2b55}',
- GC_Extended_Pictographic), ('\u{2cef}', '\u{2cf1}', GC_Extend), ('\u{2d7f}', '\u{2d7f}',
- GC_Extend), ('\u{2de0}', '\u{2dff}', GC_Extend), ('\u{302a}', '\u{302f}', GC_Extend),
- ('\u{3030}', '\u{3030}', GC_Extended_Pictographic), ('\u{303d}', '\u{303d}',
- GC_Extended_Pictographic), ('\u{3099}', '\u{309a}', GC_Extend), ('\u{3297}', '\u{3297}',
- GC_Extended_Pictographic), ('\u{3299}', '\u{3299}', GC_Extended_Pictographic), ('\u{a66f}',
- '\u{a672}', GC_Extend), ('\u{a674}', '\u{a67d}', GC_Extend), ('\u{a69e}', '\u{a69f}',
- GC_Extend), ('\u{a6f0}', '\u{a6f1}', GC_Extend), ('\u{a802}', '\u{a802}', GC_Extend),
- ('\u{a806}', '\u{a806}', GC_Extend), ('\u{a80b}', '\u{a80b}', GC_Extend), ('\u{a823}',
- '\u{a824}', GC_SpacingMark), ('\u{a825}', '\u{a826}', GC_Extend), ('\u{a827}', '\u{a827}',
- GC_SpacingMark), ('\u{a880}', '\u{a881}', GC_SpacingMark), ('\u{a8b4}', '\u{a8c3}',
- GC_SpacingMark), ('\u{a8c4}', '\u{a8c5}', GC_Extend), ('\u{a8e0}', '\u{a8f1}', GC_Extend),
- ('\u{a8ff}', '\u{a8ff}', GC_Extend), ('\u{a926}', '\u{a92d}', GC_Extend), ('\u{a947}',
- '\u{a951}', GC_Extend), ('\u{a952}', '\u{a953}', GC_SpacingMark), ('\u{a960}', '\u{a97c}',
- GC_L), ('\u{a980}', '\u{a982}', GC_Extend), ('\u{a983}', '\u{a983}', GC_SpacingMark),
- ('\u{a9b3}', '\u{a9b3}', GC_Extend), ('\u{a9b4}', '\u{a9b5}', GC_SpacingMark), ('\u{a9b6}',
- '\u{a9b9}', GC_Extend), ('\u{a9ba}', '\u{a9bb}', GC_SpacingMark), ('\u{a9bc}', '\u{a9bd}',
- GC_Extend), ('\u{a9be}', '\u{a9c0}', GC_SpacingMark), ('\u{a9e5}', '\u{a9e5}', GC_Extend),
- ('\u{aa29}', '\u{aa2e}', GC_Extend), ('\u{aa2f}', '\u{aa30}', GC_SpacingMark), ('\u{aa31}',
- '\u{aa32}', GC_Extend), ('\u{aa33}', '\u{aa34}', GC_SpacingMark), ('\u{aa35}', '\u{aa36}',
- GC_Extend), ('\u{aa43}', '\u{aa43}', GC_Extend), ('\u{aa4c}', '\u{aa4c}', GC_Extend),
- ('\u{aa4d}', '\u{aa4d}', GC_SpacingMark), ('\u{aa7c}', '\u{aa7c}', GC_Extend), ('\u{aab0}',
- '\u{aab0}', GC_Extend), ('\u{aab2}', '\u{aab4}', GC_Extend), ('\u{aab7}', '\u{aab8}',
- GC_Extend), ('\u{aabe}', '\u{aabf}', GC_Extend), ('\u{aac1}', '\u{aac1}', GC_Extend),
- ('\u{aaeb}', '\u{aaeb}', GC_SpacingMark), ('\u{aaec}', '\u{aaed}', GC_Extend), ('\u{aaee}',
- '\u{aaef}', GC_SpacingMark), ('\u{aaf5}', '\u{aaf5}', GC_SpacingMark), ('\u{aaf6}',
- '\u{aaf6}', GC_Extend), ('\u{abe3}', '\u{abe4}', GC_SpacingMark), ('\u{abe5}', '\u{abe5}',
- GC_Extend), ('\u{abe6}', '\u{abe7}', GC_SpacingMark), ('\u{abe8}', '\u{abe8}', GC_Extend),
- ('\u{abe9}', '\u{abea}', GC_SpacingMark), ('\u{abec}', '\u{abec}', GC_SpacingMark),
- ('\u{abed}', '\u{abed}', GC_Extend), ('\u{ac00}', '\u{ac00}', GC_LV), ('\u{ac01}',
- '\u{ac1b}', GC_LVT), ('\u{ac1c}', '\u{ac1c}', GC_LV), ('\u{ac1d}', '\u{ac37}', GC_LVT),
- ('\u{ac38}', '\u{ac38}', GC_LV), ('\u{ac39}', '\u{ac53}', GC_LVT), ('\u{ac54}', '\u{ac54}',
- GC_LV), ('\u{ac55}', '\u{ac6f}', GC_LVT), ('\u{ac70}', '\u{ac70}', GC_LV), ('\u{ac71}',
- '\u{ac8b}', GC_LVT), ('\u{ac8c}', '\u{ac8c}', GC_LV), ('\u{ac8d}', '\u{aca7}', GC_LVT),
- ('\u{aca8}', '\u{aca8}', GC_LV), ('\u{aca9}', '\u{acc3}', GC_LVT), ('\u{acc4}', '\u{acc4}',
- GC_LV), ('\u{acc5}', '\u{acdf}', GC_LVT), ('\u{ace0}', '\u{ace0}', GC_LV), ('\u{ace1}',
- '\u{acfb}', GC_LVT), ('\u{acfc}', '\u{acfc}', GC_LV), ('\u{acfd}', '\u{ad17}', GC_LVT),
- ('\u{ad18}', '\u{ad18}', GC_LV), ('\u{ad19}', '\u{ad33}', GC_LVT), ('\u{ad34}', '\u{ad34}',
- GC_LV), ('\u{ad35}', '\u{ad4f}', GC_LVT), ('\u{ad50}', '\u{ad50}', GC_LV), ('\u{ad51}',
- '\u{ad6b}', GC_LVT), ('\u{ad6c}', '\u{ad6c}', GC_LV), ('\u{ad6d}', '\u{ad87}', GC_LVT),
- ('\u{ad88}', '\u{ad88}', GC_LV), ('\u{ad89}', '\u{ada3}', GC_LVT), ('\u{ada4}', '\u{ada4}',
- GC_LV), ('\u{ada5}', '\u{adbf}', GC_LVT), ('\u{adc0}', '\u{adc0}', GC_LV), ('\u{adc1}',
- '\u{addb}', GC_LVT), ('\u{addc}', '\u{addc}', GC_LV), ('\u{addd}', '\u{adf7}', GC_LVT),
- ('\u{adf8}', '\u{adf8}', GC_LV), ('\u{adf9}', '\u{ae13}', GC_LVT), ('\u{ae14}', '\u{ae14}',
- GC_LV), ('\u{ae15}', '\u{ae2f}', GC_LVT), ('\u{ae30}', '\u{ae30}', GC_LV), ('\u{ae31}',
- '\u{ae4b}', GC_LVT), ('\u{ae4c}', '\u{ae4c}', GC_LV), ('\u{ae4d}', '\u{ae67}', GC_LVT),
- ('\u{ae68}', '\u{ae68}', GC_LV), ('\u{ae69}', '\u{ae83}', GC_LVT), ('\u{ae84}', '\u{ae84}',
- GC_LV), ('\u{ae85}', '\u{ae9f}', GC_LVT), ('\u{aea0}', '\u{aea0}', GC_LV), ('\u{aea1}',
- '\u{aebb}', GC_LVT), ('\u{aebc}', '\u{aebc}', GC_LV), ('\u{aebd}', '\u{aed7}', GC_LVT),
- ('\u{aed8}', '\u{aed8}', GC_LV), ('\u{aed9}', '\u{aef3}', GC_LVT), ('\u{aef4}', '\u{aef4}',
- GC_LV), ('\u{aef5}', '\u{af0f}', GC_LVT), ('\u{af10}', '\u{af10}', GC_LV), ('\u{af11}',
- '\u{af2b}', GC_LVT), ('\u{af2c}', '\u{af2c}', GC_LV), ('\u{af2d}', '\u{af47}', GC_LVT),
- ('\u{af48}', '\u{af48}', GC_LV), ('\u{af49}', '\u{af63}', GC_LVT), ('\u{af64}', '\u{af64}',
- GC_LV), ('\u{af65}', '\u{af7f}', GC_LVT), ('\u{af80}', '\u{af80}', GC_LV), ('\u{af81}',
- '\u{af9b}', GC_LVT), ('\u{af9c}', '\u{af9c}', GC_LV), ('\u{af9d}', '\u{afb7}', GC_LVT),
- ('\u{afb8}', '\u{afb8}', GC_LV), ('\u{afb9}', '\u{afd3}', GC_LVT), ('\u{afd4}', '\u{afd4}',
- GC_LV), ('\u{afd5}', '\u{afef}', GC_LVT), ('\u{aff0}', '\u{aff0}', GC_LV), ('\u{aff1}',
- '\u{b00b}', GC_LVT), ('\u{b00c}', '\u{b00c}', GC_LV), ('\u{b00d}', '\u{b027}', GC_LVT),
- ('\u{b028}', '\u{b028}', GC_LV), ('\u{b029}', '\u{b043}', GC_LVT), ('\u{b044}', '\u{b044}',
- GC_LV), ('\u{b045}', '\u{b05f}', GC_LVT), ('\u{b060}', '\u{b060}', GC_LV), ('\u{b061}',
- '\u{b07b}', GC_LVT), ('\u{b07c}', '\u{b07c}', GC_LV), ('\u{b07d}', '\u{b097}', GC_LVT),
- ('\u{b098}', '\u{b098}', GC_LV), ('\u{b099}', '\u{b0b3}', GC_LVT), ('\u{b0b4}', '\u{b0b4}',
- GC_LV), ('\u{b0b5}', '\u{b0cf}', GC_LVT), ('\u{b0d0}', '\u{b0d0}', GC_LV), ('\u{b0d1}',
- '\u{b0eb}', GC_LVT), ('\u{b0ec}', '\u{b0ec}', GC_LV), ('\u{b0ed}', '\u{b107}', GC_LVT),
- ('\u{b108}', '\u{b108}', GC_LV), ('\u{b109}', '\u{b123}', GC_LVT), ('\u{b124}', '\u{b124}',
- GC_LV), ('\u{b125}', '\u{b13f}', GC_LVT), ('\u{b140}', '\u{b140}', GC_LV), ('\u{b141}',
- '\u{b15b}', GC_LVT), ('\u{b15c}', '\u{b15c}', GC_LV), ('\u{b15d}', '\u{b177}', GC_LVT),
- ('\u{b178}', '\u{b178}', GC_LV), ('\u{b179}', '\u{b193}', GC_LVT), ('\u{b194}', '\u{b194}',
- GC_LV), ('\u{b195}', '\u{b1af}', GC_LVT), ('\u{b1b0}', '\u{b1b0}', GC_LV), ('\u{b1b1}',
- '\u{b1cb}', GC_LVT), ('\u{b1cc}', '\u{b1cc}', GC_LV), ('\u{b1cd}', '\u{b1e7}', GC_LVT),
- ('\u{b1e8}', '\u{b1e8}', GC_LV), ('\u{b1e9}', '\u{b203}', GC_LVT), ('\u{b204}', '\u{b204}',
- GC_LV), ('\u{b205}', '\u{b21f}', GC_LVT), ('\u{b220}', '\u{b220}', GC_LV), ('\u{b221}',
- '\u{b23b}', GC_LVT), ('\u{b23c}', '\u{b23c}', GC_LV), ('\u{b23d}', '\u{b257}', GC_LVT),
- ('\u{b258}', '\u{b258}', GC_LV), ('\u{b259}', '\u{b273}', GC_LVT), ('\u{b274}', '\u{b274}',
- GC_LV), ('\u{b275}', '\u{b28f}', GC_LVT), ('\u{b290}', '\u{b290}', GC_LV), ('\u{b291}',
- '\u{b2ab}', GC_LVT), ('\u{b2ac}', '\u{b2ac}', GC_LV), ('\u{b2ad}', '\u{b2c7}', GC_LVT),
- ('\u{b2c8}', '\u{b2c8}', GC_LV), ('\u{b2c9}', '\u{b2e3}', GC_LVT), ('\u{b2e4}', '\u{b2e4}',
- GC_LV), ('\u{b2e5}', '\u{b2ff}', GC_LVT), ('\u{b300}', '\u{b300}', GC_LV), ('\u{b301}',
- '\u{b31b}', GC_LVT), ('\u{b31c}', '\u{b31c}', GC_LV), ('\u{b31d}', '\u{b337}', GC_LVT),
- ('\u{b338}', '\u{b338}', GC_LV), ('\u{b339}', '\u{b353}', GC_LVT), ('\u{b354}', '\u{b354}',
- GC_LV), ('\u{b355}', '\u{b36f}', GC_LVT), ('\u{b370}', '\u{b370}', GC_LV), ('\u{b371}',
- '\u{b38b}', GC_LVT), ('\u{b38c}', '\u{b38c}', GC_LV), ('\u{b38d}', '\u{b3a7}', GC_LVT),
- ('\u{b3a8}', '\u{b3a8}', GC_LV), ('\u{b3a9}', '\u{b3c3}', GC_LVT), ('\u{b3c4}', '\u{b3c4}',
- GC_LV), ('\u{b3c5}', '\u{b3df}', GC_LVT), ('\u{b3e0}', '\u{b3e0}', GC_LV), ('\u{b3e1}',
- '\u{b3fb}', GC_LVT), ('\u{b3fc}', '\u{b3fc}', GC_LV), ('\u{b3fd}', '\u{b417}', GC_LVT),
- ('\u{b418}', '\u{b418}', GC_LV), ('\u{b419}', '\u{b433}', GC_LVT), ('\u{b434}', '\u{b434}',
- GC_LV), ('\u{b435}', '\u{b44f}', GC_LVT), ('\u{b450}', '\u{b450}', GC_LV), ('\u{b451}',
- '\u{b46b}', GC_LVT), ('\u{b46c}', '\u{b46c}', GC_LV), ('\u{b46d}', '\u{b487}', GC_LVT),
- ('\u{b488}', '\u{b488}', GC_LV), ('\u{b489}', '\u{b4a3}', GC_LVT), ('\u{b4a4}', '\u{b4a4}',
- GC_LV), ('\u{b4a5}', '\u{b4bf}', GC_LVT), ('\u{b4c0}', '\u{b4c0}', GC_LV), ('\u{b4c1}',
- '\u{b4db}', GC_LVT), ('\u{b4dc}', '\u{b4dc}', GC_LV), ('\u{b4dd}', '\u{b4f7}', GC_LVT),
- ('\u{b4f8}', '\u{b4f8}', GC_LV), ('\u{b4f9}', '\u{b513}', GC_LVT), ('\u{b514}', '\u{b514}',
- GC_LV), ('\u{b515}', '\u{b52f}', GC_LVT), ('\u{b530}', '\u{b530}', GC_LV), ('\u{b531}',
- '\u{b54b}', GC_LVT), ('\u{b54c}', '\u{b54c}', GC_LV), ('\u{b54d}', '\u{b567}', GC_LVT),
- ('\u{b568}', '\u{b568}', GC_LV), ('\u{b569}', '\u{b583}', GC_LVT), ('\u{b584}', '\u{b584}',
- GC_LV), ('\u{b585}', '\u{b59f}', GC_LVT), ('\u{b5a0}', '\u{b5a0}', GC_LV), ('\u{b5a1}',
- '\u{b5bb}', GC_LVT), ('\u{b5bc}', '\u{b5bc}', GC_LV), ('\u{b5bd}', '\u{b5d7}', GC_LVT),
- ('\u{b5d8}', '\u{b5d8}', GC_LV), ('\u{b5d9}', '\u{b5f3}', GC_LVT), ('\u{b5f4}', '\u{b5f4}',
- GC_LV), ('\u{b5f5}', '\u{b60f}', GC_LVT), ('\u{b610}', '\u{b610}', GC_LV), ('\u{b611}',
- '\u{b62b}', GC_LVT), ('\u{b62c}', '\u{b62c}', GC_LV), ('\u{b62d}', '\u{b647}', GC_LVT),
- ('\u{b648}', '\u{b648}', GC_LV), ('\u{b649}', '\u{b663}', GC_LVT), ('\u{b664}', '\u{b664}',
- GC_LV), ('\u{b665}', '\u{b67f}', GC_LVT), ('\u{b680}', '\u{b680}', GC_LV), ('\u{b681}',
- '\u{b69b}', GC_LVT), ('\u{b69c}', '\u{b69c}', GC_LV), ('\u{b69d}', '\u{b6b7}', GC_LVT),
- ('\u{b6b8}', '\u{b6b8}', GC_LV), ('\u{b6b9}', '\u{b6d3}', GC_LVT), ('\u{b6d4}', '\u{b6d4}',
- GC_LV), ('\u{b6d5}', '\u{b6ef}', GC_LVT), ('\u{b6f0}', '\u{b6f0}', GC_LV), ('\u{b6f1}',
- '\u{b70b}', GC_LVT), ('\u{b70c}', '\u{b70c}', GC_LV), ('\u{b70d}', '\u{b727}', GC_LVT),
- ('\u{b728}', '\u{b728}', GC_LV), ('\u{b729}', '\u{b743}', GC_LVT), ('\u{b744}', '\u{b744}',
- GC_LV), ('\u{b745}', '\u{b75f}', GC_LVT), ('\u{b760}', '\u{b760}', GC_LV), ('\u{b761}',
- '\u{b77b}', GC_LVT), ('\u{b77c}', '\u{b77c}', GC_LV), ('\u{b77d}', '\u{b797}', GC_LVT),
- ('\u{b798}', '\u{b798}', GC_LV), ('\u{b799}', '\u{b7b3}', GC_LVT), ('\u{b7b4}', '\u{b7b4}',
- GC_LV), ('\u{b7b5}', '\u{b7cf}', GC_LVT), ('\u{b7d0}', '\u{b7d0}', GC_LV), ('\u{b7d1}',
- '\u{b7eb}', GC_LVT), ('\u{b7ec}', '\u{b7ec}', GC_LV), ('\u{b7ed}', '\u{b807}', GC_LVT),
- ('\u{b808}', '\u{b808}', GC_LV), ('\u{b809}', '\u{b823}', GC_LVT), ('\u{b824}', '\u{b824}',
- GC_LV), ('\u{b825}', '\u{b83f}', GC_LVT), ('\u{b840}', '\u{b840}', GC_LV), ('\u{b841}',
- '\u{b85b}', GC_LVT), ('\u{b85c}', '\u{b85c}', GC_LV), ('\u{b85d}', '\u{b877}', GC_LVT),
- ('\u{b878}', '\u{b878}', GC_LV), ('\u{b879}', '\u{b893}', GC_LVT), ('\u{b894}', '\u{b894}',
- GC_LV), ('\u{b895}', '\u{b8af}', GC_LVT), ('\u{b8b0}', '\u{b8b0}', GC_LV), ('\u{b8b1}',
- '\u{b8cb}', GC_LVT), ('\u{b8cc}', '\u{b8cc}', GC_LV), ('\u{b8cd}', '\u{b8e7}', GC_LVT),
- ('\u{b8e8}', '\u{b8e8}', GC_LV), ('\u{b8e9}', '\u{b903}', GC_LVT), ('\u{b904}', '\u{b904}',
- GC_LV), ('\u{b905}', '\u{b91f}', GC_LVT), ('\u{b920}', '\u{b920}', GC_LV), ('\u{b921}',
- '\u{b93b}', GC_LVT), ('\u{b93c}', '\u{b93c}', GC_LV), ('\u{b93d}', '\u{b957}', GC_LVT),
- ('\u{b958}', '\u{b958}', GC_LV), ('\u{b959}', '\u{b973}', GC_LVT), ('\u{b974}', '\u{b974}',
- GC_LV), ('\u{b975}', '\u{b98f}', GC_LVT), ('\u{b990}', '\u{b990}', GC_LV), ('\u{b991}',
- '\u{b9ab}', GC_LVT), ('\u{b9ac}', '\u{b9ac}', GC_LV), ('\u{b9ad}', '\u{b9c7}', GC_LVT),
- ('\u{b9c8}', '\u{b9c8}', GC_LV), ('\u{b9c9}', '\u{b9e3}', GC_LVT), ('\u{b9e4}', '\u{b9e4}',
- GC_LV), ('\u{b9e5}', '\u{b9ff}', GC_LVT), ('\u{ba00}', '\u{ba00}', GC_LV), ('\u{ba01}',
- '\u{ba1b}', GC_LVT), ('\u{ba1c}', '\u{ba1c}', GC_LV), ('\u{ba1d}', '\u{ba37}', GC_LVT),
- ('\u{ba38}', '\u{ba38}', GC_LV), ('\u{ba39}', '\u{ba53}', GC_LVT), ('\u{ba54}', '\u{ba54}',
- GC_LV), ('\u{ba55}', '\u{ba6f}', GC_LVT), ('\u{ba70}', '\u{ba70}', GC_LV), ('\u{ba71}',
- '\u{ba8b}', GC_LVT), ('\u{ba8c}', '\u{ba8c}', GC_LV), ('\u{ba8d}', '\u{baa7}', GC_LVT),
- ('\u{baa8}', '\u{baa8}', GC_LV), ('\u{baa9}', '\u{bac3}', GC_LVT), ('\u{bac4}', '\u{bac4}',
- GC_LV), ('\u{bac5}', '\u{badf}', GC_LVT), ('\u{bae0}', '\u{bae0}', GC_LV), ('\u{bae1}',
- '\u{bafb}', GC_LVT), ('\u{bafc}', '\u{bafc}', GC_LV), ('\u{bafd}', '\u{bb17}', GC_LVT),
- ('\u{bb18}', '\u{bb18}', GC_LV), ('\u{bb19}', '\u{bb33}', GC_LVT), ('\u{bb34}', '\u{bb34}',
- GC_LV), ('\u{bb35}', '\u{bb4f}', GC_LVT), ('\u{bb50}', '\u{bb50}', GC_LV), ('\u{bb51}',
- '\u{bb6b}', GC_LVT), ('\u{bb6c}', '\u{bb6c}', GC_LV), ('\u{bb6d}', '\u{bb87}', GC_LVT),
- ('\u{bb88}', '\u{bb88}', GC_LV), ('\u{bb89}', '\u{bba3}', GC_LVT), ('\u{bba4}', '\u{bba4}',
- GC_LV), ('\u{bba5}', '\u{bbbf}', GC_LVT), ('\u{bbc0}', '\u{bbc0}', GC_LV), ('\u{bbc1}',
- '\u{bbdb}', GC_LVT), ('\u{bbdc}', '\u{bbdc}', GC_LV), ('\u{bbdd}', '\u{bbf7}', GC_LVT),
- ('\u{bbf8}', '\u{bbf8}', GC_LV), ('\u{bbf9}', '\u{bc13}', GC_LVT), ('\u{bc14}', '\u{bc14}',
- GC_LV), ('\u{bc15}', '\u{bc2f}', GC_LVT), ('\u{bc30}', '\u{bc30}', GC_LV), ('\u{bc31}',
- '\u{bc4b}', GC_LVT), ('\u{bc4c}', '\u{bc4c}', GC_LV), ('\u{bc4d}', '\u{bc67}', GC_LVT),
- ('\u{bc68}', '\u{bc68}', GC_LV), ('\u{bc69}', '\u{bc83}', GC_LVT), ('\u{bc84}', '\u{bc84}',
- GC_LV), ('\u{bc85}', '\u{bc9f}', GC_LVT), ('\u{bca0}', '\u{bca0}', GC_LV), ('\u{bca1}',
- '\u{bcbb}', GC_LVT), ('\u{bcbc}', '\u{bcbc}', GC_LV), ('\u{bcbd}', '\u{bcd7}', GC_LVT),
- ('\u{bcd8}', '\u{bcd8}', GC_LV), ('\u{bcd9}', '\u{bcf3}', GC_LVT), ('\u{bcf4}', '\u{bcf4}',
- GC_LV), ('\u{bcf5}', '\u{bd0f}', GC_LVT), ('\u{bd10}', '\u{bd10}', GC_LV), ('\u{bd11}',
- '\u{bd2b}', GC_LVT), ('\u{bd2c}', '\u{bd2c}', GC_LV), ('\u{bd2d}', '\u{bd47}', GC_LVT),
- ('\u{bd48}', '\u{bd48}', GC_LV), ('\u{bd49}', '\u{bd63}', GC_LVT), ('\u{bd64}', '\u{bd64}',
- GC_LV), ('\u{bd65}', '\u{bd7f}', GC_LVT), ('\u{bd80}', '\u{bd80}', GC_LV), ('\u{bd81}',
- '\u{bd9b}', GC_LVT), ('\u{bd9c}', '\u{bd9c}', GC_LV), ('\u{bd9d}', '\u{bdb7}', GC_LVT),
- ('\u{bdb8}', '\u{bdb8}', GC_LV), ('\u{bdb9}', '\u{bdd3}', GC_LVT), ('\u{bdd4}', '\u{bdd4}',
- GC_LV), ('\u{bdd5}', '\u{bdef}', GC_LVT), ('\u{bdf0}', '\u{bdf0}', GC_LV), ('\u{bdf1}',
- '\u{be0b}', GC_LVT), ('\u{be0c}', '\u{be0c}', GC_LV), ('\u{be0d}', '\u{be27}', GC_LVT),
- ('\u{be28}', '\u{be28}', GC_LV), ('\u{be29}', '\u{be43}', GC_LVT), ('\u{be44}', '\u{be44}',
- GC_LV), ('\u{be45}', '\u{be5f}', GC_LVT), ('\u{be60}', '\u{be60}', GC_LV), ('\u{be61}',
- '\u{be7b}', GC_LVT), ('\u{be7c}', '\u{be7c}', GC_LV), ('\u{be7d}', '\u{be97}', GC_LVT),
- ('\u{be98}', '\u{be98}', GC_LV), ('\u{be99}', '\u{beb3}', GC_LVT), ('\u{beb4}', '\u{beb4}',
- GC_LV), ('\u{beb5}', '\u{becf}', GC_LVT), ('\u{bed0}', '\u{bed0}', GC_LV), ('\u{bed1}',
- '\u{beeb}', GC_LVT), ('\u{beec}', '\u{beec}', GC_LV), ('\u{beed}', '\u{bf07}', GC_LVT),
- ('\u{bf08}', '\u{bf08}', GC_LV), ('\u{bf09}', '\u{bf23}', GC_LVT), ('\u{bf24}', '\u{bf24}',
- GC_LV), ('\u{bf25}', '\u{bf3f}', GC_LVT), ('\u{bf40}', '\u{bf40}', GC_LV), ('\u{bf41}',
- '\u{bf5b}', GC_LVT), ('\u{bf5c}', '\u{bf5c}', GC_LV), ('\u{bf5d}', '\u{bf77}', GC_LVT),
- ('\u{bf78}', '\u{bf78}', GC_LV), ('\u{bf79}', '\u{bf93}', GC_LVT), ('\u{bf94}', '\u{bf94}',
- GC_LV), ('\u{bf95}', '\u{bfaf}', GC_LVT), ('\u{bfb0}', '\u{bfb0}', GC_LV), ('\u{bfb1}',
- '\u{bfcb}', GC_LVT), ('\u{bfcc}', '\u{bfcc}', GC_LV), ('\u{bfcd}', '\u{bfe7}', GC_LVT),
- ('\u{bfe8}', '\u{bfe8}', GC_LV), ('\u{bfe9}', '\u{c003}', GC_LVT), ('\u{c004}', '\u{c004}',
- GC_LV), ('\u{c005}', '\u{c01f}', GC_LVT), ('\u{c020}', '\u{c020}', GC_LV), ('\u{c021}',
- '\u{c03b}', GC_LVT), ('\u{c03c}', '\u{c03c}', GC_LV), ('\u{c03d}', '\u{c057}', GC_LVT),
- ('\u{c058}', '\u{c058}', GC_LV), ('\u{c059}', '\u{c073}', GC_LVT), ('\u{c074}', '\u{c074}',
- GC_LV), ('\u{c075}', '\u{c08f}', GC_LVT), ('\u{c090}', '\u{c090}', GC_LV), ('\u{c091}',
- '\u{c0ab}', GC_LVT), ('\u{c0ac}', '\u{c0ac}', GC_LV), ('\u{c0ad}', '\u{c0c7}', GC_LVT),
- ('\u{c0c8}', '\u{c0c8}', GC_LV), ('\u{c0c9}', '\u{c0e3}', GC_LVT), ('\u{c0e4}', '\u{c0e4}',
- GC_LV), ('\u{c0e5}', '\u{c0ff}', GC_LVT), ('\u{c100}', '\u{c100}', GC_LV), ('\u{c101}',
- '\u{c11b}', GC_LVT), ('\u{c11c}', '\u{c11c}', GC_LV), ('\u{c11d}', '\u{c137}', GC_LVT),
- ('\u{c138}', '\u{c138}', GC_LV), ('\u{c139}', '\u{c153}', GC_LVT), ('\u{c154}', '\u{c154}',
- GC_LV), ('\u{c155}', '\u{c16f}', GC_LVT), ('\u{c170}', '\u{c170}', GC_LV), ('\u{c171}',
- '\u{c18b}', GC_LVT), ('\u{c18c}', '\u{c18c}', GC_LV), ('\u{c18d}', '\u{c1a7}', GC_LVT),
- ('\u{c1a8}', '\u{c1a8}', GC_LV), ('\u{c1a9}', '\u{c1c3}', GC_LVT), ('\u{c1c4}', '\u{c1c4}',
- GC_LV), ('\u{c1c5}', '\u{c1df}', GC_LVT), ('\u{c1e0}', '\u{c1e0}', GC_LV), ('\u{c1e1}',
- '\u{c1fb}', GC_LVT), ('\u{c1fc}', '\u{c1fc}', GC_LV), ('\u{c1fd}', '\u{c217}', GC_LVT),
- ('\u{c218}', '\u{c218}', GC_LV), ('\u{c219}', '\u{c233}', GC_LVT), ('\u{c234}', '\u{c234}',
- GC_LV), ('\u{c235}', '\u{c24f}', GC_LVT), ('\u{c250}', '\u{c250}', GC_LV), ('\u{c251}',
- '\u{c26b}', GC_LVT), ('\u{c26c}', '\u{c26c}', GC_LV), ('\u{c26d}', '\u{c287}', GC_LVT),
- ('\u{c288}', '\u{c288}', GC_LV), ('\u{c289}', '\u{c2a3}', GC_LVT), ('\u{c2a4}', '\u{c2a4}',
- GC_LV), ('\u{c2a5}', '\u{c2bf}', GC_LVT), ('\u{c2c0}', '\u{c2c0}', GC_LV), ('\u{c2c1}',
- '\u{c2db}', GC_LVT), ('\u{c2dc}', '\u{c2dc}', GC_LV), ('\u{c2dd}', '\u{c2f7}', GC_LVT),
- ('\u{c2f8}', '\u{c2f8}', GC_LV), ('\u{c2f9}', '\u{c313}', GC_LVT), ('\u{c314}', '\u{c314}',
- GC_LV), ('\u{c315}', '\u{c32f}', GC_LVT), ('\u{c330}', '\u{c330}', GC_LV), ('\u{c331}',
- '\u{c34b}', GC_LVT), ('\u{c34c}', '\u{c34c}', GC_LV), ('\u{c34d}', '\u{c367}', GC_LVT),
- ('\u{c368}', '\u{c368}', GC_LV), ('\u{c369}', '\u{c383}', GC_LVT), ('\u{c384}', '\u{c384}',
- GC_LV), ('\u{c385}', '\u{c39f}', GC_LVT), ('\u{c3a0}', '\u{c3a0}', GC_LV), ('\u{c3a1}',
- '\u{c3bb}', GC_LVT), ('\u{c3bc}', '\u{c3bc}', GC_LV), ('\u{c3bd}', '\u{c3d7}', GC_LVT),
- ('\u{c3d8}', '\u{c3d8}', GC_LV), ('\u{c3d9}', '\u{c3f3}', GC_LVT), ('\u{c3f4}', '\u{c3f4}',
- GC_LV), ('\u{c3f5}', '\u{c40f}', GC_LVT), ('\u{c410}', '\u{c410}', GC_LV), ('\u{c411}',
- '\u{c42b}', GC_LVT), ('\u{c42c}', '\u{c42c}', GC_LV), ('\u{c42d}', '\u{c447}', GC_LVT),
- ('\u{c448}', '\u{c448}', GC_LV), ('\u{c449}', '\u{c463}', GC_LVT), ('\u{c464}', '\u{c464}',
- GC_LV), ('\u{c465}', '\u{c47f}', GC_LVT), ('\u{c480}', '\u{c480}', GC_LV), ('\u{c481}',
- '\u{c49b}', GC_LVT), ('\u{c49c}', '\u{c49c}', GC_LV), ('\u{c49d}', '\u{c4b7}', GC_LVT),
- ('\u{c4b8}', '\u{c4b8}', GC_LV), ('\u{c4b9}', '\u{c4d3}', GC_LVT), ('\u{c4d4}', '\u{c4d4}',
- GC_LV), ('\u{c4d5}', '\u{c4ef}', GC_LVT), ('\u{c4f0}', '\u{c4f0}', GC_LV), ('\u{c4f1}',
- '\u{c50b}', GC_LVT), ('\u{c50c}', '\u{c50c}', GC_LV), ('\u{c50d}', '\u{c527}', GC_LVT),
- ('\u{c528}', '\u{c528}', GC_LV), ('\u{c529}', '\u{c543}', GC_LVT), ('\u{c544}', '\u{c544}',
- GC_LV), ('\u{c545}', '\u{c55f}', GC_LVT), ('\u{c560}', '\u{c560}', GC_LV), ('\u{c561}',
- '\u{c57b}', GC_LVT), ('\u{c57c}', '\u{c57c}', GC_LV), ('\u{c57d}', '\u{c597}', GC_LVT),
- ('\u{c598}', '\u{c598}', GC_LV), ('\u{c599}', '\u{c5b3}', GC_LVT), ('\u{c5b4}', '\u{c5b4}',
- GC_LV), ('\u{c5b5}', '\u{c5cf}', GC_LVT), ('\u{c5d0}', '\u{c5d0}', GC_LV), ('\u{c5d1}',
- '\u{c5eb}', GC_LVT), ('\u{c5ec}', '\u{c5ec}', GC_LV), ('\u{c5ed}', '\u{c607}', GC_LVT),
- ('\u{c608}', '\u{c608}', GC_LV), ('\u{c609}', '\u{c623}', GC_LVT), ('\u{c624}', '\u{c624}',
- GC_LV), ('\u{c625}', '\u{c63f}', GC_LVT), ('\u{c640}', '\u{c640}', GC_LV), ('\u{c641}',
- '\u{c65b}', GC_LVT), ('\u{c65c}', '\u{c65c}', GC_LV), ('\u{c65d}', '\u{c677}', GC_LVT),
- ('\u{c678}', '\u{c678}', GC_LV), ('\u{c679}', '\u{c693}', GC_LVT), ('\u{c694}', '\u{c694}',
- GC_LV), ('\u{c695}', '\u{c6af}', GC_LVT), ('\u{c6b0}', '\u{c6b0}', GC_LV), ('\u{c6b1}',
- '\u{c6cb}', GC_LVT), ('\u{c6cc}', '\u{c6cc}', GC_LV), ('\u{c6cd}', '\u{c6e7}', GC_LVT),
- ('\u{c6e8}', '\u{c6e8}', GC_LV), ('\u{c6e9}', '\u{c703}', GC_LVT), ('\u{c704}', '\u{c704}',
- GC_LV), ('\u{c705}', '\u{c71f}', GC_LVT), ('\u{c720}', '\u{c720}', GC_LV), ('\u{c721}',
- '\u{c73b}', GC_LVT), ('\u{c73c}', '\u{c73c}', GC_LV), ('\u{c73d}', '\u{c757}', GC_LVT),
- ('\u{c758}', '\u{c758}', GC_LV), ('\u{c759}', '\u{c773}', GC_LVT), ('\u{c774}', '\u{c774}',
- GC_LV), ('\u{c775}', '\u{c78f}', GC_LVT), ('\u{c790}', '\u{c790}', GC_LV), ('\u{c791}',
- '\u{c7ab}', GC_LVT), ('\u{c7ac}', '\u{c7ac}', GC_LV), ('\u{c7ad}', '\u{c7c7}', GC_LVT),
- ('\u{c7c8}', '\u{c7c8}', GC_LV), ('\u{c7c9}', '\u{c7e3}', GC_LVT), ('\u{c7e4}', '\u{c7e4}',
- GC_LV), ('\u{c7e5}', '\u{c7ff}', GC_LVT), ('\u{c800}', '\u{c800}', GC_LV), ('\u{c801}',
- '\u{c81b}', GC_LVT), ('\u{c81c}', '\u{c81c}', GC_LV), ('\u{c81d}', '\u{c837}', GC_LVT),
- ('\u{c838}', '\u{c838}', GC_LV), ('\u{c839}', '\u{c853}', GC_LVT), ('\u{c854}', '\u{c854}',
- GC_LV), ('\u{c855}', '\u{c86f}', GC_LVT), ('\u{c870}', '\u{c870}', GC_LV), ('\u{c871}',
- '\u{c88b}', GC_LVT), ('\u{c88c}', '\u{c88c}', GC_LV), ('\u{c88d}', '\u{c8a7}', GC_LVT),
- ('\u{c8a8}', '\u{c8a8}', GC_LV), ('\u{c8a9}', '\u{c8c3}', GC_LVT), ('\u{c8c4}', '\u{c8c4}',
- GC_LV), ('\u{c8c5}', '\u{c8df}', GC_LVT), ('\u{c8e0}', '\u{c8e0}', GC_LV), ('\u{c8e1}',
- '\u{c8fb}', GC_LVT), ('\u{c8fc}', '\u{c8fc}', GC_LV), ('\u{c8fd}', '\u{c917}', GC_LVT),
- ('\u{c918}', '\u{c918}', GC_LV), ('\u{c919}', '\u{c933}', GC_LVT), ('\u{c934}', '\u{c934}',
- GC_LV), ('\u{c935}', '\u{c94f}', GC_LVT), ('\u{c950}', '\u{c950}', GC_LV), ('\u{c951}',
- '\u{c96b}', GC_LVT), ('\u{c96c}', '\u{c96c}', GC_LV), ('\u{c96d}', '\u{c987}', GC_LVT),
- ('\u{c988}', '\u{c988}', GC_LV), ('\u{c989}', '\u{c9a3}', GC_LVT), ('\u{c9a4}', '\u{c9a4}',
- GC_LV), ('\u{c9a5}', '\u{c9bf}', GC_LVT), ('\u{c9c0}', '\u{c9c0}', GC_LV), ('\u{c9c1}',
- '\u{c9db}', GC_LVT), ('\u{c9dc}', '\u{c9dc}', GC_LV), ('\u{c9dd}', '\u{c9f7}', GC_LVT),
- ('\u{c9f8}', '\u{c9f8}', GC_LV), ('\u{c9f9}', '\u{ca13}', GC_LVT), ('\u{ca14}', '\u{ca14}',
- GC_LV), ('\u{ca15}', '\u{ca2f}', GC_LVT), ('\u{ca30}', '\u{ca30}', GC_LV), ('\u{ca31}',
- '\u{ca4b}', GC_LVT), ('\u{ca4c}', '\u{ca4c}', GC_LV), ('\u{ca4d}', '\u{ca67}', GC_LVT),
- ('\u{ca68}', '\u{ca68}', GC_LV), ('\u{ca69}', '\u{ca83}', GC_LVT), ('\u{ca84}', '\u{ca84}',
- GC_LV), ('\u{ca85}', '\u{ca9f}', GC_LVT), ('\u{caa0}', '\u{caa0}', GC_LV), ('\u{caa1}',
- '\u{cabb}', GC_LVT), ('\u{cabc}', '\u{cabc}', GC_LV), ('\u{cabd}', '\u{cad7}', GC_LVT),
- ('\u{cad8}', '\u{cad8}', GC_LV), ('\u{cad9}', '\u{caf3}', GC_LVT), ('\u{caf4}', '\u{caf4}',
- GC_LV), ('\u{caf5}', '\u{cb0f}', GC_LVT), ('\u{cb10}', '\u{cb10}', GC_LV), ('\u{cb11}',
- '\u{cb2b}', GC_LVT), ('\u{cb2c}', '\u{cb2c}', GC_LV), ('\u{cb2d}', '\u{cb47}', GC_LVT),
- ('\u{cb48}', '\u{cb48}', GC_LV), ('\u{cb49}', '\u{cb63}', GC_LVT), ('\u{cb64}', '\u{cb64}',
- GC_LV), ('\u{cb65}', '\u{cb7f}', GC_LVT), ('\u{cb80}', '\u{cb80}', GC_LV), ('\u{cb81}',
- '\u{cb9b}', GC_LVT), ('\u{cb9c}', '\u{cb9c}', GC_LV), ('\u{cb9d}', '\u{cbb7}', GC_LVT),
- ('\u{cbb8}', '\u{cbb8}', GC_LV), ('\u{cbb9}', '\u{cbd3}', GC_LVT), ('\u{cbd4}', '\u{cbd4}',
- GC_LV), ('\u{cbd5}', '\u{cbef}', GC_LVT), ('\u{cbf0}', '\u{cbf0}', GC_LV), ('\u{cbf1}',
- '\u{cc0b}', GC_LVT), ('\u{cc0c}', '\u{cc0c}', GC_LV), ('\u{cc0d}', '\u{cc27}', GC_LVT),
- ('\u{cc28}', '\u{cc28}', GC_LV), ('\u{cc29}', '\u{cc43}', GC_LVT), ('\u{cc44}', '\u{cc44}',
- GC_LV), ('\u{cc45}', '\u{cc5f}', GC_LVT), ('\u{cc60}', '\u{cc60}', GC_LV), ('\u{cc61}',
- '\u{cc7b}', GC_LVT), ('\u{cc7c}', '\u{cc7c}', GC_LV), ('\u{cc7d}', '\u{cc97}', GC_LVT),
- ('\u{cc98}', '\u{cc98}', GC_LV), ('\u{cc99}', '\u{ccb3}', GC_LVT), ('\u{ccb4}', '\u{ccb4}',
- GC_LV), ('\u{ccb5}', '\u{cccf}', GC_LVT), ('\u{ccd0}', '\u{ccd0}', GC_LV), ('\u{ccd1}',
- '\u{cceb}', GC_LVT), ('\u{ccec}', '\u{ccec}', GC_LV), ('\u{cced}', '\u{cd07}', GC_LVT),
- ('\u{cd08}', '\u{cd08}', GC_LV), ('\u{cd09}', '\u{cd23}', GC_LVT), ('\u{cd24}', '\u{cd24}',
- GC_LV), ('\u{cd25}', '\u{cd3f}', GC_LVT), ('\u{cd40}', '\u{cd40}', GC_LV), ('\u{cd41}',
- '\u{cd5b}', GC_LVT), ('\u{cd5c}', '\u{cd5c}', GC_LV), ('\u{cd5d}', '\u{cd77}', GC_LVT),
- ('\u{cd78}', '\u{cd78}', GC_LV), ('\u{cd79}', '\u{cd93}', GC_LVT), ('\u{cd94}', '\u{cd94}',
- GC_LV), ('\u{cd95}', '\u{cdaf}', GC_LVT), ('\u{cdb0}', '\u{cdb0}', GC_LV), ('\u{cdb1}',
- '\u{cdcb}', GC_LVT), ('\u{cdcc}', '\u{cdcc}', GC_LV), ('\u{cdcd}', '\u{cde7}', GC_LVT),
- ('\u{cde8}', '\u{cde8}', GC_LV), ('\u{cde9}', '\u{ce03}', GC_LVT), ('\u{ce04}', '\u{ce04}',
- GC_LV), ('\u{ce05}', '\u{ce1f}', GC_LVT), ('\u{ce20}', '\u{ce20}', GC_LV), ('\u{ce21}',
- '\u{ce3b}', GC_LVT), ('\u{ce3c}', '\u{ce3c}', GC_LV), ('\u{ce3d}', '\u{ce57}', GC_LVT),
- ('\u{ce58}', '\u{ce58}', GC_LV), ('\u{ce59}', '\u{ce73}', GC_LVT), ('\u{ce74}', '\u{ce74}',
- GC_LV), ('\u{ce75}', '\u{ce8f}', GC_LVT), ('\u{ce90}', '\u{ce90}', GC_LV), ('\u{ce91}',
- '\u{ceab}', GC_LVT), ('\u{ceac}', '\u{ceac}', GC_LV), ('\u{cead}', '\u{cec7}', GC_LVT),
- ('\u{cec8}', '\u{cec8}', GC_LV), ('\u{cec9}', '\u{cee3}', GC_LVT), ('\u{cee4}', '\u{cee4}',
- GC_LV), ('\u{cee5}', '\u{ceff}', GC_LVT), ('\u{cf00}', '\u{cf00}', GC_LV), ('\u{cf01}',
- '\u{cf1b}', GC_LVT), ('\u{cf1c}', '\u{cf1c}', GC_LV), ('\u{cf1d}', '\u{cf37}', GC_LVT),
- ('\u{cf38}', '\u{cf38}', GC_LV), ('\u{cf39}', '\u{cf53}', GC_LVT), ('\u{cf54}', '\u{cf54}',
- GC_LV), ('\u{cf55}', '\u{cf6f}', GC_LVT), ('\u{cf70}', '\u{cf70}', GC_LV), ('\u{cf71}',
- '\u{cf8b}', GC_LVT), ('\u{cf8c}', '\u{cf8c}', GC_LV), ('\u{cf8d}', '\u{cfa7}', GC_LVT),
- ('\u{cfa8}', '\u{cfa8}', GC_LV), ('\u{cfa9}', '\u{cfc3}', GC_LVT), ('\u{cfc4}', '\u{cfc4}',
- GC_LV), ('\u{cfc5}', '\u{cfdf}', GC_LVT), ('\u{cfe0}', '\u{cfe0}', GC_LV), ('\u{cfe1}',
- '\u{cffb}', GC_LVT), ('\u{cffc}', '\u{cffc}', GC_LV), ('\u{cffd}', '\u{d017}', GC_LVT),
- ('\u{d018}', '\u{d018}', GC_LV), ('\u{d019}', '\u{d033}', GC_LVT), ('\u{d034}', '\u{d034}',
- GC_LV), ('\u{d035}', '\u{d04f}', GC_LVT), ('\u{d050}', '\u{d050}', GC_LV), ('\u{d051}',
- '\u{d06b}', GC_LVT), ('\u{d06c}', '\u{d06c}', GC_LV), ('\u{d06d}', '\u{d087}', GC_LVT),
- ('\u{d088}', '\u{d088}', GC_LV), ('\u{d089}', '\u{d0a3}', GC_LVT), ('\u{d0a4}', '\u{d0a4}',
- GC_LV), ('\u{d0a5}', '\u{d0bf}', GC_LVT), ('\u{d0c0}', '\u{d0c0}', GC_LV), ('\u{d0c1}',
- '\u{d0db}', GC_LVT), ('\u{d0dc}', '\u{d0dc}', GC_LV), ('\u{d0dd}', '\u{d0f7}', GC_LVT),
- ('\u{d0f8}', '\u{d0f8}', GC_LV), ('\u{d0f9}', '\u{d113}', GC_LVT), ('\u{d114}', '\u{d114}',
- GC_LV), ('\u{d115}', '\u{d12f}', GC_LVT), ('\u{d130}', '\u{d130}', GC_LV), ('\u{d131}',
- '\u{d14b}', GC_LVT), ('\u{d14c}', '\u{d14c}', GC_LV), ('\u{d14d}', '\u{d167}', GC_LVT),
- ('\u{d168}', '\u{d168}', GC_LV), ('\u{d169}', '\u{d183}', GC_LVT), ('\u{d184}', '\u{d184}',
- GC_LV), ('\u{d185}', '\u{d19f}', GC_LVT), ('\u{d1a0}', '\u{d1a0}', GC_LV), ('\u{d1a1}',
- '\u{d1bb}', GC_LVT), ('\u{d1bc}', '\u{d1bc}', GC_LV), ('\u{d1bd}', '\u{d1d7}', GC_LVT),
- ('\u{d1d8}', '\u{d1d8}', GC_LV), ('\u{d1d9}', '\u{d1f3}', GC_LVT), ('\u{d1f4}', '\u{d1f4}',
- GC_LV), ('\u{d1f5}', '\u{d20f}', GC_LVT), ('\u{d210}', '\u{d210}', GC_LV), ('\u{d211}',
- '\u{d22b}', GC_LVT), ('\u{d22c}', '\u{d22c}', GC_LV), ('\u{d22d}', '\u{d247}', GC_LVT),
- ('\u{d248}', '\u{d248}', GC_LV), ('\u{d249}', '\u{d263}', GC_LVT), ('\u{d264}', '\u{d264}',
- GC_LV), ('\u{d265}', '\u{d27f}', GC_LVT), ('\u{d280}', '\u{d280}', GC_LV), ('\u{d281}',
- '\u{d29b}', GC_LVT), ('\u{d29c}', '\u{d29c}', GC_LV), ('\u{d29d}', '\u{d2b7}', GC_LVT),
- ('\u{d2b8}', '\u{d2b8}', GC_LV), ('\u{d2b9}', '\u{d2d3}', GC_LVT), ('\u{d2d4}', '\u{d2d4}',
- GC_LV), ('\u{d2d5}', '\u{d2ef}', GC_LVT), ('\u{d2f0}', '\u{d2f0}', GC_LV), ('\u{d2f1}',
- '\u{d30b}', GC_LVT), ('\u{d30c}', '\u{d30c}', GC_LV), ('\u{d30d}', '\u{d327}', GC_LVT),
- ('\u{d328}', '\u{d328}', GC_LV), ('\u{d329}', '\u{d343}', GC_LVT), ('\u{d344}', '\u{d344}',
- GC_LV), ('\u{d345}', '\u{d35f}', GC_LVT), ('\u{d360}', '\u{d360}', GC_LV), ('\u{d361}',
- '\u{d37b}', GC_LVT), ('\u{d37c}', '\u{d37c}', GC_LV), ('\u{d37d}', '\u{d397}', GC_LVT),
- ('\u{d398}', '\u{d398}', GC_LV), ('\u{d399}', '\u{d3b3}', GC_LVT), ('\u{d3b4}', '\u{d3b4}',
- GC_LV), ('\u{d3b5}', '\u{d3cf}', GC_LVT), ('\u{d3d0}', '\u{d3d0}', GC_LV), ('\u{d3d1}',
- '\u{d3eb}', GC_LVT), ('\u{d3ec}', '\u{d3ec}', GC_LV), ('\u{d3ed}', '\u{d407}', GC_LVT),
- ('\u{d408}', '\u{d408}', GC_LV), ('\u{d409}', '\u{d423}', GC_LVT), ('\u{d424}', '\u{d424}',
- GC_LV), ('\u{d425}', '\u{d43f}', GC_LVT), ('\u{d440}', '\u{d440}', GC_LV), ('\u{d441}',
- '\u{d45b}', GC_LVT), ('\u{d45c}', '\u{d45c}', GC_LV), ('\u{d45d}', '\u{d477}', GC_LVT),
- ('\u{d478}', '\u{d478}', GC_LV), ('\u{d479}', '\u{d493}', GC_LVT), ('\u{d494}', '\u{d494}',
- GC_LV), ('\u{d495}', '\u{d4af}', GC_LVT), ('\u{d4b0}', '\u{d4b0}', GC_LV), ('\u{d4b1}',
- '\u{d4cb}', GC_LVT), ('\u{d4cc}', '\u{d4cc}', GC_LV), ('\u{d4cd}', '\u{d4e7}', GC_LVT),
- ('\u{d4e8}', '\u{d4e8}', GC_LV), ('\u{d4e9}', '\u{d503}', GC_LVT), ('\u{d504}', '\u{d504}',
- GC_LV), ('\u{d505}', '\u{d51f}', GC_LVT), ('\u{d520}', '\u{d520}', GC_LV), ('\u{d521}',
- '\u{d53b}', GC_LVT), ('\u{d53c}', '\u{d53c}', GC_LV), ('\u{d53d}', '\u{d557}', GC_LVT),
- ('\u{d558}', '\u{d558}', GC_LV), ('\u{d559}', '\u{d573}', GC_LVT), ('\u{d574}', '\u{d574}',
- GC_LV), ('\u{d575}', '\u{d58f}', GC_LVT), ('\u{d590}', '\u{d590}', GC_LV), ('\u{d591}',
- '\u{d5ab}', GC_LVT), ('\u{d5ac}', '\u{d5ac}', GC_LV), ('\u{d5ad}', '\u{d5c7}', GC_LVT),
- ('\u{d5c8}', '\u{d5c8}', GC_LV), ('\u{d5c9}', '\u{d5e3}', GC_LVT), ('\u{d5e4}', '\u{d5e4}',
- GC_LV), ('\u{d5e5}', '\u{d5ff}', GC_LVT), ('\u{d600}', '\u{d600}', GC_LV), ('\u{d601}',
- '\u{d61b}', GC_LVT), ('\u{d61c}', '\u{d61c}', GC_LV), ('\u{d61d}', '\u{d637}', GC_LVT),
- ('\u{d638}', '\u{d638}', GC_LV), ('\u{d639}', '\u{d653}', GC_LVT), ('\u{d654}', '\u{d654}',
- GC_LV), ('\u{d655}', '\u{d66f}', GC_LVT), ('\u{d670}', '\u{d670}', GC_LV), ('\u{d671}',
- '\u{d68b}', GC_LVT), ('\u{d68c}', '\u{d68c}', GC_LV), ('\u{d68d}', '\u{d6a7}', GC_LVT),
- ('\u{d6a8}', '\u{d6a8}', GC_LV), ('\u{d6a9}', '\u{d6c3}', GC_LVT), ('\u{d6c4}', '\u{d6c4}',
- GC_LV), ('\u{d6c5}', '\u{d6df}', GC_LVT), ('\u{d6e0}', '\u{d6e0}', GC_LV), ('\u{d6e1}',
- '\u{d6fb}', GC_LVT), ('\u{d6fc}', '\u{d6fc}', GC_LV), ('\u{d6fd}', '\u{d717}', GC_LVT),
- ('\u{d718}', '\u{d718}', GC_LV), ('\u{d719}', '\u{d733}', GC_LVT), ('\u{d734}', '\u{d734}',
- GC_LV), ('\u{d735}', '\u{d74f}', GC_LVT), ('\u{d750}', '\u{d750}', GC_LV), ('\u{d751}',
- '\u{d76b}', GC_LVT), ('\u{d76c}', '\u{d76c}', GC_LV), ('\u{d76d}', '\u{d787}', GC_LVT),
- ('\u{d788}', '\u{d788}', GC_LV), ('\u{d789}', '\u{d7a3}', GC_LVT), ('\u{d7b0}', '\u{d7c6}',
- GC_V), ('\u{d7cb}', '\u{d7fb}', GC_T), ('\u{fb1e}', '\u{fb1e}', GC_Extend), ('\u{fe00}',
- '\u{fe0f}', GC_Extend), ('\u{fe20}', '\u{fe2f}', GC_Extend), ('\u{feff}', '\u{feff}',
- GC_Control), ('\u{ff9e}', '\u{ff9f}', GC_Extend), ('\u{fff0}', '\u{fffb}', GC_Control),
- ('\u{101fd}', '\u{101fd}', GC_Extend), ('\u{102e0}', '\u{102e0}', GC_Extend), ('\u{10376}',
- '\u{1037a}', GC_Extend), ('\u{10a01}', '\u{10a03}', GC_Extend), ('\u{10a05}', '\u{10a06}',
- GC_Extend), ('\u{10a0c}', '\u{10a0f}', GC_Extend), ('\u{10a38}', '\u{10a3a}', GC_Extend),
- ('\u{10a3f}', '\u{10a3f}', GC_Extend), ('\u{10ae5}', '\u{10ae6}', GC_Extend), ('\u{10d24}',
- '\u{10d27}', GC_Extend), ('\u{10f46}', '\u{10f50}', GC_Extend), ('\u{11000}', '\u{11000}',
- GC_SpacingMark), ('\u{11001}', '\u{11001}', GC_Extend), ('\u{11002}', '\u{11002}',
- GC_SpacingMark), ('\u{11038}', '\u{11046}', GC_Extend), ('\u{1107f}', '\u{11081}',
- GC_Extend), ('\u{11082}', '\u{11082}', GC_SpacingMark), ('\u{110b0}', '\u{110b2}',
- GC_SpacingMark), ('\u{110b3}', '\u{110b6}', GC_Extend), ('\u{110b7}', '\u{110b8}',
- GC_SpacingMark), ('\u{110b9}', '\u{110ba}', GC_Extend), ('\u{110bd}', '\u{110bd}',
- GC_Prepend), ('\u{110cd}', '\u{110cd}', GC_Prepend), ('\u{11100}', '\u{11102}', GC_Extend),
- ('\u{11127}', '\u{1112b}', GC_Extend), ('\u{1112c}', '\u{1112c}', GC_SpacingMark),
- ('\u{1112d}', '\u{11134}', GC_Extend), ('\u{11145}', '\u{11146}', GC_SpacingMark),
- ('\u{11173}', '\u{11173}', GC_Extend), ('\u{11180}', '\u{11181}', GC_Extend), ('\u{11182}',
- '\u{11182}', GC_SpacingMark), ('\u{111b3}', '\u{111b5}', GC_SpacingMark), ('\u{111b6}',
- '\u{111be}', GC_Extend), ('\u{111bf}', '\u{111c0}', GC_SpacingMark), ('\u{111c2}',
- '\u{111c3}', GC_Prepend), ('\u{111c9}', '\u{111cc}', GC_Extend), ('\u{1122c}', '\u{1122e}',
- GC_SpacingMark), ('\u{1122f}', '\u{11231}', GC_Extend), ('\u{11232}', '\u{11233}',
- GC_SpacingMark), ('\u{11234}', '\u{11234}', GC_Extend), ('\u{11235}', '\u{11235}',
- GC_SpacingMark), ('\u{11236}', '\u{11237}', GC_Extend), ('\u{1123e}', '\u{1123e}',
- GC_Extend), ('\u{112df}', '\u{112df}', GC_Extend), ('\u{112e0}', '\u{112e2}',
- GC_SpacingMark), ('\u{112e3}', '\u{112ea}', GC_Extend), ('\u{11300}', '\u{11301}',
- GC_Extend), ('\u{11302}', '\u{11303}', GC_SpacingMark), ('\u{1133b}', '\u{1133c}',
- GC_Extend), ('\u{1133e}', '\u{1133e}', GC_Extend), ('\u{1133f}', '\u{1133f}',
- GC_SpacingMark), ('\u{11340}', '\u{11340}', GC_Extend), ('\u{11341}', '\u{11344}',
- GC_SpacingMark), ('\u{11347}', '\u{11348}', GC_SpacingMark), ('\u{1134b}', '\u{1134d}',
- GC_SpacingMark), ('\u{11357}', '\u{11357}', GC_Extend), ('\u{11362}', '\u{11363}',
- GC_SpacingMark), ('\u{11366}', '\u{1136c}', GC_Extend), ('\u{11370}', '\u{11374}',
- GC_Extend), ('\u{11435}', '\u{11437}', GC_SpacingMark), ('\u{11438}', '\u{1143f}',
- GC_Extend), ('\u{11440}', '\u{11441}', GC_SpacingMark), ('\u{11442}', '\u{11444}',
- GC_Extend), ('\u{11445}', '\u{11445}', GC_SpacingMark), ('\u{11446}', '\u{11446}',
- GC_Extend), ('\u{1145e}', '\u{1145e}', GC_Extend), ('\u{114b0}', '\u{114b0}', GC_Extend),
- ('\u{114b1}', '\u{114b2}', GC_SpacingMark), ('\u{114b3}', '\u{114b8}', GC_Extend),
- ('\u{114b9}', '\u{114b9}', GC_SpacingMark), ('\u{114ba}', '\u{114ba}', GC_Extend),
- ('\u{114bb}', '\u{114bc}', GC_SpacingMark), ('\u{114bd}', '\u{114bd}', GC_Extend),
- ('\u{114be}', '\u{114be}', GC_SpacingMark), ('\u{114bf}', '\u{114c0}', GC_Extend),
- ('\u{114c1}', '\u{114c1}', GC_SpacingMark), ('\u{114c2}', '\u{114c3}', GC_Extend),
- ('\u{115af}', '\u{115af}', GC_Extend), ('\u{115b0}', '\u{115b1}', GC_SpacingMark),
- ('\u{115b2}', '\u{115b5}', GC_Extend), ('\u{115b8}', '\u{115bb}', GC_SpacingMark),
- ('\u{115bc}', '\u{115bd}', GC_Extend), ('\u{115be}', '\u{115be}', GC_SpacingMark),
- ('\u{115bf}', '\u{115c0}', GC_Extend), ('\u{115dc}', '\u{115dd}', GC_Extend), ('\u{11630}',
- '\u{11632}', GC_SpacingMark), ('\u{11633}', '\u{1163a}', GC_Extend), ('\u{1163b}',
- '\u{1163c}', GC_SpacingMark), ('\u{1163d}', '\u{1163d}', GC_Extend), ('\u{1163e}',
- '\u{1163e}', GC_SpacingMark), ('\u{1163f}', '\u{11640}', GC_Extend), ('\u{116ab}',
- '\u{116ab}', GC_Extend), ('\u{116ac}', '\u{116ac}', GC_SpacingMark), ('\u{116ad}',
- '\u{116ad}', GC_Extend), ('\u{116ae}', '\u{116af}', GC_SpacingMark), ('\u{116b0}',
- '\u{116b5}', GC_Extend), ('\u{116b6}', '\u{116b6}', GC_SpacingMark), ('\u{116b7}',
- '\u{116b7}', GC_Extend), ('\u{1171d}', '\u{1171f}', GC_Extend), ('\u{11720}', '\u{11721}',
- GC_SpacingMark), ('\u{11722}', '\u{11725}', GC_Extend), ('\u{11726}', '\u{11726}',
- GC_SpacingMark), ('\u{11727}', '\u{1172b}', GC_Extend), ('\u{1182c}', '\u{1182e}',
- GC_SpacingMark), ('\u{1182f}', '\u{11837}', GC_Extend), ('\u{11838}', '\u{11838}',
- GC_SpacingMark), ('\u{11839}', '\u{1183a}', GC_Extend), ('\u{119d1}', '\u{119d3}',
- GC_SpacingMark), ('\u{119d4}', '\u{119d7}', GC_Extend), ('\u{119da}', '\u{119db}',
- GC_Extend), ('\u{119dc}', '\u{119df}', GC_SpacingMark), ('\u{119e0}', '\u{119e0}',
- GC_Extend), ('\u{119e4}', '\u{119e4}', GC_SpacingMark), ('\u{11a01}', '\u{11a0a}',
- GC_Extend), ('\u{11a33}', '\u{11a38}', GC_Extend), ('\u{11a39}', '\u{11a39}',
- GC_SpacingMark), ('\u{11a3a}', '\u{11a3a}', GC_Prepend), ('\u{11a3b}', '\u{11a3e}',
- GC_Extend), ('\u{11a47}', '\u{11a47}', GC_Extend), ('\u{11a51}', '\u{11a56}', GC_Extend),
- ('\u{11a57}', '\u{11a58}', GC_SpacingMark), ('\u{11a59}', '\u{11a5b}', GC_Extend),
- ('\u{11a84}', '\u{11a89}', GC_Prepend), ('\u{11a8a}', '\u{11a96}', GC_Extend), ('\u{11a97}',
- '\u{11a97}', GC_SpacingMark), ('\u{11a98}', '\u{11a99}', GC_Extend), ('\u{11c2f}',
- '\u{11c2f}', GC_SpacingMark), ('\u{11c30}', '\u{11c36}', GC_Extend), ('\u{11c38}',
- '\u{11c3d}', GC_Extend), ('\u{11c3e}', '\u{11c3e}', GC_SpacingMark), ('\u{11c3f}',
- '\u{11c3f}', GC_Extend), ('\u{11c92}', '\u{11ca7}', GC_Extend), ('\u{11ca9}', '\u{11ca9}',
- GC_SpacingMark), ('\u{11caa}', '\u{11cb0}', GC_Extend), ('\u{11cb1}', '\u{11cb1}',
- GC_SpacingMark), ('\u{11cb2}', '\u{11cb3}', GC_Extend), ('\u{11cb4}', '\u{11cb4}',
- GC_SpacingMark), ('\u{11cb5}', '\u{11cb6}', GC_Extend), ('\u{11d31}', '\u{11d36}',
- GC_Extend), ('\u{11d3a}', '\u{11d3a}', GC_Extend), ('\u{11d3c}', '\u{11d3d}', GC_Extend),
- ('\u{11d3f}', '\u{11d45}', GC_Extend), ('\u{11d46}', '\u{11d46}', GC_Prepend), ('\u{11d47}',
- '\u{11d47}', GC_Extend), ('\u{11d8a}', '\u{11d8e}', GC_SpacingMark), ('\u{11d90}',
- '\u{11d91}', GC_Extend), ('\u{11d93}', '\u{11d94}', GC_SpacingMark), ('\u{11d95}',
- '\u{11d95}', GC_Extend), ('\u{11d96}', '\u{11d96}', GC_SpacingMark), ('\u{11d97}',
- '\u{11d97}', GC_Extend), ('\u{11ef3}', '\u{11ef4}', GC_Extend), ('\u{11ef5}', '\u{11ef6}',
- GC_SpacingMark), ('\u{13430}', '\u{13438}', GC_Control), ('\u{16af0}', '\u{16af4}',
- GC_Extend), ('\u{16b30}', '\u{16b36}', GC_Extend), ('\u{16f4f}', '\u{16f4f}', GC_Extend),
- ('\u{16f51}', '\u{16f87}', GC_SpacingMark), ('\u{16f8f}', '\u{16f92}', GC_Extend),
- ('\u{1bc9d}', '\u{1bc9e}', GC_Extend), ('\u{1bca0}', '\u{1bca3}', GC_Control), ('\u{1d165}',
- '\u{1d165}', GC_Extend), ('\u{1d166}', '\u{1d166}', GC_SpacingMark), ('\u{1d167}',
- '\u{1d169}', GC_Extend), ('\u{1d16d}', '\u{1d16d}', GC_SpacingMark), ('\u{1d16e}',
- '\u{1d172}', GC_Extend), ('\u{1d173}', '\u{1d17a}', GC_Control), ('\u{1d17b}', '\u{1d182}',
- GC_Extend), ('\u{1d185}', '\u{1d18b}', GC_Extend), ('\u{1d1aa}', '\u{1d1ad}', GC_Extend),
- ('\u{1d242}', '\u{1d244}', GC_Extend), ('\u{1da00}', '\u{1da36}', GC_Extend), ('\u{1da3b}',
- '\u{1da6c}', GC_Extend), ('\u{1da75}', '\u{1da75}', GC_Extend), ('\u{1da84}', '\u{1da84}',
- GC_Extend), ('\u{1da9b}', '\u{1da9f}', GC_Extend), ('\u{1daa1}', '\u{1daaf}', GC_Extend),
- ('\u{1e000}', '\u{1e006}', GC_Extend), ('\u{1e008}', '\u{1e018}', GC_Extend), ('\u{1e01b}',
- '\u{1e021}', GC_Extend), ('\u{1e023}', '\u{1e024}', GC_Extend), ('\u{1e026}', '\u{1e02a}',
- GC_Extend), ('\u{1e130}', '\u{1e136}', GC_Extend), ('\u{1e2ec}', '\u{1e2ef}', GC_Extend),
- ('\u{1e8d0}', '\u{1e8d6}', GC_Extend), ('\u{1e944}', '\u{1e94a}', GC_Extend), ('\u{1f000}',
- '\u{1f0ff}', GC_Extended_Pictographic), ('\u{1f10d}', '\u{1f10f}',
- GC_Extended_Pictographic), ('\u{1f12f}', '\u{1f12f}', GC_Extended_Pictographic),
- ('\u{1f16c}', '\u{1f171}', GC_Extended_Pictographic), ('\u{1f17e}', '\u{1f17f}',
- GC_Extended_Pictographic), ('\u{1f18e}', '\u{1f18e}', GC_Extended_Pictographic),
- ('\u{1f191}', '\u{1f19a}', GC_Extended_Pictographic), ('\u{1f1ad}', '\u{1f1e5}',
- GC_Extended_Pictographic), ('\u{1f1e6}', '\u{1f1ff}', GC_Regional_Indicator), ('\u{1f201}',
- '\u{1f20f}', GC_Extended_Pictographic), ('\u{1f21a}', '\u{1f21a}',
- GC_Extended_Pictographic), ('\u{1f22f}', '\u{1f22f}', GC_Extended_Pictographic),
- ('\u{1f232}', '\u{1f23a}', GC_Extended_Pictographic), ('\u{1f23c}', '\u{1f23f}',
- GC_Extended_Pictographic), ('\u{1f249}', '\u{1f3fa}', GC_Extended_Pictographic),
- ('\u{1f3fb}', '\u{1f3ff}', GC_Extend), ('\u{1f400}', '\u{1f53d}', GC_Extended_Pictographic),
- ('\u{1f546}', '\u{1f64f}', GC_Extended_Pictographic), ('\u{1f680}', '\u{1f6ff}',
- GC_Extended_Pictographic), ('\u{1f774}', '\u{1f77f}', GC_Extended_Pictographic),
- ('\u{1f7d5}', '\u{1f7ff}', GC_Extended_Pictographic), ('\u{1f80c}', '\u{1f80f}',
- GC_Extended_Pictographic), ('\u{1f848}', '\u{1f84f}', GC_Extended_Pictographic),
- ('\u{1f85a}', '\u{1f85f}', GC_Extended_Pictographic), ('\u{1f888}', '\u{1f88f}',
- GC_Extended_Pictographic), ('\u{1f8ae}', '\u{1f8ff}', GC_Extended_Pictographic),
- ('\u{1f90c}', '\u{1f93a}', GC_Extended_Pictographic), ('\u{1f93c}', '\u{1f945}',
- GC_Extended_Pictographic), ('\u{1f947}', '\u{1fffd}', GC_Extended_Pictographic),
- ('\u{e0000}', '\u{e001f}', GC_Control), ('\u{e0020}', '\u{e007f}', GC_Extend), ('\u{e0080}',
- '\u{e00ff}', GC_Control), ('\u{e0100}', '\u{e01ef}', GC_Extend), ('\u{e01f0}', '\u{e0fff}',
- GC_Control)
- ];
-
-}
-
-pub mod word {
- use core::result::Result::{Ok, Err};
-
- pub use self::WordCat::*;
-
- #[allow(non_camel_case_types)]
- #[derive(Clone, Copy, PartialEq, Eq, Debug)]
- pub enum WordCat {
- WC_ALetter,
- WC_Any,
- WC_CR,
- WC_Double_Quote,
- WC_Extend,
- WC_ExtendNumLet,
- WC_Format,
- WC_Hebrew_Letter,
- WC_Katakana,
- WC_LF,
- WC_MidLetter,
- WC_MidNum,
- WC_MidNumLet,
- WC_Newline,
- WC_Numeric,
- WC_Regional_Indicator,
- WC_Single_Quote,
- WC_WSegSpace,
- WC_ZWJ,
- }
-
- fn bsearch_range_value_table(c: char, r: &'static [(char, char, WordCat)]) -> WordCat {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, cat) = r[idx];
- cat
- }
- Err(_) => WC_Any
- }
- }
-
- pub fn word_category(c: char) -> WordCat {
- bsearch_range_value_table(c, word_cat_table)
- }
-
- const word_cat_table: &'static [(char, char, WordCat)] = &[
- ('\u{a}', '\u{a}', WC_LF), ('\u{b}', '\u{c}', WC_Newline), ('\u{d}', '\u{d}', WC_CR),
- ('\u{20}', '\u{20}', WC_WSegSpace), ('\u{22}', '\u{22}', WC_Double_Quote), ('\u{27}',
- '\u{27}', WC_Single_Quote), ('\u{2c}', '\u{2c}', WC_MidNum), ('\u{2e}', '\u{2e}',
- WC_MidNumLet), ('\u{30}', '\u{39}', WC_Numeric), ('\u{3a}', '\u{3a}', WC_MidLetter),
- ('\u{3b}', '\u{3b}', WC_MidNum), ('\u{41}', '\u{5a}', WC_ALetter), ('\u{5f}', '\u{5f}',
- WC_ExtendNumLet), ('\u{61}', '\u{7a}', WC_ALetter), ('\u{85}', '\u{85}', WC_Newline),
- ('\u{aa}', '\u{aa}', WC_ALetter), ('\u{ad}', '\u{ad}', WC_Format), ('\u{b5}', '\u{b5}',
- WC_ALetter), ('\u{b7}', '\u{b7}', WC_MidLetter), ('\u{ba}', '\u{ba}', WC_ALetter),
- ('\u{c0}', '\u{d6}', WC_ALetter), ('\u{d8}', '\u{f6}', WC_ALetter), ('\u{f8}', '\u{2d7}',
- WC_ALetter), ('\u{2de}', '\u{2e4}', WC_ALetter), ('\u{2ec}', '\u{2ff}', WC_ALetter),
- ('\u{300}', '\u{36f}', WC_Extend), ('\u{370}', '\u{374}', WC_ALetter), ('\u{376}',
- '\u{377}', WC_ALetter), ('\u{37a}', '\u{37d}', WC_ALetter), ('\u{37e}', '\u{37e}',
- WC_MidNum), ('\u{37f}', '\u{37f}', WC_ALetter), ('\u{386}', '\u{386}', WC_ALetter),
- ('\u{387}', '\u{387}', WC_MidLetter), ('\u{388}', '\u{38a}', WC_ALetter), ('\u{38c}',
- '\u{38c}', WC_ALetter), ('\u{38e}', '\u{3a1}', WC_ALetter), ('\u{3a3}', '\u{3f5}',
- WC_ALetter), ('\u{3f7}', '\u{481}', WC_ALetter), ('\u{483}', '\u{489}', WC_Extend),
- ('\u{48a}', '\u{52f}', WC_ALetter), ('\u{531}', '\u{556}', WC_ALetter), ('\u{559}',
- '\u{559}', WC_ALetter), ('\u{55b}', '\u{55c}', WC_ALetter), ('\u{55e}', '\u{55e}',
- WC_ALetter), ('\u{560}', '\u{588}', WC_ALetter), ('\u{589}', '\u{589}', WC_MidNum),
- ('\u{591}', '\u{5bd}', WC_Extend), ('\u{5bf}', '\u{5bf}', WC_Extend), ('\u{5c1}', '\u{5c2}',
- WC_Extend), ('\u{5c4}', '\u{5c5}', WC_Extend), ('\u{5c7}', '\u{5c7}', WC_Extend),
- ('\u{5d0}', '\u{5ea}', WC_Hebrew_Letter), ('\u{5ef}', '\u{5f2}', WC_Hebrew_Letter),
- ('\u{5f3}', '\u{5f3}', WC_ALetter), ('\u{5f4}', '\u{5f4}', WC_MidLetter), ('\u{600}',
- '\u{605}', WC_Format), ('\u{60c}', '\u{60d}', WC_MidNum), ('\u{610}', '\u{61a}', WC_Extend),
- ('\u{61c}', '\u{61c}', WC_Format), ('\u{620}', '\u{64a}', WC_ALetter), ('\u{64b}',
- '\u{65f}', WC_Extend), ('\u{660}', '\u{669}', WC_Numeric), ('\u{66b}', '\u{66b}',
- WC_Numeric), ('\u{66c}', '\u{66c}', WC_MidNum), ('\u{66e}', '\u{66f}', WC_ALetter),
- ('\u{670}', '\u{670}', WC_Extend), ('\u{671}', '\u{6d3}', WC_ALetter), ('\u{6d5}',
- '\u{6d5}', WC_ALetter), ('\u{6d6}', '\u{6dc}', WC_Extend), ('\u{6dd}', '\u{6dd}',
- WC_Format), ('\u{6df}', '\u{6e4}', WC_Extend), ('\u{6e5}', '\u{6e6}', WC_ALetter),
- ('\u{6e7}', '\u{6e8}', WC_Extend), ('\u{6ea}', '\u{6ed}', WC_Extend), ('\u{6ee}', '\u{6ef}',
- WC_ALetter), ('\u{6f0}', '\u{6f9}', WC_Numeric), ('\u{6fa}', '\u{6fc}', WC_ALetter),
- ('\u{6ff}', '\u{6ff}', WC_ALetter), ('\u{70f}', '\u{70f}', WC_Format), ('\u{710}',
- '\u{710}', WC_ALetter), ('\u{711}', '\u{711}', WC_Extend), ('\u{712}', '\u{72f}',
- WC_ALetter), ('\u{730}', '\u{74a}', WC_Extend), ('\u{74d}', '\u{7a5}', WC_ALetter),
- ('\u{7a6}', '\u{7b0}', WC_Extend), ('\u{7b1}', '\u{7b1}', WC_ALetter), ('\u{7c0}',
- '\u{7c9}', WC_Numeric), ('\u{7ca}', '\u{7ea}', WC_ALetter), ('\u{7eb}', '\u{7f3}',
- WC_Extend), ('\u{7f4}', '\u{7f5}', WC_ALetter), ('\u{7f8}', '\u{7f8}', WC_MidNum),
- ('\u{7fa}', '\u{7fa}', WC_ALetter), ('\u{7fd}', '\u{7fd}', WC_Extend), ('\u{800}',
- '\u{815}', WC_ALetter), ('\u{816}', '\u{819}', WC_Extend), ('\u{81a}', '\u{81a}',
- WC_ALetter), ('\u{81b}', '\u{823}', WC_Extend), ('\u{824}', '\u{824}', WC_ALetter),
- ('\u{825}', '\u{827}', WC_Extend), ('\u{828}', '\u{828}', WC_ALetter), ('\u{829}',
- '\u{82d}', WC_Extend), ('\u{840}', '\u{858}', WC_ALetter), ('\u{859}', '\u{85b}',
- WC_Extend), ('\u{860}', '\u{86a}', WC_ALetter), ('\u{8a0}', '\u{8b4}', WC_ALetter),
- ('\u{8b6}', '\u{8bd}', WC_ALetter), ('\u{8d3}', '\u{8e1}', WC_Extend), ('\u{8e2}',
- '\u{8e2}', WC_Format), ('\u{8e3}', '\u{903}', WC_Extend), ('\u{904}', '\u{939}',
- WC_ALetter), ('\u{93a}', '\u{93c}', WC_Extend), ('\u{93d}', '\u{93d}', WC_ALetter),
- ('\u{93e}', '\u{94f}', WC_Extend), ('\u{950}', '\u{950}', WC_ALetter), ('\u{951}',
- '\u{957}', WC_Extend), ('\u{958}', '\u{961}', WC_ALetter), ('\u{962}', '\u{963}',
- WC_Extend), ('\u{966}', '\u{96f}', WC_Numeric), ('\u{971}', '\u{980}', WC_ALetter),
- ('\u{981}', '\u{983}', WC_Extend), ('\u{985}', '\u{98c}', WC_ALetter), ('\u{98f}',
- '\u{990}', WC_ALetter), ('\u{993}', '\u{9a8}', WC_ALetter), ('\u{9aa}', '\u{9b0}',
- WC_ALetter), ('\u{9b2}', '\u{9b2}', WC_ALetter), ('\u{9b6}', '\u{9b9}', WC_ALetter),
- ('\u{9bc}', '\u{9bc}', WC_Extend), ('\u{9bd}', '\u{9bd}', WC_ALetter), ('\u{9be}',
- '\u{9c4}', WC_Extend), ('\u{9c7}', '\u{9c8}', WC_Extend), ('\u{9cb}', '\u{9cd}', WC_Extend),
- ('\u{9ce}', '\u{9ce}', WC_ALetter), ('\u{9d7}', '\u{9d7}', WC_Extend), ('\u{9dc}',
- '\u{9dd}', WC_ALetter), ('\u{9df}', '\u{9e1}', WC_ALetter), ('\u{9e2}', '\u{9e3}',
- WC_Extend), ('\u{9e6}', '\u{9ef}', WC_Numeric), ('\u{9f0}', '\u{9f1}', WC_ALetter),
- ('\u{9fc}', '\u{9fc}', WC_ALetter), ('\u{9fe}', '\u{9fe}', WC_Extend), ('\u{a01}',
- '\u{a03}', WC_Extend), ('\u{a05}', '\u{a0a}', WC_ALetter), ('\u{a0f}', '\u{a10}',
- WC_ALetter), ('\u{a13}', '\u{a28}', WC_ALetter), ('\u{a2a}', '\u{a30}', WC_ALetter),
- ('\u{a32}', '\u{a33}', WC_ALetter), ('\u{a35}', '\u{a36}', WC_ALetter), ('\u{a38}',
- '\u{a39}', WC_ALetter), ('\u{a3c}', '\u{a3c}', WC_Extend), ('\u{a3e}', '\u{a42}',
- WC_Extend), ('\u{a47}', '\u{a48}', WC_Extend), ('\u{a4b}', '\u{a4d}', WC_Extend),
- ('\u{a51}', '\u{a51}', WC_Extend), ('\u{a59}', '\u{a5c}', WC_ALetter), ('\u{a5e}',
- '\u{a5e}', WC_ALetter), ('\u{a66}', '\u{a6f}', WC_Numeric), ('\u{a70}', '\u{a71}',
- WC_Extend), ('\u{a72}', '\u{a74}', WC_ALetter), ('\u{a75}', '\u{a75}', WC_Extend),
- ('\u{a81}', '\u{a83}', WC_Extend), ('\u{a85}', '\u{a8d}', WC_ALetter), ('\u{a8f}',
- '\u{a91}', WC_ALetter), ('\u{a93}', '\u{aa8}', WC_ALetter), ('\u{aaa}', '\u{ab0}',
- WC_ALetter), ('\u{ab2}', '\u{ab3}', WC_ALetter), ('\u{ab5}', '\u{ab9}', WC_ALetter),
- ('\u{abc}', '\u{abc}', WC_Extend), ('\u{abd}', '\u{abd}', WC_ALetter), ('\u{abe}',
- '\u{ac5}', WC_Extend), ('\u{ac7}', '\u{ac9}', WC_Extend), ('\u{acb}', '\u{acd}', WC_Extend),
- ('\u{ad0}', '\u{ad0}', WC_ALetter), ('\u{ae0}', '\u{ae1}', WC_ALetter), ('\u{ae2}',
- '\u{ae3}', WC_Extend), ('\u{ae6}', '\u{aef}', WC_Numeric), ('\u{af9}', '\u{af9}',
- WC_ALetter), ('\u{afa}', '\u{aff}', WC_Extend), ('\u{b01}', '\u{b03}', WC_Extend),
- ('\u{b05}', '\u{b0c}', WC_ALetter), ('\u{b0f}', '\u{b10}', WC_ALetter), ('\u{b13}',
- '\u{b28}', WC_ALetter), ('\u{b2a}', '\u{b30}', WC_ALetter), ('\u{b32}', '\u{b33}',
- WC_ALetter), ('\u{b35}', '\u{b39}', WC_ALetter), ('\u{b3c}', '\u{b3c}', WC_Extend),
- ('\u{b3d}', '\u{b3d}', WC_ALetter), ('\u{b3e}', '\u{b44}', WC_Extend), ('\u{b47}',
- '\u{b48}', WC_Extend), ('\u{b4b}', '\u{b4d}', WC_Extend), ('\u{b56}', '\u{b57}', WC_Extend),
- ('\u{b5c}', '\u{b5d}', WC_ALetter), ('\u{b5f}', '\u{b61}', WC_ALetter), ('\u{b62}',
- '\u{b63}', WC_Extend), ('\u{b66}', '\u{b6f}', WC_Numeric), ('\u{b71}', '\u{b71}',
- WC_ALetter), ('\u{b82}', '\u{b82}', WC_Extend), ('\u{b83}', '\u{b83}', WC_ALetter),
- ('\u{b85}', '\u{b8a}', WC_ALetter), ('\u{b8e}', '\u{b90}', WC_ALetter), ('\u{b92}',
- '\u{b95}', WC_ALetter), ('\u{b99}', '\u{b9a}', WC_ALetter), ('\u{b9c}', '\u{b9c}',
- WC_ALetter), ('\u{b9e}', '\u{b9f}', WC_ALetter), ('\u{ba3}', '\u{ba4}', WC_ALetter),
- ('\u{ba8}', '\u{baa}', WC_ALetter), ('\u{bae}', '\u{bb9}', WC_ALetter), ('\u{bbe}',
- '\u{bc2}', WC_Extend), ('\u{bc6}', '\u{bc8}', WC_Extend), ('\u{bca}', '\u{bcd}', WC_Extend),
- ('\u{bd0}', '\u{bd0}', WC_ALetter), ('\u{bd7}', '\u{bd7}', WC_Extend), ('\u{be6}',
- '\u{bef}', WC_Numeric), ('\u{c00}', '\u{c04}', WC_Extend), ('\u{c05}', '\u{c0c}',
- WC_ALetter), ('\u{c0e}', '\u{c10}', WC_ALetter), ('\u{c12}', '\u{c28}', WC_ALetter),
- ('\u{c2a}', '\u{c39}', WC_ALetter), ('\u{c3d}', '\u{c3d}', WC_ALetter), ('\u{c3e}',
- '\u{c44}', WC_Extend), ('\u{c46}', '\u{c48}', WC_Extend), ('\u{c4a}', '\u{c4d}', WC_Extend),
- ('\u{c55}', '\u{c56}', WC_Extend), ('\u{c58}', '\u{c5a}', WC_ALetter), ('\u{c60}',
- '\u{c61}', WC_ALetter), ('\u{c62}', '\u{c63}', WC_Extend), ('\u{c66}', '\u{c6f}',
- WC_Numeric), ('\u{c80}', '\u{c80}', WC_ALetter), ('\u{c81}', '\u{c83}', WC_Extend),
- ('\u{c85}', '\u{c8c}', WC_ALetter), ('\u{c8e}', '\u{c90}', WC_ALetter), ('\u{c92}',
- '\u{ca8}', WC_ALetter), ('\u{caa}', '\u{cb3}', WC_ALetter), ('\u{cb5}', '\u{cb9}',
- WC_ALetter), ('\u{cbc}', '\u{cbc}', WC_Extend), ('\u{cbd}', '\u{cbd}', WC_ALetter),
- ('\u{cbe}', '\u{cc4}', WC_Extend), ('\u{cc6}', '\u{cc8}', WC_Extend), ('\u{cca}', '\u{ccd}',
- WC_Extend), ('\u{cd5}', '\u{cd6}', WC_Extend), ('\u{cde}', '\u{cde}', WC_ALetter),
- ('\u{ce0}', '\u{ce1}', WC_ALetter), ('\u{ce2}', '\u{ce3}', WC_Extend), ('\u{ce6}',
- '\u{cef}', WC_Numeric), ('\u{cf1}', '\u{cf2}', WC_ALetter), ('\u{d00}', '\u{d03}',
- WC_Extend), ('\u{d05}', '\u{d0c}', WC_ALetter), ('\u{d0e}', '\u{d10}', WC_ALetter),
- ('\u{d12}', '\u{d3a}', WC_ALetter), ('\u{d3b}', '\u{d3c}', WC_Extend), ('\u{d3d}',
- '\u{d3d}', WC_ALetter), ('\u{d3e}', '\u{d44}', WC_Extend), ('\u{d46}', '\u{d48}',
- WC_Extend), ('\u{d4a}', '\u{d4d}', WC_Extend), ('\u{d4e}', '\u{d4e}', WC_ALetter),
- ('\u{d54}', '\u{d56}', WC_ALetter), ('\u{d57}', '\u{d57}', WC_Extend), ('\u{d5f}',
- '\u{d61}', WC_ALetter), ('\u{d62}', '\u{d63}', WC_Extend), ('\u{d66}', '\u{d6f}',
- WC_Numeric), ('\u{d7a}', '\u{d7f}', WC_ALetter), ('\u{d82}', '\u{d83}', WC_Extend),
- ('\u{d85}', '\u{d96}', WC_ALetter), ('\u{d9a}', '\u{db1}', WC_ALetter), ('\u{db3}',
- '\u{dbb}', WC_ALetter), ('\u{dbd}', '\u{dbd}', WC_ALetter), ('\u{dc0}', '\u{dc6}',
- WC_ALetter), ('\u{dca}', '\u{dca}', WC_Extend), ('\u{dcf}', '\u{dd4}', WC_Extend),
- ('\u{dd6}', '\u{dd6}', WC_Extend), ('\u{dd8}', '\u{ddf}', WC_Extend), ('\u{de6}', '\u{def}',
- WC_Numeric), ('\u{df2}', '\u{df3}', WC_Extend), ('\u{e31}', '\u{e31}', WC_Extend),
- ('\u{e34}', '\u{e3a}', WC_Extend), ('\u{e47}', '\u{e4e}', WC_Extend), ('\u{e50}', '\u{e59}',
- WC_Numeric), ('\u{eb1}', '\u{eb1}', WC_Extend), ('\u{eb4}', '\u{ebc}', WC_Extend),
- ('\u{ec8}', '\u{ecd}', WC_Extend), ('\u{ed0}', '\u{ed9}', WC_Numeric), ('\u{f00}',
- '\u{f00}', WC_ALetter), ('\u{f18}', '\u{f19}', WC_Extend), ('\u{f20}', '\u{f29}',
- WC_Numeric), ('\u{f35}', '\u{f35}', WC_Extend), ('\u{f37}', '\u{f37}', WC_Extend),
- ('\u{f39}', '\u{f39}', WC_Extend), ('\u{f3e}', '\u{f3f}', WC_Extend), ('\u{f40}', '\u{f47}',
- WC_ALetter), ('\u{f49}', '\u{f6c}', WC_ALetter), ('\u{f71}', '\u{f84}', WC_Extend),
- ('\u{f86}', '\u{f87}', WC_Extend), ('\u{f88}', '\u{f8c}', WC_ALetter), ('\u{f8d}',
- '\u{f97}', WC_Extend), ('\u{f99}', '\u{fbc}', WC_Extend), ('\u{fc6}', '\u{fc6}', WC_Extend),
- ('\u{102b}', '\u{103e}', WC_Extend), ('\u{1040}', '\u{1049}', WC_Numeric), ('\u{1056}',
- '\u{1059}', WC_Extend), ('\u{105e}', '\u{1060}', WC_Extend), ('\u{1062}', '\u{1064}',
- WC_Extend), ('\u{1067}', '\u{106d}', WC_Extend), ('\u{1071}', '\u{1074}', WC_Extend),
- ('\u{1082}', '\u{108d}', WC_Extend), ('\u{108f}', '\u{108f}', WC_Extend), ('\u{1090}',
- '\u{1099}', WC_Numeric), ('\u{109a}', '\u{109d}', WC_Extend), ('\u{10a0}', '\u{10c5}',
- WC_ALetter), ('\u{10c7}', '\u{10c7}', WC_ALetter), ('\u{10cd}', '\u{10cd}', WC_ALetter),
- ('\u{10d0}', '\u{10fa}', WC_ALetter), ('\u{10fc}', '\u{1248}', WC_ALetter), ('\u{124a}',
- '\u{124d}', WC_ALetter), ('\u{1250}', '\u{1256}', WC_ALetter), ('\u{1258}', '\u{1258}',
- WC_ALetter), ('\u{125a}', '\u{125d}', WC_ALetter), ('\u{1260}', '\u{1288}', WC_ALetter),
- ('\u{128a}', '\u{128d}', WC_ALetter), ('\u{1290}', '\u{12b0}', WC_ALetter), ('\u{12b2}',
- '\u{12b5}', WC_ALetter), ('\u{12b8}', '\u{12be}', WC_ALetter), ('\u{12c0}', '\u{12c0}',
- WC_ALetter), ('\u{12c2}', '\u{12c5}', WC_ALetter), ('\u{12c8}', '\u{12d6}', WC_ALetter),
- ('\u{12d8}', '\u{1310}', WC_ALetter), ('\u{1312}', '\u{1315}', WC_ALetter), ('\u{1318}',
- '\u{135a}', WC_ALetter), ('\u{135d}', '\u{135f}', WC_Extend), ('\u{1380}', '\u{138f}',
- WC_ALetter), ('\u{13a0}', '\u{13f5}', WC_ALetter), ('\u{13f8}', '\u{13fd}', WC_ALetter),
- ('\u{1401}', '\u{166c}', WC_ALetter), ('\u{166f}', '\u{167f}', WC_ALetter), ('\u{1680}',
- '\u{1680}', WC_WSegSpace), ('\u{1681}', '\u{169a}', WC_ALetter), ('\u{16a0}', '\u{16ea}',
- WC_ALetter), ('\u{16ee}', '\u{16f8}', WC_ALetter), ('\u{1700}', '\u{170c}', WC_ALetter),
- ('\u{170e}', '\u{1711}', WC_ALetter), ('\u{1712}', '\u{1714}', WC_Extend), ('\u{1720}',
- '\u{1731}', WC_ALetter), ('\u{1732}', '\u{1734}', WC_Extend), ('\u{1740}', '\u{1751}',
- WC_ALetter), ('\u{1752}', '\u{1753}', WC_Extend), ('\u{1760}', '\u{176c}', WC_ALetter),
- ('\u{176e}', '\u{1770}', WC_ALetter), ('\u{1772}', '\u{1773}', WC_Extend), ('\u{17b4}',
- '\u{17d3}', WC_Extend), ('\u{17dd}', '\u{17dd}', WC_Extend), ('\u{17e0}', '\u{17e9}',
- WC_Numeric), ('\u{180b}', '\u{180d}', WC_Extend), ('\u{180e}', '\u{180e}', WC_Format),
- ('\u{1810}', '\u{1819}', WC_Numeric), ('\u{1820}', '\u{1878}', WC_ALetter), ('\u{1880}',
- '\u{1884}', WC_ALetter), ('\u{1885}', '\u{1886}', WC_Extend), ('\u{1887}', '\u{18a8}',
- WC_ALetter), ('\u{18a9}', '\u{18a9}', WC_Extend), ('\u{18aa}', '\u{18aa}', WC_ALetter),
- ('\u{18b0}', '\u{18f5}', WC_ALetter), ('\u{1900}', '\u{191e}', WC_ALetter), ('\u{1920}',
- '\u{192b}', WC_Extend), ('\u{1930}', '\u{193b}', WC_Extend), ('\u{1946}', '\u{194f}',
- WC_Numeric), ('\u{19d0}', '\u{19d9}', WC_Numeric), ('\u{1a00}', '\u{1a16}', WC_ALetter),
- ('\u{1a17}', '\u{1a1b}', WC_Extend), ('\u{1a55}', '\u{1a5e}', WC_Extend), ('\u{1a60}',
- '\u{1a7c}', WC_Extend), ('\u{1a7f}', '\u{1a7f}', WC_Extend), ('\u{1a80}', '\u{1a89}',
- WC_Numeric), ('\u{1a90}', '\u{1a99}', WC_Numeric), ('\u{1ab0}', '\u{1abe}', WC_Extend),
- ('\u{1b00}', '\u{1b04}', WC_Extend), ('\u{1b05}', '\u{1b33}', WC_ALetter), ('\u{1b34}',
- '\u{1b44}', WC_Extend), ('\u{1b45}', '\u{1b4b}', WC_ALetter), ('\u{1b50}', '\u{1b59}',
- WC_Numeric), ('\u{1b6b}', '\u{1b73}', WC_Extend), ('\u{1b80}', '\u{1b82}', WC_Extend),
- ('\u{1b83}', '\u{1ba0}', WC_ALetter), ('\u{1ba1}', '\u{1bad}', WC_Extend), ('\u{1bae}',
- '\u{1baf}', WC_ALetter), ('\u{1bb0}', '\u{1bb9}', WC_Numeric), ('\u{1bba}', '\u{1be5}',
- WC_ALetter), ('\u{1be6}', '\u{1bf3}', WC_Extend), ('\u{1c00}', '\u{1c23}', WC_ALetter),
- ('\u{1c24}', '\u{1c37}', WC_Extend), ('\u{1c40}', '\u{1c49}', WC_Numeric), ('\u{1c4d}',
- '\u{1c4f}', WC_ALetter), ('\u{1c50}', '\u{1c59}', WC_Numeric), ('\u{1c5a}', '\u{1c7d}',
- WC_ALetter), ('\u{1c80}', '\u{1c88}', WC_ALetter), ('\u{1c90}', '\u{1cba}', WC_ALetter),
- ('\u{1cbd}', '\u{1cbf}', WC_ALetter), ('\u{1cd0}', '\u{1cd2}', WC_Extend), ('\u{1cd4}',
- '\u{1ce8}', WC_Extend), ('\u{1ce9}', '\u{1cec}', WC_ALetter), ('\u{1ced}', '\u{1ced}',
- WC_Extend), ('\u{1cee}', '\u{1cf3}', WC_ALetter), ('\u{1cf4}', '\u{1cf4}', WC_Extend),
- ('\u{1cf5}', '\u{1cf6}', WC_ALetter), ('\u{1cf7}', '\u{1cf9}', WC_Extend), ('\u{1cfa}',
- '\u{1cfa}', WC_ALetter), ('\u{1d00}', '\u{1dbf}', WC_ALetter), ('\u{1dc0}', '\u{1df9}',
- WC_Extend), ('\u{1dfb}', '\u{1dff}', WC_Extend), ('\u{1e00}', '\u{1f15}', WC_ALetter),
- ('\u{1f18}', '\u{1f1d}', WC_ALetter), ('\u{1f20}', '\u{1f45}', WC_ALetter), ('\u{1f48}',
- '\u{1f4d}', WC_ALetter), ('\u{1f50}', '\u{1f57}', WC_ALetter), ('\u{1f59}', '\u{1f59}',
- WC_ALetter), ('\u{1f5b}', '\u{1f5b}', WC_ALetter), ('\u{1f5d}', '\u{1f5d}', WC_ALetter),
- ('\u{1f5f}', '\u{1f7d}', WC_ALetter), ('\u{1f80}', '\u{1fb4}', WC_ALetter), ('\u{1fb6}',
- '\u{1fbc}', WC_ALetter), ('\u{1fbe}', '\u{1fbe}', WC_ALetter), ('\u{1fc2}', '\u{1fc4}',
- WC_ALetter), ('\u{1fc6}', '\u{1fcc}', WC_ALetter), ('\u{1fd0}', '\u{1fd3}', WC_ALetter),
- ('\u{1fd6}', '\u{1fdb}', WC_ALetter), ('\u{1fe0}', '\u{1fec}', WC_ALetter), ('\u{1ff2}',
- '\u{1ff4}', WC_ALetter), ('\u{1ff6}', '\u{1ffc}', WC_ALetter), ('\u{2000}', '\u{2006}',
- WC_WSegSpace), ('\u{2008}', '\u{200a}', WC_WSegSpace), ('\u{200c}', '\u{200c}', WC_Extend),
- ('\u{200d}', '\u{200d}', WC_ZWJ), ('\u{200e}', '\u{200f}', WC_Format), ('\u{2018}',
- '\u{2019}', WC_MidNumLet), ('\u{2024}', '\u{2024}', WC_MidNumLet), ('\u{2027}', '\u{2027}',
- WC_MidLetter), ('\u{2028}', '\u{2029}', WC_Newline), ('\u{202a}', '\u{202e}', WC_Format),
- ('\u{202f}', '\u{202f}', WC_ExtendNumLet), ('\u{203f}', '\u{2040}', WC_ExtendNumLet),
- ('\u{2044}', '\u{2044}', WC_MidNum), ('\u{2054}', '\u{2054}', WC_ExtendNumLet), ('\u{205f}',
- '\u{205f}', WC_WSegSpace), ('\u{2060}', '\u{2064}', WC_Format), ('\u{2066}', '\u{206f}',
- WC_Format), ('\u{2071}', '\u{2071}', WC_ALetter), ('\u{207f}', '\u{207f}', WC_ALetter),
- ('\u{2090}', '\u{209c}', WC_ALetter), ('\u{20d0}', '\u{20f0}', WC_Extend), ('\u{2102}',
- '\u{2102}', WC_ALetter), ('\u{2107}', '\u{2107}', WC_ALetter), ('\u{210a}', '\u{2113}',
- WC_ALetter), ('\u{2115}', '\u{2115}', WC_ALetter), ('\u{2119}', '\u{211d}', WC_ALetter),
- ('\u{2124}', '\u{2124}', WC_ALetter), ('\u{2126}', '\u{2126}', WC_ALetter), ('\u{2128}',
- '\u{2128}', WC_ALetter), ('\u{212a}', '\u{212d}', WC_ALetter), ('\u{212f}', '\u{2139}',
- WC_ALetter), ('\u{213c}', '\u{213f}', WC_ALetter), ('\u{2145}', '\u{2149}', WC_ALetter),
- ('\u{214e}', '\u{214e}', WC_ALetter), ('\u{2160}', '\u{2188}', WC_ALetter), ('\u{24b6}',
- '\u{24e9}', WC_ALetter), ('\u{2c00}', '\u{2c2e}', WC_ALetter), ('\u{2c30}', '\u{2c5e}',
- WC_ALetter), ('\u{2c60}', '\u{2ce4}', WC_ALetter), ('\u{2ceb}', '\u{2cee}', WC_ALetter),
- ('\u{2cef}', '\u{2cf1}', WC_Extend), ('\u{2cf2}', '\u{2cf3}', WC_ALetter), ('\u{2d00}',
- '\u{2d25}', WC_ALetter), ('\u{2d27}', '\u{2d27}', WC_ALetter), ('\u{2d2d}', '\u{2d2d}',
- WC_ALetter), ('\u{2d30}', '\u{2d67}', WC_ALetter), ('\u{2d6f}', '\u{2d6f}', WC_ALetter),
- ('\u{2d7f}', '\u{2d7f}', WC_Extend), ('\u{2d80}', '\u{2d96}', WC_ALetter), ('\u{2da0}',
- '\u{2da6}', WC_ALetter), ('\u{2da8}', '\u{2dae}', WC_ALetter), ('\u{2db0}', '\u{2db6}',
- WC_ALetter), ('\u{2db8}', '\u{2dbe}', WC_ALetter), ('\u{2dc0}', '\u{2dc6}', WC_ALetter),
- ('\u{2dc8}', '\u{2dce}', WC_ALetter), ('\u{2dd0}', '\u{2dd6}', WC_ALetter), ('\u{2dd8}',
- '\u{2dde}', WC_ALetter), ('\u{2de0}', '\u{2dff}', WC_Extend), ('\u{2e2f}', '\u{2e2f}',
- WC_ALetter), ('\u{3000}', '\u{3000}', WC_WSegSpace), ('\u{3005}', '\u{3005}', WC_ALetter),
- ('\u{302a}', '\u{302f}', WC_Extend), ('\u{3031}', '\u{3035}', WC_Katakana), ('\u{303b}',
- '\u{303c}', WC_ALetter), ('\u{3099}', '\u{309a}', WC_Extend), ('\u{309b}', '\u{309c}',
- WC_Katakana), ('\u{30a0}', '\u{30fa}', WC_Katakana), ('\u{30fc}', '\u{30ff}', WC_Katakana),
- ('\u{3105}', '\u{312f}', WC_ALetter), ('\u{3131}', '\u{318e}', WC_ALetter), ('\u{31a0}',
- '\u{31ba}', WC_ALetter), ('\u{31f0}', '\u{31ff}', WC_Katakana), ('\u{32d0}', '\u{32fe}',
- WC_Katakana), ('\u{3300}', '\u{3357}', WC_Katakana), ('\u{a000}', '\u{a48c}', WC_ALetter),
- ('\u{a4d0}', '\u{a4fd}', WC_ALetter), ('\u{a500}', '\u{a60c}', WC_ALetter), ('\u{a610}',
- '\u{a61f}', WC_ALetter), ('\u{a620}', '\u{a629}', WC_Numeric), ('\u{a62a}', '\u{a62b}',
- WC_ALetter), ('\u{a640}', '\u{a66e}', WC_ALetter), ('\u{a66f}', '\u{a672}', WC_Extend),
- ('\u{a674}', '\u{a67d}', WC_Extend), ('\u{a67f}', '\u{a69d}', WC_ALetter), ('\u{a69e}',
- '\u{a69f}', WC_Extend), ('\u{a6a0}', '\u{a6ef}', WC_ALetter), ('\u{a6f0}', '\u{a6f1}',
- WC_Extend), ('\u{a717}', '\u{a7bf}', WC_ALetter), ('\u{a7c2}', '\u{a7c6}', WC_ALetter),
- ('\u{a7f7}', '\u{a801}', WC_ALetter), ('\u{a802}', '\u{a802}', WC_Extend), ('\u{a803}',
- '\u{a805}', WC_ALetter), ('\u{a806}', '\u{a806}', WC_Extend), ('\u{a807}', '\u{a80a}',
- WC_ALetter), ('\u{a80b}', '\u{a80b}', WC_Extend), ('\u{a80c}', '\u{a822}', WC_ALetter),
- ('\u{a823}', '\u{a827}', WC_Extend), ('\u{a840}', '\u{a873}', WC_ALetter), ('\u{a880}',
- '\u{a881}', WC_Extend), ('\u{a882}', '\u{a8b3}', WC_ALetter), ('\u{a8b4}', '\u{a8c5}',
- WC_Extend), ('\u{a8d0}', '\u{a8d9}', WC_Numeric), ('\u{a8e0}', '\u{a8f1}', WC_Extend),
- ('\u{a8f2}', '\u{a8f7}', WC_ALetter), ('\u{a8fb}', '\u{a8fb}', WC_ALetter), ('\u{a8fd}',
- '\u{a8fe}', WC_ALetter), ('\u{a8ff}', '\u{a8ff}', WC_Extend), ('\u{a900}', '\u{a909}',
- WC_Numeric), ('\u{a90a}', '\u{a925}', WC_ALetter), ('\u{a926}', '\u{a92d}', WC_Extend),
- ('\u{a930}', '\u{a946}', WC_ALetter), ('\u{a947}', '\u{a953}', WC_Extend), ('\u{a960}',
- '\u{a97c}', WC_ALetter), ('\u{a980}', '\u{a983}', WC_Extend), ('\u{a984}', '\u{a9b2}',
- WC_ALetter), ('\u{a9b3}', '\u{a9c0}', WC_Extend), ('\u{a9cf}', '\u{a9cf}', WC_ALetter),
- ('\u{a9d0}', '\u{a9d9}', WC_Numeric), ('\u{a9e5}', '\u{a9e5}', WC_Extend), ('\u{a9f0}',
- '\u{a9f9}', WC_Numeric), ('\u{aa00}', '\u{aa28}', WC_ALetter), ('\u{aa29}', '\u{aa36}',
- WC_Extend), ('\u{aa40}', '\u{aa42}', WC_ALetter), ('\u{aa43}', '\u{aa43}', WC_Extend),
- ('\u{aa44}', '\u{aa4b}', WC_ALetter), ('\u{aa4c}', '\u{aa4d}', WC_Extend), ('\u{aa50}',
- '\u{aa59}', WC_Numeric), ('\u{aa7b}', '\u{aa7d}', WC_Extend), ('\u{aab0}', '\u{aab0}',
- WC_Extend), ('\u{aab2}', '\u{aab4}', WC_Extend), ('\u{aab7}', '\u{aab8}', WC_Extend),
- ('\u{aabe}', '\u{aabf}', WC_Extend), ('\u{aac1}', '\u{aac1}', WC_Extend), ('\u{aae0}',
- '\u{aaea}', WC_ALetter), ('\u{aaeb}', '\u{aaef}', WC_Extend), ('\u{aaf2}', '\u{aaf4}',
- WC_ALetter), ('\u{aaf5}', '\u{aaf6}', WC_Extend), ('\u{ab01}', '\u{ab06}', WC_ALetter),
- ('\u{ab09}', '\u{ab0e}', WC_ALetter), ('\u{ab11}', '\u{ab16}', WC_ALetter), ('\u{ab20}',
- '\u{ab26}', WC_ALetter), ('\u{ab28}', '\u{ab2e}', WC_ALetter), ('\u{ab30}', '\u{ab67}',
- WC_ALetter), ('\u{ab70}', '\u{abe2}', WC_ALetter), ('\u{abe3}', '\u{abea}', WC_Extend),
- ('\u{abec}', '\u{abed}', WC_Extend), ('\u{abf0}', '\u{abf9}', WC_Numeric), ('\u{ac00}',
- '\u{d7a3}', WC_ALetter), ('\u{d7b0}', '\u{d7c6}', WC_ALetter), ('\u{d7cb}', '\u{d7fb}',
- WC_ALetter), ('\u{fb00}', '\u{fb06}', WC_ALetter), ('\u{fb13}', '\u{fb17}', WC_ALetter),
- ('\u{fb1d}', '\u{fb1d}', WC_Hebrew_Letter), ('\u{fb1e}', '\u{fb1e}', WC_Extend),
- ('\u{fb1f}', '\u{fb28}', WC_Hebrew_Letter), ('\u{fb2a}', '\u{fb36}', WC_Hebrew_Letter),
- ('\u{fb38}', '\u{fb3c}', WC_Hebrew_Letter), ('\u{fb3e}', '\u{fb3e}', WC_Hebrew_Letter),
- ('\u{fb40}', '\u{fb41}', WC_Hebrew_Letter), ('\u{fb43}', '\u{fb44}', WC_Hebrew_Letter),
- ('\u{fb46}', '\u{fb4f}', WC_Hebrew_Letter), ('\u{fb50}', '\u{fbb1}', WC_ALetter),
- ('\u{fbd3}', '\u{fd3d}', WC_ALetter), ('\u{fd50}', '\u{fd8f}', WC_ALetter), ('\u{fd92}',
- '\u{fdc7}', WC_ALetter), ('\u{fdf0}', '\u{fdfb}', WC_ALetter), ('\u{fe00}', '\u{fe0f}',
- WC_Extend), ('\u{fe10}', '\u{fe10}', WC_MidNum), ('\u{fe13}', '\u{fe13}', WC_MidLetter),
- ('\u{fe14}', '\u{fe14}', WC_MidNum), ('\u{fe20}', '\u{fe2f}', WC_Extend), ('\u{fe33}',
- '\u{fe34}', WC_ExtendNumLet), ('\u{fe4d}', '\u{fe4f}', WC_ExtendNumLet), ('\u{fe50}',
- '\u{fe50}', WC_MidNum), ('\u{fe52}', '\u{fe52}', WC_MidNumLet), ('\u{fe54}', '\u{fe54}',
- WC_MidNum), ('\u{fe55}', '\u{fe55}', WC_MidLetter), ('\u{fe70}', '\u{fe74}', WC_ALetter),
- ('\u{fe76}', '\u{fefc}', WC_ALetter), ('\u{feff}', '\u{feff}', WC_Format), ('\u{ff07}',
- '\u{ff07}', WC_MidNumLet), ('\u{ff0c}', '\u{ff0c}', WC_MidNum), ('\u{ff0e}', '\u{ff0e}',
- WC_MidNumLet), ('\u{ff10}', '\u{ff19}', WC_Numeric), ('\u{ff1a}', '\u{ff1a}', WC_MidLetter),
- ('\u{ff1b}', '\u{ff1b}', WC_MidNum), ('\u{ff21}', '\u{ff3a}', WC_ALetter), ('\u{ff3f}',
- '\u{ff3f}', WC_ExtendNumLet), ('\u{ff41}', '\u{ff5a}', WC_ALetter), ('\u{ff66}', '\u{ff9d}',
- WC_Katakana), ('\u{ff9e}', '\u{ff9f}', WC_Extend), ('\u{ffa0}', '\u{ffbe}', WC_ALetter),
- ('\u{ffc2}', '\u{ffc7}', WC_ALetter), ('\u{ffca}', '\u{ffcf}', WC_ALetter), ('\u{ffd2}',
- '\u{ffd7}', WC_ALetter), ('\u{ffda}', '\u{ffdc}', WC_ALetter), ('\u{fff9}', '\u{fffb}',
- WC_Format), ('\u{10000}', '\u{1000b}', WC_ALetter), ('\u{1000d}', '\u{10026}', WC_ALetter),
- ('\u{10028}', '\u{1003a}', WC_ALetter), ('\u{1003c}', '\u{1003d}', WC_ALetter),
- ('\u{1003f}', '\u{1004d}', WC_ALetter), ('\u{10050}', '\u{1005d}', WC_ALetter),
- ('\u{10080}', '\u{100fa}', WC_ALetter), ('\u{10140}', '\u{10174}', WC_ALetter),
- ('\u{101fd}', '\u{101fd}', WC_Extend), ('\u{10280}', '\u{1029c}', WC_ALetter), ('\u{102a0}',
- '\u{102d0}', WC_ALetter), ('\u{102e0}', '\u{102e0}', WC_Extend), ('\u{10300}', '\u{1031f}',
- WC_ALetter), ('\u{1032d}', '\u{1034a}', WC_ALetter), ('\u{10350}', '\u{10375}', WC_ALetter),
- ('\u{10376}', '\u{1037a}', WC_Extend), ('\u{10380}', '\u{1039d}', WC_ALetter), ('\u{103a0}',
- '\u{103c3}', WC_ALetter), ('\u{103c8}', '\u{103cf}', WC_ALetter), ('\u{103d1}', '\u{103d5}',
- WC_ALetter), ('\u{10400}', '\u{1049d}', WC_ALetter), ('\u{104a0}', '\u{104a9}', WC_Numeric),
- ('\u{104b0}', '\u{104d3}', WC_ALetter), ('\u{104d8}', '\u{104fb}', WC_ALetter),
- ('\u{10500}', '\u{10527}', WC_ALetter), ('\u{10530}', '\u{10563}', WC_ALetter),
- ('\u{10600}', '\u{10736}', WC_ALetter), ('\u{10740}', '\u{10755}', WC_ALetter),
- ('\u{10760}', '\u{10767}', WC_ALetter), ('\u{10800}', '\u{10805}', WC_ALetter),
- ('\u{10808}', '\u{10808}', WC_ALetter), ('\u{1080a}', '\u{10835}', WC_ALetter),
- ('\u{10837}', '\u{10838}', WC_ALetter), ('\u{1083c}', '\u{1083c}', WC_ALetter),
- ('\u{1083f}', '\u{10855}', WC_ALetter), ('\u{10860}', '\u{10876}', WC_ALetter),
- ('\u{10880}', '\u{1089e}', WC_ALetter), ('\u{108e0}', '\u{108f2}', WC_ALetter),
- ('\u{108f4}', '\u{108f5}', WC_ALetter), ('\u{10900}', '\u{10915}', WC_ALetter),
- ('\u{10920}', '\u{10939}', WC_ALetter), ('\u{10980}', '\u{109b7}', WC_ALetter),
- ('\u{109be}', '\u{109bf}', WC_ALetter), ('\u{10a00}', '\u{10a00}', WC_ALetter),
- ('\u{10a01}', '\u{10a03}', WC_Extend), ('\u{10a05}', '\u{10a06}', WC_Extend), ('\u{10a0c}',
- '\u{10a0f}', WC_Extend), ('\u{10a10}', '\u{10a13}', WC_ALetter), ('\u{10a15}', '\u{10a17}',
- WC_ALetter), ('\u{10a19}', '\u{10a35}', WC_ALetter), ('\u{10a38}', '\u{10a3a}', WC_Extend),
- ('\u{10a3f}', '\u{10a3f}', WC_Extend), ('\u{10a60}', '\u{10a7c}', WC_ALetter), ('\u{10a80}',
- '\u{10a9c}', WC_ALetter), ('\u{10ac0}', '\u{10ac7}', WC_ALetter), ('\u{10ac9}', '\u{10ae4}',
- WC_ALetter), ('\u{10ae5}', '\u{10ae6}', WC_Extend), ('\u{10b00}', '\u{10b35}', WC_ALetter),
- ('\u{10b40}', '\u{10b55}', WC_ALetter), ('\u{10b60}', '\u{10b72}', WC_ALetter),
- ('\u{10b80}', '\u{10b91}', WC_ALetter), ('\u{10c00}', '\u{10c48}', WC_ALetter),
- ('\u{10c80}', '\u{10cb2}', WC_ALetter), ('\u{10cc0}', '\u{10cf2}', WC_ALetter),
- ('\u{10d00}', '\u{10d23}', WC_ALetter), ('\u{10d24}', '\u{10d27}', WC_Extend), ('\u{10d30}',
- '\u{10d39}', WC_Numeric), ('\u{10f00}', '\u{10f1c}', WC_ALetter), ('\u{10f27}', '\u{10f27}',
- WC_ALetter), ('\u{10f30}', '\u{10f45}', WC_ALetter), ('\u{10f46}', '\u{10f50}', WC_Extend),
- ('\u{10fe0}', '\u{10ff6}', WC_ALetter), ('\u{11000}', '\u{11002}', WC_Extend), ('\u{11003}',
- '\u{11037}', WC_ALetter), ('\u{11038}', '\u{11046}', WC_Extend), ('\u{11066}', '\u{1106f}',
- WC_Numeric), ('\u{1107f}', '\u{11082}', WC_Extend), ('\u{11083}', '\u{110af}', WC_ALetter),
- ('\u{110b0}', '\u{110ba}', WC_Extend), ('\u{110bd}', '\u{110bd}', WC_Format), ('\u{110cd}',
- '\u{110cd}', WC_Format), ('\u{110d0}', '\u{110e8}', WC_ALetter), ('\u{110f0}', '\u{110f9}',
- WC_Numeric), ('\u{11100}', '\u{11102}', WC_Extend), ('\u{11103}', '\u{11126}', WC_ALetter),
- ('\u{11127}', '\u{11134}', WC_Extend), ('\u{11136}', '\u{1113f}', WC_Numeric), ('\u{11144}',
- '\u{11144}', WC_ALetter), ('\u{11145}', '\u{11146}', WC_Extend), ('\u{11150}', '\u{11172}',
- WC_ALetter), ('\u{11173}', '\u{11173}', WC_Extend), ('\u{11176}', '\u{11176}', WC_ALetter),
- ('\u{11180}', '\u{11182}', WC_Extend), ('\u{11183}', '\u{111b2}', WC_ALetter), ('\u{111b3}',
- '\u{111c0}', WC_Extend), ('\u{111c1}', '\u{111c4}', WC_ALetter), ('\u{111c9}', '\u{111cc}',
- WC_Extend), ('\u{111d0}', '\u{111d9}', WC_Numeric), ('\u{111da}', '\u{111da}', WC_ALetter),
- ('\u{111dc}', '\u{111dc}', WC_ALetter), ('\u{11200}', '\u{11211}', WC_ALetter),
- ('\u{11213}', '\u{1122b}', WC_ALetter), ('\u{1122c}', '\u{11237}', WC_Extend), ('\u{1123e}',
- '\u{1123e}', WC_Extend), ('\u{11280}', '\u{11286}', WC_ALetter), ('\u{11288}', '\u{11288}',
- WC_ALetter), ('\u{1128a}', '\u{1128d}', WC_ALetter), ('\u{1128f}', '\u{1129d}', WC_ALetter),
- ('\u{1129f}', '\u{112a8}', WC_ALetter), ('\u{112b0}', '\u{112de}', WC_ALetter),
- ('\u{112df}', '\u{112ea}', WC_Extend), ('\u{112f0}', '\u{112f9}', WC_Numeric), ('\u{11300}',
- '\u{11303}', WC_Extend), ('\u{11305}', '\u{1130c}', WC_ALetter), ('\u{1130f}', '\u{11310}',
- WC_ALetter), ('\u{11313}', '\u{11328}', WC_ALetter), ('\u{1132a}', '\u{11330}', WC_ALetter),
- ('\u{11332}', '\u{11333}', WC_ALetter), ('\u{11335}', '\u{11339}', WC_ALetter),
- ('\u{1133b}', '\u{1133c}', WC_Extend), ('\u{1133d}', '\u{1133d}', WC_ALetter), ('\u{1133e}',
- '\u{11344}', WC_Extend), ('\u{11347}', '\u{11348}', WC_Extend), ('\u{1134b}', '\u{1134d}',
- WC_Extend), ('\u{11350}', '\u{11350}', WC_ALetter), ('\u{11357}', '\u{11357}', WC_Extend),
- ('\u{1135d}', '\u{11361}', WC_ALetter), ('\u{11362}', '\u{11363}', WC_Extend), ('\u{11366}',
- '\u{1136c}', WC_Extend), ('\u{11370}', '\u{11374}', WC_Extend), ('\u{11400}', '\u{11434}',
- WC_ALetter), ('\u{11435}', '\u{11446}', WC_Extend), ('\u{11447}', '\u{1144a}', WC_ALetter),
- ('\u{11450}', '\u{11459}', WC_Numeric), ('\u{1145e}', '\u{1145e}', WC_Extend), ('\u{1145f}',
- '\u{1145f}', WC_ALetter), ('\u{11480}', '\u{114af}', WC_ALetter), ('\u{114b0}', '\u{114c3}',
- WC_Extend), ('\u{114c4}', '\u{114c5}', WC_ALetter), ('\u{114c7}', '\u{114c7}', WC_ALetter),
- ('\u{114d0}', '\u{114d9}', WC_Numeric), ('\u{11580}', '\u{115ae}', WC_ALetter),
- ('\u{115af}', '\u{115b5}', WC_Extend), ('\u{115b8}', '\u{115c0}', WC_Extend), ('\u{115d8}',
- '\u{115db}', WC_ALetter), ('\u{115dc}', '\u{115dd}', WC_Extend), ('\u{11600}', '\u{1162f}',
- WC_ALetter), ('\u{11630}', '\u{11640}', WC_Extend), ('\u{11644}', '\u{11644}', WC_ALetter),
- ('\u{11650}', '\u{11659}', WC_Numeric), ('\u{11680}', '\u{116aa}', WC_ALetter),
- ('\u{116ab}', '\u{116b7}', WC_Extend), ('\u{116b8}', '\u{116b8}', WC_ALetter), ('\u{116c0}',
- '\u{116c9}', WC_Numeric), ('\u{1171d}', '\u{1172b}', WC_Extend), ('\u{11730}', '\u{11739}',
- WC_Numeric), ('\u{11800}', '\u{1182b}', WC_ALetter), ('\u{1182c}', '\u{1183a}', WC_Extend),
- ('\u{118a0}', '\u{118df}', WC_ALetter), ('\u{118e0}', '\u{118e9}', WC_Numeric),
- ('\u{118ff}', '\u{118ff}', WC_ALetter), ('\u{119a0}', '\u{119a7}', WC_ALetter),
- ('\u{119aa}', '\u{119d0}', WC_ALetter), ('\u{119d1}', '\u{119d7}', WC_Extend), ('\u{119da}',
- '\u{119e0}', WC_Extend), ('\u{119e1}', '\u{119e1}', WC_ALetter), ('\u{119e3}', '\u{119e3}',
- WC_ALetter), ('\u{119e4}', '\u{119e4}', WC_Extend), ('\u{11a00}', '\u{11a00}', WC_ALetter),
- ('\u{11a01}', '\u{11a0a}', WC_Extend), ('\u{11a0b}', '\u{11a32}', WC_ALetter), ('\u{11a33}',
- '\u{11a39}', WC_Extend), ('\u{11a3a}', '\u{11a3a}', WC_ALetter), ('\u{11a3b}', '\u{11a3e}',
- WC_Extend), ('\u{11a47}', '\u{11a47}', WC_Extend), ('\u{11a50}', '\u{11a50}', WC_ALetter),
- ('\u{11a51}', '\u{11a5b}', WC_Extend), ('\u{11a5c}', '\u{11a89}', WC_ALetter), ('\u{11a8a}',
- '\u{11a99}', WC_Extend), ('\u{11a9d}', '\u{11a9d}', WC_ALetter), ('\u{11ac0}', '\u{11af8}',
- WC_ALetter), ('\u{11c00}', '\u{11c08}', WC_ALetter), ('\u{11c0a}', '\u{11c2e}', WC_ALetter),
- ('\u{11c2f}', '\u{11c36}', WC_Extend), ('\u{11c38}', '\u{11c3f}', WC_Extend), ('\u{11c40}',
- '\u{11c40}', WC_ALetter), ('\u{11c50}', '\u{11c59}', WC_Numeric), ('\u{11c72}', '\u{11c8f}',
- WC_ALetter), ('\u{11c92}', '\u{11ca7}', WC_Extend), ('\u{11ca9}', '\u{11cb6}', WC_Extend),
- ('\u{11d00}', '\u{11d06}', WC_ALetter), ('\u{11d08}', '\u{11d09}', WC_ALetter),
- ('\u{11d0b}', '\u{11d30}', WC_ALetter), ('\u{11d31}', '\u{11d36}', WC_Extend), ('\u{11d3a}',
- '\u{11d3a}', WC_Extend), ('\u{11d3c}', '\u{11d3d}', WC_Extend), ('\u{11d3f}', '\u{11d45}',
- WC_Extend), ('\u{11d46}', '\u{11d46}', WC_ALetter), ('\u{11d47}', '\u{11d47}', WC_Extend),
- ('\u{11d50}', '\u{11d59}', WC_Numeric), ('\u{11d60}', '\u{11d65}', WC_ALetter),
- ('\u{11d67}', '\u{11d68}', WC_ALetter), ('\u{11d6a}', '\u{11d89}', WC_ALetter),
- ('\u{11d8a}', '\u{11d8e}', WC_Extend), ('\u{11d90}', '\u{11d91}', WC_Extend), ('\u{11d93}',
- '\u{11d97}', WC_Extend), ('\u{11d98}', '\u{11d98}', WC_ALetter), ('\u{11da0}', '\u{11da9}',
- WC_Numeric), ('\u{11ee0}', '\u{11ef2}', WC_ALetter), ('\u{11ef3}', '\u{11ef6}', WC_Extend),
- ('\u{12000}', '\u{12399}', WC_ALetter), ('\u{12400}', '\u{1246e}', WC_ALetter),
- ('\u{12480}', '\u{12543}', WC_ALetter), ('\u{13000}', '\u{1342e}', WC_ALetter),
- ('\u{13430}', '\u{13438}', WC_Format), ('\u{14400}', '\u{14646}', WC_ALetter), ('\u{16800}',
- '\u{16a38}', WC_ALetter), ('\u{16a40}', '\u{16a5e}', WC_ALetter), ('\u{16a60}', '\u{16a69}',
- WC_Numeric), ('\u{16ad0}', '\u{16aed}', WC_ALetter), ('\u{16af0}', '\u{16af4}', WC_Extend),
- ('\u{16b00}', '\u{16b2f}', WC_ALetter), ('\u{16b30}', '\u{16b36}', WC_Extend), ('\u{16b40}',
- '\u{16b43}', WC_ALetter), ('\u{16b50}', '\u{16b59}', WC_Numeric), ('\u{16b63}', '\u{16b77}',
- WC_ALetter), ('\u{16b7d}', '\u{16b8f}', WC_ALetter), ('\u{16e40}', '\u{16e7f}', WC_ALetter),
- ('\u{16f00}', '\u{16f4a}', WC_ALetter), ('\u{16f4f}', '\u{16f4f}', WC_Extend), ('\u{16f50}',
- '\u{16f50}', WC_ALetter), ('\u{16f51}', '\u{16f87}', WC_Extend), ('\u{16f8f}', '\u{16f92}',
- WC_Extend), ('\u{16f93}', '\u{16f9f}', WC_ALetter), ('\u{16fe0}', '\u{16fe1}', WC_ALetter),
- ('\u{16fe3}', '\u{16fe3}', WC_ALetter), ('\u{1b000}', '\u{1b000}', WC_Katakana),
- ('\u{1b164}', '\u{1b167}', WC_Katakana), ('\u{1bc00}', '\u{1bc6a}', WC_ALetter),
- ('\u{1bc70}', '\u{1bc7c}', WC_ALetter), ('\u{1bc80}', '\u{1bc88}', WC_ALetter),
- ('\u{1bc90}', '\u{1bc99}', WC_ALetter), ('\u{1bc9d}', '\u{1bc9e}', WC_Extend), ('\u{1bca0}',
- '\u{1bca3}', WC_Format), ('\u{1d165}', '\u{1d169}', WC_Extend), ('\u{1d16d}', '\u{1d172}',
- WC_Extend), ('\u{1d173}', '\u{1d17a}', WC_Format), ('\u{1d17b}', '\u{1d182}', WC_Extend),
- ('\u{1d185}', '\u{1d18b}', WC_Extend), ('\u{1d1aa}', '\u{1d1ad}', WC_Extend), ('\u{1d242}',
- '\u{1d244}', WC_Extend), ('\u{1d400}', '\u{1d454}', WC_ALetter), ('\u{1d456}', '\u{1d49c}',
- WC_ALetter), ('\u{1d49e}', '\u{1d49f}', WC_ALetter), ('\u{1d4a2}', '\u{1d4a2}', WC_ALetter),
- ('\u{1d4a5}', '\u{1d4a6}', WC_ALetter), ('\u{1d4a9}', '\u{1d4ac}', WC_ALetter),
- ('\u{1d4ae}', '\u{1d4b9}', WC_ALetter), ('\u{1d4bb}', '\u{1d4bb}', WC_ALetter),
- ('\u{1d4bd}', '\u{1d4c3}', WC_ALetter), ('\u{1d4c5}', '\u{1d505}', WC_ALetter),
- ('\u{1d507}', '\u{1d50a}', WC_ALetter), ('\u{1d50d}', '\u{1d514}', WC_ALetter),
- ('\u{1d516}', '\u{1d51c}', WC_ALetter), ('\u{1d51e}', '\u{1d539}', WC_ALetter),
- ('\u{1d53b}', '\u{1d53e}', WC_ALetter), ('\u{1d540}', '\u{1d544}', WC_ALetter),
- ('\u{1d546}', '\u{1d546}', WC_ALetter), ('\u{1d54a}', '\u{1d550}', WC_ALetter),
- ('\u{1d552}', '\u{1d6a5}', WC_ALetter), ('\u{1d6a8}', '\u{1d6c0}', WC_ALetter),
- ('\u{1d6c2}', '\u{1d6da}', WC_ALetter), ('\u{1d6dc}', '\u{1d6fa}', WC_ALetter),
- ('\u{1d6fc}', '\u{1d714}', WC_ALetter), ('\u{1d716}', '\u{1d734}', WC_ALetter),
- ('\u{1d736}', '\u{1d74e}', WC_ALetter), ('\u{1d750}', '\u{1d76e}', WC_ALetter),
- ('\u{1d770}', '\u{1d788}', WC_ALetter), ('\u{1d78a}', '\u{1d7a8}', WC_ALetter),
- ('\u{1d7aa}', '\u{1d7c2}', WC_ALetter), ('\u{1d7c4}', '\u{1d7cb}', WC_ALetter),
- ('\u{1d7ce}', '\u{1d7ff}', WC_Numeric), ('\u{1da00}', '\u{1da36}', WC_Extend), ('\u{1da3b}',
- '\u{1da6c}', WC_Extend), ('\u{1da75}', '\u{1da75}', WC_Extend), ('\u{1da84}', '\u{1da84}',
- WC_Extend), ('\u{1da9b}', '\u{1da9f}', WC_Extend), ('\u{1daa1}', '\u{1daaf}', WC_Extend),
- ('\u{1e000}', '\u{1e006}', WC_Extend), ('\u{1e008}', '\u{1e018}', WC_Extend), ('\u{1e01b}',
- '\u{1e021}', WC_Extend), ('\u{1e023}', '\u{1e024}', WC_Extend), ('\u{1e026}', '\u{1e02a}',
- WC_Extend), ('\u{1e100}', '\u{1e12c}', WC_ALetter), ('\u{1e130}', '\u{1e136}', WC_Extend),
- ('\u{1e137}', '\u{1e13d}', WC_ALetter), ('\u{1e140}', '\u{1e149}', WC_Numeric),
- ('\u{1e14e}', '\u{1e14e}', WC_ALetter), ('\u{1e2c0}', '\u{1e2eb}', WC_ALetter),
- ('\u{1e2ec}', '\u{1e2ef}', WC_Extend), ('\u{1e2f0}', '\u{1e2f9}', WC_Numeric), ('\u{1e800}',
- '\u{1e8c4}', WC_ALetter), ('\u{1e8d0}', '\u{1e8d6}', WC_Extend), ('\u{1e900}', '\u{1e943}',
- WC_ALetter), ('\u{1e944}', '\u{1e94a}', WC_Extend), ('\u{1e94b}', '\u{1e94b}', WC_ALetter),
- ('\u{1e950}', '\u{1e959}', WC_Numeric), ('\u{1ee00}', '\u{1ee03}', WC_ALetter),
- ('\u{1ee05}', '\u{1ee1f}', WC_ALetter), ('\u{1ee21}', '\u{1ee22}', WC_ALetter),
- ('\u{1ee24}', '\u{1ee24}', WC_ALetter), ('\u{1ee27}', '\u{1ee27}', WC_ALetter),
- ('\u{1ee29}', '\u{1ee32}', WC_ALetter), ('\u{1ee34}', '\u{1ee37}', WC_ALetter),
- ('\u{1ee39}', '\u{1ee39}', WC_ALetter), ('\u{1ee3b}', '\u{1ee3b}', WC_ALetter),
- ('\u{1ee42}', '\u{1ee42}', WC_ALetter), ('\u{1ee47}', '\u{1ee47}', WC_ALetter),
- ('\u{1ee49}', '\u{1ee49}', WC_ALetter), ('\u{1ee4b}', '\u{1ee4b}', WC_ALetter),
- ('\u{1ee4d}', '\u{1ee4f}', WC_ALetter), ('\u{1ee51}', '\u{1ee52}', WC_ALetter),
- ('\u{1ee54}', '\u{1ee54}', WC_ALetter), ('\u{1ee57}', '\u{1ee57}', WC_ALetter),
- ('\u{1ee59}', '\u{1ee59}', WC_ALetter), ('\u{1ee5b}', '\u{1ee5b}', WC_ALetter),
- ('\u{1ee5d}', '\u{1ee5d}', WC_ALetter), ('\u{1ee5f}', '\u{1ee5f}', WC_ALetter),
- ('\u{1ee61}', '\u{1ee62}', WC_ALetter), ('\u{1ee64}', '\u{1ee64}', WC_ALetter),
- ('\u{1ee67}', '\u{1ee6a}', WC_ALetter), ('\u{1ee6c}', '\u{1ee72}', WC_ALetter),
- ('\u{1ee74}', '\u{1ee77}', WC_ALetter), ('\u{1ee79}', '\u{1ee7c}', WC_ALetter),
- ('\u{1ee7e}', '\u{1ee7e}', WC_ALetter), ('\u{1ee80}', '\u{1ee89}', WC_ALetter),
- ('\u{1ee8b}', '\u{1ee9b}', WC_ALetter), ('\u{1eea1}', '\u{1eea3}', WC_ALetter),
- ('\u{1eea5}', '\u{1eea9}', WC_ALetter), ('\u{1eeab}', '\u{1eebb}', WC_ALetter),
- ('\u{1f130}', '\u{1f149}', WC_ALetter), ('\u{1f150}', '\u{1f169}', WC_ALetter),
- ('\u{1f170}', '\u{1f189}', WC_ALetter), ('\u{1f1e6}', '\u{1f1ff}', WC_Regional_Indicator),
- ('\u{1f3fb}', '\u{1f3ff}', WC_Extend), ('\u{e0001}', '\u{e0001}', WC_Format), ('\u{e0020}',
- '\u{e007f}', WC_Extend), ('\u{e0100}', '\u{e01ef}', WC_Extend)
- ];
-
-}
-pub mod emoji {
- use core::result::Result::{Ok, Err};
-
- pub use self::EmojiCat::*;
-
- #[allow(non_camel_case_types)]
- #[derive(Clone, Copy, PartialEq, Eq, Debug)]
- pub enum EmojiCat {
- EC_Any,
- EC_Extended_Pictographic,
- }
-
- fn bsearch_range_value_table(c: char, r: &'static [(char, char, EmojiCat)]) -> EmojiCat {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, cat) = r[idx];
- cat
- }
- Err(_) => EC_Any
- }
- }
-
- pub fn emoji_category(c: char) -> EmojiCat {
- bsearch_range_value_table(c, emoji_cat_table)
- }
-
- const emoji_cat_table: &'static [(char, char, EmojiCat)] = &[
- ('\u{a9}', '\u{a9}', EC_Extended_Pictographic), ('\u{ae}', '\u{ae}',
- EC_Extended_Pictographic), ('\u{203c}', '\u{203c}', EC_Extended_Pictographic), ('\u{2049}',
- '\u{2049}', EC_Extended_Pictographic), ('\u{2122}', '\u{2122}', EC_Extended_Pictographic),
- ('\u{2139}', '\u{2139}', EC_Extended_Pictographic), ('\u{2194}', '\u{2199}',
- EC_Extended_Pictographic), ('\u{21a9}', '\u{21aa}', EC_Extended_Pictographic), ('\u{231a}',
- '\u{231b}', EC_Extended_Pictographic), ('\u{2328}', '\u{2328}', EC_Extended_Pictographic),
- ('\u{2388}', '\u{2388}', EC_Extended_Pictographic), ('\u{23cf}', '\u{23cf}',
- EC_Extended_Pictographic), ('\u{23e9}', '\u{23f3}', EC_Extended_Pictographic), ('\u{23f8}',
- '\u{23fa}', EC_Extended_Pictographic), ('\u{24c2}', '\u{24c2}', EC_Extended_Pictographic),
- ('\u{25aa}', '\u{25ab}', EC_Extended_Pictographic), ('\u{25b6}', '\u{25b6}',
- EC_Extended_Pictographic), ('\u{25c0}', '\u{25c0}', EC_Extended_Pictographic), ('\u{25fb}',
- '\u{25fe}', EC_Extended_Pictographic), ('\u{2600}', '\u{2605}', EC_Extended_Pictographic),
- ('\u{2607}', '\u{2612}', EC_Extended_Pictographic), ('\u{2614}', '\u{2685}',
- EC_Extended_Pictographic), ('\u{2690}', '\u{2705}', EC_Extended_Pictographic), ('\u{2708}',
- '\u{2712}', EC_Extended_Pictographic), ('\u{2714}', '\u{2714}', EC_Extended_Pictographic),
- ('\u{2716}', '\u{2716}', EC_Extended_Pictographic), ('\u{271d}', '\u{271d}',
- EC_Extended_Pictographic), ('\u{2721}', '\u{2721}', EC_Extended_Pictographic), ('\u{2728}',
- '\u{2728}', EC_Extended_Pictographic), ('\u{2733}', '\u{2734}', EC_Extended_Pictographic),
- ('\u{2744}', '\u{2744}', EC_Extended_Pictographic), ('\u{2747}', '\u{2747}',
- EC_Extended_Pictographic), ('\u{274c}', '\u{274c}', EC_Extended_Pictographic), ('\u{274e}',
- '\u{274e}', EC_Extended_Pictographic), ('\u{2753}', '\u{2755}', EC_Extended_Pictographic),
- ('\u{2757}', '\u{2757}', EC_Extended_Pictographic), ('\u{2763}', '\u{2767}',
- EC_Extended_Pictographic), ('\u{2795}', '\u{2797}', EC_Extended_Pictographic), ('\u{27a1}',
- '\u{27a1}', EC_Extended_Pictographic), ('\u{27b0}', '\u{27b0}', EC_Extended_Pictographic),
- ('\u{27bf}', '\u{27bf}', EC_Extended_Pictographic), ('\u{2934}', '\u{2935}',
- EC_Extended_Pictographic), ('\u{2b05}', '\u{2b07}', EC_Extended_Pictographic), ('\u{2b1b}',
- '\u{2b1c}', EC_Extended_Pictographic), ('\u{2b50}', '\u{2b50}', EC_Extended_Pictographic),
- ('\u{2b55}', '\u{2b55}', EC_Extended_Pictographic), ('\u{3030}', '\u{3030}',
- EC_Extended_Pictographic), ('\u{303d}', '\u{303d}', EC_Extended_Pictographic), ('\u{3297}',
- '\u{3297}', EC_Extended_Pictographic), ('\u{3299}', '\u{3299}', EC_Extended_Pictographic),
- ('\u{1f000}', '\u{1f0ff}', EC_Extended_Pictographic), ('\u{1f10d}', '\u{1f10f}',
- EC_Extended_Pictographic), ('\u{1f12f}', '\u{1f12f}', EC_Extended_Pictographic),
- ('\u{1f16c}', '\u{1f171}', EC_Extended_Pictographic), ('\u{1f17e}', '\u{1f17f}',
- EC_Extended_Pictographic), ('\u{1f18e}', '\u{1f18e}', EC_Extended_Pictographic),
- ('\u{1f191}', '\u{1f19a}', EC_Extended_Pictographic), ('\u{1f1ad}', '\u{1f1e5}',
- EC_Extended_Pictographic), ('\u{1f201}', '\u{1f20f}', EC_Extended_Pictographic),
- ('\u{1f21a}', '\u{1f21a}', EC_Extended_Pictographic), ('\u{1f22f}', '\u{1f22f}',
- EC_Extended_Pictographic), ('\u{1f232}', '\u{1f23a}', EC_Extended_Pictographic),
- ('\u{1f23c}', '\u{1f23f}', EC_Extended_Pictographic), ('\u{1f249}', '\u{1f3fa}',
- EC_Extended_Pictographic), ('\u{1f400}', '\u{1f53d}', EC_Extended_Pictographic),
- ('\u{1f546}', '\u{1f64f}', EC_Extended_Pictographic), ('\u{1f680}', '\u{1f6ff}',
- EC_Extended_Pictographic), ('\u{1f774}', '\u{1f77f}', EC_Extended_Pictographic),
- ('\u{1f7d5}', '\u{1f7ff}', EC_Extended_Pictographic), ('\u{1f80c}', '\u{1f80f}',
- EC_Extended_Pictographic), ('\u{1f848}', '\u{1f84f}', EC_Extended_Pictographic),
- ('\u{1f85a}', '\u{1f85f}', EC_Extended_Pictographic), ('\u{1f888}', '\u{1f88f}',
- EC_Extended_Pictographic), ('\u{1f8ae}', '\u{1f8ff}', EC_Extended_Pictographic),
- ('\u{1f90c}', '\u{1f93a}', EC_Extended_Pictographic), ('\u{1f93c}', '\u{1f945}',
- EC_Extended_Pictographic), ('\u{1f947}', '\u{1fffd}', EC_Extended_Pictographic)
- ];
-
-}
-pub mod sentence {
- use core::result::Result::{Ok, Err};
-
- pub use self::SentenceCat::*;
-
- #[allow(non_camel_case_types)]
- #[derive(Clone, Copy, PartialEq, Eq, Debug)]
- pub enum SentenceCat {
- SC_ATerm,
- SC_Any,
- SC_CR,
- SC_Close,
- SC_Extend,
- SC_Format,
- SC_LF,
- SC_Lower,
- SC_Numeric,
- SC_OLetter,
- SC_SContinue,
- SC_STerm,
- SC_Sep,
- SC_Sp,
- SC_Upper,
- }
-
- fn bsearch_range_value_table(c: char, r: &'static [(char, char, SentenceCat)]) -> SentenceCat {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, cat) = r[idx];
- cat
- }
- Err(_) => SC_Any
- }
- }
-
- pub fn sentence_category(c: char) -> SentenceCat {
- bsearch_range_value_table(c, sentence_cat_table)
- }
-
- const sentence_cat_table: &'static [(char, char, SentenceCat)] = &[
- ('\u{9}', '\u{9}', SC_Sp), ('\u{a}', '\u{a}', SC_LF), ('\u{b}', '\u{c}', SC_Sp), ('\u{d}',
- '\u{d}', SC_CR), ('\u{20}', '\u{20}', SC_Sp), ('\u{21}', '\u{21}', SC_STerm), ('\u{22}',
- '\u{22}', SC_Close), ('\u{27}', '\u{29}', SC_Close), ('\u{2c}', '\u{2d}', SC_SContinue),
- ('\u{2e}', '\u{2e}', SC_ATerm), ('\u{30}', '\u{39}', SC_Numeric), ('\u{3a}', '\u{3a}',
- SC_SContinue), ('\u{3f}', '\u{3f}', SC_STerm), ('\u{41}', '\u{5a}', SC_Upper), ('\u{5b}',
- '\u{5b}', SC_Close), ('\u{5d}', '\u{5d}', SC_Close), ('\u{61}', '\u{7a}', SC_Lower),
- ('\u{7b}', '\u{7b}', SC_Close), ('\u{7d}', '\u{7d}', SC_Close), ('\u{85}', '\u{85}',
- SC_Sep), ('\u{a0}', '\u{a0}', SC_Sp), ('\u{aa}', '\u{aa}', SC_Lower), ('\u{ab}', '\u{ab}',
- SC_Close), ('\u{ad}', '\u{ad}', SC_Format), ('\u{b5}', '\u{b5}', SC_Lower), ('\u{ba}',
- '\u{ba}', SC_Lower), ('\u{bb}', '\u{bb}', SC_Close), ('\u{c0}', '\u{d6}', SC_Upper),
- ('\u{d8}', '\u{de}', SC_Upper), ('\u{df}', '\u{f6}', SC_Lower), ('\u{f8}', '\u{ff}',
- SC_Lower), ('\u{100}', '\u{100}', SC_Upper), ('\u{101}', '\u{101}', SC_Lower), ('\u{102}',
- '\u{102}', SC_Upper), ('\u{103}', '\u{103}', SC_Lower), ('\u{104}', '\u{104}', SC_Upper),
- ('\u{105}', '\u{105}', SC_Lower), ('\u{106}', '\u{106}', SC_Upper), ('\u{107}', '\u{107}',
- SC_Lower), ('\u{108}', '\u{108}', SC_Upper), ('\u{109}', '\u{109}', SC_Lower), ('\u{10a}',
- '\u{10a}', SC_Upper), ('\u{10b}', '\u{10b}', SC_Lower), ('\u{10c}', '\u{10c}', SC_Upper),
- ('\u{10d}', '\u{10d}', SC_Lower), ('\u{10e}', '\u{10e}', SC_Upper), ('\u{10f}', '\u{10f}',
- SC_Lower), ('\u{110}', '\u{110}', SC_Upper), ('\u{111}', '\u{111}', SC_Lower), ('\u{112}',
- '\u{112}', SC_Upper), ('\u{113}', '\u{113}', SC_Lower), ('\u{114}', '\u{114}', SC_Upper),
- ('\u{115}', '\u{115}', SC_Lower), ('\u{116}', '\u{116}', SC_Upper), ('\u{117}', '\u{117}',
- SC_Lower), ('\u{118}', '\u{118}', SC_Upper), ('\u{119}', '\u{119}', SC_Lower), ('\u{11a}',
- '\u{11a}', SC_Upper), ('\u{11b}', '\u{11b}', SC_Lower), ('\u{11c}', '\u{11c}', SC_Upper),
- ('\u{11d}', '\u{11d}', SC_Lower), ('\u{11e}', '\u{11e}', SC_Upper), ('\u{11f}', '\u{11f}',
- SC_Lower), ('\u{120}', '\u{120}', SC_Upper), ('\u{121}', '\u{121}', SC_Lower), ('\u{122}',
- '\u{122}', SC_Upper), ('\u{123}', '\u{123}', SC_Lower), ('\u{124}', '\u{124}', SC_Upper),
- ('\u{125}', '\u{125}', SC_Lower), ('\u{126}', '\u{126}', SC_Upper), ('\u{127}', '\u{127}',
- SC_Lower), ('\u{128}', '\u{128}', SC_Upper), ('\u{129}', '\u{129}', SC_Lower), ('\u{12a}',
- '\u{12a}', SC_Upper), ('\u{12b}', '\u{12b}', SC_Lower), ('\u{12c}', '\u{12c}', SC_Upper),
- ('\u{12d}', '\u{12d}', SC_Lower), ('\u{12e}', '\u{12e}', SC_Upper), ('\u{12f}', '\u{12f}',
- SC_Lower), ('\u{130}', '\u{130}', SC_Upper), ('\u{131}', '\u{131}', SC_Lower), ('\u{132}',
- '\u{132}', SC_Upper), ('\u{133}', '\u{133}', SC_Lower), ('\u{134}', '\u{134}', SC_Upper),
- ('\u{135}', '\u{135}', SC_Lower), ('\u{136}', '\u{136}', SC_Upper), ('\u{137}', '\u{138}',
- SC_Lower), ('\u{139}', '\u{139}', SC_Upper), ('\u{13a}', '\u{13a}', SC_Lower), ('\u{13b}',
- '\u{13b}', SC_Upper), ('\u{13c}', '\u{13c}', SC_Lower), ('\u{13d}', '\u{13d}', SC_Upper),
- ('\u{13e}', '\u{13e}', SC_Lower), ('\u{13f}', '\u{13f}', SC_Upper), ('\u{140}', '\u{140}',
- SC_Lower), ('\u{141}', '\u{141}', SC_Upper), ('\u{142}', '\u{142}', SC_Lower), ('\u{143}',
- '\u{143}', SC_Upper), ('\u{144}', '\u{144}', SC_Lower), ('\u{145}', '\u{145}', SC_Upper),
- ('\u{146}', '\u{146}', SC_Lower), ('\u{147}', '\u{147}', SC_Upper), ('\u{148}', '\u{149}',
- SC_Lower), ('\u{14a}', '\u{14a}', SC_Upper), ('\u{14b}', '\u{14b}', SC_Lower), ('\u{14c}',
- '\u{14c}', SC_Upper), ('\u{14d}', '\u{14d}', SC_Lower), ('\u{14e}', '\u{14e}', SC_Upper),
- ('\u{14f}', '\u{14f}', SC_Lower), ('\u{150}', '\u{150}', SC_Upper), ('\u{151}', '\u{151}',
- SC_Lower), ('\u{152}', '\u{152}', SC_Upper), ('\u{153}', '\u{153}', SC_Lower), ('\u{154}',
- '\u{154}', SC_Upper), ('\u{155}', '\u{155}', SC_Lower), ('\u{156}', '\u{156}', SC_Upper),
- ('\u{157}', '\u{157}', SC_Lower), ('\u{158}', '\u{158}', SC_Upper), ('\u{159}', '\u{159}',
- SC_Lower), ('\u{15a}', '\u{15a}', SC_Upper), ('\u{15b}', '\u{15b}', SC_Lower), ('\u{15c}',
- '\u{15c}', SC_Upper), ('\u{15d}', '\u{15d}', SC_Lower), ('\u{15e}', '\u{15e}', SC_Upper),
- ('\u{15f}', '\u{15f}', SC_Lower), ('\u{160}', '\u{160}', SC_Upper), ('\u{161}', '\u{161}',
- SC_Lower), ('\u{162}', '\u{162}', SC_Upper), ('\u{163}', '\u{163}', SC_Lower), ('\u{164}',
- '\u{164}', SC_Upper), ('\u{165}', '\u{165}', SC_Lower), ('\u{166}', '\u{166}', SC_Upper),
- ('\u{167}', '\u{167}', SC_Lower), ('\u{168}', '\u{168}', SC_Upper), ('\u{169}', '\u{169}',
- SC_Lower), ('\u{16a}', '\u{16a}', SC_Upper), ('\u{16b}', '\u{16b}', SC_Lower), ('\u{16c}',
- '\u{16c}', SC_Upper), ('\u{16d}', '\u{16d}', SC_Lower), ('\u{16e}', '\u{16e}', SC_Upper),
- ('\u{16f}', '\u{16f}', SC_Lower), ('\u{170}', '\u{170}', SC_Upper), ('\u{171}', '\u{171}',
- SC_Lower), ('\u{172}', '\u{172}', SC_Upper), ('\u{173}', '\u{173}', SC_Lower), ('\u{174}',
- '\u{174}', SC_Upper), ('\u{175}', '\u{175}', SC_Lower), ('\u{176}', '\u{176}', SC_Upper),
- ('\u{177}', '\u{177}', SC_Lower), ('\u{178}', '\u{179}', SC_Upper), ('\u{17a}', '\u{17a}',
- SC_Lower), ('\u{17b}', '\u{17b}', SC_Upper), ('\u{17c}', '\u{17c}', SC_Lower), ('\u{17d}',
- '\u{17d}', SC_Upper), ('\u{17e}', '\u{180}', SC_Lower), ('\u{181}', '\u{182}', SC_Upper),
- ('\u{183}', '\u{183}', SC_Lower), ('\u{184}', '\u{184}', SC_Upper), ('\u{185}', '\u{185}',
- SC_Lower), ('\u{186}', '\u{187}', SC_Upper), ('\u{188}', '\u{188}', SC_Lower), ('\u{189}',
- '\u{18b}', SC_Upper), ('\u{18c}', '\u{18d}', SC_Lower), ('\u{18e}', '\u{191}', SC_Upper),
- ('\u{192}', '\u{192}', SC_Lower), ('\u{193}', '\u{194}', SC_Upper), ('\u{195}', '\u{195}',
- SC_Lower), ('\u{196}', '\u{198}', SC_Upper), ('\u{199}', '\u{19b}', SC_Lower), ('\u{19c}',
- '\u{19d}', SC_Upper), ('\u{19e}', '\u{19e}', SC_Lower), ('\u{19f}', '\u{1a0}', SC_Upper),
- ('\u{1a1}', '\u{1a1}', SC_Lower), ('\u{1a2}', '\u{1a2}', SC_Upper), ('\u{1a3}', '\u{1a3}',
- SC_Lower), ('\u{1a4}', '\u{1a4}', SC_Upper), ('\u{1a5}', '\u{1a5}', SC_Lower), ('\u{1a6}',
- '\u{1a7}', SC_Upper), ('\u{1a8}', '\u{1a8}', SC_Lower), ('\u{1a9}', '\u{1a9}', SC_Upper),
- ('\u{1aa}', '\u{1ab}', SC_Lower), ('\u{1ac}', '\u{1ac}', SC_Upper), ('\u{1ad}', '\u{1ad}',
- SC_Lower), ('\u{1ae}', '\u{1af}', SC_Upper), ('\u{1b0}', '\u{1b0}', SC_Lower), ('\u{1b1}',
- '\u{1b3}', SC_Upper), ('\u{1b4}', '\u{1b4}', SC_Lower), ('\u{1b5}', '\u{1b5}', SC_Upper),
- ('\u{1b6}', '\u{1b6}', SC_Lower), ('\u{1b7}', '\u{1b8}', SC_Upper), ('\u{1b9}', '\u{1ba}',
- SC_Lower), ('\u{1bb}', '\u{1bb}', SC_OLetter), ('\u{1bc}', '\u{1bc}', SC_Upper), ('\u{1bd}',
- '\u{1bf}', SC_Lower), ('\u{1c0}', '\u{1c3}', SC_OLetter), ('\u{1c4}', '\u{1c5}', SC_Upper),
- ('\u{1c6}', '\u{1c6}', SC_Lower), ('\u{1c7}', '\u{1c8}', SC_Upper), ('\u{1c9}', '\u{1c9}',
- SC_Lower), ('\u{1ca}', '\u{1cb}', SC_Upper), ('\u{1cc}', '\u{1cc}', SC_Lower), ('\u{1cd}',
- '\u{1cd}', SC_Upper), ('\u{1ce}', '\u{1ce}', SC_Lower), ('\u{1cf}', '\u{1cf}', SC_Upper),
- ('\u{1d0}', '\u{1d0}', SC_Lower), ('\u{1d1}', '\u{1d1}', SC_Upper), ('\u{1d2}', '\u{1d2}',
- SC_Lower), ('\u{1d3}', '\u{1d3}', SC_Upper), ('\u{1d4}', '\u{1d4}', SC_Lower), ('\u{1d5}',
- '\u{1d5}', SC_Upper), ('\u{1d6}', '\u{1d6}', SC_Lower), ('\u{1d7}', '\u{1d7}', SC_Upper),
- ('\u{1d8}', '\u{1d8}', SC_Lower), ('\u{1d9}', '\u{1d9}', SC_Upper), ('\u{1da}', '\u{1da}',
- SC_Lower), ('\u{1db}', '\u{1db}', SC_Upper), ('\u{1dc}', '\u{1dd}', SC_Lower), ('\u{1de}',
- '\u{1de}', SC_Upper), ('\u{1df}', '\u{1df}', SC_Lower), ('\u{1e0}', '\u{1e0}', SC_Upper),
- ('\u{1e1}', '\u{1e1}', SC_Lower), ('\u{1e2}', '\u{1e2}', SC_Upper), ('\u{1e3}', '\u{1e3}',
- SC_Lower), ('\u{1e4}', '\u{1e4}', SC_Upper), ('\u{1e5}', '\u{1e5}', SC_Lower), ('\u{1e6}',
- '\u{1e6}', SC_Upper), ('\u{1e7}', '\u{1e7}', SC_Lower), ('\u{1e8}', '\u{1e8}', SC_Upper),
- ('\u{1e9}', '\u{1e9}', SC_Lower), ('\u{1ea}', '\u{1ea}', SC_Upper), ('\u{1eb}', '\u{1eb}',
- SC_Lower), ('\u{1ec}', '\u{1ec}', SC_Upper), ('\u{1ed}', '\u{1ed}', SC_Lower), ('\u{1ee}',
- '\u{1ee}', SC_Upper), ('\u{1ef}', '\u{1f0}', SC_Lower), ('\u{1f1}', '\u{1f2}', SC_Upper),
- ('\u{1f3}', '\u{1f3}', SC_Lower), ('\u{1f4}', '\u{1f4}', SC_Upper), ('\u{1f5}', '\u{1f5}',
- SC_Lower), ('\u{1f6}', '\u{1f8}', SC_Upper), ('\u{1f9}', '\u{1f9}', SC_Lower), ('\u{1fa}',
- '\u{1fa}', SC_Upper), ('\u{1fb}', '\u{1fb}', SC_Lower), ('\u{1fc}', '\u{1fc}', SC_Upper),
- ('\u{1fd}', '\u{1fd}', SC_Lower), ('\u{1fe}', '\u{1fe}', SC_Upper), ('\u{1ff}', '\u{1ff}',
- SC_Lower), ('\u{200}', '\u{200}', SC_Upper), ('\u{201}', '\u{201}', SC_Lower), ('\u{202}',
- '\u{202}', SC_Upper), ('\u{203}', '\u{203}', SC_Lower), ('\u{204}', '\u{204}', SC_Upper),
- ('\u{205}', '\u{205}', SC_Lower), ('\u{206}', '\u{206}', SC_Upper), ('\u{207}', '\u{207}',
- SC_Lower), ('\u{208}', '\u{208}', SC_Upper), ('\u{209}', '\u{209}', SC_Lower), ('\u{20a}',
- '\u{20a}', SC_Upper), ('\u{20b}', '\u{20b}', SC_Lower), ('\u{20c}', '\u{20c}', SC_Upper),
- ('\u{20d}', '\u{20d}', SC_Lower), ('\u{20e}', '\u{20e}', SC_Upper), ('\u{20f}', '\u{20f}',
- SC_Lower), ('\u{210}', '\u{210}', SC_Upper), ('\u{211}', '\u{211}', SC_Lower), ('\u{212}',
- '\u{212}', SC_Upper), ('\u{213}', '\u{213}', SC_Lower), ('\u{214}', '\u{214}', SC_Upper),
- ('\u{215}', '\u{215}', SC_Lower), ('\u{216}', '\u{216}', SC_Upper), ('\u{217}', '\u{217}',
- SC_Lower), ('\u{218}', '\u{218}', SC_Upper), ('\u{219}', '\u{219}', SC_Lower), ('\u{21a}',
- '\u{21a}', SC_Upper), ('\u{21b}', '\u{21b}', SC_Lower), ('\u{21c}', '\u{21c}', SC_Upper),
- ('\u{21d}', '\u{21d}', SC_Lower), ('\u{21e}', '\u{21e}', SC_Upper), ('\u{21f}', '\u{21f}',
- SC_Lower), ('\u{220}', '\u{220}', SC_Upper), ('\u{221}', '\u{221}', SC_Lower), ('\u{222}',
- '\u{222}', SC_Upper), ('\u{223}', '\u{223}', SC_Lower), ('\u{224}', '\u{224}', SC_Upper),
- ('\u{225}', '\u{225}', SC_Lower), ('\u{226}', '\u{226}', SC_Upper), ('\u{227}', '\u{227}',
- SC_Lower), ('\u{228}', '\u{228}', SC_Upper), ('\u{229}', '\u{229}', SC_Lower), ('\u{22a}',
- '\u{22a}', SC_Upper), ('\u{22b}', '\u{22b}', SC_Lower), ('\u{22c}', '\u{22c}', SC_Upper),
- ('\u{22d}', '\u{22d}', SC_Lower), ('\u{22e}', '\u{22e}', SC_Upper), ('\u{22f}', '\u{22f}',
- SC_Lower), ('\u{230}', '\u{230}', SC_Upper), ('\u{231}', '\u{231}', SC_Lower), ('\u{232}',
- '\u{232}', SC_Upper), ('\u{233}', '\u{239}', SC_Lower), ('\u{23a}', '\u{23b}', SC_Upper),
- ('\u{23c}', '\u{23c}', SC_Lower), ('\u{23d}', '\u{23e}', SC_Upper), ('\u{23f}', '\u{240}',
- SC_Lower), ('\u{241}', '\u{241}', SC_Upper), ('\u{242}', '\u{242}', SC_Lower), ('\u{243}',
- '\u{246}', SC_Upper), ('\u{247}', '\u{247}', SC_Lower), ('\u{248}', '\u{248}', SC_Upper),
- ('\u{249}', '\u{249}', SC_Lower), ('\u{24a}', '\u{24a}', SC_Upper), ('\u{24b}', '\u{24b}',
- SC_Lower), ('\u{24c}', '\u{24c}', SC_Upper), ('\u{24d}', '\u{24d}', SC_Lower), ('\u{24e}',
- '\u{24e}', SC_Upper), ('\u{24f}', '\u{293}', SC_Lower), ('\u{294}', '\u{294}', SC_OLetter),
- ('\u{295}', '\u{2b8}', SC_Lower), ('\u{2b9}', '\u{2bf}', SC_OLetter), ('\u{2c0}', '\u{2c1}',
- SC_Lower), ('\u{2c6}', '\u{2d1}', SC_OLetter), ('\u{2e0}', '\u{2e4}', SC_Lower), ('\u{2ec}',
- '\u{2ec}', SC_OLetter), ('\u{2ee}', '\u{2ee}', SC_OLetter), ('\u{300}', '\u{36f}',
- SC_Extend), ('\u{370}', '\u{370}', SC_Upper), ('\u{371}', '\u{371}', SC_Lower), ('\u{372}',
- '\u{372}', SC_Upper), ('\u{373}', '\u{373}', SC_Lower), ('\u{374}', '\u{374}', SC_OLetter),
- ('\u{376}', '\u{376}', SC_Upper), ('\u{377}', '\u{377}', SC_Lower), ('\u{37a}', '\u{37d}',
- SC_Lower), ('\u{37f}', '\u{37f}', SC_Upper), ('\u{386}', '\u{386}', SC_Upper), ('\u{388}',
- '\u{38a}', SC_Upper), ('\u{38c}', '\u{38c}', SC_Upper), ('\u{38e}', '\u{38f}', SC_Upper),
- ('\u{390}', '\u{390}', SC_Lower), ('\u{391}', '\u{3a1}', SC_Upper), ('\u{3a3}', '\u{3ab}',
- SC_Upper), ('\u{3ac}', '\u{3ce}', SC_Lower), ('\u{3cf}', '\u{3cf}', SC_Upper), ('\u{3d0}',
- '\u{3d1}', SC_Lower), ('\u{3d2}', '\u{3d4}', SC_Upper), ('\u{3d5}', '\u{3d7}', SC_Lower),
- ('\u{3d8}', '\u{3d8}', SC_Upper), ('\u{3d9}', '\u{3d9}', SC_Lower), ('\u{3da}', '\u{3da}',
- SC_Upper), ('\u{3db}', '\u{3db}', SC_Lower), ('\u{3dc}', '\u{3dc}', SC_Upper), ('\u{3dd}',
- '\u{3dd}', SC_Lower), ('\u{3de}', '\u{3de}', SC_Upper), ('\u{3df}', '\u{3df}', SC_Lower),
- ('\u{3e0}', '\u{3e0}', SC_Upper), ('\u{3e1}', '\u{3e1}', SC_Lower), ('\u{3e2}', '\u{3e2}',
- SC_Upper), ('\u{3e3}', '\u{3e3}', SC_Lower), ('\u{3e4}', '\u{3e4}', SC_Upper), ('\u{3e5}',
- '\u{3e5}', SC_Lower), ('\u{3e6}', '\u{3e6}', SC_Upper), ('\u{3e7}', '\u{3e7}', SC_Lower),
- ('\u{3e8}', '\u{3e8}', SC_Upper), ('\u{3e9}', '\u{3e9}', SC_Lower), ('\u{3ea}', '\u{3ea}',
- SC_Upper), ('\u{3eb}', '\u{3eb}', SC_Lower), ('\u{3ec}', '\u{3ec}', SC_Upper), ('\u{3ed}',
- '\u{3ed}', SC_Lower), ('\u{3ee}', '\u{3ee}', SC_Upper), ('\u{3ef}', '\u{3f3}', SC_Lower),
- ('\u{3f4}', '\u{3f4}', SC_Upper), ('\u{3f5}', '\u{3f5}', SC_Lower), ('\u{3f7}', '\u{3f7}',
- SC_Upper), ('\u{3f8}', '\u{3f8}', SC_Lower), ('\u{3f9}', '\u{3fa}', SC_Upper), ('\u{3fb}',
- '\u{3fc}', SC_Lower), ('\u{3fd}', '\u{42f}', SC_Upper), ('\u{430}', '\u{45f}', SC_Lower),
- ('\u{460}', '\u{460}', SC_Upper), ('\u{461}', '\u{461}', SC_Lower), ('\u{462}', '\u{462}',
- SC_Upper), ('\u{463}', '\u{463}', SC_Lower), ('\u{464}', '\u{464}', SC_Upper), ('\u{465}',
- '\u{465}', SC_Lower), ('\u{466}', '\u{466}', SC_Upper), ('\u{467}', '\u{467}', SC_Lower),
- ('\u{468}', '\u{468}', SC_Upper), ('\u{469}', '\u{469}', SC_Lower), ('\u{46a}', '\u{46a}',
- SC_Upper), ('\u{46b}', '\u{46b}', SC_Lower), ('\u{46c}', '\u{46c}', SC_Upper), ('\u{46d}',
- '\u{46d}', SC_Lower), ('\u{46e}', '\u{46e}', SC_Upper), ('\u{46f}', '\u{46f}', SC_Lower),
- ('\u{470}', '\u{470}', SC_Upper), ('\u{471}', '\u{471}', SC_Lower), ('\u{472}', '\u{472}',
- SC_Upper), ('\u{473}', '\u{473}', SC_Lower), ('\u{474}', '\u{474}', SC_Upper), ('\u{475}',
- '\u{475}', SC_Lower), ('\u{476}', '\u{476}', SC_Upper), ('\u{477}', '\u{477}', SC_Lower),
- ('\u{478}', '\u{478}', SC_Upper), ('\u{479}', '\u{479}', SC_Lower), ('\u{47a}', '\u{47a}',
- SC_Upper), ('\u{47b}', '\u{47b}', SC_Lower), ('\u{47c}', '\u{47c}', SC_Upper), ('\u{47d}',
- '\u{47d}', SC_Lower), ('\u{47e}', '\u{47e}', SC_Upper), ('\u{47f}', '\u{47f}', SC_Lower),
- ('\u{480}', '\u{480}', SC_Upper), ('\u{481}', '\u{481}', SC_Lower), ('\u{483}', '\u{489}',
- SC_Extend), ('\u{48a}', '\u{48a}', SC_Upper), ('\u{48b}', '\u{48b}', SC_Lower), ('\u{48c}',
- '\u{48c}', SC_Upper), ('\u{48d}', '\u{48d}', SC_Lower), ('\u{48e}', '\u{48e}', SC_Upper),
- ('\u{48f}', '\u{48f}', SC_Lower), ('\u{490}', '\u{490}', SC_Upper), ('\u{491}', '\u{491}',
- SC_Lower), ('\u{492}', '\u{492}', SC_Upper), ('\u{493}', '\u{493}', SC_Lower), ('\u{494}',
- '\u{494}', SC_Upper), ('\u{495}', '\u{495}', SC_Lower), ('\u{496}', '\u{496}', SC_Upper),
- ('\u{497}', '\u{497}', SC_Lower), ('\u{498}', '\u{498}', SC_Upper), ('\u{499}', '\u{499}',
- SC_Lower), ('\u{49a}', '\u{49a}', SC_Upper), ('\u{49b}', '\u{49b}', SC_Lower), ('\u{49c}',
- '\u{49c}', SC_Upper), ('\u{49d}', '\u{49d}', SC_Lower), ('\u{49e}', '\u{49e}', SC_Upper),
- ('\u{49f}', '\u{49f}', SC_Lower), ('\u{4a0}', '\u{4a0}', SC_Upper), ('\u{4a1}', '\u{4a1}',
- SC_Lower), ('\u{4a2}', '\u{4a2}', SC_Upper), ('\u{4a3}', '\u{4a3}', SC_Lower), ('\u{4a4}',
- '\u{4a4}', SC_Upper), ('\u{4a5}', '\u{4a5}', SC_Lower), ('\u{4a6}', '\u{4a6}', SC_Upper),
- ('\u{4a7}', '\u{4a7}', SC_Lower), ('\u{4a8}', '\u{4a8}', SC_Upper), ('\u{4a9}', '\u{4a9}',
- SC_Lower), ('\u{4aa}', '\u{4aa}', SC_Upper), ('\u{4ab}', '\u{4ab}', SC_Lower), ('\u{4ac}',
- '\u{4ac}', SC_Upper), ('\u{4ad}', '\u{4ad}', SC_Lower), ('\u{4ae}', '\u{4ae}', SC_Upper),
- ('\u{4af}', '\u{4af}', SC_Lower), ('\u{4b0}', '\u{4b0}', SC_Upper), ('\u{4b1}', '\u{4b1}',
- SC_Lower), ('\u{4b2}', '\u{4b2}', SC_Upper), ('\u{4b3}', '\u{4b3}', SC_Lower), ('\u{4b4}',
- '\u{4b4}', SC_Upper), ('\u{4b5}', '\u{4b5}', SC_Lower), ('\u{4b6}', '\u{4b6}', SC_Upper),
- ('\u{4b7}', '\u{4b7}', SC_Lower), ('\u{4b8}', '\u{4b8}', SC_Upper), ('\u{4b9}', '\u{4b9}',
- SC_Lower), ('\u{4ba}', '\u{4ba}', SC_Upper), ('\u{4bb}', '\u{4bb}', SC_Lower), ('\u{4bc}',
- '\u{4bc}', SC_Upper), ('\u{4bd}', '\u{4bd}', SC_Lower), ('\u{4be}', '\u{4be}', SC_Upper),
- ('\u{4bf}', '\u{4bf}', SC_Lower), ('\u{4c0}', '\u{4c1}', SC_Upper), ('\u{4c2}', '\u{4c2}',
- SC_Lower), ('\u{4c3}', '\u{4c3}', SC_Upper), ('\u{4c4}', '\u{4c4}', SC_Lower), ('\u{4c5}',
- '\u{4c5}', SC_Upper), ('\u{4c6}', '\u{4c6}', SC_Lower), ('\u{4c7}', '\u{4c7}', SC_Upper),
- ('\u{4c8}', '\u{4c8}', SC_Lower), ('\u{4c9}', '\u{4c9}', SC_Upper), ('\u{4ca}', '\u{4ca}',
- SC_Lower), ('\u{4cb}', '\u{4cb}', SC_Upper), ('\u{4cc}', '\u{4cc}', SC_Lower), ('\u{4cd}',
- '\u{4cd}', SC_Upper), ('\u{4ce}', '\u{4cf}', SC_Lower), ('\u{4d0}', '\u{4d0}', SC_Upper),
- ('\u{4d1}', '\u{4d1}', SC_Lower), ('\u{4d2}', '\u{4d2}', SC_Upper), ('\u{4d3}', '\u{4d3}',
- SC_Lower), ('\u{4d4}', '\u{4d4}', SC_Upper), ('\u{4d5}', '\u{4d5}', SC_Lower), ('\u{4d6}',
- '\u{4d6}', SC_Upper), ('\u{4d7}', '\u{4d7}', SC_Lower), ('\u{4d8}', '\u{4d8}', SC_Upper),
- ('\u{4d9}', '\u{4d9}', SC_Lower), ('\u{4da}', '\u{4da}', SC_Upper), ('\u{4db}', '\u{4db}',
- SC_Lower), ('\u{4dc}', '\u{4dc}', SC_Upper), ('\u{4dd}', '\u{4dd}', SC_Lower), ('\u{4de}',
- '\u{4de}', SC_Upper), ('\u{4df}', '\u{4df}', SC_Lower), ('\u{4e0}', '\u{4e0}', SC_Upper),
- ('\u{4e1}', '\u{4e1}', SC_Lower), ('\u{4e2}', '\u{4e2}', SC_Upper), ('\u{4e3}', '\u{4e3}',
- SC_Lower), ('\u{4e4}', '\u{4e4}', SC_Upper), ('\u{4e5}', '\u{4e5}', SC_Lower), ('\u{4e6}',
- '\u{4e6}', SC_Upper), ('\u{4e7}', '\u{4e7}', SC_Lower), ('\u{4e8}', '\u{4e8}', SC_Upper),
- ('\u{4e9}', '\u{4e9}', SC_Lower), ('\u{4ea}', '\u{4ea}', SC_Upper), ('\u{4eb}', '\u{4eb}',
- SC_Lower), ('\u{4ec}', '\u{4ec}', SC_Upper), ('\u{4ed}', '\u{4ed}', SC_Lower), ('\u{4ee}',
- '\u{4ee}', SC_Upper), ('\u{4ef}', '\u{4ef}', SC_Lower), ('\u{4f0}', '\u{4f0}', SC_Upper),
- ('\u{4f1}', '\u{4f1}', SC_Lower), ('\u{4f2}', '\u{4f2}', SC_Upper), ('\u{4f3}', '\u{4f3}',
- SC_Lower), ('\u{4f4}', '\u{4f4}', SC_Upper), ('\u{4f5}', '\u{4f5}', SC_Lower), ('\u{4f6}',
- '\u{4f6}', SC_Upper), ('\u{4f7}', '\u{4f7}', SC_Lower), ('\u{4f8}', '\u{4f8}', SC_Upper),
- ('\u{4f9}', '\u{4f9}', SC_Lower), ('\u{4fa}', '\u{4fa}', SC_Upper), ('\u{4fb}', '\u{4fb}',
- SC_Lower), ('\u{4fc}', '\u{4fc}', SC_Upper), ('\u{4fd}', '\u{4fd}', SC_Lower), ('\u{4fe}',
- '\u{4fe}', SC_Upper), ('\u{4ff}', '\u{4ff}', SC_Lower), ('\u{500}', '\u{500}', SC_Upper),
- ('\u{501}', '\u{501}', SC_Lower), ('\u{502}', '\u{502}', SC_Upper), ('\u{503}', '\u{503}',
- SC_Lower), ('\u{504}', '\u{504}', SC_Upper), ('\u{505}', '\u{505}', SC_Lower), ('\u{506}',
- '\u{506}', SC_Upper), ('\u{507}', '\u{507}', SC_Lower), ('\u{508}', '\u{508}', SC_Upper),
- ('\u{509}', '\u{509}', SC_Lower), ('\u{50a}', '\u{50a}', SC_Upper), ('\u{50b}', '\u{50b}',
- SC_Lower), ('\u{50c}', '\u{50c}', SC_Upper), ('\u{50d}', '\u{50d}', SC_Lower), ('\u{50e}',
- '\u{50e}', SC_Upper), ('\u{50f}', '\u{50f}', SC_Lower), ('\u{510}', '\u{510}', SC_Upper),
- ('\u{511}', '\u{511}', SC_Lower), ('\u{512}', '\u{512}', SC_Upper), ('\u{513}', '\u{513}',
- SC_Lower), ('\u{514}', '\u{514}', SC_Upper), ('\u{515}', '\u{515}', SC_Lower), ('\u{516}',
- '\u{516}', SC_Upper), ('\u{517}', '\u{517}', SC_Lower), ('\u{518}', '\u{518}', SC_Upper),
- ('\u{519}', '\u{519}', SC_Lower), ('\u{51a}', '\u{51a}', SC_Upper), ('\u{51b}', '\u{51b}',
- SC_Lower), ('\u{51c}', '\u{51c}', SC_Upper), ('\u{51d}', '\u{51d}', SC_Lower), ('\u{51e}',
- '\u{51e}', SC_Upper), ('\u{51f}', '\u{51f}', SC_Lower), ('\u{520}', '\u{520}', SC_Upper),
- ('\u{521}', '\u{521}', SC_Lower), ('\u{522}', '\u{522}', SC_Upper), ('\u{523}', '\u{523}',
- SC_Lower), ('\u{524}', '\u{524}', SC_Upper), ('\u{525}', '\u{525}', SC_Lower), ('\u{526}',
- '\u{526}', SC_Upper), ('\u{527}', '\u{527}', SC_Lower), ('\u{528}', '\u{528}', SC_Upper),
- ('\u{529}', '\u{529}', SC_Lower), ('\u{52a}', '\u{52a}', SC_Upper), ('\u{52b}', '\u{52b}',
- SC_Lower), ('\u{52c}', '\u{52c}', SC_Upper), ('\u{52d}', '\u{52d}', SC_Lower), ('\u{52e}',
- '\u{52e}', SC_Upper), ('\u{52f}', '\u{52f}', SC_Lower), ('\u{531}', '\u{556}', SC_Upper),
- ('\u{559}', '\u{559}', SC_OLetter), ('\u{55d}', '\u{55d}', SC_SContinue), ('\u{560}',
- '\u{588}', SC_Lower), ('\u{589}', '\u{589}', SC_STerm), ('\u{591}', '\u{5bd}', SC_Extend),
- ('\u{5bf}', '\u{5bf}', SC_Extend), ('\u{5c1}', '\u{5c2}', SC_Extend), ('\u{5c4}', '\u{5c5}',
- SC_Extend), ('\u{5c7}', '\u{5c7}', SC_Extend), ('\u{5d0}', '\u{5ea}', SC_OLetter),
- ('\u{5ef}', '\u{5f3}', SC_OLetter), ('\u{600}', '\u{605}', SC_Format), ('\u{60c}',
- '\u{60d}', SC_SContinue), ('\u{610}', '\u{61a}', SC_Extend), ('\u{61c}', '\u{61c}',
- SC_Format), ('\u{61e}', '\u{61f}', SC_STerm), ('\u{620}', '\u{64a}', SC_OLetter),
- ('\u{64b}', '\u{65f}', SC_Extend), ('\u{660}', '\u{669}', SC_Numeric), ('\u{66b}',
- '\u{66c}', SC_Numeric), ('\u{66e}', '\u{66f}', SC_OLetter), ('\u{670}', '\u{670}',
- SC_Extend), ('\u{671}', '\u{6d3}', SC_OLetter), ('\u{6d4}', '\u{6d4}', SC_STerm),
- ('\u{6d5}', '\u{6d5}', SC_OLetter), ('\u{6d6}', '\u{6dc}', SC_Extend), ('\u{6dd}',
- '\u{6dd}', SC_Format), ('\u{6df}', '\u{6e4}', SC_Extend), ('\u{6e5}', '\u{6e6}',
- SC_OLetter), ('\u{6e7}', '\u{6e8}', SC_Extend), ('\u{6ea}', '\u{6ed}', SC_Extend),
- ('\u{6ee}', '\u{6ef}', SC_OLetter), ('\u{6f0}', '\u{6f9}', SC_Numeric), ('\u{6fa}',
- '\u{6fc}', SC_OLetter), ('\u{6ff}', '\u{6ff}', SC_OLetter), ('\u{700}', '\u{702}',
- SC_STerm), ('\u{70f}', '\u{70f}', SC_Format), ('\u{710}', '\u{710}', SC_OLetter),
- ('\u{711}', '\u{711}', SC_Extend), ('\u{712}', '\u{72f}', SC_OLetter), ('\u{730}',
- '\u{74a}', SC_Extend), ('\u{74d}', '\u{7a5}', SC_OLetter), ('\u{7a6}', '\u{7b0}',
- SC_Extend), ('\u{7b1}', '\u{7b1}', SC_OLetter), ('\u{7c0}', '\u{7c9}', SC_Numeric),
- ('\u{7ca}', '\u{7ea}', SC_OLetter), ('\u{7eb}', '\u{7f3}', SC_Extend), ('\u{7f4}',
- '\u{7f5}', SC_OLetter), ('\u{7f8}', '\u{7f8}', SC_SContinue), ('\u{7f9}', '\u{7f9}',
- SC_STerm), ('\u{7fa}', '\u{7fa}', SC_OLetter), ('\u{7fd}', '\u{7fd}', SC_Extend),
- ('\u{800}', '\u{815}', SC_OLetter), ('\u{816}', '\u{819}', SC_Extend), ('\u{81a}',
- '\u{81a}', SC_OLetter), ('\u{81b}', '\u{823}', SC_Extend), ('\u{824}', '\u{824}',
- SC_OLetter), ('\u{825}', '\u{827}', SC_Extend), ('\u{828}', '\u{828}', SC_OLetter),
- ('\u{829}', '\u{82d}', SC_Extend), ('\u{837}', '\u{837}', SC_STerm), ('\u{839}', '\u{839}',
- SC_STerm), ('\u{83d}', '\u{83e}', SC_STerm), ('\u{840}', '\u{858}', SC_OLetter), ('\u{859}',
- '\u{85b}', SC_Extend), ('\u{860}', '\u{86a}', SC_OLetter), ('\u{8a0}', '\u{8b4}',
- SC_OLetter), ('\u{8b6}', '\u{8bd}', SC_OLetter), ('\u{8d3}', '\u{8e1}', SC_Extend),
- ('\u{8e2}', '\u{8e2}', SC_Format), ('\u{8e3}', '\u{903}', SC_Extend), ('\u{904}', '\u{939}',
- SC_OLetter), ('\u{93a}', '\u{93c}', SC_Extend), ('\u{93d}', '\u{93d}', SC_OLetter),
- ('\u{93e}', '\u{94f}', SC_Extend), ('\u{950}', '\u{950}', SC_OLetter), ('\u{951}',
- '\u{957}', SC_Extend), ('\u{958}', '\u{961}', SC_OLetter), ('\u{962}', '\u{963}',
- SC_Extend), ('\u{964}', '\u{965}', SC_STerm), ('\u{966}', '\u{96f}', SC_Numeric),
- ('\u{971}', '\u{980}', SC_OLetter), ('\u{981}', '\u{983}', SC_Extend), ('\u{985}',
- '\u{98c}', SC_OLetter), ('\u{98f}', '\u{990}', SC_OLetter), ('\u{993}', '\u{9a8}',
- SC_OLetter), ('\u{9aa}', '\u{9b0}', SC_OLetter), ('\u{9b2}', '\u{9b2}', SC_OLetter),
- ('\u{9b6}', '\u{9b9}', SC_OLetter), ('\u{9bc}', '\u{9bc}', SC_Extend), ('\u{9bd}',
- '\u{9bd}', SC_OLetter), ('\u{9be}', '\u{9c4}', SC_Extend), ('\u{9c7}', '\u{9c8}',
- SC_Extend), ('\u{9cb}', '\u{9cd}', SC_Extend), ('\u{9ce}', '\u{9ce}', SC_OLetter),
- ('\u{9d7}', '\u{9d7}', SC_Extend), ('\u{9dc}', '\u{9dd}', SC_OLetter), ('\u{9df}',
- '\u{9e1}', SC_OLetter), ('\u{9e2}', '\u{9e3}', SC_Extend), ('\u{9e6}', '\u{9ef}',
- SC_Numeric), ('\u{9f0}', '\u{9f1}', SC_OLetter), ('\u{9fc}', '\u{9fc}', SC_OLetter),
- ('\u{9fe}', '\u{9fe}', SC_Extend), ('\u{a01}', '\u{a03}', SC_Extend), ('\u{a05}', '\u{a0a}',
- SC_OLetter), ('\u{a0f}', '\u{a10}', SC_OLetter), ('\u{a13}', '\u{a28}', SC_OLetter),
- ('\u{a2a}', '\u{a30}', SC_OLetter), ('\u{a32}', '\u{a33}', SC_OLetter), ('\u{a35}',
- '\u{a36}', SC_OLetter), ('\u{a38}', '\u{a39}', SC_OLetter), ('\u{a3c}', '\u{a3c}',
- SC_Extend), ('\u{a3e}', '\u{a42}', SC_Extend), ('\u{a47}', '\u{a48}', SC_Extend),
- ('\u{a4b}', '\u{a4d}', SC_Extend), ('\u{a51}', '\u{a51}', SC_Extend), ('\u{a59}', '\u{a5c}',
- SC_OLetter), ('\u{a5e}', '\u{a5e}', SC_OLetter), ('\u{a66}', '\u{a6f}', SC_Numeric),
- ('\u{a70}', '\u{a71}', SC_Extend), ('\u{a72}', '\u{a74}', SC_OLetter), ('\u{a75}',
- '\u{a75}', SC_Extend), ('\u{a81}', '\u{a83}', SC_Extend), ('\u{a85}', '\u{a8d}',
- SC_OLetter), ('\u{a8f}', '\u{a91}', SC_OLetter), ('\u{a93}', '\u{aa8}', SC_OLetter),
- ('\u{aaa}', '\u{ab0}', SC_OLetter), ('\u{ab2}', '\u{ab3}', SC_OLetter), ('\u{ab5}',
- '\u{ab9}', SC_OLetter), ('\u{abc}', '\u{abc}', SC_Extend), ('\u{abd}', '\u{abd}',
- SC_OLetter), ('\u{abe}', '\u{ac5}', SC_Extend), ('\u{ac7}', '\u{ac9}', SC_Extend),
- ('\u{acb}', '\u{acd}', SC_Extend), ('\u{ad0}', '\u{ad0}', SC_OLetter), ('\u{ae0}',
- '\u{ae1}', SC_OLetter), ('\u{ae2}', '\u{ae3}', SC_Extend), ('\u{ae6}', '\u{aef}',
- SC_Numeric), ('\u{af9}', '\u{af9}', SC_OLetter), ('\u{afa}', '\u{aff}', SC_Extend),
- ('\u{b01}', '\u{b03}', SC_Extend), ('\u{b05}', '\u{b0c}', SC_OLetter), ('\u{b0f}',
- '\u{b10}', SC_OLetter), ('\u{b13}', '\u{b28}', SC_OLetter), ('\u{b2a}', '\u{b30}',
- SC_OLetter), ('\u{b32}', '\u{b33}', SC_OLetter), ('\u{b35}', '\u{b39}', SC_OLetter),
- ('\u{b3c}', '\u{b3c}', SC_Extend), ('\u{b3d}', '\u{b3d}', SC_OLetter), ('\u{b3e}',
- '\u{b44}', SC_Extend), ('\u{b47}', '\u{b48}', SC_Extend), ('\u{b4b}', '\u{b4d}', SC_Extend),
- ('\u{b56}', '\u{b57}', SC_Extend), ('\u{b5c}', '\u{b5d}', SC_OLetter), ('\u{b5f}',
- '\u{b61}', SC_OLetter), ('\u{b62}', '\u{b63}', SC_Extend), ('\u{b66}', '\u{b6f}',
- SC_Numeric), ('\u{b71}', '\u{b71}', SC_OLetter), ('\u{b82}', '\u{b82}', SC_Extend),
- ('\u{b83}', '\u{b83}', SC_OLetter), ('\u{b85}', '\u{b8a}', SC_OLetter), ('\u{b8e}',
- '\u{b90}', SC_OLetter), ('\u{b92}', '\u{b95}', SC_OLetter), ('\u{b99}', '\u{b9a}',
- SC_OLetter), ('\u{b9c}', '\u{b9c}', SC_OLetter), ('\u{b9e}', '\u{b9f}', SC_OLetter),
- ('\u{ba3}', '\u{ba4}', SC_OLetter), ('\u{ba8}', '\u{baa}', SC_OLetter), ('\u{bae}',
- '\u{bb9}', SC_OLetter), ('\u{bbe}', '\u{bc2}', SC_Extend), ('\u{bc6}', '\u{bc8}',
- SC_Extend), ('\u{bca}', '\u{bcd}', SC_Extend), ('\u{bd0}', '\u{bd0}', SC_OLetter),
- ('\u{bd7}', '\u{bd7}', SC_Extend), ('\u{be6}', '\u{bef}', SC_Numeric), ('\u{c00}',
- '\u{c04}', SC_Extend), ('\u{c05}', '\u{c0c}', SC_OLetter), ('\u{c0e}', '\u{c10}',
- SC_OLetter), ('\u{c12}', '\u{c28}', SC_OLetter), ('\u{c2a}', '\u{c39}', SC_OLetter),
- ('\u{c3d}', '\u{c3d}', SC_OLetter), ('\u{c3e}', '\u{c44}', SC_Extend), ('\u{c46}',
- '\u{c48}', SC_Extend), ('\u{c4a}', '\u{c4d}', SC_Extend), ('\u{c55}', '\u{c56}', SC_Extend),
- ('\u{c58}', '\u{c5a}', SC_OLetter), ('\u{c60}', '\u{c61}', SC_OLetter), ('\u{c62}',
- '\u{c63}', SC_Extend), ('\u{c66}', '\u{c6f}', SC_Numeric), ('\u{c80}', '\u{c80}',
- SC_OLetter), ('\u{c81}', '\u{c83}', SC_Extend), ('\u{c85}', '\u{c8c}', SC_OLetter),
- ('\u{c8e}', '\u{c90}', SC_OLetter), ('\u{c92}', '\u{ca8}', SC_OLetter), ('\u{caa}',
- '\u{cb3}', SC_OLetter), ('\u{cb5}', '\u{cb9}', SC_OLetter), ('\u{cbc}', '\u{cbc}',
- SC_Extend), ('\u{cbd}', '\u{cbd}', SC_OLetter), ('\u{cbe}', '\u{cc4}', SC_Extend),
- ('\u{cc6}', '\u{cc8}', SC_Extend), ('\u{cca}', '\u{ccd}', SC_Extend), ('\u{cd5}', '\u{cd6}',
- SC_Extend), ('\u{cde}', '\u{cde}', SC_OLetter), ('\u{ce0}', '\u{ce1}', SC_OLetter),
- ('\u{ce2}', '\u{ce3}', SC_Extend), ('\u{ce6}', '\u{cef}', SC_Numeric), ('\u{cf1}',
- '\u{cf2}', SC_OLetter), ('\u{d00}', '\u{d03}', SC_Extend), ('\u{d05}', '\u{d0c}',
- SC_OLetter), ('\u{d0e}', '\u{d10}', SC_OLetter), ('\u{d12}', '\u{d3a}', SC_OLetter),
- ('\u{d3b}', '\u{d3c}', SC_Extend), ('\u{d3d}', '\u{d3d}', SC_OLetter), ('\u{d3e}',
- '\u{d44}', SC_Extend), ('\u{d46}', '\u{d48}', SC_Extend), ('\u{d4a}', '\u{d4d}', SC_Extend),
- ('\u{d4e}', '\u{d4e}', SC_OLetter), ('\u{d54}', '\u{d56}', SC_OLetter), ('\u{d57}',
- '\u{d57}', SC_Extend), ('\u{d5f}', '\u{d61}', SC_OLetter), ('\u{d62}', '\u{d63}',
- SC_Extend), ('\u{d66}', '\u{d6f}', SC_Numeric), ('\u{d7a}', '\u{d7f}', SC_OLetter),
- ('\u{d82}', '\u{d83}', SC_Extend), ('\u{d85}', '\u{d96}', SC_OLetter), ('\u{d9a}',
- '\u{db1}', SC_OLetter), ('\u{db3}', '\u{dbb}', SC_OLetter), ('\u{dbd}', '\u{dbd}',
- SC_OLetter), ('\u{dc0}', '\u{dc6}', SC_OLetter), ('\u{dca}', '\u{dca}', SC_Extend),
- ('\u{dcf}', '\u{dd4}', SC_Extend), ('\u{dd6}', '\u{dd6}', SC_Extend), ('\u{dd8}', '\u{ddf}',
- SC_Extend), ('\u{de6}', '\u{def}', SC_Numeric), ('\u{df2}', '\u{df3}', SC_Extend),
- ('\u{e01}', '\u{e30}', SC_OLetter), ('\u{e31}', '\u{e31}', SC_Extend), ('\u{e32}',
- '\u{e33}', SC_OLetter), ('\u{e34}', '\u{e3a}', SC_Extend), ('\u{e40}', '\u{e46}',
- SC_OLetter), ('\u{e47}', '\u{e4e}', SC_Extend), ('\u{e50}', '\u{e59}', SC_Numeric),
- ('\u{e81}', '\u{e82}', SC_OLetter), ('\u{e84}', '\u{e84}', SC_OLetter), ('\u{e86}',
- '\u{e8a}', SC_OLetter), ('\u{e8c}', '\u{ea3}', SC_OLetter), ('\u{ea5}', '\u{ea5}',
- SC_OLetter), ('\u{ea7}', '\u{eb0}', SC_OLetter), ('\u{eb1}', '\u{eb1}', SC_Extend),
- ('\u{eb2}', '\u{eb3}', SC_OLetter), ('\u{eb4}', '\u{ebc}', SC_Extend), ('\u{ebd}',
- '\u{ebd}', SC_OLetter), ('\u{ec0}', '\u{ec4}', SC_OLetter), ('\u{ec6}', '\u{ec6}',
- SC_OLetter), ('\u{ec8}', '\u{ecd}', SC_Extend), ('\u{ed0}', '\u{ed9}', SC_Numeric),
- ('\u{edc}', '\u{edf}', SC_OLetter), ('\u{f00}', '\u{f00}', SC_OLetter), ('\u{f18}',
- '\u{f19}', SC_Extend), ('\u{f20}', '\u{f29}', SC_Numeric), ('\u{f35}', '\u{f35}',
- SC_Extend), ('\u{f37}', '\u{f37}', SC_Extend), ('\u{f39}', '\u{f39}', SC_Extend),
- ('\u{f3a}', '\u{f3d}', SC_Close), ('\u{f3e}', '\u{f3f}', SC_Extend), ('\u{f40}', '\u{f47}',
- SC_OLetter), ('\u{f49}', '\u{f6c}', SC_OLetter), ('\u{f71}', '\u{f84}', SC_Extend),
- ('\u{f86}', '\u{f87}', SC_Extend), ('\u{f88}', '\u{f8c}', SC_OLetter), ('\u{f8d}',
- '\u{f97}', SC_Extend), ('\u{f99}', '\u{fbc}', SC_Extend), ('\u{fc6}', '\u{fc6}', SC_Extend),
- ('\u{1000}', '\u{102a}', SC_OLetter), ('\u{102b}', '\u{103e}', SC_Extend), ('\u{103f}',
- '\u{103f}', SC_OLetter), ('\u{1040}', '\u{1049}', SC_Numeric), ('\u{104a}', '\u{104b}',
- SC_STerm), ('\u{1050}', '\u{1055}', SC_OLetter), ('\u{1056}', '\u{1059}', SC_Extend),
- ('\u{105a}', '\u{105d}', SC_OLetter), ('\u{105e}', '\u{1060}', SC_Extend), ('\u{1061}',
- '\u{1061}', SC_OLetter), ('\u{1062}', '\u{1064}', SC_Extend), ('\u{1065}', '\u{1066}',
- SC_OLetter), ('\u{1067}', '\u{106d}', SC_Extend), ('\u{106e}', '\u{1070}', SC_OLetter),
- ('\u{1071}', '\u{1074}', SC_Extend), ('\u{1075}', '\u{1081}', SC_OLetter), ('\u{1082}',
- '\u{108d}', SC_Extend), ('\u{108e}', '\u{108e}', SC_OLetter), ('\u{108f}', '\u{108f}',
- SC_Extend), ('\u{1090}', '\u{1099}', SC_Numeric), ('\u{109a}', '\u{109d}', SC_Extend),
- ('\u{10a0}', '\u{10c5}', SC_Upper), ('\u{10c7}', '\u{10c7}', SC_Upper), ('\u{10cd}',
- '\u{10cd}', SC_Upper), ('\u{10d0}', '\u{10fa}', SC_OLetter), ('\u{10fc}', '\u{1248}',
- SC_OLetter), ('\u{124a}', '\u{124d}', SC_OLetter), ('\u{1250}', '\u{1256}', SC_OLetter),
- ('\u{1258}', '\u{1258}', SC_OLetter), ('\u{125a}', '\u{125d}', SC_OLetter), ('\u{1260}',
- '\u{1288}', SC_OLetter), ('\u{128a}', '\u{128d}', SC_OLetter), ('\u{1290}', '\u{12b0}',
- SC_OLetter), ('\u{12b2}', '\u{12b5}', SC_OLetter), ('\u{12b8}', '\u{12be}', SC_OLetter),
- ('\u{12c0}', '\u{12c0}', SC_OLetter), ('\u{12c2}', '\u{12c5}', SC_OLetter), ('\u{12c8}',
- '\u{12d6}', SC_OLetter), ('\u{12d8}', '\u{1310}', SC_OLetter), ('\u{1312}', '\u{1315}',
- SC_OLetter), ('\u{1318}', '\u{135a}', SC_OLetter), ('\u{135d}', '\u{135f}', SC_Extend),
- ('\u{1362}', '\u{1362}', SC_STerm), ('\u{1367}', '\u{1368}', SC_STerm), ('\u{1380}',
- '\u{138f}', SC_OLetter), ('\u{13a0}', '\u{13f5}', SC_Upper), ('\u{13f8}', '\u{13fd}',
- SC_Lower), ('\u{1401}', '\u{166c}', SC_OLetter), ('\u{166e}', '\u{166e}', SC_STerm),
- ('\u{166f}', '\u{167f}', SC_OLetter), ('\u{1680}', '\u{1680}', SC_Sp), ('\u{1681}',
- '\u{169a}', SC_OLetter), ('\u{169b}', '\u{169c}', SC_Close), ('\u{16a0}', '\u{16ea}',
- SC_OLetter), ('\u{16ee}', '\u{16f8}', SC_OLetter), ('\u{1700}', '\u{170c}', SC_OLetter),
- ('\u{170e}', '\u{1711}', SC_OLetter), ('\u{1712}', '\u{1714}', SC_Extend), ('\u{1720}',
- '\u{1731}', SC_OLetter), ('\u{1732}', '\u{1734}', SC_Extend), ('\u{1735}', '\u{1736}',
- SC_STerm), ('\u{1740}', '\u{1751}', SC_OLetter), ('\u{1752}', '\u{1753}', SC_Extend),
- ('\u{1760}', '\u{176c}', SC_OLetter), ('\u{176e}', '\u{1770}', SC_OLetter), ('\u{1772}',
- '\u{1773}', SC_Extend), ('\u{1780}', '\u{17b3}', SC_OLetter), ('\u{17b4}', '\u{17d3}',
- SC_Extend), ('\u{17d7}', '\u{17d7}', SC_OLetter), ('\u{17dc}', '\u{17dc}', SC_OLetter),
- ('\u{17dd}', '\u{17dd}', SC_Extend), ('\u{17e0}', '\u{17e9}', SC_Numeric), ('\u{1802}',
- '\u{1802}', SC_SContinue), ('\u{1803}', '\u{1803}', SC_STerm), ('\u{1808}', '\u{1808}',
- SC_SContinue), ('\u{1809}', '\u{1809}', SC_STerm), ('\u{180b}', '\u{180d}', SC_Extend),
- ('\u{180e}', '\u{180e}', SC_Format), ('\u{1810}', '\u{1819}', SC_Numeric), ('\u{1820}',
- '\u{1878}', SC_OLetter), ('\u{1880}', '\u{1884}', SC_OLetter), ('\u{1885}', '\u{1886}',
- SC_Extend), ('\u{1887}', '\u{18a8}', SC_OLetter), ('\u{18a9}', '\u{18a9}', SC_Extend),
- ('\u{18aa}', '\u{18aa}', SC_OLetter), ('\u{18b0}', '\u{18f5}', SC_OLetter), ('\u{1900}',
- '\u{191e}', SC_OLetter), ('\u{1920}', '\u{192b}', SC_Extend), ('\u{1930}', '\u{193b}',
- SC_Extend), ('\u{1944}', '\u{1945}', SC_STerm), ('\u{1946}', '\u{194f}', SC_Numeric),
- ('\u{1950}', '\u{196d}', SC_OLetter), ('\u{1970}', '\u{1974}', SC_OLetter), ('\u{1980}',
- '\u{19ab}', SC_OLetter), ('\u{19b0}', '\u{19c9}', SC_OLetter), ('\u{19d0}', '\u{19d9}',
- SC_Numeric), ('\u{1a00}', '\u{1a16}', SC_OLetter), ('\u{1a17}', '\u{1a1b}', SC_Extend),
- ('\u{1a20}', '\u{1a54}', SC_OLetter), ('\u{1a55}', '\u{1a5e}', SC_Extend), ('\u{1a60}',
- '\u{1a7c}', SC_Extend), ('\u{1a7f}', '\u{1a7f}', SC_Extend), ('\u{1a80}', '\u{1a89}',
- SC_Numeric), ('\u{1a90}', '\u{1a99}', SC_Numeric), ('\u{1aa7}', '\u{1aa7}', SC_OLetter),
- ('\u{1aa8}', '\u{1aab}', SC_STerm), ('\u{1ab0}', '\u{1abe}', SC_Extend), ('\u{1b00}',
- '\u{1b04}', SC_Extend), ('\u{1b05}', '\u{1b33}', SC_OLetter), ('\u{1b34}', '\u{1b44}',
- SC_Extend), ('\u{1b45}', '\u{1b4b}', SC_OLetter), ('\u{1b50}', '\u{1b59}', SC_Numeric),
- ('\u{1b5a}', '\u{1b5b}', SC_STerm), ('\u{1b5e}', '\u{1b5f}', SC_STerm), ('\u{1b6b}',
- '\u{1b73}', SC_Extend), ('\u{1b80}', '\u{1b82}', SC_Extend), ('\u{1b83}', '\u{1ba0}',
- SC_OLetter), ('\u{1ba1}', '\u{1bad}', SC_Extend), ('\u{1bae}', '\u{1baf}', SC_OLetter),
- ('\u{1bb0}', '\u{1bb9}', SC_Numeric), ('\u{1bba}', '\u{1be5}', SC_OLetter), ('\u{1be6}',
- '\u{1bf3}', SC_Extend), ('\u{1c00}', '\u{1c23}', SC_OLetter), ('\u{1c24}', '\u{1c37}',
- SC_Extend), ('\u{1c3b}', '\u{1c3c}', SC_STerm), ('\u{1c40}', '\u{1c49}', SC_Numeric),
- ('\u{1c4d}', '\u{1c4f}', SC_OLetter), ('\u{1c50}', '\u{1c59}', SC_Numeric), ('\u{1c5a}',
- '\u{1c7d}', SC_OLetter), ('\u{1c7e}', '\u{1c7f}', SC_STerm), ('\u{1c80}', '\u{1c88}',
- SC_Lower), ('\u{1c90}', '\u{1cba}', SC_OLetter), ('\u{1cbd}', '\u{1cbf}', SC_OLetter),
- ('\u{1cd0}', '\u{1cd2}', SC_Extend), ('\u{1cd4}', '\u{1ce8}', SC_Extend), ('\u{1ce9}',
- '\u{1cec}', SC_OLetter), ('\u{1ced}', '\u{1ced}', SC_Extend), ('\u{1cee}', '\u{1cf3}',
- SC_OLetter), ('\u{1cf4}', '\u{1cf4}', SC_Extend), ('\u{1cf5}', '\u{1cf6}', SC_OLetter),
- ('\u{1cf7}', '\u{1cf9}', SC_Extend), ('\u{1cfa}', '\u{1cfa}', SC_OLetter), ('\u{1d00}',
- '\u{1dbf}', SC_Lower), ('\u{1dc0}', '\u{1df9}', SC_Extend), ('\u{1dfb}', '\u{1dff}',
- SC_Extend), ('\u{1e00}', '\u{1e00}', SC_Upper), ('\u{1e01}', '\u{1e01}', SC_Lower),
- ('\u{1e02}', '\u{1e02}', SC_Upper), ('\u{1e03}', '\u{1e03}', SC_Lower), ('\u{1e04}',
- '\u{1e04}', SC_Upper), ('\u{1e05}', '\u{1e05}', SC_Lower), ('\u{1e06}', '\u{1e06}',
- SC_Upper), ('\u{1e07}', '\u{1e07}', SC_Lower), ('\u{1e08}', '\u{1e08}', SC_Upper),
- ('\u{1e09}', '\u{1e09}', SC_Lower), ('\u{1e0a}', '\u{1e0a}', SC_Upper), ('\u{1e0b}',
- '\u{1e0b}', SC_Lower), ('\u{1e0c}', '\u{1e0c}', SC_Upper), ('\u{1e0d}', '\u{1e0d}',
- SC_Lower), ('\u{1e0e}', '\u{1e0e}', SC_Upper), ('\u{1e0f}', '\u{1e0f}', SC_Lower),
- ('\u{1e10}', '\u{1e10}', SC_Upper), ('\u{1e11}', '\u{1e11}', SC_Lower), ('\u{1e12}',
- '\u{1e12}', SC_Upper), ('\u{1e13}', '\u{1e13}', SC_Lower), ('\u{1e14}', '\u{1e14}',
- SC_Upper), ('\u{1e15}', '\u{1e15}', SC_Lower), ('\u{1e16}', '\u{1e16}', SC_Upper),
- ('\u{1e17}', '\u{1e17}', SC_Lower), ('\u{1e18}', '\u{1e18}', SC_Upper), ('\u{1e19}',
- '\u{1e19}', SC_Lower), ('\u{1e1a}', '\u{1e1a}', SC_Upper), ('\u{1e1b}', '\u{1e1b}',
- SC_Lower), ('\u{1e1c}', '\u{1e1c}', SC_Upper), ('\u{1e1d}', '\u{1e1d}', SC_Lower),
- ('\u{1e1e}', '\u{1e1e}', SC_Upper), ('\u{1e1f}', '\u{1e1f}', SC_Lower), ('\u{1e20}',
- '\u{1e20}', SC_Upper), ('\u{1e21}', '\u{1e21}', SC_Lower), ('\u{1e22}', '\u{1e22}',
- SC_Upper), ('\u{1e23}', '\u{1e23}', SC_Lower), ('\u{1e24}', '\u{1e24}', SC_Upper),
- ('\u{1e25}', '\u{1e25}', SC_Lower), ('\u{1e26}', '\u{1e26}', SC_Upper), ('\u{1e27}',
- '\u{1e27}', SC_Lower), ('\u{1e28}', '\u{1e28}', SC_Upper), ('\u{1e29}', '\u{1e29}',
- SC_Lower), ('\u{1e2a}', '\u{1e2a}', SC_Upper), ('\u{1e2b}', '\u{1e2b}', SC_Lower),
- ('\u{1e2c}', '\u{1e2c}', SC_Upper), ('\u{1e2d}', '\u{1e2d}', SC_Lower), ('\u{1e2e}',
- '\u{1e2e}', SC_Upper), ('\u{1e2f}', '\u{1e2f}', SC_Lower), ('\u{1e30}', '\u{1e30}',
- SC_Upper), ('\u{1e31}', '\u{1e31}', SC_Lower), ('\u{1e32}', '\u{1e32}', SC_Upper),
- ('\u{1e33}', '\u{1e33}', SC_Lower), ('\u{1e34}', '\u{1e34}', SC_Upper), ('\u{1e35}',
- '\u{1e35}', SC_Lower), ('\u{1e36}', '\u{1e36}', SC_Upper), ('\u{1e37}', '\u{1e37}',
- SC_Lower), ('\u{1e38}', '\u{1e38}', SC_Upper), ('\u{1e39}', '\u{1e39}', SC_Lower),
- ('\u{1e3a}', '\u{1e3a}', SC_Upper), ('\u{1e3b}', '\u{1e3b}', SC_Lower), ('\u{1e3c}',
- '\u{1e3c}', SC_Upper), ('\u{1e3d}', '\u{1e3d}', SC_Lower), ('\u{1e3e}', '\u{1e3e}',
- SC_Upper), ('\u{1e3f}', '\u{1e3f}', SC_Lower), ('\u{1e40}', '\u{1e40}', SC_Upper),
- ('\u{1e41}', '\u{1e41}', SC_Lower), ('\u{1e42}', '\u{1e42}', SC_Upper), ('\u{1e43}',
- '\u{1e43}', SC_Lower), ('\u{1e44}', '\u{1e44}', SC_Upper), ('\u{1e45}', '\u{1e45}',
- SC_Lower), ('\u{1e46}', '\u{1e46}', SC_Upper), ('\u{1e47}', '\u{1e47}', SC_Lower),
- ('\u{1e48}', '\u{1e48}', SC_Upper), ('\u{1e49}', '\u{1e49}', SC_Lower), ('\u{1e4a}',
- '\u{1e4a}', SC_Upper), ('\u{1e4b}', '\u{1e4b}', SC_Lower), ('\u{1e4c}', '\u{1e4c}',
- SC_Upper), ('\u{1e4d}', '\u{1e4d}', SC_Lower), ('\u{1e4e}', '\u{1e4e}', SC_Upper),
- ('\u{1e4f}', '\u{1e4f}', SC_Lower), ('\u{1e50}', '\u{1e50}', SC_Upper), ('\u{1e51}',
- '\u{1e51}', SC_Lower), ('\u{1e52}', '\u{1e52}', SC_Upper), ('\u{1e53}', '\u{1e53}',
- SC_Lower), ('\u{1e54}', '\u{1e54}', SC_Upper), ('\u{1e55}', '\u{1e55}', SC_Lower),
- ('\u{1e56}', '\u{1e56}', SC_Upper), ('\u{1e57}', '\u{1e57}', SC_Lower), ('\u{1e58}',
- '\u{1e58}', SC_Upper), ('\u{1e59}', '\u{1e59}', SC_Lower), ('\u{1e5a}', '\u{1e5a}',
- SC_Upper), ('\u{1e5b}', '\u{1e5b}', SC_Lower), ('\u{1e5c}', '\u{1e5c}', SC_Upper),
- ('\u{1e5d}', '\u{1e5d}', SC_Lower), ('\u{1e5e}', '\u{1e5e}', SC_Upper), ('\u{1e5f}',
- '\u{1e5f}', SC_Lower), ('\u{1e60}', '\u{1e60}', SC_Upper), ('\u{1e61}', '\u{1e61}',
- SC_Lower), ('\u{1e62}', '\u{1e62}', SC_Upper), ('\u{1e63}', '\u{1e63}', SC_Lower),
- ('\u{1e64}', '\u{1e64}', SC_Upper), ('\u{1e65}', '\u{1e65}', SC_Lower), ('\u{1e66}',
- '\u{1e66}', SC_Upper), ('\u{1e67}', '\u{1e67}', SC_Lower), ('\u{1e68}', '\u{1e68}',
- SC_Upper), ('\u{1e69}', '\u{1e69}', SC_Lower), ('\u{1e6a}', '\u{1e6a}', SC_Upper),
- ('\u{1e6b}', '\u{1e6b}', SC_Lower), ('\u{1e6c}', '\u{1e6c}', SC_Upper), ('\u{1e6d}',
- '\u{1e6d}', SC_Lower), ('\u{1e6e}', '\u{1e6e}', SC_Upper), ('\u{1e6f}', '\u{1e6f}',
- SC_Lower), ('\u{1e70}', '\u{1e70}', SC_Upper), ('\u{1e71}', '\u{1e71}', SC_Lower),
- ('\u{1e72}', '\u{1e72}', SC_Upper), ('\u{1e73}', '\u{1e73}', SC_Lower), ('\u{1e74}',
- '\u{1e74}', SC_Upper), ('\u{1e75}', '\u{1e75}', SC_Lower), ('\u{1e76}', '\u{1e76}',
- SC_Upper), ('\u{1e77}', '\u{1e77}', SC_Lower), ('\u{1e78}', '\u{1e78}', SC_Upper),
- ('\u{1e79}', '\u{1e79}', SC_Lower), ('\u{1e7a}', '\u{1e7a}', SC_Upper), ('\u{1e7b}',
- '\u{1e7b}', SC_Lower), ('\u{1e7c}', '\u{1e7c}', SC_Upper), ('\u{1e7d}', '\u{1e7d}',
- SC_Lower), ('\u{1e7e}', '\u{1e7e}', SC_Upper), ('\u{1e7f}', '\u{1e7f}', SC_Lower),
- ('\u{1e80}', '\u{1e80}', SC_Upper), ('\u{1e81}', '\u{1e81}', SC_Lower), ('\u{1e82}',
- '\u{1e82}', SC_Upper), ('\u{1e83}', '\u{1e83}', SC_Lower), ('\u{1e84}', '\u{1e84}',
- SC_Upper), ('\u{1e85}', '\u{1e85}', SC_Lower), ('\u{1e86}', '\u{1e86}', SC_Upper),
- ('\u{1e87}', '\u{1e87}', SC_Lower), ('\u{1e88}', '\u{1e88}', SC_Upper), ('\u{1e89}',
- '\u{1e89}', SC_Lower), ('\u{1e8a}', '\u{1e8a}', SC_Upper), ('\u{1e8b}', '\u{1e8b}',
- SC_Lower), ('\u{1e8c}', '\u{1e8c}', SC_Upper), ('\u{1e8d}', '\u{1e8d}', SC_Lower),
- ('\u{1e8e}', '\u{1e8e}', SC_Upper), ('\u{1e8f}', '\u{1e8f}', SC_Lower), ('\u{1e90}',
- '\u{1e90}', SC_Upper), ('\u{1e91}', '\u{1e91}', SC_Lower), ('\u{1e92}', '\u{1e92}',
- SC_Upper), ('\u{1e93}', '\u{1e93}', SC_Lower), ('\u{1e94}', '\u{1e94}', SC_Upper),
- ('\u{1e95}', '\u{1e9d}', SC_Lower), ('\u{1e9e}', '\u{1e9e}', SC_Upper), ('\u{1e9f}',
- '\u{1e9f}', SC_Lower), ('\u{1ea0}', '\u{1ea0}', SC_Upper), ('\u{1ea1}', '\u{1ea1}',
- SC_Lower), ('\u{1ea2}', '\u{1ea2}', SC_Upper), ('\u{1ea3}', '\u{1ea3}', SC_Lower),
- ('\u{1ea4}', '\u{1ea4}', SC_Upper), ('\u{1ea5}', '\u{1ea5}', SC_Lower), ('\u{1ea6}',
- '\u{1ea6}', SC_Upper), ('\u{1ea7}', '\u{1ea7}', SC_Lower), ('\u{1ea8}', '\u{1ea8}',
- SC_Upper), ('\u{1ea9}', '\u{1ea9}', SC_Lower), ('\u{1eaa}', '\u{1eaa}', SC_Upper),
- ('\u{1eab}', '\u{1eab}', SC_Lower), ('\u{1eac}', '\u{1eac}', SC_Upper), ('\u{1ead}',
- '\u{1ead}', SC_Lower), ('\u{1eae}', '\u{1eae}', SC_Upper), ('\u{1eaf}', '\u{1eaf}',
- SC_Lower), ('\u{1eb0}', '\u{1eb0}', SC_Upper), ('\u{1eb1}', '\u{1eb1}', SC_Lower),
- ('\u{1eb2}', '\u{1eb2}', SC_Upper), ('\u{1eb3}', '\u{1eb3}', SC_Lower), ('\u{1eb4}',
- '\u{1eb4}', SC_Upper), ('\u{1eb5}', '\u{1eb5}', SC_Lower), ('\u{1eb6}', '\u{1eb6}',
- SC_Upper), ('\u{1eb7}', '\u{1eb7}', SC_Lower), ('\u{1eb8}', '\u{1eb8}', SC_Upper),
- ('\u{1eb9}', '\u{1eb9}', SC_Lower), ('\u{1eba}', '\u{1eba}', SC_Upper), ('\u{1ebb}',
- '\u{1ebb}', SC_Lower), ('\u{1ebc}', '\u{1ebc}', SC_Upper), ('\u{1ebd}', '\u{1ebd}',
- SC_Lower), ('\u{1ebe}', '\u{1ebe}', SC_Upper), ('\u{1ebf}', '\u{1ebf}', SC_Lower),
- ('\u{1ec0}', '\u{1ec0}', SC_Upper), ('\u{1ec1}', '\u{1ec1}', SC_Lower), ('\u{1ec2}',
- '\u{1ec2}', SC_Upper), ('\u{1ec3}', '\u{1ec3}', SC_Lower), ('\u{1ec4}', '\u{1ec4}',
- SC_Upper), ('\u{1ec5}', '\u{1ec5}', SC_Lower), ('\u{1ec6}', '\u{1ec6}', SC_Upper),
- ('\u{1ec7}', '\u{1ec7}', SC_Lower), ('\u{1ec8}', '\u{1ec8}', SC_Upper), ('\u{1ec9}',
- '\u{1ec9}', SC_Lower), ('\u{1eca}', '\u{1eca}', SC_Upper), ('\u{1ecb}', '\u{1ecb}',
- SC_Lower), ('\u{1ecc}', '\u{1ecc}', SC_Upper), ('\u{1ecd}', '\u{1ecd}', SC_Lower),
- ('\u{1ece}', '\u{1ece}', SC_Upper), ('\u{1ecf}', '\u{1ecf}', SC_Lower), ('\u{1ed0}',
- '\u{1ed0}', SC_Upper), ('\u{1ed1}', '\u{1ed1}', SC_Lower), ('\u{1ed2}', '\u{1ed2}',
- SC_Upper), ('\u{1ed3}', '\u{1ed3}', SC_Lower), ('\u{1ed4}', '\u{1ed4}', SC_Upper),
- ('\u{1ed5}', '\u{1ed5}', SC_Lower), ('\u{1ed6}', '\u{1ed6}', SC_Upper), ('\u{1ed7}',
- '\u{1ed7}', SC_Lower), ('\u{1ed8}', '\u{1ed8}', SC_Upper), ('\u{1ed9}', '\u{1ed9}',
- SC_Lower), ('\u{1eda}', '\u{1eda}', SC_Upper), ('\u{1edb}', '\u{1edb}', SC_Lower),
- ('\u{1edc}', '\u{1edc}', SC_Upper), ('\u{1edd}', '\u{1edd}', SC_Lower), ('\u{1ede}',
- '\u{1ede}', SC_Upper), ('\u{1edf}', '\u{1edf}', SC_Lower), ('\u{1ee0}', '\u{1ee0}',
- SC_Upper), ('\u{1ee1}', '\u{1ee1}', SC_Lower), ('\u{1ee2}', '\u{1ee2}', SC_Upper),
- ('\u{1ee3}', '\u{1ee3}', SC_Lower), ('\u{1ee4}', '\u{1ee4}', SC_Upper), ('\u{1ee5}',
- '\u{1ee5}', SC_Lower), ('\u{1ee6}', '\u{1ee6}', SC_Upper), ('\u{1ee7}', '\u{1ee7}',
- SC_Lower), ('\u{1ee8}', '\u{1ee8}', SC_Upper), ('\u{1ee9}', '\u{1ee9}', SC_Lower),
- ('\u{1eea}', '\u{1eea}', SC_Upper), ('\u{1eeb}', '\u{1eeb}', SC_Lower), ('\u{1eec}',
- '\u{1eec}', SC_Upper), ('\u{1eed}', '\u{1eed}', SC_Lower), ('\u{1eee}', '\u{1eee}',
- SC_Upper), ('\u{1eef}', '\u{1eef}', SC_Lower), ('\u{1ef0}', '\u{1ef0}', SC_Upper),
- ('\u{1ef1}', '\u{1ef1}', SC_Lower), ('\u{1ef2}', '\u{1ef2}', SC_Upper), ('\u{1ef3}',
- '\u{1ef3}', SC_Lower), ('\u{1ef4}', '\u{1ef4}', SC_Upper), ('\u{1ef5}', '\u{1ef5}',
- SC_Lower), ('\u{1ef6}', '\u{1ef6}', SC_Upper), ('\u{1ef7}', '\u{1ef7}', SC_Lower),
- ('\u{1ef8}', '\u{1ef8}', SC_Upper), ('\u{1ef9}', '\u{1ef9}', SC_Lower), ('\u{1efa}',
- '\u{1efa}', SC_Upper), ('\u{1efb}', '\u{1efb}', SC_Lower), ('\u{1efc}', '\u{1efc}',
- SC_Upper), ('\u{1efd}', '\u{1efd}', SC_Lower), ('\u{1efe}', '\u{1efe}', SC_Upper),
- ('\u{1eff}', '\u{1f07}', SC_Lower), ('\u{1f08}', '\u{1f0f}', SC_Upper), ('\u{1f10}',
- '\u{1f15}', SC_Lower), ('\u{1f18}', '\u{1f1d}', SC_Upper), ('\u{1f20}', '\u{1f27}',
- SC_Lower), ('\u{1f28}', '\u{1f2f}', SC_Upper), ('\u{1f30}', '\u{1f37}', SC_Lower),
- ('\u{1f38}', '\u{1f3f}', SC_Upper), ('\u{1f40}', '\u{1f45}', SC_Lower), ('\u{1f48}',
- '\u{1f4d}', SC_Upper), ('\u{1f50}', '\u{1f57}', SC_Lower), ('\u{1f59}', '\u{1f59}',
- SC_Upper), ('\u{1f5b}', '\u{1f5b}', SC_Upper), ('\u{1f5d}', '\u{1f5d}', SC_Upper),
- ('\u{1f5f}', '\u{1f5f}', SC_Upper), ('\u{1f60}', '\u{1f67}', SC_Lower), ('\u{1f68}',
- '\u{1f6f}', SC_Upper), ('\u{1f70}', '\u{1f7d}', SC_Lower), ('\u{1f80}', '\u{1f87}',
- SC_Lower), ('\u{1f88}', '\u{1f8f}', SC_Upper), ('\u{1f90}', '\u{1f97}', SC_Lower),
- ('\u{1f98}', '\u{1f9f}', SC_Upper), ('\u{1fa0}', '\u{1fa7}', SC_Lower), ('\u{1fa8}',
- '\u{1faf}', SC_Upper), ('\u{1fb0}', '\u{1fb4}', SC_Lower), ('\u{1fb6}', '\u{1fb7}',
- SC_Lower), ('\u{1fb8}', '\u{1fbc}', SC_Upper), ('\u{1fbe}', '\u{1fbe}', SC_Lower),
- ('\u{1fc2}', '\u{1fc4}', SC_Lower), ('\u{1fc6}', '\u{1fc7}', SC_Lower), ('\u{1fc8}',
- '\u{1fcc}', SC_Upper), ('\u{1fd0}', '\u{1fd3}', SC_Lower), ('\u{1fd6}', '\u{1fd7}',
- SC_Lower), ('\u{1fd8}', '\u{1fdb}', SC_Upper), ('\u{1fe0}', '\u{1fe7}', SC_Lower),
- ('\u{1fe8}', '\u{1fec}', SC_Upper), ('\u{1ff2}', '\u{1ff4}', SC_Lower), ('\u{1ff6}',
- '\u{1ff7}', SC_Lower), ('\u{1ff8}', '\u{1ffc}', SC_Upper), ('\u{2000}', '\u{200a}', SC_Sp),
- ('\u{200b}', '\u{200b}', SC_Format), ('\u{200c}', '\u{200d}', SC_Extend), ('\u{200e}',
- '\u{200f}', SC_Format), ('\u{2013}', '\u{2014}', SC_SContinue), ('\u{2018}', '\u{201f}',
- SC_Close), ('\u{2024}', '\u{2024}', SC_ATerm), ('\u{2028}', '\u{2029}', SC_Sep),
- ('\u{202a}', '\u{202e}', SC_Format), ('\u{202f}', '\u{202f}', SC_Sp), ('\u{2039}',
- '\u{203a}', SC_Close), ('\u{203c}', '\u{203d}', SC_STerm), ('\u{2045}', '\u{2046}',
- SC_Close), ('\u{2047}', '\u{2049}', SC_STerm), ('\u{205f}', '\u{205f}', SC_Sp), ('\u{2060}',
- '\u{2064}', SC_Format), ('\u{2066}', '\u{206f}', SC_Format), ('\u{2071}', '\u{2071}',
- SC_Lower), ('\u{207d}', '\u{207e}', SC_Close), ('\u{207f}', '\u{207f}', SC_Lower),
- ('\u{208d}', '\u{208e}', SC_Close), ('\u{2090}', '\u{209c}', SC_Lower), ('\u{20d0}',
- '\u{20f0}', SC_Extend), ('\u{2102}', '\u{2102}', SC_Upper), ('\u{2107}', '\u{2107}',
- SC_Upper), ('\u{210a}', '\u{210a}', SC_Lower), ('\u{210b}', '\u{210d}', SC_Upper),
- ('\u{210e}', '\u{210f}', SC_Lower), ('\u{2110}', '\u{2112}', SC_Upper), ('\u{2113}',
- '\u{2113}', SC_Lower), ('\u{2115}', '\u{2115}', SC_Upper), ('\u{2119}', '\u{211d}',
- SC_Upper), ('\u{2124}', '\u{2124}', SC_Upper), ('\u{2126}', '\u{2126}', SC_Upper),
- ('\u{2128}', '\u{2128}', SC_Upper), ('\u{212a}', '\u{212d}', SC_Upper), ('\u{212f}',
- '\u{212f}', SC_Lower), ('\u{2130}', '\u{2133}', SC_Upper), ('\u{2134}', '\u{2134}',
- SC_Lower), ('\u{2135}', '\u{2138}', SC_OLetter), ('\u{2139}', '\u{2139}', SC_Lower),
- ('\u{213c}', '\u{213d}', SC_Lower), ('\u{213e}', '\u{213f}', SC_Upper), ('\u{2145}',
- '\u{2145}', SC_Upper), ('\u{2146}', '\u{2149}', SC_Lower), ('\u{214e}', '\u{214e}',
- SC_Lower), ('\u{2160}', '\u{216f}', SC_Upper), ('\u{2170}', '\u{217f}', SC_Lower),
- ('\u{2180}', '\u{2182}', SC_OLetter), ('\u{2183}', '\u{2183}', SC_Upper), ('\u{2184}',
- '\u{2184}', SC_Lower), ('\u{2185}', '\u{2188}', SC_OLetter), ('\u{2308}', '\u{230b}',
- SC_Close), ('\u{2329}', '\u{232a}', SC_Close), ('\u{24b6}', '\u{24cf}', SC_Upper),
- ('\u{24d0}', '\u{24e9}', SC_Lower), ('\u{275b}', '\u{2760}', SC_Close), ('\u{2768}',
- '\u{2775}', SC_Close), ('\u{27c5}', '\u{27c6}', SC_Close), ('\u{27e6}', '\u{27ef}',
- SC_Close), ('\u{2983}', '\u{2998}', SC_Close), ('\u{29d8}', '\u{29db}', SC_Close),
- ('\u{29fc}', '\u{29fd}', SC_Close), ('\u{2c00}', '\u{2c2e}', SC_Upper), ('\u{2c30}',
- '\u{2c5e}', SC_Lower), ('\u{2c60}', '\u{2c60}', SC_Upper), ('\u{2c61}', '\u{2c61}',
- SC_Lower), ('\u{2c62}', '\u{2c64}', SC_Upper), ('\u{2c65}', '\u{2c66}', SC_Lower),
- ('\u{2c67}', '\u{2c67}', SC_Upper), ('\u{2c68}', '\u{2c68}', SC_Lower), ('\u{2c69}',
- '\u{2c69}', SC_Upper), ('\u{2c6a}', '\u{2c6a}', SC_Lower), ('\u{2c6b}', '\u{2c6b}',
- SC_Upper), ('\u{2c6c}', '\u{2c6c}', SC_Lower), ('\u{2c6d}', '\u{2c70}', SC_Upper),
- ('\u{2c71}', '\u{2c71}', SC_Lower), ('\u{2c72}', '\u{2c72}', SC_Upper), ('\u{2c73}',
- '\u{2c74}', SC_Lower), ('\u{2c75}', '\u{2c75}', SC_Upper), ('\u{2c76}', '\u{2c7d}',
- SC_Lower), ('\u{2c7e}', '\u{2c80}', SC_Upper), ('\u{2c81}', '\u{2c81}', SC_Lower),
- ('\u{2c82}', '\u{2c82}', SC_Upper), ('\u{2c83}', '\u{2c83}', SC_Lower), ('\u{2c84}',
- '\u{2c84}', SC_Upper), ('\u{2c85}', '\u{2c85}', SC_Lower), ('\u{2c86}', '\u{2c86}',
- SC_Upper), ('\u{2c87}', '\u{2c87}', SC_Lower), ('\u{2c88}', '\u{2c88}', SC_Upper),
- ('\u{2c89}', '\u{2c89}', SC_Lower), ('\u{2c8a}', '\u{2c8a}', SC_Upper), ('\u{2c8b}',
- '\u{2c8b}', SC_Lower), ('\u{2c8c}', '\u{2c8c}', SC_Upper), ('\u{2c8d}', '\u{2c8d}',
- SC_Lower), ('\u{2c8e}', '\u{2c8e}', SC_Upper), ('\u{2c8f}', '\u{2c8f}', SC_Lower),
- ('\u{2c90}', '\u{2c90}', SC_Upper), ('\u{2c91}', '\u{2c91}', SC_Lower), ('\u{2c92}',
- '\u{2c92}', SC_Upper), ('\u{2c93}', '\u{2c93}', SC_Lower), ('\u{2c94}', '\u{2c94}',
- SC_Upper), ('\u{2c95}', '\u{2c95}', SC_Lower), ('\u{2c96}', '\u{2c96}', SC_Upper),
- ('\u{2c97}', '\u{2c97}', SC_Lower), ('\u{2c98}', '\u{2c98}', SC_Upper), ('\u{2c99}',
- '\u{2c99}', SC_Lower), ('\u{2c9a}', '\u{2c9a}', SC_Upper), ('\u{2c9b}', '\u{2c9b}',
- SC_Lower), ('\u{2c9c}', '\u{2c9c}', SC_Upper), ('\u{2c9d}', '\u{2c9d}', SC_Lower),
- ('\u{2c9e}', '\u{2c9e}', SC_Upper), ('\u{2c9f}', '\u{2c9f}', SC_Lower), ('\u{2ca0}',
- '\u{2ca0}', SC_Upper), ('\u{2ca1}', '\u{2ca1}', SC_Lower), ('\u{2ca2}', '\u{2ca2}',
- SC_Upper), ('\u{2ca3}', '\u{2ca3}', SC_Lower), ('\u{2ca4}', '\u{2ca4}', SC_Upper),
- ('\u{2ca5}', '\u{2ca5}', SC_Lower), ('\u{2ca6}', '\u{2ca6}', SC_Upper), ('\u{2ca7}',
- '\u{2ca7}', SC_Lower), ('\u{2ca8}', '\u{2ca8}', SC_Upper), ('\u{2ca9}', '\u{2ca9}',
- SC_Lower), ('\u{2caa}', '\u{2caa}', SC_Upper), ('\u{2cab}', '\u{2cab}', SC_Lower),
- ('\u{2cac}', '\u{2cac}', SC_Upper), ('\u{2cad}', '\u{2cad}', SC_Lower), ('\u{2cae}',
- '\u{2cae}', SC_Upper), ('\u{2caf}', '\u{2caf}', SC_Lower), ('\u{2cb0}', '\u{2cb0}',
- SC_Upper), ('\u{2cb1}', '\u{2cb1}', SC_Lower), ('\u{2cb2}', '\u{2cb2}', SC_Upper),
- ('\u{2cb3}', '\u{2cb3}', SC_Lower), ('\u{2cb4}', '\u{2cb4}', SC_Upper), ('\u{2cb5}',
- '\u{2cb5}', SC_Lower), ('\u{2cb6}', '\u{2cb6}', SC_Upper), ('\u{2cb7}', '\u{2cb7}',
- SC_Lower), ('\u{2cb8}', '\u{2cb8}', SC_Upper), ('\u{2cb9}', '\u{2cb9}', SC_Lower),
- ('\u{2cba}', '\u{2cba}', SC_Upper), ('\u{2cbb}', '\u{2cbb}', SC_Lower), ('\u{2cbc}',
- '\u{2cbc}', SC_Upper), ('\u{2cbd}', '\u{2cbd}', SC_Lower), ('\u{2cbe}', '\u{2cbe}',
- SC_Upper), ('\u{2cbf}', '\u{2cbf}', SC_Lower), ('\u{2cc0}', '\u{2cc0}', SC_Upper),
- ('\u{2cc1}', '\u{2cc1}', SC_Lower), ('\u{2cc2}', '\u{2cc2}', SC_Upper), ('\u{2cc3}',
- '\u{2cc3}', SC_Lower), ('\u{2cc4}', '\u{2cc4}', SC_Upper), ('\u{2cc5}', '\u{2cc5}',
- SC_Lower), ('\u{2cc6}', '\u{2cc6}', SC_Upper), ('\u{2cc7}', '\u{2cc7}', SC_Lower),
- ('\u{2cc8}', '\u{2cc8}', SC_Upper), ('\u{2cc9}', '\u{2cc9}', SC_Lower), ('\u{2cca}',
- '\u{2cca}', SC_Upper), ('\u{2ccb}', '\u{2ccb}', SC_Lower), ('\u{2ccc}', '\u{2ccc}',
- SC_Upper), ('\u{2ccd}', '\u{2ccd}', SC_Lower), ('\u{2cce}', '\u{2cce}', SC_Upper),
- ('\u{2ccf}', '\u{2ccf}', SC_Lower), ('\u{2cd0}', '\u{2cd0}', SC_Upper), ('\u{2cd1}',
- '\u{2cd1}', SC_Lower), ('\u{2cd2}', '\u{2cd2}', SC_Upper), ('\u{2cd3}', '\u{2cd3}',
- SC_Lower), ('\u{2cd4}', '\u{2cd4}', SC_Upper), ('\u{2cd5}', '\u{2cd5}', SC_Lower),
- ('\u{2cd6}', '\u{2cd6}', SC_Upper), ('\u{2cd7}', '\u{2cd7}', SC_Lower), ('\u{2cd8}',
- '\u{2cd8}', SC_Upper), ('\u{2cd9}', '\u{2cd9}', SC_Lower), ('\u{2cda}', '\u{2cda}',
- SC_Upper), ('\u{2cdb}', '\u{2cdb}', SC_Lower), ('\u{2cdc}', '\u{2cdc}', SC_Upper),
- ('\u{2cdd}', '\u{2cdd}', SC_Lower), ('\u{2cde}', '\u{2cde}', SC_Upper), ('\u{2cdf}',
- '\u{2cdf}', SC_Lower), ('\u{2ce0}', '\u{2ce0}', SC_Upper), ('\u{2ce1}', '\u{2ce1}',
- SC_Lower), ('\u{2ce2}', '\u{2ce2}', SC_Upper), ('\u{2ce3}', '\u{2ce4}', SC_Lower),
- ('\u{2ceb}', '\u{2ceb}', SC_Upper), ('\u{2cec}', '\u{2cec}', SC_Lower), ('\u{2ced}',
- '\u{2ced}', SC_Upper), ('\u{2cee}', '\u{2cee}', SC_Lower), ('\u{2cef}', '\u{2cf1}',
- SC_Extend), ('\u{2cf2}', '\u{2cf2}', SC_Upper), ('\u{2cf3}', '\u{2cf3}', SC_Lower),
- ('\u{2d00}', '\u{2d25}', SC_Lower), ('\u{2d27}', '\u{2d27}', SC_Lower), ('\u{2d2d}',
- '\u{2d2d}', SC_Lower), ('\u{2d30}', '\u{2d67}', SC_OLetter), ('\u{2d6f}', '\u{2d6f}',
- SC_OLetter), ('\u{2d7f}', '\u{2d7f}', SC_Extend), ('\u{2d80}', '\u{2d96}', SC_OLetter),
- ('\u{2da0}', '\u{2da6}', SC_OLetter), ('\u{2da8}', '\u{2dae}', SC_OLetter), ('\u{2db0}',
- '\u{2db6}', SC_OLetter), ('\u{2db8}', '\u{2dbe}', SC_OLetter), ('\u{2dc0}', '\u{2dc6}',
- SC_OLetter), ('\u{2dc8}', '\u{2dce}', SC_OLetter), ('\u{2dd0}', '\u{2dd6}', SC_OLetter),
- ('\u{2dd8}', '\u{2dde}', SC_OLetter), ('\u{2de0}', '\u{2dff}', SC_Extend), ('\u{2e00}',
- '\u{2e0d}', SC_Close), ('\u{2e1c}', '\u{2e1d}', SC_Close), ('\u{2e20}', '\u{2e29}',
- SC_Close), ('\u{2e2e}', '\u{2e2e}', SC_STerm), ('\u{2e2f}', '\u{2e2f}', SC_OLetter),
- ('\u{2e3c}', '\u{2e3c}', SC_STerm), ('\u{2e42}', '\u{2e42}', SC_Close), ('\u{3000}',
- '\u{3000}', SC_Sp), ('\u{3001}', '\u{3001}', SC_SContinue), ('\u{3002}', '\u{3002}',
- SC_STerm), ('\u{3005}', '\u{3007}', SC_OLetter), ('\u{3008}', '\u{3011}', SC_Close),
- ('\u{3014}', '\u{301b}', SC_Close), ('\u{301d}', '\u{301f}', SC_Close), ('\u{3021}',
- '\u{3029}', SC_OLetter), ('\u{302a}', '\u{302f}', SC_Extend), ('\u{3031}', '\u{3035}',
- SC_OLetter), ('\u{3038}', '\u{303c}', SC_OLetter), ('\u{3041}', '\u{3096}', SC_OLetter),
- ('\u{3099}', '\u{309a}', SC_Extend), ('\u{309d}', '\u{309f}', SC_OLetter), ('\u{30a1}',
- '\u{30fa}', SC_OLetter), ('\u{30fc}', '\u{30ff}', SC_OLetter), ('\u{3105}', '\u{312f}',
- SC_OLetter), ('\u{3131}', '\u{318e}', SC_OLetter), ('\u{31a0}', '\u{31ba}', SC_OLetter),
- ('\u{31f0}', '\u{31ff}', SC_OLetter), ('\u{3400}', '\u{4db5}', SC_OLetter), ('\u{4e00}',
- '\u{9fef}', SC_OLetter), ('\u{a000}', '\u{a48c}', SC_OLetter), ('\u{a4d0}', '\u{a4fd}',
- SC_OLetter), ('\u{a4ff}', '\u{a4ff}', SC_STerm), ('\u{a500}', '\u{a60c}', SC_OLetter),
- ('\u{a60e}', '\u{a60f}', SC_STerm), ('\u{a610}', '\u{a61f}', SC_OLetter), ('\u{a620}',
- '\u{a629}', SC_Numeric), ('\u{a62a}', '\u{a62b}', SC_OLetter), ('\u{a640}', '\u{a640}',
- SC_Upper), ('\u{a641}', '\u{a641}', SC_Lower), ('\u{a642}', '\u{a642}', SC_Upper),
- ('\u{a643}', '\u{a643}', SC_Lower), ('\u{a644}', '\u{a644}', SC_Upper), ('\u{a645}',
- '\u{a645}', SC_Lower), ('\u{a646}', '\u{a646}', SC_Upper), ('\u{a647}', '\u{a647}',
- SC_Lower), ('\u{a648}', '\u{a648}', SC_Upper), ('\u{a649}', '\u{a649}', SC_Lower),
- ('\u{a64a}', '\u{a64a}', SC_Upper), ('\u{a64b}', '\u{a64b}', SC_Lower), ('\u{a64c}',
- '\u{a64c}', SC_Upper), ('\u{a64d}', '\u{a64d}', SC_Lower), ('\u{a64e}', '\u{a64e}',
- SC_Upper), ('\u{a64f}', '\u{a64f}', SC_Lower), ('\u{a650}', '\u{a650}', SC_Upper),
- ('\u{a651}', '\u{a651}', SC_Lower), ('\u{a652}', '\u{a652}', SC_Upper), ('\u{a653}',
- '\u{a653}', SC_Lower), ('\u{a654}', '\u{a654}', SC_Upper), ('\u{a655}', '\u{a655}',
- SC_Lower), ('\u{a656}', '\u{a656}', SC_Upper), ('\u{a657}', '\u{a657}', SC_Lower),
- ('\u{a658}', '\u{a658}', SC_Upper), ('\u{a659}', '\u{a659}', SC_Lower), ('\u{a65a}',
- '\u{a65a}', SC_Upper), ('\u{a65b}', '\u{a65b}', SC_Lower), ('\u{a65c}', '\u{a65c}',
- SC_Upper), ('\u{a65d}', '\u{a65d}', SC_Lower), ('\u{a65e}', '\u{a65e}', SC_Upper),
- ('\u{a65f}', '\u{a65f}', SC_Lower), ('\u{a660}', '\u{a660}', SC_Upper), ('\u{a661}',
- '\u{a661}', SC_Lower), ('\u{a662}', '\u{a662}', SC_Upper), ('\u{a663}', '\u{a663}',
- SC_Lower), ('\u{a664}', '\u{a664}', SC_Upper), ('\u{a665}', '\u{a665}', SC_Lower),
- ('\u{a666}', '\u{a666}', SC_Upper), ('\u{a667}', '\u{a667}', SC_Lower), ('\u{a668}',
- '\u{a668}', SC_Upper), ('\u{a669}', '\u{a669}', SC_Lower), ('\u{a66a}', '\u{a66a}',
- SC_Upper), ('\u{a66b}', '\u{a66b}', SC_Lower), ('\u{a66c}', '\u{a66c}', SC_Upper),
- ('\u{a66d}', '\u{a66d}', SC_Lower), ('\u{a66e}', '\u{a66e}', SC_OLetter), ('\u{a66f}',
- '\u{a672}', SC_Extend), ('\u{a674}', '\u{a67d}', SC_Extend), ('\u{a67f}', '\u{a67f}',
- SC_OLetter), ('\u{a680}', '\u{a680}', SC_Upper), ('\u{a681}', '\u{a681}', SC_Lower),
- ('\u{a682}', '\u{a682}', SC_Upper), ('\u{a683}', '\u{a683}', SC_Lower), ('\u{a684}',
- '\u{a684}', SC_Upper), ('\u{a685}', '\u{a685}', SC_Lower), ('\u{a686}', '\u{a686}',
- SC_Upper), ('\u{a687}', '\u{a687}', SC_Lower), ('\u{a688}', '\u{a688}', SC_Upper),
- ('\u{a689}', '\u{a689}', SC_Lower), ('\u{a68a}', '\u{a68a}', SC_Upper), ('\u{a68b}',
- '\u{a68b}', SC_Lower), ('\u{a68c}', '\u{a68c}', SC_Upper), ('\u{a68d}', '\u{a68d}',
- SC_Lower), ('\u{a68e}', '\u{a68e}', SC_Upper), ('\u{a68f}', '\u{a68f}', SC_Lower),
- ('\u{a690}', '\u{a690}', SC_Upper), ('\u{a691}', '\u{a691}', SC_Lower), ('\u{a692}',
- '\u{a692}', SC_Upper), ('\u{a693}', '\u{a693}', SC_Lower), ('\u{a694}', '\u{a694}',
- SC_Upper), ('\u{a695}', '\u{a695}', SC_Lower), ('\u{a696}', '\u{a696}', SC_Upper),
- ('\u{a697}', '\u{a697}', SC_Lower), ('\u{a698}', '\u{a698}', SC_Upper), ('\u{a699}',
- '\u{a699}', SC_Lower), ('\u{a69a}', '\u{a69a}', SC_Upper), ('\u{a69b}', '\u{a69d}',
- SC_Lower), ('\u{a69e}', '\u{a69f}', SC_Extend), ('\u{a6a0}', '\u{a6ef}', SC_OLetter),
- ('\u{a6f0}', '\u{a6f1}', SC_Extend), ('\u{a6f3}', '\u{a6f3}', SC_STerm), ('\u{a6f7}',
- '\u{a6f7}', SC_STerm), ('\u{a717}', '\u{a71f}', SC_OLetter), ('\u{a722}', '\u{a722}',
- SC_Upper), ('\u{a723}', '\u{a723}', SC_Lower), ('\u{a724}', '\u{a724}', SC_Upper),
- ('\u{a725}', '\u{a725}', SC_Lower), ('\u{a726}', '\u{a726}', SC_Upper), ('\u{a727}',
- '\u{a727}', SC_Lower), ('\u{a728}', '\u{a728}', SC_Upper), ('\u{a729}', '\u{a729}',
- SC_Lower), ('\u{a72a}', '\u{a72a}', SC_Upper), ('\u{a72b}', '\u{a72b}', SC_Lower),
- ('\u{a72c}', '\u{a72c}', SC_Upper), ('\u{a72d}', '\u{a72d}', SC_Lower), ('\u{a72e}',
- '\u{a72e}', SC_Upper), ('\u{a72f}', '\u{a731}', SC_Lower), ('\u{a732}', '\u{a732}',
- SC_Upper), ('\u{a733}', '\u{a733}', SC_Lower), ('\u{a734}', '\u{a734}', SC_Upper),
- ('\u{a735}', '\u{a735}', SC_Lower), ('\u{a736}', '\u{a736}', SC_Upper), ('\u{a737}',
- '\u{a737}', SC_Lower), ('\u{a738}', '\u{a738}', SC_Upper), ('\u{a739}', '\u{a739}',
- SC_Lower), ('\u{a73a}', '\u{a73a}', SC_Upper), ('\u{a73b}', '\u{a73b}', SC_Lower),
- ('\u{a73c}', '\u{a73c}', SC_Upper), ('\u{a73d}', '\u{a73d}', SC_Lower), ('\u{a73e}',
- '\u{a73e}', SC_Upper), ('\u{a73f}', '\u{a73f}', SC_Lower), ('\u{a740}', '\u{a740}',
- SC_Upper), ('\u{a741}', '\u{a741}', SC_Lower), ('\u{a742}', '\u{a742}', SC_Upper),
- ('\u{a743}', '\u{a743}', SC_Lower), ('\u{a744}', '\u{a744}', SC_Upper), ('\u{a745}',
- '\u{a745}', SC_Lower), ('\u{a746}', '\u{a746}', SC_Upper), ('\u{a747}', '\u{a747}',
- SC_Lower), ('\u{a748}', '\u{a748}', SC_Upper), ('\u{a749}', '\u{a749}', SC_Lower),
- ('\u{a74a}', '\u{a74a}', SC_Upper), ('\u{a74b}', '\u{a74b}', SC_Lower), ('\u{a74c}',
- '\u{a74c}', SC_Upper), ('\u{a74d}', '\u{a74d}', SC_Lower), ('\u{a74e}', '\u{a74e}',
- SC_Upper), ('\u{a74f}', '\u{a74f}', SC_Lower), ('\u{a750}', '\u{a750}', SC_Upper),
- ('\u{a751}', '\u{a751}', SC_Lower), ('\u{a752}', '\u{a752}', SC_Upper), ('\u{a753}',
- '\u{a753}', SC_Lower), ('\u{a754}', '\u{a754}', SC_Upper), ('\u{a755}', '\u{a755}',
- SC_Lower), ('\u{a756}', '\u{a756}', SC_Upper), ('\u{a757}', '\u{a757}', SC_Lower),
- ('\u{a758}', '\u{a758}', SC_Upper), ('\u{a759}', '\u{a759}', SC_Lower), ('\u{a75a}',
- '\u{a75a}', SC_Upper), ('\u{a75b}', '\u{a75b}', SC_Lower), ('\u{a75c}', '\u{a75c}',
- SC_Upper), ('\u{a75d}', '\u{a75d}', SC_Lower), ('\u{a75e}', '\u{a75e}', SC_Upper),
- ('\u{a75f}', '\u{a75f}', SC_Lower), ('\u{a760}', '\u{a760}', SC_Upper), ('\u{a761}',
- '\u{a761}', SC_Lower), ('\u{a762}', '\u{a762}', SC_Upper), ('\u{a763}', '\u{a763}',
- SC_Lower), ('\u{a764}', '\u{a764}', SC_Upper), ('\u{a765}', '\u{a765}', SC_Lower),
- ('\u{a766}', '\u{a766}', SC_Upper), ('\u{a767}', '\u{a767}', SC_Lower), ('\u{a768}',
- '\u{a768}', SC_Upper), ('\u{a769}', '\u{a769}', SC_Lower), ('\u{a76a}', '\u{a76a}',
- SC_Upper), ('\u{a76b}', '\u{a76b}', SC_Lower), ('\u{a76c}', '\u{a76c}', SC_Upper),
- ('\u{a76d}', '\u{a76d}', SC_Lower), ('\u{a76e}', '\u{a76e}', SC_Upper), ('\u{a76f}',
- '\u{a778}', SC_Lower), ('\u{a779}', '\u{a779}', SC_Upper), ('\u{a77a}', '\u{a77a}',
- SC_Lower), ('\u{a77b}', '\u{a77b}', SC_Upper), ('\u{a77c}', '\u{a77c}', SC_Lower),
- ('\u{a77d}', '\u{a77e}', SC_Upper), ('\u{a77f}', '\u{a77f}', SC_Lower), ('\u{a780}',
- '\u{a780}', SC_Upper), ('\u{a781}', '\u{a781}', SC_Lower), ('\u{a782}', '\u{a782}',
- SC_Upper), ('\u{a783}', '\u{a783}', SC_Lower), ('\u{a784}', '\u{a784}', SC_Upper),
- ('\u{a785}', '\u{a785}', SC_Lower), ('\u{a786}', '\u{a786}', SC_Upper), ('\u{a787}',
- '\u{a787}', SC_Lower), ('\u{a788}', '\u{a788}', SC_OLetter), ('\u{a78b}', '\u{a78b}',
- SC_Upper), ('\u{a78c}', '\u{a78c}', SC_Lower), ('\u{a78d}', '\u{a78d}', SC_Upper),
- ('\u{a78e}', '\u{a78e}', SC_Lower), ('\u{a78f}', '\u{a78f}', SC_OLetter), ('\u{a790}',
- '\u{a790}', SC_Upper), ('\u{a791}', '\u{a791}', SC_Lower), ('\u{a792}', '\u{a792}',
- SC_Upper), ('\u{a793}', '\u{a795}', SC_Lower), ('\u{a796}', '\u{a796}', SC_Upper),
- ('\u{a797}', '\u{a797}', SC_Lower), ('\u{a798}', '\u{a798}', SC_Upper), ('\u{a799}',
- '\u{a799}', SC_Lower), ('\u{a79a}', '\u{a79a}', SC_Upper), ('\u{a79b}', '\u{a79b}',
- SC_Lower), ('\u{a79c}', '\u{a79c}', SC_Upper), ('\u{a79d}', '\u{a79d}', SC_Lower),
- ('\u{a79e}', '\u{a79e}', SC_Upper), ('\u{a79f}', '\u{a79f}', SC_Lower), ('\u{a7a0}',
- '\u{a7a0}', SC_Upper), ('\u{a7a1}', '\u{a7a1}', SC_Lower), ('\u{a7a2}', '\u{a7a2}',
- SC_Upper), ('\u{a7a3}', '\u{a7a3}', SC_Lower), ('\u{a7a4}', '\u{a7a4}', SC_Upper),
- ('\u{a7a5}', '\u{a7a5}', SC_Lower), ('\u{a7a6}', '\u{a7a6}', SC_Upper), ('\u{a7a7}',
- '\u{a7a7}', SC_Lower), ('\u{a7a8}', '\u{a7a8}', SC_Upper), ('\u{a7a9}', '\u{a7a9}',
- SC_Lower), ('\u{a7aa}', '\u{a7ae}', SC_Upper), ('\u{a7af}', '\u{a7af}', SC_Lower),
- ('\u{a7b0}', '\u{a7b4}', SC_Upper), ('\u{a7b5}', '\u{a7b5}', SC_Lower), ('\u{a7b6}',
- '\u{a7b6}', SC_Upper), ('\u{a7b7}', '\u{a7b7}', SC_Lower), ('\u{a7b8}', '\u{a7b8}',
- SC_Upper), ('\u{a7b9}', '\u{a7b9}', SC_Lower), ('\u{a7ba}', '\u{a7ba}', SC_Upper),
- ('\u{a7bb}', '\u{a7bb}', SC_Lower), ('\u{a7bc}', '\u{a7bc}', SC_Upper), ('\u{a7bd}',
- '\u{a7bd}', SC_Lower), ('\u{a7be}', '\u{a7be}', SC_Upper), ('\u{a7bf}', '\u{a7bf}',
- SC_Lower), ('\u{a7c2}', '\u{a7c2}', SC_Upper), ('\u{a7c3}', '\u{a7c3}', SC_Lower),
- ('\u{a7c4}', '\u{a7c6}', SC_Upper), ('\u{a7f7}', '\u{a7f7}', SC_OLetter), ('\u{a7f8}',
- '\u{a7fa}', SC_Lower), ('\u{a7fb}', '\u{a801}', SC_OLetter), ('\u{a802}', '\u{a802}',
- SC_Extend), ('\u{a803}', '\u{a805}', SC_OLetter), ('\u{a806}', '\u{a806}', SC_Extend),
- ('\u{a807}', '\u{a80a}', SC_OLetter), ('\u{a80b}', '\u{a80b}', SC_Extend), ('\u{a80c}',
- '\u{a822}', SC_OLetter), ('\u{a823}', '\u{a827}', SC_Extend), ('\u{a840}', '\u{a873}',
- SC_OLetter), ('\u{a876}', '\u{a877}', SC_STerm), ('\u{a880}', '\u{a881}', SC_Extend),
- ('\u{a882}', '\u{a8b3}', SC_OLetter), ('\u{a8b4}', '\u{a8c5}', SC_Extend), ('\u{a8ce}',
- '\u{a8cf}', SC_STerm), ('\u{a8d0}', '\u{a8d9}', SC_Numeric), ('\u{a8e0}', '\u{a8f1}',
- SC_Extend), ('\u{a8f2}', '\u{a8f7}', SC_OLetter), ('\u{a8fb}', '\u{a8fb}', SC_OLetter),
- ('\u{a8fd}', '\u{a8fe}', SC_OLetter), ('\u{a8ff}', '\u{a8ff}', SC_Extend), ('\u{a900}',
- '\u{a909}', SC_Numeric), ('\u{a90a}', '\u{a925}', SC_OLetter), ('\u{a926}', '\u{a92d}',
- SC_Extend), ('\u{a92f}', '\u{a92f}', SC_STerm), ('\u{a930}', '\u{a946}', SC_OLetter),
- ('\u{a947}', '\u{a953}', SC_Extend), ('\u{a960}', '\u{a97c}', SC_OLetter), ('\u{a980}',
- '\u{a983}', SC_Extend), ('\u{a984}', '\u{a9b2}', SC_OLetter), ('\u{a9b3}', '\u{a9c0}',
- SC_Extend), ('\u{a9c8}', '\u{a9c9}', SC_STerm), ('\u{a9cf}', '\u{a9cf}', SC_OLetter),
- ('\u{a9d0}', '\u{a9d9}', SC_Numeric), ('\u{a9e0}', '\u{a9e4}', SC_OLetter), ('\u{a9e5}',
- '\u{a9e5}', SC_Extend), ('\u{a9e6}', '\u{a9ef}', SC_OLetter), ('\u{a9f0}', '\u{a9f9}',
- SC_Numeric), ('\u{a9fa}', '\u{a9fe}', SC_OLetter), ('\u{aa00}', '\u{aa28}', SC_OLetter),
- ('\u{aa29}', '\u{aa36}', SC_Extend), ('\u{aa40}', '\u{aa42}', SC_OLetter), ('\u{aa43}',
- '\u{aa43}', SC_Extend), ('\u{aa44}', '\u{aa4b}', SC_OLetter), ('\u{aa4c}', '\u{aa4d}',
- SC_Extend), ('\u{aa50}', '\u{aa59}', SC_Numeric), ('\u{aa5d}', '\u{aa5f}', SC_STerm),
- ('\u{aa60}', '\u{aa76}', SC_OLetter), ('\u{aa7a}', '\u{aa7a}', SC_OLetter), ('\u{aa7b}',
- '\u{aa7d}', SC_Extend), ('\u{aa7e}', '\u{aaaf}', SC_OLetter), ('\u{aab0}', '\u{aab0}',
- SC_Extend), ('\u{aab1}', '\u{aab1}', SC_OLetter), ('\u{aab2}', '\u{aab4}', SC_Extend),
- ('\u{aab5}', '\u{aab6}', SC_OLetter), ('\u{aab7}', '\u{aab8}', SC_Extend), ('\u{aab9}',
- '\u{aabd}', SC_OLetter), ('\u{aabe}', '\u{aabf}', SC_Extend), ('\u{aac0}', '\u{aac0}',
- SC_OLetter), ('\u{aac1}', '\u{aac1}', SC_Extend), ('\u{aac2}', '\u{aac2}', SC_OLetter),
- ('\u{aadb}', '\u{aadd}', SC_OLetter), ('\u{aae0}', '\u{aaea}', SC_OLetter), ('\u{aaeb}',
- '\u{aaef}', SC_Extend), ('\u{aaf0}', '\u{aaf1}', SC_STerm), ('\u{aaf2}', '\u{aaf4}',
- SC_OLetter), ('\u{aaf5}', '\u{aaf6}', SC_Extend), ('\u{ab01}', '\u{ab06}', SC_OLetter),
- ('\u{ab09}', '\u{ab0e}', SC_OLetter), ('\u{ab11}', '\u{ab16}', SC_OLetter), ('\u{ab20}',
- '\u{ab26}', SC_OLetter), ('\u{ab28}', '\u{ab2e}', SC_OLetter), ('\u{ab30}', '\u{ab5a}',
- SC_Lower), ('\u{ab5c}', '\u{ab67}', SC_Lower), ('\u{ab70}', '\u{abbf}', SC_Lower),
- ('\u{abc0}', '\u{abe2}', SC_OLetter), ('\u{abe3}', '\u{abea}', SC_Extend), ('\u{abeb}',
- '\u{abeb}', SC_STerm), ('\u{abec}', '\u{abed}', SC_Extend), ('\u{abf0}', '\u{abf9}',
- SC_Numeric), ('\u{ac00}', '\u{d7a3}', SC_OLetter), ('\u{d7b0}', '\u{d7c6}', SC_OLetter),
- ('\u{d7cb}', '\u{d7fb}', SC_OLetter), ('\u{f900}', '\u{fa6d}', SC_OLetter), ('\u{fa70}',
- '\u{fad9}', SC_OLetter), ('\u{fb00}', '\u{fb06}', SC_Lower), ('\u{fb13}', '\u{fb17}',
- SC_Lower), ('\u{fb1d}', '\u{fb1d}', SC_OLetter), ('\u{fb1e}', '\u{fb1e}', SC_Extend),
- ('\u{fb1f}', '\u{fb28}', SC_OLetter), ('\u{fb2a}', '\u{fb36}', SC_OLetter), ('\u{fb38}',
- '\u{fb3c}', SC_OLetter), ('\u{fb3e}', '\u{fb3e}', SC_OLetter), ('\u{fb40}', '\u{fb41}',
- SC_OLetter), ('\u{fb43}', '\u{fb44}', SC_OLetter), ('\u{fb46}', '\u{fbb1}', SC_OLetter),
- ('\u{fbd3}', '\u{fd3d}', SC_OLetter), ('\u{fd3e}', '\u{fd3f}', SC_Close), ('\u{fd50}',
- '\u{fd8f}', SC_OLetter), ('\u{fd92}', '\u{fdc7}', SC_OLetter), ('\u{fdf0}', '\u{fdfb}',
- SC_OLetter), ('\u{fe00}', '\u{fe0f}', SC_Extend), ('\u{fe10}', '\u{fe11}', SC_SContinue),
- ('\u{fe13}', '\u{fe13}', SC_SContinue), ('\u{fe17}', '\u{fe18}', SC_Close), ('\u{fe20}',
- '\u{fe2f}', SC_Extend), ('\u{fe31}', '\u{fe32}', SC_SContinue), ('\u{fe35}', '\u{fe44}',
- SC_Close), ('\u{fe47}', '\u{fe48}', SC_Close), ('\u{fe50}', '\u{fe51}', SC_SContinue),
- ('\u{fe52}', '\u{fe52}', SC_ATerm), ('\u{fe55}', '\u{fe55}', SC_SContinue), ('\u{fe56}',
- '\u{fe57}', SC_STerm), ('\u{fe58}', '\u{fe58}', SC_SContinue), ('\u{fe59}', '\u{fe5e}',
- SC_Close), ('\u{fe63}', '\u{fe63}', SC_SContinue), ('\u{fe70}', '\u{fe74}', SC_OLetter),
- ('\u{fe76}', '\u{fefc}', SC_OLetter), ('\u{feff}', '\u{feff}', SC_Format), ('\u{ff01}',
- '\u{ff01}', SC_STerm), ('\u{ff08}', '\u{ff09}', SC_Close), ('\u{ff0c}', '\u{ff0d}',
- SC_SContinue), ('\u{ff0e}', '\u{ff0e}', SC_ATerm), ('\u{ff10}', '\u{ff19}', SC_Numeric),
- ('\u{ff1a}', '\u{ff1a}', SC_SContinue), ('\u{ff1f}', '\u{ff1f}', SC_STerm), ('\u{ff21}',
- '\u{ff3a}', SC_Upper), ('\u{ff3b}', '\u{ff3b}', SC_Close), ('\u{ff3d}', '\u{ff3d}',
- SC_Close), ('\u{ff41}', '\u{ff5a}', SC_Lower), ('\u{ff5b}', '\u{ff5b}', SC_Close),
- ('\u{ff5d}', '\u{ff5d}', SC_Close), ('\u{ff5f}', '\u{ff60}', SC_Close), ('\u{ff61}',
- '\u{ff61}', SC_STerm), ('\u{ff62}', '\u{ff63}', SC_Close), ('\u{ff64}', '\u{ff64}',
- SC_SContinue), ('\u{ff66}', '\u{ff9d}', SC_OLetter), ('\u{ff9e}', '\u{ff9f}', SC_Extend),
- ('\u{ffa0}', '\u{ffbe}', SC_OLetter), ('\u{ffc2}', '\u{ffc7}', SC_OLetter), ('\u{ffca}',
- '\u{ffcf}', SC_OLetter), ('\u{ffd2}', '\u{ffd7}', SC_OLetter), ('\u{ffda}', '\u{ffdc}',
- SC_OLetter), ('\u{fff9}', '\u{fffb}', SC_Format), ('\u{10000}', '\u{1000b}', SC_OLetter),
- ('\u{1000d}', '\u{10026}', SC_OLetter), ('\u{10028}', '\u{1003a}', SC_OLetter),
- ('\u{1003c}', '\u{1003d}', SC_OLetter), ('\u{1003f}', '\u{1004d}', SC_OLetter),
- ('\u{10050}', '\u{1005d}', SC_OLetter), ('\u{10080}', '\u{100fa}', SC_OLetter),
- ('\u{10140}', '\u{10174}', SC_OLetter), ('\u{101fd}', '\u{101fd}', SC_Extend), ('\u{10280}',
- '\u{1029c}', SC_OLetter), ('\u{102a0}', '\u{102d0}', SC_OLetter), ('\u{102e0}', '\u{102e0}',
- SC_Extend), ('\u{10300}', '\u{1031f}', SC_OLetter), ('\u{1032d}', '\u{1034a}', SC_OLetter),
- ('\u{10350}', '\u{10375}', SC_OLetter), ('\u{10376}', '\u{1037a}', SC_Extend), ('\u{10380}',
- '\u{1039d}', SC_OLetter), ('\u{103a0}', '\u{103c3}', SC_OLetter), ('\u{103c8}', '\u{103cf}',
- SC_OLetter), ('\u{103d1}', '\u{103d5}', SC_OLetter), ('\u{10400}', '\u{10427}', SC_Upper),
- ('\u{10428}', '\u{1044f}', SC_Lower), ('\u{10450}', '\u{1049d}', SC_OLetter), ('\u{104a0}',
- '\u{104a9}', SC_Numeric), ('\u{104b0}', '\u{104d3}', SC_Upper), ('\u{104d8}', '\u{104fb}',
- SC_Lower), ('\u{10500}', '\u{10527}', SC_OLetter), ('\u{10530}', '\u{10563}', SC_OLetter),
- ('\u{10600}', '\u{10736}', SC_OLetter), ('\u{10740}', '\u{10755}', SC_OLetter),
- ('\u{10760}', '\u{10767}', SC_OLetter), ('\u{10800}', '\u{10805}', SC_OLetter),
- ('\u{10808}', '\u{10808}', SC_OLetter), ('\u{1080a}', '\u{10835}', SC_OLetter),
- ('\u{10837}', '\u{10838}', SC_OLetter), ('\u{1083c}', '\u{1083c}', SC_OLetter),
- ('\u{1083f}', '\u{10855}', SC_OLetter), ('\u{10860}', '\u{10876}', SC_OLetter),
- ('\u{10880}', '\u{1089e}', SC_OLetter), ('\u{108e0}', '\u{108f2}', SC_OLetter),
- ('\u{108f4}', '\u{108f5}', SC_OLetter), ('\u{10900}', '\u{10915}', SC_OLetter),
- ('\u{10920}', '\u{10939}', SC_OLetter), ('\u{10980}', '\u{109b7}', SC_OLetter),
- ('\u{109be}', '\u{109bf}', SC_OLetter), ('\u{10a00}', '\u{10a00}', SC_OLetter),
- ('\u{10a01}', '\u{10a03}', SC_Extend), ('\u{10a05}', '\u{10a06}', SC_Extend), ('\u{10a0c}',
- '\u{10a0f}', SC_Extend), ('\u{10a10}', '\u{10a13}', SC_OLetter), ('\u{10a15}', '\u{10a17}',
- SC_OLetter), ('\u{10a19}', '\u{10a35}', SC_OLetter), ('\u{10a38}', '\u{10a3a}', SC_Extend),
- ('\u{10a3f}', '\u{10a3f}', SC_Extend), ('\u{10a56}', '\u{10a57}', SC_STerm), ('\u{10a60}',
- '\u{10a7c}', SC_OLetter), ('\u{10a80}', '\u{10a9c}', SC_OLetter), ('\u{10ac0}', '\u{10ac7}',
- SC_OLetter), ('\u{10ac9}', '\u{10ae4}', SC_OLetter), ('\u{10ae5}', '\u{10ae6}', SC_Extend),
- ('\u{10b00}', '\u{10b35}', SC_OLetter), ('\u{10b40}', '\u{10b55}', SC_OLetter),
- ('\u{10b60}', '\u{10b72}', SC_OLetter), ('\u{10b80}', '\u{10b91}', SC_OLetter),
- ('\u{10c00}', '\u{10c48}', SC_OLetter), ('\u{10c80}', '\u{10cb2}', SC_Upper), ('\u{10cc0}',
- '\u{10cf2}', SC_Lower), ('\u{10d00}', '\u{10d23}', SC_OLetter), ('\u{10d24}', '\u{10d27}',
- SC_Extend), ('\u{10d30}', '\u{10d39}', SC_Numeric), ('\u{10f00}', '\u{10f1c}', SC_OLetter),
- ('\u{10f27}', '\u{10f27}', SC_OLetter), ('\u{10f30}', '\u{10f45}', SC_OLetter),
- ('\u{10f46}', '\u{10f50}', SC_Extend), ('\u{10f55}', '\u{10f59}', SC_STerm), ('\u{10fe0}',
- '\u{10ff6}', SC_OLetter), ('\u{11000}', '\u{11002}', SC_Extend), ('\u{11003}', '\u{11037}',
- SC_OLetter), ('\u{11038}', '\u{11046}', SC_Extend), ('\u{11047}', '\u{11048}', SC_STerm),
- ('\u{11066}', '\u{1106f}', SC_Numeric), ('\u{1107f}', '\u{11082}', SC_Extend), ('\u{11083}',
- '\u{110af}', SC_OLetter), ('\u{110b0}', '\u{110ba}', SC_Extend), ('\u{110bd}', '\u{110bd}',
- SC_Format), ('\u{110be}', '\u{110c1}', SC_STerm), ('\u{110cd}', '\u{110cd}', SC_Format),
- ('\u{110d0}', '\u{110e8}', SC_OLetter), ('\u{110f0}', '\u{110f9}', SC_Numeric),
- ('\u{11100}', '\u{11102}', SC_Extend), ('\u{11103}', '\u{11126}', SC_OLetter), ('\u{11127}',
- '\u{11134}', SC_Extend), ('\u{11136}', '\u{1113f}', SC_Numeric), ('\u{11141}', '\u{11143}',
- SC_STerm), ('\u{11144}', '\u{11144}', SC_OLetter), ('\u{11145}', '\u{11146}', SC_Extend),
- ('\u{11150}', '\u{11172}', SC_OLetter), ('\u{11173}', '\u{11173}', SC_Extend), ('\u{11176}',
- '\u{11176}', SC_OLetter), ('\u{11180}', '\u{11182}', SC_Extend), ('\u{11183}', '\u{111b2}',
- SC_OLetter), ('\u{111b3}', '\u{111c0}', SC_Extend), ('\u{111c1}', '\u{111c4}', SC_OLetter),
- ('\u{111c5}', '\u{111c6}', SC_STerm), ('\u{111c9}', '\u{111cc}', SC_Extend), ('\u{111cd}',
- '\u{111cd}', SC_STerm), ('\u{111d0}', '\u{111d9}', SC_Numeric), ('\u{111da}', '\u{111da}',
- SC_OLetter), ('\u{111dc}', '\u{111dc}', SC_OLetter), ('\u{111de}', '\u{111df}', SC_STerm),
- ('\u{11200}', '\u{11211}', SC_OLetter), ('\u{11213}', '\u{1122b}', SC_OLetter),
- ('\u{1122c}', '\u{11237}', SC_Extend), ('\u{11238}', '\u{11239}', SC_STerm), ('\u{1123b}',
- '\u{1123c}', SC_STerm), ('\u{1123e}', '\u{1123e}', SC_Extend), ('\u{11280}', '\u{11286}',
- SC_OLetter), ('\u{11288}', '\u{11288}', SC_OLetter), ('\u{1128a}', '\u{1128d}', SC_OLetter),
- ('\u{1128f}', '\u{1129d}', SC_OLetter), ('\u{1129f}', '\u{112a8}', SC_OLetter),
- ('\u{112a9}', '\u{112a9}', SC_STerm), ('\u{112b0}', '\u{112de}', SC_OLetter), ('\u{112df}',
- '\u{112ea}', SC_Extend), ('\u{112f0}', '\u{112f9}', SC_Numeric), ('\u{11300}', '\u{11303}',
- SC_Extend), ('\u{11305}', '\u{1130c}', SC_OLetter), ('\u{1130f}', '\u{11310}', SC_OLetter),
- ('\u{11313}', '\u{11328}', SC_OLetter), ('\u{1132a}', '\u{11330}', SC_OLetter),
- ('\u{11332}', '\u{11333}', SC_OLetter), ('\u{11335}', '\u{11339}', SC_OLetter),
- ('\u{1133b}', '\u{1133c}', SC_Extend), ('\u{1133d}', '\u{1133d}', SC_OLetter), ('\u{1133e}',
- '\u{11344}', SC_Extend), ('\u{11347}', '\u{11348}', SC_Extend), ('\u{1134b}', '\u{1134d}',
- SC_Extend), ('\u{11350}', '\u{11350}', SC_OLetter), ('\u{11357}', '\u{11357}', SC_Extend),
- ('\u{1135d}', '\u{11361}', SC_OLetter), ('\u{11362}', '\u{11363}', SC_Extend), ('\u{11366}',
- '\u{1136c}', SC_Extend), ('\u{11370}', '\u{11374}', SC_Extend), ('\u{11400}', '\u{11434}',
- SC_OLetter), ('\u{11435}', '\u{11446}', SC_Extend), ('\u{11447}', '\u{1144a}', SC_OLetter),
- ('\u{1144b}', '\u{1144c}', SC_STerm), ('\u{11450}', '\u{11459}', SC_Numeric), ('\u{1145e}',
- '\u{1145e}', SC_Extend), ('\u{1145f}', '\u{1145f}', SC_OLetter), ('\u{11480}', '\u{114af}',
- SC_OLetter), ('\u{114b0}', '\u{114c3}', SC_Extend), ('\u{114c4}', '\u{114c5}', SC_OLetter),
- ('\u{114c7}', '\u{114c7}', SC_OLetter), ('\u{114d0}', '\u{114d9}', SC_Numeric),
- ('\u{11580}', '\u{115ae}', SC_OLetter), ('\u{115af}', '\u{115b5}', SC_Extend), ('\u{115b8}',
- '\u{115c0}', SC_Extend), ('\u{115c2}', '\u{115c3}', SC_STerm), ('\u{115c9}', '\u{115d7}',
- SC_STerm), ('\u{115d8}', '\u{115db}', SC_OLetter), ('\u{115dc}', '\u{115dd}', SC_Extend),
- ('\u{11600}', '\u{1162f}', SC_OLetter), ('\u{11630}', '\u{11640}', SC_Extend), ('\u{11641}',
- '\u{11642}', SC_STerm), ('\u{11644}', '\u{11644}', SC_OLetter), ('\u{11650}', '\u{11659}',
- SC_Numeric), ('\u{11680}', '\u{116aa}', SC_OLetter), ('\u{116ab}', '\u{116b7}', SC_Extend),
- ('\u{116b8}', '\u{116b8}', SC_OLetter), ('\u{116c0}', '\u{116c9}', SC_Numeric),
- ('\u{11700}', '\u{1171a}', SC_OLetter), ('\u{1171d}', '\u{1172b}', SC_Extend), ('\u{11730}',
- '\u{11739}', SC_Numeric), ('\u{1173c}', '\u{1173e}', SC_STerm), ('\u{11800}', '\u{1182b}',
- SC_OLetter), ('\u{1182c}', '\u{1183a}', SC_Extend), ('\u{118a0}', '\u{118bf}', SC_Upper),
- ('\u{118c0}', '\u{118df}', SC_Lower), ('\u{118e0}', '\u{118e9}', SC_Numeric), ('\u{118ff}',
- '\u{118ff}', SC_OLetter), ('\u{119a0}', '\u{119a7}', SC_OLetter), ('\u{119aa}', '\u{119d0}',
- SC_OLetter), ('\u{119d1}', '\u{119d7}', SC_Extend), ('\u{119da}', '\u{119e0}', SC_Extend),
- ('\u{119e1}', '\u{119e1}', SC_OLetter), ('\u{119e3}', '\u{119e3}', SC_OLetter),
- ('\u{119e4}', '\u{119e4}', SC_Extend), ('\u{11a00}', '\u{11a00}', SC_OLetter), ('\u{11a01}',
- '\u{11a0a}', SC_Extend), ('\u{11a0b}', '\u{11a32}', SC_OLetter), ('\u{11a33}', '\u{11a39}',
- SC_Extend), ('\u{11a3a}', '\u{11a3a}', SC_OLetter), ('\u{11a3b}', '\u{11a3e}', SC_Extend),
- ('\u{11a42}', '\u{11a43}', SC_STerm), ('\u{11a47}', '\u{11a47}', SC_Extend), ('\u{11a50}',
- '\u{11a50}', SC_OLetter), ('\u{11a51}', '\u{11a5b}', SC_Extend), ('\u{11a5c}', '\u{11a89}',
- SC_OLetter), ('\u{11a8a}', '\u{11a99}', SC_Extend), ('\u{11a9b}', '\u{11a9c}', SC_STerm),
- ('\u{11a9d}', '\u{11a9d}', SC_OLetter), ('\u{11ac0}', '\u{11af8}', SC_OLetter),
- ('\u{11c00}', '\u{11c08}', SC_OLetter), ('\u{11c0a}', '\u{11c2e}', SC_OLetter),
- ('\u{11c2f}', '\u{11c36}', SC_Extend), ('\u{11c38}', '\u{11c3f}', SC_Extend), ('\u{11c40}',
- '\u{11c40}', SC_OLetter), ('\u{11c41}', '\u{11c42}', SC_STerm), ('\u{11c50}', '\u{11c59}',
- SC_Numeric), ('\u{11c72}', '\u{11c8f}', SC_OLetter), ('\u{11c92}', '\u{11ca7}', SC_Extend),
- ('\u{11ca9}', '\u{11cb6}', SC_Extend), ('\u{11d00}', '\u{11d06}', SC_OLetter), ('\u{11d08}',
- '\u{11d09}', SC_OLetter), ('\u{11d0b}', '\u{11d30}', SC_OLetter), ('\u{11d31}', '\u{11d36}',
- SC_Extend), ('\u{11d3a}', '\u{11d3a}', SC_Extend), ('\u{11d3c}', '\u{11d3d}', SC_Extend),
- ('\u{11d3f}', '\u{11d45}', SC_Extend), ('\u{11d46}', '\u{11d46}', SC_OLetter), ('\u{11d47}',
- '\u{11d47}', SC_Extend), ('\u{11d50}', '\u{11d59}', SC_Numeric), ('\u{11d60}', '\u{11d65}',
- SC_OLetter), ('\u{11d67}', '\u{11d68}', SC_OLetter), ('\u{11d6a}', '\u{11d89}', SC_OLetter),
- ('\u{11d8a}', '\u{11d8e}', SC_Extend), ('\u{11d90}', '\u{11d91}', SC_Extend), ('\u{11d93}',
- '\u{11d97}', SC_Extend), ('\u{11d98}', '\u{11d98}', SC_OLetter), ('\u{11da0}', '\u{11da9}',
- SC_Numeric), ('\u{11ee0}', '\u{11ef2}', SC_OLetter), ('\u{11ef3}', '\u{11ef6}', SC_Extend),
- ('\u{11ef7}', '\u{11ef8}', SC_STerm), ('\u{12000}', '\u{12399}', SC_OLetter), ('\u{12400}',
- '\u{1246e}', SC_OLetter), ('\u{12480}', '\u{12543}', SC_OLetter), ('\u{13000}', '\u{1342e}',
- SC_OLetter), ('\u{13430}', '\u{13438}', SC_Format), ('\u{14400}', '\u{14646}', SC_OLetter),
- ('\u{16800}', '\u{16a38}', SC_OLetter), ('\u{16a40}', '\u{16a5e}', SC_OLetter),
- ('\u{16a60}', '\u{16a69}', SC_Numeric), ('\u{16a6e}', '\u{16a6f}', SC_STerm), ('\u{16ad0}',
- '\u{16aed}', SC_OLetter), ('\u{16af0}', '\u{16af4}', SC_Extend), ('\u{16af5}', '\u{16af5}',
- SC_STerm), ('\u{16b00}', '\u{16b2f}', SC_OLetter), ('\u{16b30}', '\u{16b36}', SC_Extend),
- ('\u{16b37}', '\u{16b38}', SC_STerm), ('\u{16b40}', '\u{16b43}', SC_OLetter), ('\u{16b44}',
- '\u{16b44}', SC_STerm), ('\u{16b50}', '\u{16b59}', SC_Numeric), ('\u{16b63}', '\u{16b77}',
- SC_OLetter), ('\u{16b7d}', '\u{16b8f}', SC_OLetter), ('\u{16e40}', '\u{16e5f}', SC_Upper),
- ('\u{16e60}', '\u{16e7f}', SC_Lower), ('\u{16e98}', '\u{16e98}', SC_STerm), ('\u{16f00}',
- '\u{16f4a}', SC_OLetter), ('\u{16f4f}', '\u{16f4f}', SC_Extend), ('\u{16f50}', '\u{16f50}',
- SC_OLetter), ('\u{16f51}', '\u{16f87}', SC_Extend), ('\u{16f8f}', '\u{16f92}', SC_Extend),
- ('\u{16f93}', '\u{16f9f}', SC_OLetter), ('\u{16fe0}', '\u{16fe1}', SC_OLetter),
- ('\u{16fe3}', '\u{16fe3}', SC_OLetter), ('\u{17000}', '\u{187f7}', SC_OLetter),
- ('\u{18800}', '\u{18af2}', SC_OLetter), ('\u{1b000}', '\u{1b11e}', SC_OLetter),
- ('\u{1b150}', '\u{1b152}', SC_OLetter), ('\u{1b164}', '\u{1b167}', SC_OLetter),
- ('\u{1b170}', '\u{1b2fb}', SC_OLetter), ('\u{1bc00}', '\u{1bc6a}', SC_OLetter),
- ('\u{1bc70}', '\u{1bc7c}', SC_OLetter), ('\u{1bc80}', '\u{1bc88}', SC_OLetter),
- ('\u{1bc90}', '\u{1bc99}', SC_OLetter), ('\u{1bc9d}', '\u{1bc9e}', SC_Extend), ('\u{1bc9f}',
- '\u{1bc9f}', SC_STerm), ('\u{1bca0}', '\u{1bca3}', SC_Format), ('\u{1d165}', '\u{1d169}',
- SC_Extend), ('\u{1d16d}', '\u{1d172}', SC_Extend), ('\u{1d173}', '\u{1d17a}', SC_Format),
- ('\u{1d17b}', '\u{1d182}', SC_Extend), ('\u{1d185}', '\u{1d18b}', SC_Extend), ('\u{1d1aa}',
- '\u{1d1ad}', SC_Extend), ('\u{1d242}', '\u{1d244}', SC_Extend), ('\u{1d400}', '\u{1d419}',
- SC_Upper), ('\u{1d41a}', '\u{1d433}', SC_Lower), ('\u{1d434}', '\u{1d44d}', SC_Upper),
- ('\u{1d44e}', '\u{1d454}', SC_Lower), ('\u{1d456}', '\u{1d467}', SC_Lower), ('\u{1d468}',
- '\u{1d481}', SC_Upper), ('\u{1d482}', '\u{1d49b}', SC_Lower), ('\u{1d49c}', '\u{1d49c}',
- SC_Upper), ('\u{1d49e}', '\u{1d49f}', SC_Upper), ('\u{1d4a2}', '\u{1d4a2}', SC_Upper),
- ('\u{1d4a5}', '\u{1d4a6}', SC_Upper), ('\u{1d4a9}', '\u{1d4ac}', SC_Upper), ('\u{1d4ae}',
- '\u{1d4b5}', SC_Upper), ('\u{1d4b6}', '\u{1d4b9}', SC_Lower), ('\u{1d4bb}', '\u{1d4bb}',
- SC_Lower), ('\u{1d4bd}', '\u{1d4c3}', SC_Lower), ('\u{1d4c5}', '\u{1d4cf}', SC_Lower),
- ('\u{1d4d0}', '\u{1d4e9}', SC_Upper), ('\u{1d4ea}', '\u{1d503}', SC_Lower), ('\u{1d504}',
- '\u{1d505}', SC_Upper), ('\u{1d507}', '\u{1d50a}', SC_Upper), ('\u{1d50d}', '\u{1d514}',
- SC_Upper), ('\u{1d516}', '\u{1d51c}', SC_Upper), ('\u{1d51e}', '\u{1d537}', SC_Lower),
- ('\u{1d538}', '\u{1d539}', SC_Upper), ('\u{1d53b}', '\u{1d53e}', SC_Upper), ('\u{1d540}',
- '\u{1d544}', SC_Upper), ('\u{1d546}', '\u{1d546}', SC_Upper), ('\u{1d54a}', '\u{1d550}',
- SC_Upper), ('\u{1d552}', '\u{1d56b}', SC_Lower), ('\u{1d56c}', '\u{1d585}', SC_Upper),
- ('\u{1d586}', '\u{1d59f}', SC_Lower), ('\u{1d5a0}', '\u{1d5b9}', SC_Upper), ('\u{1d5ba}',
- '\u{1d5d3}', SC_Lower), ('\u{1d5d4}', '\u{1d5ed}', SC_Upper), ('\u{1d5ee}', '\u{1d607}',
- SC_Lower), ('\u{1d608}', '\u{1d621}', SC_Upper), ('\u{1d622}', '\u{1d63b}', SC_Lower),
- ('\u{1d63c}', '\u{1d655}', SC_Upper), ('\u{1d656}', '\u{1d66f}', SC_Lower), ('\u{1d670}',
- '\u{1d689}', SC_Upper), ('\u{1d68a}', '\u{1d6a5}', SC_Lower), ('\u{1d6a8}', '\u{1d6c0}',
- SC_Upper), ('\u{1d6c2}', '\u{1d6da}', SC_Lower), ('\u{1d6dc}', '\u{1d6e1}', SC_Lower),
- ('\u{1d6e2}', '\u{1d6fa}', SC_Upper), ('\u{1d6fc}', '\u{1d714}', SC_Lower), ('\u{1d716}',
- '\u{1d71b}', SC_Lower), ('\u{1d71c}', '\u{1d734}', SC_Upper), ('\u{1d736}', '\u{1d74e}',
- SC_Lower), ('\u{1d750}', '\u{1d755}', SC_Lower), ('\u{1d756}', '\u{1d76e}', SC_Upper),
- ('\u{1d770}', '\u{1d788}', SC_Lower), ('\u{1d78a}', '\u{1d78f}', SC_Lower), ('\u{1d790}',
- '\u{1d7a8}', SC_Upper), ('\u{1d7aa}', '\u{1d7c2}', SC_Lower), ('\u{1d7c4}', '\u{1d7c9}',
- SC_Lower), ('\u{1d7ca}', '\u{1d7ca}', SC_Upper), ('\u{1d7cb}', '\u{1d7cb}', SC_Lower),
- ('\u{1d7ce}', '\u{1d7ff}', SC_Numeric), ('\u{1da00}', '\u{1da36}', SC_Extend), ('\u{1da3b}',
- '\u{1da6c}', SC_Extend), ('\u{1da75}', '\u{1da75}', SC_Extend), ('\u{1da84}', '\u{1da84}',
- SC_Extend), ('\u{1da88}', '\u{1da88}', SC_STerm), ('\u{1da9b}', '\u{1da9f}', SC_Extend),
- ('\u{1daa1}', '\u{1daaf}', SC_Extend), ('\u{1e000}', '\u{1e006}', SC_Extend), ('\u{1e008}',
- '\u{1e018}', SC_Extend), ('\u{1e01b}', '\u{1e021}', SC_Extend), ('\u{1e023}', '\u{1e024}',
- SC_Extend), ('\u{1e026}', '\u{1e02a}', SC_Extend), ('\u{1e100}', '\u{1e12c}', SC_OLetter),
- ('\u{1e130}', '\u{1e136}', SC_Extend), ('\u{1e137}', '\u{1e13d}', SC_OLetter), ('\u{1e140}',
- '\u{1e149}', SC_Numeric), ('\u{1e14e}', '\u{1e14e}', SC_OLetter), ('\u{1e2c0}', '\u{1e2eb}',
- SC_OLetter), ('\u{1e2ec}', '\u{1e2ef}', SC_Extend), ('\u{1e2f0}', '\u{1e2f9}', SC_Numeric),
- ('\u{1e800}', '\u{1e8c4}', SC_OLetter), ('\u{1e8d0}', '\u{1e8d6}', SC_Extend), ('\u{1e900}',
- '\u{1e921}', SC_Upper), ('\u{1e922}', '\u{1e943}', SC_Lower), ('\u{1e944}', '\u{1e94a}',
- SC_Extend), ('\u{1e94b}', '\u{1e94b}', SC_OLetter), ('\u{1e950}', '\u{1e959}', SC_Numeric),
- ('\u{1ee00}', '\u{1ee03}', SC_OLetter), ('\u{1ee05}', '\u{1ee1f}', SC_OLetter),
- ('\u{1ee21}', '\u{1ee22}', SC_OLetter), ('\u{1ee24}', '\u{1ee24}', SC_OLetter),
- ('\u{1ee27}', '\u{1ee27}', SC_OLetter), ('\u{1ee29}', '\u{1ee32}', SC_OLetter),
- ('\u{1ee34}', '\u{1ee37}', SC_OLetter), ('\u{1ee39}', '\u{1ee39}', SC_OLetter),
- ('\u{1ee3b}', '\u{1ee3b}', SC_OLetter), ('\u{1ee42}', '\u{1ee42}', SC_OLetter),
- ('\u{1ee47}', '\u{1ee47}', SC_OLetter), ('\u{1ee49}', '\u{1ee49}', SC_OLetter),
- ('\u{1ee4b}', '\u{1ee4b}', SC_OLetter), ('\u{1ee4d}', '\u{1ee4f}', SC_OLetter),
- ('\u{1ee51}', '\u{1ee52}', SC_OLetter), ('\u{1ee54}', '\u{1ee54}', SC_OLetter),
- ('\u{1ee57}', '\u{1ee57}', SC_OLetter), ('\u{1ee59}', '\u{1ee59}', SC_OLetter),
- ('\u{1ee5b}', '\u{1ee5b}', SC_OLetter), ('\u{1ee5d}', '\u{1ee5d}', SC_OLetter),
- ('\u{1ee5f}', '\u{1ee5f}', SC_OLetter), ('\u{1ee61}', '\u{1ee62}', SC_OLetter),
- ('\u{1ee64}', '\u{1ee64}', SC_OLetter), ('\u{1ee67}', '\u{1ee6a}', SC_OLetter),
- ('\u{1ee6c}', '\u{1ee72}', SC_OLetter), ('\u{1ee74}', '\u{1ee77}', SC_OLetter),
- ('\u{1ee79}', '\u{1ee7c}', SC_OLetter), ('\u{1ee7e}', '\u{1ee7e}', SC_OLetter),
- ('\u{1ee80}', '\u{1ee89}', SC_OLetter), ('\u{1ee8b}', '\u{1ee9b}', SC_OLetter),
- ('\u{1eea1}', '\u{1eea3}', SC_OLetter), ('\u{1eea5}', '\u{1eea9}', SC_OLetter),
- ('\u{1eeab}', '\u{1eebb}', SC_OLetter), ('\u{1f130}', '\u{1f149}', SC_Upper), ('\u{1f150}',
- '\u{1f169}', SC_Upper), ('\u{1f170}', '\u{1f189}', SC_Upper), ('\u{1f676}', '\u{1f678}',
- SC_Close), ('\u{20000}', '\u{2a6d6}', SC_OLetter), ('\u{2a700}', '\u{2b734}', SC_OLetter),
- ('\u{2b740}', '\u{2b81d}', SC_OLetter), ('\u{2b820}', '\u{2cea1}', SC_OLetter),
- ('\u{2ceb0}', '\u{2ebe0}', SC_OLetter), ('\u{2f800}', '\u{2fa1d}', SC_OLetter),
- ('\u{e0001}', '\u{e0001}', SC_Format), ('\u{e0020}', '\u{e007f}', SC_Extend), ('\u{e0100}',
- '\u{e01ef}', SC_Extend)
- ];
-
-}
diff --git a/unicode-segmentation/src/test.rs b/unicode-segmentation/src/test.rs
deleted file mode 100644
index 75b77c5..0000000
--- a/unicode-segmentation/src/test.rs
+++ /dev/null
@@ -1,197 +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.
-
-use super::UnicodeSegmentation;
-
-use std::prelude::v1::*;
-
-#[test]
-fn test_graphemes() {
- use testdata::{TEST_SAME, TEST_DIFF};
-
- pub const EXTRA_DIFF: &'static [(&'static str,
- &'static [&'static str],
- &'static [&'static str])] = &[
- // Official test suite doesn't include two Prepend chars between two other chars.
- ("\u{20}\u{600}\u{600}\u{20}",
- &["\u{20}", "\u{600}\u{600}\u{20}"],
- &["\u{20}", "\u{600}", "\u{600}", "\u{20}"]),
-
- // Test for Prepend followed by two Any chars
- ("\u{600}\u{20}\u{20}",
- &["\u{600}\u{20}", "\u{20}"],
- &["\u{600}", "\u{20}", "\u{20}"]),
- ];
-
- pub const EXTRA_SAME: &'static [(&'static str, &'static [&'static str])] = &[
- // family emoji (more than two emoji joined by ZWJ)
- ("\u{1f468}\u{200d}\u{1f467}\u{200d}\u{1f466}",
- &["\u{1f468}\u{200d}\u{1f467}\u{200d}\u{1f466}"]),
- // cartwheel emoji followed by two fitzpatrick skin tone modifiers
- // (test case from issue #19)
- ("\u{1F938}\u{1F3FE}\u{1F3FE}",
- &["\u{1F938}\u{1F3FE}\u{1F3FE}"]),
- ];
-
- for &(s, g) in TEST_SAME.iter().chain(EXTRA_SAME) {
- // test forward iterator
- assert!(UnicodeSegmentation::graphemes(s, true).eq(g.iter().cloned()));
- assert!(UnicodeSegmentation::graphemes(s, false).eq(g.iter().cloned()));
-
- // test reverse iterator
- assert!(UnicodeSegmentation::graphemes(s, true).rev().eq(g.iter().rev().cloned()));
- assert!(UnicodeSegmentation::graphemes(s, false).rev().eq(g.iter().rev().cloned()));
- }
-
- for &(s, gt, gf) in TEST_DIFF.iter().chain(EXTRA_DIFF) {
- // test forward iterator
- assert!(UnicodeSegmentation::graphemes(s, true).eq(gt.iter().cloned()));
- assert!(UnicodeSegmentation::graphemes(s, false).eq(gf.iter().cloned()));
-
- // test reverse iterator
- assert!(UnicodeSegmentation::graphemes(s, true).rev().eq(gt.iter().rev().cloned()));
- assert!(UnicodeSegmentation::graphemes(s, false).rev().eq(gf.iter().rev().cloned()));
- }
-
- // test the indices iterators
- let s = "a̐éö̲\r\n";
- let gr_inds = UnicodeSegmentation::grapheme_indices(s, true).collect::<Vec<(usize, &str)>>();
- let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
- assert_eq!(gr_inds, b);
- let gr_inds = UnicodeSegmentation::grapheme_indices(s, true).rev().collect::<Vec<(usize, &str)>>();
- let b: &[_] = &[(11, "\r\n"), (6, "ö̲"), (3, "é"), (0, "a̐")];
- assert_eq!(gr_inds, b);
- let mut gr_inds_iter = UnicodeSegmentation::grapheme_indices(s, true);
- {
- let gr_inds = gr_inds_iter.by_ref();
- let e1 = gr_inds.size_hint();
- assert_eq!(e1, (1, Some(13)));
- let c = gr_inds.count();
- assert_eq!(c, 4);
- }
- let e2 = gr_inds_iter.size_hint();
- assert_eq!(e2, (0, Some(0)));
-
- // make sure the reverse iterator does the right thing with "\n" at beginning of string
- let s = "\n\r\n\r";
- let gr = UnicodeSegmentation::graphemes(s, true).rev().collect::<Vec<&str>>();
- let b: &[_] = &["\r", "\r\n", "\n"];
- assert_eq!(gr, b);
-}
-
-#[test]
-fn test_words() {
- use testdata::TEST_WORD;
-
- // Unicode's official tests don't really test longer chains of flag emoji
- // TODO This could be improved with more tests like flag emoji with interspersed Extend chars and ZWJ
- const EXTRA_TESTS: &'static [(&'static str, &'static [&'static str])] = &[
- ("🇦🇫🇦🇽🇦🇱🇩🇿🇦🇸🇦🇩🇦🇴", &["🇦🇫", "🇦🇽", "🇦🇱", "🇩🇿", "🇦🇸", "🇦🇩", "🇦🇴"]),
- ("🇦🇫🇦🇽🇦🇱🇩🇿🇦🇸🇦🇩🇦", &["🇦🇫", "🇦🇽", "🇦🇱", "🇩🇿", "🇦🇸", "🇦🇩", "🇦"]),
- ("🇦a🇫🇦🇽a🇦🇱🇩🇿🇦🇸🇦🇩🇦", &["🇦", "a", "🇫🇦", "🇽", "a", "🇦🇱", "🇩🇿", "🇦🇸", "🇦🇩", "🇦"]),
- ("\u{1f468}\u{200d}\u{1f468}\u{200d}\u{1f466}", &["\u{1f468}\u{200d}\u{1f468}\u{200d}\u{1f466}"]),
- ("😌👎🏼", &["😌", "👎🏼"]),
- // perhaps wrong, spaces should not be included?
- ("hello world", &["hello", " ", "world"]),
- ("🇨🇦🇨🇭🇿🇲🇿 hi", &["🇨🇦", "🇨🇭", "🇿🇲", "🇿", " ", "hi"]),
- ];
- for &(s, w) in TEST_WORD.iter().chain(EXTRA_TESTS.iter()) {
- macro_rules! assert_ {
- ($test:expr, $exp:expr, $name:expr) => {
- // collect into vector for better diagnostics in failure case
- let testing = $test.collect::<Vec<_>>();
- let expected = $exp.collect::<Vec<_>>();
- assert_eq!(testing, expected, "{} test for testcase ({:?}, {:?}) failed.", $name, s, w)
- }
- }
- // test forward iterator
- assert_!(s.split_word_bounds(),
- w.iter().cloned(),
- "Forward word boundaries");
-
- // test reverse iterator
- assert_!(s.split_word_bounds().rev(),
- w.iter().rev().cloned(),
- "Reverse word boundaries");
-
- // generate offsets from word string lengths
- let mut indices = vec![0];
- for i in w.iter().cloned().map(|s| s.len()).scan(0, |t, n| { *t += n; Some(*t) }) {
- indices.push(i);
- }
- indices.pop();
- let indices = indices;
-
- // test forward indices iterator
- assert_!(s.split_word_bound_indices().map(|(l,_)| l),
- indices.iter().cloned(),
- "Forward word indices");
-
- // test backward indices iterator
- assert_!(s.split_word_bound_indices().rev().map(|(l,_)| l),
- indices.iter().rev().cloned(),
- "Reverse word indices");
- }
-}
-
-
-#[test]
-fn test_sentences() {
- use testdata::TEST_SENTENCE;
-
- for &(s, w) in TEST_SENTENCE.iter() {
- macro_rules! assert_ {
- ($test:expr, $exp:expr, $name:expr) => {
- // collect into vector for better diagnostics in failure case
- let testing = $test.collect::<Vec<_>>();
- let expected = $exp.collect::<Vec<_>>();
- assert_eq!(testing, expected, "{} test for testcase ({:?}, {:?}) failed.", $name, s, w)
- }
- }
-
- assert_!(s.split_sentence_bounds(),
- w.iter().cloned(),
- "Forward sentence boundaries");
- }
-}
-
-quickcheck! {
- fn quickcheck_forward_reverse_graphemes_extended(s: String) -> bool {
- let a = s.graphemes(true).collect::<Vec<_>>();
- let mut b = s.graphemes(true).rev().collect::<Vec<_>>();
- b.reverse();
- a == b
- }
-
- fn quickcheck_forward_reverse_graphemes_legacy(s: String) -> bool {
- let a = s.graphemes(false).collect::<Vec<_>>();
- let mut b = s.graphemes(false).rev().collect::<Vec<_>>();
- b.reverse();
- a == b
- }
-
- fn quickcheck_join_graphemes(s: String) -> bool {
- let a = s.graphemes(true).collect::<String>();
- let b = s.graphemes(false).collect::<String>();
- a == s && b == s
- }
-
- fn quickcheck_forward_reverse_words(s: String) -> bool {
- let a = s.split_word_bounds().collect::<Vec<_>>();
- let mut b = s.split_word_bounds().rev().collect::<Vec<_>>();
- b.reverse();
- a == b
- }
-
- fn quickcheck_join_words(s: String) -> bool {
- let a = s.split_word_bounds().collect::<String>();
- a == s
- }
-}
diff --git a/unicode-segmentation/src/testdata.rs b/unicode-segmentation/src/testdata.rs
deleted file mode 100644
index b0402fa..0000000
--- a/unicode-segmentation/src/testdata.rs
+++ /dev/null
@@ -1,2122 +0,0 @@
-// Copyright 2012-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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
- // official Unicode test data
- // http://www.unicode.org/Public/12.0.0/ucd/auxiliary/GraphemeBreakTest.txt
- pub const TEST_SAME: &'static [(&'static str, &'static [&'static str])] = &[
- ("\u{20}\u{20}", &["\u{20}", "\u{20}"]), ("\u{20}\u{308}\u{20}", &["\u{20}\u{308}",
- "\u{20}"]), ("\u{20}\u{d}", &["\u{20}", "\u{d}"]), ("\u{20}\u{308}\u{d}", &["\u{20}\u{308}",
- "\u{d}"]), ("\u{20}\u{a}", &["\u{20}", "\u{a}"]), ("\u{20}\u{308}\u{a}", &["\u{20}\u{308}",
- "\u{a}"]), ("\u{20}\u{1}", &["\u{20}", "\u{1}"]), ("\u{20}\u{308}\u{1}", &["\u{20}\u{308}",
- "\u{1}"]), ("\u{20}\u{34f}", &["\u{20}\u{34f}"]), ("\u{20}\u{308}\u{34f}",
- &["\u{20}\u{308}\u{34f}"]), ("\u{20}\u{1f1e6}", &["\u{20}", "\u{1f1e6}"]),
- ("\u{20}\u{308}\u{1f1e6}", &["\u{20}\u{308}", "\u{1f1e6}"]), ("\u{20}\u{600}", &["\u{20}",
- "\u{600}"]), ("\u{20}\u{308}\u{600}", &["\u{20}\u{308}", "\u{600}"]), ("\u{20}\u{1100}",
- &["\u{20}", "\u{1100}"]), ("\u{20}\u{308}\u{1100}", &["\u{20}\u{308}", "\u{1100}"]),
- ("\u{20}\u{1160}", &["\u{20}", "\u{1160}"]), ("\u{20}\u{308}\u{1160}", &["\u{20}\u{308}",
- "\u{1160}"]), ("\u{20}\u{11a8}", &["\u{20}", "\u{11a8}"]), ("\u{20}\u{308}\u{11a8}",
- &["\u{20}\u{308}", "\u{11a8}"]), ("\u{20}\u{ac00}", &["\u{20}", "\u{ac00}"]),
- ("\u{20}\u{308}\u{ac00}", &["\u{20}\u{308}", "\u{ac00}"]), ("\u{20}\u{ac01}", &["\u{20}",
- "\u{ac01}"]), ("\u{20}\u{308}\u{ac01}", &["\u{20}\u{308}", "\u{ac01}"]), ("\u{20}\u{231a}",
- &["\u{20}", "\u{231a}"]), ("\u{20}\u{308}\u{231a}", &["\u{20}\u{308}", "\u{231a}"]),
- ("\u{20}\u{300}", &["\u{20}\u{300}"]), ("\u{20}\u{308}\u{300}", &["\u{20}\u{308}\u{300}"]),
- ("\u{20}\u{200d}", &["\u{20}\u{200d}"]), ("\u{20}\u{308}\u{200d}",
- &["\u{20}\u{308}\u{200d}"]), ("\u{20}\u{378}", &["\u{20}", "\u{378}"]),
- ("\u{20}\u{308}\u{378}", &["\u{20}\u{308}", "\u{378}"]), ("\u{d}\u{20}", &["\u{d}",
- "\u{20}"]), ("\u{d}\u{308}\u{20}", &["\u{d}", "\u{308}", "\u{20}"]), ("\u{d}\u{d}",
- &["\u{d}", "\u{d}"]), ("\u{d}\u{308}\u{d}", &["\u{d}", "\u{308}", "\u{d}"]), ("\u{d}\u{a}",
- &["\u{d}\u{a}"]), ("\u{d}\u{308}\u{a}", &["\u{d}", "\u{308}", "\u{a}"]), ("\u{d}\u{1}",
- &["\u{d}", "\u{1}"]), ("\u{d}\u{308}\u{1}", &["\u{d}", "\u{308}", "\u{1}"]),
- ("\u{d}\u{34f}", &["\u{d}", "\u{34f}"]), ("\u{d}\u{308}\u{34f}", &["\u{d}",
- "\u{308}\u{34f}"]), ("\u{d}\u{1f1e6}", &["\u{d}", "\u{1f1e6}"]), ("\u{d}\u{308}\u{1f1e6}",
- &["\u{d}", "\u{308}", "\u{1f1e6}"]), ("\u{d}\u{600}", &["\u{d}", "\u{600}"]),
- ("\u{d}\u{308}\u{600}", &["\u{d}", "\u{308}", "\u{600}"]), ("\u{d}\u{903}", &["\u{d}",
- "\u{903}"]), ("\u{d}\u{1100}", &["\u{d}", "\u{1100}"]), ("\u{d}\u{308}\u{1100}", &["\u{d}",
- "\u{308}", "\u{1100}"]), ("\u{d}\u{1160}", &["\u{d}", "\u{1160}"]), ("\u{d}\u{308}\u{1160}",
- &["\u{d}", "\u{308}", "\u{1160}"]), ("\u{d}\u{11a8}", &["\u{d}", "\u{11a8}"]),
- ("\u{d}\u{308}\u{11a8}", &["\u{d}", "\u{308}", "\u{11a8}"]), ("\u{d}\u{ac00}", &["\u{d}",
- "\u{ac00}"]), ("\u{d}\u{308}\u{ac00}", &["\u{d}", "\u{308}", "\u{ac00}"]), ("\u{d}\u{ac01}",
- &["\u{d}", "\u{ac01}"]), ("\u{d}\u{308}\u{ac01}", &["\u{d}", "\u{308}", "\u{ac01}"]),
- ("\u{d}\u{231a}", &["\u{d}", "\u{231a}"]), ("\u{d}\u{308}\u{231a}", &["\u{d}", "\u{308}",
- "\u{231a}"]), ("\u{d}\u{300}", &["\u{d}", "\u{300}"]), ("\u{d}\u{308}\u{300}", &["\u{d}",
- "\u{308}\u{300}"]), ("\u{d}\u{200d}", &["\u{d}", "\u{200d}"]), ("\u{d}\u{308}\u{200d}",
- &["\u{d}", "\u{308}\u{200d}"]), ("\u{d}\u{378}", &["\u{d}", "\u{378}"]),
- ("\u{d}\u{308}\u{378}", &["\u{d}", "\u{308}", "\u{378}"]), ("\u{a}\u{20}", &["\u{a}",
- "\u{20}"]), ("\u{a}\u{308}\u{20}", &["\u{a}", "\u{308}", "\u{20}"]), ("\u{a}\u{d}",
- &["\u{a}", "\u{d}"]), ("\u{a}\u{308}\u{d}", &["\u{a}", "\u{308}", "\u{d}"]), ("\u{a}\u{a}",
- &["\u{a}", "\u{a}"]), ("\u{a}\u{308}\u{a}", &["\u{a}", "\u{308}", "\u{a}"]), ("\u{a}\u{1}",
- &["\u{a}", "\u{1}"]), ("\u{a}\u{308}\u{1}", &["\u{a}", "\u{308}", "\u{1}"]),
- ("\u{a}\u{34f}", &["\u{a}", "\u{34f}"]), ("\u{a}\u{308}\u{34f}", &["\u{a}",
- "\u{308}\u{34f}"]), ("\u{a}\u{1f1e6}", &["\u{a}", "\u{1f1e6}"]), ("\u{a}\u{308}\u{1f1e6}",
- &["\u{a}", "\u{308}", "\u{1f1e6}"]), ("\u{a}\u{600}", &["\u{a}", "\u{600}"]),
- ("\u{a}\u{308}\u{600}", &["\u{a}", "\u{308}", "\u{600}"]), ("\u{a}\u{903}", &["\u{a}",
- "\u{903}"]), ("\u{a}\u{1100}", &["\u{a}", "\u{1100}"]), ("\u{a}\u{308}\u{1100}", &["\u{a}",
- "\u{308}", "\u{1100}"]), ("\u{a}\u{1160}", &["\u{a}", "\u{1160}"]), ("\u{a}\u{308}\u{1160}",
- &["\u{a}", "\u{308}", "\u{1160}"]), ("\u{a}\u{11a8}", &["\u{a}", "\u{11a8}"]),
- ("\u{a}\u{308}\u{11a8}", &["\u{a}", "\u{308}", "\u{11a8}"]), ("\u{a}\u{ac00}", &["\u{a}",
- "\u{ac00}"]), ("\u{a}\u{308}\u{ac00}", &["\u{a}", "\u{308}", "\u{ac00}"]), ("\u{a}\u{ac01}",
- &["\u{a}", "\u{ac01}"]), ("\u{a}\u{308}\u{ac01}", &["\u{a}", "\u{308}", "\u{ac01}"]),
- ("\u{a}\u{231a}", &["\u{a}", "\u{231a}"]), ("\u{a}\u{308}\u{231a}", &["\u{a}", "\u{308}",
- "\u{231a}"]), ("\u{a}\u{300}", &["\u{a}", "\u{300}"]), ("\u{a}\u{308}\u{300}", &["\u{a}",
- "\u{308}\u{300}"]), ("\u{a}\u{200d}", &["\u{a}", "\u{200d}"]), ("\u{a}\u{308}\u{200d}",
- &["\u{a}", "\u{308}\u{200d}"]), ("\u{a}\u{378}", &["\u{a}", "\u{378}"]),
- ("\u{a}\u{308}\u{378}", &["\u{a}", "\u{308}", "\u{378}"]), ("\u{1}\u{20}", &["\u{1}",
- "\u{20}"]), ("\u{1}\u{308}\u{20}", &["\u{1}", "\u{308}", "\u{20}"]), ("\u{1}\u{d}",
- &["\u{1}", "\u{d}"]), ("\u{1}\u{308}\u{d}", &["\u{1}", "\u{308}", "\u{d}"]), ("\u{1}\u{a}",
- &["\u{1}", "\u{a}"]), ("\u{1}\u{308}\u{a}", &["\u{1}", "\u{308}", "\u{a}"]), ("\u{1}\u{1}",
- &["\u{1}", "\u{1}"]), ("\u{1}\u{308}\u{1}", &["\u{1}", "\u{308}", "\u{1}"]),
- ("\u{1}\u{34f}", &["\u{1}", "\u{34f}"]), ("\u{1}\u{308}\u{34f}", &["\u{1}",
- "\u{308}\u{34f}"]), ("\u{1}\u{1f1e6}", &["\u{1}", "\u{1f1e6}"]), ("\u{1}\u{308}\u{1f1e6}",
- &["\u{1}", "\u{308}", "\u{1f1e6}"]), ("\u{1}\u{600}", &["\u{1}", "\u{600}"]),
- ("\u{1}\u{308}\u{600}", &["\u{1}", "\u{308}", "\u{600}"]), ("\u{1}\u{903}", &["\u{1}",
- "\u{903}"]), ("\u{1}\u{1100}", &["\u{1}", "\u{1100}"]), ("\u{1}\u{308}\u{1100}", &["\u{1}",
- "\u{308}", "\u{1100}"]), ("\u{1}\u{1160}", &["\u{1}", "\u{1160}"]), ("\u{1}\u{308}\u{1160}",
- &["\u{1}", "\u{308}", "\u{1160}"]), ("\u{1}\u{11a8}", &["\u{1}", "\u{11a8}"]),
- ("\u{1}\u{308}\u{11a8}", &["\u{1}", "\u{308}", "\u{11a8}"]), ("\u{1}\u{ac00}", &["\u{1}",
- "\u{ac00}"]), ("\u{1}\u{308}\u{ac00}", &["\u{1}", "\u{308}", "\u{ac00}"]), ("\u{1}\u{ac01}",
- &["\u{1}", "\u{ac01}"]), ("\u{1}\u{308}\u{ac01}", &["\u{1}", "\u{308}", "\u{ac01}"]),
- ("\u{1}\u{231a}", &["\u{1}", "\u{231a}"]), ("\u{1}\u{308}\u{231a}", &["\u{1}", "\u{308}",
- "\u{231a}"]), ("\u{1}\u{300}", &["\u{1}", "\u{300}"]), ("\u{1}\u{308}\u{300}", &["\u{1}",
- "\u{308}\u{300}"]), ("\u{1}\u{200d}", &["\u{1}", "\u{200d}"]), ("\u{1}\u{308}\u{200d}",
- &["\u{1}", "\u{308}\u{200d}"]), ("\u{1}\u{378}", &["\u{1}", "\u{378}"]),
- ("\u{1}\u{308}\u{378}", &["\u{1}", "\u{308}", "\u{378}"]), ("\u{34f}\u{20}", &["\u{34f}",
- "\u{20}"]), ("\u{34f}\u{308}\u{20}", &["\u{34f}\u{308}", "\u{20}"]), ("\u{34f}\u{d}",
- &["\u{34f}", "\u{d}"]), ("\u{34f}\u{308}\u{d}", &["\u{34f}\u{308}", "\u{d}"]),
- ("\u{34f}\u{a}", &["\u{34f}", "\u{a}"]), ("\u{34f}\u{308}\u{a}", &["\u{34f}\u{308}",
- "\u{a}"]), ("\u{34f}\u{1}", &["\u{34f}", "\u{1}"]), ("\u{34f}\u{308}\u{1}",
- &["\u{34f}\u{308}", "\u{1}"]), ("\u{34f}\u{34f}", &["\u{34f}\u{34f}"]),
- ("\u{34f}\u{308}\u{34f}", &["\u{34f}\u{308}\u{34f}"]), ("\u{34f}\u{1f1e6}", &["\u{34f}",
- "\u{1f1e6}"]), ("\u{34f}\u{308}\u{1f1e6}", &["\u{34f}\u{308}", "\u{1f1e6}"]),
- ("\u{34f}\u{600}", &["\u{34f}", "\u{600}"]), ("\u{34f}\u{308}\u{600}", &["\u{34f}\u{308}",
- "\u{600}"]), ("\u{34f}\u{1100}", &["\u{34f}", "\u{1100}"]), ("\u{34f}\u{308}\u{1100}",
- &["\u{34f}\u{308}", "\u{1100}"]), ("\u{34f}\u{1160}", &["\u{34f}", "\u{1160}"]),
- ("\u{34f}\u{308}\u{1160}", &["\u{34f}\u{308}", "\u{1160}"]), ("\u{34f}\u{11a8}",
- &["\u{34f}", "\u{11a8}"]), ("\u{34f}\u{308}\u{11a8}", &["\u{34f}\u{308}", "\u{11a8}"]),
- ("\u{34f}\u{ac00}", &["\u{34f}", "\u{ac00}"]), ("\u{34f}\u{308}\u{ac00}",
- &["\u{34f}\u{308}", "\u{ac00}"]), ("\u{34f}\u{ac01}", &["\u{34f}", "\u{ac01}"]),
- ("\u{34f}\u{308}\u{ac01}", &["\u{34f}\u{308}", "\u{ac01}"]), ("\u{34f}\u{231a}",
- &["\u{34f}", "\u{231a}"]), ("\u{34f}\u{308}\u{231a}", &["\u{34f}\u{308}", "\u{231a}"]),
- ("\u{34f}\u{300}", &["\u{34f}\u{300}"]), ("\u{34f}\u{308}\u{300}",
- &["\u{34f}\u{308}\u{300}"]), ("\u{34f}\u{200d}", &["\u{34f}\u{200d}"]),
- ("\u{34f}\u{308}\u{200d}", &["\u{34f}\u{308}\u{200d}"]), ("\u{34f}\u{378}", &["\u{34f}",
- "\u{378}"]), ("\u{34f}\u{308}\u{378}", &["\u{34f}\u{308}", "\u{378}"]), ("\u{1f1e6}\u{20}",
- &["\u{1f1e6}", "\u{20}"]), ("\u{1f1e6}\u{308}\u{20}", &["\u{1f1e6}\u{308}", "\u{20}"]),
- ("\u{1f1e6}\u{d}", &["\u{1f1e6}", "\u{d}"]), ("\u{1f1e6}\u{308}\u{d}", &["\u{1f1e6}\u{308}",
- "\u{d}"]), ("\u{1f1e6}\u{a}", &["\u{1f1e6}", "\u{a}"]), ("\u{1f1e6}\u{308}\u{a}",
- &["\u{1f1e6}\u{308}", "\u{a}"]), ("\u{1f1e6}\u{1}", &["\u{1f1e6}", "\u{1}"]),
- ("\u{1f1e6}\u{308}\u{1}", &["\u{1f1e6}\u{308}", "\u{1}"]), ("\u{1f1e6}\u{34f}",
- &["\u{1f1e6}\u{34f}"]), ("\u{1f1e6}\u{308}\u{34f}", &["\u{1f1e6}\u{308}\u{34f}"]),
- ("\u{1f1e6}\u{1f1e6}", &["\u{1f1e6}\u{1f1e6}"]), ("\u{1f1e6}\u{308}\u{1f1e6}",
- &["\u{1f1e6}\u{308}", "\u{1f1e6}"]), ("\u{1f1e6}\u{600}", &["\u{1f1e6}", "\u{600}"]),
- ("\u{1f1e6}\u{308}\u{600}", &["\u{1f1e6}\u{308}", "\u{600}"]), ("\u{1f1e6}\u{1100}",
- &["\u{1f1e6}", "\u{1100}"]), ("\u{1f1e6}\u{308}\u{1100}", &["\u{1f1e6}\u{308}",
- "\u{1100}"]), ("\u{1f1e6}\u{1160}", &["\u{1f1e6}", "\u{1160}"]),
- ("\u{1f1e6}\u{308}\u{1160}", &["\u{1f1e6}\u{308}", "\u{1160}"]), ("\u{1f1e6}\u{11a8}",
- &["\u{1f1e6}", "\u{11a8}"]), ("\u{1f1e6}\u{308}\u{11a8}", &["\u{1f1e6}\u{308}",
- "\u{11a8}"]), ("\u{1f1e6}\u{ac00}", &["\u{1f1e6}", "\u{ac00}"]),
- ("\u{1f1e6}\u{308}\u{ac00}", &["\u{1f1e6}\u{308}", "\u{ac00}"]), ("\u{1f1e6}\u{ac01}",
- &["\u{1f1e6}", "\u{ac01}"]), ("\u{1f1e6}\u{308}\u{ac01}", &["\u{1f1e6}\u{308}",
- "\u{ac01}"]), ("\u{1f1e6}\u{231a}", &["\u{1f1e6}", "\u{231a}"]),
- ("\u{1f1e6}\u{308}\u{231a}", &["\u{1f1e6}\u{308}", "\u{231a}"]), ("\u{1f1e6}\u{300}",
- &["\u{1f1e6}\u{300}"]), ("\u{1f1e6}\u{308}\u{300}", &["\u{1f1e6}\u{308}\u{300}"]),
- ("\u{1f1e6}\u{200d}", &["\u{1f1e6}\u{200d}"]), ("\u{1f1e6}\u{308}\u{200d}",
- &["\u{1f1e6}\u{308}\u{200d}"]), ("\u{1f1e6}\u{378}", &["\u{1f1e6}", "\u{378}"]),
- ("\u{1f1e6}\u{308}\u{378}", &["\u{1f1e6}\u{308}", "\u{378}"]), ("\u{600}\u{308}\u{20}",
- &["\u{600}\u{308}", "\u{20}"]), ("\u{600}\u{d}", &["\u{600}", "\u{d}"]),
- ("\u{600}\u{308}\u{d}", &["\u{600}\u{308}", "\u{d}"]), ("\u{600}\u{a}", &["\u{600}",
- "\u{a}"]), ("\u{600}\u{308}\u{a}", &["\u{600}\u{308}", "\u{a}"]), ("\u{600}\u{1}",
- &["\u{600}", "\u{1}"]), ("\u{600}\u{308}\u{1}", &["\u{600}\u{308}", "\u{1}"]),
- ("\u{600}\u{34f}", &["\u{600}\u{34f}"]), ("\u{600}\u{308}\u{34f}",
- &["\u{600}\u{308}\u{34f}"]), ("\u{600}\u{308}\u{1f1e6}", &["\u{600}\u{308}", "\u{1f1e6}"]),
- ("\u{600}\u{308}\u{600}", &["\u{600}\u{308}", "\u{600}"]), ("\u{600}\u{308}\u{1100}",
- &["\u{600}\u{308}", "\u{1100}"]), ("\u{600}\u{308}\u{1160}", &["\u{600}\u{308}",
- "\u{1160}"]), ("\u{600}\u{308}\u{11a8}", &["\u{600}\u{308}", "\u{11a8}"]),
- ("\u{600}\u{308}\u{ac00}", &["\u{600}\u{308}", "\u{ac00}"]), ("\u{600}\u{308}\u{ac01}",
- &["\u{600}\u{308}", "\u{ac01}"]), ("\u{600}\u{308}\u{231a}", &["\u{600}\u{308}",
- "\u{231a}"]), ("\u{600}\u{300}", &["\u{600}\u{300}"]), ("\u{600}\u{308}\u{300}",
- &["\u{600}\u{308}\u{300}"]), ("\u{600}\u{200d}", &["\u{600}\u{200d}"]),
- ("\u{600}\u{308}\u{200d}", &["\u{600}\u{308}\u{200d}"]), ("\u{600}\u{308}\u{378}",
- &["\u{600}\u{308}", "\u{378}"]), ("\u{903}\u{20}", &["\u{903}", "\u{20}"]),
- ("\u{903}\u{308}\u{20}", &["\u{903}\u{308}", "\u{20}"]), ("\u{903}\u{d}", &["\u{903}",
- "\u{d}"]), ("\u{903}\u{308}\u{d}", &["\u{903}\u{308}", "\u{d}"]), ("\u{903}\u{a}",
- &["\u{903}", "\u{a}"]), ("\u{903}\u{308}\u{a}", &["\u{903}\u{308}", "\u{a}"]),
- ("\u{903}\u{1}", &["\u{903}", "\u{1}"]), ("\u{903}\u{308}\u{1}", &["\u{903}\u{308}",
- "\u{1}"]), ("\u{903}\u{34f}", &["\u{903}\u{34f}"]), ("\u{903}\u{308}\u{34f}",
- &["\u{903}\u{308}\u{34f}"]), ("\u{903}\u{1f1e6}", &["\u{903}", "\u{1f1e6}"]),
- ("\u{903}\u{308}\u{1f1e6}", &["\u{903}\u{308}", "\u{1f1e6}"]), ("\u{903}\u{600}",
- &["\u{903}", "\u{600}"]), ("\u{903}\u{308}\u{600}", &["\u{903}\u{308}", "\u{600}"]),
- ("\u{903}\u{1100}", &["\u{903}", "\u{1100}"]), ("\u{903}\u{308}\u{1100}",
- &["\u{903}\u{308}", "\u{1100}"]), ("\u{903}\u{1160}", &["\u{903}", "\u{1160}"]),
- ("\u{903}\u{308}\u{1160}", &["\u{903}\u{308}", "\u{1160}"]), ("\u{903}\u{11a8}",
- &["\u{903}", "\u{11a8}"]), ("\u{903}\u{308}\u{11a8}", &["\u{903}\u{308}", "\u{11a8}"]),
- ("\u{903}\u{ac00}", &["\u{903}", "\u{ac00}"]), ("\u{903}\u{308}\u{ac00}",
- &["\u{903}\u{308}", "\u{ac00}"]), ("\u{903}\u{ac01}", &["\u{903}", "\u{ac01}"]),
- ("\u{903}\u{308}\u{ac01}", &["\u{903}\u{308}", "\u{ac01}"]), ("\u{903}\u{231a}",
- &["\u{903}", "\u{231a}"]), ("\u{903}\u{308}\u{231a}", &["\u{903}\u{308}", "\u{231a}"]),
- ("\u{903}\u{300}", &["\u{903}\u{300}"]), ("\u{903}\u{308}\u{300}",
- &["\u{903}\u{308}\u{300}"]), ("\u{903}\u{200d}", &["\u{903}\u{200d}"]),
- ("\u{903}\u{308}\u{200d}", &["\u{903}\u{308}\u{200d}"]), ("\u{903}\u{378}", &["\u{903}",
- "\u{378}"]), ("\u{903}\u{308}\u{378}", &["\u{903}\u{308}", "\u{378}"]), ("\u{1100}\u{20}",
- &["\u{1100}", "\u{20}"]), ("\u{1100}\u{308}\u{20}", &["\u{1100}\u{308}", "\u{20}"]),
- ("\u{1100}\u{d}", &["\u{1100}", "\u{d}"]), ("\u{1100}\u{308}\u{d}", &["\u{1100}\u{308}",
- "\u{d}"]), ("\u{1100}\u{a}", &["\u{1100}", "\u{a}"]), ("\u{1100}\u{308}\u{a}",
- &["\u{1100}\u{308}", "\u{a}"]), ("\u{1100}\u{1}", &["\u{1100}", "\u{1}"]),
- ("\u{1100}\u{308}\u{1}", &["\u{1100}\u{308}", "\u{1}"]), ("\u{1100}\u{34f}",
- &["\u{1100}\u{34f}"]), ("\u{1100}\u{308}\u{34f}", &["\u{1100}\u{308}\u{34f}"]),
- ("\u{1100}\u{1f1e6}", &["\u{1100}", "\u{1f1e6}"]), ("\u{1100}\u{308}\u{1f1e6}",
- &["\u{1100}\u{308}", "\u{1f1e6}"]), ("\u{1100}\u{600}", &["\u{1100}", "\u{600}"]),
- ("\u{1100}\u{308}\u{600}", &["\u{1100}\u{308}", "\u{600}"]), ("\u{1100}\u{1100}",
- &["\u{1100}\u{1100}"]), ("\u{1100}\u{308}\u{1100}", &["\u{1100}\u{308}", "\u{1100}"]),
- ("\u{1100}\u{1160}", &["\u{1100}\u{1160}"]), ("\u{1100}\u{308}\u{1160}",
- &["\u{1100}\u{308}", "\u{1160}"]), ("\u{1100}\u{11a8}", &["\u{1100}", "\u{11a8}"]),
- ("\u{1100}\u{308}\u{11a8}", &["\u{1100}\u{308}", "\u{11a8}"]), ("\u{1100}\u{ac00}",
- &["\u{1100}\u{ac00}"]), ("\u{1100}\u{308}\u{ac00}", &["\u{1100}\u{308}", "\u{ac00}"]),
- ("\u{1100}\u{ac01}", &["\u{1100}\u{ac01}"]), ("\u{1100}\u{308}\u{ac01}",
- &["\u{1100}\u{308}", "\u{ac01}"]), ("\u{1100}\u{231a}", &["\u{1100}", "\u{231a}"]),
- ("\u{1100}\u{308}\u{231a}", &["\u{1100}\u{308}", "\u{231a}"]), ("\u{1100}\u{300}",
- &["\u{1100}\u{300}"]), ("\u{1100}\u{308}\u{300}", &["\u{1100}\u{308}\u{300}"]),
- ("\u{1100}\u{200d}", &["\u{1100}\u{200d}"]), ("\u{1100}\u{308}\u{200d}",
- &["\u{1100}\u{308}\u{200d}"]), ("\u{1100}\u{378}", &["\u{1100}", "\u{378}"]),
- ("\u{1100}\u{308}\u{378}", &["\u{1100}\u{308}", "\u{378}"]), ("\u{1160}\u{20}",
- &["\u{1160}", "\u{20}"]), ("\u{1160}\u{308}\u{20}", &["\u{1160}\u{308}", "\u{20}"]),
- ("\u{1160}\u{d}", &["\u{1160}", "\u{d}"]), ("\u{1160}\u{308}\u{d}", &["\u{1160}\u{308}",
- "\u{d}"]), ("\u{1160}\u{a}", &["\u{1160}", "\u{a}"]), ("\u{1160}\u{308}\u{a}",
- &["\u{1160}\u{308}", "\u{a}"]), ("\u{1160}\u{1}", &["\u{1160}", "\u{1}"]),
- ("\u{1160}\u{308}\u{1}", &["\u{1160}\u{308}", "\u{1}"]), ("\u{1160}\u{34f}",
- &["\u{1160}\u{34f}"]), ("\u{1160}\u{308}\u{34f}", &["\u{1160}\u{308}\u{34f}"]),
- ("\u{1160}\u{1f1e6}", &["\u{1160}", "\u{1f1e6}"]), ("\u{1160}\u{308}\u{1f1e6}",
- &["\u{1160}\u{308}", "\u{1f1e6}"]), ("\u{1160}\u{600}", &["\u{1160}", "\u{600}"]),
- ("\u{1160}\u{308}\u{600}", &["\u{1160}\u{308}", "\u{600}"]), ("\u{1160}\u{1100}",
- &["\u{1160}", "\u{1100}"]), ("\u{1160}\u{308}\u{1100}", &["\u{1160}\u{308}", "\u{1100}"]),
- ("\u{1160}\u{1160}", &["\u{1160}\u{1160}"]), ("\u{1160}\u{308}\u{1160}",
- &["\u{1160}\u{308}", "\u{1160}"]), ("\u{1160}\u{11a8}", &["\u{1160}\u{11a8}"]),
- ("\u{1160}\u{308}\u{11a8}", &["\u{1160}\u{308}", "\u{11a8}"]), ("\u{1160}\u{ac00}",
- &["\u{1160}", "\u{ac00}"]), ("\u{1160}\u{308}\u{ac00}", &["\u{1160}\u{308}", "\u{ac00}"]),
- ("\u{1160}\u{ac01}", &["\u{1160}", "\u{ac01}"]), ("\u{1160}\u{308}\u{ac01}",
- &["\u{1160}\u{308}", "\u{ac01}"]), ("\u{1160}\u{231a}", &["\u{1160}", "\u{231a}"]),
- ("\u{1160}\u{308}\u{231a}", &["\u{1160}\u{308}", "\u{231a}"]), ("\u{1160}\u{300}",
- &["\u{1160}\u{300}"]), ("\u{1160}\u{308}\u{300}", &["\u{1160}\u{308}\u{300}"]),
- ("\u{1160}\u{200d}", &["\u{1160}\u{200d}"]), ("\u{1160}\u{308}\u{200d}",
- &["\u{1160}\u{308}\u{200d}"]), ("\u{1160}\u{378}", &["\u{1160}", "\u{378}"]),
- ("\u{1160}\u{308}\u{378}", &["\u{1160}\u{308}", "\u{378}"]), ("\u{11a8}\u{20}",
- &["\u{11a8}", "\u{20}"]), ("\u{11a8}\u{308}\u{20}", &["\u{11a8}\u{308}", "\u{20}"]),
- ("\u{11a8}\u{d}", &["\u{11a8}", "\u{d}"]), ("\u{11a8}\u{308}\u{d}", &["\u{11a8}\u{308}",
- "\u{d}"]), ("\u{11a8}\u{a}", &["\u{11a8}", "\u{a}"]), ("\u{11a8}\u{308}\u{a}",
- &["\u{11a8}\u{308}", "\u{a}"]), ("\u{11a8}\u{1}", &["\u{11a8}", "\u{1}"]),
- ("\u{11a8}\u{308}\u{1}", &["\u{11a8}\u{308}", "\u{1}"]), ("\u{11a8}\u{34f}",
- &["\u{11a8}\u{34f}"]), ("\u{11a8}\u{308}\u{34f}", &["\u{11a8}\u{308}\u{34f}"]),
- ("\u{11a8}\u{1f1e6}", &["\u{11a8}", "\u{1f1e6}"]), ("\u{11a8}\u{308}\u{1f1e6}",
- &["\u{11a8}\u{308}", "\u{1f1e6}"]), ("\u{11a8}\u{600}", &["\u{11a8}", "\u{600}"]),
- ("\u{11a8}\u{308}\u{600}", &["\u{11a8}\u{308}", "\u{600}"]), ("\u{11a8}\u{1100}",
- &["\u{11a8}", "\u{1100}"]), ("\u{11a8}\u{308}\u{1100}", &["\u{11a8}\u{308}", "\u{1100}"]),
- ("\u{11a8}\u{1160}", &["\u{11a8}", "\u{1160}"]), ("\u{11a8}\u{308}\u{1160}",
- &["\u{11a8}\u{308}", "\u{1160}"]), ("\u{11a8}\u{11a8}", &["\u{11a8}\u{11a8}"]),
- ("\u{11a8}\u{308}\u{11a8}", &["\u{11a8}\u{308}", "\u{11a8}"]), ("\u{11a8}\u{ac00}",
- &["\u{11a8}", "\u{ac00}"]), ("\u{11a8}\u{308}\u{ac00}", &["\u{11a8}\u{308}", "\u{ac00}"]),
- ("\u{11a8}\u{ac01}", &["\u{11a8}", "\u{ac01}"]), ("\u{11a8}\u{308}\u{ac01}",
- &["\u{11a8}\u{308}", "\u{ac01}"]), ("\u{11a8}\u{231a}", &["\u{11a8}", "\u{231a}"]),
- ("\u{11a8}\u{308}\u{231a}", &["\u{11a8}\u{308}", "\u{231a}"]), ("\u{11a8}\u{300}",
- &["\u{11a8}\u{300}"]), ("\u{11a8}\u{308}\u{300}", &["\u{11a8}\u{308}\u{300}"]),
- ("\u{11a8}\u{200d}", &["\u{11a8}\u{200d}"]), ("\u{11a8}\u{308}\u{200d}",
- &["\u{11a8}\u{308}\u{200d}"]), ("\u{11a8}\u{378}", &["\u{11a8}", "\u{378}"]),
- ("\u{11a8}\u{308}\u{378}", &["\u{11a8}\u{308}", "\u{378}"]), ("\u{ac00}\u{20}",
- &["\u{ac00}", "\u{20}"]), ("\u{ac00}\u{308}\u{20}", &["\u{ac00}\u{308}", "\u{20}"]),
- ("\u{ac00}\u{d}", &["\u{ac00}", "\u{d}"]), ("\u{ac00}\u{308}\u{d}", &["\u{ac00}\u{308}",
- "\u{d}"]), ("\u{ac00}\u{a}", &["\u{ac00}", "\u{a}"]), ("\u{ac00}\u{308}\u{a}",
- &["\u{ac00}\u{308}", "\u{a}"]), ("\u{ac00}\u{1}", &["\u{ac00}", "\u{1}"]),
- ("\u{ac00}\u{308}\u{1}", &["\u{ac00}\u{308}", "\u{1}"]), ("\u{ac00}\u{34f}",
- &["\u{ac00}\u{34f}"]), ("\u{ac00}\u{308}\u{34f}", &["\u{ac00}\u{308}\u{34f}"]),
- ("\u{ac00}\u{1f1e6}", &["\u{ac00}", "\u{1f1e6}"]), ("\u{ac00}\u{308}\u{1f1e6}",
- &["\u{ac00}\u{308}", "\u{1f1e6}"]), ("\u{ac00}\u{600}", &["\u{ac00}", "\u{600}"]),
- ("\u{ac00}\u{308}\u{600}", &["\u{ac00}\u{308}", "\u{600}"]), ("\u{ac00}\u{1100}",
- &["\u{ac00}", "\u{1100}"]), ("\u{ac00}\u{308}\u{1100}", &["\u{ac00}\u{308}", "\u{1100}"]),
- ("\u{ac00}\u{1160}", &["\u{ac00}\u{1160}"]), ("\u{ac00}\u{308}\u{1160}",
- &["\u{ac00}\u{308}", "\u{1160}"]), ("\u{ac00}\u{11a8}", &["\u{ac00}\u{11a8}"]),
- ("\u{ac00}\u{308}\u{11a8}", &["\u{ac00}\u{308}", "\u{11a8}"]), ("\u{ac00}\u{ac00}",
- &["\u{ac00}", "\u{ac00}"]), ("\u{ac00}\u{308}\u{ac00}", &["\u{ac00}\u{308}", "\u{ac00}"]),
- ("\u{ac00}\u{ac01}", &["\u{ac00}", "\u{ac01}"]), ("\u{ac00}\u{308}\u{ac01}",
- &["\u{ac00}\u{308}", "\u{ac01}"]), ("\u{ac00}\u{231a}", &["\u{ac00}", "\u{231a}"]),
- ("\u{ac00}\u{308}\u{231a}", &["\u{ac00}\u{308}", "\u{231a}"]), ("\u{ac00}\u{300}",
- &["\u{ac00}\u{300}"]), ("\u{ac00}\u{308}\u{300}", &["\u{ac00}\u{308}\u{300}"]),
- ("\u{ac00}\u{200d}", &["\u{ac00}\u{200d}"]), ("\u{ac00}\u{308}\u{200d}",
- &["\u{ac00}\u{308}\u{200d}"]), ("\u{ac00}\u{378}", &["\u{ac00}", "\u{378}"]),
- ("\u{ac00}\u{308}\u{378}", &["\u{ac00}\u{308}", "\u{378}"]), ("\u{ac01}\u{20}",
- &["\u{ac01}", "\u{20}"]), ("\u{ac01}\u{308}\u{20}", &["\u{ac01}\u{308}", "\u{20}"]),
- ("\u{ac01}\u{d}", &["\u{ac01}", "\u{d}"]), ("\u{ac01}\u{308}\u{d}", &["\u{ac01}\u{308}",
- "\u{d}"]), ("\u{ac01}\u{a}", &["\u{ac01}", "\u{a}"]), ("\u{ac01}\u{308}\u{a}",
- &["\u{ac01}\u{308}", "\u{a}"]), ("\u{ac01}\u{1}", &["\u{ac01}", "\u{1}"]),
- ("\u{ac01}\u{308}\u{1}", &["\u{ac01}\u{308}", "\u{1}"]), ("\u{ac01}\u{34f}",
- &["\u{ac01}\u{34f}"]), ("\u{ac01}\u{308}\u{34f}", &["\u{ac01}\u{308}\u{34f}"]),
- ("\u{ac01}\u{1f1e6}", &["\u{ac01}", "\u{1f1e6}"]), ("\u{ac01}\u{308}\u{1f1e6}",
- &["\u{ac01}\u{308}", "\u{1f1e6}"]), ("\u{ac01}\u{600}", &["\u{ac01}", "\u{600}"]),
- ("\u{ac01}\u{308}\u{600}", &["\u{ac01}\u{308}", "\u{600}"]), ("\u{ac01}\u{1100}",
- &["\u{ac01}", "\u{1100}"]), ("\u{ac01}\u{308}\u{1100}", &["\u{ac01}\u{308}", "\u{1100}"]),
- ("\u{ac01}\u{1160}", &["\u{ac01}", "\u{1160}"]), ("\u{ac01}\u{308}\u{1160}",
- &["\u{ac01}\u{308}", "\u{1160}"]), ("\u{ac01}\u{11a8}", &["\u{ac01}\u{11a8}"]),
- ("\u{ac01}\u{308}\u{11a8}", &["\u{ac01}\u{308}", "\u{11a8}"]), ("\u{ac01}\u{ac00}",
- &["\u{ac01}", "\u{ac00}"]), ("\u{ac01}\u{308}\u{ac00}", &["\u{ac01}\u{308}", "\u{ac00}"]),
- ("\u{ac01}\u{ac01}", &["\u{ac01}", "\u{ac01}"]), ("\u{ac01}\u{308}\u{ac01}",
- &["\u{ac01}\u{308}", "\u{ac01}"]), ("\u{ac01}\u{231a}", &["\u{ac01}", "\u{231a}"]),
- ("\u{ac01}\u{308}\u{231a}", &["\u{ac01}\u{308}", "\u{231a}"]), ("\u{ac01}\u{300}",
- &["\u{ac01}\u{300}"]), ("\u{ac01}\u{308}\u{300}", &["\u{ac01}\u{308}\u{300}"]),
- ("\u{ac01}\u{200d}", &["\u{ac01}\u{200d}"]), ("\u{ac01}\u{308}\u{200d}",
- &["\u{ac01}\u{308}\u{200d}"]), ("\u{ac01}\u{378}", &["\u{ac01}", "\u{378}"]),
- ("\u{ac01}\u{308}\u{378}", &["\u{ac01}\u{308}", "\u{378}"]), ("\u{231a}\u{20}",
- &["\u{231a}", "\u{20}"]), ("\u{231a}\u{308}\u{20}", &["\u{231a}\u{308}", "\u{20}"]),
- ("\u{231a}\u{d}", &["\u{231a}", "\u{d}"]), ("\u{231a}\u{308}\u{d}", &["\u{231a}\u{308}",
- "\u{d}"]), ("\u{231a}\u{a}", &["\u{231a}", "\u{a}"]), ("\u{231a}\u{308}\u{a}",
- &["\u{231a}\u{308}", "\u{a}"]), ("\u{231a}\u{1}", &["\u{231a}", "\u{1}"]),
- ("\u{231a}\u{308}\u{1}", &["\u{231a}\u{308}", "\u{1}"]), ("\u{231a}\u{34f}",
- &["\u{231a}\u{34f}"]), ("\u{231a}\u{308}\u{34f}", &["\u{231a}\u{308}\u{34f}"]),
- ("\u{231a}\u{1f1e6}", &["\u{231a}", "\u{1f1e6}"]), ("\u{231a}\u{308}\u{1f1e6}",
- &["\u{231a}\u{308}", "\u{1f1e6}"]), ("\u{231a}\u{600}", &["\u{231a}", "\u{600}"]),
- ("\u{231a}\u{308}\u{600}", &["\u{231a}\u{308}", "\u{600}"]), ("\u{231a}\u{1100}",
- &["\u{231a}", "\u{1100}"]), ("\u{231a}\u{308}\u{1100}", &["\u{231a}\u{308}", "\u{1100}"]),
- ("\u{231a}\u{1160}", &["\u{231a}", "\u{1160}"]), ("\u{231a}\u{308}\u{1160}",
- &["\u{231a}\u{308}", "\u{1160}"]), ("\u{231a}\u{11a8}", &["\u{231a}", "\u{11a8}"]),
- ("\u{231a}\u{308}\u{11a8}", &["\u{231a}\u{308}", "\u{11a8}"]), ("\u{231a}\u{ac00}",
- &["\u{231a}", "\u{ac00}"]), ("\u{231a}\u{308}\u{ac00}", &["\u{231a}\u{308}", "\u{ac00}"]),
- ("\u{231a}\u{ac01}", &["\u{231a}", "\u{ac01}"]), ("\u{231a}\u{308}\u{ac01}",
- &["\u{231a}\u{308}", "\u{ac01}"]), ("\u{231a}\u{231a}", &["\u{231a}", "\u{231a}"]),
- ("\u{231a}\u{308}\u{231a}", &["\u{231a}\u{308}", "\u{231a}"]), ("\u{231a}\u{300}",
- &["\u{231a}\u{300}"]), ("\u{231a}\u{308}\u{300}", &["\u{231a}\u{308}\u{300}"]),
- ("\u{231a}\u{200d}", &["\u{231a}\u{200d}"]), ("\u{231a}\u{308}\u{200d}",
- &["\u{231a}\u{308}\u{200d}"]), ("\u{231a}\u{378}", &["\u{231a}", "\u{378}"]),
- ("\u{231a}\u{308}\u{378}", &["\u{231a}\u{308}", "\u{378}"]), ("\u{300}\u{20}", &["\u{300}",
- "\u{20}"]), ("\u{300}\u{308}\u{20}", &["\u{300}\u{308}", "\u{20}"]), ("\u{300}\u{d}",
- &["\u{300}", "\u{d}"]), ("\u{300}\u{308}\u{d}", &["\u{300}\u{308}", "\u{d}"]),
- ("\u{300}\u{a}", &["\u{300}", "\u{a}"]), ("\u{300}\u{308}\u{a}", &["\u{300}\u{308}",
- "\u{a}"]), ("\u{300}\u{1}", &["\u{300}", "\u{1}"]), ("\u{300}\u{308}\u{1}",
- &["\u{300}\u{308}", "\u{1}"]), ("\u{300}\u{34f}", &["\u{300}\u{34f}"]),
- ("\u{300}\u{308}\u{34f}", &["\u{300}\u{308}\u{34f}"]), ("\u{300}\u{1f1e6}", &["\u{300}",
- "\u{1f1e6}"]), ("\u{300}\u{308}\u{1f1e6}", &["\u{300}\u{308}", "\u{1f1e6}"]),
- ("\u{300}\u{600}", &["\u{300}", "\u{600}"]), ("\u{300}\u{308}\u{600}", &["\u{300}\u{308}",
- "\u{600}"]), ("\u{300}\u{1100}", &["\u{300}", "\u{1100}"]), ("\u{300}\u{308}\u{1100}",
- &["\u{300}\u{308}", "\u{1100}"]), ("\u{300}\u{1160}", &["\u{300}", "\u{1160}"]),
- ("\u{300}\u{308}\u{1160}", &["\u{300}\u{308}", "\u{1160}"]), ("\u{300}\u{11a8}",
- &["\u{300}", "\u{11a8}"]), ("\u{300}\u{308}\u{11a8}", &["\u{300}\u{308}", "\u{11a8}"]),
- ("\u{300}\u{ac00}", &["\u{300}", "\u{ac00}"]), ("\u{300}\u{308}\u{ac00}",
- &["\u{300}\u{308}", "\u{ac00}"]), ("\u{300}\u{ac01}", &["\u{300}", "\u{ac01}"]),
- ("\u{300}\u{308}\u{ac01}", &["\u{300}\u{308}", "\u{ac01}"]), ("\u{300}\u{231a}",
- &["\u{300}", "\u{231a}"]), ("\u{300}\u{308}\u{231a}", &["\u{300}\u{308}", "\u{231a}"]),
- ("\u{300}\u{300}", &["\u{300}\u{300}"]), ("\u{300}\u{308}\u{300}",
- &["\u{300}\u{308}\u{300}"]), ("\u{300}\u{200d}", &["\u{300}\u{200d}"]),
- ("\u{300}\u{308}\u{200d}", &["\u{300}\u{308}\u{200d}"]), ("\u{300}\u{378}", &["\u{300}",
- "\u{378}"]), ("\u{300}\u{308}\u{378}", &["\u{300}\u{308}", "\u{378}"]), ("\u{200d}\u{20}",
- &["\u{200d}", "\u{20}"]), ("\u{200d}\u{308}\u{20}", &["\u{200d}\u{308}", "\u{20}"]),
- ("\u{200d}\u{d}", &["\u{200d}", "\u{d}"]), ("\u{200d}\u{308}\u{d}", &["\u{200d}\u{308}",
- "\u{d}"]), ("\u{200d}\u{a}", &["\u{200d}", "\u{a}"]), ("\u{200d}\u{308}\u{a}",
- &["\u{200d}\u{308}", "\u{a}"]), ("\u{200d}\u{1}", &["\u{200d}", "\u{1}"]),
- ("\u{200d}\u{308}\u{1}", &["\u{200d}\u{308}", "\u{1}"]), ("\u{200d}\u{34f}",
- &["\u{200d}\u{34f}"]), ("\u{200d}\u{308}\u{34f}", &["\u{200d}\u{308}\u{34f}"]),
- ("\u{200d}\u{1f1e6}", &["\u{200d}", "\u{1f1e6}"]), ("\u{200d}\u{308}\u{1f1e6}",
- &["\u{200d}\u{308}", "\u{1f1e6}"]), ("\u{200d}\u{600}", &["\u{200d}", "\u{600}"]),
- ("\u{200d}\u{308}\u{600}", &["\u{200d}\u{308}", "\u{600}"]), ("\u{200d}\u{1100}",
- &["\u{200d}", "\u{1100}"]), ("\u{200d}\u{308}\u{1100}", &["\u{200d}\u{308}", "\u{1100}"]),
- ("\u{200d}\u{1160}", &["\u{200d}", "\u{1160}"]), ("\u{200d}\u{308}\u{1160}",
- &["\u{200d}\u{308}", "\u{1160}"]), ("\u{200d}\u{11a8}", &["\u{200d}", "\u{11a8}"]),
- ("\u{200d}\u{308}\u{11a8}", &["\u{200d}\u{308}", "\u{11a8}"]), ("\u{200d}\u{ac00}",
- &["\u{200d}", "\u{ac00}"]), ("\u{200d}\u{308}\u{ac00}", &["\u{200d}\u{308}", "\u{ac00}"]),
- ("\u{200d}\u{ac01}", &["\u{200d}", "\u{ac01}"]), ("\u{200d}\u{308}\u{ac01}",
- &["\u{200d}\u{308}", "\u{ac01}"]), ("\u{200d}\u{231a}", &["\u{200d}", "\u{231a}"]),
- ("\u{200d}\u{308}\u{231a}", &["\u{200d}\u{308}", "\u{231a}"]), ("\u{200d}\u{300}",
- &["\u{200d}\u{300}"]), ("\u{200d}\u{308}\u{300}", &["\u{200d}\u{308}\u{300}"]),
- ("\u{200d}\u{200d}", &["\u{200d}\u{200d}"]), ("\u{200d}\u{308}\u{200d}",
- &["\u{200d}\u{308}\u{200d}"]), ("\u{200d}\u{378}", &["\u{200d}", "\u{378}"]),
- ("\u{200d}\u{308}\u{378}", &["\u{200d}\u{308}", "\u{378}"]), ("\u{378}\u{20}", &["\u{378}",
- "\u{20}"]), ("\u{378}\u{308}\u{20}", &["\u{378}\u{308}", "\u{20}"]), ("\u{378}\u{d}",
- &["\u{378}", "\u{d}"]), ("\u{378}\u{308}\u{d}", &["\u{378}\u{308}", "\u{d}"]),
- ("\u{378}\u{a}", &["\u{378}", "\u{a}"]), ("\u{378}\u{308}\u{a}", &["\u{378}\u{308}",
- "\u{a}"]), ("\u{378}\u{1}", &["\u{378}", "\u{1}"]), ("\u{378}\u{308}\u{1}",
- &["\u{378}\u{308}", "\u{1}"]), ("\u{378}\u{34f}", &["\u{378}\u{34f}"]),
- ("\u{378}\u{308}\u{34f}", &["\u{378}\u{308}\u{34f}"]), ("\u{378}\u{1f1e6}", &["\u{378}",
- "\u{1f1e6}"]), ("\u{378}\u{308}\u{1f1e6}", &["\u{378}\u{308}", "\u{1f1e6}"]),
- ("\u{378}\u{600}", &["\u{378}", "\u{600}"]), ("\u{378}\u{308}\u{600}", &["\u{378}\u{308}",
- "\u{600}"]), ("\u{378}\u{1100}", &["\u{378}", "\u{1100}"]), ("\u{378}\u{308}\u{1100}",
- &["\u{378}\u{308}", "\u{1100}"]), ("\u{378}\u{1160}", &["\u{378}", "\u{1160}"]),
- ("\u{378}\u{308}\u{1160}", &["\u{378}\u{308}", "\u{1160}"]), ("\u{378}\u{11a8}",
- &["\u{378}", "\u{11a8}"]), ("\u{378}\u{308}\u{11a8}", &["\u{378}\u{308}", "\u{11a8}"]),
- ("\u{378}\u{ac00}", &["\u{378}", "\u{ac00}"]), ("\u{378}\u{308}\u{ac00}",
- &["\u{378}\u{308}", "\u{ac00}"]), ("\u{378}\u{ac01}", &["\u{378}", "\u{ac01}"]),
- ("\u{378}\u{308}\u{ac01}", &["\u{378}\u{308}", "\u{ac01}"]), ("\u{378}\u{231a}",
- &["\u{378}", "\u{231a}"]), ("\u{378}\u{308}\u{231a}", &["\u{378}\u{308}", "\u{231a}"]),
- ("\u{378}\u{300}", &["\u{378}\u{300}"]), ("\u{378}\u{308}\u{300}",
- &["\u{378}\u{308}\u{300}"]), ("\u{378}\u{200d}", &["\u{378}\u{200d}"]),
- ("\u{378}\u{308}\u{200d}", &["\u{378}\u{308}\u{200d}"]), ("\u{378}\u{378}", &["\u{378}",
- "\u{378}"]), ("\u{378}\u{308}\u{378}", &["\u{378}\u{308}", "\u{378}"]),
- ("\u{d}\u{a}\u{61}\u{a}\u{308}", &["\u{d}\u{a}", "\u{61}", "\u{a}", "\u{308}"]),
- ("\u{61}\u{308}", &["\u{61}\u{308}"]), ("\u{20}\u{200d}\u{646}", &["\u{20}\u{200d}",
- "\u{646}"]), ("\u{646}\u{200d}\u{20}", &["\u{646}\u{200d}", "\u{20}"]), ("\u{1100}\u{1100}",
- &["\u{1100}\u{1100}"]), ("\u{ac00}\u{11a8}\u{1100}", &["\u{ac00}\u{11a8}", "\u{1100}"]),
- ("\u{ac01}\u{11a8}\u{1100}", &["\u{ac01}\u{11a8}", "\u{1100}"]),
- ("\u{1f1e6}\u{1f1e7}\u{1f1e8}\u{62}", &["\u{1f1e6}\u{1f1e7}", "\u{1f1e8}", "\u{62}"]),
- ("\u{61}\u{1f1e6}\u{1f1e7}\u{1f1e8}\u{62}", &["\u{61}", "\u{1f1e6}\u{1f1e7}", "\u{1f1e8}",
- "\u{62}"]), ("\u{61}\u{1f1e6}\u{1f1e7}\u{200d}\u{1f1e8}\u{62}", &["\u{61}",
- "\u{1f1e6}\u{1f1e7}\u{200d}", "\u{1f1e8}", "\u{62}"]),
- ("\u{61}\u{1f1e6}\u{200d}\u{1f1e7}\u{1f1e8}\u{62}", &["\u{61}", "\u{1f1e6}\u{200d}",
- "\u{1f1e7}\u{1f1e8}", "\u{62}"]), ("\u{61}\u{1f1e6}\u{1f1e7}\u{1f1e8}\u{1f1e9}\u{62}",
- &["\u{61}", "\u{1f1e6}\u{1f1e7}", "\u{1f1e8}\u{1f1e9}", "\u{62}"]), ("\u{61}\u{200d}",
- &["\u{61}\u{200d}"]), ("\u{61}\u{308}\u{62}", &["\u{61}\u{308}", "\u{62}"]),
- ("\u{1f476}\u{1f3ff}\u{1f476}", &["\u{1f476}\u{1f3ff}", "\u{1f476}"]),
- ("\u{61}\u{1f3ff}\u{1f476}", &["\u{61}\u{1f3ff}", "\u{1f476}"]),
- ("\u{61}\u{1f3ff}\u{1f476}\u{200d}\u{1f6d1}", &["\u{61}\u{1f3ff}",
- "\u{1f476}\u{200d}\u{1f6d1}"]), ("\u{1f476}\u{1f3ff}\u{308}\u{200d}\u{1f476}\u{1f3ff}",
- &["\u{1f476}\u{1f3ff}\u{308}\u{200d}\u{1f476}\u{1f3ff}"]), ("\u{1f6d1}\u{200d}\u{1f6d1}",
- &["\u{1f6d1}\u{200d}\u{1f6d1}"]), ("\u{61}\u{200d}\u{1f6d1}", &["\u{61}\u{200d}",
- "\u{1f6d1}"]), ("\u{2701}\u{200d}\u{2701}", &["\u{2701}\u{200d}\u{2701}"]),
- ("\u{61}\u{200d}\u{2701}", &["\u{61}\u{200d}", "\u{2701}"])
- ];
-
- pub const TEST_DIFF: &'static [(&'static str, &'static [&'static str], &'static [&'static str])] = &[
- ("\u{20}\u{903}", &["\u{20}\u{903}"], &["\u{20}", "\u{903}"]), ("\u{20}\u{308}\u{903}",
- &["\u{20}\u{308}\u{903}"], &["\u{20}\u{308}", "\u{903}"]), ("\u{d}\u{308}\u{903}",
- &["\u{d}", "\u{308}\u{903}"], &["\u{d}", "\u{308}", "\u{903}"]), ("\u{a}\u{308}\u{903}",
- &["\u{a}", "\u{308}\u{903}"], &["\u{a}", "\u{308}", "\u{903}"]), ("\u{1}\u{308}\u{903}",
- &["\u{1}", "\u{308}\u{903}"], &["\u{1}", "\u{308}", "\u{903}"]), ("\u{34f}\u{903}",
- &["\u{34f}\u{903}"], &["\u{34f}", "\u{903}"]), ("\u{34f}\u{308}\u{903}",
- &["\u{34f}\u{308}\u{903}"], &["\u{34f}\u{308}", "\u{903}"]), ("\u{1f1e6}\u{903}",
- &["\u{1f1e6}\u{903}"], &["\u{1f1e6}", "\u{903}"]), ("\u{1f1e6}\u{308}\u{903}",
- &["\u{1f1e6}\u{308}\u{903}"], &["\u{1f1e6}\u{308}", "\u{903}"]), ("\u{600}\u{20}",
- &["\u{600}\u{20}"], &["\u{600}", "\u{20}"]), ("\u{600}\u{1f1e6}", &["\u{600}\u{1f1e6}"],
- &["\u{600}", "\u{1f1e6}"]), ("\u{600}\u{600}", &["\u{600}\u{600}"], &["\u{600}",
- "\u{600}"]), ("\u{600}\u{903}", &["\u{600}\u{903}"], &["\u{600}", "\u{903}"]),
- ("\u{600}\u{308}\u{903}", &["\u{600}\u{308}\u{903}"], &["\u{600}\u{308}", "\u{903}"]),
- ("\u{600}\u{1100}", &["\u{600}\u{1100}"], &["\u{600}", "\u{1100}"]), ("\u{600}\u{1160}",
- &["\u{600}\u{1160}"], &["\u{600}", "\u{1160}"]), ("\u{600}\u{11a8}", &["\u{600}\u{11a8}"],
- &["\u{600}", "\u{11a8}"]), ("\u{600}\u{ac00}", &["\u{600}\u{ac00}"], &["\u{600}",
- "\u{ac00}"]), ("\u{600}\u{ac01}", &["\u{600}\u{ac01}"], &["\u{600}", "\u{ac01}"]),
- ("\u{600}\u{231a}", &["\u{600}\u{231a}"], &["\u{600}", "\u{231a}"]), ("\u{600}\u{378}",
- &["\u{600}\u{378}"], &["\u{600}", "\u{378}"]), ("\u{903}\u{903}", &["\u{903}\u{903}"],
- &["\u{903}", "\u{903}"]), ("\u{903}\u{308}\u{903}", &["\u{903}\u{308}\u{903}"],
- &["\u{903}\u{308}", "\u{903}"]), ("\u{1100}\u{903}", &["\u{1100}\u{903}"], &["\u{1100}",
- "\u{903}"]), ("\u{1100}\u{308}\u{903}", &["\u{1100}\u{308}\u{903}"], &["\u{1100}\u{308}",
- "\u{903}"]), ("\u{1160}\u{903}", &["\u{1160}\u{903}"], &["\u{1160}", "\u{903}"]),
- ("\u{1160}\u{308}\u{903}", &["\u{1160}\u{308}\u{903}"], &["\u{1160}\u{308}", "\u{903}"]),
- ("\u{11a8}\u{903}", &["\u{11a8}\u{903}"], &["\u{11a8}", "\u{903}"]),
- ("\u{11a8}\u{308}\u{903}", &["\u{11a8}\u{308}\u{903}"], &["\u{11a8}\u{308}", "\u{903}"]),
- ("\u{ac00}\u{903}", &["\u{ac00}\u{903}"], &["\u{ac00}", "\u{903}"]),
- ("\u{ac00}\u{308}\u{903}", &["\u{ac00}\u{308}\u{903}"], &["\u{ac00}\u{308}", "\u{903}"]),
- ("\u{ac01}\u{903}", &["\u{ac01}\u{903}"], &["\u{ac01}", "\u{903}"]),
- ("\u{ac01}\u{308}\u{903}", &["\u{ac01}\u{308}\u{903}"], &["\u{ac01}\u{308}", "\u{903}"]),
- ("\u{231a}\u{903}", &["\u{231a}\u{903}"], &["\u{231a}", "\u{903}"]),
- ("\u{231a}\u{308}\u{903}", &["\u{231a}\u{308}\u{903}"], &["\u{231a}\u{308}", "\u{903}"]),
- ("\u{300}\u{903}", &["\u{300}\u{903}"], &["\u{300}", "\u{903}"]), ("\u{300}\u{308}\u{903}",
- &["\u{300}\u{308}\u{903}"], &["\u{300}\u{308}", "\u{903}"]), ("\u{200d}\u{903}",
- &["\u{200d}\u{903}"], &["\u{200d}", "\u{903}"]), ("\u{200d}\u{308}\u{903}",
- &["\u{200d}\u{308}\u{903}"], &["\u{200d}\u{308}", "\u{903}"]), ("\u{378}\u{903}",
- &["\u{378}\u{903}"], &["\u{378}", "\u{903}"]), ("\u{378}\u{308}\u{903}",
- &["\u{378}\u{308}\u{903}"], &["\u{378}\u{308}", "\u{903}"]), ("\u{61}\u{903}\u{62}",
- &["\u{61}\u{903}", "\u{62}"], &["\u{61}", "\u{903}", "\u{62}"]), ("\u{61}\u{600}\u{62}",
- &["\u{61}", "\u{600}\u{62}"], &["\u{61}", "\u{600}", "\u{62}"])
- ];
-
- // official Unicode test data
- // http://www.unicode.org/Public/12.0.0/ucd/auxiliary/WordBreakTest.txt
- pub const TEST_WORD: &'static [(&'static str, &'static [&'static str])] = &[
- ("\u{1}\u{1}", &["\u{1}", "\u{1}"]), ("\u{1}\u{308}\u{1}", &["\u{1}\u{308}", "\u{1}"]),
- ("\u{1}\u{d}", &["\u{1}", "\u{d}"]), ("\u{1}\u{308}\u{d}", &["\u{1}\u{308}", "\u{d}"]),
- ("\u{1}\u{a}", &["\u{1}", "\u{a}"]), ("\u{1}\u{308}\u{a}", &["\u{1}\u{308}", "\u{a}"]),
- ("\u{1}\u{b}", &["\u{1}", "\u{b}"]), ("\u{1}\u{308}\u{b}", &["\u{1}\u{308}", "\u{b}"]),
- ("\u{1}\u{3031}", &["\u{1}", "\u{3031}"]), ("\u{1}\u{308}\u{3031}", &["\u{1}\u{308}",
- "\u{3031}"]), ("\u{1}\u{41}", &["\u{1}", "\u{41}"]), ("\u{1}\u{308}\u{41}",
- &["\u{1}\u{308}", "\u{41}"]), ("\u{1}\u{3a}", &["\u{1}", "\u{3a}"]), ("\u{1}\u{308}\u{3a}",
- &["\u{1}\u{308}", "\u{3a}"]), ("\u{1}\u{2c}", &["\u{1}", "\u{2c}"]), ("\u{1}\u{308}\u{2c}",
- &["\u{1}\u{308}", "\u{2c}"]), ("\u{1}\u{2e}", &["\u{1}", "\u{2e}"]), ("\u{1}\u{308}\u{2e}",
- &["\u{1}\u{308}", "\u{2e}"]), ("\u{1}\u{30}", &["\u{1}", "\u{30}"]), ("\u{1}\u{308}\u{30}",
- &["\u{1}\u{308}", "\u{30}"]), ("\u{1}\u{5f}", &["\u{1}", "\u{5f}"]), ("\u{1}\u{308}\u{5f}",
- &["\u{1}\u{308}", "\u{5f}"]), ("\u{1}\u{1f1e6}", &["\u{1}", "\u{1f1e6}"]),
- ("\u{1}\u{308}\u{1f1e6}", &["\u{1}\u{308}", "\u{1f1e6}"]), ("\u{1}\u{5d0}", &["\u{1}",
- "\u{5d0}"]), ("\u{1}\u{308}\u{5d0}", &["\u{1}\u{308}", "\u{5d0}"]), ("\u{1}\u{22}",
- &["\u{1}", "\u{22}"]), ("\u{1}\u{308}\u{22}", &["\u{1}\u{308}", "\u{22}"]), ("\u{1}\u{27}",
- &["\u{1}", "\u{27}"]), ("\u{1}\u{308}\u{27}", &["\u{1}\u{308}", "\u{27}"]),
- ("\u{1}\u{231a}", &["\u{1}", "\u{231a}"]), ("\u{1}\u{308}\u{231a}", &["\u{1}\u{308}",
- "\u{231a}"]), ("\u{1}\u{20}", &["\u{1}", "\u{20}"]), ("\u{1}\u{308}\u{20}",
- &["\u{1}\u{308}", "\u{20}"]), ("\u{1}\u{ad}", &["\u{1}\u{ad}"]), ("\u{1}\u{308}\u{ad}",
- &["\u{1}\u{308}\u{ad}"]), ("\u{1}\u{300}", &["\u{1}\u{300}"]), ("\u{1}\u{308}\u{300}",
- &["\u{1}\u{308}\u{300}"]), ("\u{1}\u{200d}", &["\u{1}\u{200d}"]), ("\u{1}\u{308}\u{200d}",
- &["\u{1}\u{308}\u{200d}"]), ("\u{1}\u{61}\u{2060}", &["\u{1}", "\u{61}\u{2060}"]),
- ("\u{1}\u{308}\u{61}\u{2060}", &["\u{1}\u{308}", "\u{61}\u{2060}"]), ("\u{1}\u{61}\u{3a}",
- &["\u{1}", "\u{61}", "\u{3a}"]), ("\u{1}\u{308}\u{61}\u{3a}", &["\u{1}\u{308}", "\u{61}",
- "\u{3a}"]), ("\u{1}\u{61}\u{27}", &["\u{1}", "\u{61}", "\u{27}"]),
- ("\u{1}\u{308}\u{61}\u{27}", &["\u{1}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{1}\u{61}\u{27}\u{2060}", &["\u{1}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{1}\u{308}\u{61}\u{27}\u{2060}", &["\u{1}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{1}\u{61}\u{2c}", &["\u{1}", "\u{61}", "\u{2c}"]), ("\u{1}\u{308}\u{61}\u{2c}",
- &["\u{1}\u{308}", "\u{61}", "\u{2c}"]), ("\u{1}\u{31}\u{3a}", &["\u{1}", "\u{31}",
- "\u{3a}"]), ("\u{1}\u{308}\u{31}\u{3a}", &["\u{1}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{1}\u{31}\u{27}", &["\u{1}", "\u{31}", "\u{27}"]), ("\u{1}\u{308}\u{31}\u{27}",
- &["\u{1}\u{308}", "\u{31}", "\u{27}"]), ("\u{1}\u{31}\u{2c}", &["\u{1}", "\u{31}",
- "\u{2c}"]), ("\u{1}\u{308}\u{31}\u{2c}", &["\u{1}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{1}\u{31}\u{2e}\u{2060}", &["\u{1}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{1}\u{308}\u{31}\u{2e}\u{2060}", &["\u{1}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{d}\u{1}", &["\u{d}", "\u{1}"]), ("\u{d}\u{308}\u{1}", &["\u{d}", "\u{308}", "\u{1}"]),
- ("\u{d}\u{d}", &["\u{d}", "\u{d}"]), ("\u{d}\u{308}\u{d}", &["\u{d}", "\u{308}", "\u{d}"]),
- ("\u{d}\u{a}", &["\u{d}\u{a}"]), ("\u{d}\u{308}\u{a}", &["\u{d}", "\u{308}", "\u{a}"]),
- ("\u{d}\u{b}", &["\u{d}", "\u{b}"]), ("\u{d}\u{308}\u{b}", &["\u{d}", "\u{308}", "\u{b}"]),
- ("\u{d}\u{3031}", &["\u{d}", "\u{3031}"]), ("\u{d}\u{308}\u{3031}", &["\u{d}", "\u{308}",
- "\u{3031}"]), ("\u{d}\u{41}", &["\u{d}", "\u{41}"]), ("\u{d}\u{308}\u{41}", &["\u{d}",
- "\u{308}", "\u{41}"]), ("\u{d}\u{3a}", &["\u{d}", "\u{3a}"]), ("\u{d}\u{308}\u{3a}",
- &["\u{d}", "\u{308}", "\u{3a}"]), ("\u{d}\u{2c}", &["\u{d}", "\u{2c}"]),
- ("\u{d}\u{308}\u{2c}", &["\u{d}", "\u{308}", "\u{2c}"]), ("\u{d}\u{2e}", &["\u{d}",
- "\u{2e}"]), ("\u{d}\u{308}\u{2e}", &["\u{d}", "\u{308}", "\u{2e}"]), ("\u{d}\u{30}",
- &["\u{d}", "\u{30}"]), ("\u{d}\u{308}\u{30}", &["\u{d}", "\u{308}", "\u{30}"]),
- ("\u{d}\u{5f}", &["\u{d}", "\u{5f}"]), ("\u{d}\u{308}\u{5f}", &["\u{d}", "\u{308}",
- "\u{5f}"]), ("\u{d}\u{1f1e6}", &["\u{d}", "\u{1f1e6}"]), ("\u{d}\u{308}\u{1f1e6}",
- &["\u{d}", "\u{308}", "\u{1f1e6}"]), ("\u{d}\u{5d0}", &["\u{d}", "\u{5d0}"]),
- ("\u{d}\u{308}\u{5d0}", &["\u{d}", "\u{308}", "\u{5d0}"]), ("\u{d}\u{22}", &["\u{d}",
- "\u{22}"]), ("\u{d}\u{308}\u{22}", &["\u{d}", "\u{308}", "\u{22}"]), ("\u{d}\u{27}",
- &["\u{d}", "\u{27}"]), ("\u{d}\u{308}\u{27}", &["\u{d}", "\u{308}", "\u{27}"]),
- ("\u{d}\u{231a}", &["\u{d}", "\u{231a}"]), ("\u{d}\u{308}\u{231a}", &["\u{d}", "\u{308}",
- "\u{231a}"]), ("\u{d}\u{20}", &["\u{d}", "\u{20}"]), ("\u{d}\u{308}\u{20}", &["\u{d}",
- "\u{308}", "\u{20}"]), ("\u{d}\u{ad}", &["\u{d}", "\u{ad}"]), ("\u{d}\u{308}\u{ad}",
- &["\u{d}", "\u{308}\u{ad}"]), ("\u{d}\u{300}", &["\u{d}", "\u{300}"]),
- ("\u{d}\u{308}\u{300}", &["\u{d}", "\u{308}\u{300}"]), ("\u{d}\u{200d}", &["\u{d}",
- "\u{200d}"]), ("\u{d}\u{308}\u{200d}", &["\u{d}", "\u{308}\u{200d}"]),
- ("\u{d}\u{61}\u{2060}", &["\u{d}", "\u{61}\u{2060}"]), ("\u{d}\u{308}\u{61}\u{2060}",
- &["\u{d}", "\u{308}", "\u{61}\u{2060}"]), ("\u{d}\u{61}\u{3a}", &["\u{d}", "\u{61}",
- "\u{3a}"]), ("\u{d}\u{308}\u{61}\u{3a}", &["\u{d}", "\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{d}\u{61}\u{27}", &["\u{d}", "\u{61}", "\u{27}"]), ("\u{d}\u{308}\u{61}\u{27}",
- &["\u{d}", "\u{308}", "\u{61}", "\u{27}"]), ("\u{d}\u{61}\u{27}\u{2060}", &["\u{d}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{d}\u{308}\u{61}\u{27}\u{2060}", &["\u{d}", "\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{d}\u{61}\u{2c}", &["\u{d}", "\u{61}", "\u{2c}"]),
- ("\u{d}\u{308}\u{61}\u{2c}", &["\u{d}", "\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{d}\u{31}\u{3a}", &["\u{d}", "\u{31}", "\u{3a}"]), ("\u{d}\u{308}\u{31}\u{3a}",
- &["\u{d}", "\u{308}", "\u{31}", "\u{3a}"]), ("\u{d}\u{31}\u{27}", &["\u{d}", "\u{31}",
- "\u{27}"]), ("\u{d}\u{308}\u{31}\u{27}", &["\u{d}", "\u{308}", "\u{31}", "\u{27}"]),
- ("\u{d}\u{31}\u{2c}", &["\u{d}", "\u{31}", "\u{2c}"]), ("\u{d}\u{308}\u{31}\u{2c}",
- &["\u{d}", "\u{308}", "\u{31}", "\u{2c}"]), ("\u{d}\u{31}\u{2e}\u{2060}", &["\u{d}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{d}\u{308}\u{31}\u{2e}\u{2060}", &["\u{d}", "\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{a}\u{1}", &["\u{a}", "\u{1}"]), ("\u{a}\u{308}\u{1}",
- &["\u{a}", "\u{308}", "\u{1}"]), ("\u{a}\u{d}", &["\u{a}", "\u{d}"]), ("\u{a}\u{308}\u{d}",
- &["\u{a}", "\u{308}", "\u{d}"]), ("\u{a}\u{a}", &["\u{a}", "\u{a}"]), ("\u{a}\u{308}\u{a}",
- &["\u{a}", "\u{308}", "\u{a}"]), ("\u{a}\u{b}", &["\u{a}", "\u{b}"]), ("\u{a}\u{308}\u{b}",
- &["\u{a}", "\u{308}", "\u{b}"]), ("\u{a}\u{3031}", &["\u{a}", "\u{3031}"]),
- ("\u{a}\u{308}\u{3031}", &["\u{a}", "\u{308}", "\u{3031}"]), ("\u{a}\u{41}", &["\u{a}",
- "\u{41}"]), ("\u{a}\u{308}\u{41}", &["\u{a}", "\u{308}", "\u{41}"]), ("\u{a}\u{3a}",
- &["\u{a}", "\u{3a}"]), ("\u{a}\u{308}\u{3a}", &["\u{a}", "\u{308}", "\u{3a}"]),
- ("\u{a}\u{2c}", &["\u{a}", "\u{2c}"]), ("\u{a}\u{308}\u{2c}", &["\u{a}", "\u{308}",
- "\u{2c}"]), ("\u{a}\u{2e}", &["\u{a}", "\u{2e}"]), ("\u{a}\u{308}\u{2e}", &["\u{a}",
- "\u{308}", "\u{2e}"]), ("\u{a}\u{30}", &["\u{a}", "\u{30}"]), ("\u{a}\u{308}\u{30}",
- &["\u{a}", "\u{308}", "\u{30}"]), ("\u{a}\u{5f}", &["\u{a}", "\u{5f}"]),
- ("\u{a}\u{308}\u{5f}", &["\u{a}", "\u{308}", "\u{5f}"]), ("\u{a}\u{1f1e6}", &["\u{a}",
- "\u{1f1e6}"]), ("\u{a}\u{308}\u{1f1e6}", &["\u{a}", "\u{308}", "\u{1f1e6}"]),
- ("\u{a}\u{5d0}", &["\u{a}", "\u{5d0}"]), ("\u{a}\u{308}\u{5d0}", &["\u{a}", "\u{308}",
- "\u{5d0}"]), ("\u{a}\u{22}", &["\u{a}", "\u{22}"]), ("\u{a}\u{308}\u{22}", &["\u{a}",
- "\u{308}", "\u{22}"]), ("\u{a}\u{27}", &["\u{a}", "\u{27}"]), ("\u{a}\u{308}\u{27}",
- &["\u{a}", "\u{308}", "\u{27}"]), ("\u{a}\u{231a}", &["\u{a}", "\u{231a}"]),
- ("\u{a}\u{308}\u{231a}", &["\u{a}", "\u{308}", "\u{231a}"]), ("\u{a}\u{20}", &["\u{a}",
- "\u{20}"]), ("\u{a}\u{308}\u{20}", &["\u{a}", "\u{308}", "\u{20}"]), ("\u{a}\u{ad}",
- &["\u{a}", "\u{ad}"]), ("\u{a}\u{308}\u{ad}", &["\u{a}", "\u{308}\u{ad}"]), ("\u{a}\u{300}",
- &["\u{a}", "\u{300}"]), ("\u{a}\u{308}\u{300}", &["\u{a}", "\u{308}\u{300}"]),
- ("\u{a}\u{200d}", &["\u{a}", "\u{200d}"]), ("\u{a}\u{308}\u{200d}", &["\u{a}",
- "\u{308}\u{200d}"]), ("\u{a}\u{61}\u{2060}", &["\u{a}", "\u{61}\u{2060}"]),
- ("\u{a}\u{308}\u{61}\u{2060}", &["\u{a}", "\u{308}", "\u{61}\u{2060}"]),
- ("\u{a}\u{61}\u{3a}", &["\u{a}", "\u{61}", "\u{3a}"]), ("\u{a}\u{308}\u{61}\u{3a}",
- &["\u{a}", "\u{308}", "\u{61}", "\u{3a}"]), ("\u{a}\u{61}\u{27}", &["\u{a}", "\u{61}",
- "\u{27}"]), ("\u{a}\u{308}\u{61}\u{27}", &["\u{a}", "\u{308}", "\u{61}", "\u{27}"]),
- ("\u{a}\u{61}\u{27}\u{2060}", &["\u{a}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{a}\u{308}\u{61}\u{27}\u{2060}", &["\u{a}", "\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{a}\u{61}\u{2c}", &["\u{a}", "\u{61}", "\u{2c}"]), ("\u{a}\u{308}\u{61}\u{2c}",
- &["\u{a}", "\u{308}", "\u{61}", "\u{2c}"]), ("\u{a}\u{31}\u{3a}", &["\u{a}", "\u{31}",
- "\u{3a}"]), ("\u{a}\u{308}\u{31}\u{3a}", &["\u{a}", "\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{a}\u{31}\u{27}", &["\u{a}", "\u{31}", "\u{27}"]), ("\u{a}\u{308}\u{31}\u{27}",
- &["\u{a}", "\u{308}", "\u{31}", "\u{27}"]), ("\u{a}\u{31}\u{2c}", &["\u{a}", "\u{31}",
- "\u{2c}"]), ("\u{a}\u{308}\u{31}\u{2c}", &["\u{a}", "\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{a}\u{31}\u{2e}\u{2060}", &["\u{a}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{a}\u{308}\u{31}\u{2e}\u{2060}", &["\u{a}", "\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{b}\u{1}", &["\u{b}", "\u{1}"]), ("\u{b}\u{308}\u{1}", &["\u{b}", "\u{308}", "\u{1}"]),
- ("\u{b}\u{d}", &["\u{b}", "\u{d}"]), ("\u{b}\u{308}\u{d}", &["\u{b}", "\u{308}", "\u{d}"]),
- ("\u{b}\u{a}", &["\u{b}", "\u{a}"]), ("\u{b}\u{308}\u{a}", &["\u{b}", "\u{308}", "\u{a}"]),
- ("\u{b}\u{b}", &["\u{b}", "\u{b}"]), ("\u{b}\u{308}\u{b}", &["\u{b}", "\u{308}", "\u{b}"]),
- ("\u{b}\u{3031}", &["\u{b}", "\u{3031}"]), ("\u{b}\u{308}\u{3031}", &["\u{b}", "\u{308}",
- "\u{3031}"]), ("\u{b}\u{41}", &["\u{b}", "\u{41}"]), ("\u{b}\u{308}\u{41}", &["\u{b}",
- "\u{308}", "\u{41}"]), ("\u{b}\u{3a}", &["\u{b}", "\u{3a}"]), ("\u{b}\u{308}\u{3a}",
- &["\u{b}", "\u{308}", "\u{3a}"]), ("\u{b}\u{2c}", &["\u{b}", "\u{2c}"]),
- ("\u{b}\u{308}\u{2c}", &["\u{b}", "\u{308}", "\u{2c}"]), ("\u{b}\u{2e}", &["\u{b}",
- "\u{2e}"]), ("\u{b}\u{308}\u{2e}", &["\u{b}", "\u{308}", "\u{2e}"]), ("\u{b}\u{30}",
- &["\u{b}", "\u{30}"]), ("\u{b}\u{308}\u{30}", &["\u{b}", "\u{308}", "\u{30}"]),
- ("\u{b}\u{5f}", &["\u{b}", "\u{5f}"]), ("\u{b}\u{308}\u{5f}", &["\u{b}", "\u{308}",
- "\u{5f}"]), ("\u{b}\u{1f1e6}", &["\u{b}", "\u{1f1e6}"]), ("\u{b}\u{308}\u{1f1e6}",
- &["\u{b}", "\u{308}", "\u{1f1e6}"]), ("\u{b}\u{5d0}", &["\u{b}", "\u{5d0}"]),
- ("\u{b}\u{308}\u{5d0}", &["\u{b}", "\u{308}", "\u{5d0}"]), ("\u{b}\u{22}", &["\u{b}",
- "\u{22}"]), ("\u{b}\u{308}\u{22}", &["\u{b}", "\u{308}", "\u{22}"]), ("\u{b}\u{27}",
- &["\u{b}", "\u{27}"]), ("\u{b}\u{308}\u{27}", &["\u{b}", "\u{308}", "\u{27}"]),
- ("\u{b}\u{231a}", &["\u{b}", "\u{231a}"]), ("\u{b}\u{308}\u{231a}", &["\u{b}", "\u{308}",
- "\u{231a}"]), ("\u{b}\u{20}", &["\u{b}", "\u{20}"]), ("\u{b}\u{308}\u{20}", &["\u{b}",
- "\u{308}", "\u{20}"]), ("\u{b}\u{ad}", &["\u{b}", "\u{ad}"]), ("\u{b}\u{308}\u{ad}",
- &["\u{b}", "\u{308}\u{ad}"]), ("\u{b}\u{300}", &["\u{b}", "\u{300}"]),
- ("\u{b}\u{308}\u{300}", &["\u{b}", "\u{308}\u{300}"]), ("\u{b}\u{200d}", &["\u{b}",
- "\u{200d}"]), ("\u{b}\u{308}\u{200d}", &["\u{b}", "\u{308}\u{200d}"]),
- ("\u{b}\u{61}\u{2060}", &["\u{b}", "\u{61}\u{2060}"]), ("\u{b}\u{308}\u{61}\u{2060}",
- &["\u{b}", "\u{308}", "\u{61}\u{2060}"]), ("\u{b}\u{61}\u{3a}", &["\u{b}", "\u{61}",
- "\u{3a}"]), ("\u{b}\u{308}\u{61}\u{3a}", &["\u{b}", "\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{b}\u{61}\u{27}", &["\u{b}", "\u{61}", "\u{27}"]), ("\u{b}\u{308}\u{61}\u{27}",
- &["\u{b}", "\u{308}", "\u{61}", "\u{27}"]), ("\u{b}\u{61}\u{27}\u{2060}", &["\u{b}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{b}\u{308}\u{61}\u{27}\u{2060}", &["\u{b}", "\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{b}\u{61}\u{2c}", &["\u{b}", "\u{61}", "\u{2c}"]),
- ("\u{b}\u{308}\u{61}\u{2c}", &["\u{b}", "\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{b}\u{31}\u{3a}", &["\u{b}", "\u{31}", "\u{3a}"]), ("\u{b}\u{308}\u{31}\u{3a}",
- &["\u{b}", "\u{308}", "\u{31}", "\u{3a}"]), ("\u{b}\u{31}\u{27}", &["\u{b}", "\u{31}",
- "\u{27}"]), ("\u{b}\u{308}\u{31}\u{27}", &["\u{b}", "\u{308}", "\u{31}", "\u{27}"]),
- ("\u{b}\u{31}\u{2c}", &["\u{b}", "\u{31}", "\u{2c}"]), ("\u{b}\u{308}\u{31}\u{2c}",
- &["\u{b}", "\u{308}", "\u{31}", "\u{2c}"]), ("\u{b}\u{31}\u{2e}\u{2060}", &["\u{b}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{b}\u{308}\u{31}\u{2e}\u{2060}", &["\u{b}", "\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{3031}\u{1}", &["\u{3031}", "\u{1}"]),
- ("\u{3031}\u{308}\u{1}", &["\u{3031}\u{308}", "\u{1}"]), ("\u{3031}\u{d}", &["\u{3031}",
- "\u{d}"]), ("\u{3031}\u{308}\u{d}", &["\u{3031}\u{308}", "\u{d}"]), ("\u{3031}\u{a}",
- &["\u{3031}", "\u{a}"]), ("\u{3031}\u{308}\u{a}", &["\u{3031}\u{308}", "\u{a}"]),
- ("\u{3031}\u{b}", &["\u{3031}", "\u{b}"]), ("\u{3031}\u{308}\u{b}", &["\u{3031}\u{308}",
- "\u{b}"]), ("\u{3031}\u{3031}", &["\u{3031}\u{3031}"]), ("\u{3031}\u{308}\u{3031}",
- &["\u{3031}\u{308}\u{3031}"]), ("\u{3031}\u{41}", &["\u{3031}", "\u{41}"]),
- ("\u{3031}\u{308}\u{41}", &["\u{3031}\u{308}", "\u{41}"]), ("\u{3031}\u{3a}", &["\u{3031}",
- "\u{3a}"]), ("\u{3031}\u{308}\u{3a}", &["\u{3031}\u{308}", "\u{3a}"]), ("\u{3031}\u{2c}",
- &["\u{3031}", "\u{2c}"]), ("\u{3031}\u{308}\u{2c}", &["\u{3031}\u{308}", "\u{2c}"]),
- ("\u{3031}\u{2e}", &["\u{3031}", "\u{2e}"]), ("\u{3031}\u{308}\u{2e}", &["\u{3031}\u{308}",
- "\u{2e}"]), ("\u{3031}\u{30}", &["\u{3031}", "\u{30}"]), ("\u{3031}\u{308}\u{30}",
- &["\u{3031}\u{308}", "\u{30}"]), ("\u{3031}\u{5f}", &["\u{3031}\u{5f}"]),
- ("\u{3031}\u{308}\u{5f}", &["\u{3031}\u{308}\u{5f}"]), ("\u{3031}\u{1f1e6}", &["\u{3031}",
- "\u{1f1e6}"]), ("\u{3031}\u{308}\u{1f1e6}", &["\u{3031}\u{308}", "\u{1f1e6}"]),
- ("\u{3031}\u{5d0}", &["\u{3031}", "\u{5d0}"]), ("\u{3031}\u{308}\u{5d0}",
- &["\u{3031}\u{308}", "\u{5d0}"]), ("\u{3031}\u{22}", &["\u{3031}", "\u{22}"]),
- ("\u{3031}\u{308}\u{22}", &["\u{3031}\u{308}", "\u{22}"]), ("\u{3031}\u{27}", &["\u{3031}",
- "\u{27}"]), ("\u{3031}\u{308}\u{27}", &["\u{3031}\u{308}", "\u{27}"]), ("\u{3031}\u{231a}",
- &["\u{3031}", "\u{231a}"]), ("\u{3031}\u{308}\u{231a}", &["\u{3031}\u{308}", "\u{231a}"]),
- ("\u{3031}\u{20}", &["\u{3031}", "\u{20}"]), ("\u{3031}\u{308}\u{20}", &["\u{3031}\u{308}",
- "\u{20}"]), ("\u{3031}\u{ad}", &["\u{3031}\u{ad}"]), ("\u{3031}\u{308}\u{ad}",
- &["\u{3031}\u{308}\u{ad}"]), ("\u{3031}\u{300}", &["\u{3031}\u{300}"]),
- ("\u{3031}\u{308}\u{300}", &["\u{3031}\u{308}\u{300}"]), ("\u{3031}\u{200d}",
- &["\u{3031}\u{200d}"]), ("\u{3031}\u{308}\u{200d}", &["\u{3031}\u{308}\u{200d}"]),
- ("\u{3031}\u{61}\u{2060}", &["\u{3031}", "\u{61}\u{2060}"]),
- ("\u{3031}\u{308}\u{61}\u{2060}", &["\u{3031}\u{308}", "\u{61}\u{2060}"]),
- ("\u{3031}\u{61}\u{3a}", &["\u{3031}", "\u{61}", "\u{3a}"]), ("\u{3031}\u{308}\u{61}\u{3a}",
- &["\u{3031}\u{308}", "\u{61}", "\u{3a}"]), ("\u{3031}\u{61}\u{27}", &["\u{3031}", "\u{61}",
- "\u{27}"]), ("\u{3031}\u{308}\u{61}\u{27}", &["\u{3031}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{3031}\u{61}\u{27}\u{2060}", &["\u{3031}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{3031}\u{308}\u{61}\u{27}\u{2060}", &["\u{3031}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{3031}\u{61}\u{2c}", &["\u{3031}", "\u{61}", "\u{2c}"]), ("\u{3031}\u{308}\u{61}\u{2c}",
- &["\u{3031}\u{308}", "\u{61}", "\u{2c}"]), ("\u{3031}\u{31}\u{3a}", &["\u{3031}", "\u{31}",
- "\u{3a}"]), ("\u{3031}\u{308}\u{31}\u{3a}", &["\u{3031}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{3031}\u{31}\u{27}", &["\u{3031}", "\u{31}", "\u{27}"]), ("\u{3031}\u{308}\u{31}\u{27}",
- &["\u{3031}\u{308}", "\u{31}", "\u{27}"]), ("\u{3031}\u{31}\u{2c}", &["\u{3031}", "\u{31}",
- "\u{2c}"]), ("\u{3031}\u{308}\u{31}\u{2c}", &["\u{3031}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{3031}\u{31}\u{2e}\u{2060}", &["\u{3031}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{3031}\u{308}\u{31}\u{2e}\u{2060}", &["\u{3031}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{41}\u{1}", &["\u{41}", "\u{1}"]), ("\u{41}\u{308}\u{1}", &["\u{41}\u{308}", "\u{1}"]),
- ("\u{41}\u{d}", &["\u{41}", "\u{d}"]), ("\u{41}\u{308}\u{d}", &["\u{41}\u{308}", "\u{d}"]),
- ("\u{41}\u{a}", &["\u{41}", "\u{a}"]), ("\u{41}\u{308}\u{a}", &["\u{41}\u{308}", "\u{a}"]),
- ("\u{41}\u{b}", &["\u{41}", "\u{b}"]), ("\u{41}\u{308}\u{b}", &["\u{41}\u{308}", "\u{b}"]),
- ("\u{41}\u{3031}", &["\u{41}", "\u{3031}"]), ("\u{41}\u{308}\u{3031}", &["\u{41}\u{308}",
- "\u{3031}"]), ("\u{41}\u{41}", &["\u{41}\u{41}"]), ("\u{41}\u{308}\u{41}",
- &["\u{41}\u{308}\u{41}"]), ("\u{41}\u{3a}", &["\u{41}", "\u{3a}"]), ("\u{41}\u{308}\u{3a}",
- &["\u{41}\u{308}", "\u{3a}"]), ("\u{41}\u{2c}", &["\u{41}", "\u{2c}"]),
- ("\u{41}\u{308}\u{2c}", &["\u{41}\u{308}", "\u{2c}"]), ("\u{41}\u{2e}", &["\u{41}",
- "\u{2e}"]), ("\u{41}\u{308}\u{2e}", &["\u{41}\u{308}", "\u{2e}"]), ("\u{41}\u{30}",
- &["\u{41}\u{30}"]), ("\u{41}\u{308}\u{30}", &["\u{41}\u{308}\u{30}"]), ("\u{41}\u{5f}",
- &["\u{41}\u{5f}"]), ("\u{41}\u{308}\u{5f}", &["\u{41}\u{308}\u{5f}"]), ("\u{41}\u{1f1e6}",
- &["\u{41}", "\u{1f1e6}"]), ("\u{41}\u{308}\u{1f1e6}", &["\u{41}\u{308}", "\u{1f1e6}"]),
- ("\u{41}\u{5d0}", &["\u{41}\u{5d0}"]), ("\u{41}\u{308}\u{5d0}", &["\u{41}\u{308}\u{5d0}"]),
- ("\u{41}\u{22}", &["\u{41}", "\u{22}"]), ("\u{41}\u{308}\u{22}", &["\u{41}\u{308}",
- "\u{22}"]), ("\u{41}\u{27}", &["\u{41}", "\u{27}"]), ("\u{41}\u{308}\u{27}",
- &["\u{41}\u{308}", "\u{27}"]), ("\u{41}\u{231a}", &["\u{41}", "\u{231a}"]),
- ("\u{41}\u{308}\u{231a}", &["\u{41}\u{308}", "\u{231a}"]), ("\u{41}\u{20}", &["\u{41}",
- "\u{20}"]), ("\u{41}\u{308}\u{20}", &["\u{41}\u{308}", "\u{20}"]), ("\u{41}\u{ad}",
- &["\u{41}\u{ad}"]), ("\u{41}\u{308}\u{ad}", &["\u{41}\u{308}\u{ad}"]), ("\u{41}\u{300}",
- &["\u{41}\u{300}"]), ("\u{41}\u{308}\u{300}", &["\u{41}\u{308}\u{300}"]), ("\u{41}\u{200d}",
- &["\u{41}\u{200d}"]), ("\u{41}\u{308}\u{200d}", &["\u{41}\u{308}\u{200d}"]),
- ("\u{41}\u{61}\u{2060}", &["\u{41}\u{61}\u{2060}"]), ("\u{41}\u{308}\u{61}\u{2060}",
- &["\u{41}\u{308}\u{61}\u{2060}"]), ("\u{41}\u{61}\u{3a}", &["\u{41}\u{61}", "\u{3a}"]),
- ("\u{41}\u{308}\u{61}\u{3a}", &["\u{41}\u{308}\u{61}", "\u{3a}"]), ("\u{41}\u{61}\u{27}",
- &["\u{41}\u{61}", "\u{27}"]), ("\u{41}\u{308}\u{61}\u{27}", &["\u{41}\u{308}\u{61}",
- "\u{27}"]), ("\u{41}\u{61}\u{27}\u{2060}", &["\u{41}\u{61}", "\u{27}\u{2060}"]),
- ("\u{41}\u{308}\u{61}\u{27}\u{2060}", &["\u{41}\u{308}\u{61}", "\u{27}\u{2060}"]),
- ("\u{41}\u{61}\u{2c}", &["\u{41}\u{61}", "\u{2c}"]), ("\u{41}\u{308}\u{61}\u{2c}",
- &["\u{41}\u{308}\u{61}", "\u{2c}"]), ("\u{41}\u{31}\u{3a}", &["\u{41}\u{31}", "\u{3a}"]),
- ("\u{41}\u{308}\u{31}\u{3a}", &["\u{41}\u{308}\u{31}", "\u{3a}"]), ("\u{41}\u{31}\u{27}",
- &["\u{41}\u{31}", "\u{27}"]), ("\u{41}\u{308}\u{31}\u{27}", &["\u{41}\u{308}\u{31}",
- "\u{27}"]), ("\u{41}\u{31}\u{2c}", &["\u{41}\u{31}", "\u{2c}"]),
- ("\u{41}\u{308}\u{31}\u{2c}", &["\u{41}\u{308}\u{31}", "\u{2c}"]),
- ("\u{41}\u{31}\u{2e}\u{2060}", &["\u{41}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{41}\u{308}\u{31}\u{2e}\u{2060}", &["\u{41}\u{308}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{3a}\u{1}", &["\u{3a}", "\u{1}"]), ("\u{3a}\u{308}\u{1}", &["\u{3a}\u{308}", "\u{1}"]),
- ("\u{3a}\u{d}", &["\u{3a}", "\u{d}"]), ("\u{3a}\u{308}\u{d}", &["\u{3a}\u{308}", "\u{d}"]),
- ("\u{3a}\u{a}", &["\u{3a}", "\u{a}"]), ("\u{3a}\u{308}\u{a}", &["\u{3a}\u{308}", "\u{a}"]),
- ("\u{3a}\u{b}", &["\u{3a}", "\u{b}"]), ("\u{3a}\u{308}\u{b}", &["\u{3a}\u{308}", "\u{b}"]),
- ("\u{3a}\u{3031}", &["\u{3a}", "\u{3031}"]), ("\u{3a}\u{308}\u{3031}", &["\u{3a}\u{308}",
- "\u{3031}"]), ("\u{3a}\u{41}", &["\u{3a}", "\u{41}"]), ("\u{3a}\u{308}\u{41}",
- &["\u{3a}\u{308}", "\u{41}"]), ("\u{3a}\u{3a}", &["\u{3a}", "\u{3a}"]),
- ("\u{3a}\u{308}\u{3a}", &["\u{3a}\u{308}", "\u{3a}"]), ("\u{3a}\u{2c}", &["\u{3a}",
- "\u{2c}"]), ("\u{3a}\u{308}\u{2c}", &["\u{3a}\u{308}", "\u{2c}"]), ("\u{3a}\u{2e}",
- &["\u{3a}", "\u{2e}"]), ("\u{3a}\u{308}\u{2e}", &["\u{3a}\u{308}", "\u{2e}"]),
- ("\u{3a}\u{30}", &["\u{3a}", "\u{30}"]), ("\u{3a}\u{308}\u{30}", &["\u{3a}\u{308}",
- "\u{30}"]), ("\u{3a}\u{5f}", &["\u{3a}", "\u{5f}"]), ("\u{3a}\u{308}\u{5f}",
- &["\u{3a}\u{308}", "\u{5f}"]), ("\u{3a}\u{1f1e6}", &["\u{3a}", "\u{1f1e6}"]),
- ("\u{3a}\u{308}\u{1f1e6}", &["\u{3a}\u{308}", "\u{1f1e6}"]), ("\u{3a}\u{5d0}", &["\u{3a}",
- "\u{5d0}"]), ("\u{3a}\u{308}\u{5d0}", &["\u{3a}\u{308}", "\u{5d0}"]), ("\u{3a}\u{22}",
- &["\u{3a}", "\u{22}"]), ("\u{3a}\u{308}\u{22}", &["\u{3a}\u{308}", "\u{22}"]),
- ("\u{3a}\u{27}", &["\u{3a}", "\u{27}"]), ("\u{3a}\u{308}\u{27}", &["\u{3a}\u{308}",
- "\u{27}"]), ("\u{3a}\u{231a}", &["\u{3a}", "\u{231a}"]), ("\u{3a}\u{308}\u{231a}",
- &["\u{3a}\u{308}", "\u{231a}"]), ("\u{3a}\u{20}", &["\u{3a}", "\u{20}"]),
- ("\u{3a}\u{308}\u{20}", &["\u{3a}\u{308}", "\u{20}"]), ("\u{3a}\u{ad}", &["\u{3a}\u{ad}"]),
- ("\u{3a}\u{308}\u{ad}", &["\u{3a}\u{308}\u{ad}"]), ("\u{3a}\u{300}", &["\u{3a}\u{300}"]),
- ("\u{3a}\u{308}\u{300}", &["\u{3a}\u{308}\u{300}"]), ("\u{3a}\u{200d}",
- &["\u{3a}\u{200d}"]), ("\u{3a}\u{308}\u{200d}", &["\u{3a}\u{308}\u{200d}"]),
- ("\u{3a}\u{61}\u{2060}", &["\u{3a}", "\u{61}\u{2060}"]), ("\u{3a}\u{308}\u{61}\u{2060}",
- &["\u{3a}\u{308}", "\u{61}\u{2060}"]), ("\u{3a}\u{61}\u{3a}", &["\u{3a}", "\u{61}",
- "\u{3a}"]), ("\u{3a}\u{308}\u{61}\u{3a}", &["\u{3a}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{3a}\u{61}\u{27}", &["\u{3a}", "\u{61}", "\u{27}"]), ("\u{3a}\u{308}\u{61}\u{27}",
- &["\u{3a}\u{308}", "\u{61}", "\u{27}"]), ("\u{3a}\u{61}\u{27}\u{2060}", &["\u{3a}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{3a}\u{308}\u{61}\u{27}\u{2060}", &["\u{3a}\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{3a}\u{61}\u{2c}", &["\u{3a}", "\u{61}", "\u{2c}"]),
- ("\u{3a}\u{308}\u{61}\u{2c}", &["\u{3a}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{3a}\u{31}\u{3a}", &["\u{3a}", "\u{31}", "\u{3a}"]), ("\u{3a}\u{308}\u{31}\u{3a}",
- &["\u{3a}\u{308}", "\u{31}", "\u{3a}"]), ("\u{3a}\u{31}\u{27}", &["\u{3a}", "\u{31}",
- "\u{27}"]), ("\u{3a}\u{308}\u{31}\u{27}", &["\u{3a}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{3a}\u{31}\u{2c}", &["\u{3a}", "\u{31}", "\u{2c}"]), ("\u{3a}\u{308}\u{31}\u{2c}",
- &["\u{3a}\u{308}", "\u{31}", "\u{2c}"]), ("\u{3a}\u{31}\u{2e}\u{2060}", &["\u{3a}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{3a}\u{308}\u{31}\u{2e}\u{2060}", &["\u{3a}\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{2c}\u{1}", &["\u{2c}", "\u{1}"]), ("\u{2c}\u{308}\u{1}",
- &["\u{2c}\u{308}", "\u{1}"]), ("\u{2c}\u{d}", &["\u{2c}", "\u{d}"]), ("\u{2c}\u{308}\u{d}",
- &["\u{2c}\u{308}", "\u{d}"]), ("\u{2c}\u{a}", &["\u{2c}", "\u{a}"]), ("\u{2c}\u{308}\u{a}",
- &["\u{2c}\u{308}", "\u{a}"]), ("\u{2c}\u{b}", &["\u{2c}", "\u{b}"]), ("\u{2c}\u{308}\u{b}",
- &["\u{2c}\u{308}", "\u{b}"]), ("\u{2c}\u{3031}", &["\u{2c}", "\u{3031}"]),
- ("\u{2c}\u{308}\u{3031}", &["\u{2c}\u{308}", "\u{3031}"]), ("\u{2c}\u{41}", &["\u{2c}",
- "\u{41}"]), ("\u{2c}\u{308}\u{41}", &["\u{2c}\u{308}", "\u{41}"]), ("\u{2c}\u{3a}",
- &["\u{2c}", "\u{3a}"]), ("\u{2c}\u{308}\u{3a}", &["\u{2c}\u{308}", "\u{3a}"]),
- ("\u{2c}\u{2c}", &["\u{2c}", "\u{2c}"]), ("\u{2c}\u{308}\u{2c}", &["\u{2c}\u{308}",
- "\u{2c}"]), ("\u{2c}\u{2e}", &["\u{2c}", "\u{2e}"]), ("\u{2c}\u{308}\u{2e}",
- &["\u{2c}\u{308}", "\u{2e}"]), ("\u{2c}\u{30}", &["\u{2c}", "\u{30}"]),
- ("\u{2c}\u{308}\u{30}", &["\u{2c}\u{308}", "\u{30}"]), ("\u{2c}\u{5f}", &["\u{2c}",
- "\u{5f}"]), ("\u{2c}\u{308}\u{5f}", &["\u{2c}\u{308}", "\u{5f}"]), ("\u{2c}\u{1f1e6}",
- &["\u{2c}", "\u{1f1e6}"]), ("\u{2c}\u{308}\u{1f1e6}", &["\u{2c}\u{308}", "\u{1f1e6}"]),
- ("\u{2c}\u{5d0}", &["\u{2c}", "\u{5d0}"]), ("\u{2c}\u{308}\u{5d0}", &["\u{2c}\u{308}",
- "\u{5d0}"]), ("\u{2c}\u{22}", &["\u{2c}", "\u{22}"]), ("\u{2c}\u{308}\u{22}",
- &["\u{2c}\u{308}", "\u{22}"]), ("\u{2c}\u{27}", &["\u{2c}", "\u{27}"]),
- ("\u{2c}\u{308}\u{27}", &["\u{2c}\u{308}", "\u{27}"]), ("\u{2c}\u{231a}", &["\u{2c}",
- "\u{231a}"]), ("\u{2c}\u{308}\u{231a}", &["\u{2c}\u{308}", "\u{231a}"]), ("\u{2c}\u{20}",
- &["\u{2c}", "\u{20}"]), ("\u{2c}\u{308}\u{20}", &["\u{2c}\u{308}", "\u{20}"]),
- ("\u{2c}\u{ad}", &["\u{2c}\u{ad}"]), ("\u{2c}\u{308}\u{ad}", &["\u{2c}\u{308}\u{ad}"]),
- ("\u{2c}\u{300}", &["\u{2c}\u{300}"]), ("\u{2c}\u{308}\u{300}", &["\u{2c}\u{308}\u{300}"]),
- ("\u{2c}\u{200d}", &["\u{2c}\u{200d}"]), ("\u{2c}\u{308}\u{200d}",
- &["\u{2c}\u{308}\u{200d}"]), ("\u{2c}\u{61}\u{2060}", &["\u{2c}", "\u{61}\u{2060}"]),
- ("\u{2c}\u{308}\u{61}\u{2060}", &["\u{2c}\u{308}", "\u{61}\u{2060}"]),
- ("\u{2c}\u{61}\u{3a}", &["\u{2c}", "\u{61}", "\u{3a}"]), ("\u{2c}\u{308}\u{61}\u{3a}",
- &["\u{2c}\u{308}", "\u{61}", "\u{3a}"]), ("\u{2c}\u{61}\u{27}", &["\u{2c}", "\u{61}",
- "\u{27}"]), ("\u{2c}\u{308}\u{61}\u{27}", &["\u{2c}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{2c}\u{61}\u{27}\u{2060}", &["\u{2c}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{2c}\u{308}\u{61}\u{27}\u{2060}", &["\u{2c}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{2c}\u{61}\u{2c}", &["\u{2c}", "\u{61}", "\u{2c}"]), ("\u{2c}\u{308}\u{61}\u{2c}",
- &["\u{2c}\u{308}", "\u{61}", "\u{2c}"]), ("\u{2c}\u{31}\u{3a}", &["\u{2c}", "\u{31}",
- "\u{3a}"]), ("\u{2c}\u{308}\u{31}\u{3a}", &["\u{2c}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{2c}\u{31}\u{27}", &["\u{2c}", "\u{31}", "\u{27}"]), ("\u{2c}\u{308}\u{31}\u{27}",
- &["\u{2c}\u{308}", "\u{31}", "\u{27}"]), ("\u{2c}\u{31}\u{2c}", &["\u{2c}", "\u{31}",
- "\u{2c}"]), ("\u{2c}\u{308}\u{31}\u{2c}", &["\u{2c}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{2c}\u{31}\u{2e}\u{2060}", &["\u{2c}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{2c}\u{308}\u{31}\u{2e}\u{2060}", &["\u{2c}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{2e}\u{1}", &["\u{2e}", "\u{1}"]), ("\u{2e}\u{308}\u{1}", &["\u{2e}\u{308}", "\u{1}"]),
- ("\u{2e}\u{d}", &["\u{2e}", "\u{d}"]), ("\u{2e}\u{308}\u{d}", &["\u{2e}\u{308}", "\u{d}"]),
- ("\u{2e}\u{a}", &["\u{2e}", "\u{a}"]), ("\u{2e}\u{308}\u{a}", &["\u{2e}\u{308}", "\u{a}"]),
- ("\u{2e}\u{b}", &["\u{2e}", "\u{b}"]), ("\u{2e}\u{308}\u{b}", &["\u{2e}\u{308}", "\u{b}"]),
- ("\u{2e}\u{3031}", &["\u{2e}", "\u{3031}"]), ("\u{2e}\u{308}\u{3031}", &["\u{2e}\u{308}",
- "\u{3031}"]), ("\u{2e}\u{41}", &["\u{2e}", "\u{41}"]), ("\u{2e}\u{308}\u{41}",
- &["\u{2e}\u{308}", "\u{41}"]), ("\u{2e}\u{3a}", &["\u{2e}", "\u{3a}"]),
- ("\u{2e}\u{308}\u{3a}", &["\u{2e}\u{308}", "\u{3a}"]), ("\u{2e}\u{2c}", &["\u{2e}",
- "\u{2c}"]), ("\u{2e}\u{308}\u{2c}", &["\u{2e}\u{308}", "\u{2c}"]), ("\u{2e}\u{2e}",
- &["\u{2e}", "\u{2e}"]), ("\u{2e}\u{308}\u{2e}", &["\u{2e}\u{308}", "\u{2e}"]),
- ("\u{2e}\u{30}", &["\u{2e}", "\u{30}"]), ("\u{2e}\u{308}\u{30}", &["\u{2e}\u{308}",
- "\u{30}"]), ("\u{2e}\u{5f}", &["\u{2e}", "\u{5f}"]), ("\u{2e}\u{308}\u{5f}",
- &["\u{2e}\u{308}", "\u{5f}"]), ("\u{2e}\u{1f1e6}", &["\u{2e}", "\u{1f1e6}"]),
- ("\u{2e}\u{308}\u{1f1e6}", &["\u{2e}\u{308}", "\u{1f1e6}"]), ("\u{2e}\u{5d0}", &["\u{2e}",
- "\u{5d0}"]), ("\u{2e}\u{308}\u{5d0}", &["\u{2e}\u{308}", "\u{5d0}"]), ("\u{2e}\u{22}",
- &["\u{2e}", "\u{22}"]), ("\u{2e}\u{308}\u{22}", &["\u{2e}\u{308}", "\u{22}"]),
- ("\u{2e}\u{27}", &["\u{2e}", "\u{27}"]), ("\u{2e}\u{308}\u{27}", &["\u{2e}\u{308}",
- "\u{27}"]), ("\u{2e}\u{231a}", &["\u{2e}", "\u{231a}"]), ("\u{2e}\u{308}\u{231a}",
- &["\u{2e}\u{308}", "\u{231a}"]), ("\u{2e}\u{20}", &["\u{2e}", "\u{20}"]),
- ("\u{2e}\u{308}\u{20}", &["\u{2e}\u{308}", "\u{20}"]), ("\u{2e}\u{ad}", &["\u{2e}\u{ad}"]),
- ("\u{2e}\u{308}\u{ad}", &["\u{2e}\u{308}\u{ad}"]), ("\u{2e}\u{300}", &["\u{2e}\u{300}"]),
- ("\u{2e}\u{308}\u{300}", &["\u{2e}\u{308}\u{300}"]), ("\u{2e}\u{200d}",
- &["\u{2e}\u{200d}"]), ("\u{2e}\u{308}\u{200d}", &["\u{2e}\u{308}\u{200d}"]),
- ("\u{2e}\u{61}\u{2060}", &["\u{2e}", "\u{61}\u{2060}"]), ("\u{2e}\u{308}\u{61}\u{2060}",
- &["\u{2e}\u{308}", "\u{61}\u{2060}"]), ("\u{2e}\u{61}\u{3a}", &["\u{2e}", "\u{61}",
- "\u{3a}"]), ("\u{2e}\u{308}\u{61}\u{3a}", &["\u{2e}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{2e}\u{61}\u{27}", &["\u{2e}", "\u{61}", "\u{27}"]), ("\u{2e}\u{308}\u{61}\u{27}",
- &["\u{2e}\u{308}", "\u{61}", "\u{27}"]), ("\u{2e}\u{61}\u{27}\u{2060}", &["\u{2e}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{2e}\u{308}\u{61}\u{27}\u{2060}", &["\u{2e}\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{2e}\u{61}\u{2c}", &["\u{2e}", "\u{61}", "\u{2c}"]),
- ("\u{2e}\u{308}\u{61}\u{2c}", &["\u{2e}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{2e}\u{31}\u{3a}", &["\u{2e}", "\u{31}", "\u{3a}"]), ("\u{2e}\u{308}\u{31}\u{3a}",
- &["\u{2e}\u{308}", "\u{31}", "\u{3a}"]), ("\u{2e}\u{31}\u{27}", &["\u{2e}", "\u{31}",
- "\u{27}"]), ("\u{2e}\u{308}\u{31}\u{27}", &["\u{2e}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{2e}\u{31}\u{2c}", &["\u{2e}", "\u{31}", "\u{2c}"]), ("\u{2e}\u{308}\u{31}\u{2c}",
- &["\u{2e}\u{308}", "\u{31}", "\u{2c}"]), ("\u{2e}\u{31}\u{2e}\u{2060}", &["\u{2e}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{2e}\u{308}\u{31}\u{2e}\u{2060}", &["\u{2e}\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{30}\u{1}", &["\u{30}", "\u{1}"]), ("\u{30}\u{308}\u{1}",
- &["\u{30}\u{308}", "\u{1}"]), ("\u{30}\u{d}", &["\u{30}", "\u{d}"]), ("\u{30}\u{308}\u{d}",
- &["\u{30}\u{308}", "\u{d}"]), ("\u{30}\u{a}", &["\u{30}", "\u{a}"]), ("\u{30}\u{308}\u{a}",
- &["\u{30}\u{308}", "\u{a}"]), ("\u{30}\u{b}", &["\u{30}", "\u{b}"]), ("\u{30}\u{308}\u{b}",
- &["\u{30}\u{308}", "\u{b}"]), ("\u{30}\u{3031}", &["\u{30}", "\u{3031}"]),
- ("\u{30}\u{308}\u{3031}", &["\u{30}\u{308}", "\u{3031}"]), ("\u{30}\u{41}",
- &["\u{30}\u{41}"]), ("\u{30}\u{308}\u{41}", &["\u{30}\u{308}\u{41}"]), ("\u{30}\u{3a}",
- &["\u{30}", "\u{3a}"]), ("\u{30}\u{308}\u{3a}", &["\u{30}\u{308}", "\u{3a}"]),
- ("\u{30}\u{2c}", &["\u{30}", "\u{2c}"]), ("\u{30}\u{308}\u{2c}", &["\u{30}\u{308}",
- "\u{2c}"]), ("\u{30}\u{2e}", &["\u{30}", "\u{2e}"]), ("\u{30}\u{308}\u{2e}",
- &["\u{30}\u{308}", "\u{2e}"]), ("\u{30}\u{30}", &["\u{30}\u{30}"]), ("\u{30}\u{308}\u{30}",
- &["\u{30}\u{308}\u{30}"]), ("\u{30}\u{5f}", &["\u{30}\u{5f}"]), ("\u{30}\u{308}\u{5f}",
- &["\u{30}\u{308}\u{5f}"]), ("\u{30}\u{1f1e6}", &["\u{30}", "\u{1f1e6}"]),
- ("\u{30}\u{308}\u{1f1e6}", &["\u{30}\u{308}", "\u{1f1e6}"]), ("\u{30}\u{5d0}",
- &["\u{30}\u{5d0}"]), ("\u{30}\u{308}\u{5d0}", &["\u{30}\u{308}\u{5d0}"]), ("\u{30}\u{22}",
- &["\u{30}", "\u{22}"]), ("\u{30}\u{308}\u{22}", &["\u{30}\u{308}", "\u{22}"]),
- ("\u{30}\u{27}", &["\u{30}", "\u{27}"]), ("\u{30}\u{308}\u{27}", &["\u{30}\u{308}",
- "\u{27}"]), ("\u{30}\u{231a}", &["\u{30}", "\u{231a}"]), ("\u{30}\u{308}\u{231a}",
- &["\u{30}\u{308}", "\u{231a}"]), ("\u{30}\u{20}", &["\u{30}", "\u{20}"]),
- ("\u{30}\u{308}\u{20}", &["\u{30}\u{308}", "\u{20}"]), ("\u{30}\u{ad}", &["\u{30}\u{ad}"]),
- ("\u{30}\u{308}\u{ad}", &["\u{30}\u{308}\u{ad}"]), ("\u{30}\u{300}", &["\u{30}\u{300}"]),
- ("\u{30}\u{308}\u{300}", &["\u{30}\u{308}\u{300}"]), ("\u{30}\u{200d}",
- &["\u{30}\u{200d}"]), ("\u{30}\u{308}\u{200d}", &["\u{30}\u{308}\u{200d}"]),
- ("\u{30}\u{61}\u{2060}", &["\u{30}\u{61}\u{2060}"]), ("\u{30}\u{308}\u{61}\u{2060}",
- &["\u{30}\u{308}\u{61}\u{2060}"]), ("\u{30}\u{61}\u{3a}", &["\u{30}\u{61}", "\u{3a}"]),
- ("\u{30}\u{308}\u{61}\u{3a}", &["\u{30}\u{308}\u{61}", "\u{3a}"]), ("\u{30}\u{61}\u{27}",
- &["\u{30}\u{61}", "\u{27}"]), ("\u{30}\u{308}\u{61}\u{27}", &["\u{30}\u{308}\u{61}",
- "\u{27}"]), ("\u{30}\u{61}\u{27}\u{2060}", &["\u{30}\u{61}", "\u{27}\u{2060}"]),
- ("\u{30}\u{308}\u{61}\u{27}\u{2060}", &["\u{30}\u{308}\u{61}", "\u{27}\u{2060}"]),
- ("\u{30}\u{61}\u{2c}", &["\u{30}\u{61}", "\u{2c}"]), ("\u{30}\u{308}\u{61}\u{2c}",
- &["\u{30}\u{308}\u{61}", "\u{2c}"]), ("\u{30}\u{31}\u{3a}", &["\u{30}\u{31}", "\u{3a}"]),
- ("\u{30}\u{308}\u{31}\u{3a}", &["\u{30}\u{308}\u{31}", "\u{3a}"]), ("\u{30}\u{31}\u{27}",
- &["\u{30}\u{31}", "\u{27}"]), ("\u{30}\u{308}\u{31}\u{27}", &["\u{30}\u{308}\u{31}",
- "\u{27}"]), ("\u{30}\u{31}\u{2c}", &["\u{30}\u{31}", "\u{2c}"]),
- ("\u{30}\u{308}\u{31}\u{2c}", &["\u{30}\u{308}\u{31}", "\u{2c}"]),
- ("\u{30}\u{31}\u{2e}\u{2060}", &["\u{30}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{30}\u{308}\u{31}\u{2e}\u{2060}", &["\u{30}\u{308}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{5f}\u{1}", &["\u{5f}", "\u{1}"]), ("\u{5f}\u{308}\u{1}", &["\u{5f}\u{308}", "\u{1}"]),
- ("\u{5f}\u{d}", &["\u{5f}", "\u{d}"]), ("\u{5f}\u{308}\u{d}", &["\u{5f}\u{308}", "\u{d}"]),
- ("\u{5f}\u{a}", &["\u{5f}", "\u{a}"]), ("\u{5f}\u{308}\u{a}", &["\u{5f}\u{308}", "\u{a}"]),
- ("\u{5f}\u{b}", &["\u{5f}", "\u{b}"]), ("\u{5f}\u{308}\u{b}", &["\u{5f}\u{308}", "\u{b}"]),
- ("\u{5f}\u{3031}", &["\u{5f}\u{3031}"]), ("\u{5f}\u{308}\u{3031}",
- &["\u{5f}\u{308}\u{3031}"]), ("\u{5f}\u{41}", &["\u{5f}\u{41}"]), ("\u{5f}\u{308}\u{41}",
- &["\u{5f}\u{308}\u{41}"]), ("\u{5f}\u{3a}", &["\u{5f}", "\u{3a}"]), ("\u{5f}\u{308}\u{3a}",
- &["\u{5f}\u{308}", "\u{3a}"]), ("\u{5f}\u{2c}", &["\u{5f}", "\u{2c}"]),
- ("\u{5f}\u{308}\u{2c}", &["\u{5f}\u{308}", "\u{2c}"]), ("\u{5f}\u{2e}", &["\u{5f}",
- "\u{2e}"]), ("\u{5f}\u{308}\u{2e}", &["\u{5f}\u{308}", "\u{2e}"]), ("\u{5f}\u{30}",
- &["\u{5f}\u{30}"]), ("\u{5f}\u{308}\u{30}", &["\u{5f}\u{308}\u{30}"]), ("\u{5f}\u{5f}",
- &["\u{5f}\u{5f}"]), ("\u{5f}\u{308}\u{5f}", &["\u{5f}\u{308}\u{5f}"]), ("\u{5f}\u{1f1e6}",
- &["\u{5f}", "\u{1f1e6}"]), ("\u{5f}\u{308}\u{1f1e6}", &["\u{5f}\u{308}", "\u{1f1e6}"]),
- ("\u{5f}\u{5d0}", &["\u{5f}\u{5d0}"]), ("\u{5f}\u{308}\u{5d0}", &["\u{5f}\u{308}\u{5d0}"]),
- ("\u{5f}\u{22}", &["\u{5f}", "\u{22}"]), ("\u{5f}\u{308}\u{22}", &["\u{5f}\u{308}",
- "\u{22}"]), ("\u{5f}\u{27}", &["\u{5f}", "\u{27}"]), ("\u{5f}\u{308}\u{27}",
- &["\u{5f}\u{308}", "\u{27}"]), ("\u{5f}\u{231a}", &["\u{5f}", "\u{231a}"]),
- ("\u{5f}\u{308}\u{231a}", &["\u{5f}\u{308}", "\u{231a}"]), ("\u{5f}\u{20}", &["\u{5f}",
- "\u{20}"]), ("\u{5f}\u{308}\u{20}", &["\u{5f}\u{308}", "\u{20}"]), ("\u{5f}\u{ad}",
- &["\u{5f}\u{ad}"]), ("\u{5f}\u{308}\u{ad}", &["\u{5f}\u{308}\u{ad}"]), ("\u{5f}\u{300}",
- &["\u{5f}\u{300}"]), ("\u{5f}\u{308}\u{300}", &["\u{5f}\u{308}\u{300}"]), ("\u{5f}\u{200d}",
- &["\u{5f}\u{200d}"]), ("\u{5f}\u{308}\u{200d}", &["\u{5f}\u{308}\u{200d}"]),
- ("\u{5f}\u{61}\u{2060}", &["\u{5f}\u{61}\u{2060}"]), ("\u{5f}\u{308}\u{61}\u{2060}",
- &["\u{5f}\u{308}\u{61}\u{2060}"]), ("\u{5f}\u{61}\u{3a}", &["\u{5f}\u{61}", "\u{3a}"]),
- ("\u{5f}\u{308}\u{61}\u{3a}", &["\u{5f}\u{308}\u{61}", "\u{3a}"]), ("\u{5f}\u{61}\u{27}",
- &["\u{5f}\u{61}", "\u{27}"]), ("\u{5f}\u{308}\u{61}\u{27}", &["\u{5f}\u{308}\u{61}",
- "\u{27}"]), ("\u{5f}\u{61}\u{27}\u{2060}", &["\u{5f}\u{61}", "\u{27}\u{2060}"]),
- ("\u{5f}\u{308}\u{61}\u{27}\u{2060}", &["\u{5f}\u{308}\u{61}", "\u{27}\u{2060}"]),
- ("\u{5f}\u{61}\u{2c}", &["\u{5f}\u{61}", "\u{2c}"]), ("\u{5f}\u{308}\u{61}\u{2c}",
- &["\u{5f}\u{308}\u{61}", "\u{2c}"]), ("\u{5f}\u{31}\u{3a}", &["\u{5f}\u{31}", "\u{3a}"]),
- ("\u{5f}\u{308}\u{31}\u{3a}", &["\u{5f}\u{308}\u{31}", "\u{3a}"]), ("\u{5f}\u{31}\u{27}",
- &["\u{5f}\u{31}", "\u{27}"]), ("\u{5f}\u{308}\u{31}\u{27}", &["\u{5f}\u{308}\u{31}",
- "\u{27}"]), ("\u{5f}\u{31}\u{2c}", &["\u{5f}\u{31}", "\u{2c}"]),
- ("\u{5f}\u{308}\u{31}\u{2c}", &["\u{5f}\u{308}\u{31}", "\u{2c}"]),
- ("\u{5f}\u{31}\u{2e}\u{2060}", &["\u{5f}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{5f}\u{308}\u{31}\u{2e}\u{2060}", &["\u{5f}\u{308}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{1f1e6}\u{1}", &["\u{1f1e6}", "\u{1}"]), ("\u{1f1e6}\u{308}\u{1}", &["\u{1f1e6}\u{308}",
- "\u{1}"]), ("\u{1f1e6}\u{d}", &["\u{1f1e6}", "\u{d}"]), ("\u{1f1e6}\u{308}\u{d}",
- &["\u{1f1e6}\u{308}", "\u{d}"]), ("\u{1f1e6}\u{a}", &["\u{1f1e6}", "\u{a}"]),
- ("\u{1f1e6}\u{308}\u{a}", &["\u{1f1e6}\u{308}", "\u{a}"]), ("\u{1f1e6}\u{b}", &["\u{1f1e6}",
- "\u{b}"]), ("\u{1f1e6}\u{308}\u{b}", &["\u{1f1e6}\u{308}", "\u{b}"]), ("\u{1f1e6}\u{3031}",
- &["\u{1f1e6}", "\u{3031}"]), ("\u{1f1e6}\u{308}\u{3031}", &["\u{1f1e6}\u{308}",
- "\u{3031}"]), ("\u{1f1e6}\u{41}", &["\u{1f1e6}", "\u{41}"]), ("\u{1f1e6}\u{308}\u{41}",
- &["\u{1f1e6}\u{308}", "\u{41}"]), ("\u{1f1e6}\u{3a}", &["\u{1f1e6}", "\u{3a}"]),
- ("\u{1f1e6}\u{308}\u{3a}", &["\u{1f1e6}\u{308}", "\u{3a}"]), ("\u{1f1e6}\u{2c}",
- &["\u{1f1e6}", "\u{2c}"]), ("\u{1f1e6}\u{308}\u{2c}", &["\u{1f1e6}\u{308}", "\u{2c}"]),
- ("\u{1f1e6}\u{2e}", &["\u{1f1e6}", "\u{2e}"]), ("\u{1f1e6}\u{308}\u{2e}",
- &["\u{1f1e6}\u{308}", "\u{2e}"]), ("\u{1f1e6}\u{30}", &["\u{1f1e6}", "\u{30}"]),
- ("\u{1f1e6}\u{308}\u{30}", &["\u{1f1e6}\u{308}", "\u{30}"]), ("\u{1f1e6}\u{5f}",
- &["\u{1f1e6}", "\u{5f}"]), ("\u{1f1e6}\u{308}\u{5f}", &["\u{1f1e6}\u{308}", "\u{5f}"]),
- ("\u{1f1e6}\u{1f1e6}", &["\u{1f1e6}\u{1f1e6}"]), ("\u{1f1e6}\u{308}\u{1f1e6}",
- &["\u{1f1e6}\u{308}\u{1f1e6}"]), ("\u{1f1e6}\u{5d0}", &["\u{1f1e6}", "\u{5d0}"]),
- ("\u{1f1e6}\u{308}\u{5d0}", &["\u{1f1e6}\u{308}", "\u{5d0}"]), ("\u{1f1e6}\u{22}",
- &["\u{1f1e6}", "\u{22}"]), ("\u{1f1e6}\u{308}\u{22}", &["\u{1f1e6}\u{308}", "\u{22}"]),
- ("\u{1f1e6}\u{27}", &["\u{1f1e6}", "\u{27}"]), ("\u{1f1e6}\u{308}\u{27}",
- &["\u{1f1e6}\u{308}", "\u{27}"]), ("\u{1f1e6}\u{231a}", &["\u{1f1e6}", "\u{231a}"]),
- ("\u{1f1e6}\u{308}\u{231a}", &["\u{1f1e6}\u{308}", "\u{231a}"]), ("\u{1f1e6}\u{20}",
- &["\u{1f1e6}", "\u{20}"]), ("\u{1f1e6}\u{308}\u{20}", &["\u{1f1e6}\u{308}", "\u{20}"]),
- ("\u{1f1e6}\u{ad}", &["\u{1f1e6}\u{ad}"]), ("\u{1f1e6}\u{308}\u{ad}",
- &["\u{1f1e6}\u{308}\u{ad}"]), ("\u{1f1e6}\u{300}", &["\u{1f1e6}\u{300}"]),
- ("\u{1f1e6}\u{308}\u{300}", &["\u{1f1e6}\u{308}\u{300}"]), ("\u{1f1e6}\u{200d}",
- &["\u{1f1e6}\u{200d}"]), ("\u{1f1e6}\u{308}\u{200d}", &["\u{1f1e6}\u{308}\u{200d}"]),
- ("\u{1f1e6}\u{61}\u{2060}", &["\u{1f1e6}", "\u{61}\u{2060}"]),
- ("\u{1f1e6}\u{308}\u{61}\u{2060}", &["\u{1f1e6}\u{308}", "\u{61}\u{2060}"]),
- ("\u{1f1e6}\u{61}\u{3a}", &["\u{1f1e6}", "\u{61}", "\u{3a}"]),
- ("\u{1f1e6}\u{308}\u{61}\u{3a}", &["\u{1f1e6}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{1f1e6}\u{61}\u{27}", &["\u{1f1e6}", "\u{61}", "\u{27}"]),
- ("\u{1f1e6}\u{308}\u{61}\u{27}", &["\u{1f1e6}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{1f1e6}\u{61}\u{27}\u{2060}", &["\u{1f1e6}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{1f1e6}\u{308}\u{61}\u{27}\u{2060}", &["\u{1f1e6}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{1f1e6}\u{61}\u{2c}", &["\u{1f1e6}", "\u{61}", "\u{2c}"]),
- ("\u{1f1e6}\u{308}\u{61}\u{2c}", &["\u{1f1e6}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{1f1e6}\u{31}\u{3a}", &["\u{1f1e6}", "\u{31}", "\u{3a}"]),
- ("\u{1f1e6}\u{308}\u{31}\u{3a}", &["\u{1f1e6}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{1f1e6}\u{31}\u{27}", &["\u{1f1e6}", "\u{31}", "\u{27}"]),
- ("\u{1f1e6}\u{308}\u{31}\u{27}", &["\u{1f1e6}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{1f1e6}\u{31}\u{2c}", &["\u{1f1e6}", "\u{31}", "\u{2c}"]),
- ("\u{1f1e6}\u{308}\u{31}\u{2c}", &["\u{1f1e6}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{1f1e6}\u{31}\u{2e}\u{2060}", &["\u{1f1e6}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{1f1e6}\u{308}\u{31}\u{2e}\u{2060}", &["\u{1f1e6}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{5d0}\u{1}", &["\u{5d0}", "\u{1}"]), ("\u{5d0}\u{308}\u{1}", &["\u{5d0}\u{308}",
- "\u{1}"]), ("\u{5d0}\u{d}", &["\u{5d0}", "\u{d}"]), ("\u{5d0}\u{308}\u{d}",
- &["\u{5d0}\u{308}", "\u{d}"]), ("\u{5d0}\u{a}", &["\u{5d0}", "\u{a}"]),
- ("\u{5d0}\u{308}\u{a}", &["\u{5d0}\u{308}", "\u{a}"]), ("\u{5d0}\u{b}", &["\u{5d0}",
- "\u{b}"]), ("\u{5d0}\u{308}\u{b}", &["\u{5d0}\u{308}", "\u{b}"]), ("\u{5d0}\u{3031}",
- &["\u{5d0}", "\u{3031}"]), ("\u{5d0}\u{308}\u{3031}", &["\u{5d0}\u{308}", "\u{3031}"]),
- ("\u{5d0}\u{41}", &["\u{5d0}\u{41}"]), ("\u{5d0}\u{308}\u{41}", &["\u{5d0}\u{308}\u{41}"]),
- ("\u{5d0}\u{3a}", &["\u{5d0}", "\u{3a}"]), ("\u{5d0}\u{308}\u{3a}", &["\u{5d0}\u{308}",
- "\u{3a}"]), ("\u{5d0}\u{2c}", &["\u{5d0}", "\u{2c}"]), ("\u{5d0}\u{308}\u{2c}",
- &["\u{5d0}\u{308}", "\u{2c}"]), ("\u{5d0}\u{2e}", &["\u{5d0}", "\u{2e}"]),
- ("\u{5d0}\u{308}\u{2e}", &["\u{5d0}\u{308}", "\u{2e}"]), ("\u{5d0}\u{30}",
- &["\u{5d0}\u{30}"]), ("\u{5d0}\u{308}\u{30}", &["\u{5d0}\u{308}\u{30}"]), ("\u{5d0}\u{5f}",
- &["\u{5d0}\u{5f}"]), ("\u{5d0}\u{308}\u{5f}", &["\u{5d0}\u{308}\u{5f}"]),
- ("\u{5d0}\u{1f1e6}", &["\u{5d0}", "\u{1f1e6}"]), ("\u{5d0}\u{308}\u{1f1e6}",
- &["\u{5d0}\u{308}", "\u{1f1e6}"]), ("\u{5d0}\u{5d0}", &["\u{5d0}\u{5d0}"]),
- ("\u{5d0}\u{308}\u{5d0}", &["\u{5d0}\u{308}\u{5d0}"]), ("\u{5d0}\u{22}", &["\u{5d0}",
- "\u{22}"]), ("\u{5d0}\u{308}\u{22}", &["\u{5d0}\u{308}", "\u{22}"]), ("\u{5d0}\u{27}",
- &["\u{5d0}\u{27}"]), ("\u{5d0}\u{308}\u{27}", &["\u{5d0}\u{308}\u{27}"]),
- ("\u{5d0}\u{231a}", &["\u{5d0}", "\u{231a}"]), ("\u{5d0}\u{308}\u{231a}",
- &["\u{5d0}\u{308}", "\u{231a}"]), ("\u{5d0}\u{20}", &["\u{5d0}", "\u{20}"]),
- ("\u{5d0}\u{308}\u{20}", &["\u{5d0}\u{308}", "\u{20}"]), ("\u{5d0}\u{ad}",
- &["\u{5d0}\u{ad}"]), ("\u{5d0}\u{308}\u{ad}", &["\u{5d0}\u{308}\u{ad}"]), ("\u{5d0}\u{300}",
- &["\u{5d0}\u{300}"]), ("\u{5d0}\u{308}\u{300}", &["\u{5d0}\u{308}\u{300}"]),
- ("\u{5d0}\u{200d}", &["\u{5d0}\u{200d}"]), ("\u{5d0}\u{308}\u{200d}",
- &["\u{5d0}\u{308}\u{200d}"]), ("\u{5d0}\u{61}\u{2060}", &["\u{5d0}\u{61}\u{2060}"]),
- ("\u{5d0}\u{308}\u{61}\u{2060}", &["\u{5d0}\u{308}\u{61}\u{2060}"]), ("\u{5d0}\u{61}\u{3a}",
- &["\u{5d0}\u{61}", "\u{3a}"]), ("\u{5d0}\u{308}\u{61}\u{3a}", &["\u{5d0}\u{308}\u{61}",
- "\u{3a}"]), ("\u{5d0}\u{61}\u{27}", &["\u{5d0}\u{61}", "\u{27}"]),
- ("\u{5d0}\u{308}\u{61}\u{27}", &["\u{5d0}\u{308}\u{61}", "\u{27}"]),
- ("\u{5d0}\u{61}\u{27}\u{2060}", &["\u{5d0}\u{61}", "\u{27}\u{2060}"]),
- ("\u{5d0}\u{308}\u{61}\u{27}\u{2060}", &["\u{5d0}\u{308}\u{61}", "\u{27}\u{2060}"]),
- ("\u{5d0}\u{61}\u{2c}", &["\u{5d0}\u{61}", "\u{2c}"]), ("\u{5d0}\u{308}\u{61}\u{2c}",
- &["\u{5d0}\u{308}\u{61}", "\u{2c}"]), ("\u{5d0}\u{31}\u{3a}", &["\u{5d0}\u{31}", "\u{3a}"]),
- ("\u{5d0}\u{308}\u{31}\u{3a}", &["\u{5d0}\u{308}\u{31}", "\u{3a}"]), ("\u{5d0}\u{31}\u{27}",
- &["\u{5d0}\u{31}", "\u{27}"]), ("\u{5d0}\u{308}\u{31}\u{27}", &["\u{5d0}\u{308}\u{31}",
- "\u{27}"]), ("\u{5d0}\u{31}\u{2c}", &["\u{5d0}\u{31}", "\u{2c}"]),
- ("\u{5d0}\u{308}\u{31}\u{2c}", &["\u{5d0}\u{308}\u{31}", "\u{2c}"]),
- ("\u{5d0}\u{31}\u{2e}\u{2060}", &["\u{5d0}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{5d0}\u{308}\u{31}\u{2e}\u{2060}", &["\u{5d0}\u{308}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{22}\u{1}", &["\u{22}", "\u{1}"]), ("\u{22}\u{308}\u{1}", &["\u{22}\u{308}", "\u{1}"]),
- ("\u{22}\u{d}", &["\u{22}", "\u{d}"]), ("\u{22}\u{308}\u{d}", &["\u{22}\u{308}", "\u{d}"]),
- ("\u{22}\u{a}", &["\u{22}", "\u{a}"]), ("\u{22}\u{308}\u{a}", &["\u{22}\u{308}", "\u{a}"]),
- ("\u{22}\u{b}", &["\u{22}", "\u{b}"]), ("\u{22}\u{308}\u{b}", &["\u{22}\u{308}", "\u{b}"]),
- ("\u{22}\u{3031}", &["\u{22}", "\u{3031}"]), ("\u{22}\u{308}\u{3031}", &["\u{22}\u{308}",
- "\u{3031}"]), ("\u{22}\u{41}", &["\u{22}", "\u{41}"]), ("\u{22}\u{308}\u{41}",
- &["\u{22}\u{308}", "\u{41}"]), ("\u{22}\u{3a}", &["\u{22}", "\u{3a}"]),
- ("\u{22}\u{308}\u{3a}", &["\u{22}\u{308}", "\u{3a}"]), ("\u{22}\u{2c}", &["\u{22}",
- "\u{2c}"]), ("\u{22}\u{308}\u{2c}", &["\u{22}\u{308}", "\u{2c}"]), ("\u{22}\u{2e}",
- &["\u{22}", "\u{2e}"]), ("\u{22}\u{308}\u{2e}", &["\u{22}\u{308}", "\u{2e}"]),
- ("\u{22}\u{30}", &["\u{22}", "\u{30}"]), ("\u{22}\u{308}\u{30}", &["\u{22}\u{308}",
- "\u{30}"]), ("\u{22}\u{5f}", &["\u{22}", "\u{5f}"]), ("\u{22}\u{308}\u{5f}",
- &["\u{22}\u{308}", "\u{5f}"]), ("\u{22}\u{1f1e6}", &["\u{22}", "\u{1f1e6}"]),
- ("\u{22}\u{308}\u{1f1e6}", &["\u{22}\u{308}", "\u{1f1e6}"]), ("\u{22}\u{5d0}", &["\u{22}",
- "\u{5d0}"]), ("\u{22}\u{308}\u{5d0}", &["\u{22}\u{308}", "\u{5d0}"]), ("\u{22}\u{22}",
- &["\u{22}", "\u{22}"]), ("\u{22}\u{308}\u{22}", &["\u{22}\u{308}", "\u{22}"]),
- ("\u{22}\u{27}", &["\u{22}", "\u{27}"]), ("\u{22}\u{308}\u{27}", &["\u{22}\u{308}",
- "\u{27}"]), ("\u{22}\u{231a}", &["\u{22}", "\u{231a}"]), ("\u{22}\u{308}\u{231a}",
- &["\u{22}\u{308}", "\u{231a}"]), ("\u{22}\u{20}", &["\u{22}", "\u{20}"]),
- ("\u{22}\u{308}\u{20}", &["\u{22}\u{308}", "\u{20}"]), ("\u{22}\u{ad}", &["\u{22}\u{ad}"]),
- ("\u{22}\u{308}\u{ad}", &["\u{22}\u{308}\u{ad}"]), ("\u{22}\u{300}", &["\u{22}\u{300}"]),
- ("\u{22}\u{308}\u{300}", &["\u{22}\u{308}\u{300}"]), ("\u{22}\u{200d}",
- &["\u{22}\u{200d}"]), ("\u{22}\u{308}\u{200d}", &["\u{22}\u{308}\u{200d}"]),
- ("\u{22}\u{61}\u{2060}", &["\u{22}", "\u{61}\u{2060}"]), ("\u{22}\u{308}\u{61}\u{2060}",
- &["\u{22}\u{308}", "\u{61}\u{2060}"]), ("\u{22}\u{61}\u{3a}", &["\u{22}", "\u{61}",
- "\u{3a}"]), ("\u{22}\u{308}\u{61}\u{3a}", &["\u{22}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{22}\u{61}\u{27}", &["\u{22}", "\u{61}", "\u{27}"]), ("\u{22}\u{308}\u{61}\u{27}",
- &["\u{22}\u{308}", "\u{61}", "\u{27}"]), ("\u{22}\u{61}\u{27}\u{2060}", &["\u{22}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{22}\u{308}\u{61}\u{27}\u{2060}", &["\u{22}\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{22}\u{61}\u{2c}", &["\u{22}", "\u{61}", "\u{2c}"]),
- ("\u{22}\u{308}\u{61}\u{2c}", &["\u{22}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{22}\u{31}\u{3a}", &["\u{22}", "\u{31}", "\u{3a}"]), ("\u{22}\u{308}\u{31}\u{3a}",
- &["\u{22}\u{308}", "\u{31}", "\u{3a}"]), ("\u{22}\u{31}\u{27}", &["\u{22}", "\u{31}",
- "\u{27}"]), ("\u{22}\u{308}\u{31}\u{27}", &["\u{22}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{22}\u{31}\u{2c}", &["\u{22}", "\u{31}", "\u{2c}"]), ("\u{22}\u{308}\u{31}\u{2c}",
- &["\u{22}\u{308}", "\u{31}", "\u{2c}"]), ("\u{22}\u{31}\u{2e}\u{2060}", &["\u{22}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{22}\u{308}\u{31}\u{2e}\u{2060}", &["\u{22}\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{27}\u{1}", &["\u{27}", "\u{1}"]), ("\u{27}\u{308}\u{1}",
- &["\u{27}\u{308}", "\u{1}"]), ("\u{27}\u{d}", &["\u{27}", "\u{d}"]), ("\u{27}\u{308}\u{d}",
- &["\u{27}\u{308}", "\u{d}"]), ("\u{27}\u{a}", &["\u{27}", "\u{a}"]), ("\u{27}\u{308}\u{a}",
- &["\u{27}\u{308}", "\u{a}"]), ("\u{27}\u{b}", &["\u{27}", "\u{b}"]), ("\u{27}\u{308}\u{b}",
- &["\u{27}\u{308}", "\u{b}"]), ("\u{27}\u{3031}", &["\u{27}", "\u{3031}"]),
- ("\u{27}\u{308}\u{3031}", &["\u{27}\u{308}", "\u{3031}"]), ("\u{27}\u{41}", &["\u{27}",
- "\u{41}"]), ("\u{27}\u{308}\u{41}", &["\u{27}\u{308}", "\u{41}"]), ("\u{27}\u{3a}",
- &["\u{27}", "\u{3a}"]), ("\u{27}\u{308}\u{3a}", &["\u{27}\u{308}", "\u{3a}"]),
- ("\u{27}\u{2c}", &["\u{27}", "\u{2c}"]), ("\u{27}\u{308}\u{2c}", &["\u{27}\u{308}",
- "\u{2c}"]), ("\u{27}\u{2e}", &["\u{27}", "\u{2e}"]), ("\u{27}\u{308}\u{2e}",
- &["\u{27}\u{308}", "\u{2e}"]), ("\u{27}\u{30}", &["\u{27}", "\u{30}"]),
- ("\u{27}\u{308}\u{30}", &["\u{27}\u{308}", "\u{30}"]), ("\u{27}\u{5f}", &["\u{27}",
- "\u{5f}"]), ("\u{27}\u{308}\u{5f}", &["\u{27}\u{308}", "\u{5f}"]), ("\u{27}\u{1f1e6}",
- &["\u{27}", "\u{1f1e6}"]), ("\u{27}\u{308}\u{1f1e6}", &["\u{27}\u{308}", "\u{1f1e6}"]),
- ("\u{27}\u{5d0}", &["\u{27}", "\u{5d0}"]), ("\u{27}\u{308}\u{5d0}", &["\u{27}\u{308}",
- "\u{5d0}"]), ("\u{27}\u{22}", &["\u{27}", "\u{22}"]), ("\u{27}\u{308}\u{22}",
- &["\u{27}\u{308}", "\u{22}"]), ("\u{27}\u{27}", &["\u{27}", "\u{27}"]),
- ("\u{27}\u{308}\u{27}", &["\u{27}\u{308}", "\u{27}"]), ("\u{27}\u{231a}", &["\u{27}",
- "\u{231a}"]), ("\u{27}\u{308}\u{231a}", &["\u{27}\u{308}", "\u{231a}"]), ("\u{27}\u{20}",
- &["\u{27}", "\u{20}"]), ("\u{27}\u{308}\u{20}", &["\u{27}\u{308}", "\u{20}"]),
- ("\u{27}\u{ad}", &["\u{27}\u{ad}"]), ("\u{27}\u{308}\u{ad}", &["\u{27}\u{308}\u{ad}"]),
- ("\u{27}\u{300}", &["\u{27}\u{300}"]), ("\u{27}\u{308}\u{300}", &["\u{27}\u{308}\u{300}"]),
- ("\u{27}\u{200d}", &["\u{27}\u{200d}"]), ("\u{27}\u{308}\u{200d}",
- &["\u{27}\u{308}\u{200d}"]), ("\u{27}\u{61}\u{2060}", &["\u{27}", "\u{61}\u{2060}"]),
- ("\u{27}\u{308}\u{61}\u{2060}", &["\u{27}\u{308}", "\u{61}\u{2060}"]),
- ("\u{27}\u{61}\u{3a}", &["\u{27}", "\u{61}", "\u{3a}"]), ("\u{27}\u{308}\u{61}\u{3a}",
- &["\u{27}\u{308}", "\u{61}", "\u{3a}"]), ("\u{27}\u{61}\u{27}", &["\u{27}", "\u{61}",
- "\u{27}"]), ("\u{27}\u{308}\u{61}\u{27}", &["\u{27}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{27}\u{61}\u{27}\u{2060}", &["\u{27}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{27}\u{308}\u{61}\u{27}\u{2060}", &["\u{27}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{27}\u{61}\u{2c}", &["\u{27}", "\u{61}", "\u{2c}"]), ("\u{27}\u{308}\u{61}\u{2c}",
- &["\u{27}\u{308}", "\u{61}", "\u{2c}"]), ("\u{27}\u{31}\u{3a}", &["\u{27}", "\u{31}",
- "\u{3a}"]), ("\u{27}\u{308}\u{31}\u{3a}", &["\u{27}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{27}\u{31}\u{27}", &["\u{27}", "\u{31}", "\u{27}"]), ("\u{27}\u{308}\u{31}\u{27}",
- &["\u{27}\u{308}", "\u{31}", "\u{27}"]), ("\u{27}\u{31}\u{2c}", &["\u{27}", "\u{31}",
- "\u{2c}"]), ("\u{27}\u{308}\u{31}\u{2c}", &["\u{27}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{27}\u{31}\u{2e}\u{2060}", &["\u{27}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{27}\u{308}\u{31}\u{2e}\u{2060}", &["\u{27}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{231a}\u{1}", &["\u{231a}", "\u{1}"]), ("\u{231a}\u{308}\u{1}", &["\u{231a}\u{308}",
- "\u{1}"]), ("\u{231a}\u{d}", &["\u{231a}", "\u{d}"]), ("\u{231a}\u{308}\u{d}",
- &["\u{231a}\u{308}", "\u{d}"]), ("\u{231a}\u{a}", &["\u{231a}", "\u{a}"]),
- ("\u{231a}\u{308}\u{a}", &["\u{231a}\u{308}", "\u{a}"]), ("\u{231a}\u{b}", &["\u{231a}",
- "\u{b}"]), ("\u{231a}\u{308}\u{b}", &["\u{231a}\u{308}", "\u{b}"]), ("\u{231a}\u{3031}",
- &["\u{231a}", "\u{3031}"]), ("\u{231a}\u{308}\u{3031}", &["\u{231a}\u{308}", "\u{3031}"]),
- ("\u{231a}\u{41}", &["\u{231a}", "\u{41}"]), ("\u{231a}\u{308}\u{41}", &["\u{231a}\u{308}",
- "\u{41}"]), ("\u{231a}\u{3a}", &["\u{231a}", "\u{3a}"]), ("\u{231a}\u{308}\u{3a}",
- &["\u{231a}\u{308}", "\u{3a}"]), ("\u{231a}\u{2c}", &["\u{231a}", "\u{2c}"]),
- ("\u{231a}\u{308}\u{2c}", &["\u{231a}\u{308}", "\u{2c}"]), ("\u{231a}\u{2e}", &["\u{231a}",
- "\u{2e}"]), ("\u{231a}\u{308}\u{2e}", &["\u{231a}\u{308}", "\u{2e}"]), ("\u{231a}\u{30}",
- &["\u{231a}", "\u{30}"]), ("\u{231a}\u{308}\u{30}", &["\u{231a}\u{308}", "\u{30}"]),
- ("\u{231a}\u{5f}", &["\u{231a}", "\u{5f}"]), ("\u{231a}\u{308}\u{5f}", &["\u{231a}\u{308}",
- "\u{5f}"]), ("\u{231a}\u{1f1e6}", &["\u{231a}", "\u{1f1e6}"]), ("\u{231a}\u{308}\u{1f1e6}",
- &["\u{231a}\u{308}", "\u{1f1e6}"]), ("\u{231a}\u{5d0}", &["\u{231a}", "\u{5d0}"]),
- ("\u{231a}\u{308}\u{5d0}", &["\u{231a}\u{308}", "\u{5d0}"]), ("\u{231a}\u{22}",
- &["\u{231a}", "\u{22}"]), ("\u{231a}\u{308}\u{22}", &["\u{231a}\u{308}", "\u{22}"]),
- ("\u{231a}\u{27}", &["\u{231a}", "\u{27}"]), ("\u{231a}\u{308}\u{27}", &["\u{231a}\u{308}",
- "\u{27}"]), ("\u{231a}\u{231a}", &["\u{231a}", "\u{231a}"]), ("\u{231a}\u{308}\u{231a}",
- &["\u{231a}\u{308}", "\u{231a}"]), ("\u{231a}\u{20}", &["\u{231a}", "\u{20}"]),
- ("\u{231a}\u{308}\u{20}", &["\u{231a}\u{308}", "\u{20}"]), ("\u{231a}\u{ad}",
- &["\u{231a}\u{ad}"]), ("\u{231a}\u{308}\u{ad}", &["\u{231a}\u{308}\u{ad}"]),
- ("\u{231a}\u{300}", &["\u{231a}\u{300}"]), ("\u{231a}\u{308}\u{300}",
- &["\u{231a}\u{308}\u{300}"]), ("\u{231a}\u{200d}", &["\u{231a}\u{200d}"]),
- ("\u{231a}\u{308}\u{200d}", &["\u{231a}\u{308}\u{200d}"]), ("\u{231a}\u{61}\u{2060}",
- &["\u{231a}", "\u{61}\u{2060}"]), ("\u{231a}\u{308}\u{61}\u{2060}", &["\u{231a}\u{308}",
- "\u{61}\u{2060}"]), ("\u{231a}\u{61}\u{3a}", &["\u{231a}", "\u{61}", "\u{3a}"]),
- ("\u{231a}\u{308}\u{61}\u{3a}", &["\u{231a}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{231a}\u{61}\u{27}", &["\u{231a}", "\u{61}", "\u{27}"]), ("\u{231a}\u{308}\u{61}\u{27}",
- &["\u{231a}\u{308}", "\u{61}", "\u{27}"]), ("\u{231a}\u{61}\u{27}\u{2060}", &["\u{231a}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{231a}\u{308}\u{61}\u{27}\u{2060}", &["\u{231a}\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{231a}\u{61}\u{2c}", &["\u{231a}", "\u{61}", "\u{2c}"]),
- ("\u{231a}\u{308}\u{61}\u{2c}", &["\u{231a}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{231a}\u{31}\u{3a}", &["\u{231a}", "\u{31}", "\u{3a}"]), ("\u{231a}\u{308}\u{31}\u{3a}",
- &["\u{231a}\u{308}", "\u{31}", "\u{3a}"]), ("\u{231a}\u{31}\u{27}", &["\u{231a}", "\u{31}",
- "\u{27}"]), ("\u{231a}\u{308}\u{31}\u{27}", &["\u{231a}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{231a}\u{31}\u{2c}", &["\u{231a}", "\u{31}", "\u{2c}"]), ("\u{231a}\u{308}\u{31}\u{2c}",
- &["\u{231a}\u{308}", "\u{31}", "\u{2c}"]), ("\u{231a}\u{31}\u{2e}\u{2060}", &["\u{231a}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{231a}\u{308}\u{31}\u{2e}\u{2060}", &["\u{231a}\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{20}\u{1}", &["\u{20}", "\u{1}"]), ("\u{20}\u{308}\u{1}",
- &["\u{20}\u{308}", "\u{1}"]), ("\u{20}\u{d}", &["\u{20}", "\u{d}"]), ("\u{20}\u{308}\u{d}",
- &["\u{20}\u{308}", "\u{d}"]), ("\u{20}\u{a}", &["\u{20}", "\u{a}"]), ("\u{20}\u{308}\u{a}",
- &["\u{20}\u{308}", "\u{a}"]), ("\u{20}\u{b}", &["\u{20}", "\u{b}"]), ("\u{20}\u{308}\u{b}",
- &["\u{20}\u{308}", "\u{b}"]), ("\u{20}\u{3031}", &["\u{20}", "\u{3031}"]),
- ("\u{20}\u{308}\u{3031}", &["\u{20}\u{308}", "\u{3031}"]), ("\u{20}\u{41}", &["\u{20}",
- "\u{41}"]), ("\u{20}\u{308}\u{41}", &["\u{20}\u{308}", "\u{41}"]), ("\u{20}\u{3a}",
- &["\u{20}", "\u{3a}"]), ("\u{20}\u{308}\u{3a}", &["\u{20}\u{308}", "\u{3a}"]),
- ("\u{20}\u{2c}", &["\u{20}", "\u{2c}"]), ("\u{20}\u{308}\u{2c}", &["\u{20}\u{308}",
- "\u{2c}"]), ("\u{20}\u{2e}", &["\u{20}", "\u{2e}"]), ("\u{20}\u{308}\u{2e}",
- &["\u{20}\u{308}", "\u{2e}"]), ("\u{20}\u{30}", &["\u{20}", "\u{30}"]),
- ("\u{20}\u{308}\u{30}", &["\u{20}\u{308}", "\u{30}"]), ("\u{20}\u{5f}", &["\u{20}",
- "\u{5f}"]), ("\u{20}\u{308}\u{5f}", &["\u{20}\u{308}", "\u{5f}"]), ("\u{20}\u{1f1e6}",
- &["\u{20}", "\u{1f1e6}"]), ("\u{20}\u{308}\u{1f1e6}", &["\u{20}\u{308}", "\u{1f1e6}"]),
- ("\u{20}\u{5d0}", &["\u{20}", "\u{5d0}"]), ("\u{20}\u{308}\u{5d0}", &["\u{20}\u{308}",
- "\u{5d0}"]), ("\u{20}\u{22}", &["\u{20}", "\u{22}"]), ("\u{20}\u{308}\u{22}",
- &["\u{20}\u{308}", "\u{22}"]), ("\u{20}\u{27}", &["\u{20}", "\u{27}"]),
- ("\u{20}\u{308}\u{27}", &["\u{20}\u{308}", "\u{27}"]), ("\u{20}\u{231a}", &["\u{20}",
- "\u{231a}"]), ("\u{20}\u{308}\u{231a}", &["\u{20}\u{308}", "\u{231a}"]), ("\u{20}\u{20}",
- &["\u{20}\u{20}"]), ("\u{20}\u{308}\u{20}", &["\u{20}\u{308}", "\u{20}"]), ("\u{20}\u{ad}",
- &["\u{20}\u{ad}"]), ("\u{20}\u{308}\u{ad}", &["\u{20}\u{308}\u{ad}"]), ("\u{20}\u{300}",
- &["\u{20}\u{300}"]), ("\u{20}\u{308}\u{300}", &["\u{20}\u{308}\u{300}"]), ("\u{20}\u{200d}",
- &["\u{20}\u{200d}"]), ("\u{20}\u{308}\u{200d}", &["\u{20}\u{308}\u{200d}"]),
- ("\u{20}\u{61}\u{2060}", &["\u{20}", "\u{61}\u{2060}"]), ("\u{20}\u{308}\u{61}\u{2060}",
- &["\u{20}\u{308}", "\u{61}\u{2060}"]), ("\u{20}\u{61}\u{3a}", &["\u{20}", "\u{61}",
- "\u{3a}"]), ("\u{20}\u{308}\u{61}\u{3a}", &["\u{20}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{20}\u{61}\u{27}", &["\u{20}", "\u{61}", "\u{27}"]), ("\u{20}\u{308}\u{61}\u{27}",
- &["\u{20}\u{308}", "\u{61}", "\u{27}"]), ("\u{20}\u{61}\u{27}\u{2060}", &["\u{20}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{20}\u{308}\u{61}\u{27}\u{2060}", &["\u{20}\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{20}\u{61}\u{2c}", &["\u{20}", "\u{61}", "\u{2c}"]),
- ("\u{20}\u{308}\u{61}\u{2c}", &["\u{20}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{20}\u{31}\u{3a}", &["\u{20}", "\u{31}", "\u{3a}"]), ("\u{20}\u{308}\u{31}\u{3a}",
- &["\u{20}\u{308}", "\u{31}", "\u{3a}"]), ("\u{20}\u{31}\u{27}", &["\u{20}", "\u{31}",
- "\u{27}"]), ("\u{20}\u{308}\u{31}\u{27}", &["\u{20}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{20}\u{31}\u{2c}", &["\u{20}", "\u{31}", "\u{2c}"]), ("\u{20}\u{308}\u{31}\u{2c}",
- &["\u{20}\u{308}", "\u{31}", "\u{2c}"]), ("\u{20}\u{31}\u{2e}\u{2060}", &["\u{20}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{20}\u{308}\u{31}\u{2e}\u{2060}", &["\u{20}\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{ad}\u{1}", &["\u{ad}", "\u{1}"]), ("\u{ad}\u{308}\u{1}",
- &["\u{ad}\u{308}", "\u{1}"]), ("\u{ad}\u{d}", &["\u{ad}", "\u{d}"]), ("\u{ad}\u{308}\u{d}",
- &["\u{ad}\u{308}", "\u{d}"]), ("\u{ad}\u{a}", &["\u{ad}", "\u{a}"]), ("\u{ad}\u{308}\u{a}",
- &["\u{ad}\u{308}", "\u{a}"]), ("\u{ad}\u{b}", &["\u{ad}", "\u{b}"]), ("\u{ad}\u{308}\u{b}",
- &["\u{ad}\u{308}", "\u{b}"]), ("\u{ad}\u{3031}", &["\u{ad}", "\u{3031}"]),
- ("\u{ad}\u{308}\u{3031}", &["\u{ad}\u{308}", "\u{3031}"]), ("\u{ad}\u{41}", &["\u{ad}",
- "\u{41}"]), ("\u{ad}\u{308}\u{41}", &["\u{ad}\u{308}", "\u{41}"]), ("\u{ad}\u{3a}",
- &["\u{ad}", "\u{3a}"]), ("\u{ad}\u{308}\u{3a}", &["\u{ad}\u{308}", "\u{3a}"]),
- ("\u{ad}\u{2c}", &["\u{ad}", "\u{2c}"]), ("\u{ad}\u{308}\u{2c}", &["\u{ad}\u{308}",
- "\u{2c}"]), ("\u{ad}\u{2e}", &["\u{ad}", "\u{2e}"]), ("\u{ad}\u{308}\u{2e}",
- &["\u{ad}\u{308}", "\u{2e}"]), ("\u{ad}\u{30}", &["\u{ad}", "\u{30}"]),
- ("\u{ad}\u{308}\u{30}", &["\u{ad}\u{308}", "\u{30}"]), ("\u{ad}\u{5f}", &["\u{ad}",
- "\u{5f}"]), ("\u{ad}\u{308}\u{5f}", &["\u{ad}\u{308}", "\u{5f}"]), ("\u{ad}\u{1f1e6}",
- &["\u{ad}", "\u{1f1e6}"]), ("\u{ad}\u{308}\u{1f1e6}", &["\u{ad}\u{308}", "\u{1f1e6}"]),
- ("\u{ad}\u{5d0}", &["\u{ad}", "\u{5d0}"]), ("\u{ad}\u{308}\u{5d0}", &["\u{ad}\u{308}",
- "\u{5d0}"]), ("\u{ad}\u{22}", &["\u{ad}", "\u{22}"]), ("\u{ad}\u{308}\u{22}",
- &["\u{ad}\u{308}", "\u{22}"]), ("\u{ad}\u{27}", &["\u{ad}", "\u{27}"]),
- ("\u{ad}\u{308}\u{27}", &["\u{ad}\u{308}", "\u{27}"]), ("\u{ad}\u{231a}", &["\u{ad}",
- "\u{231a}"]), ("\u{ad}\u{308}\u{231a}", &["\u{ad}\u{308}", "\u{231a}"]), ("\u{ad}\u{20}",
- &["\u{ad}", "\u{20}"]), ("\u{ad}\u{308}\u{20}", &["\u{ad}\u{308}", "\u{20}"]),
- ("\u{ad}\u{ad}", &["\u{ad}\u{ad}"]), ("\u{ad}\u{308}\u{ad}", &["\u{ad}\u{308}\u{ad}"]),
- ("\u{ad}\u{300}", &["\u{ad}\u{300}"]), ("\u{ad}\u{308}\u{300}", &["\u{ad}\u{308}\u{300}"]),
- ("\u{ad}\u{200d}", &["\u{ad}\u{200d}"]), ("\u{ad}\u{308}\u{200d}",
- &["\u{ad}\u{308}\u{200d}"]), ("\u{ad}\u{61}\u{2060}", &["\u{ad}", "\u{61}\u{2060}"]),
- ("\u{ad}\u{308}\u{61}\u{2060}", &["\u{ad}\u{308}", "\u{61}\u{2060}"]),
- ("\u{ad}\u{61}\u{3a}", &["\u{ad}", "\u{61}", "\u{3a}"]), ("\u{ad}\u{308}\u{61}\u{3a}",
- &["\u{ad}\u{308}", "\u{61}", "\u{3a}"]), ("\u{ad}\u{61}\u{27}", &["\u{ad}", "\u{61}",
- "\u{27}"]), ("\u{ad}\u{308}\u{61}\u{27}", &["\u{ad}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{ad}\u{61}\u{27}\u{2060}", &["\u{ad}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{ad}\u{308}\u{61}\u{27}\u{2060}", &["\u{ad}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{ad}\u{61}\u{2c}", &["\u{ad}", "\u{61}", "\u{2c}"]), ("\u{ad}\u{308}\u{61}\u{2c}",
- &["\u{ad}\u{308}", "\u{61}", "\u{2c}"]), ("\u{ad}\u{31}\u{3a}", &["\u{ad}", "\u{31}",
- "\u{3a}"]), ("\u{ad}\u{308}\u{31}\u{3a}", &["\u{ad}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{ad}\u{31}\u{27}", &["\u{ad}", "\u{31}", "\u{27}"]), ("\u{ad}\u{308}\u{31}\u{27}",
- &["\u{ad}\u{308}", "\u{31}", "\u{27}"]), ("\u{ad}\u{31}\u{2c}", &["\u{ad}", "\u{31}",
- "\u{2c}"]), ("\u{ad}\u{308}\u{31}\u{2c}", &["\u{ad}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{ad}\u{31}\u{2e}\u{2060}", &["\u{ad}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{ad}\u{308}\u{31}\u{2e}\u{2060}", &["\u{ad}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{300}\u{1}", &["\u{300}", "\u{1}"]), ("\u{300}\u{308}\u{1}", &["\u{300}\u{308}",
- "\u{1}"]), ("\u{300}\u{d}", &["\u{300}", "\u{d}"]), ("\u{300}\u{308}\u{d}",
- &["\u{300}\u{308}", "\u{d}"]), ("\u{300}\u{a}", &["\u{300}", "\u{a}"]),
- ("\u{300}\u{308}\u{a}", &["\u{300}\u{308}", "\u{a}"]), ("\u{300}\u{b}", &["\u{300}",
- "\u{b}"]), ("\u{300}\u{308}\u{b}", &["\u{300}\u{308}", "\u{b}"]), ("\u{300}\u{3031}",
- &["\u{300}", "\u{3031}"]), ("\u{300}\u{308}\u{3031}", &["\u{300}\u{308}", "\u{3031}"]),
- ("\u{300}\u{41}", &["\u{300}", "\u{41}"]), ("\u{300}\u{308}\u{41}", &["\u{300}\u{308}",
- "\u{41}"]), ("\u{300}\u{3a}", &["\u{300}", "\u{3a}"]), ("\u{300}\u{308}\u{3a}",
- &["\u{300}\u{308}", "\u{3a}"]), ("\u{300}\u{2c}", &["\u{300}", "\u{2c}"]),
- ("\u{300}\u{308}\u{2c}", &["\u{300}\u{308}", "\u{2c}"]), ("\u{300}\u{2e}", &["\u{300}",
- "\u{2e}"]), ("\u{300}\u{308}\u{2e}", &["\u{300}\u{308}", "\u{2e}"]), ("\u{300}\u{30}",
- &["\u{300}", "\u{30}"]), ("\u{300}\u{308}\u{30}", &["\u{300}\u{308}", "\u{30}"]),
- ("\u{300}\u{5f}", &["\u{300}", "\u{5f}"]), ("\u{300}\u{308}\u{5f}", &["\u{300}\u{308}",
- "\u{5f}"]), ("\u{300}\u{1f1e6}", &["\u{300}", "\u{1f1e6}"]), ("\u{300}\u{308}\u{1f1e6}",
- &["\u{300}\u{308}", "\u{1f1e6}"]), ("\u{300}\u{5d0}", &["\u{300}", "\u{5d0}"]),
- ("\u{300}\u{308}\u{5d0}", &["\u{300}\u{308}", "\u{5d0}"]), ("\u{300}\u{22}", &["\u{300}",
- "\u{22}"]), ("\u{300}\u{308}\u{22}", &["\u{300}\u{308}", "\u{22}"]), ("\u{300}\u{27}",
- &["\u{300}", "\u{27}"]), ("\u{300}\u{308}\u{27}", &["\u{300}\u{308}", "\u{27}"]),
- ("\u{300}\u{231a}", &["\u{300}", "\u{231a}"]), ("\u{300}\u{308}\u{231a}",
- &["\u{300}\u{308}", "\u{231a}"]), ("\u{300}\u{20}", &["\u{300}", "\u{20}"]),
- ("\u{300}\u{308}\u{20}", &["\u{300}\u{308}", "\u{20}"]), ("\u{300}\u{ad}",
- &["\u{300}\u{ad}"]), ("\u{300}\u{308}\u{ad}", &["\u{300}\u{308}\u{ad}"]), ("\u{300}\u{300}",
- &["\u{300}\u{300}"]), ("\u{300}\u{308}\u{300}", &["\u{300}\u{308}\u{300}"]),
- ("\u{300}\u{200d}", &["\u{300}\u{200d}"]), ("\u{300}\u{308}\u{200d}",
- &["\u{300}\u{308}\u{200d}"]), ("\u{300}\u{61}\u{2060}", &["\u{300}", "\u{61}\u{2060}"]),
- ("\u{300}\u{308}\u{61}\u{2060}", &["\u{300}\u{308}", "\u{61}\u{2060}"]),
- ("\u{300}\u{61}\u{3a}", &["\u{300}", "\u{61}", "\u{3a}"]), ("\u{300}\u{308}\u{61}\u{3a}",
- &["\u{300}\u{308}", "\u{61}", "\u{3a}"]), ("\u{300}\u{61}\u{27}", &["\u{300}", "\u{61}",
- "\u{27}"]), ("\u{300}\u{308}\u{61}\u{27}", &["\u{300}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{300}\u{61}\u{27}\u{2060}", &["\u{300}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{300}\u{308}\u{61}\u{27}\u{2060}", &["\u{300}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{300}\u{61}\u{2c}", &["\u{300}", "\u{61}", "\u{2c}"]), ("\u{300}\u{308}\u{61}\u{2c}",
- &["\u{300}\u{308}", "\u{61}", "\u{2c}"]), ("\u{300}\u{31}\u{3a}", &["\u{300}", "\u{31}",
- "\u{3a}"]), ("\u{300}\u{308}\u{31}\u{3a}", &["\u{300}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{300}\u{31}\u{27}", &["\u{300}", "\u{31}", "\u{27}"]), ("\u{300}\u{308}\u{31}\u{27}",
- &["\u{300}\u{308}", "\u{31}", "\u{27}"]), ("\u{300}\u{31}\u{2c}", &["\u{300}", "\u{31}",
- "\u{2c}"]), ("\u{300}\u{308}\u{31}\u{2c}", &["\u{300}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{300}\u{31}\u{2e}\u{2060}", &["\u{300}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{300}\u{308}\u{31}\u{2e}\u{2060}", &["\u{300}\u{308}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{200d}\u{1}", &["\u{200d}", "\u{1}"]), ("\u{200d}\u{308}\u{1}", &["\u{200d}\u{308}",
- "\u{1}"]), ("\u{200d}\u{d}", &["\u{200d}", "\u{d}"]), ("\u{200d}\u{308}\u{d}",
- &["\u{200d}\u{308}", "\u{d}"]), ("\u{200d}\u{a}", &["\u{200d}", "\u{a}"]),
- ("\u{200d}\u{308}\u{a}", &["\u{200d}\u{308}", "\u{a}"]), ("\u{200d}\u{b}", &["\u{200d}",
- "\u{b}"]), ("\u{200d}\u{308}\u{b}", &["\u{200d}\u{308}", "\u{b}"]), ("\u{200d}\u{3031}",
- &["\u{200d}", "\u{3031}"]), ("\u{200d}\u{308}\u{3031}", &["\u{200d}\u{308}", "\u{3031}"]),
- ("\u{200d}\u{41}", &["\u{200d}", "\u{41}"]), ("\u{200d}\u{308}\u{41}", &["\u{200d}\u{308}",
- "\u{41}"]), ("\u{200d}\u{3a}", &["\u{200d}", "\u{3a}"]), ("\u{200d}\u{308}\u{3a}",
- &["\u{200d}\u{308}", "\u{3a}"]), ("\u{200d}\u{2c}", &["\u{200d}", "\u{2c}"]),
- ("\u{200d}\u{308}\u{2c}", &["\u{200d}\u{308}", "\u{2c}"]), ("\u{200d}\u{2e}", &["\u{200d}",
- "\u{2e}"]), ("\u{200d}\u{308}\u{2e}", &["\u{200d}\u{308}", "\u{2e}"]), ("\u{200d}\u{30}",
- &["\u{200d}", "\u{30}"]), ("\u{200d}\u{308}\u{30}", &["\u{200d}\u{308}", "\u{30}"]),
- ("\u{200d}\u{5f}", &["\u{200d}", "\u{5f}"]), ("\u{200d}\u{308}\u{5f}", &["\u{200d}\u{308}",
- "\u{5f}"]), ("\u{200d}\u{1f1e6}", &["\u{200d}", "\u{1f1e6}"]), ("\u{200d}\u{308}\u{1f1e6}",
- &["\u{200d}\u{308}", "\u{1f1e6}"]), ("\u{200d}\u{5d0}", &["\u{200d}", "\u{5d0}"]),
- ("\u{200d}\u{308}\u{5d0}", &["\u{200d}\u{308}", "\u{5d0}"]), ("\u{200d}\u{22}",
- &["\u{200d}", "\u{22}"]), ("\u{200d}\u{308}\u{22}", &["\u{200d}\u{308}", "\u{22}"]),
- ("\u{200d}\u{27}", &["\u{200d}", "\u{27}"]), ("\u{200d}\u{308}\u{27}", &["\u{200d}\u{308}",
- "\u{27}"]), ("\u{200d}\u{231a}", &["\u{200d}\u{231a}"]), ("\u{200d}\u{308}\u{231a}",
- &["\u{200d}\u{308}", "\u{231a}"]), ("\u{200d}\u{20}", &["\u{200d}", "\u{20}"]),
- ("\u{200d}\u{308}\u{20}", &["\u{200d}\u{308}", "\u{20}"]), ("\u{200d}\u{ad}",
- &["\u{200d}\u{ad}"]), ("\u{200d}\u{308}\u{ad}", &["\u{200d}\u{308}\u{ad}"]),
- ("\u{200d}\u{300}", &["\u{200d}\u{300}"]), ("\u{200d}\u{308}\u{300}",
- &["\u{200d}\u{308}\u{300}"]), ("\u{200d}\u{200d}", &["\u{200d}\u{200d}"]),
- ("\u{200d}\u{308}\u{200d}", &["\u{200d}\u{308}\u{200d}"]), ("\u{200d}\u{61}\u{2060}",
- &["\u{200d}", "\u{61}\u{2060}"]), ("\u{200d}\u{308}\u{61}\u{2060}", &["\u{200d}\u{308}",
- "\u{61}\u{2060}"]), ("\u{200d}\u{61}\u{3a}", &["\u{200d}", "\u{61}", "\u{3a}"]),
- ("\u{200d}\u{308}\u{61}\u{3a}", &["\u{200d}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{200d}\u{61}\u{27}", &["\u{200d}", "\u{61}", "\u{27}"]), ("\u{200d}\u{308}\u{61}\u{27}",
- &["\u{200d}\u{308}", "\u{61}", "\u{27}"]), ("\u{200d}\u{61}\u{27}\u{2060}", &["\u{200d}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{200d}\u{308}\u{61}\u{27}\u{2060}", &["\u{200d}\u{308}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{200d}\u{61}\u{2c}", &["\u{200d}", "\u{61}", "\u{2c}"]),
- ("\u{200d}\u{308}\u{61}\u{2c}", &["\u{200d}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{200d}\u{31}\u{3a}", &["\u{200d}", "\u{31}", "\u{3a}"]), ("\u{200d}\u{308}\u{31}\u{3a}",
- &["\u{200d}\u{308}", "\u{31}", "\u{3a}"]), ("\u{200d}\u{31}\u{27}", &["\u{200d}", "\u{31}",
- "\u{27}"]), ("\u{200d}\u{308}\u{31}\u{27}", &["\u{200d}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{200d}\u{31}\u{2c}", &["\u{200d}", "\u{31}", "\u{2c}"]), ("\u{200d}\u{308}\u{31}\u{2c}",
- &["\u{200d}\u{308}", "\u{31}", "\u{2c}"]), ("\u{200d}\u{31}\u{2e}\u{2060}", &["\u{200d}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{200d}\u{308}\u{31}\u{2e}\u{2060}", &["\u{200d}\u{308}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{61}\u{2060}\u{1}", &["\u{61}\u{2060}", "\u{1}"]),
- ("\u{61}\u{2060}\u{308}\u{1}", &["\u{61}\u{2060}\u{308}", "\u{1}"]), ("\u{61}\u{2060}\u{d}",
- &["\u{61}\u{2060}", "\u{d}"]), ("\u{61}\u{2060}\u{308}\u{d}", &["\u{61}\u{2060}\u{308}",
- "\u{d}"]), ("\u{61}\u{2060}\u{a}", &["\u{61}\u{2060}", "\u{a}"]),
- ("\u{61}\u{2060}\u{308}\u{a}", &["\u{61}\u{2060}\u{308}", "\u{a}"]), ("\u{61}\u{2060}\u{b}",
- &["\u{61}\u{2060}", "\u{b}"]), ("\u{61}\u{2060}\u{308}\u{b}", &["\u{61}\u{2060}\u{308}",
- "\u{b}"]), ("\u{61}\u{2060}\u{3031}", &["\u{61}\u{2060}", "\u{3031}"]),
- ("\u{61}\u{2060}\u{308}\u{3031}", &["\u{61}\u{2060}\u{308}", "\u{3031}"]),
- ("\u{61}\u{2060}\u{41}", &["\u{61}\u{2060}\u{41}"]), ("\u{61}\u{2060}\u{308}\u{41}",
- &["\u{61}\u{2060}\u{308}\u{41}"]), ("\u{61}\u{2060}\u{3a}", &["\u{61}\u{2060}", "\u{3a}"]),
- ("\u{61}\u{2060}\u{308}\u{3a}", &["\u{61}\u{2060}\u{308}", "\u{3a}"]),
- ("\u{61}\u{2060}\u{2c}", &["\u{61}\u{2060}", "\u{2c}"]), ("\u{61}\u{2060}\u{308}\u{2c}",
- &["\u{61}\u{2060}\u{308}", "\u{2c}"]), ("\u{61}\u{2060}\u{2e}", &["\u{61}\u{2060}",
- "\u{2e}"]), ("\u{61}\u{2060}\u{308}\u{2e}", &["\u{61}\u{2060}\u{308}", "\u{2e}"]),
- ("\u{61}\u{2060}\u{30}", &["\u{61}\u{2060}\u{30}"]), ("\u{61}\u{2060}\u{308}\u{30}",
- &["\u{61}\u{2060}\u{308}\u{30}"]), ("\u{61}\u{2060}\u{5f}", &["\u{61}\u{2060}\u{5f}"]),
- ("\u{61}\u{2060}\u{308}\u{5f}", &["\u{61}\u{2060}\u{308}\u{5f}"]),
- ("\u{61}\u{2060}\u{1f1e6}", &["\u{61}\u{2060}", "\u{1f1e6}"]),
- ("\u{61}\u{2060}\u{308}\u{1f1e6}", &["\u{61}\u{2060}\u{308}", "\u{1f1e6}"]),
- ("\u{61}\u{2060}\u{5d0}", &["\u{61}\u{2060}\u{5d0}"]), ("\u{61}\u{2060}\u{308}\u{5d0}",
- &["\u{61}\u{2060}\u{308}\u{5d0}"]), ("\u{61}\u{2060}\u{22}", &["\u{61}\u{2060}", "\u{22}"]),
- ("\u{61}\u{2060}\u{308}\u{22}", &["\u{61}\u{2060}\u{308}", "\u{22}"]),
- ("\u{61}\u{2060}\u{27}", &["\u{61}\u{2060}", "\u{27}"]), ("\u{61}\u{2060}\u{308}\u{27}",
- &["\u{61}\u{2060}\u{308}", "\u{27}"]), ("\u{61}\u{2060}\u{231a}", &["\u{61}\u{2060}",
- "\u{231a}"]), ("\u{61}\u{2060}\u{308}\u{231a}", &["\u{61}\u{2060}\u{308}", "\u{231a}"]),
- ("\u{61}\u{2060}\u{20}", &["\u{61}\u{2060}", "\u{20}"]), ("\u{61}\u{2060}\u{308}\u{20}",
- &["\u{61}\u{2060}\u{308}", "\u{20}"]), ("\u{61}\u{2060}\u{ad}", &["\u{61}\u{2060}\u{ad}"]),
- ("\u{61}\u{2060}\u{308}\u{ad}", &["\u{61}\u{2060}\u{308}\u{ad}"]), ("\u{61}\u{2060}\u{300}",
- &["\u{61}\u{2060}\u{300}"]), ("\u{61}\u{2060}\u{308}\u{300}",
- &["\u{61}\u{2060}\u{308}\u{300}"]), ("\u{61}\u{2060}\u{200d}", &["\u{61}\u{2060}\u{200d}"]),
- ("\u{61}\u{2060}\u{308}\u{200d}", &["\u{61}\u{2060}\u{308}\u{200d}"]),
- ("\u{61}\u{2060}\u{61}\u{2060}", &["\u{61}\u{2060}\u{61}\u{2060}"]),
- ("\u{61}\u{2060}\u{308}\u{61}\u{2060}", &["\u{61}\u{2060}\u{308}\u{61}\u{2060}"]),
- ("\u{61}\u{2060}\u{61}\u{3a}", &["\u{61}\u{2060}\u{61}", "\u{3a}"]),
- ("\u{61}\u{2060}\u{308}\u{61}\u{3a}", &["\u{61}\u{2060}\u{308}\u{61}", "\u{3a}"]),
- ("\u{61}\u{2060}\u{61}\u{27}", &["\u{61}\u{2060}\u{61}", "\u{27}"]),
- ("\u{61}\u{2060}\u{308}\u{61}\u{27}", &["\u{61}\u{2060}\u{308}\u{61}", "\u{27}"]),
- ("\u{61}\u{2060}\u{61}\u{27}\u{2060}", &["\u{61}\u{2060}\u{61}", "\u{27}\u{2060}"]),
- ("\u{61}\u{2060}\u{308}\u{61}\u{27}\u{2060}", &["\u{61}\u{2060}\u{308}\u{61}",
- "\u{27}\u{2060}"]), ("\u{61}\u{2060}\u{61}\u{2c}", &["\u{61}\u{2060}\u{61}", "\u{2c}"]),
- ("\u{61}\u{2060}\u{308}\u{61}\u{2c}", &["\u{61}\u{2060}\u{308}\u{61}", "\u{2c}"]),
- ("\u{61}\u{2060}\u{31}\u{3a}", &["\u{61}\u{2060}\u{31}", "\u{3a}"]),
- ("\u{61}\u{2060}\u{308}\u{31}\u{3a}", &["\u{61}\u{2060}\u{308}\u{31}", "\u{3a}"]),
- ("\u{61}\u{2060}\u{31}\u{27}", &["\u{61}\u{2060}\u{31}", "\u{27}"]),
- ("\u{61}\u{2060}\u{308}\u{31}\u{27}", &["\u{61}\u{2060}\u{308}\u{31}", "\u{27}"]),
- ("\u{61}\u{2060}\u{31}\u{2c}", &["\u{61}\u{2060}\u{31}", "\u{2c}"]),
- ("\u{61}\u{2060}\u{308}\u{31}\u{2c}", &["\u{61}\u{2060}\u{308}\u{31}", "\u{2c}"]),
- ("\u{61}\u{2060}\u{31}\u{2e}\u{2060}", &["\u{61}\u{2060}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{61}\u{2060}\u{308}\u{31}\u{2e}\u{2060}", &["\u{61}\u{2060}\u{308}\u{31}",
- "\u{2e}\u{2060}"]), ("\u{61}\u{3a}\u{1}", &["\u{61}", "\u{3a}", "\u{1}"]),
- ("\u{61}\u{3a}\u{308}\u{1}", &["\u{61}", "\u{3a}\u{308}", "\u{1}"]), ("\u{61}\u{3a}\u{d}",
- &["\u{61}", "\u{3a}", "\u{d}"]), ("\u{61}\u{3a}\u{308}\u{d}", &["\u{61}", "\u{3a}\u{308}",
- "\u{d}"]), ("\u{61}\u{3a}\u{a}", &["\u{61}", "\u{3a}", "\u{a}"]),
- ("\u{61}\u{3a}\u{308}\u{a}", &["\u{61}", "\u{3a}\u{308}", "\u{a}"]), ("\u{61}\u{3a}\u{b}",
- &["\u{61}", "\u{3a}", "\u{b}"]), ("\u{61}\u{3a}\u{308}\u{b}", &["\u{61}", "\u{3a}\u{308}",
- "\u{b}"]), ("\u{61}\u{3a}\u{3031}", &["\u{61}", "\u{3a}", "\u{3031}"]),
- ("\u{61}\u{3a}\u{308}\u{3031}", &["\u{61}", "\u{3a}\u{308}", "\u{3031}"]),
- ("\u{61}\u{3a}\u{41}", &["\u{61}\u{3a}\u{41}"]), ("\u{61}\u{3a}\u{308}\u{41}",
- &["\u{61}\u{3a}\u{308}\u{41}"]), ("\u{61}\u{3a}\u{3a}", &["\u{61}", "\u{3a}", "\u{3a}"]),
- ("\u{61}\u{3a}\u{308}\u{3a}", &["\u{61}", "\u{3a}\u{308}", "\u{3a}"]),
- ("\u{61}\u{3a}\u{2c}", &["\u{61}", "\u{3a}", "\u{2c}"]), ("\u{61}\u{3a}\u{308}\u{2c}",
- &["\u{61}", "\u{3a}\u{308}", "\u{2c}"]), ("\u{61}\u{3a}\u{2e}", &["\u{61}", "\u{3a}",
- "\u{2e}"]), ("\u{61}\u{3a}\u{308}\u{2e}", &["\u{61}", "\u{3a}\u{308}", "\u{2e}"]),
- ("\u{61}\u{3a}\u{30}", &["\u{61}", "\u{3a}", "\u{30}"]), ("\u{61}\u{3a}\u{308}\u{30}",
- &["\u{61}", "\u{3a}\u{308}", "\u{30}"]), ("\u{61}\u{3a}\u{5f}", &["\u{61}", "\u{3a}",
- "\u{5f}"]), ("\u{61}\u{3a}\u{308}\u{5f}", &["\u{61}", "\u{3a}\u{308}", "\u{5f}"]),
- ("\u{61}\u{3a}\u{1f1e6}", &["\u{61}", "\u{3a}", "\u{1f1e6}"]),
- ("\u{61}\u{3a}\u{308}\u{1f1e6}", &["\u{61}", "\u{3a}\u{308}", "\u{1f1e6}"]),
- ("\u{61}\u{3a}\u{5d0}", &["\u{61}\u{3a}\u{5d0}"]), ("\u{61}\u{3a}\u{308}\u{5d0}",
- &["\u{61}\u{3a}\u{308}\u{5d0}"]), ("\u{61}\u{3a}\u{22}", &["\u{61}", "\u{3a}", "\u{22}"]),
- ("\u{61}\u{3a}\u{308}\u{22}", &["\u{61}", "\u{3a}\u{308}", "\u{22}"]),
- ("\u{61}\u{3a}\u{27}", &["\u{61}", "\u{3a}", "\u{27}"]), ("\u{61}\u{3a}\u{308}\u{27}",
- &["\u{61}", "\u{3a}\u{308}", "\u{27}"]), ("\u{61}\u{3a}\u{231a}", &["\u{61}", "\u{3a}",
- "\u{231a}"]), ("\u{61}\u{3a}\u{308}\u{231a}", &["\u{61}", "\u{3a}\u{308}", "\u{231a}"]),
- ("\u{61}\u{3a}\u{20}", &["\u{61}", "\u{3a}", "\u{20}"]), ("\u{61}\u{3a}\u{308}\u{20}",
- &["\u{61}", "\u{3a}\u{308}", "\u{20}"]), ("\u{61}\u{3a}\u{ad}", &["\u{61}",
- "\u{3a}\u{ad}"]), ("\u{61}\u{3a}\u{308}\u{ad}", &["\u{61}", "\u{3a}\u{308}\u{ad}"]),
- ("\u{61}\u{3a}\u{300}", &["\u{61}", "\u{3a}\u{300}"]), ("\u{61}\u{3a}\u{308}\u{300}",
- &["\u{61}", "\u{3a}\u{308}\u{300}"]), ("\u{61}\u{3a}\u{200d}", &["\u{61}",
- "\u{3a}\u{200d}"]), ("\u{61}\u{3a}\u{308}\u{200d}", &["\u{61}", "\u{3a}\u{308}\u{200d}"]),
- ("\u{61}\u{3a}\u{61}\u{2060}", &["\u{61}\u{3a}\u{61}\u{2060}"]),
- ("\u{61}\u{3a}\u{308}\u{61}\u{2060}", &["\u{61}\u{3a}\u{308}\u{61}\u{2060}"]),
- ("\u{61}\u{3a}\u{61}\u{3a}", &["\u{61}\u{3a}\u{61}", "\u{3a}"]),
- ("\u{61}\u{3a}\u{308}\u{61}\u{3a}", &["\u{61}\u{3a}\u{308}\u{61}", "\u{3a}"]),
- ("\u{61}\u{3a}\u{61}\u{27}", &["\u{61}\u{3a}\u{61}", "\u{27}"]),
- ("\u{61}\u{3a}\u{308}\u{61}\u{27}", &["\u{61}\u{3a}\u{308}\u{61}", "\u{27}"]),
- ("\u{61}\u{3a}\u{61}\u{27}\u{2060}", &["\u{61}\u{3a}\u{61}", "\u{27}\u{2060}"]),
- ("\u{61}\u{3a}\u{308}\u{61}\u{27}\u{2060}", &["\u{61}\u{3a}\u{308}\u{61}",
- "\u{27}\u{2060}"]), ("\u{61}\u{3a}\u{61}\u{2c}", &["\u{61}\u{3a}\u{61}", "\u{2c}"]),
- ("\u{61}\u{3a}\u{308}\u{61}\u{2c}", &["\u{61}\u{3a}\u{308}\u{61}", "\u{2c}"]),
- ("\u{61}\u{3a}\u{31}\u{3a}", &["\u{61}", "\u{3a}", "\u{31}", "\u{3a}"]),
- ("\u{61}\u{3a}\u{308}\u{31}\u{3a}", &["\u{61}", "\u{3a}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{61}\u{3a}\u{31}\u{27}", &["\u{61}", "\u{3a}", "\u{31}", "\u{27}"]),
- ("\u{61}\u{3a}\u{308}\u{31}\u{27}", &["\u{61}", "\u{3a}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{61}\u{3a}\u{31}\u{2c}", &["\u{61}", "\u{3a}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{3a}\u{308}\u{31}\u{2c}", &["\u{61}", "\u{3a}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{3a}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{3a}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{61}\u{3a}\u{308}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{3a}\u{308}", "\u{31}",
- "\u{2e}\u{2060}"]), ("\u{61}\u{27}\u{1}", &["\u{61}", "\u{27}", "\u{1}"]),
- ("\u{61}\u{27}\u{308}\u{1}", &["\u{61}", "\u{27}\u{308}", "\u{1}"]), ("\u{61}\u{27}\u{d}",
- &["\u{61}", "\u{27}", "\u{d}"]), ("\u{61}\u{27}\u{308}\u{d}", &["\u{61}", "\u{27}\u{308}",
- "\u{d}"]), ("\u{61}\u{27}\u{a}", &["\u{61}", "\u{27}", "\u{a}"]),
- ("\u{61}\u{27}\u{308}\u{a}", &["\u{61}", "\u{27}\u{308}", "\u{a}"]), ("\u{61}\u{27}\u{b}",
- &["\u{61}", "\u{27}", "\u{b}"]), ("\u{61}\u{27}\u{308}\u{b}", &["\u{61}", "\u{27}\u{308}",
- "\u{b}"]), ("\u{61}\u{27}\u{3031}", &["\u{61}", "\u{27}", "\u{3031}"]),
- ("\u{61}\u{27}\u{308}\u{3031}", &["\u{61}", "\u{27}\u{308}", "\u{3031}"]),
- ("\u{61}\u{27}\u{41}", &["\u{61}\u{27}\u{41}"]), ("\u{61}\u{27}\u{308}\u{41}",
- &["\u{61}\u{27}\u{308}\u{41}"]), ("\u{61}\u{27}\u{3a}", &["\u{61}", "\u{27}", "\u{3a}"]),
- ("\u{61}\u{27}\u{308}\u{3a}", &["\u{61}", "\u{27}\u{308}", "\u{3a}"]),
- ("\u{61}\u{27}\u{2c}", &["\u{61}", "\u{27}", "\u{2c}"]), ("\u{61}\u{27}\u{308}\u{2c}",
- &["\u{61}", "\u{27}\u{308}", "\u{2c}"]), ("\u{61}\u{27}\u{2e}", &["\u{61}", "\u{27}",
- "\u{2e}"]), ("\u{61}\u{27}\u{308}\u{2e}", &["\u{61}", "\u{27}\u{308}", "\u{2e}"]),
- ("\u{61}\u{27}\u{30}", &["\u{61}", "\u{27}", "\u{30}"]), ("\u{61}\u{27}\u{308}\u{30}",
- &["\u{61}", "\u{27}\u{308}", "\u{30}"]), ("\u{61}\u{27}\u{5f}", &["\u{61}", "\u{27}",
- "\u{5f}"]), ("\u{61}\u{27}\u{308}\u{5f}", &["\u{61}", "\u{27}\u{308}", "\u{5f}"]),
- ("\u{61}\u{27}\u{1f1e6}", &["\u{61}", "\u{27}", "\u{1f1e6}"]),
- ("\u{61}\u{27}\u{308}\u{1f1e6}", &["\u{61}", "\u{27}\u{308}", "\u{1f1e6}"]),
- ("\u{61}\u{27}\u{5d0}", &["\u{61}\u{27}\u{5d0}"]), ("\u{61}\u{27}\u{308}\u{5d0}",
- &["\u{61}\u{27}\u{308}\u{5d0}"]), ("\u{61}\u{27}\u{22}", &["\u{61}", "\u{27}", "\u{22}"]),
- ("\u{61}\u{27}\u{308}\u{22}", &["\u{61}", "\u{27}\u{308}", "\u{22}"]),
- ("\u{61}\u{27}\u{27}", &["\u{61}", "\u{27}", "\u{27}"]), ("\u{61}\u{27}\u{308}\u{27}",
- &["\u{61}", "\u{27}\u{308}", "\u{27}"]), ("\u{61}\u{27}\u{231a}", &["\u{61}", "\u{27}",
- "\u{231a}"]), ("\u{61}\u{27}\u{308}\u{231a}", &["\u{61}", "\u{27}\u{308}", "\u{231a}"]),
- ("\u{61}\u{27}\u{20}", &["\u{61}", "\u{27}", "\u{20}"]), ("\u{61}\u{27}\u{308}\u{20}",
- &["\u{61}", "\u{27}\u{308}", "\u{20}"]), ("\u{61}\u{27}\u{ad}", &["\u{61}",
- "\u{27}\u{ad}"]), ("\u{61}\u{27}\u{308}\u{ad}", &["\u{61}", "\u{27}\u{308}\u{ad}"]),
- ("\u{61}\u{27}\u{300}", &["\u{61}", "\u{27}\u{300}"]), ("\u{61}\u{27}\u{308}\u{300}",
- &["\u{61}", "\u{27}\u{308}\u{300}"]), ("\u{61}\u{27}\u{200d}", &["\u{61}",
- "\u{27}\u{200d}"]), ("\u{61}\u{27}\u{308}\u{200d}", &["\u{61}", "\u{27}\u{308}\u{200d}"]),
- ("\u{61}\u{27}\u{61}\u{2060}", &["\u{61}\u{27}\u{61}\u{2060}"]),
- ("\u{61}\u{27}\u{308}\u{61}\u{2060}", &["\u{61}\u{27}\u{308}\u{61}\u{2060}"]),
- ("\u{61}\u{27}\u{61}\u{3a}", &["\u{61}\u{27}\u{61}", "\u{3a}"]),
- ("\u{61}\u{27}\u{308}\u{61}\u{3a}", &["\u{61}\u{27}\u{308}\u{61}", "\u{3a}"]),
- ("\u{61}\u{27}\u{61}\u{27}", &["\u{61}\u{27}\u{61}", "\u{27}"]),
- ("\u{61}\u{27}\u{308}\u{61}\u{27}", &["\u{61}\u{27}\u{308}\u{61}", "\u{27}"]),
- ("\u{61}\u{27}\u{61}\u{27}\u{2060}", &["\u{61}\u{27}\u{61}", "\u{27}\u{2060}"]),
- ("\u{61}\u{27}\u{308}\u{61}\u{27}\u{2060}", &["\u{61}\u{27}\u{308}\u{61}",
- "\u{27}\u{2060}"]), ("\u{61}\u{27}\u{61}\u{2c}", &["\u{61}\u{27}\u{61}", "\u{2c}"]),
- ("\u{61}\u{27}\u{308}\u{61}\u{2c}", &["\u{61}\u{27}\u{308}\u{61}", "\u{2c}"]),
- ("\u{61}\u{27}\u{31}\u{3a}", &["\u{61}", "\u{27}", "\u{31}", "\u{3a}"]),
- ("\u{61}\u{27}\u{308}\u{31}\u{3a}", &["\u{61}", "\u{27}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{61}\u{27}\u{31}\u{27}", &["\u{61}", "\u{27}", "\u{31}", "\u{27}"]),
- ("\u{61}\u{27}\u{308}\u{31}\u{27}", &["\u{61}", "\u{27}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{61}\u{27}\u{31}\u{2c}", &["\u{61}", "\u{27}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{27}\u{308}\u{31}\u{2c}", &["\u{61}", "\u{27}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{27}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{27}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{61}\u{27}\u{308}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{27}\u{308}", "\u{31}",
- "\u{2e}\u{2060}"]), ("\u{61}\u{27}\u{2060}\u{1}", &["\u{61}", "\u{27}\u{2060}", "\u{1}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{1}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{1}"]),
- ("\u{61}\u{27}\u{2060}\u{d}", &["\u{61}", "\u{27}\u{2060}", "\u{d}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{d}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{d}"]),
- ("\u{61}\u{27}\u{2060}\u{a}", &["\u{61}", "\u{27}\u{2060}", "\u{a}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{a}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{a}"]),
- ("\u{61}\u{27}\u{2060}\u{b}", &["\u{61}", "\u{27}\u{2060}", "\u{b}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{b}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{b}"]),
- ("\u{61}\u{27}\u{2060}\u{3031}", &["\u{61}", "\u{27}\u{2060}", "\u{3031}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{3031}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{3031}"]),
- ("\u{61}\u{27}\u{2060}\u{41}", &["\u{61}\u{27}\u{2060}\u{41}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{41}", &["\u{61}\u{27}\u{2060}\u{308}\u{41}"]),
- ("\u{61}\u{27}\u{2060}\u{3a}", &["\u{61}", "\u{27}\u{2060}", "\u{3a}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{3a}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{3a}"]),
- ("\u{61}\u{27}\u{2060}\u{2c}", &["\u{61}", "\u{27}\u{2060}", "\u{2c}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{2c}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{2c}"]),
- ("\u{61}\u{27}\u{2060}\u{2e}", &["\u{61}", "\u{27}\u{2060}", "\u{2e}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{2e}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{2e}"]),
- ("\u{61}\u{27}\u{2060}\u{30}", &["\u{61}", "\u{27}\u{2060}", "\u{30}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{30}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{30}"]),
- ("\u{61}\u{27}\u{2060}\u{5f}", &["\u{61}", "\u{27}\u{2060}", "\u{5f}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{5f}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{5f}"]),
- ("\u{61}\u{27}\u{2060}\u{1f1e6}", &["\u{61}", "\u{27}\u{2060}", "\u{1f1e6}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{1f1e6}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{1f1e6}"]),
- ("\u{61}\u{27}\u{2060}\u{5d0}", &["\u{61}\u{27}\u{2060}\u{5d0}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{5d0}", &["\u{61}\u{27}\u{2060}\u{308}\u{5d0}"]),
- ("\u{61}\u{27}\u{2060}\u{22}", &["\u{61}", "\u{27}\u{2060}", "\u{22}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{22}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{22}"]),
- ("\u{61}\u{27}\u{2060}\u{27}", &["\u{61}", "\u{27}\u{2060}", "\u{27}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{27}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{27}"]),
- ("\u{61}\u{27}\u{2060}\u{231a}", &["\u{61}", "\u{27}\u{2060}", "\u{231a}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{231a}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{231a}"]),
- ("\u{61}\u{27}\u{2060}\u{20}", &["\u{61}", "\u{27}\u{2060}", "\u{20}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{20}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{20}"]),
- ("\u{61}\u{27}\u{2060}\u{ad}", &["\u{61}", "\u{27}\u{2060}\u{ad}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{ad}", &["\u{61}", "\u{27}\u{2060}\u{308}\u{ad}"]),
- ("\u{61}\u{27}\u{2060}\u{300}", &["\u{61}", "\u{27}\u{2060}\u{300}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{300}", &["\u{61}", "\u{27}\u{2060}\u{308}\u{300}"]),
- ("\u{61}\u{27}\u{2060}\u{200d}", &["\u{61}", "\u{27}\u{2060}\u{200d}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{200d}", &["\u{61}", "\u{27}\u{2060}\u{308}\u{200d}"]),
- ("\u{61}\u{27}\u{2060}\u{61}\u{2060}", &["\u{61}\u{27}\u{2060}\u{61}\u{2060}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{61}\u{2060}",
- &["\u{61}\u{27}\u{2060}\u{308}\u{61}\u{2060}"]), ("\u{61}\u{27}\u{2060}\u{61}\u{3a}",
- &["\u{61}\u{27}\u{2060}\u{61}", "\u{3a}"]), ("\u{61}\u{27}\u{2060}\u{308}\u{61}\u{3a}",
- &["\u{61}\u{27}\u{2060}\u{308}\u{61}", "\u{3a}"]), ("\u{61}\u{27}\u{2060}\u{61}\u{27}",
- &["\u{61}\u{27}\u{2060}\u{61}", "\u{27}"]), ("\u{61}\u{27}\u{2060}\u{308}\u{61}\u{27}",
- &["\u{61}\u{27}\u{2060}\u{308}\u{61}", "\u{27}"]),
- ("\u{61}\u{27}\u{2060}\u{61}\u{27}\u{2060}", &["\u{61}\u{27}\u{2060}\u{61}",
- "\u{27}\u{2060}"]), ("\u{61}\u{27}\u{2060}\u{308}\u{61}\u{27}\u{2060}",
- &["\u{61}\u{27}\u{2060}\u{308}\u{61}", "\u{27}\u{2060}"]),
- ("\u{61}\u{27}\u{2060}\u{61}\u{2c}", &["\u{61}\u{27}\u{2060}\u{61}", "\u{2c}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{61}\u{2c}", &["\u{61}\u{27}\u{2060}\u{308}\u{61}",
- "\u{2c}"]), ("\u{61}\u{27}\u{2060}\u{31}\u{3a}", &["\u{61}", "\u{27}\u{2060}", "\u{31}",
- "\u{3a}"]), ("\u{61}\u{27}\u{2060}\u{308}\u{31}\u{3a}", &["\u{61}", "\u{27}\u{2060}\u{308}",
- "\u{31}", "\u{3a}"]), ("\u{61}\u{27}\u{2060}\u{31}\u{27}", &["\u{61}", "\u{27}\u{2060}",
- "\u{31}", "\u{27}"]), ("\u{61}\u{27}\u{2060}\u{308}\u{31}\u{27}", &["\u{61}",
- "\u{27}\u{2060}\u{308}", "\u{31}", "\u{27}"]), ("\u{61}\u{27}\u{2060}\u{31}\u{2c}",
- &["\u{61}", "\u{27}\u{2060}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{27}\u{2060}\u{308}\u{31}\u{2c}", &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{31}",
- "\u{2c}"]), ("\u{61}\u{27}\u{2060}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{27}\u{2060}",
- "\u{31}", "\u{2e}\u{2060}"]), ("\u{61}\u{27}\u{2060}\u{308}\u{31}\u{2e}\u{2060}",
- &["\u{61}", "\u{27}\u{2060}\u{308}", "\u{31}", "\u{2e}\u{2060}"]), ("\u{61}\u{2c}\u{1}",
- &["\u{61}", "\u{2c}", "\u{1}"]), ("\u{61}\u{2c}\u{308}\u{1}", &["\u{61}", "\u{2c}\u{308}",
- "\u{1}"]), ("\u{61}\u{2c}\u{d}", &["\u{61}", "\u{2c}", "\u{d}"]),
- ("\u{61}\u{2c}\u{308}\u{d}", &["\u{61}", "\u{2c}\u{308}", "\u{d}"]), ("\u{61}\u{2c}\u{a}",
- &["\u{61}", "\u{2c}", "\u{a}"]), ("\u{61}\u{2c}\u{308}\u{a}", &["\u{61}", "\u{2c}\u{308}",
- "\u{a}"]), ("\u{61}\u{2c}\u{b}", &["\u{61}", "\u{2c}", "\u{b}"]),
- ("\u{61}\u{2c}\u{308}\u{b}", &["\u{61}", "\u{2c}\u{308}", "\u{b}"]),
- ("\u{61}\u{2c}\u{3031}", &["\u{61}", "\u{2c}", "\u{3031}"]), ("\u{61}\u{2c}\u{308}\u{3031}",
- &["\u{61}", "\u{2c}\u{308}", "\u{3031}"]), ("\u{61}\u{2c}\u{41}", &["\u{61}", "\u{2c}",
- "\u{41}"]), ("\u{61}\u{2c}\u{308}\u{41}", &["\u{61}", "\u{2c}\u{308}", "\u{41}"]),
- ("\u{61}\u{2c}\u{3a}", &["\u{61}", "\u{2c}", "\u{3a}"]), ("\u{61}\u{2c}\u{308}\u{3a}",
- &["\u{61}", "\u{2c}\u{308}", "\u{3a}"]), ("\u{61}\u{2c}\u{2c}", &["\u{61}", "\u{2c}",
- "\u{2c}"]), ("\u{61}\u{2c}\u{308}\u{2c}", &["\u{61}", "\u{2c}\u{308}", "\u{2c}"]),
- ("\u{61}\u{2c}\u{2e}", &["\u{61}", "\u{2c}", "\u{2e}"]), ("\u{61}\u{2c}\u{308}\u{2e}",
- &["\u{61}", "\u{2c}\u{308}", "\u{2e}"]), ("\u{61}\u{2c}\u{30}", &["\u{61}", "\u{2c}",
- "\u{30}"]), ("\u{61}\u{2c}\u{308}\u{30}", &["\u{61}", "\u{2c}\u{308}", "\u{30}"]),
- ("\u{61}\u{2c}\u{5f}", &["\u{61}", "\u{2c}", "\u{5f}"]), ("\u{61}\u{2c}\u{308}\u{5f}",
- &["\u{61}", "\u{2c}\u{308}", "\u{5f}"]), ("\u{61}\u{2c}\u{1f1e6}", &["\u{61}", "\u{2c}",
- "\u{1f1e6}"]), ("\u{61}\u{2c}\u{308}\u{1f1e6}", &["\u{61}", "\u{2c}\u{308}", "\u{1f1e6}"]),
- ("\u{61}\u{2c}\u{5d0}", &["\u{61}", "\u{2c}", "\u{5d0}"]), ("\u{61}\u{2c}\u{308}\u{5d0}",
- &["\u{61}", "\u{2c}\u{308}", "\u{5d0}"]), ("\u{61}\u{2c}\u{22}", &["\u{61}", "\u{2c}",
- "\u{22}"]), ("\u{61}\u{2c}\u{308}\u{22}", &["\u{61}", "\u{2c}\u{308}", "\u{22}"]),
- ("\u{61}\u{2c}\u{27}", &["\u{61}", "\u{2c}", "\u{27}"]), ("\u{61}\u{2c}\u{308}\u{27}",
- &["\u{61}", "\u{2c}\u{308}", "\u{27}"]), ("\u{61}\u{2c}\u{231a}", &["\u{61}", "\u{2c}",
- "\u{231a}"]), ("\u{61}\u{2c}\u{308}\u{231a}", &["\u{61}", "\u{2c}\u{308}", "\u{231a}"]),
- ("\u{61}\u{2c}\u{20}", &["\u{61}", "\u{2c}", "\u{20}"]), ("\u{61}\u{2c}\u{308}\u{20}",
- &["\u{61}", "\u{2c}\u{308}", "\u{20}"]), ("\u{61}\u{2c}\u{ad}", &["\u{61}",
- "\u{2c}\u{ad}"]), ("\u{61}\u{2c}\u{308}\u{ad}", &["\u{61}", "\u{2c}\u{308}\u{ad}"]),
- ("\u{61}\u{2c}\u{300}", &["\u{61}", "\u{2c}\u{300}"]), ("\u{61}\u{2c}\u{308}\u{300}",
- &["\u{61}", "\u{2c}\u{308}\u{300}"]), ("\u{61}\u{2c}\u{200d}", &["\u{61}",
- "\u{2c}\u{200d}"]), ("\u{61}\u{2c}\u{308}\u{200d}", &["\u{61}", "\u{2c}\u{308}\u{200d}"]),
- ("\u{61}\u{2c}\u{61}\u{2060}", &["\u{61}", "\u{2c}", "\u{61}\u{2060}"]),
- ("\u{61}\u{2c}\u{308}\u{61}\u{2060}", &["\u{61}", "\u{2c}\u{308}", "\u{61}\u{2060}"]),
- ("\u{61}\u{2c}\u{61}\u{3a}", &["\u{61}", "\u{2c}", "\u{61}", "\u{3a}"]),
- ("\u{61}\u{2c}\u{308}\u{61}\u{3a}", &["\u{61}", "\u{2c}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{61}\u{2c}\u{61}\u{27}", &["\u{61}", "\u{2c}", "\u{61}", "\u{27}"]),
- ("\u{61}\u{2c}\u{308}\u{61}\u{27}", &["\u{61}", "\u{2c}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{61}\u{2c}\u{61}\u{27}\u{2060}", &["\u{61}", "\u{2c}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{61}\u{2c}\u{308}\u{61}\u{27}\u{2060}", &["\u{61}", "\u{2c}\u{308}", "\u{61}",
- "\u{27}\u{2060}"]), ("\u{61}\u{2c}\u{61}\u{2c}", &["\u{61}", "\u{2c}", "\u{61}", "\u{2c}"]),
- ("\u{61}\u{2c}\u{308}\u{61}\u{2c}", &["\u{61}", "\u{2c}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{61}\u{2c}\u{31}\u{3a}", &["\u{61}", "\u{2c}", "\u{31}", "\u{3a}"]),
- ("\u{61}\u{2c}\u{308}\u{31}\u{3a}", &["\u{61}", "\u{2c}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{61}\u{2c}\u{31}\u{27}", &["\u{61}", "\u{2c}", "\u{31}", "\u{27}"]),
- ("\u{61}\u{2c}\u{308}\u{31}\u{27}", &["\u{61}", "\u{2c}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{61}\u{2c}\u{31}\u{2c}", &["\u{61}", "\u{2c}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{2c}\u{308}\u{31}\u{2c}", &["\u{61}", "\u{2c}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{61}\u{2c}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{2c}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{61}\u{2c}\u{308}\u{31}\u{2e}\u{2060}", &["\u{61}", "\u{2c}\u{308}", "\u{31}",
- "\u{2e}\u{2060}"]), ("\u{31}\u{3a}\u{1}", &["\u{31}", "\u{3a}", "\u{1}"]),
- ("\u{31}\u{3a}\u{308}\u{1}", &["\u{31}", "\u{3a}\u{308}", "\u{1}"]), ("\u{31}\u{3a}\u{d}",
- &["\u{31}", "\u{3a}", "\u{d}"]), ("\u{31}\u{3a}\u{308}\u{d}", &["\u{31}", "\u{3a}\u{308}",
- "\u{d}"]), ("\u{31}\u{3a}\u{a}", &["\u{31}", "\u{3a}", "\u{a}"]),
- ("\u{31}\u{3a}\u{308}\u{a}", &["\u{31}", "\u{3a}\u{308}", "\u{a}"]), ("\u{31}\u{3a}\u{b}",
- &["\u{31}", "\u{3a}", "\u{b}"]), ("\u{31}\u{3a}\u{308}\u{b}", &["\u{31}", "\u{3a}\u{308}",
- "\u{b}"]), ("\u{31}\u{3a}\u{3031}", &["\u{31}", "\u{3a}", "\u{3031}"]),
- ("\u{31}\u{3a}\u{308}\u{3031}", &["\u{31}", "\u{3a}\u{308}", "\u{3031}"]),
- ("\u{31}\u{3a}\u{41}", &["\u{31}", "\u{3a}", "\u{41}"]), ("\u{31}\u{3a}\u{308}\u{41}",
- &["\u{31}", "\u{3a}\u{308}", "\u{41}"]), ("\u{31}\u{3a}\u{3a}", &["\u{31}", "\u{3a}",
- "\u{3a}"]), ("\u{31}\u{3a}\u{308}\u{3a}", &["\u{31}", "\u{3a}\u{308}", "\u{3a}"]),
- ("\u{31}\u{3a}\u{2c}", &["\u{31}", "\u{3a}", "\u{2c}"]), ("\u{31}\u{3a}\u{308}\u{2c}",
- &["\u{31}", "\u{3a}\u{308}", "\u{2c}"]), ("\u{31}\u{3a}\u{2e}", &["\u{31}", "\u{3a}",
- "\u{2e}"]), ("\u{31}\u{3a}\u{308}\u{2e}", &["\u{31}", "\u{3a}\u{308}", "\u{2e}"]),
- ("\u{31}\u{3a}\u{30}", &["\u{31}", "\u{3a}", "\u{30}"]), ("\u{31}\u{3a}\u{308}\u{30}",
- &["\u{31}", "\u{3a}\u{308}", "\u{30}"]), ("\u{31}\u{3a}\u{5f}", &["\u{31}", "\u{3a}",
- "\u{5f}"]), ("\u{31}\u{3a}\u{308}\u{5f}", &["\u{31}", "\u{3a}\u{308}", "\u{5f}"]),
- ("\u{31}\u{3a}\u{1f1e6}", &["\u{31}", "\u{3a}", "\u{1f1e6}"]),
- ("\u{31}\u{3a}\u{308}\u{1f1e6}", &["\u{31}", "\u{3a}\u{308}", "\u{1f1e6}"]),
- ("\u{31}\u{3a}\u{5d0}", &["\u{31}", "\u{3a}", "\u{5d0}"]), ("\u{31}\u{3a}\u{308}\u{5d0}",
- &["\u{31}", "\u{3a}\u{308}", "\u{5d0}"]), ("\u{31}\u{3a}\u{22}", &["\u{31}", "\u{3a}",
- "\u{22}"]), ("\u{31}\u{3a}\u{308}\u{22}", &["\u{31}", "\u{3a}\u{308}", "\u{22}"]),
- ("\u{31}\u{3a}\u{27}", &["\u{31}", "\u{3a}", "\u{27}"]), ("\u{31}\u{3a}\u{308}\u{27}",
- &["\u{31}", "\u{3a}\u{308}", "\u{27}"]), ("\u{31}\u{3a}\u{231a}", &["\u{31}", "\u{3a}",
- "\u{231a}"]), ("\u{31}\u{3a}\u{308}\u{231a}", &["\u{31}", "\u{3a}\u{308}", "\u{231a}"]),
- ("\u{31}\u{3a}\u{20}", &["\u{31}", "\u{3a}", "\u{20}"]), ("\u{31}\u{3a}\u{308}\u{20}",
- &["\u{31}", "\u{3a}\u{308}", "\u{20}"]), ("\u{31}\u{3a}\u{ad}", &["\u{31}",
- "\u{3a}\u{ad}"]), ("\u{31}\u{3a}\u{308}\u{ad}", &["\u{31}", "\u{3a}\u{308}\u{ad}"]),
- ("\u{31}\u{3a}\u{300}", &["\u{31}", "\u{3a}\u{300}"]), ("\u{31}\u{3a}\u{308}\u{300}",
- &["\u{31}", "\u{3a}\u{308}\u{300}"]), ("\u{31}\u{3a}\u{200d}", &["\u{31}",
- "\u{3a}\u{200d}"]), ("\u{31}\u{3a}\u{308}\u{200d}", &["\u{31}", "\u{3a}\u{308}\u{200d}"]),
- ("\u{31}\u{3a}\u{61}\u{2060}", &["\u{31}", "\u{3a}", "\u{61}\u{2060}"]),
- ("\u{31}\u{3a}\u{308}\u{61}\u{2060}", &["\u{31}", "\u{3a}\u{308}", "\u{61}\u{2060}"]),
- ("\u{31}\u{3a}\u{61}\u{3a}", &["\u{31}", "\u{3a}", "\u{61}", "\u{3a}"]),
- ("\u{31}\u{3a}\u{308}\u{61}\u{3a}", &["\u{31}", "\u{3a}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{31}\u{3a}\u{61}\u{27}", &["\u{31}", "\u{3a}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{3a}\u{308}\u{61}\u{27}", &["\u{31}", "\u{3a}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{3a}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{3a}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{31}\u{3a}\u{308}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{3a}\u{308}", "\u{61}",
- "\u{27}\u{2060}"]), ("\u{31}\u{3a}\u{61}\u{2c}", &["\u{31}", "\u{3a}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{3a}\u{308}\u{61}\u{2c}", &["\u{31}", "\u{3a}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{3a}\u{31}\u{3a}", &["\u{31}", "\u{3a}", "\u{31}", "\u{3a}"]),
- ("\u{31}\u{3a}\u{308}\u{31}\u{3a}", &["\u{31}", "\u{3a}\u{308}", "\u{31}", "\u{3a}"]),
- ("\u{31}\u{3a}\u{31}\u{27}", &["\u{31}", "\u{3a}", "\u{31}", "\u{27}"]),
- ("\u{31}\u{3a}\u{308}\u{31}\u{27}", &["\u{31}", "\u{3a}\u{308}", "\u{31}", "\u{27}"]),
- ("\u{31}\u{3a}\u{31}\u{2c}", &["\u{31}", "\u{3a}", "\u{31}", "\u{2c}"]),
- ("\u{31}\u{3a}\u{308}\u{31}\u{2c}", &["\u{31}", "\u{3a}\u{308}", "\u{31}", "\u{2c}"]),
- ("\u{31}\u{3a}\u{31}\u{2e}\u{2060}", &["\u{31}", "\u{3a}", "\u{31}", "\u{2e}\u{2060}"]),
- ("\u{31}\u{3a}\u{308}\u{31}\u{2e}\u{2060}", &["\u{31}", "\u{3a}\u{308}", "\u{31}",
- "\u{2e}\u{2060}"]), ("\u{31}\u{27}\u{1}", &["\u{31}", "\u{27}", "\u{1}"]),
- ("\u{31}\u{27}\u{308}\u{1}", &["\u{31}", "\u{27}\u{308}", "\u{1}"]), ("\u{31}\u{27}\u{d}",
- &["\u{31}", "\u{27}", "\u{d}"]), ("\u{31}\u{27}\u{308}\u{d}", &["\u{31}", "\u{27}\u{308}",
- "\u{d}"]), ("\u{31}\u{27}\u{a}", &["\u{31}", "\u{27}", "\u{a}"]),
- ("\u{31}\u{27}\u{308}\u{a}", &["\u{31}", "\u{27}\u{308}", "\u{a}"]), ("\u{31}\u{27}\u{b}",
- &["\u{31}", "\u{27}", "\u{b}"]), ("\u{31}\u{27}\u{308}\u{b}", &["\u{31}", "\u{27}\u{308}",
- "\u{b}"]), ("\u{31}\u{27}\u{3031}", &["\u{31}", "\u{27}", "\u{3031}"]),
- ("\u{31}\u{27}\u{308}\u{3031}", &["\u{31}", "\u{27}\u{308}", "\u{3031}"]),
- ("\u{31}\u{27}\u{41}", &["\u{31}", "\u{27}", "\u{41}"]), ("\u{31}\u{27}\u{308}\u{41}",
- &["\u{31}", "\u{27}\u{308}", "\u{41}"]), ("\u{31}\u{27}\u{3a}", &["\u{31}", "\u{27}",
- "\u{3a}"]), ("\u{31}\u{27}\u{308}\u{3a}", &["\u{31}", "\u{27}\u{308}", "\u{3a}"]),
- ("\u{31}\u{27}\u{2c}", &["\u{31}", "\u{27}", "\u{2c}"]), ("\u{31}\u{27}\u{308}\u{2c}",
- &["\u{31}", "\u{27}\u{308}", "\u{2c}"]), ("\u{31}\u{27}\u{2e}", &["\u{31}", "\u{27}",
- "\u{2e}"]), ("\u{31}\u{27}\u{308}\u{2e}", &["\u{31}", "\u{27}\u{308}", "\u{2e}"]),
- ("\u{31}\u{27}\u{30}", &["\u{31}\u{27}\u{30}"]), ("\u{31}\u{27}\u{308}\u{30}",
- &["\u{31}\u{27}\u{308}\u{30}"]), ("\u{31}\u{27}\u{5f}", &["\u{31}", "\u{27}", "\u{5f}"]),
- ("\u{31}\u{27}\u{308}\u{5f}", &["\u{31}", "\u{27}\u{308}", "\u{5f}"]),
- ("\u{31}\u{27}\u{1f1e6}", &["\u{31}", "\u{27}", "\u{1f1e6}"]),
- ("\u{31}\u{27}\u{308}\u{1f1e6}", &["\u{31}", "\u{27}\u{308}", "\u{1f1e6}"]),
- ("\u{31}\u{27}\u{5d0}", &["\u{31}", "\u{27}", "\u{5d0}"]), ("\u{31}\u{27}\u{308}\u{5d0}",
- &["\u{31}", "\u{27}\u{308}", "\u{5d0}"]), ("\u{31}\u{27}\u{22}", &["\u{31}", "\u{27}",
- "\u{22}"]), ("\u{31}\u{27}\u{308}\u{22}", &["\u{31}", "\u{27}\u{308}", "\u{22}"]),
- ("\u{31}\u{27}\u{27}", &["\u{31}", "\u{27}", "\u{27}"]), ("\u{31}\u{27}\u{308}\u{27}",
- &["\u{31}", "\u{27}\u{308}", "\u{27}"]), ("\u{31}\u{27}\u{231a}", &["\u{31}", "\u{27}",
- "\u{231a}"]), ("\u{31}\u{27}\u{308}\u{231a}", &["\u{31}", "\u{27}\u{308}", "\u{231a}"]),
- ("\u{31}\u{27}\u{20}", &["\u{31}", "\u{27}", "\u{20}"]), ("\u{31}\u{27}\u{308}\u{20}",
- &["\u{31}", "\u{27}\u{308}", "\u{20}"]), ("\u{31}\u{27}\u{ad}", &["\u{31}",
- "\u{27}\u{ad}"]), ("\u{31}\u{27}\u{308}\u{ad}", &["\u{31}", "\u{27}\u{308}\u{ad}"]),
- ("\u{31}\u{27}\u{300}", &["\u{31}", "\u{27}\u{300}"]), ("\u{31}\u{27}\u{308}\u{300}",
- &["\u{31}", "\u{27}\u{308}\u{300}"]), ("\u{31}\u{27}\u{200d}", &["\u{31}",
- "\u{27}\u{200d}"]), ("\u{31}\u{27}\u{308}\u{200d}", &["\u{31}", "\u{27}\u{308}\u{200d}"]),
- ("\u{31}\u{27}\u{61}\u{2060}", &["\u{31}", "\u{27}", "\u{61}\u{2060}"]),
- ("\u{31}\u{27}\u{308}\u{61}\u{2060}", &["\u{31}", "\u{27}\u{308}", "\u{61}\u{2060}"]),
- ("\u{31}\u{27}\u{61}\u{3a}", &["\u{31}", "\u{27}", "\u{61}", "\u{3a}"]),
- ("\u{31}\u{27}\u{308}\u{61}\u{3a}", &["\u{31}", "\u{27}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{31}\u{27}\u{61}\u{27}", &["\u{31}", "\u{27}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{27}\u{308}\u{61}\u{27}", &["\u{31}", "\u{27}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{27}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{27}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{31}\u{27}\u{308}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{27}\u{308}", "\u{61}",
- "\u{27}\u{2060}"]), ("\u{31}\u{27}\u{61}\u{2c}", &["\u{31}", "\u{27}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{27}\u{308}\u{61}\u{2c}", &["\u{31}", "\u{27}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{27}\u{31}\u{3a}", &["\u{31}\u{27}\u{31}", "\u{3a}"]),
- ("\u{31}\u{27}\u{308}\u{31}\u{3a}", &["\u{31}\u{27}\u{308}\u{31}", "\u{3a}"]),
- ("\u{31}\u{27}\u{31}\u{27}", &["\u{31}\u{27}\u{31}", "\u{27}"]),
- ("\u{31}\u{27}\u{308}\u{31}\u{27}", &["\u{31}\u{27}\u{308}\u{31}", "\u{27}"]),
- ("\u{31}\u{27}\u{31}\u{2c}", &["\u{31}\u{27}\u{31}", "\u{2c}"]),
- ("\u{31}\u{27}\u{308}\u{31}\u{2c}", &["\u{31}\u{27}\u{308}\u{31}", "\u{2c}"]),
- ("\u{31}\u{27}\u{31}\u{2e}\u{2060}", &["\u{31}\u{27}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{31}\u{27}\u{308}\u{31}\u{2e}\u{2060}", &["\u{31}\u{27}\u{308}\u{31}",
- "\u{2e}\u{2060}"]), ("\u{31}\u{2c}\u{1}", &["\u{31}", "\u{2c}", "\u{1}"]),
- ("\u{31}\u{2c}\u{308}\u{1}", &["\u{31}", "\u{2c}\u{308}", "\u{1}"]), ("\u{31}\u{2c}\u{d}",
- &["\u{31}", "\u{2c}", "\u{d}"]), ("\u{31}\u{2c}\u{308}\u{d}", &["\u{31}", "\u{2c}\u{308}",
- "\u{d}"]), ("\u{31}\u{2c}\u{a}", &["\u{31}", "\u{2c}", "\u{a}"]),
- ("\u{31}\u{2c}\u{308}\u{a}", &["\u{31}", "\u{2c}\u{308}", "\u{a}"]), ("\u{31}\u{2c}\u{b}",
- &["\u{31}", "\u{2c}", "\u{b}"]), ("\u{31}\u{2c}\u{308}\u{b}", &["\u{31}", "\u{2c}\u{308}",
- "\u{b}"]), ("\u{31}\u{2c}\u{3031}", &["\u{31}", "\u{2c}", "\u{3031}"]),
- ("\u{31}\u{2c}\u{308}\u{3031}", &["\u{31}", "\u{2c}\u{308}", "\u{3031}"]),
- ("\u{31}\u{2c}\u{41}", &["\u{31}", "\u{2c}", "\u{41}"]), ("\u{31}\u{2c}\u{308}\u{41}",
- &["\u{31}", "\u{2c}\u{308}", "\u{41}"]), ("\u{31}\u{2c}\u{3a}", &["\u{31}", "\u{2c}",
- "\u{3a}"]), ("\u{31}\u{2c}\u{308}\u{3a}", &["\u{31}", "\u{2c}\u{308}", "\u{3a}"]),
- ("\u{31}\u{2c}\u{2c}", &["\u{31}", "\u{2c}", "\u{2c}"]), ("\u{31}\u{2c}\u{308}\u{2c}",
- &["\u{31}", "\u{2c}\u{308}", "\u{2c}"]), ("\u{31}\u{2c}\u{2e}", &["\u{31}", "\u{2c}",
- "\u{2e}"]), ("\u{31}\u{2c}\u{308}\u{2e}", &["\u{31}", "\u{2c}\u{308}", "\u{2e}"]),
- ("\u{31}\u{2c}\u{30}", &["\u{31}\u{2c}\u{30}"]), ("\u{31}\u{2c}\u{308}\u{30}",
- &["\u{31}\u{2c}\u{308}\u{30}"]), ("\u{31}\u{2c}\u{5f}", &["\u{31}", "\u{2c}", "\u{5f}"]),
- ("\u{31}\u{2c}\u{308}\u{5f}", &["\u{31}", "\u{2c}\u{308}", "\u{5f}"]),
- ("\u{31}\u{2c}\u{1f1e6}", &["\u{31}", "\u{2c}", "\u{1f1e6}"]),
- ("\u{31}\u{2c}\u{308}\u{1f1e6}", &["\u{31}", "\u{2c}\u{308}", "\u{1f1e6}"]),
- ("\u{31}\u{2c}\u{5d0}", &["\u{31}", "\u{2c}", "\u{5d0}"]), ("\u{31}\u{2c}\u{308}\u{5d0}",
- &["\u{31}", "\u{2c}\u{308}", "\u{5d0}"]), ("\u{31}\u{2c}\u{22}", &["\u{31}", "\u{2c}",
- "\u{22}"]), ("\u{31}\u{2c}\u{308}\u{22}", &["\u{31}", "\u{2c}\u{308}", "\u{22}"]),
- ("\u{31}\u{2c}\u{27}", &["\u{31}", "\u{2c}", "\u{27}"]), ("\u{31}\u{2c}\u{308}\u{27}",
- &["\u{31}", "\u{2c}\u{308}", "\u{27}"]), ("\u{31}\u{2c}\u{231a}", &["\u{31}", "\u{2c}",
- "\u{231a}"]), ("\u{31}\u{2c}\u{308}\u{231a}", &["\u{31}", "\u{2c}\u{308}", "\u{231a}"]),
- ("\u{31}\u{2c}\u{20}", &["\u{31}", "\u{2c}", "\u{20}"]), ("\u{31}\u{2c}\u{308}\u{20}",
- &["\u{31}", "\u{2c}\u{308}", "\u{20}"]), ("\u{31}\u{2c}\u{ad}", &["\u{31}",
- "\u{2c}\u{ad}"]), ("\u{31}\u{2c}\u{308}\u{ad}", &["\u{31}", "\u{2c}\u{308}\u{ad}"]),
- ("\u{31}\u{2c}\u{300}", &["\u{31}", "\u{2c}\u{300}"]), ("\u{31}\u{2c}\u{308}\u{300}",
- &["\u{31}", "\u{2c}\u{308}\u{300}"]), ("\u{31}\u{2c}\u{200d}", &["\u{31}",
- "\u{2c}\u{200d}"]), ("\u{31}\u{2c}\u{308}\u{200d}", &["\u{31}", "\u{2c}\u{308}\u{200d}"]),
- ("\u{31}\u{2c}\u{61}\u{2060}", &["\u{31}", "\u{2c}", "\u{61}\u{2060}"]),
- ("\u{31}\u{2c}\u{308}\u{61}\u{2060}", &["\u{31}", "\u{2c}\u{308}", "\u{61}\u{2060}"]),
- ("\u{31}\u{2c}\u{61}\u{3a}", &["\u{31}", "\u{2c}", "\u{61}", "\u{3a}"]),
- ("\u{31}\u{2c}\u{308}\u{61}\u{3a}", &["\u{31}", "\u{2c}\u{308}", "\u{61}", "\u{3a}"]),
- ("\u{31}\u{2c}\u{61}\u{27}", &["\u{31}", "\u{2c}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{2c}\u{308}\u{61}\u{27}", &["\u{31}", "\u{2c}\u{308}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{2c}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{2c}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{31}\u{2c}\u{308}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{2c}\u{308}", "\u{61}",
- "\u{27}\u{2060}"]), ("\u{31}\u{2c}\u{61}\u{2c}", &["\u{31}", "\u{2c}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{2c}\u{308}\u{61}\u{2c}", &["\u{31}", "\u{2c}\u{308}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{2c}\u{31}\u{3a}", &["\u{31}\u{2c}\u{31}", "\u{3a}"]),
- ("\u{31}\u{2c}\u{308}\u{31}\u{3a}", &["\u{31}\u{2c}\u{308}\u{31}", "\u{3a}"]),
- ("\u{31}\u{2c}\u{31}\u{27}", &["\u{31}\u{2c}\u{31}", "\u{27}"]),
- ("\u{31}\u{2c}\u{308}\u{31}\u{27}", &["\u{31}\u{2c}\u{308}\u{31}", "\u{27}"]),
- ("\u{31}\u{2c}\u{31}\u{2c}", &["\u{31}\u{2c}\u{31}", "\u{2c}"]),
- ("\u{31}\u{2c}\u{308}\u{31}\u{2c}", &["\u{31}\u{2c}\u{308}\u{31}", "\u{2c}"]),
- ("\u{31}\u{2c}\u{31}\u{2e}\u{2060}", &["\u{31}\u{2c}\u{31}", "\u{2e}\u{2060}"]),
- ("\u{31}\u{2c}\u{308}\u{31}\u{2e}\u{2060}", &["\u{31}\u{2c}\u{308}\u{31}",
- "\u{2e}\u{2060}"]), ("\u{31}\u{2e}\u{2060}\u{1}", &["\u{31}", "\u{2e}\u{2060}", "\u{1}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{1}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{1}"]),
- ("\u{31}\u{2e}\u{2060}\u{d}", &["\u{31}", "\u{2e}\u{2060}", "\u{d}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{d}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{d}"]),
- ("\u{31}\u{2e}\u{2060}\u{a}", &["\u{31}", "\u{2e}\u{2060}", "\u{a}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{a}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{a}"]),
- ("\u{31}\u{2e}\u{2060}\u{b}", &["\u{31}", "\u{2e}\u{2060}", "\u{b}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{b}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{b}"]),
- ("\u{31}\u{2e}\u{2060}\u{3031}", &["\u{31}", "\u{2e}\u{2060}", "\u{3031}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{3031}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{3031}"]),
- ("\u{31}\u{2e}\u{2060}\u{41}", &["\u{31}", "\u{2e}\u{2060}", "\u{41}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{41}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{41}"]),
- ("\u{31}\u{2e}\u{2060}\u{3a}", &["\u{31}", "\u{2e}\u{2060}", "\u{3a}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{3a}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{3a}"]),
- ("\u{31}\u{2e}\u{2060}\u{2c}", &["\u{31}", "\u{2e}\u{2060}", "\u{2c}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{2c}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{2c}"]),
- ("\u{31}\u{2e}\u{2060}\u{2e}", &["\u{31}", "\u{2e}\u{2060}", "\u{2e}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{2e}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{2e}"]),
- ("\u{31}\u{2e}\u{2060}\u{30}", &["\u{31}\u{2e}\u{2060}\u{30}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{30}", &["\u{31}\u{2e}\u{2060}\u{308}\u{30}"]),
- ("\u{31}\u{2e}\u{2060}\u{5f}", &["\u{31}", "\u{2e}\u{2060}", "\u{5f}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{5f}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{5f}"]),
- ("\u{31}\u{2e}\u{2060}\u{1f1e6}", &["\u{31}", "\u{2e}\u{2060}", "\u{1f1e6}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{1f1e6}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{1f1e6}"]),
- ("\u{31}\u{2e}\u{2060}\u{5d0}", &["\u{31}", "\u{2e}\u{2060}", "\u{5d0}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{5d0}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{5d0}"]),
- ("\u{31}\u{2e}\u{2060}\u{22}", &["\u{31}", "\u{2e}\u{2060}", "\u{22}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{22}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{22}"]),
- ("\u{31}\u{2e}\u{2060}\u{27}", &["\u{31}", "\u{2e}\u{2060}", "\u{27}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{27}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{27}"]),
- ("\u{31}\u{2e}\u{2060}\u{231a}", &["\u{31}", "\u{2e}\u{2060}", "\u{231a}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{231a}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{231a}"]),
- ("\u{31}\u{2e}\u{2060}\u{20}", &["\u{31}", "\u{2e}\u{2060}", "\u{20}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{20}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{20}"]),
- ("\u{31}\u{2e}\u{2060}\u{ad}", &["\u{31}", "\u{2e}\u{2060}\u{ad}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{ad}", &["\u{31}", "\u{2e}\u{2060}\u{308}\u{ad}"]),
- ("\u{31}\u{2e}\u{2060}\u{300}", &["\u{31}", "\u{2e}\u{2060}\u{300}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{300}", &["\u{31}", "\u{2e}\u{2060}\u{308}\u{300}"]),
- ("\u{31}\u{2e}\u{2060}\u{200d}", &["\u{31}", "\u{2e}\u{2060}\u{200d}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{200d}", &["\u{31}", "\u{2e}\u{2060}\u{308}\u{200d}"]),
- ("\u{31}\u{2e}\u{2060}\u{61}\u{2060}", &["\u{31}", "\u{2e}\u{2060}", "\u{61}\u{2060}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{61}\u{2060}", &["\u{31}", "\u{2e}\u{2060}\u{308}",
- "\u{61}\u{2060}"]), ("\u{31}\u{2e}\u{2060}\u{61}\u{3a}", &["\u{31}", "\u{2e}\u{2060}",
- "\u{61}", "\u{3a}"]), ("\u{31}\u{2e}\u{2060}\u{308}\u{61}\u{3a}", &["\u{31}",
- "\u{2e}\u{2060}\u{308}", "\u{61}", "\u{3a}"]), ("\u{31}\u{2e}\u{2060}\u{61}\u{27}",
- &["\u{31}", "\u{2e}\u{2060}", "\u{61}", "\u{27}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{61}\u{27}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{61}",
- "\u{27}"]), ("\u{31}\u{2e}\u{2060}\u{61}\u{27}\u{2060}", &["\u{31}", "\u{2e}\u{2060}",
- "\u{61}", "\u{27}\u{2060}"]), ("\u{31}\u{2e}\u{2060}\u{308}\u{61}\u{27}\u{2060}",
- &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{61}", "\u{27}\u{2060}"]),
- ("\u{31}\u{2e}\u{2060}\u{61}\u{2c}", &["\u{31}", "\u{2e}\u{2060}", "\u{61}", "\u{2c}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{61}\u{2c}", &["\u{31}", "\u{2e}\u{2060}\u{308}", "\u{61}",
- "\u{2c}"]), ("\u{31}\u{2e}\u{2060}\u{31}\u{3a}", &["\u{31}\u{2e}\u{2060}\u{31}", "\u{3a}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{31}\u{3a}", &["\u{31}\u{2e}\u{2060}\u{308}\u{31}",
- "\u{3a}"]), ("\u{31}\u{2e}\u{2060}\u{31}\u{27}", &["\u{31}\u{2e}\u{2060}\u{31}", "\u{27}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{31}\u{27}", &["\u{31}\u{2e}\u{2060}\u{308}\u{31}",
- "\u{27}"]), ("\u{31}\u{2e}\u{2060}\u{31}\u{2c}", &["\u{31}\u{2e}\u{2060}\u{31}", "\u{2c}"]),
- ("\u{31}\u{2e}\u{2060}\u{308}\u{31}\u{2c}", &["\u{31}\u{2e}\u{2060}\u{308}\u{31}",
- "\u{2c}"]), ("\u{31}\u{2e}\u{2060}\u{31}\u{2e}\u{2060}", &["\u{31}\u{2e}\u{2060}\u{31}",
- "\u{2e}\u{2060}"]), ("\u{31}\u{2e}\u{2060}\u{308}\u{31}\u{2e}\u{2060}",
- &["\u{31}\u{2e}\u{2060}\u{308}\u{31}", "\u{2e}\u{2060}"]), ("\u{d}\u{a}\u{61}\u{a}\u{308}",
- &["\u{d}\u{a}", "\u{61}", "\u{a}", "\u{308}"]), ("\u{61}\u{308}", &["\u{61}\u{308}"]),
- ("\u{20}\u{200d}\u{646}", &["\u{20}\u{200d}", "\u{646}"]), ("\u{646}\u{200d}\u{20}",
- &["\u{646}\u{200d}", "\u{20}"]), ("\u{41}\u{41}\u{41}", &["\u{41}\u{41}\u{41}"]),
- ("\u{41}\u{3a}\u{41}", &["\u{41}\u{3a}\u{41}"]), ("\u{41}\u{3a}\u{3a}\u{41}", &["\u{41}",
- "\u{3a}", "\u{3a}", "\u{41}"]), ("\u{5d0}\u{27}", &["\u{5d0}\u{27}"]),
- ("\u{5d0}\u{22}\u{5d0}", &["\u{5d0}\u{22}\u{5d0}"]), ("\u{41}\u{30}\u{30}\u{41}",
- &["\u{41}\u{30}\u{30}\u{41}"]), ("\u{30}\u{2c}\u{30}", &["\u{30}\u{2c}\u{30}"]),
- ("\u{30}\u{2c}\u{2c}\u{30}", &["\u{30}", "\u{2c}", "\u{2c}", "\u{30}"]),
- ("\u{3031}\u{3031}", &["\u{3031}\u{3031}"]), ("\u{41}\u{5f}\u{30}\u{5f}\u{3031}\u{5f}",
- &["\u{41}\u{5f}\u{30}\u{5f}\u{3031}\u{5f}"]), ("\u{41}\u{5f}\u{5f}\u{41}",
- &["\u{41}\u{5f}\u{5f}\u{41}"]), ("\u{1f1e6}\u{1f1e7}\u{1f1e8}\u{62}",
- &["\u{1f1e6}\u{1f1e7}", "\u{1f1e8}", "\u{62}"]), ("\u{61}\u{1f1e6}\u{1f1e7}\u{1f1e8}\u{62}",
- &["\u{61}", "\u{1f1e6}\u{1f1e7}", "\u{1f1e8}", "\u{62}"]),
- ("\u{61}\u{1f1e6}\u{1f1e7}\u{200d}\u{1f1e8}\u{62}", &["\u{61}",
- "\u{1f1e6}\u{1f1e7}\u{200d}", "\u{1f1e8}", "\u{62}"]),
- ("\u{61}\u{1f1e6}\u{200d}\u{1f1e7}\u{1f1e8}\u{62}", &["\u{61}",
- "\u{1f1e6}\u{200d}\u{1f1e7}", "\u{1f1e8}", "\u{62}"]),
- ("\u{61}\u{1f1e6}\u{1f1e7}\u{1f1e8}\u{1f1e9}\u{62}", &["\u{61}", "\u{1f1e6}\u{1f1e7}",
- "\u{1f1e8}\u{1f1e9}", "\u{62}"]), ("\u{1f476}\u{1f3ff}\u{1f476}", &["\u{1f476}\u{1f3ff}",
- "\u{1f476}"]), ("\u{1f6d1}\u{200d}\u{1f6d1}", &["\u{1f6d1}\u{200d}\u{1f6d1}"]),
- ("\u{61}\u{200d}\u{1f6d1}", &["\u{61}\u{200d}\u{1f6d1}"]), ("\u{2701}\u{200d}\u{2701}",
- &["\u{2701}\u{200d}\u{2701}"]), ("\u{61}\u{200d}\u{2701}", &["\u{61}\u{200d}\u{2701}"]),
- ("\u{1f476}\u{1f3ff}\u{308}\u{200d}\u{1f476}\u{1f3ff}",
- &["\u{1f476}\u{1f3ff}\u{308}\u{200d}\u{1f476}\u{1f3ff}"]), ("\u{1f6d1}\u{1f3ff}",
- &["\u{1f6d1}\u{1f3ff}"]), ("\u{200d}\u{1f6d1}\u{1f3ff}", &["\u{200d}\u{1f6d1}\u{1f3ff}"]),
- ("\u{200d}\u{1f6d1}", &["\u{200d}\u{1f6d1}"]), ("\u{200d}\u{1f6d1}",
- &["\u{200d}\u{1f6d1}"]), ("\u{1f6d1}\u{1f6d1}", &["\u{1f6d1}", "\u{1f6d1}"]),
- ("\u{61}\u{308}\u{200d}\u{308}\u{62}", &["\u{61}\u{308}\u{200d}\u{308}\u{62}"]),
- ("\u{61}\u{20}\u{20}\u{62}", &["\u{61}", "\u{20}\u{20}", "\u{62}"]),
- ("\u{31}\u{3a}\u{3a}\u{31}", &["\u{31}", "\u{3a}", "\u{3a}", "\u{31}"]),
- ("\u{31}\u{5f}\u{31}\u{3a}\u{3a}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{3a}", "\u{3a}",
- "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{3a}\u{3a}\u{31}", &["\u{31}\u{5f}\u{61}", "\u{3a}",
- "\u{3a}", "\u{31}"]), ("\u{31}\u{3a}\u{3a}\u{61}", &["\u{31}", "\u{3a}", "\u{3a}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{3a}\u{3a}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{3a}",
- "\u{3a}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{3a}\u{3a}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{3a}", "\u{3a}", "\u{61}"]), ("\u{31}\u{3a}\u{2e}\u{31}", &["\u{31}", "\u{3a}", "\u{2e}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{3a}\u{2e}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{3a}",
- "\u{2e}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{3a}\u{2e}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{3a}", "\u{2e}", "\u{31}"]), ("\u{31}\u{3a}\u{2e}\u{61}", &["\u{31}", "\u{3a}", "\u{2e}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{3a}\u{2e}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{3a}",
- "\u{2e}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{3a}\u{2e}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{3a}", "\u{2e}", "\u{61}"]), ("\u{31}\u{3a}\u{2c}\u{31}", &["\u{31}", "\u{3a}", "\u{2c}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{3a}\u{2c}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{3a}",
- "\u{2c}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{3a}\u{2c}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{3a}", "\u{2c}", "\u{31}"]), ("\u{31}\u{3a}\u{2c}\u{61}", &["\u{31}", "\u{3a}", "\u{2c}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{3a}\u{2c}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{3a}",
- "\u{2c}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{3a}\u{2c}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{3a}", "\u{2c}", "\u{61}"]), ("\u{31}\u{2e}\u{3a}\u{31}", &["\u{31}", "\u{2e}", "\u{3a}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{2e}\u{3a}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{2e}",
- "\u{3a}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{2e}\u{3a}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{2e}", "\u{3a}", "\u{31}"]), ("\u{31}\u{2e}\u{3a}\u{61}", &["\u{31}", "\u{2e}", "\u{3a}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{2e}\u{3a}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{2e}",
- "\u{3a}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{2e}\u{3a}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{2e}", "\u{3a}", "\u{61}"]), ("\u{31}\u{2e}\u{2e}\u{31}", &["\u{31}", "\u{2e}", "\u{2e}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{2e}\u{2e}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{2e}",
- "\u{2e}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{2e}\u{2e}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{2e}", "\u{2e}", "\u{31}"]), ("\u{31}\u{2e}\u{2e}\u{61}", &["\u{31}", "\u{2e}", "\u{2e}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{2e}\u{2e}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{2e}",
- "\u{2e}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{2e}\u{2e}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{2e}", "\u{2e}", "\u{61}"]), ("\u{31}\u{2e}\u{2c}\u{31}", &["\u{31}", "\u{2e}", "\u{2c}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{2e}\u{2c}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{2e}",
- "\u{2c}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{2e}\u{2c}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{2e}", "\u{2c}", "\u{31}"]), ("\u{31}\u{2e}\u{2c}\u{61}", &["\u{31}", "\u{2e}", "\u{2c}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{2e}\u{2c}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{2e}",
- "\u{2c}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{2e}\u{2c}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{2e}", "\u{2c}", "\u{61}"]), ("\u{31}\u{2c}\u{3a}\u{31}", &["\u{31}", "\u{2c}", "\u{3a}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{2c}\u{3a}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{2c}",
- "\u{3a}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{2c}\u{3a}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{2c}", "\u{3a}", "\u{31}"]), ("\u{31}\u{2c}\u{3a}\u{61}", &["\u{31}", "\u{2c}", "\u{3a}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{2c}\u{3a}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{2c}",
- "\u{3a}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{2c}\u{3a}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{2c}", "\u{3a}", "\u{61}"]), ("\u{31}\u{2c}\u{2e}\u{31}", &["\u{31}", "\u{2c}", "\u{2e}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{2c}\u{2e}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{2c}",
- "\u{2e}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{2c}\u{2e}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{2c}", "\u{2e}", "\u{31}"]), ("\u{31}\u{2c}\u{2e}\u{61}", &["\u{31}", "\u{2c}", "\u{2e}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{2c}\u{2e}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{2c}",
- "\u{2e}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{2c}\u{2e}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{2c}", "\u{2e}", "\u{61}"]), ("\u{31}\u{2c}\u{2c}\u{31}", &["\u{31}", "\u{2c}", "\u{2c}",
- "\u{31}"]), ("\u{31}\u{5f}\u{31}\u{2c}\u{2c}\u{31}", &["\u{31}\u{5f}\u{31}", "\u{2c}",
- "\u{2c}", "\u{31}"]), ("\u{31}\u{5f}\u{61}\u{2c}\u{2c}\u{31}", &["\u{31}\u{5f}\u{61}",
- "\u{2c}", "\u{2c}", "\u{31}"]), ("\u{31}\u{2c}\u{2c}\u{61}", &["\u{31}", "\u{2c}", "\u{2c}",
- "\u{61}"]), ("\u{31}\u{5f}\u{31}\u{2c}\u{2c}\u{61}", &["\u{31}\u{5f}\u{31}", "\u{2c}",
- "\u{2c}", "\u{61}"]), ("\u{31}\u{5f}\u{61}\u{2c}\u{2c}\u{61}", &["\u{31}\u{5f}\u{61}",
- "\u{2c}", "\u{2c}", "\u{61}"]), ("\u{61}\u{3a}\u{3a}\u{31}", &["\u{61}", "\u{3a}", "\u{3a}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{3a}\u{3a}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{3a}",
- "\u{3a}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{3a}\u{3a}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{3a}", "\u{3a}", "\u{31}"]), ("\u{61}\u{3a}\u{3a}\u{61}", &["\u{61}", "\u{3a}", "\u{3a}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{3a}\u{3a}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{3a}",
- "\u{3a}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{3a}\u{3a}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{3a}", "\u{3a}", "\u{61}"]), ("\u{61}\u{3a}\u{2e}\u{31}", &["\u{61}", "\u{3a}", "\u{2e}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{3a}\u{2e}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{3a}",
- "\u{2e}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{3a}\u{2e}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{3a}", "\u{2e}", "\u{31}"]), ("\u{61}\u{3a}\u{2e}\u{61}", &["\u{61}", "\u{3a}", "\u{2e}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{3a}\u{2e}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{3a}",
- "\u{2e}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{3a}\u{2e}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{3a}", "\u{2e}", "\u{61}"]), ("\u{61}\u{3a}\u{2c}\u{31}", &["\u{61}", "\u{3a}", "\u{2c}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{3a}\u{2c}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{3a}",
- "\u{2c}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{3a}\u{2c}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{3a}", "\u{2c}", "\u{31}"]), ("\u{61}\u{3a}\u{2c}\u{61}", &["\u{61}", "\u{3a}", "\u{2c}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{3a}\u{2c}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{3a}",
- "\u{2c}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{3a}\u{2c}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{3a}", "\u{2c}", "\u{61}"]), ("\u{61}\u{2e}\u{3a}\u{31}", &["\u{61}", "\u{2e}", "\u{3a}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{2e}\u{3a}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{2e}",
- "\u{3a}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{2e}\u{3a}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{2e}", "\u{3a}", "\u{31}"]), ("\u{61}\u{2e}\u{3a}\u{61}", &["\u{61}", "\u{2e}", "\u{3a}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{2e}\u{3a}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{2e}",
- "\u{3a}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{2e}\u{3a}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{2e}", "\u{3a}", "\u{61}"]), ("\u{61}\u{2e}\u{2e}\u{31}", &["\u{61}", "\u{2e}", "\u{2e}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{2e}\u{2e}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{2e}",
- "\u{2e}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{2e}\u{2e}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{2e}", "\u{2e}", "\u{31}"]), ("\u{61}\u{2e}\u{2e}\u{61}", &["\u{61}", "\u{2e}", "\u{2e}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{2e}\u{2e}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{2e}",
- "\u{2e}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{2e}\u{2e}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{2e}", "\u{2e}", "\u{61}"]), ("\u{61}\u{2e}\u{2c}\u{31}", &["\u{61}", "\u{2e}", "\u{2c}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{2e}\u{2c}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{2e}",
- "\u{2c}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{2e}\u{2c}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{2e}", "\u{2c}", "\u{31}"]), ("\u{61}\u{2e}\u{2c}\u{61}", &["\u{61}", "\u{2e}", "\u{2c}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{2e}\u{2c}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{2e}",
- "\u{2c}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{2e}\u{2c}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{2e}", "\u{2c}", "\u{61}"]), ("\u{61}\u{2c}\u{3a}\u{31}", &["\u{61}", "\u{2c}", "\u{3a}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{2c}\u{3a}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{2c}",
- "\u{3a}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{2c}\u{3a}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{2c}", "\u{3a}", "\u{31}"]), ("\u{61}\u{2c}\u{3a}\u{61}", &["\u{61}", "\u{2c}", "\u{3a}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{2c}\u{3a}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{2c}",
- "\u{3a}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{2c}\u{3a}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{2c}", "\u{3a}", "\u{61}"]), ("\u{61}\u{2c}\u{2e}\u{31}", &["\u{61}", "\u{2c}", "\u{2e}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{2c}\u{2e}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{2c}",
- "\u{2e}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{2c}\u{2e}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{2c}", "\u{2e}", "\u{31}"]), ("\u{61}\u{2c}\u{2e}\u{61}", &["\u{61}", "\u{2c}", "\u{2e}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{2c}\u{2e}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{2c}",
- "\u{2e}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{2c}\u{2e}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{2c}", "\u{2e}", "\u{61}"]), ("\u{61}\u{2c}\u{2c}\u{31}", &["\u{61}", "\u{2c}", "\u{2c}",
- "\u{31}"]), ("\u{61}\u{5f}\u{31}\u{2c}\u{2c}\u{31}", &["\u{61}\u{5f}\u{31}", "\u{2c}",
- "\u{2c}", "\u{31}"]), ("\u{61}\u{5f}\u{61}\u{2c}\u{2c}\u{31}", &["\u{61}\u{5f}\u{61}",
- "\u{2c}", "\u{2c}", "\u{31}"]), ("\u{61}\u{2c}\u{2c}\u{61}", &["\u{61}", "\u{2c}", "\u{2c}",
- "\u{61}"]), ("\u{61}\u{5f}\u{31}\u{2c}\u{2c}\u{61}", &["\u{61}\u{5f}\u{31}", "\u{2c}",
- "\u{2c}", "\u{61}"]), ("\u{61}\u{5f}\u{61}\u{2c}\u{2c}\u{61}", &["\u{61}\u{5f}\u{61}",
- "\u{2c}", "\u{2c}", "\u{61}"])
- ];
-
- // official Unicode test data
- // http://www.unicode.org/Public/12.0.0/ucd/auxiliary/SentenceBreakTest.txt
- pub const TEST_SENTENCE: &'static [(&'static str, &'static [&'static str])] = &[
- ("\u{1}\u{1}", &["\u{1}\u{1}"]), ("\u{1}\u{308}\u{1}", &["\u{1}\u{308}\u{1}"]),
- ("\u{1}\u{d}", &["\u{1}\u{d}"]), ("\u{1}\u{308}\u{d}", &["\u{1}\u{308}\u{d}"]),
- ("\u{1}\u{a}", &["\u{1}\u{a}"]), ("\u{1}\u{308}\u{a}", &["\u{1}\u{308}\u{a}"]),
- ("\u{1}\u{85}", &["\u{1}\u{85}"]), ("\u{1}\u{308}\u{85}", &["\u{1}\u{308}\u{85}"]),
- ("\u{1}\u{9}", &["\u{1}\u{9}"]), ("\u{1}\u{308}\u{9}", &["\u{1}\u{308}\u{9}"]),
- ("\u{1}\u{61}", &["\u{1}\u{61}"]), ("\u{1}\u{308}\u{61}", &["\u{1}\u{308}\u{61}"]),
- ("\u{1}\u{41}", &["\u{1}\u{41}"]), ("\u{1}\u{308}\u{41}", &["\u{1}\u{308}\u{41}"]),
- ("\u{1}\u{1bb}", &["\u{1}\u{1bb}"]), ("\u{1}\u{308}\u{1bb}", &["\u{1}\u{308}\u{1bb}"]),
- ("\u{1}\u{30}", &["\u{1}\u{30}"]), ("\u{1}\u{308}\u{30}", &["\u{1}\u{308}\u{30}"]),
- ("\u{1}\u{2e}", &["\u{1}\u{2e}"]), ("\u{1}\u{308}\u{2e}", &["\u{1}\u{308}\u{2e}"]),
- ("\u{1}\u{21}", &["\u{1}\u{21}"]), ("\u{1}\u{308}\u{21}", &["\u{1}\u{308}\u{21}"]),
- ("\u{1}\u{22}", &["\u{1}\u{22}"]), ("\u{1}\u{308}\u{22}", &["\u{1}\u{308}\u{22}"]),
- ("\u{1}\u{2c}", &["\u{1}\u{2c}"]), ("\u{1}\u{308}\u{2c}", &["\u{1}\u{308}\u{2c}"]),
- ("\u{1}\u{ad}", &["\u{1}\u{ad}"]), ("\u{1}\u{308}\u{ad}", &["\u{1}\u{308}\u{ad}"]),
- ("\u{1}\u{300}", &["\u{1}\u{300}"]), ("\u{1}\u{308}\u{300}", &["\u{1}\u{308}\u{300}"]),
- ("\u{d}\u{1}", &["\u{d}", "\u{1}"]), ("\u{d}\u{308}\u{1}", &["\u{d}", "\u{308}\u{1}"]),
- ("\u{d}\u{d}", &["\u{d}", "\u{d}"]), ("\u{d}\u{308}\u{d}", &["\u{d}", "\u{308}\u{d}"]),
- ("\u{d}\u{a}", &["\u{d}\u{a}"]), ("\u{d}\u{308}\u{a}", &["\u{d}", "\u{308}\u{a}"]),
- ("\u{d}\u{85}", &["\u{d}", "\u{85}"]), ("\u{d}\u{308}\u{85}", &["\u{d}", "\u{308}\u{85}"]),
- ("\u{d}\u{9}", &["\u{d}", "\u{9}"]), ("\u{d}\u{308}\u{9}", &["\u{d}", "\u{308}\u{9}"]),
- ("\u{d}\u{61}", &["\u{d}", "\u{61}"]), ("\u{d}\u{308}\u{61}", &["\u{d}", "\u{308}\u{61}"]),
- ("\u{d}\u{41}", &["\u{d}", "\u{41}"]), ("\u{d}\u{308}\u{41}", &["\u{d}", "\u{308}\u{41}"]),
- ("\u{d}\u{1bb}", &["\u{d}", "\u{1bb}"]), ("\u{d}\u{308}\u{1bb}", &["\u{d}",
- "\u{308}\u{1bb}"]), ("\u{d}\u{30}", &["\u{d}", "\u{30}"]), ("\u{d}\u{308}\u{30}", &["\u{d}",
- "\u{308}\u{30}"]), ("\u{d}\u{2e}", &["\u{d}", "\u{2e}"]), ("\u{d}\u{308}\u{2e}", &["\u{d}",
- "\u{308}\u{2e}"]), ("\u{d}\u{21}", &["\u{d}", "\u{21}"]), ("\u{d}\u{308}\u{21}", &["\u{d}",
- "\u{308}\u{21}"]), ("\u{d}\u{22}", &["\u{d}", "\u{22}"]), ("\u{d}\u{308}\u{22}", &["\u{d}",
- "\u{308}\u{22}"]), ("\u{d}\u{2c}", &["\u{d}", "\u{2c}"]), ("\u{d}\u{308}\u{2c}", &["\u{d}",
- "\u{308}\u{2c}"]), ("\u{d}\u{ad}", &["\u{d}", "\u{ad}"]), ("\u{d}\u{308}\u{ad}", &["\u{d}",
- "\u{308}\u{ad}"]), ("\u{d}\u{300}", &["\u{d}", "\u{300}"]), ("\u{d}\u{308}\u{300}",
- &["\u{d}", "\u{308}\u{300}"]), ("\u{a}\u{1}", &["\u{a}", "\u{1}"]), ("\u{a}\u{308}\u{1}",
- &["\u{a}", "\u{308}\u{1}"]), ("\u{a}\u{d}", &["\u{a}", "\u{d}"]), ("\u{a}\u{308}\u{d}",
- &["\u{a}", "\u{308}\u{d}"]), ("\u{a}\u{a}", &["\u{a}", "\u{a}"]), ("\u{a}\u{308}\u{a}",
- &["\u{a}", "\u{308}\u{a}"]), ("\u{a}\u{85}", &["\u{a}", "\u{85}"]), ("\u{a}\u{308}\u{85}",
- &["\u{a}", "\u{308}\u{85}"]), ("\u{a}\u{9}", &["\u{a}", "\u{9}"]), ("\u{a}\u{308}\u{9}",
- &["\u{a}", "\u{308}\u{9}"]), ("\u{a}\u{61}", &["\u{a}", "\u{61}"]), ("\u{a}\u{308}\u{61}",
- &["\u{a}", "\u{308}\u{61}"]), ("\u{a}\u{41}", &["\u{a}", "\u{41}"]), ("\u{a}\u{308}\u{41}",
- &["\u{a}", "\u{308}\u{41}"]), ("\u{a}\u{1bb}", &["\u{a}", "\u{1bb}"]),
- ("\u{a}\u{308}\u{1bb}", &["\u{a}", "\u{308}\u{1bb}"]), ("\u{a}\u{30}", &["\u{a}",
- "\u{30}"]), ("\u{a}\u{308}\u{30}", &["\u{a}", "\u{308}\u{30}"]), ("\u{a}\u{2e}", &["\u{a}",
- "\u{2e}"]), ("\u{a}\u{308}\u{2e}", &["\u{a}", "\u{308}\u{2e}"]), ("\u{a}\u{21}", &["\u{a}",
- "\u{21}"]), ("\u{a}\u{308}\u{21}", &["\u{a}", "\u{308}\u{21}"]), ("\u{a}\u{22}", &["\u{a}",
- "\u{22}"]), ("\u{a}\u{308}\u{22}", &["\u{a}", "\u{308}\u{22}"]), ("\u{a}\u{2c}", &["\u{a}",
- "\u{2c}"]), ("\u{a}\u{308}\u{2c}", &["\u{a}", "\u{308}\u{2c}"]), ("\u{a}\u{ad}", &["\u{a}",
- "\u{ad}"]), ("\u{a}\u{308}\u{ad}", &["\u{a}", "\u{308}\u{ad}"]), ("\u{a}\u{300}", &["\u{a}",
- "\u{300}"]), ("\u{a}\u{308}\u{300}", &["\u{a}", "\u{308}\u{300}"]), ("\u{85}\u{1}",
- &["\u{85}", "\u{1}"]), ("\u{85}\u{308}\u{1}", &["\u{85}", "\u{308}\u{1}"]), ("\u{85}\u{d}",
- &["\u{85}", "\u{d}"]), ("\u{85}\u{308}\u{d}", &["\u{85}", "\u{308}\u{d}"]), ("\u{85}\u{a}",
- &["\u{85}", "\u{a}"]), ("\u{85}\u{308}\u{a}", &["\u{85}", "\u{308}\u{a}"]), ("\u{85}\u{85}",
- &["\u{85}", "\u{85}"]), ("\u{85}\u{308}\u{85}", &["\u{85}", "\u{308}\u{85}"]),
- ("\u{85}\u{9}", &["\u{85}", "\u{9}"]), ("\u{85}\u{308}\u{9}", &["\u{85}", "\u{308}\u{9}"]),
- ("\u{85}\u{61}", &["\u{85}", "\u{61}"]), ("\u{85}\u{308}\u{61}", &["\u{85}",
- "\u{308}\u{61}"]), ("\u{85}\u{41}", &["\u{85}", "\u{41}"]), ("\u{85}\u{308}\u{41}",
- &["\u{85}", "\u{308}\u{41}"]), ("\u{85}\u{1bb}", &["\u{85}", "\u{1bb}"]),
- ("\u{85}\u{308}\u{1bb}", &["\u{85}", "\u{308}\u{1bb}"]), ("\u{85}\u{30}", &["\u{85}",
- "\u{30}"]), ("\u{85}\u{308}\u{30}", &["\u{85}", "\u{308}\u{30}"]), ("\u{85}\u{2e}",
- &["\u{85}", "\u{2e}"]), ("\u{85}\u{308}\u{2e}", &["\u{85}", "\u{308}\u{2e}"]),
- ("\u{85}\u{21}", &["\u{85}", "\u{21}"]), ("\u{85}\u{308}\u{21}", &["\u{85}",
- "\u{308}\u{21}"]), ("\u{85}\u{22}", &["\u{85}", "\u{22}"]), ("\u{85}\u{308}\u{22}",
- &["\u{85}", "\u{308}\u{22}"]), ("\u{85}\u{2c}", &["\u{85}", "\u{2c}"]),
- ("\u{85}\u{308}\u{2c}", &["\u{85}", "\u{308}\u{2c}"]), ("\u{85}\u{ad}", &["\u{85}",
- "\u{ad}"]), ("\u{85}\u{308}\u{ad}", &["\u{85}", "\u{308}\u{ad}"]), ("\u{85}\u{300}",
- &["\u{85}", "\u{300}"]), ("\u{85}\u{308}\u{300}", &["\u{85}", "\u{308}\u{300}"]),
- ("\u{9}\u{1}", &["\u{9}\u{1}"]), ("\u{9}\u{308}\u{1}", &["\u{9}\u{308}\u{1}"]),
- ("\u{9}\u{d}", &["\u{9}\u{d}"]), ("\u{9}\u{308}\u{d}", &["\u{9}\u{308}\u{d}"]),
- ("\u{9}\u{a}", &["\u{9}\u{a}"]), ("\u{9}\u{308}\u{a}", &["\u{9}\u{308}\u{a}"]),
- ("\u{9}\u{85}", &["\u{9}\u{85}"]), ("\u{9}\u{308}\u{85}", &["\u{9}\u{308}\u{85}"]),
- ("\u{9}\u{9}", &["\u{9}\u{9}"]), ("\u{9}\u{308}\u{9}", &["\u{9}\u{308}\u{9}"]),
- ("\u{9}\u{61}", &["\u{9}\u{61}"]), ("\u{9}\u{308}\u{61}", &["\u{9}\u{308}\u{61}"]),
- ("\u{9}\u{41}", &["\u{9}\u{41}"]), ("\u{9}\u{308}\u{41}", &["\u{9}\u{308}\u{41}"]),
- ("\u{9}\u{1bb}", &["\u{9}\u{1bb}"]), ("\u{9}\u{308}\u{1bb}", &["\u{9}\u{308}\u{1bb}"]),
- ("\u{9}\u{30}", &["\u{9}\u{30}"]), ("\u{9}\u{308}\u{30}", &["\u{9}\u{308}\u{30}"]),
- ("\u{9}\u{2e}", &["\u{9}\u{2e}"]), ("\u{9}\u{308}\u{2e}", &["\u{9}\u{308}\u{2e}"]),
- ("\u{9}\u{21}", &["\u{9}\u{21}"]), ("\u{9}\u{308}\u{21}", &["\u{9}\u{308}\u{21}"]),
- ("\u{9}\u{22}", &["\u{9}\u{22}"]), ("\u{9}\u{308}\u{22}", &["\u{9}\u{308}\u{22}"]),
- ("\u{9}\u{2c}", &["\u{9}\u{2c}"]), ("\u{9}\u{308}\u{2c}", &["\u{9}\u{308}\u{2c}"]),
- ("\u{9}\u{ad}", &["\u{9}\u{ad}"]), ("\u{9}\u{308}\u{ad}", &["\u{9}\u{308}\u{ad}"]),
- ("\u{9}\u{300}", &["\u{9}\u{300}"]), ("\u{9}\u{308}\u{300}", &["\u{9}\u{308}\u{300}"]),
- ("\u{61}\u{1}", &["\u{61}\u{1}"]), ("\u{61}\u{308}\u{1}", &["\u{61}\u{308}\u{1}"]),
- ("\u{61}\u{d}", &["\u{61}\u{d}"]), ("\u{61}\u{308}\u{d}", &["\u{61}\u{308}\u{d}"]),
- ("\u{61}\u{a}", &["\u{61}\u{a}"]), ("\u{61}\u{308}\u{a}", &["\u{61}\u{308}\u{a}"]),
- ("\u{61}\u{85}", &["\u{61}\u{85}"]), ("\u{61}\u{308}\u{85}", &["\u{61}\u{308}\u{85}"]),
- ("\u{61}\u{9}", &["\u{61}\u{9}"]), ("\u{61}\u{308}\u{9}", &["\u{61}\u{308}\u{9}"]),
- ("\u{61}\u{61}", &["\u{61}\u{61}"]), ("\u{61}\u{308}\u{61}", &["\u{61}\u{308}\u{61}"]),
- ("\u{61}\u{41}", &["\u{61}\u{41}"]), ("\u{61}\u{308}\u{41}", &["\u{61}\u{308}\u{41}"]),
- ("\u{61}\u{1bb}", &["\u{61}\u{1bb}"]), ("\u{61}\u{308}\u{1bb}", &["\u{61}\u{308}\u{1bb}"]),
- ("\u{61}\u{30}", &["\u{61}\u{30}"]), ("\u{61}\u{308}\u{30}", &["\u{61}\u{308}\u{30}"]),
- ("\u{61}\u{2e}", &["\u{61}\u{2e}"]), ("\u{61}\u{308}\u{2e}", &["\u{61}\u{308}\u{2e}"]),
- ("\u{61}\u{21}", &["\u{61}\u{21}"]), ("\u{61}\u{308}\u{21}", &["\u{61}\u{308}\u{21}"]),
- ("\u{61}\u{22}", &["\u{61}\u{22}"]), ("\u{61}\u{308}\u{22}", &["\u{61}\u{308}\u{22}"]),
- ("\u{61}\u{2c}", &["\u{61}\u{2c}"]), ("\u{61}\u{308}\u{2c}", &["\u{61}\u{308}\u{2c}"]),
- ("\u{61}\u{ad}", &["\u{61}\u{ad}"]), ("\u{61}\u{308}\u{ad}", &["\u{61}\u{308}\u{ad}"]),
- ("\u{61}\u{300}", &["\u{61}\u{300}"]), ("\u{61}\u{308}\u{300}", &["\u{61}\u{308}\u{300}"]),
- ("\u{41}\u{1}", &["\u{41}\u{1}"]), ("\u{41}\u{308}\u{1}", &["\u{41}\u{308}\u{1}"]),
- ("\u{41}\u{d}", &["\u{41}\u{d}"]), ("\u{41}\u{308}\u{d}", &["\u{41}\u{308}\u{d}"]),
- ("\u{41}\u{a}", &["\u{41}\u{a}"]), ("\u{41}\u{308}\u{a}", &["\u{41}\u{308}\u{a}"]),
- ("\u{41}\u{85}", &["\u{41}\u{85}"]), ("\u{41}\u{308}\u{85}", &["\u{41}\u{308}\u{85}"]),
- ("\u{41}\u{9}", &["\u{41}\u{9}"]), ("\u{41}\u{308}\u{9}", &["\u{41}\u{308}\u{9}"]),
- ("\u{41}\u{61}", &["\u{41}\u{61}"]), ("\u{41}\u{308}\u{61}", &["\u{41}\u{308}\u{61}"]),
- ("\u{41}\u{41}", &["\u{41}\u{41}"]), ("\u{41}\u{308}\u{41}", &["\u{41}\u{308}\u{41}"]),
- ("\u{41}\u{1bb}", &["\u{41}\u{1bb}"]), ("\u{41}\u{308}\u{1bb}", &["\u{41}\u{308}\u{1bb}"]),
- ("\u{41}\u{30}", &["\u{41}\u{30}"]), ("\u{41}\u{308}\u{30}", &["\u{41}\u{308}\u{30}"]),
- ("\u{41}\u{2e}", &["\u{41}\u{2e}"]), ("\u{41}\u{308}\u{2e}", &["\u{41}\u{308}\u{2e}"]),
- ("\u{41}\u{21}", &["\u{41}\u{21}"]), ("\u{41}\u{308}\u{21}", &["\u{41}\u{308}\u{21}"]),
- ("\u{41}\u{22}", &["\u{41}\u{22}"]), ("\u{41}\u{308}\u{22}", &["\u{41}\u{308}\u{22}"]),
- ("\u{41}\u{2c}", &["\u{41}\u{2c}"]), ("\u{41}\u{308}\u{2c}", &["\u{41}\u{308}\u{2c}"]),
- ("\u{41}\u{ad}", &["\u{41}\u{ad}"]), ("\u{41}\u{308}\u{ad}", &["\u{41}\u{308}\u{ad}"]),
- ("\u{41}\u{300}", &["\u{41}\u{300}"]), ("\u{41}\u{308}\u{300}", &["\u{41}\u{308}\u{300}"]),
- ("\u{1bb}\u{1}", &["\u{1bb}\u{1}"]), ("\u{1bb}\u{308}\u{1}", &["\u{1bb}\u{308}\u{1}"]),
- ("\u{1bb}\u{d}", &["\u{1bb}\u{d}"]), ("\u{1bb}\u{308}\u{d}", &["\u{1bb}\u{308}\u{d}"]),
- ("\u{1bb}\u{a}", &["\u{1bb}\u{a}"]), ("\u{1bb}\u{308}\u{a}", &["\u{1bb}\u{308}\u{a}"]),
- ("\u{1bb}\u{85}", &["\u{1bb}\u{85}"]), ("\u{1bb}\u{308}\u{85}", &["\u{1bb}\u{308}\u{85}"]),
- ("\u{1bb}\u{9}", &["\u{1bb}\u{9}"]), ("\u{1bb}\u{308}\u{9}", &["\u{1bb}\u{308}\u{9}"]),
- ("\u{1bb}\u{61}", &["\u{1bb}\u{61}"]), ("\u{1bb}\u{308}\u{61}", &["\u{1bb}\u{308}\u{61}"]),
- ("\u{1bb}\u{41}", &["\u{1bb}\u{41}"]), ("\u{1bb}\u{308}\u{41}", &["\u{1bb}\u{308}\u{41}"]),
- ("\u{1bb}\u{1bb}", &["\u{1bb}\u{1bb}"]), ("\u{1bb}\u{308}\u{1bb}",
- &["\u{1bb}\u{308}\u{1bb}"]), ("\u{1bb}\u{30}", &["\u{1bb}\u{30}"]), ("\u{1bb}\u{308}\u{30}",
- &["\u{1bb}\u{308}\u{30}"]), ("\u{1bb}\u{2e}", &["\u{1bb}\u{2e}"]), ("\u{1bb}\u{308}\u{2e}",
- &["\u{1bb}\u{308}\u{2e}"]), ("\u{1bb}\u{21}", &["\u{1bb}\u{21}"]), ("\u{1bb}\u{308}\u{21}",
- &["\u{1bb}\u{308}\u{21}"]), ("\u{1bb}\u{22}", &["\u{1bb}\u{22}"]), ("\u{1bb}\u{308}\u{22}",
- &["\u{1bb}\u{308}\u{22}"]), ("\u{1bb}\u{2c}", &["\u{1bb}\u{2c}"]), ("\u{1bb}\u{308}\u{2c}",
- &["\u{1bb}\u{308}\u{2c}"]), ("\u{1bb}\u{ad}", &["\u{1bb}\u{ad}"]), ("\u{1bb}\u{308}\u{ad}",
- &["\u{1bb}\u{308}\u{ad}"]), ("\u{1bb}\u{300}", &["\u{1bb}\u{300}"]),
- ("\u{1bb}\u{308}\u{300}", &["\u{1bb}\u{308}\u{300}"]), ("\u{30}\u{1}", &["\u{30}\u{1}"]),
- ("\u{30}\u{308}\u{1}", &["\u{30}\u{308}\u{1}"]), ("\u{30}\u{d}", &["\u{30}\u{d}"]),
- ("\u{30}\u{308}\u{d}", &["\u{30}\u{308}\u{d}"]), ("\u{30}\u{a}", &["\u{30}\u{a}"]),
- ("\u{30}\u{308}\u{a}", &["\u{30}\u{308}\u{a}"]), ("\u{30}\u{85}", &["\u{30}\u{85}"]),
- ("\u{30}\u{308}\u{85}", &["\u{30}\u{308}\u{85}"]), ("\u{30}\u{9}", &["\u{30}\u{9}"]),
- ("\u{30}\u{308}\u{9}", &["\u{30}\u{308}\u{9}"]), ("\u{30}\u{61}", &["\u{30}\u{61}"]),
- ("\u{30}\u{308}\u{61}", &["\u{30}\u{308}\u{61}"]), ("\u{30}\u{41}", &["\u{30}\u{41}"]),
- ("\u{30}\u{308}\u{41}", &["\u{30}\u{308}\u{41}"]), ("\u{30}\u{1bb}", &["\u{30}\u{1bb}"]),
- ("\u{30}\u{308}\u{1bb}", &["\u{30}\u{308}\u{1bb}"]), ("\u{30}\u{30}", &["\u{30}\u{30}"]),
- ("\u{30}\u{308}\u{30}", &["\u{30}\u{308}\u{30}"]), ("\u{30}\u{2e}", &["\u{30}\u{2e}"]),
- ("\u{30}\u{308}\u{2e}", &["\u{30}\u{308}\u{2e}"]), ("\u{30}\u{21}", &["\u{30}\u{21}"]),
- ("\u{30}\u{308}\u{21}", &["\u{30}\u{308}\u{21}"]), ("\u{30}\u{22}", &["\u{30}\u{22}"]),
- ("\u{30}\u{308}\u{22}", &["\u{30}\u{308}\u{22}"]), ("\u{30}\u{2c}", &["\u{30}\u{2c}"]),
- ("\u{30}\u{308}\u{2c}", &["\u{30}\u{308}\u{2c}"]), ("\u{30}\u{ad}", &["\u{30}\u{ad}"]),
- ("\u{30}\u{308}\u{ad}", &["\u{30}\u{308}\u{ad}"]), ("\u{30}\u{300}", &["\u{30}\u{300}"]),
- ("\u{30}\u{308}\u{300}", &["\u{30}\u{308}\u{300}"]), ("\u{2e}\u{1}", &["\u{2e}", "\u{1}"]),
- ("\u{2e}\u{308}\u{1}", &["\u{2e}\u{308}", "\u{1}"]), ("\u{2e}\u{d}", &["\u{2e}\u{d}"]),
- ("\u{2e}\u{308}\u{d}", &["\u{2e}\u{308}\u{d}"]), ("\u{2e}\u{a}", &["\u{2e}\u{a}"]),
- ("\u{2e}\u{308}\u{a}", &["\u{2e}\u{308}\u{a}"]), ("\u{2e}\u{85}", &["\u{2e}\u{85}"]),
- ("\u{2e}\u{308}\u{85}", &["\u{2e}\u{308}\u{85}"]), ("\u{2e}\u{9}", &["\u{2e}\u{9}"]),
- ("\u{2e}\u{308}\u{9}", &["\u{2e}\u{308}\u{9}"]), ("\u{2e}\u{61}", &["\u{2e}\u{61}"]),
- ("\u{2e}\u{308}\u{61}", &["\u{2e}\u{308}\u{61}"]), ("\u{2e}\u{41}", &["\u{2e}", "\u{41}"]),
- ("\u{2e}\u{308}\u{41}", &["\u{2e}\u{308}", "\u{41}"]), ("\u{2e}\u{1bb}", &["\u{2e}",
- "\u{1bb}"]), ("\u{2e}\u{308}\u{1bb}", &["\u{2e}\u{308}", "\u{1bb}"]), ("\u{2e}\u{30}",
- &["\u{2e}\u{30}"]), ("\u{2e}\u{308}\u{30}", &["\u{2e}\u{308}\u{30}"]), ("\u{2e}\u{2e}",
- &["\u{2e}\u{2e}"]), ("\u{2e}\u{308}\u{2e}", &["\u{2e}\u{308}\u{2e}"]), ("\u{2e}\u{21}",
- &["\u{2e}\u{21}"]), ("\u{2e}\u{308}\u{21}", &["\u{2e}\u{308}\u{21}"]), ("\u{2e}\u{22}",
- &["\u{2e}\u{22}"]), ("\u{2e}\u{308}\u{22}", &["\u{2e}\u{308}\u{22}"]), ("\u{2e}\u{2c}",
- &["\u{2e}\u{2c}"]), ("\u{2e}\u{308}\u{2c}", &["\u{2e}\u{308}\u{2c}"]), ("\u{2e}\u{ad}",
- &["\u{2e}\u{ad}"]), ("\u{2e}\u{308}\u{ad}", &["\u{2e}\u{308}\u{ad}"]), ("\u{2e}\u{300}",
- &["\u{2e}\u{300}"]), ("\u{2e}\u{308}\u{300}", &["\u{2e}\u{308}\u{300}"]), ("\u{21}\u{1}",
- &["\u{21}", "\u{1}"]), ("\u{21}\u{308}\u{1}", &["\u{21}\u{308}", "\u{1}"]), ("\u{21}\u{d}",
- &["\u{21}\u{d}"]), ("\u{21}\u{308}\u{d}", &["\u{21}\u{308}\u{d}"]), ("\u{21}\u{a}",
- &["\u{21}\u{a}"]), ("\u{21}\u{308}\u{a}", &["\u{21}\u{308}\u{a}"]), ("\u{21}\u{85}",
- &["\u{21}\u{85}"]), ("\u{21}\u{308}\u{85}", &["\u{21}\u{308}\u{85}"]), ("\u{21}\u{9}",
- &["\u{21}\u{9}"]), ("\u{21}\u{308}\u{9}", &["\u{21}\u{308}\u{9}"]), ("\u{21}\u{61}",
- &["\u{21}", "\u{61}"]), ("\u{21}\u{308}\u{61}", &["\u{21}\u{308}", "\u{61}"]),
- ("\u{21}\u{41}", &["\u{21}", "\u{41}"]), ("\u{21}\u{308}\u{41}", &["\u{21}\u{308}",
- "\u{41}"]), ("\u{21}\u{1bb}", &["\u{21}", "\u{1bb}"]), ("\u{21}\u{308}\u{1bb}",
- &["\u{21}\u{308}", "\u{1bb}"]), ("\u{21}\u{30}", &["\u{21}", "\u{30}"]),
- ("\u{21}\u{308}\u{30}", &["\u{21}\u{308}", "\u{30}"]), ("\u{21}\u{2e}", &["\u{21}\u{2e}"]),
- ("\u{21}\u{308}\u{2e}", &["\u{21}\u{308}\u{2e}"]), ("\u{21}\u{21}", &["\u{21}\u{21}"]),
- ("\u{21}\u{308}\u{21}", &["\u{21}\u{308}\u{21}"]), ("\u{21}\u{22}", &["\u{21}\u{22}"]),
- ("\u{21}\u{308}\u{22}", &["\u{21}\u{308}\u{22}"]), ("\u{21}\u{2c}", &["\u{21}\u{2c}"]),
- ("\u{21}\u{308}\u{2c}", &["\u{21}\u{308}\u{2c}"]), ("\u{21}\u{ad}", &["\u{21}\u{ad}"]),
- ("\u{21}\u{308}\u{ad}", &["\u{21}\u{308}\u{ad}"]), ("\u{21}\u{300}", &["\u{21}\u{300}"]),
- ("\u{21}\u{308}\u{300}", &["\u{21}\u{308}\u{300}"]), ("\u{22}\u{1}", &["\u{22}\u{1}"]),
- ("\u{22}\u{308}\u{1}", &["\u{22}\u{308}\u{1}"]), ("\u{22}\u{d}", &["\u{22}\u{d}"]),
- ("\u{22}\u{308}\u{d}", &["\u{22}\u{308}\u{d}"]), ("\u{22}\u{a}", &["\u{22}\u{a}"]),
- ("\u{22}\u{308}\u{a}", &["\u{22}\u{308}\u{a}"]), ("\u{22}\u{85}", &["\u{22}\u{85}"]),
- ("\u{22}\u{308}\u{85}", &["\u{22}\u{308}\u{85}"]), ("\u{22}\u{9}", &["\u{22}\u{9}"]),
- ("\u{22}\u{308}\u{9}", &["\u{22}\u{308}\u{9}"]), ("\u{22}\u{61}", &["\u{22}\u{61}"]),
- ("\u{22}\u{308}\u{61}", &["\u{22}\u{308}\u{61}"]), ("\u{22}\u{41}", &["\u{22}\u{41}"]),
- ("\u{22}\u{308}\u{41}", &["\u{22}\u{308}\u{41}"]), ("\u{22}\u{1bb}", &["\u{22}\u{1bb}"]),
- ("\u{22}\u{308}\u{1bb}", &["\u{22}\u{308}\u{1bb}"]), ("\u{22}\u{30}", &["\u{22}\u{30}"]),
- ("\u{22}\u{308}\u{30}", &["\u{22}\u{308}\u{30}"]), ("\u{22}\u{2e}", &["\u{22}\u{2e}"]),
- ("\u{22}\u{308}\u{2e}", &["\u{22}\u{308}\u{2e}"]), ("\u{22}\u{21}", &["\u{22}\u{21}"]),
- ("\u{22}\u{308}\u{21}", &["\u{22}\u{308}\u{21}"]), ("\u{22}\u{22}", &["\u{22}\u{22}"]),
- ("\u{22}\u{308}\u{22}", &["\u{22}\u{308}\u{22}"]), ("\u{22}\u{2c}", &["\u{22}\u{2c}"]),
- ("\u{22}\u{308}\u{2c}", &["\u{22}\u{308}\u{2c}"]), ("\u{22}\u{ad}", &["\u{22}\u{ad}"]),
- ("\u{22}\u{308}\u{ad}", &["\u{22}\u{308}\u{ad}"]), ("\u{22}\u{300}", &["\u{22}\u{300}"]),
- ("\u{22}\u{308}\u{300}", &["\u{22}\u{308}\u{300}"]), ("\u{2c}\u{1}", &["\u{2c}\u{1}"]),
- ("\u{2c}\u{308}\u{1}", &["\u{2c}\u{308}\u{1}"]), ("\u{2c}\u{d}", &["\u{2c}\u{d}"]),
- ("\u{2c}\u{308}\u{d}", &["\u{2c}\u{308}\u{d}"]), ("\u{2c}\u{a}", &["\u{2c}\u{a}"]),
- ("\u{2c}\u{308}\u{a}", &["\u{2c}\u{308}\u{a}"]), ("\u{2c}\u{85}", &["\u{2c}\u{85}"]),
- ("\u{2c}\u{308}\u{85}", &["\u{2c}\u{308}\u{85}"]), ("\u{2c}\u{9}", &["\u{2c}\u{9}"]),
- ("\u{2c}\u{308}\u{9}", &["\u{2c}\u{308}\u{9}"]), ("\u{2c}\u{61}", &["\u{2c}\u{61}"]),
- ("\u{2c}\u{308}\u{61}", &["\u{2c}\u{308}\u{61}"]), ("\u{2c}\u{41}", &["\u{2c}\u{41}"]),
- ("\u{2c}\u{308}\u{41}", &["\u{2c}\u{308}\u{41}"]), ("\u{2c}\u{1bb}", &["\u{2c}\u{1bb}"]),
- ("\u{2c}\u{308}\u{1bb}", &["\u{2c}\u{308}\u{1bb}"]), ("\u{2c}\u{30}", &["\u{2c}\u{30}"]),
- ("\u{2c}\u{308}\u{30}", &["\u{2c}\u{308}\u{30}"]), ("\u{2c}\u{2e}", &["\u{2c}\u{2e}"]),
- ("\u{2c}\u{308}\u{2e}", &["\u{2c}\u{308}\u{2e}"]), ("\u{2c}\u{21}", &["\u{2c}\u{21}"]),
- ("\u{2c}\u{308}\u{21}", &["\u{2c}\u{308}\u{21}"]), ("\u{2c}\u{22}", &["\u{2c}\u{22}"]),
- ("\u{2c}\u{308}\u{22}", &["\u{2c}\u{308}\u{22}"]), ("\u{2c}\u{2c}", &["\u{2c}\u{2c}"]),
- ("\u{2c}\u{308}\u{2c}", &["\u{2c}\u{308}\u{2c}"]), ("\u{2c}\u{ad}", &["\u{2c}\u{ad}"]),
- ("\u{2c}\u{308}\u{ad}", &["\u{2c}\u{308}\u{ad}"]), ("\u{2c}\u{300}", &["\u{2c}\u{300}"]),
- ("\u{2c}\u{308}\u{300}", &["\u{2c}\u{308}\u{300}"]), ("\u{ad}\u{1}", &["\u{ad}\u{1}"]),
- ("\u{ad}\u{308}\u{1}", &["\u{ad}\u{308}\u{1}"]), ("\u{ad}\u{d}", &["\u{ad}\u{d}"]),
- ("\u{ad}\u{308}\u{d}", &["\u{ad}\u{308}\u{d}"]), ("\u{ad}\u{a}", &["\u{ad}\u{a}"]),
- ("\u{ad}\u{308}\u{a}", &["\u{ad}\u{308}\u{a}"]), ("\u{ad}\u{85}", &["\u{ad}\u{85}"]),
- ("\u{ad}\u{308}\u{85}", &["\u{ad}\u{308}\u{85}"]), ("\u{ad}\u{9}", &["\u{ad}\u{9}"]),
- ("\u{ad}\u{308}\u{9}", &["\u{ad}\u{308}\u{9}"]), ("\u{ad}\u{61}", &["\u{ad}\u{61}"]),
- ("\u{ad}\u{308}\u{61}", &["\u{ad}\u{308}\u{61}"]), ("\u{ad}\u{41}", &["\u{ad}\u{41}"]),
- ("\u{ad}\u{308}\u{41}", &["\u{ad}\u{308}\u{41}"]), ("\u{ad}\u{1bb}", &["\u{ad}\u{1bb}"]),
- ("\u{ad}\u{308}\u{1bb}", &["\u{ad}\u{308}\u{1bb}"]), ("\u{ad}\u{30}", &["\u{ad}\u{30}"]),
- ("\u{ad}\u{308}\u{30}", &["\u{ad}\u{308}\u{30}"]), ("\u{ad}\u{2e}", &["\u{ad}\u{2e}"]),
- ("\u{ad}\u{308}\u{2e}", &["\u{ad}\u{308}\u{2e}"]), ("\u{ad}\u{21}", &["\u{ad}\u{21}"]),
- ("\u{ad}\u{308}\u{21}", &["\u{ad}\u{308}\u{21}"]), ("\u{ad}\u{22}", &["\u{ad}\u{22}"]),
- ("\u{ad}\u{308}\u{22}", &["\u{ad}\u{308}\u{22}"]), ("\u{ad}\u{2c}", &["\u{ad}\u{2c}"]),
- ("\u{ad}\u{308}\u{2c}", &["\u{ad}\u{308}\u{2c}"]), ("\u{ad}\u{ad}", &["\u{ad}\u{ad}"]),
- ("\u{ad}\u{308}\u{ad}", &["\u{ad}\u{308}\u{ad}"]), ("\u{ad}\u{300}", &["\u{ad}\u{300}"]),
- ("\u{ad}\u{308}\u{300}", &["\u{ad}\u{308}\u{300}"]), ("\u{300}\u{1}", &["\u{300}\u{1}"]),
- ("\u{300}\u{308}\u{1}", &["\u{300}\u{308}\u{1}"]), ("\u{300}\u{d}", &["\u{300}\u{d}"]),
- ("\u{300}\u{308}\u{d}", &["\u{300}\u{308}\u{d}"]), ("\u{300}\u{a}", &["\u{300}\u{a}"]),
- ("\u{300}\u{308}\u{a}", &["\u{300}\u{308}\u{a}"]), ("\u{300}\u{85}", &["\u{300}\u{85}"]),
- ("\u{300}\u{308}\u{85}", &["\u{300}\u{308}\u{85}"]), ("\u{300}\u{9}", &["\u{300}\u{9}"]),
- ("\u{300}\u{308}\u{9}", &["\u{300}\u{308}\u{9}"]), ("\u{300}\u{61}", &["\u{300}\u{61}"]),
- ("\u{300}\u{308}\u{61}", &["\u{300}\u{308}\u{61}"]), ("\u{300}\u{41}", &["\u{300}\u{41}"]),
- ("\u{300}\u{308}\u{41}", &["\u{300}\u{308}\u{41}"]), ("\u{300}\u{1bb}",
- &["\u{300}\u{1bb}"]), ("\u{300}\u{308}\u{1bb}", &["\u{300}\u{308}\u{1bb}"]),
- ("\u{300}\u{30}", &["\u{300}\u{30}"]), ("\u{300}\u{308}\u{30}", &["\u{300}\u{308}\u{30}"]),
- ("\u{300}\u{2e}", &["\u{300}\u{2e}"]), ("\u{300}\u{308}\u{2e}", &["\u{300}\u{308}\u{2e}"]),
- ("\u{300}\u{21}", &["\u{300}\u{21}"]), ("\u{300}\u{308}\u{21}", &["\u{300}\u{308}\u{21}"]),
- ("\u{300}\u{22}", &["\u{300}\u{22}"]), ("\u{300}\u{308}\u{22}", &["\u{300}\u{308}\u{22}"]),
- ("\u{300}\u{2c}", &["\u{300}\u{2c}"]), ("\u{300}\u{308}\u{2c}", &["\u{300}\u{308}\u{2c}"]),
- ("\u{300}\u{ad}", &["\u{300}\u{ad}"]), ("\u{300}\u{308}\u{ad}", &["\u{300}\u{308}\u{ad}"]),
- ("\u{300}\u{300}", &["\u{300}\u{300}"]), ("\u{300}\u{308}\u{300}",
- &["\u{300}\u{308}\u{300}"]), ("\u{d}\u{a}\u{61}\u{a}\u{308}", &["\u{d}\u{a}", "\u{61}\u{a}",
- "\u{308}"]), ("\u{61}\u{308}", &["\u{61}\u{308}"]), ("\u{20}\u{200d}\u{646}",
- &["\u{20}\u{200d}\u{646}"]), ("\u{646}\u{200d}\u{20}", &["\u{646}\u{200d}\u{20}"]),
- ("\u{28}\u{22}\u{47}\u{6f}\u{2e}\u{22}\u{29}\u{20}\u{28}\u{48}\u{65}\u{20}\u{64}\u{69}\u{64}\u{2e}\u{29}",
- &["\u{28}\u{22}\u{47}\u{6f}\u{2e}\u{22}\u{29}\u{20}",
- "\u{28}\u{48}\u{65}\u{20}\u{64}\u{69}\u{64}\u{2e}\u{29}"]),
- ("\u{28}\u{201c}\u{47}\u{6f}\u{3f}\u{201d}\u{29}\u{20}\u{28}\u{48}\u{65}\u{20}\u{64}\u{69}\u{64}\u{2e}\u{29}",
- &["\u{28}\u{201c}\u{47}\u{6f}\u{3f}\u{201d}\u{29}\u{20}",
- "\u{28}\u{48}\u{65}\u{20}\u{64}\u{69}\u{64}\u{2e}\u{29}"]),
- ("\u{55}\u{2e}\u{53}\u{2e}\u{41}\u{300}\u{2e}\u{20}\u{69}\u{73}",
- &["\u{55}\u{2e}\u{53}\u{2e}\u{41}\u{300}\u{2e}\u{20}\u{69}\u{73}"]),
- ("\u{55}\u{2e}\u{53}\u{2e}\u{41}\u{300}\u{3f}\u{20}\u{48}\u{65}",
- &["\u{55}\u{2e}\u{53}\u{2e}\u{41}\u{300}\u{3f}\u{20}", "\u{48}\u{65}"]),
- ("\u{55}\u{2e}\u{53}\u{2e}\u{41}\u{300}\u{2e}",
- &["\u{55}\u{2e}\u{53}\u{2e}\u{41}\u{300}\u{2e}"]), ("\u{33}\u{2e}\u{34}",
- &["\u{33}\u{2e}\u{34}"]), ("\u{63}\u{2e}\u{64}", &["\u{63}\u{2e}\u{64}"]),
- ("\u{43}\u{2e}\u{64}", &["\u{43}\u{2e}\u{64}"]), ("\u{63}\u{2e}\u{44}",
- &["\u{63}\u{2e}\u{44}"]), ("\u{43}\u{2e}\u{44}", &["\u{43}\u{2e}\u{44}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{74}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{74}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{54}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}", "\u{54}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{2018}\u{28}\u{74}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{2018}\u{28}\u{74}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{2018}\u{28}\u{54}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}", "\u{2018}\u{28}\u{54}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{308}\u{74}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{308}\u{74}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{308}\u{54}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{a0}\u{308}", "\u{54}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{308}\u{54}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{2019}\u{308}", "\u{54}\u{68}\u{65}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{29}\u{a}\u{308}\u{54}\u{68}\u{65}",
- &["\u{65}\u{74}\u{63}\u{2e}\u{29}\u{a}", "\u{308}\u{54}\u{68}\u{65}"]),
- ("\u{74}\u{68}\u{65}\u{20}\u{72}\u{65}\u{73}\u{70}\u{2e}\u{20}\u{6c}\u{65}\u{61}\u{64}\u{65}\u{72}\u{73}\u{20}\u{61}\u{72}\u{65}",
- &["\u{74}\u{68}\u{65}\u{20}\u{72}\u{65}\u{73}\u{70}\u{2e}\u{20}\u{6c}\u{65}\u{61}\u{64}\u{65}\u{72}\u{73}\u{20}\u{61}\u{72}\u{65}"]),
- ("\u{5b57}\u{2e}\u{5b57}", &["\u{5b57}\u{2e}", "\u{5b57}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{5b83}", &["\u{65}\u{74}\u{63}\u{2e}", "\u{5b83}"]),
- ("\u{65}\u{74}\u{63}\u{2e}\u{3002}", &["\u{65}\u{74}\u{63}\u{2e}\u{3002}"]),
- ("\u{5b57}\u{3002}\u{5b83}", &["\u{5b57}\u{3002}", "\u{5b83}"]), ("\u{21}\u{20}\u{20}",
- &["\u{21}\u{20}\u{20}"]),
- ("\u{2060}\u{28}\u{2060}\u{22}\u{2060}\u{47}\u{2060}\u{6f}\u{2060}\u{2e}\u{2060}\u{22}\u{2060}\u{29}\u{2060}\u{20}\u{2060}\u{28}\u{2060}\u{48}\u{2060}\u{65}\u{2060}\u{20}\u{2060}\u{64}\u{2060}\u{69}\u{2060}\u{64}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2060}",
- &["\u{2060}\u{28}\u{2060}\u{22}\u{2060}\u{47}\u{2060}\u{6f}\u{2060}\u{2e}\u{2060}\u{22}\u{2060}\u{29}\u{2060}\u{20}\u{2060}",
- "\u{28}\u{2060}\u{48}\u{2060}\u{65}\u{2060}\u{20}\u{2060}\u{64}\u{2060}\u{69}\u{2060}\u{64}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2060}"]),
- ("\u{2060}\u{28}\u{2060}\u{201c}\u{2060}\u{47}\u{2060}\u{6f}\u{2060}\u{3f}\u{2060}\u{201d}\u{2060}\u{29}\u{2060}\u{20}\u{2060}\u{28}\u{2060}\u{48}\u{2060}\u{65}\u{2060}\u{20}\u{2060}\u{64}\u{2060}\u{69}\u{2060}\u{64}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2060}",
- &["\u{2060}\u{28}\u{2060}\u{201c}\u{2060}\u{47}\u{2060}\u{6f}\u{2060}\u{3f}\u{2060}\u{201d}\u{2060}\u{29}\u{2060}\u{20}\u{2060}",
- "\u{28}\u{2060}\u{48}\u{2060}\u{65}\u{2060}\u{20}\u{2060}\u{64}\u{2060}\u{69}\u{2060}\u{64}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2060}"]),
- ("\u{2060}\u{55}\u{2060}\u{2e}\u{2060}\u{53}\u{2060}\u{2e}\u{2060}\u{41}\u{2060}\u{300}\u{2e}\u{2060}\u{20}\u{2060}\u{69}\u{2060}\u{73}\u{2060}\u{2060}",
- &["\u{2060}\u{55}\u{2060}\u{2e}\u{2060}\u{53}\u{2060}\u{2e}\u{2060}\u{41}\u{2060}\u{300}\u{2e}\u{2060}\u{20}\u{2060}\u{69}\u{2060}\u{73}\u{2060}\u{2060}"]),
- ("\u{2060}\u{55}\u{2060}\u{2e}\u{2060}\u{53}\u{2060}\u{2e}\u{2060}\u{41}\u{2060}\u{300}\u{3f}\u{2060}\u{20}\u{2060}\u{48}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{55}\u{2060}\u{2e}\u{2060}\u{53}\u{2060}\u{2e}\u{2060}\u{41}\u{2060}\u{300}\u{3f}\u{2060}\u{20}\u{2060}",
- "\u{48}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{55}\u{2060}\u{2e}\u{2060}\u{53}\u{2060}\u{2e}\u{2060}\u{41}\u{2060}\u{300}\u{2e}\u{2060}\u{2060}",
- &["\u{2060}\u{55}\u{2060}\u{2e}\u{2060}\u{53}\u{2060}\u{2e}\u{2060}\u{41}\u{2060}\u{300}\u{2e}\u{2060}\u{2060}"]),
- ("\u{2060}\u{33}\u{2060}\u{2e}\u{2060}\u{34}\u{2060}\u{2060}",
- &["\u{2060}\u{33}\u{2060}\u{2e}\u{2060}\u{34}\u{2060}\u{2060}"]),
- ("\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{64}\u{2060}\u{2060}",
- &["\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{64}\u{2060}\u{2060}"]),
- ("\u{2060}\u{43}\u{2060}\u{2e}\u{2060}\u{64}\u{2060}\u{2060}",
- &["\u{2060}\u{43}\u{2060}\u{2e}\u{2060}\u{64}\u{2060}\u{2060}"]),
- ("\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{44}\u{2060}\u{2060}",
- &["\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{44}\u{2060}\u{2060}"]),
- ("\u{2060}\u{43}\u{2060}\u{2e}\u{2060}\u{44}\u{2060}\u{2060}",
- &["\u{2060}\u{43}\u{2060}\u{2e}\u{2060}\u{44}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}",
- "\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{2018}\u{2060}\u{28}\u{2060}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{2018}\u{2060}\u{28}\u{2060}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{2018}\u{2060}\u{28}\u{2060}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}",
- "\u{2018}\u{2060}\u{28}\u{2060}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{308}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{308}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{308}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{a0}\u{2060}\u{308}",
- "\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{308}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{2019}\u{2060}\u{308}",
- "\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{a}\u{2060}\u{308}\u{2060}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{29}\u{2060}\u{a}",
- "\u{2060}\u{308}\u{2060}\u{54}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{20}\u{2060}\u{72}\u{2060}\u{65}\u{2060}\u{73}\u{2060}\u{70}\u{2060}\u{2e}\u{2060}\u{20}\u{2060}\u{6c}\u{2060}\u{65}\u{2060}\u{61}\u{2060}\u{64}\u{2060}\u{65}\u{2060}\u{72}\u{2060}\u{73}\u{2060}\u{20}\u{2060}\u{61}\u{2060}\u{72}\u{2060}\u{65}\u{2060}\u{2060}",
- &["\u{2060}\u{74}\u{2060}\u{68}\u{2060}\u{65}\u{2060}\u{20}\u{2060}\u{72}\u{2060}\u{65}\u{2060}\u{73}\u{2060}\u{70}\u{2060}\u{2e}\u{2060}\u{20}\u{2060}\u{6c}\u{2060}\u{65}\u{2060}\u{61}\u{2060}\u{64}\u{2060}\u{65}\u{2060}\u{72}\u{2060}\u{73}\u{2060}\u{20}\u{2060}\u{61}\u{2060}\u{72}\u{2060}\u{65}\u{2060}\u{2060}"]),
- ("\u{2060}\u{5b57}\u{2060}\u{2e}\u{2060}\u{5b57}\u{2060}\u{2060}",
- &["\u{2060}\u{5b57}\u{2060}\u{2e}\u{2060}", "\u{5b57}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{5b83}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}",
- "\u{5b83}\u{2060}\u{2060}"]),
- ("\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{3002}\u{2060}\u{2060}",
- &["\u{2060}\u{65}\u{2060}\u{74}\u{2060}\u{63}\u{2060}\u{2e}\u{2060}\u{3002}\u{2060}\u{2060}"]),
- ("\u{2060}\u{5b57}\u{2060}\u{3002}\u{2060}\u{5b83}\u{2060}\u{2060}",
- &["\u{2060}\u{5b57}\u{2060}\u{3002}\u{2060}", "\u{5b83}\u{2060}\u{2060}"]),
- ("\u{2060}\u{21}\u{2060}\u{20}\u{2060}\u{20}\u{2060}\u{2060}",
- &["\u{2060}\u{21}\u{2060}\u{20}\u{2060}\u{20}\u{2060}\u{2060}"])
- ];
-
diff --git a/unicode-segmentation/src/word.rs b/unicode-segmentation/src/word.rs
deleted file mode 100644
index 6e9c049..0000000
--- a/unicode-segmentation/src/word.rs
+++ /dev/null
@@ -1,664 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use core::cmp;
-use core::iter::Filter;
-
-use tables::word::WordCat;
-
-/// An iterator over the substrings of a string which, after splitting the string on
-/// [word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries),
-/// contain any characters with the
-/// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic)
-/// property, or with
-/// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values).
-pub struct UnicodeWords<'a> {
- inner: Filter<UWordBounds<'a>, fn(&&str) -> bool>,
-}
-
-impl<'a> Iterator for UnicodeWords<'a> {
- type Item = &'a str;
-
- #[inline]
- fn next(&mut self) -> Option<&'a str> { self.inner.next() }
-}
-impl<'a> DoubleEndedIterator for UnicodeWords<'a> {
- #[inline]
- fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() }
-}
-
-/// External iterator for a string's
-/// [word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries).
-#[derive(Clone)]
-pub struct UWordBounds<'a> {
- string: &'a str,
- cat: Option<WordCat>,
- catb: Option<WordCat>,
-}
-
-/// External iterator for word boundaries and byte offsets.
-#[derive(Clone)]
-pub struct UWordBoundIndices<'a> {
- start_offset: usize,
- iter: UWordBounds<'a>,
-}
-
-impl<'a> UWordBoundIndices<'a> {
- #[inline]
- /// View the underlying data (the part yet to be iterated) as a slice of the original string.
- ///
- /// ```rust
- /// # use unicode_segmentation::UnicodeSegmentation;
- /// let mut iter = "Hello world".split_word_bound_indices();
- /// assert_eq!(iter.as_str(), "Hello world");
- /// iter.next();
- /// assert_eq!(iter.as_str(), " world");
- /// iter.next();
- /// assert_eq!(iter.as_str(), "world");
- /// ```
- pub fn as_str(&self) -> &'a str {
- self.iter.as_str()
- }
-}
-
-impl<'a> Iterator for UWordBoundIndices<'a> {
- type Item = (usize, &'a str);
-
- #[inline]
- fn next(&mut self) -> Option<(usize, &'a str)> {
- self.iter.next().map(|s| (s.as_ptr() as usize - self.start_offset, s))
- }
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.iter.size_hint()
- }
-}
-
-impl<'a> DoubleEndedIterator for UWordBoundIndices<'a> {
- #[inline]
- fn next_back(&mut self) -> Option<(usize, &'a str)> {
- self.iter.next_back().map(|s| (s.as_ptr() as usize - self.start_offset, s))
- }
-}
-
-// state machine for word boundary rules
-#[derive(Clone,Copy,PartialEq,Eq,Debug)]
-enum UWordBoundsState {
- Start,
- Letter,
- HLetter,
- Numeric,
- Katakana,
- ExtendNumLet,
- Regional(RegionalState),
- FormatExtend(FormatExtendType),
- Zwj,
- Emoji,
- WSegSpace,
-}
-
-// subtypes for FormatExtend state in UWordBoundsState
-#[derive(Clone,Copy,PartialEq,Eq,Debug)]
-enum FormatExtendType {
- AcceptAny,
- AcceptNone,
- RequireLetter,
- RequireHLetter,
- AcceptQLetter,
- RequireNumeric,
-}
-
-#[derive(Clone,Copy,PartialEq,Eq,Debug)]
-enum RegionalState {
- Half,
- Full,
- Unknown,
-}
-
-fn is_emoji(ch: char) -> bool {
- use tables::emoji;
- emoji::emoji_category(ch) == emoji::EmojiCat::EC_Extended_Pictographic
-}
-
-impl<'a> Iterator for UWordBounds<'a> {
- type Item = &'a str;
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- let slen = self.string.len();
- (cmp::min(slen, 1), Some(slen))
- }
-
- #[inline]
- fn next(&mut self) -> Option<&'a str> {
- use self::UWordBoundsState::*;
- use self::FormatExtendType::*;
- use tables::word as wd;
- if self.string.len() == 0 {
- return None;
- }
-
- let mut take_curr = true;
- let mut take_cat = true;
- let mut idx = 0;
- let mut saveidx = 0;
- let mut state = Start;
- let mut cat = wd::WC_Any;
- let mut savecat = wd::WC_Any;
-
- // Whether or not the previous category was ZWJ
- // ZWJs get collapsed, so this handles precedence of WB3c over WB4
- let mut prev_zwj;
- // If extend/format/zwj were skipped. Handles precedence of WB3d over WB4
- let mut skipped_format_extend = false;
- for (curr, ch) in self.string.char_indices() {
- idx = curr;
- prev_zwj = cat == wd::WC_ZWJ;
- // if there's a category cached, grab it
- cat = match self.cat {
- None => wd::word_category(ch),
- _ => self.cat.take().unwrap()
- };
- take_cat = true;
-
- // handle rule WB4
- // just skip all format, extend, and zwj chars
- // note that Start is a special case: if there's a bunch of Format | Extend
- // characters at the beginning of a block of text, dump them out as one unit.
- //
- // (This is not obvious from the wording of UAX#29, but if you look at the
- // test cases http://www.unicode.org/Public/UNIDATA/auxiliary/WordBreakTest.txt
- // then the "correct" interpretation of WB4 becomes apparent.)
- if state != Start {
- match cat {
- wd::WC_Extend | wd::WC_Format | wd::WC_ZWJ => {
- skipped_format_extend = true;
- continue
- }
- _ => {}
- }
- }
-
- // rule WB3c
- // WB4 makes all ZWJs collapse into the previous state
- // but you can still be in a Zwj state if you started with Zwj
- //
- // This means that an EP + Zwj will collapse into EP, which is wrong,
- // since EP+EP is not a boundary but EP+ZWJ+EP is
- //
- // Thus, we separately keep track of whether or not the last character
- // was a ZWJ. This is an additional bit of state tracked outside of the
- // state enum; the state enum represents the last non-zwj state encountered.
- // When prev_zwj is true, for the purposes of WB3c, we are in the Zwj state,
- // however we are in the previous state for the purposes of all other rules.
- if prev_zwj {
- if is_emoji(ch) {
- state = Emoji;
- continue;
- }
- }
- // Don't use `continue` in this match without updating `cat`
- state = match state {
- Start if cat == wd::WC_CR => {
- idx += match self.get_next_cat(idx) {
- Some(ncat) if ncat == wd::WC_LF => 1, // rule WB3
- _ => 0
- };
- break; // rule WB3a
- },
- Start => match cat {
- wd::WC_ALetter => Letter, // rule WB5, WB6, WB9, WB13a
- wd::WC_Hebrew_Letter => HLetter, // rule WB5, WB6, WB7a, WB7b, WB9, WB13a
- wd::WC_Numeric => Numeric, // rule WB8, WB10, WB12, WB13a
- wd::WC_Katakana => Katakana, // rule WB13, WB13a
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a, WB13b
- wd::WC_Regional_Indicator => Regional(RegionalState::Half), // rule WB13c
- wd::WC_LF | wd::WC_Newline => break, // rule WB3a
- wd::WC_ZWJ => Zwj, // rule WB3c
- wd::WC_WSegSpace => WSegSpace, // rule WB3d
- _ => {
- if let Some(ncat) = self.get_next_cat(idx) { // rule WB4
- if ncat == wd::WC_Format || ncat == wd::WC_Extend || ncat == wd::WC_ZWJ {
- state = FormatExtend(AcceptNone);
- self.cat = Some(ncat);
- continue;
- }
- }
- break; // rule WB999
- }
- },
- WSegSpace => match cat {
- wd::WC_WSegSpace if !skipped_format_extend => WSegSpace,
- _ => {
- take_curr = false;
- break;
- }
- },
- Zwj => {
- // We already handle WB3c above.
- take_curr = false;
- break;
- }
- Letter | HLetter => match cat {
- wd::WC_ALetter => Letter, // rule WB5
- wd::WC_Hebrew_Letter => HLetter, // rule WB5
- wd::WC_Numeric => Numeric, // rule WB9
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a
- wd::WC_Double_Quote if state == HLetter => {
- savecat = cat;
- saveidx = idx;
- FormatExtend(RequireHLetter) // rule WB7b
- },
- wd::WC_Single_Quote if state == HLetter => {
- FormatExtend(AcceptQLetter) // rule WB7a
- },
- wd::WC_MidLetter | wd::WC_MidNumLet | wd::WC_Single_Quote => {
- savecat = cat;
- saveidx = idx;
- FormatExtend(RequireLetter) // rule WB6
- },
- _ => {
- take_curr = false;
- break;
- }
- },
- Numeric => match cat {
- wd::WC_Numeric => Numeric, // rule WB8
- wd::WC_ALetter => Letter, // rule WB10
- wd::WC_Hebrew_Letter => HLetter, // rule WB10
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a
- wd::WC_MidNum | wd::WC_MidNumLet | wd::WC_Single_Quote => {
- savecat = cat;
- saveidx = idx;
- FormatExtend(RequireNumeric) // rule WB12
- },
- _ => {
- take_curr = false;
- break;
- }
- },
- Katakana => match cat {
- wd::WC_Katakana => Katakana, // rule WB13
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a
- _ => {
- take_curr = false;
- break;
- }
- },
- ExtendNumLet => match cat {
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a
- wd::WC_ALetter => Letter, // rule WB13b
- wd::WC_Hebrew_Letter => HLetter, // rule WB13b
- wd::WC_Numeric => Numeric, // rule WB13b
- wd::WC_Katakana => Katakana, // rule WB13b
- _ => {
- take_curr = false;
- break;
- }
- },
- Regional(RegionalState::Full) => {
- // if it reaches here we've gone too far,
- // a full flag can only compose with ZWJ/Extend/Format
- // proceeding it.
- take_curr = false;
- break;
- }
- Regional(RegionalState::Half) => match cat {
- wd::WC_Regional_Indicator => Regional(RegionalState::Full), // rule WB13c
- _ => {
- take_curr = false;
- break;
- }
- },
- Regional(_) => unreachable!("RegionalState::Unknown should not occur on forward iteration"),
- Emoji => {
- // We already handle WB3c above. If you've reached this point, the emoji sequence is over.
- take_curr = false;
- break;
- },
- FormatExtend(t) => match t { // handle FormatExtends depending on what type
- RequireNumeric if cat == wd::WC_Numeric => Numeric, // rule WB11
- RequireLetter | AcceptQLetter if cat == wd::WC_ALetter => Letter, // rule WB7
- RequireLetter | AcceptQLetter if cat == wd::WC_Hebrew_Letter => HLetter, // WB7a
- RequireHLetter if cat == wd::WC_Hebrew_Letter => HLetter, // rule WB7b
- AcceptNone | AcceptQLetter => {
- take_curr = false; // emit all the Format|Extend characters
- take_cat = false;
- break;
- },
- _ => break // rewind (in if statement below)
- }
- }
- }
-
- if let FormatExtend(t) = state {
- // we were looking for something and didn't find it; we have to back up
- if t == RequireLetter || t == RequireHLetter || t == RequireNumeric {
- idx = saveidx;
- cat = savecat;
- take_curr = false;
- }
- }
-
- self.cat = if take_curr {
- idx = idx + self.string[idx..].chars().next().unwrap().len_utf8();
- None
- } else if take_cat {
- Some(cat)
- } else {
- None
- };
-
- let retstr = &self.string[..idx];
- self.string = &self.string[idx..];
- Some(retstr)
- }
-}
-
-impl<'a> DoubleEndedIterator for UWordBounds<'a> {
- #[inline]
- fn next_back(&mut self) -> Option<&'a str> {
- use self::UWordBoundsState::*;
- use self::FormatExtendType::*;
- use tables::word as wd;
- if self.string.len() == 0 {
- return None;
- }
-
- let mut take_curr = true;
- let mut take_cat = true;
- let mut idx = self.string.len();
- idx -= self.string.chars().next_back().unwrap().len_utf8();
- let mut previdx = idx;
- let mut saveidx = idx;
- let mut state = Start;
- let mut savestate = Start;
- let mut cat = wd::WC_Any;
-
- let mut skipped_format_extend = false;
-
- for (curr, ch) in self.string.char_indices().rev() {
- previdx = idx;
- idx = curr;
-
- // if there's a category cached, grab it
- cat = match self.catb {
- None => wd::word_category(ch),
- _ => self.catb.take().unwrap()
- };
- take_cat = true;
-
- // backward iterator over word boundaries. Mostly the same as the forward
- // iterator, with two weirdnesses:
- // (1) If we encounter a single quote in the Start state, we have to check for a
- // Hebrew Letter immediately before it.
- // (2) Format and Extend char handling takes some gymnastics.
-
- if cat == wd::WC_Extend
- || cat == wd::WC_Format
- || (cat == wd::WC_ZWJ && state != Zwj) { // WB3c has more priority so we should not
- // fold in that case
- if match state {
- FormatExtend(_) | Start => false,
- _ => true
- } {
- saveidx = previdx;
- savestate = state;
- state = FormatExtend(AcceptNone);
- }
-
- if state != Start {
- continue;
- }
- } else if state == FormatExtend(AcceptNone) {
- // finished a scan of some Format|Extend chars, restore previous state
- state = savestate;
- previdx = saveidx;
- take_cat = false;
- skipped_format_extend = true;
- }
-
- // Don't use `continue` in this match without updating `catb`
- state = match state {
- Start | FormatExtend(AcceptAny) => match cat {
- _ if is_emoji(ch) => Zwj,
- wd::WC_ALetter => Letter, // rule WB5, WB7, WB10, WB13b
- wd::WC_Hebrew_Letter => HLetter, // rule WB5, WB7, WB7c, WB10, WB13b
- wd::WC_Numeric => Numeric, // rule WB8, WB9, WB11, WB13b
- wd::WC_Katakana => Katakana, // rule WB13, WB13b
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a
- wd::WC_Regional_Indicator => Regional(RegionalState::Unknown), // rule WB13c
- // rule WB4:
- wd::WC_Extend | wd::WC_Format | wd::WC_ZWJ => FormatExtend(AcceptAny),
- wd::WC_Single_Quote => {
- saveidx = idx;
- FormatExtend(AcceptQLetter) // rule WB7a
- },
- wd::WC_WSegSpace => WSegSpace,
- wd::WC_CR | wd::WC_LF | wd::WC_Newline => {
- if state == Start {
- if cat == wd::WC_LF {
- idx -= match self.get_prev_cat(idx) {
- Some(pcat) if pcat == wd::WC_CR => 1, // rule WB3
- _ => 0
- };
- }
- } else {
- take_curr = false;
- }
- break; // rule WB3a
- },
- _ => break // rule WB999
- },
- Zwj => match cat { // rule WB3c
- wd::WC_ZWJ => {
- FormatExtend(AcceptAny)
- }
- _ => {
- take_curr = false;
- break;
- }
- },
- WSegSpace => match cat { // rule WB3d
- wd::WC_WSegSpace if !skipped_format_extend => {
- WSegSpace
- }
- _ => {
- take_curr = false;
- break;
- }
- },
- Letter | HLetter => match cat {
- wd::WC_ALetter => Letter, // rule WB5
- wd::WC_Hebrew_Letter => HLetter, // rule WB5
- wd::WC_Numeric => Numeric, // rule WB10
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13b
- wd::WC_Double_Quote if state == HLetter => {
- saveidx = previdx;
- FormatExtend(RequireHLetter) // rule WB7c
- },
- wd::WC_MidLetter | wd::WC_MidNumLet | wd::WC_Single_Quote => {
- saveidx = previdx;
- FormatExtend(RequireLetter) // rule WB7
- },
- _ => {
- take_curr = false;
- break;
- }
- },
- Numeric => match cat {
- wd::WC_Numeric => Numeric, // rule WB8
- wd::WC_ALetter => Letter, // rule WB9
- wd::WC_Hebrew_Letter => HLetter, // rule WB9
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13b
- wd::WC_MidNum | wd::WC_MidNumLet | wd::WC_Single_Quote => {
- saveidx = previdx;
- FormatExtend(RequireNumeric) // rule WB11
- },
- _ => {
- take_curr = false;
- break;
- }
- },
- Katakana => match cat {
- wd::WC_Katakana => Katakana, // rule WB13
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13b
- _ => {
- take_curr = false;
- break;
- }
- },
- ExtendNumLet => match cat {
- wd::WC_ExtendNumLet => ExtendNumLet, // rule WB13a
- wd::WC_ALetter => Letter, // rule WB13a
- wd::WC_Hebrew_Letter => HLetter, // rule WB13a
- wd::WC_Numeric => Numeric, // rule WB13a
- wd::WC_Katakana => Katakana, // rule WB13a
- _ => {
- take_curr = false;
- break;
- }
- },
- Regional(mut regional_state) => match cat {
- // rule WB13c
- wd::WC_Regional_Indicator => {
- if regional_state == RegionalState::Unknown {
- let count = self.string[..previdx]
- .chars().rev()
- .map(|c| wd::word_category(c))
- .filter(|&c| ! (c == wd::WC_ZWJ || c == wd::WC_Extend || c == wd::WC_Format))
- .take_while(|&c| c == wd::WC_Regional_Indicator)
- .count();
- regional_state = if count % 2 == 0 {
- RegionalState::Full
- } else {
- RegionalState::Half
- };
- }
- if regional_state == RegionalState::Full {
- take_curr = false;
- break;
- } else {
- Regional(RegionalState::Full)
- }
- }
- _ => {
- take_curr = false;
- break;
- }
- },
- Emoji => {
- if is_emoji(ch) { // rule WB3c
- Zwj
- } else {
- take_curr = false;
- break;
- }
- },
- FormatExtend(t) => match t {
- RequireNumeric if cat == wd::WC_Numeric => Numeric, // rule WB12
- RequireLetter if cat == wd::WC_ALetter => Letter, // rule WB6
- RequireLetter if cat == wd::WC_Hebrew_Letter => HLetter, // rule WB6
- AcceptQLetter if cat == wd::WC_Hebrew_Letter => HLetter, // rule WB7a
- RequireHLetter if cat == wd::WC_Hebrew_Letter => HLetter, // rule WB7b
- _ => break // backtrack will happens
- }
- }
- }
-
- if let FormatExtend(t) = state {
- // if we required something but didn't find it, backtrack
- if t == RequireLetter || t == RequireHLetter ||
- t == RequireNumeric || t == AcceptNone || t == AcceptQLetter {
- previdx = saveidx;
- take_cat = false;
- take_curr = false;
- }
- }
-
- self.catb = if take_curr {
- None
- } else {
- idx = previdx;
- if take_cat {
- Some(cat)
- } else {
- None
- }
- };
-
- let retstr = &self.string[idx..];
- self.string = &self.string[..idx];
- Some(retstr)
- }
-}
-
-impl<'a> UWordBounds<'a> {
- #[inline]
- /// View the underlying data (the part yet to be iterated) as a slice of the original string.
- ///
- /// ```rust
- /// # use unicode_segmentation::UnicodeSegmentation;
- /// let mut iter = "Hello world".split_word_bounds();
- /// assert_eq!(iter.as_str(), "Hello world");
- /// iter.next();
- /// assert_eq!(iter.as_str(), " world");
- /// iter.next();
- /// assert_eq!(iter.as_str(), "world");
- /// ```
- pub fn as_str(&self) -> &'a str {
- self.string
- }
-
- #[inline]
- fn get_next_cat(&self, idx: usize) -> Option<WordCat> {
- use tables::word as wd;
- let nidx = idx + self.string[idx..].chars().next().unwrap().len_utf8();
- if nidx < self.string.len() {
- let nch = self.string[nidx..].chars().next().unwrap();
- Some(wd::word_category(nch))
- } else {
- None
- }
- }
-
- #[inline]
- fn get_prev_cat(&self, idx: usize) -> Option<WordCat> {
- use tables::word as wd;
- if idx > 0 {
- let nch = self.string[..idx].chars().next_back().unwrap();
- Some(wd::word_category(nch))
- } else {
- None
- }
- }
-}
-
-#[inline]
-pub fn new_word_bounds<'b>(s: &'b str) -> UWordBounds<'b> {
- UWordBounds { string: s, cat: None, catb: None }
-}
-
-#[inline]
-pub fn new_word_bound_indices<'b>(s: &'b str) -> UWordBoundIndices<'b> {
- UWordBoundIndices { start_offset: s.as_ptr() as usize, iter: new_word_bounds(s) }
-}
-
-#[inline]
-pub fn new_unicode_words<'b>(s: &'b str) -> UnicodeWords<'b> {
- use super::UnicodeSegmentation;
- use tables::util::is_alphanumeric;
-
- fn has_alphanumeric(s: &&str) -> bool { s.chars().any(|c| is_alphanumeric(c)) }
- let has_alphanumeric: fn(&&str) -> bool = has_alphanumeric; // coerce to fn pointer
-
- UnicodeWords { inner: s.split_word_bounds().filter(has_alphanumeric) }
-}
diff --git a/unicode-width/.gitignore b/unicode-width/.gitignore
deleted file mode 100644
index 5cdcdba..0000000
--- a/unicode-width/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-target
-Cargo.lock
-scripts/tmp
diff --git a/unicode-width/.travis.yml b/unicode-width/.travis.yml
deleted file mode 100644
index 64196fa..0000000
--- a/unicode-width/.travis.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-language: rust
-rust: 'nightly'
-sudo: false
-script:
- - cargo build --verbose --features bench
- - cargo test --verbose --features bench
- - cargo bench --verbose --features bench
- - cargo clean
- - cargo build --verbose
- - cargo test --verbose
-# next line is an ugly hack to fix an annoying bug where rustdoc tries to use the rustc_private unicode_width crate
-# (there is probably a better fix than this)
- - rm $(find /home/travis/.rustup -type f -name 'libunicode_width*')
- - rustdoc --test README.md -L target/debug -L target/debug/deps
- - cargo doc
-after_success: |
- [ $TRAVIS_BRANCH = master ] &&
- [ $TRAVIS_PULL_REQUEST = false ] &&
- echo '<meta http-equiv=refresh content=0;url=unicode_width/index.html>' > target/doc/index.html &&
- pip install ghp-import --user $USER &&
- $HOME/.local/bin/ghp-import -n target/doc &&
- git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
-env:
- global:
- secure: vHL3zrN8AF+H79jrB8OfzuPqsUHevo6ECzwqXPj2dMSqcSXEeCY/ENAfiyFg+oW8yEVP8X2BS1a/C9yvVQRLqLbm1HbZ/5vUpoggT9S0IhKqZMyAcLYXfIEUDMDQuaSdFndDaHvq8275ScgX1LRv1kcPjQoZHuaXWMH8y/Suvyo=
-notifications:
- email:
- on_success: never
diff --git a/unicode-width/COPYRIGHT b/unicode-width/COPYRIGHT
deleted file mode 100644
index b286ec1..0000000
--- a/unicode-width/COPYRIGHT
+++ /dev/null
@@ -1,7 +0,0 @@
-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.
diff --git a/unicode-width/Cargo.toml b/unicode-width/Cargo.toml
deleted file mode 100644
index 35228f2..0000000
--- a/unicode-width/Cargo.toml
+++ /dev/null
@@ -1,29 +0,0 @@
-[package]
-
-name = "unicode-width"
-version = "0.1.7"
-authors = ["kwantam <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"]
-
-homepage = "https://github.com/unicode-rs/unicode-width"
-repository = "https://github.com/unicode-rs/unicode-width"
-documentation = "https://unicode-rs.github.io/unicode-width"
-license = "MIT/Apache-2.0"
-keywords = ["text", "width", "unicode"]
-readme = "README.md"
-description = """
-Determine displayed width of `char` and `str` types
-according to Unicode Standard Annex #11 rules.
-"""
-
-exclude = [ "target/*", "Cargo.lock" ]
-
-[dependencies]
-std = { version = "1.0", package = "rustc-std-workspace-std", optional = true }
-core = { version = "1.0", package = "rustc-std-workspace-core", optional = true }
-compiler_builtins = { version = "0.1", optional = true }
-
-[features]
-default = []
-no_std = []
-bench = []
-rustc-dep-of-std = ['std', 'core', 'compiler_builtins']
diff --git a/unicode-width/LICENSE-APACHE b/unicode-width/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/unicode-width/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/unicode-width/LICENSE-MIT b/unicode-width/LICENSE-MIT
deleted file mode 100644
index e69282e..0000000
--- a/unicode-width/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2015 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/unicode-width/README.md b/unicode-width/README.md
deleted file mode 100644
index 595e163..0000000
--- a/unicode-width/README.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# unicode-width
-
-Determine displayed width of `char` and `str` types according to
-[Unicode Standard Annex #11][UAX11] rules.
-
-[UAX11]: http://www.unicode.org/reports/tr11/
-
-[![Build Status](https://travis-ci.org/unicode-rs/unicode-width.svg)](https://travis-ci.org/unicode-rs/unicode-width)
-
-[Documentation](https://unicode-rs.github.io/unicode-width/unicode_width/index.html)
-
-```rust
-extern crate unicode_width;
-
-use unicode_width::UnicodeWidthStr;
-
-fn main() {
- let teststr = "Hello, world!";
- let width = UnicodeWidthStr::width(teststr);
- println!("{}", teststr);
- println!("The above string is {} columns wide.", width);
- let width = teststr.width_cjk();
- println!("The above string is {} columns wide (CJK).", width);
-}
-```
-
-**NOTE:** The computed width values may not match the actual rendered column
-width. For example, the woman scientist emoji comprises of a woman emoji, a
-zero-width joiner and a microscope emoji.
-
-```rust
-extern crate unicode_width;
-use unicode_width::UnicodeWidthStr;
-
-fn main() {
- assert_eq!(UnicodeWidthStr::width("👩"), 2); // Woman
- assert_eq!(UnicodeWidthStr::width("🔬"), 2); // Microscope
- assert_eq!(UnicodeWidthStr::width("👩‍🔬"), 4); // Woman scientist
-}
-```
-
-See [Unicode Standard Annex #11][UAX11] for precise details on what is and isn't
-covered by this crate.
-
-## features
-
-unicode-width does not depend on libstd, so it can be used in crates
-with the `#![no_std]` attribute.
-
-## crates.io
-
-You can use this package in your project by adding the following
-to your `Cargo.toml`:
-
-```toml
-[dependencies]
-unicode-width = "0.1.7"
-```
diff --git a/unicode-width/scripts/unicode.py b/unicode-width/scripts/unicode.py
deleted file mode 100755
index 5456ee3..0000000
--- a/unicode-width/scripts/unicode.py
+++ /dev/null
@@ -1,321 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright 2011-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.
-
-# This script uses the following Unicode tables:
-# - EastAsianWidth.txt
-# - ReadMe.txt
-# - UnicodeData.txt
-#
-# Since this should not require frequent updates, we just store this
-# out-of-line and check the unicode.rs file into git.
-
-import fileinput, re, os, sys, operator
-
-preamble = '''// 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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
-'''
-
-# Mapping taken from Table 12 from:
-# http://www.unicode.org/reports/tr44/#General_Category_Values
-expanded_categories = {
- 'Lu': ['LC', 'L'], 'Ll': ['LC', 'L'], 'Lt': ['LC', 'L'],
- 'Lm': ['L'], 'Lo': ['L'],
- 'Mn': ['M'], 'Mc': ['M'], 'Me': ['M'],
- 'Nd': ['N'], 'Nl': ['N'], 'No': ['No'],
- 'Pc': ['P'], 'Pd': ['P'], 'Ps': ['P'], 'Pe': ['P'],
- 'Pi': ['P'], 'Pf': ['P'], 'Po': ['P'],
- 'Sm': ['S'], 'Sc': ['S'], 'Sk': ['S'], 'So': ['S'],
- 'Zs': ['Z'], 'Zl': ['Z'], 'Zp': ['Z'],
- 'Cc': ['C'], 'Cf': ['C'], 'Cs': ['C'], 'Co': ['C'], 'Cn': ['C'],
-}
-
-# these are the surrogate codepoints, which are not valid rust characters
-surrogate_codepoints = (0xd800, 0xdfff)
-
-def fetch(f):
- if not os.path.exists(os.path.basename(f)):
- os.system("curl -O http://www.unicode.org/Public/UNIDATA/%s"
- % f)
-
- if not os.path.exists(os.path.basename(f)):
- sys.stderr.write("cannot load %s" % f)
- exit(1)
-
-def is_surrogate(n):
- return surrogate_codepoints[0] <= n <= surrogate_codepoints[1]
-
-def load_unicode_data(f):
- fetch(f)
- gencats = {}
-
- udict = {}
- range_start = -1
- for line in fileinput.input(f):
- data = line.split(';')
- if len(data) != 15:
- continue
- cp = int(data[0], 16)
- if is_surrogate(cp):
- continue
- if range_start >= 0:
- for i in range(range_start, cp):
- udict[i] = data
- range_start = -1
- if data[1].endswith(", First>"):
- range_start = cp
- continue
- udict[cp] = data
-
- for code in udict:
- [code_org, name, gencat, combine, bidi,
- decomp, deci, digit, num, mirror,
- old, iso, upcase, lowcase, titlecase ] = udict[code]
-
- # place letter in categories as appropriate
- for cat in [gencat, "Assigned"] + expanded_categories.get(gencat, []):
- if cat not in gencats:
- gencats[cat] = []
- gencats[cat].append(code)
-
- gencats = group_cats(gencats)
-
- return gencats
-
-def group_cats(cats):
- cats_out = {}
- for cat in cats:
- cats_out[cat] = group_cat(cats[cat])
- return cats_out
-
-def group_cat(cat):
- cat_out = []
- letters = sorted(set(cat))
- cur_start = letters.pop(0)
- cur_end = cur_start
- for letter in letters:
- assert letter > cur_end, \
- "cur_end: %s, letter: %s" % (hex(cur_end), hex(letter))
- if letter == cur_end + 1:
- cur_end = letter
- else:
- cat_out.append((cur_start, cur_end))
- cur_start = cur_end = letter
- cat_out.append((cur_start, cur_end))
- return cat_out
-
-def format_table_content(f, content, indent):
- line = " "*indent
- first = True
- for chunk in content.split(","):
- if len(line) + len(chunk) < 98:
- if first:
- line += chunk
- else:
- line += ", " + chunk
- first = False
- else:
- f.write(line + ",\n")
- line = " "*indent + chunk
- f.write(line)
-
-# load all widths of want_widths, except those in except_cats
-def load_east_asian_width(want_widths, except_cats):
- f = "EastAsianWidth.txt"
- fetch(f)
- widths = {}
- re1 = re.compile("^([0-9A-F]+);(\w+) +# (\w+)")
- re2 = re.compile("^([0-9A-F]+)\.\.([0-9A-F]+);(\w+) +# (\w+)")
-
- for line in fileinput.input(f):
- width = None
- d_lo = 0
- d_hi = 0
- cat = None
- m = re1.match(line)
- if m:
- d_lo = m.group(1)
- d_hi = m.group(1)
- width = m.group(2)
- cat = m.group(3)
- else:
- m = re2.match(line)
- if m:
- d_lo = m.group(1)
- d_hi = m.group(2)
- width = m.group(3)
- cat = m.group(4)
- else:
- continue
- if cat in except_cats or width not in want_widths:
- continue
- d_lo = int(d_lo, 16)
- d_hi = int(d_hi, 16)
- if width not in widths:
- widths[width] = []
- widths[width].append((d_lo, d_hi))
- return widths
-
-def escape_char(c):
- return "'\\u{%x}'" % c
-
-def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
- pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1])), is_const=True):
- pub_string = "const"
- if not is_const:
- pub_string = "let"
- if is_pub:
- pub_string = "pub " + pub_string
- f.write(" %s %s: %s = &[\n" % (pub_string, name, t_type))
- data = ""
- first = True
- for dat in t_data:
- if not first:
- data += ","
- first = False
- data += pfun(dat)
- format_table_content(f, data, 8)
- f.write("\n ];\n\n")
-
-def emit_charwidth_module(f, width_table):
- f.write("pub mod charwidth {")
- f.write("""
- use core::option::Option::{self, Some, None};
- use core::result::Result::{Ok, Err};
-
- #[inline]
- fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, r_ncjk, r_cjk) = r[idx];
- if is_cjk { r_cjk } else { r_ncjk }
- }
- Err(_) => 1
- }
- }
-""")
-
- f.write("""
- #[inline]
- pub fn width(c: char, is_cjk: bool) -> Option<usize> {
- match c as usize {
- _c @ 0 => Some(0), // null is zero width
- cu if cu < 0x20 => None, // control sequences have no width
- cu if cu < 0x7F => Some(1), // ASCII
- cu if cu < 0xA0 => None, // more control sequences
- _ => Some(bsearch_range_value_table(c, is_cjk, charwidth_table) as usize)
- }
- }
-
-""")
-
- f.write(" // character width table. Based on Markus Kuhn's free wcwidth() implementation,\n")
- f.write(" // http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c\n")
- emit_table(f, "charwidth_table", width_table, "&'static [(char, char, u8, u8)]", is_pub=False,
- pfun=lambda x: "(%s,%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), x[2], x[3]))
- f.write("}\n\n")
-
-def remove_from_wtable(wtable, val):
- wtable_out = []
- while wtable:
- if wtable[0][1] < val:
- wtable_out.append(wtable.pop(0))
- elif wtable[0][0] > val:
- break
- else:
- (wt_lo, wt_hi, width, width_cjk) = wtable.pop(0)
- if wt_lo == wt_hi == val:
- continue
- elif wt_lo == val:
- wtable_out.append((wt_lo+1, wt_hi, width, width_cjk))
- elif wt_hi == val:
- wtable_out.append((wt_lo, wt_hi-1, width, width_cjk))
- else:
- wtable_out.append((wt_lo, val-1, width, width_cjk))
- wtable_out.append((val+1, wt_hi, width, width_cjk))
- if wtable:
- wtable_out.extend(wtable)
- return wtable_out
-
-
-
-def optimize_width_table(wtable):
- wtable_out = []
- w_this = wtable.pop(0)
- while wtable:
- if w_this[1] == wtable[0][0] - 1 and w_this[2:3] == wtable[0][2:3]:
- w_tmp = wtable.pop(0)
- w_this = (w_this[0], w_tmp[1], w_tmp[2], w_tmp[3])
- else:
- wtable_out.append(w_this)
- w_this = wtable.pop(0)
- wtable_out.append(w_this)
- return wtable_out
-
-if __name__ == "__main__":
- r = "tables.rs"
- if os.path.exists(r):
- os.remove(r)
- with open(r, "w") as rf:
- # write the file's preamble
- rf.write(preamble)
-
- # download and parse all the data
- fetch("ReadMe.txt")
- with open("ReadMe.txt") as readme:
- pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode"
- unicode_version = re.search(pattern, readme.read()).groups()
- rf.write("""
-/// The version of [Unicode](http://www.unicode.org/)
-/// that this version of unicode-width is based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
-
-""" % unicode_version)
- gencats = load_unicode_data("UnicodeData.txt")
-
- ### character width module
- width_table = []
- for zwcat in ["Me", "Mn", "Cf"]:
- width_table.extend([(lo_hi[0], lo_hi[1], 0, 0) for lo_hi in gencats[zwcat]])
- width_table.append((4448, 4607, 0, 0))
-
- # get widths, except those that are explicitly marked zero-width above
- ea_widths = load_east_asian_width(["W", "F", "A"], ["Me", "Mn", "Cf"])
- # these are doublewidth
- for dwcat in ["W", "F"]:
- width_table.extend([(lo_hi1[0], lo_hi1[1], 2, 2) for lo_hi1 in ea_widths[dwcat]])
- width_table.extend([(lo_hi2[0], lo_hi2[1], 1, 2) for lo_hi2 in ea_widths["A"]])
-
- width_table.sort(key=lambda w: w[0])
-
- # soft hyphen is not zero width in preformatted text; it's used to indicate
- # a hyphen inserted to facilitate a linebreak.
- width_table = remove_from_wtable(width_table, 173)
-
- # optimize the width table by collapsing adjacent entities when possible
- width_table = optimize_width_table(width_table)
- emit_charwidth_module(rf, width_table)
diff --git a/unicode-width/src/lib.rs b/unicode-width/src/lib.rs
deleted file mode 100644
index 1ee35c8..0000000
--- a/unicode-width/src/lib.rs
+++ /dev/null
@@ -1,131 +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.
-
-//! Determine displayed width of `char` and `str` types according to
-//! [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
-//! rules.
-//!
-//! ```rust
-//! extern crate unicode_width;
-//!
-//! use unicode_width::UnicodeWidthStr;
-//!
-//! fn main() {
-//! let teststr = "Hello, world!";
-//! let width = UnicodeWidthStr::width(teststr);
-//! println!("{}", teststr);
-//! println!("The above string is {} columns wide.", width);
-//! let width = teststr.width_cjk();
-//! println!("The above string is {} columns wide (CJK).", width);
-//! }
-//! ```
-//!
-//! # features
-//!
-//! unicode-width supports a `no_std` feature. This eliminates dependence
-//! on std, and instead uses equivalent functions from core.
-//!
-//! # crates.io
-//!
-//! You can use this package in your project by adding the following
-//! to your `Cargo.toml`:
-//!
-//! ```toml
-//! [dependencies]
-//! unicode-width = "0.1.5"
-//! ```
-
-#![deny(missing_docs, unsafe_code)]
-#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png",
- html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")]
-
-#![cfg_attr(feature = "bench", feature(test))]
-#![no_std]
-
-#[cfg(test)]
-#[macro_use]
-extern crate std;
-
-#[cfg(feature = "bench")]
-extern crate test;
-
-use tables::charwidth as cw;
-pub use tables::UNICODE_VERSION;
-
-use core::ops::Add;
-
-mod tables;
-
-#[cfg(test)]
-mod tests;
-
-/// Methods for determining displayed width of Unicode characters.
-pub trait UnicodeWidthChar {
- /// Returns the character's displayed width in columns, or `None` if the
- /// character is a control character other than `'\x00'`.
- ///
- /// This function treats characters in the Ambiguous category according
- /// to [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
- /// as 1 column wide. This is consistent with the recommendations for non-CJK
- /// contexts, or when the context cannot be reliably determined.
- fn width(self) -> Option<usize>;
-
- /// Returns the character's displayed width in columns, or `None` if the
- /// character is a control character other than `'\x00'`.
- ///
- /// This function treats characters in the Ambiguous category according
- /// to [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
- /// as 2 columns wide. This is consistent with the recommendations for
- /// CJK contexts.
- fn width_cjk(self) -> Option<usize>;
-}
-
-impl UnicodeWidthChar for char {
- #[inline]
- fn width(self) -> Option<usize> { cw::width(self, false) }
-
- #[inline]
- fn width_cjk(self) -> Option<usize> { cw::width(self, true) }
-}
-
-/// Methods for determining displayed width of Unicode strings.
-pub trait UnicodeWidthStr {
- /// Returns the string's displayed width in columns.
- ///
- /// Control characters are treated as having zero width.
- ///
- /// This function treats characters in the Ambiguous category according
- /// to [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
- /// as 1 column wide. This is consistent with the recommendations for
- /// non-CJK contexts, or when the context cannot be reliably determined.
- fn width<'a>(&'a self) -> usize;
-
- /// Returns the string's displayed width in columns.
- ///
- /// Control characters are treated as having zero width.
- ///
- /// This function treats characters in the Ambiguous category according
- /// to [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
- /// as 2 column wide. This is consistent with the recommendations for
- /// CJK contexts.
- fn width_cjk<'a>(&'a self) -> usize;
-}
-
-impl UnicodeWidthStr for str {
- #[inline]
- fn width(&self) -> usize {
- self.chars().map(|c| cw::width(c, false).unwrap_or(0)).fold(0, Add::add)
- }
-
- #[inline]
- fn width_cjk(&self) -> usize {
- self.chars().map(|c| cw::width(c, true).unwrap_or(0)).fold(0, Add::add)
- }
-}
diff --git a/unicode-width/src/tables.rs b/unicode-width/src/tables.rs
deleted file mode 100644
index 7ae450b..0000000
--- a/unicode-width/src/tables.rs
+++ /dev/null
@@ -1,284 +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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
-
-/// The version of [Unicode](http://www.unicode.org/)
-/// that this version of unicode-width is based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (12, 1, 0);
-
-pub mod charwidth {
- use core::option::Option::{self, Some, None};
- use core::result::Result::{Ok, Err};
-
- #[inline]
- fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
- use core::cmp::Ordering::{Equal, Less, Greater};
- match r.binary_search_by(|&(lo, hi, _, _)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }) {
- Ok(idx) => {
- let (_, _, r_ncjk, r_cjk) = r[idx];
- if is_cjk { r_cjk } else { r_ncjk }
- }
- Err(_) => 1
- }
- }
-
- #[inline]
- pub fn width(c: char, is_cjk: bool) -> Option<usize> {
- match c as usize {
- _c @ 0 => Some(0), // null is zero width
- cu if cu < 0x20 => None, // control sequences have no width
- cu if cu < 0x7F => Some(1), // ASCII
- cu if cu < 0xA0 => None, // more control sequences
- _ => Some(bsearch_range_value_table(c, is_cjk, charwidth_table) as usize)
- }
- }
-
- // character width table. Based on Markus Kuhn's free wcwidth() implementation,
- // http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
- const charwidth_table: &'static [(char, char, u8, u8)] = &[
- ('\u{a1}', '\u{a1}', 1, 2), ('\u{a4}', '\u{a4}', 1, 2), ('\u{a7}', '\u{a8}', 1, 2),
- ('\u{aa}', '\u{aa}', 1, 2), ('\u{ae}', '\u{ae}', 1, 2), ('\u{b0}', '\u{b4}', 1, 2),
- ('\u{b6}', '\u{ba}', 1, 2), ('\u{bc}', '\u{bf}', 1, 2), ('\u{c6}', '\u{c6}', 1, 2),
- ('\u{d0}', '\u{d0}', 1, 2), ('\u{d7}', '\u{d8}', 1, 2), ('\u{de}', '\u{e1}', 1, 2),
- ('\u{e6}', '\u{e6}', 1, 2), ('\u{e8}', '\u{ea}', 1, 2), ('\u{ec}', '\u{ed}', 1, 2),
- ('\u{f0}', '\u{f0}', 1, 2), ('\u{f2}', '\u{f3}', 1, 2), ('\u{f7}', '\u{fa}', 1, 2),
- ('\u{fc}', '\u{fc}', 1, 2), ('\u{fe}', '\u{fe}', 1, 2), ('\u{101}', '\u{101}', 1, 2),
- ('\u{111}', '\u{111}', 1, 2), ('\u{113}', '\u{113}', 1, 2), ('\u{11b}', '\u{11b}', 1, 2),
- ('\u{126}', '\u{127}', 1, 2), ('\u{12b}', '\u{12b}', 1, 2), ('\u{131}', '\u{133}', 1, 2),
- ('\u{138}', '\u{138}', 1, 2), ('\u{13f}', '\u{142}', 1, 2), ('\u{144}', '\u{144}', 1, 2),
- ('\u{148}', '\u{14b}', 1, 2), ('\u{14d}', '\u{14d}', 1, 2), ('\u{152}', '\u{153}', 1, 2),
- ('\u{166}', '\u{167}', 1, 2), ('\u{16b}', '\u{16b}', 1, 2), ('\u{1ce}', '\u{1ce}', 1, 2),
- ('\u{1d0}', '\u{1d0}', 1, 2), ('\u{1d2}', '\u{1d2}', 1, 2), ('\u{1d4}', '\u{1d4}', 1, 2),
- ('\u{1d6}', '\u{1d6}', 1, 2), ('\u{1d8}', '\u{1d8}', 1, 2), ('\u{1da}', '\u{1da}', 1, 2),
- ('\u{1dc}', '\u{1dc}', 1, 2), ('\u{251}', '\u{251}', 1, 2), ('\u{261}', '\u{261}', 1, 2),
- ('\u{2c4}', '\u{2c4}', 1, 2), ('\u{2c7}', '\u{2c7}', 1, 2), ('\u{2c9}', '\u{2cb}', 1, 2),
- ('\u{2cd}', '\u{2cd}', 1, 2), ('\u{2d0}', '\u{2d0}', 1, 2), ('\u{2d8}', '\u{2db}', 1, 2),
- ('\u{2dd}', '\u{2dd}', 1, 2), ('\u{2df}', '\u{2df}', 1, 2), ('\u{300}', '\u{36f}', 0, 0),
- ('\u{391}', '\u{3a1}', 1, 2), ('\u{3a3}', '\u{3a9}', 1, 2), ('\u{3b1}', '\u{3c1}', 1, 2),
- ('\u{3c3}', '\u{3c9}', 1, 2), ('\u{401}', '\u{401}', 1, 2), ('\u{410}', '\u{44f}', 1, 2),
- ('\u{451}', '\u{451}', 1, 2), ('\u{483}', '\u{489}', 0, 0), ('\u{591}', '\u{5bd}', 0, 0),
- ('\u{5bf}', '\u{5bf}', 0, 0), ('\u{5c1}', '\u{5c2}', 0, 0), ('\u{5c4}', '\u{5c5}', 0, 0),
- ('\u{5c7}', '\u{5c7}', 0, 0), ('\u{600}', '\u{605}', 0, 0), ('\u{610}', '\u{61a}', 0, 0),
- ('\u{61c}', '\u{61c}', 0, 0), ('\u{64b}', '\u{65f}', 0, 0), ('\u{670}', '\u{670}', 0, 0),
- ('\u{6d6}', '\u{6dd}', 0, 0), ('\u{6df}', '\u{6e4}', 0, 0), ('\u{6e7}', '\u{6e8}', 0, 0),
- ('\u{6ea}', '\u{6ed}', 0, 0), ('\u{70f}', '\u{70f}', 0, 0), ('\u{711}', '\u{711}', 0, 0),
- ('\u{730}', '\u{74a}', 0, 0), ('\u{7a6}', '\u{7b0}', 0, 0), ('\u{7eb}', '\u{7f3}', 0, 0),
- ('\u{7fd}', '\u{7fd}', 0, 0), ('\u{816}', '\u{819}', 0, 0), ('\u{81b}', '\u{823}', 0, 0),
- ('\u{825}', '\u{827}', 0, 0), ('\u{829}', '\u{82d}', 0, 0), ('\u{859}', '\u{85b}', 0, 0),
- ('\u{8d3}', '\u{902}', 0, 0), ('\u{93a}', '\u{93a}', 0, 0), ('\u{93c}', '\u{93c}', 0, 0),
- ('\u{941}', '\u{948}', 0, 0), ('\u{94d}', '\u{94d}', 0, 0), ('\u{951}', '\u{957}', 0, 0),
- ('\u{962}', '\u{963}', 0, 0), ('\u{981}', '\u{981}', 0, 0), ('\u{9bc}', '\u{9bc}', 0, 0),
- ('\u{9c1}', '\u{9c4}', 0, 0), ('\u{9cd}', '\u{9cd}', 0, 0), ('\u{9e2}', '\u{9e3}', 0, 0),
- ('\u{9fe}', '\u{9fe}', 0, 0), ('\u{a01}', '\u{a02}', 0, 0), ('\u{a3c}', '\u{a3c}', 0, 0),
- ('\u{a41}', '\u{a42}', 0, 0), ('\u{a47}', '\u{a48}', 0, 0), ('\u{a4b}', '\u{a4d}', 0, 0),
- ('\u{a51}', '\u{a51}', 0, 0), ('\u{a70}', '\u{a71}', 0, 0), ('\u{a75}', '\u{a75}', 0, 0),
- ('\u{a81}', '\u{a82}', 0, 0), ('\u{abc}', '\u{abc}', 0, 0), ('\u{ac1}', '\u{ac5}', 0, 0),
- ('\u{ac7}', '\u{ac8}', 0, 0), ('\u{acd}', '\u{acd}', 0, 0), ('\u{ae2}', '\u{ae3}', 0, 0),
- ('\u{afa}', '\u{aff}', 0, 0), ('\u{b01}', '\u{b01}', 0, 0), ('\u{b3c}', '\u{b3c}', 0, 0),
- ('\u{b3f}', '\u{b3f}', 0, 0), ('\u{b41}', '\u{b44}', 0, 0), ('\u{b4d}', '\u{b4d}', 0, 0),
- ('\u{b56}', '\u{b56}', 0, 0), ('\u{b62}', '\u{b63}', 0, 0), ('\u{b82}', '\u{b82}', 0, 0),
- ('\u{bc0}', '\u{bc0}', 0, 0), ('\u{bcd}', '\u{bcd}', 0, 0), ('\u{c00}', '\u{c00}', 0, 0),
- ('\u{c04}', '\u{c04}', 0, 0), ('\u{c3e}', '\u{c40}', 0, 0), ('\u{c46}', '\u{c48}', 0, 0),
- ('\u{c4a}', '\u{c4d}', 0, 0), ('\u{c55}', '\u{c56}', 0, 0), ('\u{c62}', '\u{c63}', 0, 0),
- ('\u{c81}', '\u{c81}', 0, 0), ('\u{cbc}', '\u{cbc}', 0, 0), ('\u{cbf}', '\u{cbf}', 0, 0),
- ('\u{cc6}', '\u{cc6}', 0, 0), ('\u{ccc}', '\u{ccd}', 0, 0), ('\u{ce2}', '\u{ce3}', 0, 0),
- ('\u{d00}', '\u{d01}', 0, 0), ('\u{d3b}', '\u{d3c}', 0, 0), ('\u{d41}', '\u{d44}', 0, 0),
- ('\u{d4d}', '\u{d4d}', 0, 0), ('\u{d62}', '\u{d63}', 0, 0), ('\u{dca}', '\u{dca}', 0, 0),
- ('\u{dd2}', '\u{dd4}', 0, 0), ('\u{dd6}', '\u{dd6}', 0, 0), ('\u{e31}', '\u{e31}', 0, 0),
- ('\u{e34}', '\u{e3a}', 0, 0), ('\u{e47}', '\u{e4e}', 0, 0), ('\u{eb1}', '\u{eb1}', 0, 0),
- ('\u{eb4}', '\u{ebc}', 0, 0), ('\u{ec8}', '\u{ecd}', 0, 0), ('\u{f18}', '\u{f19}', 0, 0),
- ('\u{f35}', '\u{f35}', 0, 0), ('\u{f37}', '\u{f37}', 0, 0), ('\u{f39}', '\u{f39}', 0, 0),
- ('\u{f71}', '\u{f7e}', 0, 0), ('\u{f80}', '\u{f84}', 0, 0), ('\u{f86}', '\u{f87}', 0, 0),
- ('\u{f8d}', '\u{f97}', 0, 0), ('\u{f99}', '\u{fbc}', 0, 0), ('\u{fc6}', '\u{fc6}', 0, 0),
- ('\u{102d}', '\u{1030}', 0, 0), ('\u{1032}', '\u{1037}', 0, 0), ('\u{1039}', '\u{103a}', 0,
- 0), ('\u{103d}', '\u{103e}', 0, 0), ('\u{1058}', '\u{1059}', 0, 0), ('\u{105e}', '\u{1060}',
- 0, 0), ('\u{1071}', '\u{1074}', 0, 0), ('\u{1082}', '\u{1082}', 0, 0), ('\u{1085}',
- '\u{1086}', 0, 0), ('\u{108d}', '\u{108d}', 0, 0), ('\u{109d}', '\u{109d}', 0, 0),
- ('\u{1100}', '\u{115f}', 2, 2), ('\u{1160}', '\u{11ff}', 0, 0), ('\u{135d}', '\u{135f}', 0,
- 0), ('\u{1712}', '\u{1714}', 0, 0), ('\u{1732}', '\u{1734}', 0, 0), ('\u{1752}', '\u{1753}',
- 0, 0), ('\u{1772}', '\u{1773}', 0, 0), ('\u{17b4}', '\u{17b5}', 0, 0), ('\u{17b7}',
- '\u{17bd}', 0, 0), ('\u{17c6}', '\u{17c6}', 0, 0), ('\u{17c9}', '\u{17d3}', 0, 0),
- ('\u{17dd}', '\u{17dd}', 0, 0), ('\u{180b}', '\u{180e}', 0, 0), ('\u{1885}', '\u{1886}', 0,
- 0), ('\u{18a9}', '\u{18a9}', 0, 0), ('\u{1920}', '\u{1922}', 0, 0), ('\u{1927}', '\u{1928}',
- 0, 0), ('\u{1932}', '\u{1932}', 0, 0), ('\u{1939}', '\u{193b}', 0, 0), ('\u{1a17}',
- '\u{1a18}', 0, 0), ('\u{1a1b}', '\u{1a1b}', 0, 0), ('\u{1a56}', '\u{1a56}', 0, 0),
- ('\u{1a58}', '\u{1a5e}', 0, 0), ('\u{1a60}', '\u{1a60}', 0, 0), ('\u{1a62}', '\u{1a62}', 0,
- 0), ('\u{1a65}', '\u{1a6c}', 0, 0), ('\u{1a73}', '\u{1a7c}', 0, 0), ('\u{1a7f}', '\u{1a7f}',
- 0, 0), ('\u{1ab0}', '\u{1abe}', 0, 0), ('\u{1b00}', '\u{1b03}', 0, 0), ('\u{1b34}',
- '\u{1b34}', 0, 0), ('\u{1b36}', '\u{1b3a}', 0, 0), ('\u{1b3c}', '\u{1b3c}', 0, 0),
- ('\u{1b42}', '\u{1b42}', 0, 0), ('\u{1b6b}', '\u{1b73}', 0, 0), ('\u{1b80}', '\u{1b81}', 0,
- 0), ('\u{1ba2}', '\u{1ba5}', 0, 0), ('\u{1ba8}', '\u{1ba9}', 0, 0), ('\u{1bab}', '\u{1bad}',
- 0, 0), ('\u{1be6}', '\u{1be6}', 0, 0), ('\u{1be8}', '\u{1be9}', 0, 0), ('\u{1bed}',
- '\u{1bed}', 0, 0), ('\u{1bef}', '\u{1bf1}', 0, 0), ('\u{1c2c}', '\u{1c33}', 0, 0),
- ('\u{1c36}', '\u{1c37}', 0, 0), ('\u{1cd0}', '\u{1cd2}', 0, 0), ('\u{1cd4}', '\u{1ce0}', 0,
- 0), ('\u{1ce2}', '\u{1ce8}', 0, 0), ('\u{1ced}', '\u{1ced}', 0, 0), ('\u{1cf4}', '\u{1cf4}',
- 0, 0), ('\u{1cf8}', '\u{1cf9}', 0, 0), ('\u{1dc0}', '\u{1df9}', 0, 0), ('\u{1dfb}',
- '\u{1dff}', 0, 0), ('\u{200b}', '\u{200f}', 0, 0), ('\u{2010}', '\u{2010}', 1, 2),
- ('\u{2013}', '\u{2016}', 1, 2), ('\u{2018}', '\u{2019}', 1, 2), ('\u{201c}', '\u{201d}', 1,
- 2), ('\u{2020}', '\u{2022}', 1, 2), ('\u{2024}', '\u{2027}', 1, 2), ('\u{202a}', '\u{202e}',
- 0, 0), ('\u{2030}', '\u{2030}', 1, 2), ('\u{2032}', '\u{2033}', 1, 2), ('\u{2035}',
- '\u{2035}', 1, 2), ('\u{203b}', '\u{203b}', 1, 2), ('\u{203e}', '\u{203e}', 1, 2),
- ('\u{2060}', '\u{2064}', 0, 0), ('\u{2066}', '\u{206f}', 0, 0), ('\u{2074}', '\u{2074}', 1,
- 2), ('\u{207f}', '\u{207f}', 1, 2), ('\u{2081}', '\u{2084}', 1, 2), ('\u{20ac}', '\u{20ac}',
- 1, 2), ('\u{20d0}', '\u{20f0}', 0, 0), ('\u{2103}', '\u{2103}', 1, 2), ('\u{2105}',
- '\u{2105}', 1, 2), ('\u{2109}', '\u{2109}', 1, 2), ('\u{2113}', '\u{2113}', 1, 2),
- ('\u{2116}', '\u{2116}', 1, 2), ('\u{2121}', '\u{2122}', 1, 2), ('\u{2126}', '\u{2126}', 1,
- 2), ('\u{212b}', '\u{212b}', 1, 2), ('\u{2153}', '\u{2154}', 1, 2), ('\u{215b}', '\u{215e}',
- 1, 2), ('\u{2160}', '\u{216b}', 1, 2), ('\u{2170}', '\u{2179}', 1, 2), ('\u{2189}',
- '\u{2189}', 1, 2), ('\u{2190}', '\u{2199}', 1, 2), ('\u{21b8}', '\u{21b9}', 1, 2),
- ('\u{21d2}', '\u{21d2}', 1, 2), ('\u{21d4}', '\u{21d4}', 1, 2), ('\u{21e7}', '\u{21e7}', 1,
- 2), ('\u{2200}', '\u{2200}', 1, 2), ('\u{2202}', '\u{2203}', 1, 2), ('\u{2207}', '\u{2208}',
- 1, 2), ('\u{220b}', '\u{220b}', 1, 2), ('\u{220f}', '\u{220f}', 1, 2), ('\u{2211}',
- '\u{2211}', 1, 2), ('\u{2215}', '\u{2215}', 1, 2), ('\u{221a}', '\u{221a}', 1, 2),
- ('\u{221d}', '\u{2220}', 1, 2), ('\u{2223}', '\u{2223}', 1, 2), ('\u{2225}', '\u{2225}', 1,
- 2), ('\u{2227}', '\u{222c}', 1, 2), ('\u{222e}', '\u{222e}', 1, 2), ('\u{2234}', '\u{2237}',
- 1, 2), ('\u{223c}', '\u{223d}', 1, 2), ('\u{2248}', '\u{2248}', 1, 2), ('\u{224c}',
- '\u{224c}', 1, 2), ('\u{2252}', '\u{2252}', 1, 2), ('\u{2260}', '\u{2261}', 1, 2),
- ('\u{2264}', '\u{2267}', 1, 2), ('\u{226a}', '\u{226b}', 1, 2), ('\u{226e}', '\u{226f}', 1,
- 2), ('\u{2282}', '\u{2283}', 1, 2), ('\u{2286}', '\u{2287}', 1, 2), ('\u{2295}', '\u{2295}',
- 1, 2), ('\u{2299}', '\u{2299}', 1, 2), ('\u{22a5}', '\u{22a5}', 1, 2), ('\u{22bf}',
- '\u{22bf}', 1, 2), ('\u{2312}', '\u{2312}', 1, 2), ('\u{231a}', '\u{231b}', 2, 2),
- ('\u{2329}', '\u{232a}', 2, 2), ('\u{23e9}', '\u{23ec}', 2, 2), ('\u{23f0}', '\u{23f0}', 2,
- 2), ('\u{23f3}', '\u{23f3}', 2, 2), ('\u{2460}', '\u{24e9}', 1, 2), ('\u{24eb}', '\u{254b}',
- 1, 2), ('\u{2550}', '\u{2573}', 1, 2), ('\u{2580}', '\u{258f}', 1, 2), ('\u{2592}',
- '\u{2595}', 1, 2), ('\u{25a0}', '\u{25a1}', 1, 2), ('\u{25a3}', '\u{25a9}', 1, 2),
- ('\u{25b2}', '\u{25b3}', 1, 2), ('\u{25b6}', '\u{25b7}', 1, 2), ('\u{25bc}', '\u{25bd}', 1,
- 2), ('\u{25c0}', '\u{25c1}', 1, 2), ('\u{25c6}', '\u{25c8}', 1, 2), ('\u{25cb}', '\u{25cb}',
- 1, 2), ('\u{25ce}', '\u{25d1}', 1, 2), ('\u{25e2}', '\u{25e5}', 1, 2), ('\u{25ef}',
- '\u{25ef}', 1, 2), ('\u{25fd}', '\u{25fe}', 2, 2), ('\u{2605}', '\u{2606}', 1, 2),
- ('\u{2609}', '\u{2609}', 1, 2), ('\u{260e}', '\u{260f}', 1, 2), ('\u{2614}', '\u{2615}', 2,
- 2), ('\u{261c}', '\u{261c}', 1, 2), ('\u{261e}', '\u{261e}', 1, 2), ('\u{2640}', '\u{2640}',
- 1, 2), ('\u{2642}', '\u{2642}', 1, 2), ('\u{2648}', '\u{2653}', 2, 2), ('\u{2660}',
- '\u{2661}', 1, 2), ('\u{2663}', '\u{2665}', 1, 2), ('\u{2667}', '\u{266a}', 1, 2),
- ('\u{266c}', '\u{266d}', 1, 2), ('\u{266f}', '\u{266f}', 1, 2), ('\u{267f}', '\u{267f}', 2,
- 2), ('\u{2693}', '\u{2693}', 2, 2), ('\u{269e}', '\u{269f}', 1, 2), ('\u{26a1}', '\u{26a1}',
- 2, 2), ('\u{26aa}', '\u{26ab}', 2, 2), ('\u{26bd}', '\u{26be}', 2, 2), ('\u{26bf}',
- '\u{26bf}', 1, 2), ('\u{26c4}', '\u{26c5}', 2, 2), ('\u{26c6}', '\u{26cd}', 1, 2),
- ('\u{26ce}', '\u{26ce}', 2, 2), ('\u{26cf}', '\u{26d3}', 1, 2), ('\u{26d4}', '\u{26d4}', 2,
- 2), ('\u{26d5}', '\u{26e1}', 1, 2), ('\u{26e3}', '\u{26e3}', 1, 2), ('\u{26e8}', '\u{26e9}',
- 1, 2), ('\u{26ea}', '\u{26ea}', 2, 2), ('\u{26eb}', '\u{26f1}', 1, 2), ('\u{26f2}',
- '\u{26f3}', 2, 2), ('\u{26f4}', '\u{26f4}', 1, 2), ('\u{26f5}', '\u{26f5}', 2, 2),
- ('\u{26f6}', '\u{26f9}', 1, 2), ('\u{26fa}', '\u{26fa}', 2, 2), ('\u{26fb}', '\u{26fc}', 1,
- 2), ('\u{26fd}', '\u{26fd}', 2, 2), ('\u{26fe}', '\u{26ff}', 1, 2), ('\u{2705}', '\u{2705}',
- 2, 2), ('\u{270a}', '\u{270b}', 2, 2), ('\u{2728}', '\u{2728}', 2, 2), ('\u{273d}',
- '\u{273d}', 1, 2), ('\u{274c}', '\u{274c}', 2, 2), ('\u{274e}', '\u{274e}', 2, 2),
- ('\u{2753}', '\u{2755}', 2, 2), ('\u{2757}', '\u{2757}', 2, 2), ('\u{2776}', '\u{277f}', 1,
- 2), ('\u{2795}', '\u{2797}', 2, 2), ('\u{27b0}', '\u{27b0}', 2, 2), ('\u{27bf}', '\u{27bf}',
- 2, 2), ('\u{2b1b}', '\u{2b1c}', 2, 2), ('\u{2b50}', '\u{2b50}', 2, 2), ('\u{2b55}',
- '\u{2b55}', 2, 2), ('\u{2b56}', '\u{2b59}', 1, 2), ('\u{2cef}', '\u{2cf1}', 0, 0),
- ('\u{2d7f}', '\u{2d7f}', 0, 0), ('\u{2de0}', '\u{2dff}', 0, 0), ('\u{2e80}', '\u{2e99}', 2,
- 2), ('\u{2e9b}', '\u{2ef3}', 2, 2), ('\u{2f00}', '\u{2fd5}', 2, 2), ('\u{2ff0}', '\u{2ffb}',
- 2, 2), ('\u{3000}', '\u{3029}', 2, 2), ('\u{302a}', '\u{302d}', 0, 0), ('\u{302e}',
- '\u{303e}', 2, 2), ('\u{3041}', '\u{3096}', 2, 2), ('\u{3099}', '\u{309a}', 0, 0),
- ('\u{309b}', '\u{30ff}', 2, 2), ('\u{3105}', '\u{312f}', 2, 2), ('\u{3131}', '\u{318e}', 2,
- 2), ('\u{3190}', '\u{31ba}', 2, 2), ('\u{31c0}', '\u{31e3}', 2, 2), ('\u{31f0}', '\u{321e}',
- 2, 2), ('\u{3220}', '\u{3247}', 2, 2), ('\u{3248}', '\u{324f}', 1, 2), ('\u{3250}',
- '\u{4dbf}', 2, 2), ('\u{4e00}', '\u{a48c}', 2, 2), ('\u{a490}', '\u{a4c6}', 2, 2),
- ('\u{a66f}', '\u{a672}', 0, 0), ('\u{a674}', '\u{a67d}', 0, 0), ('\u{a69e}', '\u{a69f}', 0,
- 0), ('\u{a6f0}', '\u{a6f1}', 0, 0), ('\u{a802}', '\u{a802}', 0, 0), ('\u{a806}', '\u{a806}',
- 0, 0), ('\u{a80b}', '\u{a80b}', 0, 0), ('\u{a825}', '\u{a826}', 0, 0), ('\u{a8c4}',
- '\u{a8c5}', 0, 0), ('\u{a8e0}', '\u{a8f1}', 0, 0), ('\u{a8ff}', '\u{a8ff}', 0, 0),
- ('\u{a926}', '\u{a92d}', 0, 0), ('\u{a947}', '\u{a951}', 0, 0), ('\u{a960}', '\u{a97c}', 2,
- 2), ('\u{a980}', '\u{a982}', 0, 0), ('\u{a9b3}', '\u{a9b3}', 0, 0), ('\u{a9b6}', '\u{a9b9}',
- 0, 0), ('\u{a9bc}', '\u{a9bd}', 0, 0), ('\u{a9e5}', '\u{a9e5}', 0, 0), ('\u{aa29}',
- '\u{aa2e}', 0, 0), ('\u{aa31}', '\u{aa32}', 0, 0), ('\u{aa35}', '\u{aa36}', 0, 0),
- ('\u{aa43}', '\u{aa43}', 0, 0), ('\u{aa4c}', '\u{aa4c}', 0, 0), ('\u{aa7c}', '\u{aa7c}', 0,
- 0), ('\u{aab0}', '\u{aab0}', 0, 0), ('\u{aab2}', '\u{aab4}', 0, 0), ('\u{aab7}', '\u{aab8}',
- 0, 0), ('\u{aabe}', '\u{aabf}', 0, 0), ('\u{aac1}', '\u{aac1}', 0, 0), ('\u{aaec}',
- '\u{aaed}', 0, 0), ('\u{aaf6}', '\u{aaf6}', 0, 0), ('\u{abe5}', '\u{abe5}', 0, 0),
- ('\u{abe8}', '\u{abe8}', 0, 0), ('\u{abed}', '\u{abed}', 0, 0), ('\u{ac00}', '\u{d7a3}', 2,
- 2), ('\u{e000}', '\u{f8ff}', 1, 2), ('\u{f900}', '\u{faff}', 2, 2), ('\u{fb1e}', '\u{fb1e}',
- 0, 0), ('\u{fe00}', '\u{fe0f}', 0, 0), ('\u{fe10}', '\u{fe19}', 2, 2), ('\u{fe20}',
- '\u{fe2f}', 0, 0), ('\u{fe30}', '\u{fe52}', 2, 2), ('\u{fe54}', '\u{fe66}', 2, 2),
- ('\u{fe68}', '\u{fe6b}', 2, 2), ('\u{feff}', '\u{feff}', 0, 0), ('\u{ff01}', '\u{ff60}', 2,
- 2), ('\u{ffe0}', '\u{ffe6}', 2, 2), ('\u{fff9}', '\u{fffb}', 0, 0), ('\u{fffd}', '\u{fffd}',
- 1, 2), ('\u{101fd}', '\u{101fd}', 0, 0), ('\u{102e0}', '\u{102e0}', 0, 0), ('\u{10376}',
- '\u{1037a}', 0, 0), ('\u{10a01}', '\u{10a03}', 0, 0), ('\u{10a05}', '\u{10a06}', 0, 0),
- ('\u{10a0c}', '\u{10a0f}', 0, 0), ('\u{10a38}', '\u{10a3a}', 0, 0), ('\u{10a3f}',
- '\u{10a3f}', 0, 0), ('\u{10ae5}', '\u{10ae6}', 0, 0), ('\u{10d24}', '\u{10d27}', 0, 0),
- ('\u{10f46}', '\u{10f50}', 0, 0), ('\u{11001}', '\u{11001}', 0, 0), ('\u{11038}',
- '\u{11046}', 0, 0), ('\u{1107f}', '\u{11081}', 0, 0), ('\u{110b3}', '\u{110b6}', 0, 0),
- ('\u{110b9}', '\u{110ba}', 0, 0), ('\u{110bd}', '\u{110bd}', 0, 0), ('\u{110cd}',
- '\u{110cd}', 0, 0), ('\u{11100}', '\u{11102}', 0, 0), ('\u{11127}', '\u{1112b}', 0, 0),
- ('\u{1112d}', '\u{11134}', 0, 0), ('\u{11173}', '\u{11173}', 0, 0), ('\u{11180}',
- '\u{11181}', 0, 0), ('\u{111b6}', '\u{111be}', 0, 0), ('\u{111c9}', '\u{111cc}', 0, 0),
- ('\u{1122f}', '\u{11231}', 0, 0), ('\u{11234}', '\u{11234}', 0, 0), ('\u{11236}',
- '\u{11237}', 0, 0), ('\u{1123e}', '\u{1123e}', 0, 0), ('\u{112df}', '\u{112df}', 0, 0),
- ('\u{112e3}', '\u{112ea}', 0, 0), ('\u{11300}', '\u{11301}', 0, 0), ('\u{1133b}',
- '\u{1133c}', 0, 0), ('\u{11340}', '\u{11340}', 0, 0), ('\u{11366}', '\u{1136c}', 0, 0),
- ('\u{11370}', '\u{11374}', 0, 0), ('\u{11438}', '\u{1143f}', 0, 0), ('\u{11442}',
- '\u{11444}', 0, 0), ('\u{11446}', '\u{11446}', 0, 0), ('\u{1145e}', '\u{1145e}', 0, 0),
- ('\u{114b3}', '\u{114b8}', 0, 0), ('\u{114ba}', '\u{114ba}', 0, 0), ('\u{114bf}',
- '\u{114c0}', 0, 0), ('\u{114c2}', '\u{114c3}', 0, 0), ('\u{115b2}', '\u{115b5}', 0, 0),
- ('\u{115bc}', '\u{115bd}', 0, 0), ('\u{115bf}', '\u{115c0}', 0, 0), ('\u{115dc}',
- '\u{115dd}', 0, 0), ('\u{11633}', '\u{1163a}', 0, 0), ('\u{1163d}', '\u{1163d}', 0, 0),
- ('\u{1163f}', '\u{11640}', 0, 0), ('\u{116ab}', '\u{116ab}', 0, 0), ('\u{116ad}',
- '\u{116ad}', 0, 0), ('\u{116b0}', '\u{116b5}', 0, 0), ('\u{116b7}', '\u{116b7}', 0, 0),
- ('\u{1171d}', '\u{1171f}', 0, 0), ('\u{11722}', '\u{11725}', 0, 0), ('\u{11727}',
- '\u{1172b}', 0, 0), ('\u{1182f}', '\u{11837}', 0, 0), ('\u{11839}', '\u{1183a}', 0, 0),
- ('\u{119d4}', '\u{119d7}', 0, 0), ('\u{119da}', '\u{119db}', 0, 0), ('\u{119e0}',
- '\u{119e0}', 0, 0), ('\u{11a01}', '\u{11a0a}', 0, 0), ('\u{11a33}', '\u{11a38}', 0, 0),
- ('\u{11a3b}', '\u{11a3e}', 0, 0), ('\u{11a47}', '\u{11a47}', 0, 0), ('\u{11a51}',
- '\u{11a56}', 0, 0), ('\u{11a59}', '\u{11a5b}', 0, 0), ('\u{11a8a}', '\u{11a96}', 0, 0),
- ('\u{11a98}', '\u{11a99}', 0, 0), ('\u{11c30}', '\u{11c36}', 0, 0), ('\u{11c38}',
- '\u{11c3d}', 0, 0), ('\u{11c3f}', '\u{11c3f}', 0, 0), ('\u{11c92}', '\u{11ca7}', 0, 0),
- ('\u{11caa}', '\u{11cb0}', 0, 0), ('\u{11cb2}', '\u{11cb3}', 0, 0), ('\u{11cb5}',
- '\u{11cb6}', 0, 0), ('\u{11d31}', '\u{11d36}', 0, 0), ('\u{11d3a}', '\u{11d3a}', 0, 0),
- ('\u{11d3c}', '\u{11d3d}', 0, 0), ('\u{11d3f}', '\u{11d45}', 0, 0), ('\u{11d47}',
- '\u{11d47}', 0, 0), ('\u{11d90}', '\u{11d91}', 0, 0), ('\u{11d95}', '\u{11d95}', 0, 0),
- ('\u{11d97}', '\u{11d97}', 0, 0), ('\u{11ef3}', '\u{11ef4}', 0, 0), ('\u{13430}',
- '\u{13438}', 0, 0), ('\u{16af0}', '\u{16af4}', 0, 0), ('\u{16b30}', '\u{16b36}', 0, 0),
- ('\u{16f4f}', '\u{16f4f}', 0, 0), ('\u{16f8f}', '\u{16f92}', 0, 0), ('\u{16fe0}',
- '\u{16fe3}', 2, 2), ('\u{17000}', '\u{187f7}', 2, 2), ('\u{18800}', '\u{18af2}', 2, 2),
- ('\u{1b000}', '\u{1b11e}', 2, 2), ('\u{1b150}', '\u{1b152}', 2, 2), ('\u{1b164}',
- '\u{1b167}', 2, 2), ('\u{1b170}', '\u{1b2fb}', 2, 2), ('\u{1bc9d}', '\u{1bc9e}', 0, 0),
- ('\u{1bca0}', '\u{1bca3}', 0, 0), ('\u{1d167}', '\u{1d169}', 0, 0), ('\u{1d173}',
- '\u{1d182}', 0, 0), ('\u{1d185}', '\u{1d18b}', 0, 0), ('\u{1d1aa}', '\u{1d1ad}', 0, 0),
- ('\u{1d242}', '\u{1d244}', 0, 0), ('\u{1da00}', '\u{1da36}', 0, 0), ('\u{1da3b}',
- '\u{1da6c}', 0, 0), ('\u{1da75}', '\u{1da75}', 0, 0), ('\u{1da84}', '\u{1da84}', 0, 0),
- ('\u{1da9b}', '\u{1da9f}', 0, 0), ('\u{1daa1}', '\u{1daaf}', 0, 0), ('\u{1e000}',
- '\u{1e006}', 0, 0), ('\u{1e008}', '\u{1e018}', 0, 0), ('\u{1e01b}', '\u{1e021}', 0, 0),
- ('\u{1e023}', '\u{1e024}', 0, 0), ('\u{1e026}', '\u{1e02a}', 0, 0), ('\u{1e130}',
- '\u{1e136}', 0, 0), ('\u{1e2ec}', '\u{1e2ef}', 0, 0), ('\u{1e8d0}', '\u{1e8d6}', 0, 0),
- ('\u{1e944}', '\u{1e94a}', 0, 0), ('\u{1f004}', '\u{1f004}', 2, 2), ('\u{1f0cf}',
- '\u{1f0cf}', 2, 2), ('\u{1f100}', '\u{1f10a}', 1, 2), ('\u{1f110}', '\u{1f12d}', 1, 2),
- ('\u{1f130}', '\u{1f169}', 1, 2), ('\u{1f170}', '\u{1f18d}', 1, 2), ('\u{1f18e}',
- '\u{1f18e}', 2, 2), ('\u{1f18f}', '\u{1f190}', 1, 2), ('\u{1f191}', '\u{1f19a}', 2, 2),
- ('\u{1f19b}', '\u{1f1ac}', 1, 2), ('\u{1f200}', '\u{1f202}', 2, 2), ('\u{1f210}',
- '\u{1f23b}', 2, 2), ('\u{1f240}', '\u{1f248}', 2, 2), ('\u{1f250}', '\u{1f251}', 2, 2),
- ('\u{1f260}', '\u{1f265}', 2, 2), ('\u{1f300}', '\u{1f320}', 2, 2), ('\u{1f32d}',
- '\u{1f335}', 2, 2), ('\u{1f337}', '\u{1f37c}', 2, 2), ('\u{1f37e}', '\u{1f393}', 2, 2),
- ('\u{1f3a0}', '\u{1f3ca}', 2, 2), ('\u{1f3cf}', '\u{1f3d3}', 2, 2), ('\u{1f3e0}',
- '\u{1f3f0}', 2, 2), ('\u{1f3f4}', '\u{1f3f4}', 2, 2), ('\u{1f3f8}', '\u{1f43e}', 2, 2),
- ('\u{1f440}', '\u{1f440}', 2, 2), ('\u{1f442}', '\u{1f4fc}', 2, 2), ('\u{1f4ff}',
- '\u{1f53d}', 2, 2), ('\u{1f54b}', '\u{1f54e}', 2, 2), ('\u{1f550}', '\u{1f567}', 2, 2),
- ('\u{1f57a}', '\u{1f57a}', 2, 2), ('\u{1f595}', '\u{1f596}', 2, 2), ('\u{1f5a4}',
- '\u{1f5a4}', 2, 2), ('\u{1f5fb}', '\u{1f64f}', 2, 2), ('\u{1f680}', '\u{1f6c5}', 2, 2),
- ('\u{1f6cc}', '\u{1f6cc}', 2, 2), ('\u{1f6d0}', '\u{1f6d2}', 2, 2), ('\u{1f6d5}',
- '\u{1f6d5}', 2, 2), ('\u{1f6eb}', '\u{1f6ec}', 2, 2), ('\u{1f6f4}', '\u{1f6fa}', 2, 2),
- ('\u{1f7e0}', '\u{1f7eb}', 2, 2), ('\u{1f90d}', '\u{1f971}', 2, 2), ('\u{1f973}',
- '\u{1f976}', 2, 2), ('\u{1f97a}', '\u{1f9a2}', 2, 2), ('\u{1f9a5}', '\u{1f9aa}', 2, 2),
- ('\u{1f9ae}', '\u{1f9ca}', 2, 2), ('\u{1f9cd}', '\u{1f9ff}', 2, 2), ('\u{1fa70}',
- '\u{1fa73}', 2, 2), ('\u{1fa78}', '\u{1fa7a}', 2, 2), ('\u{1fa80}', '\u{1fa82}', 2, 2),
- ('\u{1fa90}', '\u{1fa95}', 2, 2), ('\u{20000}', '\u{2fffd}', 2, 2), ('\u{30000}',
- '\u{3fffd}', 2, 2), ('\u{e0001}', '\u{e0001}', 0, 0), ('\u{e0020}', '\u{e007f}', 0, 0),
- ('\u{e0100}', '\u{e01ef}', 0, 0), ('\u{f0000}', '\u{ffffd}', 1, 2), ('\u{100000}',
- '\u{10fffd}', 1, 2)
- ];
-
-}
-
diff --git a/unicode-width/src/tests.rs b/unicode-width/src/tests.rs
deleted file mode 100644
index 72808c6..0000000
--- a/unicode-width/src/tests.rs
+++ /dev/null
@@ -1,175 +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.
-
-#[cfg(feature = "bench")]
-use std::iter;
-#[cfg(feature = "bench")]
-use test::{self, Bencher};
-#[cfg(feature = "bench")]
-use super::UnicodeWidthChar;
-
-use std::prelude::v1::*;
-
-#[cfg(feature = "bench")]
-#[bench]
-fn cargo(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.iter(|| {
- for c in string.chars() {
- test::black_box(UnicodeWidthChar::width(c));
- }
- });
-}
-
-#[cfg(feature = "bench")]
-#[bench]
-#[allow(deprecated)]
-fn stdlib(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.iter(|| {
- for c in string.chars() {
- test::black_box(c.width());
- }
- });
-}
-
-#[cfg(feature = "bench")]
-#[bench]
-fn simple_if(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.iter(|| {
- for c in string.chars() {
- test::black_box(simple_width_if(c));
- }
- });
-}
-
-#[cfg(feature = "bench")]
-#[bench]
-fn simple_match(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.iter(|| {
- for c in string.chars() {
- test::black_box(simple_width_match(c));
- }
- });
-}
-
-#[cfg(feature = "bench")]
-#[inline]
-fn simple_width_if(c: char) -> Option<usize> {
- let cu = c as u32;
- if cu < 127 {
- if cu > 31 {
- Some(1)
- } else if cu == 0 {
- Some(0)
- } else {
- None
- }
- } else {
- UnicodeWidthChar::width(c)
- }
-}
-
-#[cfg(feature = "bench")]
-#[inline]
-fn simple_width_match(c: char) -> Option<usize> {
- match c as u32 {
- cu if cu == 0 => Some(0),
- cu if cu < 0x20 => None,
- cu if cu < 0x7f => Some(1),
- _ => UnicodeWidthChar::width(c)
- }
-}
-
-#[test]
-fn test_str() {
- use super::UnicodeWidthStr;
-
- assert_eq!(UnicodeWidthStr::width("hello"), 10);
- assert_eq!("hello".width_cjk(), 10);
- assert_eq!(UnicodeWidthStr::width("\0\0\0\x01\x01"), 0);
- assert_eq!("\0\0\0\x01\x01".width_cjk(), 0);
- assert_eq!(UnicodeWidthStr::width(""), 0);
- assert_eq!("".width_cjk(), 0);
- assert_eq!(UnicodeWidthStr::width("\u{2081}\u{2082}\u{2083}\u{2084}"), 4);
- assert_eq!("\u{2081}\u{2082}\u{2083}\u{2084}".width_cjk(), 8);
-}
-
-#[test]
-fn test_emoji() {
- // Example from the README.
- use super::UnicodeWidthStr;
-
- assert_eq!(UnicodeWidthStr::width("👩"), 2); // Woman
- assert_eq!(UnicodeWidthStr::width("🔬"), 2); // Microscope
- assert_eq!(UnicodeWidthStr::width("👩‍🔬"), 4); // Woman scientist
-}
-
-#[test]
-fn test_char() {
- use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{Some, None};
-
- assert_eq!(UnicodeWidthChar::width('h'), Some(2));
- assert_eq!('h'.width_cjk(), Some(2));
- assert_eq!(UnicodeWidthChar::width('\x00'), Some(0));
- assert_eq!('\x00'.width_cjk(), Some(0));
- assert_eq!(UnicodeWidthChar::width('\x01'), None);
- assert_eq!('\x01'.width_cjk(), None);
- assert_eq!(UnicodeWidthChar::width('\u{2081}'), Some(1));
- assert_eq!('\u{2081}'.width_cjk(), Some(2));
-}
-
-#[test]
-fn test_char2() {
- use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{Some, None};
-
- assert_eq!(UnicodeWidthChar::width('\x00'),Some(0));
- assert_eq!('\x00'.width_cjk(),Some(0));
-
- assert_eq!(UnicodeWidthChar::width('\x0A'),None);
- assert_eq!('\x0A'.width_cjk(),None);
-
- assert_eq!(UnicodeWidthChar::width('w'),Some(1));
- assert_eq!('w'.width_cjk(),Some(1));
-
- assert_eq!(UnicodeWidthChar::width('h'),Some(2));
- assert_eq!('h'.width_cjk(),Some(2));
-
- assert_eq!(UnicodeWidthChar::width('\u{AD}'),Some(1));
- assert_eq!('\u{AD}'.width_cjk(),Some(1));
-
- assert_eq!(UnicodeWidthChar::width('\u{1160}'),Some(0));
- assert_eq!('\u{1160}'.width_cjk(),Some(0));
-
- assert_eq!(UnicodeWidthChar::width('\u{a1}'),Some(1));
- assert_eq!('\u{a1}'.width_cjk(),Some(2));
-
- assert_eq!(UnicodeWidthChar::width('\u{300}'),Some(0));
- assert_eq!('\u{300}'.width_cjk(),Some(0));
-}
-
-#[test]
-fn unicode_12() {
- use super::UnicodeWidthChar;
- #[cfg(feature = "no_std")]
- use core::option::Option::{Some, None};
-
- assert_eq!(UnicodeWidthChar::width('\u{1F971}'), Some(2));
-}
diff --git a/unicode-xid/.gitignore b/unicode-xid/.gitignore
deleted file mode 100644
index 5cdcdba..0000000
--- a/unicode-xid/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-target
-Cargo.lock
-scripts/tmp
diff --git a/unicode-xid/.travis.yml b/unicode-xid/.travis.yml
deleted file mode 100644
index d9c5c2a..0000000
--- a/unicode-xid/.travis.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-language: rust
-rust: 'nightly'
-sudo: false
-script:
- - cargo build --verbose --features bench
- - cargo test --verbose --features bench
- - cargo bench --verbose --features bench
- - cargo clean
- - cargo build --verbose
- - cargo test --verbose
- - rustdoc --test README.md -L target/debug -L target/debug/deps
- - cargo doc
-after_success: |
- [ $TRAVIS_BRANCH = master ] &&
- [ $TRAVIS_PULL_REQUEST = false ] &&
- echo '<meta http-equiv=refresh content=0;url=unicode_xid/index.html>' > target/doc/index.html &&
- pip install ghp-import --user $USER &&
- $HOME/.local/bin/ghp-import -n target/doc &&
- git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
-env:
- global:
- secure: gTlge+/OQlVkV0R+RThWXeN0aknmS7iUTPBMYKJyRdLz7T2vubw3w80a2CVE87JlpV87A5cVGD+LgR+AhYrhKtvqHb1brMDd99gylBBi2DfV7YapDSwSCuFgVR+FjZfJRcXBtI8po5urUZ84V0WLzRX8SyWqWgoD3oCkSL3Wp3w=
-notifications:
- email:
- on_success: never
diff --git a/unicode-xid/COPYRIGHT b/unicode-xid/COPYRIGHT
deleted file mode 100644
index b286ec1..0000000
--- a/unicode-xid/COPYRIGHT
+++ /dev/null
@@ -1,7 +0,0 @@
-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.
diff --git a/unicode-xid/Cargo.toml b/unicode-xid/Cargo.toml
deleted file mode 100644
index e813762..0000000
--- a/unicode-xid/Cargo.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-[package]
-
-name = "unicode-xid"
-version = "0.2.0"
-authors = ["erick.tryzelaar <erick.tryzelaar@gmail.com>",
- "kwantam <kwantam@gmail.com>",
- ]
-
-homepage = "https://github.com/unicode-rs/unicode-xid"
-repository = "https://github.com/unicode-rs/unicode-xid"
-documentation = "https://unicode-rs.github.io/unicode-xid"
-license = "MIT OR Apache-2.0"
-keywords = ["text", "unicode", "xid"]
-readme = "README.md"
-description = """
-Determine whether characters have the XID_Start
-or XID_Continue properties according to
-Unicode Standard Annex #31.
-"""
-exclude = ["/scripts/*", "/.travis.yml"]
-
-[badges]
-travis-ci = { repository = "unicode-rs/unicode-xid" }
-
-[features]
-default = []
-no_std = []
-bench = []
diff --git a/unicode-xid/LICENSE-APACHE b/unicode-xid/LICENSE-APACHE
deleted file mode 100644
index 16fe87b..0000000
--- a/unicode-xid/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/unicode-xid/LICENSE-MIT b/unicode-xid/LICENSE-MIT
deleted file mode 100644
index e69282e..0000000
--- a/unicode-xid/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2015 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/unicode-xid/README.md b/unicode-xid/README.md
deleted file mode 100644
index 3c1ef2a..0000000
--- a/unicode-xid/README.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# unicode-xid
-
-Determine if a `char` is a valid identifier for a parser and/or lexer according to
-[Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) rules.
-
-[![Build Status](https://travis-ci.org/unicode-rs/unicode-xid.svg)](https://travis-ci.org/unicode-rs/unicode-xid)
-
-[Documentation](https://unicode-rs.github.io/unicode-xid/unicode_xid/index.html)
-
-```rust
-extern crate unicode_xid;
-
-use unicode_xid::UnicodeXID;
-
-fn main() {
- let ch = 'a';
- println!("Is {} a valid start of an identifier? {}", ch, UnicodeXID::is_xid_start(ch));
-}
-```
-
-# features
-
-unicode-xid supports a `no_std` feature. This eliminates dependence
-on std, and instead uses equivalent functions from core.
-
-# crates.io
-
-You can use this package in your project by adding the following
-to your `Cargo.toml`:
-
-```toml
-[dependencies]
-unicode-xid = "0.1.0"
-```
-
-# changelog
-
-## 0.2.0
-
-- Update to Unicode 12.1.0.
-
-## 0.1.0
-
-- Initial release.
diff --git a/unicode-xid/scripts/unicode.py b/unicode-xid/scripts/unicode.py
deleted file mode 100755
index 393f901..0000000
--- a/unicode-xid/scripts/unicode.py
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011-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.
-
-# This script uses the following Unicode tables:
-# - DerivedCoreProperties.txt
-# - ReadMe.txt
-#
-# Since this should not require frequent updates, we just store this
-# out-of-line and check the unicode.rs file into git.
-
-import fileinput, re, os, sys
-
-preamble = '''// 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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
-'''
-
-def fetch(f):
- if not os.path.exists(os.path.basename(f)):
- os.system("curl -O http://www.unicode.org/Public/UNIDATA/%s"
- % f)
-
- if not os.path.exists(os.path.basename(f)):
- sys.stderr.write("cannot load %s" % f)
- exit(1)
-
-def group_cat(cat):
- cat_out = []
- letters = sorted(set(cat))
- cur_start = letters.pop(0)
- cur_end = cur_start
- for letter in letters:
- assert letter > cur_end, \
- "cur_end: %s, letter: %s" % (hex(cur_end), hex(letter))
- if letter == cur_end + 1:
- cur_end = letter
- else:
- cat_out.append((cur_start, cur_end))
- cur_start = cur_end = letter
- cat_out.append((cur_start, cur_end))
- return cat_out
-
-def ungroup_cat(cat):
- cat_out = []
- for (lo, hi) in cat:
- while lo <= hi:
- cat_out.append(lo)
- lo += 1
- return cat_out
-
-def format_table_content(f, content, indent):
- line = " "*indent
- first = True
- for chunk in content.split(","):
- if len(line) + len(chunk) < 98:
- if first:
- line += chunk
- else:
- line += ", " + chunk
- first = False
- else:
- f.write(line + ",\n")
- line = " "*indent + chunk
- f.write(line)
-
-def load_properties(f, interestingprops):
- fetch(f)
- props = {}
- re1 = re.compile("^ *([0-9A-F]+) *; *(\w+)")
- re2 = re.compile("^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+)")
-
- for line in fileinput.input(os.path.basename(f)):
- prop = None
- d_lo = 0
- d_hi = 0
- m = re1.match(line)
- if m:
- d_lo = m.group(1)
- d_hi = m.group(1)
- prop = m.group(2)
- else:
- m = re2.match(line)
- if m:
- d_lo = m.group(1)
- d_hi = m.group(2)
- prop = m.group(3)
- else:
- continue
- if interestingprops and prop not in interestingprops:
- continue
- d_lo = int(d_lo, 16)
- d_hi = int(d_hi, 16)
- if prop not in props:
- props[prop] = []
- props[prop].append((d_lo, d_hi))
-
- # optimize if possible
- for prop in props:
- props[prop] = group_cat(ungroup_cat(props[prop]))
-
- return props
-
-def escape_char(c):
- return "'\\u{%x}'" % c
-
-def emit_bsearch_range_table(f):
- f.write("""
-fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool {
- use core::cmp::Ordering::{Equal, Less, Greater};
-
- r.binary_search_by(|&(lo,hi)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }).is_ok()
-}\n
-""")
-
-def emit_table(f, name, t_data, t_type = "&[(char, char)]", is_pub=True,
- pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1])), is_const=True):
- pub_string = "const"
- if not is_const:
- pub_string = "let"
- if is_pub:
- pub_string = "pub " + pub_string
- f.write(" %s %s: %s = &[\n" % (pub_string, name, t_type))
- data = ""
- first = True
- for dat in t_data:
- if not first:
- data += ","
- first = False
- data += pfun(dat)
- format_table_content(f, data, 8)
- f.write("\n ];\n\n")
-
-def emit_property_module(f, mod, tbl, emit):
- f.write("pub mod %s {\n" % mod)
- for cat in sorted(emit):
- emit_table(f, "%s_table" % cat, tbl[cat])
- f.write(" pub fn %s(c: char) -> bool {\n" % cat)
- f.write(" super::bsearch_range_table(c, %s_table)\n" % cat)
- f.write(" }\n\n")
- f.write("}\n\n")
-
-if __name__ == "__main__":
- r = "tables.rs"
- if os.path.exists(r):
- os.remove(r)
- with open(r, "w") as rf:
- # write the file's preamble
- rf.write(preamble)
-
- # download and parse all the data
- fetch("ReadMe.txt")
- with open("ReadMe.txt") as readme:
- pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode"
- unicode_version = re.search(pattern, readme.read()).groups()
- rf.write("""
-/// The version of [Unicode](http://www.unicode.org/)
-/// that this version of unicode-xid is based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
-""" % unicode_version)
- emit_bsearch_range_table(rf)
-
- want_derived = ["XID_Start", "XID_Continue"]
- derived = load_properties("DerivedCoreProperties.txt", want_derived)
- emit_property_module(rf, "derived_property", derived, want_derived)
diff --git a/unicode-xid/src/lib.rs b/unicode-xid/src/lib.rs
deleted file mode 100644
index 7dd95ba..0000000
--- a/unicode-xid/src/lib.rs
+++ /dev/null
@@ -1,87 +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.
-
-//! Determine if a `char` is a valid identifier for a parser and/or lexer according to
-//! [Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) rules.
-//!
-//! ```rust
-//! extern crate unicode_xid;
-//!
-//! use unicode_xid::UnicodeXID;
-//!
-//! fn main() {
-//! let ch = 'a';
-//! println!("Is {} a valid start of an identifier? {}", ch, UnicodeXID::is_xid_start(ch));
-//! }
-//! ```
-//!
-//! # features
-//!
-//! unicode-xid supports a `no_std` feature. This eliminates dependence
-//! on std, and instead uses equivalent functions from core.
-//!
-//! # crates.io
-//!
-//! You can use this package in your project by adding the following
-//! to your `Cargo.toml`:
-//!
-//! ```toml
-//! [dependencies]
-//! unicode-xid = "0.0.4"
-//! ```
-
-#![deny(missing_docs, unsafe_code)]
-#![doc(html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png",
- html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png")]
-
-#![no_std]
-#![cfg_attr(feature = "bench", feature(test, unicode_internals))]
-
-#[cfg(test)]
-#[macro_use]
-extern crate std;
-
-#[cfg(feature = "bench")]
-extern crate test;
-
-use tables::derived_property;
-pub use tables::UNICODE_VERSION;
-
-mod tables;
-
-#[cfg(test)]
-mod tests;
-
-/// Methods for determining if a character is a valid identifier character.
-pub trait UnicodeXID {
- /// Returns whether the specified character satisfies the 'XID_Start'
- /// Unicode property.
- ///
- /// 'XID_Start' is a Unicode Derived Property specified in
- /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
- /// mostly similar to ID_Start but modified for closure under NFKx.
- fn is_xid_start(self) -> bool;
-
- /// Returns whether the specified `char` satisfies the 'XID_Continue'
- /// Unicode property.
- ///
- /// 'XID_Continue' is a Unicode Derived Property specified in
- /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
- /// mostly similar to 'ID_Continue' but modified for closure under NFKx.
- fn is_xid_continue(self) -> bool;
-}
-
-impl UnicodeXID for char {
- #[inline]
- fn is_xid_start(self) -> bool { derived_property::XID_Start(self) }
-
- #[inline]
- fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) }
-}
diff --git a/unicode-xid/src/tables.rs b/unicode-xid/src/tables.rs
deleted file mode 100644
index edd51d0..0000000
--- a/unicode-xid/src/tables.rs
+++ /dev/null
@@ -1,451 +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.
-
-// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
-
-#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
-
-/// The version of [Unicode](http://www.unicode.org/)
-/// that this version of unicode-xid is based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (12, 1, 0);
-
-fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool {
- use core::cmp::Ordering::{Equal, Less, Greater};
-
- r.binary_search_by(|&(lo,hi)| {
- if lo <= c && c <= hi { Equal }
- else if hi < c { Less }
- else { Greater }
- }).is_ok()
-}
-
-pub mod derived_property {
- pub const XID_Continue_table: &[(char, char)] = &[
- ('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), ('\u{61}', '\u{7a}'),
- ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{b7}', '\u{b7}'), ('\u{ba}', '\u{ba}'),
- ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'),
- ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{300}',
- '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), ('\u{37f}', '\u{37f}'),
- ('\u{386}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}',
- '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{483}', '\u{487}'), ('\u{48a}', '\u{52f}'),
- ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{560}', '\u{588}'), ('\u{591}',
- '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'),
- ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5ef}', '\u{5f2}'), ('\u{610}',
- '\u{61a}'), ('\u{620}', '\u{669}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'),
- ('\u{6df}', '\u{6e8}'), ('\u{6ea}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}',
- '\u{74a}'), ('\u{74d}', '\u{7b1}'), ('\u{7c0}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'),
- ('\u{7fd}', '\u{7fd}'), ('\u{800}', '\u{82d}'), ('\u{840}', '\u{85b}'), ('\u{860}',
- '\u{86a}'), ('\u{8a0}', '\u{8b4}'), ('\u{8b6}', '\u{8bd}'), ('\u{8d3}', '\u{8e1}'),
- ('\u{8e3}', '\u{963}'), ('\u{966}', '\u{96f}'), ('\u{971}', '\u{983}'), ('\u{985}',
- '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'),
- ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), ('\u{9c7}',
- '\u{9c8}'), ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'),
- ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9f1}'), ('\u{9fc}', '\u{9fc}'), ('\u{9fe}',
- '\u{9fe}'), ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'),
- ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}',
- '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'),
- ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a59}',
- '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a66}', '\u{a75}'), ('\u{a81}', '\u{a83}'),
- ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}',
- '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'),
- ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}',
- '\u{ae3}'), ('\u{ae6}', '\u{aef}'), ('\u{af9}', '\u{aff}'), ('\u{b01}', '\u{b03}'),
- ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}',
- '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'),
- ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}',
- '\u{b5d}'), ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b6f}'), ('\u{b71}', '\u{b71}'),
- ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}',
- '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'),
- ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}',
- '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'),
- ('\u{bd7}', '\u{bd7}'), ('\u{be6}', '\u{bef}'), ('\u{c00}', '\u{c0c}'), ('\u{c0e}',
- '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'),
- ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c58}',
- '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), ('\u{c80}', '\u{c83}'),
- ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}',
- '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'),
- ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}',
- '\u{ce3}'), ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}'), ('\u{d00}', '\u{d03}'),
- ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d44}'), ('\u{d46}',
- '\u{d48}'), ('\u{d4a}', '\u{d4e}'), ('\u{d54}', '\u{d57}'), ('\u{d5f}', '\u{d63}'),
- ('\u{d66}', '\u{d6f}'), ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'), ('\u{d85}',
- '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'),
- ('\u{dc0}', '\u{dc6}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}',
- '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), ('\u{df2}', '\u{df3}'),
- ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e4e}'), ('\u{e50}', '\u{e59}'), ('\u{e81}',
- '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e86}', '\u{e8a}'), ('\u{e8c}', '\u{ea3}'),
- ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}',
- '\u{ec6}'), ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), ('\u{edc}', '\u{edf}'),
- ('\u{f00}', '\u{f00}'), ('\u{f18}', '\u{f19}'), ('\u{f20}', '\u{f29}'), ('\u{f35}',
- '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f3e}', '\u{f47}'),
- ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f84}'), ('\u{f86}', '\u{f97}'), ('\u{f99}',
- '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{1000}', '\u{1049}'), ('\u{1050}', '\u{109d}'),
- ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}',
- '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'),
- ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}',
- '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'),
- ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}',
- '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135d}', '\u{135f}'),
- ('\u{1369}', '\u{1371}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}',
- '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'),
- ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}',
- '\u{1714}'), ('\u{1720}', '\u{1734}'), ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'),
- ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17d3}'), ('\u{17d7}',
- '\u{17d7}'), ('\u{17dc}', '\u{17dd}'), ('\u{17e0}', '\u{17e9}'), ('\u{180b}', '\u{180d}'),
- ('\u{1810}', '\u{1819}'), ('\u{1820}', '\u{1878}'), ('\u{1880}', '\u{18aa}'), ('\u{18b0}',
- '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{193b}'),
- ('\u{1946}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}',
- '\u{19c9}'), ('\u{19d0}', '\u{19da}'), ('\u{1a00}', '\u{1a1b}'), ('\u{1a20}', '\u{1a5e}'),
- ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1aa7}',
- '\u{1aa7}'), ('\u{1ab0}', '\u{1abd}'), ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', '\u{1b59}'),
- ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1bf3}'), ('\u{1c00}', '\u{1c37}'), ('\u{1c40}',
- '\u{1c49}'), ('\u{1c4d}', '\u{1c7d}'), ('\u{1c80}', '\u{1c88}'), ('\u{1c90}', '\u{1cba}'),
- ('\u{1cbd}', '\u{1cbf}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1cfa}'), ('\u{1d00}',
- '\u{1df9}'), ('\u{1dfb}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'),
- ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}',
- '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'),
- ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}',
- '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'),
- ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{203f}', '\u{2040}'), ('\u{2054}',
- '\u{2054}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'),
- ('\u{20d0}', '\u{20dc}'), ('\u{20e1}', '\u{20e1}'), ('\u{20e5}', '\u{20f0}'), ('\u{2102}',
- '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'),
- ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}',
- '\u{2128}'), ('\u{212a}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'),
- ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}',
- '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'),
- ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}',
- '\u{2d6f}'), ('\u{2d7f}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'),
- ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}',
- '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', '\u{2dff}'),
- ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{302f}'), ('\u{3031}', '\u{3035}'), ('\u{3038}',
- '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{3099}', '\u{309a}'), ('\u{309d}', '\u{309f}'),
- ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312f}'), ('\u{3131}',
- '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'),
- ('\u{4e00}', '\u{9fef}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}',
- '\u{a60c}'), ('\u{a610}', '\u{a62b}'), ('\u{a640}', '\u{a66f}'), ('\u{a674}', '\u{a67d}'),
- ('\u{a67f}', '\u{a6f1}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}',
- '\u{a7bf}'), ('\u{a7c2}', '\u{a7c6}'), ('\u{a7f7}', '\u{a827}'), ('\u{a840}', '\u{a873}'),
- ('\u{a880}', '\u{a8c5}'), ('\u{a8d0}', '\u{a8d9}'), ('\u{a8e0}', '\u{a8f7}'), ('\u{a8fb}',
- '\u{a8fb}'), ('\u{a8fd}', '\u{a92d}'), ('\u{a930}', '\u{a953}'), ('\u{a960}', '\u{a97c}'),
- ('\u{a980}', '\u{a9c0}'), ('\u{a9cf}', '\u{a9d9}'), ('\u{a9e0}', '\u{a9fe}'), ('\u{aa00}',
- '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa50}', '\u{aa59}'), ('\u{aa60}', '\u{aa76}'),
- ('\u{aa7a}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), ('\u{aaf2}',
- '\u{aaf6}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'),
- ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}',
- '\u{ab67}'), ('\u{ab70}', '\u{abea}'), ('\u{abec}', '\u{abed}'), ('\u{abf0}', '\u{abf9}'),
- ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}',
- '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'),
- ('\u{fb1d}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}',
- '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'),
- ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}',
- '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'),
- ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), ('\u{fe71}', '\u{fe71}'), ('\u{fe73}',
- '\u{fe73}'), ('\u{fe77}', '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'),
- ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff10}', '\u{ff19}'), ('\u{ff21}',
- '\u{ff3a}'), ('\u{ff3f}', '\u{ff3f}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'),
- ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}',
- '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}',
- '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}',
- '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{101fd}',
- '\u{101fd}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{102e0}',
- '\u{102e0}'), ('\u{10300}', '\u{1031f}'), ('\u{1032d}', '\u{1034a}'), ('\u{10350}',
- '\u{1037a}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}',
- '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{104a0}',
- '\u{104a9}'), ('\u{104b0}', '\u{104d3}'), ('\u{104d8}', '\u{104fb}'), ('\u{10500}',
- '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}',
- '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}',
- '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}',
- '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}',
- '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}',
- '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}',
- '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}',
- '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a35}'), ('\u{10a38}',
- '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}',
- '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae6}'), ('\u{10b00}',
- '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}',
- '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}',
- '\u{10cf2}'), ('\u{10d00}', '\u{10d27}'), ('\u{10d30}', '\u{10d39}'), ('\u{10f00}',
- '\u{10f1c}'), ('\u{10f27}', '\u{10f27}'), ('\u{10f30}', '\u{10f50}'), ('\u{10fe0}',
- '\u{10ff6}'), ('\u{11000}', '\u{11046}'), ('\u{11066}', '\u{1106f}'), ('\u{1107f}',
- '\u{110ba}'), ('\u{110d0}', '\u{110e8}'), ('\u{110f0}', '\u{110f9}'), ('\u{11100}',
- '\u{11134}'), ('\u{11136}', '\u{1113f}'), ('\u{11144}', '\u{11146}'), ('\u{11150}',
- '\u{11173}'), ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111c4}'), ('\u{111c9}',
- '\u{111cc}'), ('\u{111d0}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}',
- '\u{11211}'), ('\u{11213}', '\u{11237}'), ('\u{1123e}', '\u{1123e}'), ('\u{11280}',
- '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}',
- '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112ea}'), ('\u{112f0}',
- '\u{112f9}'), ('\u{11300}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}',
- '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}',
- '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133b}', '\u{11344}'), ('\u{11347}',
- '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11350}', '\u{11350}'), ('\u{11357}',
- '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}',
- '\u{11374}'), ('\u{11400}', '\u{1144a}'), ('\u{11450}', '\u{11459}'), ('\u{1145e}',
- '\u{1145f}'), ('\u{11480}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{114d0}',
- '\u{114d9}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{115d8}',
- '\u{115dd}'), ('\u{11600}', '\u{11640}'), ('\u{11644}', '\u{11644}'), ('\u{11650}',
- '\u{11659}'), ('\u{11680}', '\u{116b8}'), ('\u{116c0}', '\u{116c9}'), ('\u{11700}',
- '\u{1171a}'), ('\u{1171d}', '\u{1172b}'), ('\u{11730}', '\u{11739}'), ('\u{11800}',
- '\u{1183a}'), ('\u{118a0}', '\u{118e9}'), ('\u{118ff}', '\u{118ff}'), ('\u{119a0}',
- '\u{119a7}'), ('\u{119aa}', '\u{119d7}'), ('\u{119da}', '\u{119e1}'), ('\u{119e3}',
- '\u{119e4}'), ('\u{11a00}', '\u{11a3e}'), ('\u{11a47}', '\u{11a47}'), ('\u{11a50}',
- '\u{11a99}'), ('\u{11a9d}', '\u{11a9d}'), ('\u{11ac0}', '\u{11af8}'), ('\u{11c00}',
- '\u{11c08}'), ('\u{11c0a}', '\u{11c36}'), ('\u{11c38}', '\u{11c40}'), ('\u{11c50}',
- '\u{11c59}'), ('\u{11c72}', '\u{11c8f}'), ('\u{11c92}', '\u{11ca7}'), ('\u{11ca9}',
- '\u{11cb6}'), ('\u{11d00}', '\u{11d06}'), ('\u{11d08}', '\u{11d09}'), ('\u{11d0b}',
- '\u{11d36}'), ('\u{11d3a}', '\u{11d3a}'), ('\u{11d3c}', '\u{11d3d}'), ('\u{11d3f}',
- '\u{11d47}'), ('\u{11d50}', '\u{11d59}'), ('\u{11d60}', '\u{11d65}'), ('\u{11d67}',
- '\u{11d68}'), ('\u{11d6a}', '\u{11d8e}'), ('\u{11d90}', '\u{11d91}'), ('\u{11d93}',
- '\u{11d98}'), ('\u{11da0}', '\u{11da9}'), ('\u{11ee0}', '\u{11ef6}'), ('\u{12000}',
- '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), ('\u{13000}',
- '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}',
- '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16af0}',
- '\u{16af4}'), ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b50}',
- '\u{16b59}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16e40}',
- '\u{16e7f}'), ('\u{16f00}', '\u{16f4a}'), ('\u{16f4f}', '\u{16f87}'), ('\u{16f8f}',
- '\u{16f9f}'), ('\u{16fe0}', '\u{16fe1}'), ('\u{16fe3}', '\u{16fe3}'), ('\u{17000}',
- '\u{187f7}'), ('\u{18800}', '\u{18af2}'), ('\u{1b000}', '\u{1b11e}'), ('\u{1b150}',
- '\u{1b152}'), ('\u{1b164}', '\u{1b167}'), ('\u{1b170}', '\u{1b2fb}'), ('\u{1bc00}',
- '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}',
- '\u{1bc99}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), ('\u{1d16d}',
- '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}',
- '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}',
- '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}',
- '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}',
- '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}',
- '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}',
- '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}',
- '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}',
- '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}',
- '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}',
- '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}',
- '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1da00}',
- '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), ('\u{1da75}', '\u{1da75}'), ('\u{1da84}',
- '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}'), ('\u{1e000}',
- '\u{1e006}'), ('\u{1e008}', '\u{1e018}'), ('\u{1e01b}', '\u{1e021}'), ('\u{1e023}',
- '\u{1e024}'), ('\u{1e026}', '\u{1e02a}'), ('\u{1e100}', '\u{1e12c}'), ('\u{1e130}',
- '\u{1e13d}'), ('\u{1e140}', '\u{1e149}'), ('\u{1e14e}', '\u{1e14e}'), ('\u{1e2c0}',
- '\u{1e2f9}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{1e900}',
- '\u{1e94b}'), ('\u{1e950}', '\u{1e959}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}',
- '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}',
- '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}',
- '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}',
- '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}',
- '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}',
- '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}',
- '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}',
- '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}',
- '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}',
- '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}',
- '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}',
- '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2ceb0}',
- '\u{2ebe0}'), ('\u{2f800}', '\u{2fa1d}'), ('\u{e0100}', '\u{e01ef}')
- ];
-
- pub fn XID_Continue(c: char) -> bool {
- super::bsearch_range_table(c, XID_Continue_table)
- }
-
- pub const XID_Start_table: &[(char, char)] = &[
- ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'),
- ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'),
- ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}',
- '\u{2ee}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'),
- ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}',
- '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'),
- ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{560}',
- '\u{588}'), ('\u{5d0}', '\u{5ea}'), ('\u{5ef}', '\u{5f2}'), ('\u{620}', '\u{64a}'),
- ('\u{66e}', '\u{66f}'), ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6e5}',
- '\u{6e6}'), ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'),
- ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), ('\u{7b1}',
- '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'),
- ('\u{800}', '\u{815}'), ('\u{81a}', '\u{81a}'), ('\u{824}', '\u{824}'), ('\u{828}',
- '\u{828}'), ('\u{840}', '\u{858}'), ('\u{860}', '\u{86a}'), ('\u{8a0}', '\u{8b4}'),
- ('\u{8b6}', '\u{8bd}'), ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), ('\u{950}',
- '\u{950}'), ('\u{958}', '\u{961}'), ('\u{971}', '\u{980}'), ('\u{985}', '\u{98c}'),
- ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}',
- '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'),
- ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{9fc}',
- '\u{9fc}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'),
- ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}',
- '\u{a39}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a72}', '\u{a74}'),
- ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}',
- '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{abd}'),
- ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), ('\u{af9}', '\u{af9}'), ('\u{b05}',
- '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'),
- ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b3d}'), ('\u{b5c}',
- '\u{b5d}'), ('\u{b5f}', '\u{b61}'), ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'),
- ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}',
- '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'),
- ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bd0}', '\u{bd0}'), ('\u{c05}',
- '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'),
- ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c61}'), ('\u{c80}',
- '\u{c80}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'),
- ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cbd}'), ('\u{cde}',
- '\u{cde}'), ('\u{ce0}', '\u{ce1}'), ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'),
- ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), ('\u{d4e}',
- '\u{d4e}'), ('\u{d54}', '\u{d56}'), ('\u{d5f}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'),
- ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}',
- '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), ('\u{e32}', '\u{e32}'),
- ('\u{e40}', '\u{e46}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e86}',
- '\u{e8a}'), ('\u{e8c}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{eb0}'),
- ('\u{eb2}', '\u{eb2}'), ('\u{ebd}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}',
- '\u{ec6}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'),
- ('\u{f49}', '\u{f6c}'), ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}',
- '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), ('\u{1061}', '\u{1061}'),
- ('\u{1065}', '\u{1066}'), ('\u{106e}', '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}',
- '\u{108e}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'),
- ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}',
- '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'),
- ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}',
- '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'),
- ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{1380}',
- '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'),
- ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}',
- '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'),
- ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1780}',
- '\u{17b3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1878}'),
- ('\u{1880}', '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}',
- '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'),
- ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1aa7}',
- '\u{1aa7}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b83}', '\u{1ba0}'),
- ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), ('\u{1c4d}',
- '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1c80}', '\u{1c88}'), ('\u{1c90}', '\u{1cba}'),
- ('\u{1cbd}', '\u{1cbf}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf3}'), ('\u{1cf5}',
- '\u{1cf6}'), ('\u{1cfa}', '\u{1cfa}'), ('\u{1d00}', '\u{1dbf}'), ('\u{1e00}', '\u{1f15}'),
- ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}',
- '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'),
- ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}',
- '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'),
- ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}',
- '\u{1ffc}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'),
- ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}',
- '\u{2115}'), ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'),
- ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}',
- '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c00}', '\u{2c2e}'),
- ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}',
- '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'),
- ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}',
- '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'),
- ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}',
- '\u{2dde}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3031}', '\u{3035}'),
- ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}',
- '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312f}'), ('\u{3131}', '\u{318e}'),
- ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}',
- '\u{9fef}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'),
- ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a67f}',
- '\u{a69d}'), ('\u{a6a0}', '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'),
- ('\u{a78b}', '\u{a7bf}'), ('\u{a7c2}', '\u{a7c6}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}',
- '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'),
- ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}',
- '\u{a8fe}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'),
- ('\u{a984}', '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}',
- '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'),
- ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}',
- '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'),
- ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}',
- '\u{aaea}'), ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'),
- ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}',
- '\u{ab5a}'), ('\u{ab5c}', '\u{ab67}'), ('\u{ab70}', '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'),
- ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}',
- '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb1d}'),
- ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}',
- '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'),
- ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}',
- '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), ('\u{fe71}', '\u{fe71}'), ('\u{fe73}', '\u{fe73}'),
- ('\u{fe77}', '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'), ('\u{fe7d}',
- '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'),
- ('\u{ff66}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}',
- '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'),
- ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'),
- ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'),
- ('\u{10140}', '\u{10174}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'),
- ('\u{10300}', '\u{1031f}'), ('\u{1032d}', '\u{1034a}'), ('\u{10350}', '\u{10375}'),
- ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'),
- ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{104b0}', '\u{104d3}'),
- ('\u{104d8}', '\u{104fb}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'),
- ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'),
- ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'),
- ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'),
- ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'),
- ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'),
- ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a00}'),
- ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a35}'),
- ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'),
- ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'),
- ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'),
- ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{10d00}', '\u{10d23}'),
- ('\u{10f00}', '\u{10f1c}'), ('\u{10f27}', '\u{10f27}'), ('\u{10f30}', '\u{10f45}'),
- ('\u{10fe0}', '\u{10ff6}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'),
- ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11144}', '\u{11144}'),
- ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'),
- ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'),
- ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{11280}', '\u{11286}'),
- ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'),
- ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'),
- ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'),
- ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'),
- ('\u{11350}', '\u{11350}'), ('\u{1135d}', '\u{11361}'), ('\u{11400}', '\u{11434}'),
- ('\u{11447}', '\u{1144a}'), ('\u{1145f}', '\u{1145f}'), ('\u{11480}', '\u{114af}'),
- ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'),
- ('\u{115d8}', '\u{115db}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'),
- ('\u{11680}', '\u{116aa}'), ('\u{116b8}', '\u{116b8}'), ('\u{11700}', '\u{1171a}'),
- ('\u{11800}', '\u{1182b}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'),
- ('\u{119a0}', '\u{119a7}'), ('\u{119aa}', '\u{119d0}'), ('\u{119e1}', '\u{119e1}'),
- ('\u{119e3}', '\u{119e3}'), ('\u{11a00}', '\u{11a00}'), ('\u{11a0b}', '\u{11a32}'),
- ('\u{11a3a}', '\u{11a3a}'), ('\u{11a50}', '\u{11a50}'), ('\u{11a5c}', '\u{11a89}'),
- ('\u{11a9d}', '\u{11a9d}'), ('\u{11ac0}', '\u{11af8}'), ('\u{11c00}', '\u{11c08}'),
- ('\u{11c0a}', '\u{11c2e}'), ('\u{11c40}', '\u{11c40}'), ('\u{11c72}', '\u{11c8f}'),
- ('\u{11d00}', '\u{11d06}'), ('\u{11d08}', '\u{11d09}'), ('\u{11d0b}', '\u{11d30}'),
- ('\u{11d46}', '\u{11d46}'), ('\u{11d60}', '\u{11d65}'), ('\u{11d67}', '\u{11d68}'),
- ('\u{11d6a}', '\u{11d89}'), ('\u{11d98}', '\u{11d98}'), ('\u{11ee0}', '\u{11ef2}'),
- ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'),
- ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'),
- ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'),
- ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'),
- ('\u{16e40}', '\u{16e7f}'), ('\u{16f00}', '\u{16f4a}'), ('\u{16f50}', '\u{16f50}'),
- ('\u{16f93}', '\u{16f9f}'), ('\u{16fe0}', '\u{16fe1}'), ('\u{16fe3}', '\u{16fe3}'),
- ('\u{17000}', '\u{187f7}'), ('\u{18800}', '\u{18af2}'), ('\u{1b000}', '\u{1b11e}'),
- ('\u{1b150}', '\u{1b152}'), ('\u{1b164}', '\u{1b167}'), ('\u{1b170}', '\u{1b2fb}'),
- ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'),
- ('\u{1bc90}', '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'),
- ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'),
- ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'),
- ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'),
- ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'),
- ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'),
- ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'),
- ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'),
- ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'),
- ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'),
- ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e100}', '\u{1e12c}'), ('\u{1e137}', '\u{1e13d}'),
- ('\u{1e14e}', '\u{1e14e}'), ('\u{1e2c0}', '\u{1e2eb}'), ('\u{1e800}', '\u{1e8c4}'),
- ('\u{1e900}', '\u{1e943}'), ('\u{1e94b}', '\u{1e94b}'), ('\u{1ee00}', '\u{1ee03}'),
- ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'),
- ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'),
- ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'),
- ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'),
- ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'),
- ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'),
- ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'),
- ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'),
- ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'),
- ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'),
- ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'),
- ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'),
- ('\u{2ceb0}', '\u{2ebe0}'), ('\u{2f800}', '\u{2fa1d}')
- ];
-
- pub fn XID_Start(c: char) -> bool {
- super::bsearch_range_table(c, XID_Start_table)
- }
-
-}
-
diff --git a/unicode-xid/src/tests.rs b/unicode-xid/src/tests.rs
deleted file mode 100644
index 3c9b731..0000000
--- a/unicode-xid/src/tests.rs
+++ /dev/null
@@ -1,111 +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.
-
-#[cfg(feature = "bench")]
-use std::iter;
-#[cfg(feature = "bench")]
-use test::Bencher;
-#[cfg(feature = "bench")]
-use std::prelude::v1::*;
-
-#[cfg(feature = "bench")]
-#[bench]
-fn cargo_is_xid_start(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.bytes = string.len() as u64;
- b.iter(|| {
- string.chars().all(super::UnicodeXID::is_xid_start)
- });
-}
-
-#[cfg(feature = "bench")]
-#[bench]
-fn stdlib_is_xid_start(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.bytes = string.len() as u64;
- b.iter(|| {
- string.chars().all(char::is_xid_start)
- });
-}
-
-#[cfg(feature = "bench")]
-#[bench]
-fn cargo_xid_continue(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.bytes = string.len() as u64;
- b.iter(|| {
- string.chars().all(super::UnicodeXID::is_xid_continue)
- });
-}
-
-#[cfg(feature = "bench")]
-#[bench]
-fn stdlib_xid_continue(b: &mut Bencher) {
- let string = iter::repeat('a').take(4096).collect::<String>();
-
- b.bytes = string.len() as u64;
- b.iter(|| {
- string.chars().all(char::is_xid_continue)
- });
-}
-
-#[test]
-fn test_is_xid_start() {
- let chars = [
- 'A', 'Z', 'a', 'z',
- '\u{1000d}', '\u{10026}',
- ];
-
- for ch in &chars {
- assert!(super::UnicodeXID::is_xid_start(*ch), "{}", ch);
- }
-}
-
-#[test]
-fn test_is_not_xid_start() {
- let chars = [
- '\x00', '\x01',
- '0', '9',
- ' ', '[', '<', '{', '(',
- '\u{02c2}', '\u{ffff}',
- ];
-
- for ch in &chars {
- assert!(!super::UnicodeXID::is_xid_start(*ch), "{}", ch);
- }
-}
-
-#[test]
-fn test_is_xid_continue() {
- let chars = [
- '0', '9', 'A', 'Z', 'a', 'z', '_',
- '\u{1000d}', '\u{10026}',
- ];
-
- for ch in &chars {
- assert!(super::UnicodeXID::is_xid_continue(*ch), "{}", ch);
- }
-}
-
-#[test]
-fn test_is_not_xid_continue() {
- let chars = [
- '\x00', '\x01',
- ' ', '[', '<', '{', '(',
- '\u{02c2}', '\u{ffff}',
- ];
-
- for &ch in &chars {
- assert!(!super::UnicodeXID::is_xid_continue(ch), "{}", ch);
- }
-}
diff --git a/nitrocli/var/binary-size.py b/var/binary-size.py
index 3653814..ff1ac6b 100755
--- a/nitrocli/var/binary-size.py
+++ b/var/binary-size.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3 -B
#/***************************************************************************
-# * 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 *
@@ -86,9 +86,8 @@ def resolveCommit(commit):
def determineSizeAt(root, rev):
"""Determine the size of the nitrocli release build binary at the given git revision."""
sha1 = resolveCommit(rev)
- with TemporaryDirectory() as d:
- cwd = join(d, "nitrocli")
- check_call(["git", "clone", root, d])
+ with TemporaryDirectory() as cwd:
+ check_call(["git", "clone", root, cwd])
check_call(["git", "checkout", "--quiet", sha1], cwd=cwd)
check_call(["cargo", "build", "--quiet", "--release"], cwd=cwd)
diff --git a/var/shell-complete.rs b/var/shell-complete.rs
new file mode 100644
index 0000000..a6f476d
--- /dev/null
+++ b/var/shell-complete.rs
@@ -0,0 +1,167 @@
+// 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 {
+ ( $(#[$docs:meta])* $name:ident, [
+ $( $(#[$doc:meta])* $var:ident$(($inner:ty))? => $exec:expr, ) *
+ ] ) => {
+ $(#[$docs])*
+ #[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"
+ );
+ }
+}