diff options
| author | bors <bors@rust-lang.org> | 2017-02-14 07:06:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-02-14 07:06:25 +0000 |
| commit | 48bc08247a7b4a5579437df54ca3f4a3fb25ce8d (patch) | |
| tree | 8fbb2097c8787f3ad9d9ae638bab427143e01c8f | |
| parent | 55013cddefbd8e2616370a72df785c20880189ce (diff) | |
| parent | d29f0bc8fa166117e62b1fa2969dd31f415fd887 (diff) | |
| download | rust-48bc08247a7b4a5579437df54ca3f4a3fb25ce8d.tar.gz rust-48bc08247a7b4a5579437df54ca3f4a3fb25ce8d.zip | |
Auto merge of #39728 - eddyb:vendeur-tres-bien, r=alexcrichton
Automate vendoring by invoking cargo-vendor when building src dist tarballs. This avoids #39633 bringing the `src/vendor` checked into git by #37524, past 200,000 lines of code. I believe the strategy of having rustbuild run `cargo vendor` during the `dist src` step is sound. However, the only way to be sure `cargo-vendor` exists is to run `cargo install --force cargo-vendor`, which will recompile it every time (not passing `--force` means you can't tell between "already exists" and "build error"). ~~This is quite suboptimal and I'd like to somehow do it in each `Dockerfile` that would need it.~~ * [ ] Cache `CARGO_HOME` (i.e. `~/.cargo`) between CI runs * `bin/cargo-vendor` and the actual caches are the relevant bits * [x] Do not build `cargo-vendor` all the time * ~~Maybe detect `~/.cargo/bin/cargo-vendor` already exists?~~ * ~~Could also try to build it in a `Dockerfile` but do we have `cargo`/`rustc` there?~~ * Final solution: check `cargo install --list` for a line starting with `cargo-vendor ` cc @rust-lang/tools
355 files changed, 106 insertions, 39932 deletions
diff --git a/.travis.yml b/.travis.yml index a776f1b1e10..a3bcc85998b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,15 +47,24 @@ matrix: install: &osx_install_sccache > curl -L https://api.pub.build.mozilla.org/tooltool/sha512/d0025b286468cc5ada83b23d3fafbc936b9f190eaa7d4a981715b18e8e3bf720a7bcee7bfe758cfdeb8268857f6098fd52dcdd8818232692a30ce91039936596 | tar xJf - -C /usr/local/bin --strip-components=1 + - env: > + RUST_CHECK_TARGET=check + RUST_CONFIGURE_ARGS=--build=i686-apple-darwin + SRC=. + os: osx + osx_image: xcode8.2 + install: *osx_install_sccache - env: > - SCRIPT="./x.py test && ./x.py dist" + RUST_CHECK_TARGET=dist RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-extended" SRC=. DEPLOY=1 os: osx osx_image: xcode8.2 - install: *osx_install_sccache + install: > + curl -L https://api.pub.build.mozilla.org/tooltool/sha512/d0025b286468cc5ada83b23d3fafbc936b9f190eaa7d4a981715b18e8e3bf720a7bcee7bfe758cfdeb8268857f6098fd52dcdd8818232692a30ce91039936596 | + tar xJf - -C /usr/local/bin --strip-components=1 && brew uninstall --ignore-dependencies openssl && brew install openssl --universal --without-test - env: > RUST_CHECK_TARGET=dist RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-extended" diff --git a/appveyor.yml b/appveyor.yml index 2183d8da95f..9fff2f3c8b4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,6 @@ environment: # MSVC cargotest - MSYS_BITS: 64 - NO_VENDOR: 1 RUST_CHECK_TARGET: check-aux RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc diff --git a/configure b/configure index d529375277b..372ee756534 100755 --- a/configure +++ b/configure @@ -647,6 +647,7 @@ opt llvm-version-check 1 "check if the LLVM version is supported, build anyway" opt codegen-tests 1 "run the src/test/codegen tests" opt option-checking 1 "complain about unrecognized options in this configure script" opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)" +opt locked-deps 0 "force Cargo.lock to be up to date" opt vendor 0 "enable usage of vendored Rust crates" opt sanitizers 0 "build the sanitizer runtimes (asan, lsan, msan, tsan)" diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index caf2402f40c..ee3f663dbd5 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -294,6 +294,8 @@ class RustBuild(object): raise Exception("no cargo executable found at `%s`" % self.cargo()) args = [self.cargo(), "build", "--manifest-path", os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")] + if self.use_locked_deps: + args.append("--locked") if self.use_vendored_sources: args.append("--frozen") self.run(args, env) @@ -455,6 +457,9 @@ def main(): rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \ 'CFG_ENABLE_VENDOR' in rb.config_mk + rb.use_locked_deps = '\nlocked-deps = true' in rb.config_toml or \ + 'CFG_ENABLE_LOCKED_DEPS' in rb.config_mk + if 'SUDO_USER' in os.environ and not rb.use_vendored_sources: if os.environ.get('USER') != os.environ['SUDO_USER']: rb.use_vendored_sources = True diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index cbfbcbe4f0c..00758460bec 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -108,8 +108,12 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) { pub fn tidy(build: &Build, host: &str) { println!("tidy check ({})", host); let compiler = Compiler::new(0, host); - build.run(build.tool_cmd(&compiler, "tidy") - .arg(build.src.join("src"))); + let mut cmd = build.tool_cmd(&compiler, "tidy"); + cmd.arg(build.src.join("src")); + if !build.config.vendor { + cmd.arg("--no-vendor"); + } + build.run(&mut cmd); } fn testdir(build: &Build, host: &str) -> PathBuf { @@ -643,6 +647,7 @@ pub fn distcheck(build: &Build) { build.run(&mut cmd); build.run(Command::new("./configure") .args(&build.config.configure_args) + .arg("--enable-vendor") .current_dir(&dir)); build.run(Command::new(build_helper::make(&build.config.build)) .arg("check") diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 47f505ad37e..e95416be4b6 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -44,6 +44,7 @@ pub struct Config { pub submodules: bool, pub compiler_docs: bool, pub docs: bool, + pub locked_deps: bool, pub vendor: bool, pub target_config: HashMap<String, Target>, pub full_bootstrap: bool, @@ -145,6 +146,7 @@ struct Build { docs: Option<bool>, submodules: Option<bool>, gdb: Option<String>, + locked_deps: Option<bool>, vendor: Option<bool>, nodejs: Option<String>, python: Option<String>, @@ -294,6 +296,7 @@ impl Config { set(&mut config.compiler_docs, build.compiler_docs); set(&mut config.docs, build.docs); set(&mut config.submodules, build.submodules); + set(&mut config.locked_deps, build.locked_deps); set(&mut config.vendor, build.vendor); set(&mut config.full_bootstrap, build.full_bootstrap); set(&mut config.extended, build.extended); @@ -440,6 +443,7 @@ impl Config { ("LOCAL_REBUILD", self.local_rebuild), ("NINJA", self.ninja), ("CODEGEN_TESTS", self.codegen_tests), + ("LOCKED_DEPS", self.locked_deps), ("VENDOR", self.vendor), ("FULL_BOOTSTRAP", self.full_bootstrap), ("EXTENDED", self.extended), diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 5f4303a728c..f95e890f346 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -108,6 +108,10 @@ # Note that Python 2 is currently required. #python = "python2.7" +# Force Cargo to check that Cargo.lock describes the precise dependency +# set that all the Cargo.toml files create, instead of updating it. +#locked-deps = false + # Indicate whether the vendored sources are used for Rust dependencies or not #vendor = false diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 2da2892150b..52a7c63c904 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -360,6 +360,8 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) { t!(fs::remove_dir_all(&image)); } +const CARGO_VENDOR_VERSION: &'static str = "0.1.4"; + /// Creates the `rust-src` installer component and the plain source tarball pub fn rust_src(build: &Build) { println!("Dist src"); @@ -404,13 +406,6 @@ pub fn rust_src(build: &Build) { } } - // If we're inside the vendor directory then we need to preserve - // everything as Cargo's vendoring support tracks all checksums and we - // want to be sure we don't accidentally leave out a file. - if spath.contains("vendor") { - return true - } - let excludes = [ "CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules", ".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}", @@ -433,6 +428,29 @@ pub fn rust_src(build: &Build) { copy(&build.src.join(item), &dst_src.join(item)); } + // Get cargo-vendor installed, if it isn't already. + let mut has_cargo_vendor = false; + let mut cmd = Command::new(&build.cargo); + for line in output(cmd.arg("install").arg("--list")).lines() { + has_cargo_vendor |= line.starts_with("cargo-vendor "); + } + if !has_cargo_vendor { + let mut cmd = Command::new(&build.cargo); + cmd.arg("install") + .arg("--force") + .arg("--debug") + .arg("--vers").arg(CARGO_VENDOR_VERSION) + .arg("cargo-vendor") + .env("RUSTC", &build.rustc); + build.run(&mut cmd); + } + + // Vendor all Cargo dependencies + let mut cmd = Command::new(&build.cargo); + cmd.arg("vendor") + .current_dir(&dst_src.join("src")); + build.run(&mut cmd); + // Create source tarball in rust-installer format let mut cmd = Command::new("sh"); cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index ba6b34343f0..7bd611eb53e 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -528,6 +528,9 @@ impl Build { if self.config.rust_optimize && cmd != "bench" { cargo.arg("--release"); } + if self.config.locked_deps { + cargo.arg("--locked"); + } if self.config.vendor || self.is_sudo { cargo.arg("--frozen"); } diff --git a/src/ci/docker/android/Dockerfile b/src/ci/docker/android/Dockerfile index e3748af501f..ae1bfd9e40a 100644 --- a/src/ci/docker/android/Dockerfile +++ b/src/ci/docker/android/Dockerfile @@ -16,7 +16,9 @@ RUN dpkg --add-architecture i386 && \ openjdk-9-jre \ sudo \ libstdc++6:i386 \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config WORKDIR /android/ ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile index 29a5e7bcafb..52c5b83f263 100644 --- a/src/ci/docker/cross/Dockerfile +++ b/src/ci/docker/cross/Dockerfile @@ -17,7 +17,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-sparc64-linux-gnu \ libc6-dev-sparc64-cross \ bzip2 \ - patch + patch \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-arm-linux/Dockerfile b/src/ci/docker/dist-arm-linux/Dockerfile index 217a724fb9a..e5619564b05 100644 --- a/src/ci/docker/dist-arm-linux/Dockerfile +++ b/src/ci/docker/dist-arm-linux/Dockerfile @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ texinfo \ wget \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile index f26885bbb53..5b94d5a9727 100644 --- a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile +++ b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ texinfo \ wget \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-freebsd/Dockerfile b/src/ci/docker/dist-freebsd/Dockerfile index d824c4041ce..c39e298e3ce 100644 --- a/src/ci/docker/dist-freebsd/Dockerfile +++ b/src/ci/docker/dist-freebsd/Dockerfile @@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ bzip2 \ xz-utils \ - wget + wget \ + libssl-dev \ + pkg-config COPY build-toolchain.sh /tmp/ RUN /tmp/build-toolchain.sh x86_64 diff --git a/src/ci/docker/dist-mips-linux/Dockerfile b/src/ci/docker/dist-mips-linux/Dockerfile index 38ee95038f6..5d8b3cfeae2 100644 --- a/src/ci/docker/dist-mips-linux/Dockerfile +++ b/src/ci/docker/dist-mips-linux/Dockerfile @@ -13,7 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils \ g++-mips-linux-gnu \ - g++-mipsel-linux-gnu + g++-mipsel-linux-gnu \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-mips64-linux/Dockerfile b/src/ci/docker/dist-mips64-linux/Dockerfile index c9d89d62874..8feba12e722 100644 --- a/src/ci/docker/dist-mips64-linux/Dockerfile +++ b/src/ci/docker/dist-mips64-linux/Dockerfile @@ -13,7 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils \ g++-mips64-linux-gnuabi64 \ - g++-mips64el-linux-gnuabi64 + g++-mips64el-linux-gnuabi64 \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-powerpc-linux/Dockerfile b/src/ci/docker/dist-powerpc-linux/Dockerfile index 640bacc54eb..e5ffbfc090d 100644 --- a/src/ci/docker/dist-powerpc-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc-linux/Dockerfile @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ texinfo \ wget \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-powerpc64-linux/Dockerfile b/src/ci/docker/dist-powerpc64-linux/Dockerfile index 624763ef5de..7d13bc3d438 100644 --- a/src/ci/docker/dist-powerpc64-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc64-linux/Dockerfile @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ texinfo \ wget \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile b/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile index 589b5fd530f..7f4c6d4647c 100644 --- a/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile +++ b/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ texinfo \ wget \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/dist-x86-linux/Dockerfile b/src/ci/docker/dist-x86-linux/Dockerfile index 12e24ff1af6..61c23201c2c 100644 --- a/src/ci/docker/dist-x86-linux/Dockerfile +++ b/src/ci/docker/dist-x86-linux/Dockerfile @@ -13,13 +13,14 @@ RUN yum upgrade -y && yum install -y \ file \ xz \ which \ - pkg-config \ + pkgconfig \ wget \ autoconf \ gettext ENV PATH=/rustroot/bin:$PATH ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib +ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig WORKDIR /tmp COPY shared.sh build-binutils.sh /tmp/ diff --git a/src/ci/docker/i686-gnu/Dockerfile b/src/ci/docker/i686-gnu/Dockerfile index 6583f09be36..84b98712b33 100644 --- a/src/ci/docker/i686-gnu/Dockerfile +++ b/src/ci/docker/i686-gnu/Dockerfile @@ -23,4 +23,4 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu -ENV SCRIPT python2.7 ../x.py test && python2.7 ../x.py dist +ENV SCRIPT python2.7 ../x.py test diff --git a/src/ci/docker/linux-tested-targets/Dockerfile b/src/ci/docker/linux-tested-targets/Dockerfile index 2a43201ed0a..feb73bebbdb 100644 --- a/src/ci/docker/linux-tested-targets/Dockerfile +++ b/src/ci/docker/linux-tested-targets/Dockerfile @@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ xz-utils \ sudo \ gdb \ - patch + patch \ + libssl-dev \ + pkg-config WORKDIR /build/ COPY musl-libunwind-patch.patch build-musl.sh /build/ diff --git a/src/ci/docker/x86_64-gnu-aux/Dockerfile b/src/ci/docker/x86_64-gnu-aux/Dockerfile index 0ec0bfd1897..607163ea547 100644 --- a/src/ci/docker/x86_64-gnu-aux/Dockerfile +++ b/src/ci/docker/x86_64-gnu-aux/Dockerfile @@ -25,4 +25,3 @@ ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu ENV RUST_CHECK_TARGET check-aux -ENV NO_VENDOR 1 diff --git a/src/ci/docker/x86_64-gnu-distcheck/Dockerfile b/src/ci/docker/x86_64-gnu-distcheck/Dockerfile index 57a2c103f1e..ad6c0c15f72 100644 --- a/src/ci/docker/x86_64-gnu-distcheck/Dockerfile +++ b/src/ci/docker/x86_64-gnu-distcheck/Dockerfile @@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ sudo \ gdb \ - xz-utils + xz-utils \ + libssl-dev \ + pkg-config ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ diff --git a/src/ci/docker/x86_64-gnu/Dockerfile b/src/ci/docker/x86_64-gnu/Dockerfile index e903b6ddc64..427498fabb2 100644 --- a/src/ci/docker/x86_64-gnu/Dockerfile +++ b/src/ci/docker/x86_64-gnu/Dockerfile @@ -23,4 +23,4 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu --enable-sanitizers -ENV SCRIPT python2.7 ../x.py test && python2.7 ../x.py dist +ENV SCRIPT python2.7 ../x.py test diff --git a/src/ci/run.sh b/src/ci/run.sh index 960acc4de7d..c161d998036 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -23,6 +23,7 @@ fi RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" +RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" # If we're deploying artifacts then we set the release channel, otherwise if # we're not deploying then we want to be sure to enable all assertions becauase @@ -47,13 +48,6 @@ else fi fi -# We want to enable usage of the `src/vendor` dir as much as possible, but not -# all test suites have all their deps in there (just the main bootstrap) so we -# have the ability to disable this flag -if [ "$NO_VENDOR" = "" ]; then - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-vendor" -fi - set -ex $SRC/configure $RUST_CONFIGURE_ARGS diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 9962c6ec9af..1bb7919c1d3 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -42,6 +42,8 @@ fn main() { let path = env::args_os().skip(1).next().expect("need an argument"); let path = PathBuf::from(path); + let args: Vec<String> = env::args().skip(1).collect(); + let mut bad = false; bins::check(&path, &mut bad); style::check(&path, &mut bad); @@ -49,7 +51,9 @@ fn main() { cargo::check(&path, &mut bad); features::check(&path, &mut bad); pal::check(&path, &mut bad); - deps::check(&path, &mut bad); + if !args.iter().any(|s| *s == "--no-vendor") { + deps::check(&path, &mut bad); + } if bad { panic!("some tidy checks failed"); diff --git a/src/vendor/cmake/.cargo-checksum.json b/src/vendor/cmake/.cargo-checksum.json deleted file mode 100644 index b81d7d2fa04..00000000000 --- a/src/vendor/cmake/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"c1e953ee360e77de57f7b02f1b7880bd6a3dc22d1a69e953c2ac2c52cc52d247",".travis.yml":"5d83ed1ae0b80cd6cebfc6a25b1fdb58c893ead400f0f84cd0ebf08d9ad48b28","Cargo.toml":"2266412ecb4504137a90d378ebdbf3a41f0e8b7188858cfb149da54792f7f8d9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"8ca528d20639506546044c676ff9069e3e850937b02bff4194dcf9e5c3c50d64","src/lib.rs":"dae5d93c005bf8d16427e29eb3bfb50c5527a1ec7c39a383d0694a8e8e38af90","src/registry.rs":"ca16433f51b5e3aedb0560bba41370b0c42de9238926a5118d1c0a3a072b64b2"},"package":"0e5bcf27e097a184c1df4437654ed98df3d7a516e8508a6ba45d8b092bbdf283"} \ No newline at end of file diff --git a/src/vendor/cmake/.cargo-ok b/src/vendor/cmake/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/cmake/.cargo-ok +++ /dev/null diff --git a/src/vendor/cmake/.gitignore b/src/vendor/cmake/.gitignore deleted file mode 100644 index 4fffb2f89cb..00000000000 --- a/src/vendor/cmake/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/src/vendor/cmake/.travis.yml b/src/vendor/cmake/.travis.yml deleted file mode 100644 index 3ac040c5c09..00000000000 --- a/src/vendor/cmake/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -sudo: false -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH -script: - - cargo test --verbose - - cargo doc --no-deps -after_success: - - travis-cargo --only nightly doc-upload -env: - global: - secure: WSQJRyheeMf7eRdivHextSEQzyFnTIw2yeemO2+ZkHVftp0XYsTXQVca3RGlQNsVmjI0RP8lbDVe7HG23uwbTMeRgm+9hzSwNMa0ndJZ06TNMpPM6nqcXFUaNGeuf7EqU370xcgVBO+ZA0cSh55pJkOBg5ALd9bfRWbjEAjHkx8= -notifications: - email: - on_success: never diff --git a/src/vendor/cmake/Cargo.toml b/src/vendor/cmake/Cargo.toml deleted file mode 100644 index c17bbff9225..00000000000 --- a/src/vendor/cmake/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] - -name = "cmake" -version = "0.1.18" -authors = ["Alex Crichton <alex@alexcrichton.com>"] -license = "MIT/Apache-2.0" -readme = "README.md" -keywords = ["build-dependencies"] -repository = "https://github.com/alexcrichton/cmake-rs" -homepage = "https://github.com/alexcrichton/cmake-rs" -documentation = "http://alexcrichton.com/cmake-rs" -description = """ -A build dependency for running `cmake` to build a native library -""" - -[dependencies] -gcc = "0.3.17" diff --git a/src/vendor/cmake/LICENSE-APACHE b/src/vendor/cmake/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/cmake/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/src/vendor/cmake/LICENSE-MIT b/src/vendor/cmake/LICENSE-MIT deleted file mode 100644 index 39e0ed66021..00000000000 --- a/src/vendor/cmake/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/src/vendor/cmake/README.md b/src/vendor/cmake/README.md deleted file mode 100644 index 8b2586eb01e..00000000000 --- a/src/vendor/cmake/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# cmake - -[](https://travis-ci.org/alexcrichton/cmake-rs) - -[Documentation](http://alexcrichton.com/cmake-rs) - -A build dependency for running the `cmake` build tool to compile a native -library. - -```toml -# Cargo.toml -[build-dependencies] -cmake = "0.2" -``` - -# License - -`cmake-rs` is primarily distributed under the terms of both the MIT license and -the Apache License (Version 2.0), with portions covered by various BSD-like -licenses. - -See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/src/vendor/cmake/src/lib.rs b/src/vendor/cmake/src/lib.rs deleted file mode 100644 index 3607d29026a..00000000000 --- a/src/vendor/cmake/src/lib.rs +++ /dev/null @@ -1,522 +0,0 @@ -//! A build dependency for running `cmake` to build a native library -//! -//! This crate provides some necessary boilerplate and shim support for running -//! the system `cmake` command to build a native library. It will add -//! appropriate cflags for building code to link into Rust, handle cross -//! compilation, and use the necessary generator for the platform being -//! targeted. -//! -//! The builder-style configuration allows for various variables and such to be -//! passed down into the build as well. -//! -//! ## Installation -//! -//! Add this to your `Cargo.toml`: -//! -//! ```toml -//! [build-dependencies] -//! cmake = "0.1" -//! ``` -//! -//! ## Examples -//! -//! ```no_run -//! use cmake; -//! -//! // Builds the project in the directory located in `libfoo`, installing it -//! // into $OUT_DIR -//! let dst = cmake::build("libfoo"); -//! -//! println!("cargo:rustc-link-search=native={}", dst.display()); -//! println!("cargo:rustc-link-lib=static=foo"); -//! ``` -//! -//! ```no_run -//! use cmake::Config; -//! -//! let dst = Config::new("libfoo") -//! .define("FOO", "BAR") -//! .cflag("-foo") -//! .build(); -//! println!("cargo:rustc-link-search=native={}", dst.display()); -//! println!("cargo:rustc-link-lib=static=foo"); -//! ``` - -#![deny(missing_docs)] - -extern crate gcc; - -use std::env; -use std::ffi::{OsString, OsStr}; -use std::fs::{self, File}; -use std::io::ErrorKind; -use std::io::prelude::*; -use std::path::{Path, PathBuf}; -use std::process::Command; - -#[cfg(windows)] -mod registry; - -/// Builder style configuration for a pending CMake build. -pub struct Config { - path: PathBuf, - generator: Option<OsString>, - cflags: OsString, - cxxflags: OsString, - defines: Vec<(OsString, OsString)>, - deps: Vec<String>, - target: Option<String>, - host: Option<String>, - out_dir: Option<PathBuf>, - profile: Option<String>, - build_args: Vec<OsString>, - cmake_target: Option<String>, -} - -/// Builds the native library rooted at `path` with the default cmake options. -/// This will return the directory in which the library was installed. -/// -/// # Examples -/// -/// ```no_run -/// use cmake; -/// -/// // Builds the project in the directory located in `libfoo`, installing it -/// // into $OUT_DIR -/// let dst = cmake::build("libfoo"); -/// -/// println!("cargo:rustc-link-search=native={}", dst.display()); -/// println!("cargo:rustc-link-lib=static=foo"); -/// ``` -/// -pub fn build<P: AsRef<Path>>(path: P) -> PathBuf { - Config::new(path.as_ref()).build() -} - -impl Config { - /// Creates a new blank set of configuration to build the project specified - /// at the path `path`. - pub fn new<P: AsRef<Path>>(path: P) -> Config { - Config { - path: env::current_dir().unwrap().join(path), - generator: None, - cflags: OsString::new(), - cxxflags: OsString::new(), - defines: Vec::new(), - deps: Vec::new(), - profile: None, - out_dir: None, - target: None, - host: None, - build_args: Vec::new(), - cmake_target: None, - } - } - - /// Sets the build-tool generator (`-G`) for this compilation. - pub fn generator<T: AsRef<OsStr>>(&mut self, generator: T) -> &mut Config { - self.generator = Some(generator.as_ref().to_owned()); - self - } - - /// Adds a custom flag to pass down to the C compiler, supplementing those - /// that this library already passes. - pub fn cflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config { - self.cflags.push(" "); - self.cflags.push(flag.as_ref()); - self - } - - /// Adds a custom flag to pass down to the C++ compiler, supplementing those - /// that this library already passes. - pub fn cxxflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config { - self.cxxflags.push(" "); - self.cxxflags.push(flag.as_ref()); - self - } - - /// Adds a new `-D` flag to pass to cmake during the generation step. - pub fn define<K, V>(&mut self, k: K, v: V) -> &mut Config - where K: AsRef<OsStr>, V: AsRef<OsStr> - { - self.defines.push((k.as_ref().to_owned(), v.as_ref().to_owned())); - self - } - - /// Registers a dependency for this compilation on the native library built - /// by Cargo previously. - /// - /// This registration will modify the `CMAKE_PREFIX_PATH` environment - /// variable for the build system generation step. - pub fn register_dep(&mut self, dep: &str) -> &mut Config { - self.deps.push(dep.to_string()); - self - } - - /// Sets the target triple for this compilation. - /// - /// This is automatically scraped from `$TARGET` which is set for Cargo - /// build scripts so it's not necessary to call this from a build script. - pub fn target(&mut self, target: &str) -> &mut Config { - self.target = Some(target.to_string()); - self - } - - /// Sets the host triple for this compilation. - /// - /// This is automatically scraped from `$HOST` which is set for Cargo - /// build scripts so it's not necessary to call this from a build script. - pub fn host(&mut self, host: &str) -> &mut Config { - self.host = Some(host.to_string()); - self - } - - /// Sets the output directory for this compilation. - /// - /// This is automatically scraped from `$OUT_DIR` which is set for Cargo - /// build scripts so it's not necessary to call this from a build script. - pub fn out_dir<P: AsRef<Path>>(&mut self, out: P) -> &mut Config { - self.out_dir = Some(out.as_ref().to_path_buf()); - self - } - - /// Sets the profile for this compilation. - /// - /// This is automatically scraped from `$PROFILE` which is set for Cargo - /// build scripts so it's not necessary to call this from a build script. - pub fn profile(&mut self, profile: &str) -> &mut Config { - self.profile = Some(profile.to_string()); - self - } - - /// Add an argument to the final `cmake` build step - pub fn build_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut Config { - self.build_args.push(arg.as_ref().to_owned()); - self - } - - /// Sets the build target for the final `cmake` build step, this will - /// default to "install" if not specified. - pub fn build_target(&mut self, target: &str) -> &mut Config { - self.cmake_target = Some(target.to_string()); - self - } - - /// Run this configuration, compiling the library with all the configured - /// options. - /// - /// This will run both the build system generator command as well as the - /// command to build the library. - pub fn build(&mut self) -> PathBuf { - let target = self.target.clone().unwrap_or_else(|| { - getenv_unwrap("TARGET") - }); - let host = self.host.clone().unwrap_or_else(|| { - getenv_unwrap("HOST") - }); - let msvc = target.contains("msvc"); - let c_compiler = gcc::Config::new().cargo_metadata(false) - .opt_level(0) - .debug(false) - .target(&target) - .host(&host) - .get_compiler(); - let cxx_compiler = gcc::Config::new().cargo_metadata(false) - .cpp(true) - .opt_level(0) - .debug(false) - .target(&target) - .host(&host) - .get_compiler(); - - let dst = self.out_dir.clone().unwrap_or_else(|| { - PathBuf::from(getenv_unwrap("OUT_DIR")) - }); - let build = dst.join("build"); - self.maybe_clear(&build); - let _ = fs::create_dir(&build); - - // Add all our dependencies to our cmake paths - let mut cmake_prefix_path = Vec::new(); - for dep in &self.deps { - if let Some(root) = env::var_os(&format!("DEP_{}_ROOT", dep)) { - cmake_prefix_path.push(PathBuf::from(root)); - } - } - let system_prefix = env::var_os("CMAKE_PREFIX_PATH") - .unwrap_or(OsString::new()); - cmake_prefix_path.extend(env::split_paths(&system_prefix) - .map(|s| s.to_owned())); - let cmake_prefix_path = env::join_paths(&cmake_prefix_path).unwrap(); - - // Build up the first cmake command to build the build system. - let mut cmd = Command::new("cmake"); - cmd.arg(&self.path) - .current_dir(&build); - if target.contains("windows-gnu") { - if host.contains("windows") { - // On MinGW we need to coerce cmake to not generate a visual - // studio build system but instead use makefiles that MinGW can - // use to build. - if self.generator.is_none() { - cmd.arg("-G").arg("MSYS Makefiles"); - } - } else { - // If we're cross compiling onto windows, then set some - // variables which will hopefully get things to succeed. Some - // systems may need the `windres` or `dlltool` variables set, so - // set them if possible. - if !self.defined("CMAKE_SYSTEM_NAME") { - cmd.arg("-DCMAKE_SYSTEM_NAME=Windows"); - } - if !self.defined("CMAKE_RC_COMPILER") { - let exe = find_exe(c_compiler.path()); - if let Some(name) = exe.file_name().unwrap().to_str() { - let name = name.replace("gcc", "windres"); - let windres = exe.with_file_name(name); - if windres.is_file() { - let mut arg = OsString::from("-DCMAKE_RC_COMPILER="); - arg.push(&windres); - cmd.arg(arg); - } - } - } - } - } else if msvc { - // If we're on MSVC we need to be sure to use the right generator or - // otherwise we won't get 32/64 bit correct automatically. - if self.generator.is_none() { - cmd.arg("-G").arg(self.visual_studio_generator(&target)); - } - } - if let Some(ref generator) = self.generator { - cmd.arg("-G").arg(generator); - } - let profile = self.profile.clone().unwrap_or_else(|| { - match &getenv_unwrap("PROFILE")[..] { - "bench" | "release" => "Release", - // currently we need to always use the same CRT for MSVC - _ if msvc => "Release", - _ => "Debug", - }.to_string() - }); - for &(ref k, ref v) in &self.defines { - let mut os = OsString::from("-D"); - os.push(k); - os.push("="); - os.push(v); - cmd.arg(os); - } - - if !self.defined("CMAKE_INSTALL_PREFIX") { - let mut dstflag = OsString::from("-DCMAKE_INSTALL_PREFIX="); - dstflag.push(&dst); - cmd.arg(dstflag); - } - - { - let mut set_compiler = |kind: &str, - compiler: &gcc::Tool, - extra: &OsString| { - let flag_var = format!("CMAKE_{}_FLAGS", kind); - let tool_var = format!("CMAKE_{}_COMPILER", kind); - if !self.defined(&flag_var) { - let mut flagsflag = OsString::from("-D"); - flagsflag.push(&flag_var); - flagsflag.push("="); - flagsflag.push(extra); - for arg in compiler.args() { - flagsflag.push(" "); - flagsflag.push(arg); - } - cmd.arg(flagsflag); - } - - // Apparently cmake likes to have an absolute path to the - // compiler as otherwise it sometimes thinks that this variable - // changed as it thinks the found compiler, /usr/bin/cc, - // differs from the specified compiler, cc. Not entirely sure - // what's up, but at least this means cmake doesn't get - // confused? - // - // Also don't specify this on Windows as it's not needed for - // MSVC and for MinGW it doesn't really vary. - if !self.defined("CMAKE_TOOLCHAIN_FILE") - && !self.defined(&tool_var) - && env::consts::FAMILY != "windows" { - let mut ccompiler = OsString::from("-D"); - ccompiler.push(&tool_var); - ccompiler.push("="); - ccompiler.push(find_exe(compiler.path())); - cmd.arg(ccompiler); - } - }; - - set_compiler("C", &c_compiler, &self.cflags); - set_compiler("CXX", &cxx_compiler, &self.cxxflags); - } - - if !self.defined("CMAKE_BUILD_TYPE") { - cmd.arg(&format!("-DCMAKE_BUILD_TYPE={}", profile)); - } - - if !self.defined("CMAKE_TOOLCHAIN_FILE") { - if let Ok(s) = env::var("CMAKE_TOOLCHAIN_FILE") { - cmd.arg(&format!("-DCMAKE_TOOLCHAIN_FILE={}", s)); - } - } - - run(cmd.env("CMAKE_PREFIX_PATH", cmake_prefix_path), "cmake"); - - let mut parallel_args = Vec::new(); - if fs::metadata(&dst.join("build/Makefile")).is_ok() { - if let Ok(s) = env::var("NUM_JOBS") { - parallel_args.push(format!("-j{}", s)); - } - } - - // And build! - let target = self.cmake_target.clone().unwrap_or("install".to_string()); - run(Command::new("cmake") - .arg("--build").arg(".") - .arg("--target").arg(target) - .arg("--config").arg(profile) - .arg("--").args(&self.build_args) - .args(¶llel_args) - .current_dir(&build), "cmake"); - - println!("cargo:root={}", dst.display()); - return dst - } - - fn visual_studio_generator(&self, target: &str) -> String { - let base = match std::env::var("VisualStudioVersion") { - Ok(version) => { - match &version[..] { - "15.0" => "Visual Studio 15", - "14.0" => "Visual Studio 14 2015", - "12.0" => "Visual Studio 12 2013", - vers => panic!("\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 self.has_msbuild_version("15.0") { - "Visual Studio 15" - } else if self.has_msbuild_version("14.0") { - "Visual Studio 14 2015" - } else if self.has_msbuild_version("12.0") { - "Visual Studio 12 2013" - } else { - panic!("\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\ - "); - } - } - }; - - if target.contains("i686") { - base.to_string() - } else if target.contains("x86_64") { - format!("{} Win64", base) - } else { - panic!("unsupported msvc target: {}", target); - } - } - - #[cfg(not(windows))] - fn has_msbuild_version(&self, _version: &str) -> bool { - false - } - - #[cfg(windows)] - fn has_msbuild_version(&self, version: &str) -> bool { - let key = format!("SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{}", - version); - registry::LOCAL_MACHINE.open(key.as_ref()).is_ok() - } - - fn defined(&self, var: &str) -> bool { - self.defines.iter().any(|&(ref a, _)| a == var) - } - - // If a cmake project has previously been built (e.g. CMakeCache.txt already - // exists), then cmake will choke if the source directory for the original - // project being built has changed. Detect this situation through the - // `CMAKE_HOME_DIRECTORY` variable that cmake emits and if it doesn't match - // we blow away the build directory and start from scratch (the recommended - // solution apparently [1]). - // - // [1]: https://cmake.org/pipermail/cmake/2012-August/051545.html - fn maybe_clear(&self, dir: &Path) { - // CMake will apparently store canonicalized paths which normally - // isn't relevant to us but we canonicalize it here to ensure - // we're both checking the same thing. - let path = fs::canonicalize(&self.path).unwrap_or(self.path.clone()); - let src = match path.to_str() { - Some(src) => src, - None => return, - }; - let mut f = match File::open(dir.join("CMakeCache.txt")) { - Ok(f) => f, - Err(..) => return, - }; - let mut u8contents = Vec::new(); - match f.read_to_end(&mut u8contents) { - Ok(f) => f, - Err(..) => return, - }; - let contents = String::from_utf8_lossy(&u8contents); - drop(f); - for line in contents.lines() { - if line.contains("CMAKE_HOME_DIRECTORY") && !line.contains(src) { - println!("detected home dir change, cleaning out entire build \ - directory"); - fs::remove_dir_all(dir).unwrap(); - break - } - } - } -} - -fn run(cmd: &mut Command, program: &str) { - println!("running: {:?}", cmd); - let status = match cmd.status() { - Ok(status) => status, - Err(ref e) if e.kind() == ErrorKind::NotFound => { - fail(&format!("failed to execute command: {}\nis `{}` not installed?", - e, program)); - } - Err(e) => fail(&format!("failed to execute command: {}", e)), - }; - if !status.success() { - fail(&format!("command did not execute successfully, got: {}", status)); - } -} - -fn find_exe(path: &Path) -> PathBuf { - env::split_paths(&env::var_os("PATH").unwrap_or(OsString::new())) - .map(|p| p.join(path)) - .find(|p| fs::metadata(p).is_ok()) - .unwrap_or(path.to_owned()) -} - -fn getenv_unwrap(v: &str) -> String { - match env::var(v) { - Ok(s) => s, - Err(..) => fail(&format!("environment variable `{}` not defined", v)), - } -} - -fn fail(s: &str) -> ! { - panic!("\n{}\n\nbuild script failed, must exit now", s) -} diff --git a/src/vendor/cmake/src/registry.rs b/src/vendor/cmake/src/registry.rs deleted file mode 100644 index 8819b094151..00000000000 --- a/src/vendor/cmake/src/registry.rs +++ /dev/null @@ -1,84 +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; -use std::io; -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 HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY; -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 RegCloseKey(hKey: HKEY) -> LONG; -} - -struct OwnedKey(HKEY); - -enum Repr { - Const(HKEY), - Owned(OwnedKey), -} - -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)) - } - } -} - -impl Drop for OwnedKey { - fn drop(&mut self) { - unsafe { RegCloseKey(self.0); } - } -} diff --git a/src/vendor/env_logger/.cargo-checksum.json b/src/vendor/env_logger/.cargo-checksum.json deleted file mode 100644 index e3d83501ad0..00000000000 --- a/src/vendor/env_logger/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"4af0565a97a599bba727315d9aff1f57a350dcfee7d9f00986c851e54a24b4ca","src/lib.rs":"484cec14a5f18a25b71d7b1842f7b184f0530165021b71b36dde9fc57b7fc15a","src/regex.rs":"d8e2a6958d4ed8084867063aae4b5c77ffc5d271dc2e17909d56c5a5e1552034","src/string.rs":"26ede9ab41a2673c3ad6001bc1802c005ce9a4f190f55860a24aa66b6b71bbc7","tests/regexp_filter.rs":"a3f9c01623e90e54b247a62c53b25caf5f502d054f28c0bdf92abbea486a95b5"},"package":"15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"} \ No newline at end of file diff --git a/src/vendor/env_logger/.cargo-ok b/src/vendor/env_logger/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/env_logger/.cargo-ok +++ /dev/null diff --git a/src/vendor/env_logger/Cargo.toml b/src/vendor/env_logger/Cargo.toml deleted file mode 100644 index 5efadbf0d62..00000000000 --- a/src/vendor/env_logger/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "env_logger" -version = "0.3.5" -authors = ["The Rust Project Developers"] -license = "MIT/Apache-2.0" -repository = "https://github.com/rust-lang/log" -documentation = "http://doc.rust-lang.org/log/env_logger" -homepage = "https://github.com/rust-lang/log" -description = """ -An logging implementation for `log` which is configured via an environment -variable. -""" - -[dependencies] -log = { version = "0.3", path = ".." } -regex = { version = "0.1", optional = true } - -[[test]] -name = "regexp_filter" -harness = false - -[features] -default = ["regex"] diff --git a/src/vendor/env_logger/src/lib.rs b/src/vendor/env_logger/src/lib.rs deleted file mode 100644 index 9105c19c65c..00000000000 --- a/src/vendor/env_logger/src/lib.rs +++ /dev/null @@ -1,623 +0,0 @@ -// Copyright 2014-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 logger configured via an environment variable which writes to standard -//! error. -//! -//! ## Example -//! -//! ``` -//! #[macro_use] extern crate log; -//! extern crate env_logger; -//! -//! use log::LogLevel; -//! -//! fn main() { -//! env_logger::init().unwrap(); -//! -//! debug!("this is a debug {}", "message"); -//! error!("this is printed by default"); -//! -//! if log_enabled!(LogLevel::Info) { -//! let x = 3 * 4; // expensive computation -//! info!("the answer was: {}", x); -//! } -//! } -//! ``` -//! -//! Assumes the binary is `main`: -//! -//! ```{.bash} -//! $ RUST_LOG=error ./main -//! ERROR:main: this is printed by default -//! ``` -//! -//! ```{.bash} -//! $ RUST_LOG=info ./main -//! ERROR:main: this is printed by default -//! INFO:main: the answer was: 12 -//! ``` -//! -//! ```{.bash} -//! $ RUST_LOG=debug ./main -//! DEBUG:main: this is a debug message -//! ERROR:main: this is printed by default -//! INFO:main: the answer was: 12 -//! ``` -//! -//! You can also set the log level on a per module basis: -//! -//! ```{.bash} -//! $ RUST_LOG=main=info ./main -//! ERROR:main: this is printed by default -//! INFO:main: the answer was: 12 -//! ``` -//! -//! And enable all logging: -//! -//! ```{.bash} -//! $ RUST_LOG=main ./main -//! DEBUG:main: this is a debug message -//! ERROR:main: this is printed by default -//! INFO:main: the answer was: 12 -//! ``` -//! -//! See the documentation for the log crate for more information about its API. -//! -//! ## Enabling logging -//! -//! Log levels are controlled on a per-module basis, and by default all logging -//! is disabled except for `error!`. Logging is controlled via the `RUST_LOG` -//! environment variable. The value of this environment variable is a -//! comma-separated list of logging directives. A logging directive is of the -//! form: -//! -//! ```text -//! path::to::module=log_level -//! ``` -//! -//! The path to the module is rooted in the name of the crate it was compiled -//! for, so if your program is contained in a file `hello.rs`, for example, to -//! turn on logging for this file you would use a value of `RUST_LOG=hello`. -//! Furthermore, this path is a prefix-search, so all modules nested in the -//! specified module will also have logging enabled. -//! -//! The actual `log_level` is optional to specify. If omitted, all logging will -//! be enabled. If specified, it must be one of the strings `debug`, `error`, -//! `info`, `warn`, or `trace`. -//! -//! As the log level for a module is optional, the module to enable logging for -//! is also optional. If only a `log_level` is provided, then the global log -//! level for all modules is set to this value. -//! -//! Some examples of valid values of `RUST_LOG` are: -//! -//! * `hello` turns on all logging for the 'hello' module -//! * `info` turns on all info logging -//! * `hello=debug` turns on debug logging for 'hello' -//! * `hello,std::option` turns on hello, and std's option logging -//! * `error,hello=warn` turn on global error logging and also warn for hello -//! -//! ## Filtering results -//! -//! A RUST_LOG directive may include a regex filter. The syntax is to append `/` -//! followed by a regex. Each message is checked against the regex, and is only -//! logged if it matches. Note that the matching is done after formatting the -//! log string but before adding any logging meta-data. There is a single filter -//! for all modules. -//! -//! Some examples: -//! -//! * `hello/foo` turns on all logging for the 'hello' module where the log -//! message includes 'foo'. -//! * `info/f.o` turns on all info logging where the log message includes 'foo', -//! 'f1o', 'fao', etc. -//! * `hello=debug/foo*foo` turns on debug logging for 'hello' where the log -//! message includes 'foofoo' or 'fofoo' or 'fooooooofoo', etc. -//! * `error,hello=warn/[0-9] scopes` turn on global error logging and also -//! warn for hello. In both cases the log message must include a single digit -//! number followed by 'scopes'. - -#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/env_logger/")] -#![cfg_attr(test, deny(warnings))] - -extern crate log; - -use std::env; -use std::io::prelude::*; -use std::io; -use std::mem; - -use log::{Log, LogLevel, LogLevelFilter, LogRecord, SetLoggerError, LogMetadata}; - -#[cfg(feature = "regex")] -#[path = "regex.rs"] -mod filter; - -#[cfg(not(feature = "regex"))] -#[path = "string.rs"] -mod filter; - -/// The logger. -pub struct Logger { - directives: Vec<LogDirective>, - filter: Option<filter::Filter>, - format: Box<Fn(&LogRecord) -> String + Sync + Send>, -} - -/// LogBuilder acts as builder for initializing the Logger. -/// It can be used to customize the log format, change the enviromental variable used -/// to provide the logging directives and also set the default log level filter. -/// -/// ## Example -/// -/// ``` -/// #[macro_use] -/// extern crate log; -/// extern crate env_logger; -/// -/// use std::env; -/// use log::{LogRecord, LogLevelFilter}; -/// use env_logger::LogBuilder; -/// -/// fn main() { -/// let format = |record: &LogRecord| { -/// format!("{} - {}", record.level(), record.args()) -/// }; -/// -/// let mut builder = LogBuilder::new(); -/// builder.format(format).filter(None, LogLevelFilter::Info); -/// -/// if env::var("RUST_LOG").is_ok() { -/// builder.parse(&env::var("RUST_LOG").unwrap()); -/// } -/// -/// builder.init().unwrap(); -/// -/// error!("error message"); -/// info!("info message"); -/// } -/// ``` -pub struct LogBuilder { - directives: Vec<LogDirective>, - filter: Option<filter::Filter>, - format: Box<Fn(&LogRecord) -> String + Sync + Send>, -} - -impl LogBuilder { - /// Initializes the log builder with defaults - pub fn new() -> LogBuilder { - LogBuilder { - directives: Vec::new(), - filter: None, - format: Box::new(|record: &LogRecord| { - format!("{}:{}: {}", record.level(), - record.location().module_path(), record.args()) - }), - } - } - - /// Adds filters to the logger - /// - /// The given module (if any) will log at most the specified level provided. - /// If no module is provided then the filter will apply to all log messages. - pub fn filter(&mut self, - module: Option<&str>, - level: LogLevelFilter) -> &mut Self { - self.directives.push(LogDirective { - name: module.map(|s| s.to_string()), - level: level, - }); - self - } - - /// Sets the format function for formatting the log output. - /// - /// This function is called on each record logged to produce a string which - /// is actually printed out. - pub fn format<F: 'static>(&mut self, format: F) -> &mut Self - where F: Fn(&LogRecord) -> String + Sync + Send - { - self.format = Box::new(format); - self - } - - /// Parses the directives string in the same form as the RUST_LOG - /// environment variable. - /// - /// See the module documentation for more details. - pub fn parse(&mut self, filters: &str) -> &mut Self { - let (directives, filter) = parse_logging_spec(filters); - - self.filter = filter; - - for directive in directives { - self.directives.push(directive); - } - self - } - - /// Initializes the global logger with an env logger. - /// - /// This should be called early in the execution of a Rust program, and the - /// global logger may only be initialized once. Future initialization - /// attempts will return an error. - pub fn init(&mut self) -> Result<(), SetLoggerError> { - log::set_logger(|max_level| { - let logger = self.build(); - max_level.set(logger.filter()); - Box::new(logger) - }) - } - - /// Build an env logger. - pub fn build(&mut self) -> Logger { - if self.directives.is_empty() { - // Adds the default filter if none exist - self.directives.push(LogDirective { - name: None, - level: LogLevelFilter::Error, - }); - } else { - // Sort the directives by length of their name, this allows a - // little more efficient lookup at runtime. - self.directives.sort_by(|a, b| { - let alen = a.name.as_ref().map(|a| a.len()).unwrap_or(0); - let blen = b.name.as_ref().map(|b| b.len()).unwrap_or(0); - alen.cmp(&blen) - }); - } - - Logger { - directives: mem::replace(&mut self.directives, Vec::new()), - filter: mem::replace(&mut self.filter, None), - format: mem::replace(&mut self.format, Box::new(|_| String::new())), - } - } -} - -impl Logger { - pub fn new() -> Logger { - let mut builder = LogBuilder::new(); - - if let Ok(s) = env::var("RUST_LOG") { - builder.parse(&s); - } - - builder.build() - } - - pub fn filter(&self) -> LogLevelFilter { - self.directives.iter() - .map(|d| d.level).max() - .unwrap_or(LogLevelFilter::Off) - } - - fn enabled(&self, level: LogLevel, target: &str) -> bool { - // Search for the longest match, the vector is assumed to be pre-sorted. - for directive in self.directives.iter().rev() { - match directive.name { - Some(ref name) if !target.starts_with(&**name) => {}, - Some(..) | None => { - return level <= directive.level - } - } - } - false - } -} - -impl Log for Logger { - fn enabled(&self, metadata: &LogMetadata) -> bool { - self.enabled(metadata.level(), metadata.target()) - } - - fn log(&self, record: &LogRecord) { - if !Log::enabled(self, record.metadata()) { - return; - } - - if let Some(filter) = self.filter.as_ref() { - if !filter.is_match(&*record.args().to_string()) { - return; - } - } - - let _ = writeln!(&mut io::stderr(), "{}", (self.format)(record)); - } -} - -struct LogDirective { - name: Option<String>, - level: LogLevelFilter, -} - -/// Initializes the global logger with an env logger. -/// -/// This should be called early in the execution of a Rust program, and the -/// global logger may only be initialized once. Future initialization attempts -/// will return an error. -pub fn init() -> Result<(), SetLoggerError> { - let mut builder = LogBuilder::new(); - - if let Ok(s) = env::var("RUST_LOG") { - builder.parse(&s); - } - - builder.init() -} - -/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=error/foo") -/// and return a vector with log directives. -fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<filter::Filter>) { - let mut dirs = Vec::new(); - - let mut parts = spec.split('/'); - let mods = parts.next(); - let filter = parts.next(); - if parts.next().is_some() { - println!("warning: invalid logging spec '{}', \ - ignoring it (too many '/'s)", spec); - return (dirs, None); - } - mods.map(|m| { for s in m.split(',') { - if s.len() == 0 { continue } - let mut parts = s.split('='); - let (log_level, name) = match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) { - (Some(part0), None, None) => { - // if the single argument is a log-level string or number, - // treat that as a global fallback - match part0.parse() { - Ok(num) => (num, None), - Err(_) => (LogLevelFilter::max(), Some(part0)), - } - } - (Some(part0), Some(""), None) => (LogLevelFilter::max(), Some(part0)), - (Some(part0), Some(part1), None) => { - match part1.parse() { - Ok(num) => (num, Some(part0)), - _ => { - println!("warning: invalid logging spec '{}', \ - ignoring it", part1); - continue - } - } - }, - _ => { - println!("warning: invalid logging spec '{}', \ - ignoring it", s); - continue - } - }; - dirs.push(LogDirective { - name: name.map(|s| s.to_string()), - level: log_level, - }); - }}); - - let filter = filter.map_or(None, |filter| { - match filter::Filter::new(filter) { - Ok(re) => Some(re), - Err(e) => { - println!("warning: invalid regex filter - {}", e); - None - } - } - }); - - return (dirs, filter); -} - -#[cfg(test)] -mod tests { - use log::{LogLevel, LogLevelFilter}; - - use super::{LogBuilder, Logger, LogDirective, parse_logging_spec}; - - fn make_logger(dirs: Vec<LogDirective>) -> Logger { - let mut logger = LogBuilder::new().build(); - logger.directives = dirs; - logger - } - - #[test] - fn filter_info() { - let logger = LogBuilder::new().filter(None, LogLevelFilter::Info).build(); - assert!(logger.enabled(LogLevel::Info, "crate1")); - assert!(!logger.enabled(LogLevel::Debug, "crate1")); - } - - #[test] - fn filter_beginning_longest_match() { - let logger = LogBuilder::new() - .filter(Some("crate2"), LogLevelFilter::Info) - .filter(Some("crate2::mod"), LogLevelFilter::Debug) - .filter(Some("crate1::mod1"), LogLevelFilter::Warn) - .build(); - assert!(logger.enabled(LogLevel::Debug, "crate2::mod1")); - assert!(!logger.enabled(LogLevel::Debug, "crate2")); - } - - #[test] - fn parse_default() { - let logger = LogBuilder::new().parse("info,crate1::mod1=warn").build(); - assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); - assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); - } - - #[test] - fn match_full_path() { - let logger = make_logger(vec![ - LogDirective { - name: Some("crate2".to_string()), - level: LogLevelFilter::Info - }, - LogDirective { - name: Some("crate1::mod1".to_string()), - level: LogLevelFilter::Warn - } - ]); - assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); - assert!(!logger.enabled(LogLevel::Info, "crate1::mod1")); - assert!(logger.enabled(LogLevel::Info, "crate2")); - assert!(!logger.enabled(LogLevel::Debug, "crate2")); - } - - #[test] - fn no_match() { - let logger = make_logger(vec![ - LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, - LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } - ]); - assert!(!logger.enabled(LogLevel::Warn, "crate3")); - } - - #[test] - fn match_beginning() { - let logger = make_logger(vec![ - LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, - LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } - ]); - assert!(logger.enabled(LogLevel::Info, "crate2::mod1")); - } - - #[test] - fn match_beginning_longest_match() { - let logger = make_logger(vec![ - LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, - LogDirective { name: Some("crate2::mod".to_string()), level: LogLevelFilter::Debug }, - LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } - ]); - assert!(logger.enabled(LogLevel::Debug, "crate2::mod1")); - assert!(!logger.enabled(LogLevel::Debug, "crate2")); - } - - #[test] - fn match_default() { - let logger = make_logger(vec![ - LogDirective { name: None, level: LogLevelFilter::Info }, - LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } - ]); - assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); - assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); - } - - #[test] - fn zero_level() { - let logger = make_logger(vec![ - LogDirective { name: None, level: LogLevelFilter::Info }, - LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Off } - ]); - assert!(!logger.enabled(LogLevel::Error, "crate1::mod1")); - assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); - } - - #[test] - fn parse_logging_spec_valid() { - let (dirs, filter) = parse_logging_spec("crate1::mod1=error,crate1::mod2,crate2=debug"); - assert_eq!(dirs.len(), 3); - assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::Error); - - assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); - assert_eq!(dirs[1].level, LogLevelFilter::max()); - - assert_eq!(dirs[2].name, Some("crate2".to_string())); - assert_eq!(dirs[2].level, LogLevelFilter::Debug); - assert!(filter.is_none()); - } - - #[test] - fn parse_logging_spec_invalid_crate() { - // test parse_logging_spec with multiple = in specification - let (dirs, filter) = parse_logging_spec("crate1::mod1=warn=info,crate2=debug"); - assert_eq!(dirs.len(), 1); - assert_eq!(dirs[0].name, Some("crate2".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::Debug); - assert!(filter.is_none()); - } - - #[test] - fn parse_logging_spec_invalid_log_level() { - // test parse_logging_spec with 'noNumber' as log level - let (dirs, filter) = parse_logging_spec("crate1::mod1=noNumber,crate2=debug"); - assert_eq!(dirs.len(), 1); - assert_eq!(dirs[0].name, Some("crate2".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::Debug); - assert!(filter.is_none()); - } - - #[test] - fn parse_logging_spec_string_log_level() { - // test parse_logging_spec with 'warn' as log level - let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2=warn"); - assert_eq!(dirs.len(), 1); - assert_eq!(dirs[0].name, Some("crate2".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::Warn); - assert!(filter.is_none()); - } - - #[test] - fn parse_logging_spec_empty_log_level() { - // test parse_logging_spec with '' as log level - let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2="); - assert_eq!(dirs.len(), 1); - assert_eq!(dirs[0].name, Some("crate2".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::max()); - assert!(filter.is_none()); - } - - #[test] - fn parse_logging_spec_global() { - // test parse_logging_spec with no crate - let (dirs, filter) = parse_logging_spec("warn,crate2=debug"); - assert_eq!(dirs.len(), 2); - assert_eq!(dirs[0].name, None); - assert_eq!(dirs[0].level, LogLevelFilter::Warn); - assert_eq!(dirs[1].name, Some("crate2".to_string())); - assert_eq!(dirs[1].level, LogLevelFilter::Debug); - assert!(filter.is_none()); - } - - #[test] - fn parse_logging_spec_valid_filter() { - let (dirs, filter) = parse_logging_spec("crate1::mod1=error,crate1::mod2,crate2=debug/abc"); - assert_eq!(dirs.len(), 3); - assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::Error); - - assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); - assert_eq!(dirs[1].level, LogLevelFilter::max()); - - assert_eq!(dirs[2].name, Some("crate2".to_string())); - assert_eq!(dirs[2].level, LogLevelFilter::Debug); - assert!(filter.is_some() && filter.unwrap().to_string() == "abc"); - } - - #[test] - fn parse_logging_spec_invalid_crate_filter() { - let (dirs, filter) = parse_logging_spec("crate1::mod1=error=warn,crate2=debug/a.c"); - assert_eq!(dirs.len(), 1); - assert_eq!(dirs[0].name, Some("crate2".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::Debug); - assert!(filter.is_some() && filter.unwrap().to_string() == "a.c"); - } - - #[test] - fn parse_logging_spec_empty_with_filter() { - let (dirs, filter) = parse_logging_spec("crate1/a*c"); - assert_eq!(dirs.len(), 1); - assert_eq!(dirs[0].name, Some("crate1".to_string())); - assert_eq!(dirs[0].level, LogLevelFilter::max()); - assert!(filter.is_some() && filter.unwrap().to_string() == "a*c"); - } -} diff --git a/src/vendor/env_logger/src/regex.rs b/src/vendor/env_logger/src/regex.rs deleted file mode 100644 index 0df03e67330..00000000000 --- a/src/vendor/env_logger/src/regex.rs +++ /dev/null @@ -1,28 +0,0 @@ -extern crate regex; - -use std::fmt; - -use self::regex::Regex; - -pub struct Filter { - inner: Regex, -} - -impl Filter { - pub fn new(spec: &str) -> Result<Filter, String> { - match Regex::new(spec){ - Ok(r) => Ok(Filter { inner: r }), - Err(e) => Err(e.to_string()), - } - } - - pub fn is_match(&self, s: &str) -> bool { - self.inner.is_match(s) - } -} - -impl fmt::Display for Filter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.inner.fmt(f) - } -} diff --git a/src/vendor/env_logger/src/string.rs b/src/vendor/env_logger/src/string.rs deleted file mode 100644 index 74d0e04dbd6..00000000000 --- a/src/vendor/env_logger/src/string.rs +++ /dev/null @@ -1,21 +0,0 @@ -use std::fmt; - -pub struct Filter { - inner: String, -} - -impl Filter { - pub fn new(spec: &str) -> Result<Filter, String> { - Ok(Filter { inner: spec.to_string() }) - } - - pub fn is_match(&self, s: &str) -> bool { - s.contains(&self.inner) - } -} - -impl fmt::Display for Filter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.inner.fmt(f) - } -} diff --git a/src/vendor/env_logger/tests/regexp_filter.rs b/src/vendor/env_logger/tests/regexp_filter.rs deleted file mode 100644 index 5036fb8e3c9..00000000000 --- a/src/vendor/env_logger/tests/regexp_filter.rs +++ /dev/null @@ -1,51 +0,0 @@ -#[macro_use] extern crate log; -extern crate env_logger; - -use std::process; -use std::env; -use std::str; - -fn main() { - if env::var("LOG_REGEXP_TEST").ok() == Some(String::from("1")) { - child_main(); - } else { - parent_main() - } -} - -fn child_main() { - env_logger::init().unwrap(); - info!("XYZ Message"); -} - -fn run_child(rust_log: String) -> bool { - let exe = env::current_exe().unwrap(); - let out = process::Command::new(exe) - .env("LOG_REGEXP_TEST", "1") - .env("RUST_LOG", rust_log) - .output() - .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); - str::from_utf8(out.stderr.as_ref()).unwrap().contains("XYZ Message") -} - -fn assert_message_printed(rust_log: &str) { - if !run_child(rust_log.to_string()) { - panic!("RUST_LOG={} should allow the test log message", rust_log) - } -} - -fn assert_message_not_printed(rust_log: &str) { - if run_child(rust_log.to_string()) { - panic!("RUST_LOG={} should not allow the test log message", rust_log) - } -} - -fn parent_main() { - // test normal log severity levels - assert_message_printed("info"); - assert_message_not_printed("warn"); - - // test of regular expression filters - assert_message_printed("info/XYZ"); - assert_message_not_printed("info/XXX"); -} diff --git a/src/vendor/filetime/.cargo-checksum.json b/src/vendor/filetime/.cargo-checksum.json deleted file mode 100644 index 674ae31b296..00000000000 --- a/src/vendor/filetime/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805",".travis.yml":"c8cfe2c700e7b1d6500d0ad8084694be7009095e9572aaf54bf695c1fe7822d6","Cargo.toml":"4e414fe72ef2afcae81fb5a89f39e59ec40844272b589381746623f612333305","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"fef1998633eb2f460e6b12bc1133a21f5674e0b53ae5914ba1e53f1b63a185c3","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","src/lib.rs":"8fa03e69ab113e5a30c742f60b6beddc0b77ef41a1eb45e82f9df867c9265815"},"package":"5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"} \ No newline at end of file diff --git a/src/vendor/filetime/.cargo-ok b/src/vendor/filetime/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/filetime/.cargo-ok +++ /dev/null diff --git a/src/vendor/filetime/.gitignore b/src/vendor/filetime/.gitignore deleted file mode 100644 index a9d37c560c6..00000000000 --- a/src/vendor/filetime/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -Cargo.lock diff --git a/src/vendor/filetime/.travis.yml b/src/vendor/filetime/.travis.yml deleted file mode 100644 index 001cdd259ec..00000000000 --- a/src/vendor/filetime/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -sudo: false -script: - - cargo build --verbose - - cargo test --verbose - - cargo doc --no-deps -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - echo '<meta http-equiv=refresh content=0;url=filetime/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 -notifications: - email: - on_success: never -env: - global: - secure: dsIj09BQvGF872zKmqzG+WwCl7gfqwsnxcm3GZlAMgyLYm4juvHOwCRhIERCN3BCxPvdlSRKhe9Rwmp1RkiKuqTK3ITUTAy29Maf2vuL1T+zcdpZE0t6JSCU1gbEwzCA2foB1jzgy7Q47EzeJusmGNwibscjYmXKlH6JCFwTobM= -os: - - linux - - osx diff --git a/src/vendor/filetime/Cargo.toml b/src/vendor/filetime/Cargo.toml deleted file mode 100644 index 971eaf60146..00000000000 --- a/src/vendor/filetime/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "filetime" -authors = ["Alex Crichton <alex@alexcrichton.com>"] -version = "0.1.10" -license = "MIT/Apache-2.0" -readme = "README.md" -keywords = ["timestamp", "mtime"] -repository = "https://github.com/alexcrichton/filetime" -homepage = "https://github.com/alexcrichton/filetime" -documentation = "http://alexcrichton.com/filetime" -description = """ -Platform-agnostic accessors of timestamps in File metadata -""" - -[dependencies] -libc = "0.2" - -[dev-dependencies] -tempdir = "0.3" diff --git a/src/vendor/filetime/LICENSE-APACHE b/src/vendor/filetime/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/filetime/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/src/vendor/filetime/LICENSE-MIT b/src/vendor/filetime/LICENSE-MIT deleted file mode 100644 index 39e0ed66021..00000000000 --- a/src/vendor/filetime/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/src/vendor/filetime/README.md b/src/vendor/filetime/README.md deleted file mode 100644 index 0422084e7e2..00000000000 --- a/src/vendor/filetime/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# filetime - -[](https://travis-ci.org/alexcrichton/filetime) -[](https://ci.appveyor.com/project/alexcrichton/filetime) - -[Documentation](http://alexcrichton.com/filetime/filetime/index.html) - -A helper library for inspecting the various timestamps of files in Rust. This -library takes into account cross-platform differences in terms of where the -timestamps are located, what they are called, and how to convert them into a -platform-independent representation. - -```toml -# Cargo.toml -[dependencies] -filetime = "0.1" -``` - -# License - -`filetime` is primarily distributed under the terms of both the MIT license and -the Apache License (Version 2.0), with portions covered by various BSD-like -licenses. - -See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/src/vendor/filetime/appveyor.yml b/src/vendor/filetime/appveyor.yml deleted file mode 100644 index 6a1b8dc19c0..00000000000 --- a/src/vendor/filetime/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu -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 test --verbose diff --git a/src/vendor/filetime/src/lib.rs b/src/vendor/filetime/src/lib.rs deleted file mode 100644 index aa6bec1dfef..00000000000 --- a/src/vendor/filetime/src/lib.rs +++ /dev/null @@ -1,305 +0,0 @@ -//! Timestamps for files in Rust -//! -//! This library provides platform-agnostic inspection of the various timestamps -//! present in the standard `fs::Metadata` structure. -//! -//! # Installation -//! -//! Add this to you `Cargo.toml`: -//! -//! ```toml -//! [dependencies] -//! filetime = "0.1" -//! ``` -//! -//! # Usage -//! -//! ```no_run -//! use std::fs; -//! use filetime::FileTime; -//! -//! let metadata = fs::metadata("foo.txt").unwrap(); -//! -//! let mtime = FileTime::from_last_modification_time(&metadata); -//! println!("{}", mtime); -//! -//! let atime = FileTime::from_last_access_time(&metadata); -//! assert!(mtime < atime); -//! -//! // Inspect values that can be interpreted across platforms -//! println!("{}", mtime.seconds_relative_to_1970()); -//! println!("{}", mtime.nanoseconds()); -//! -//! // Print the platform-specific value of seconds -//! println!("{}", mtime.seconds()); -//! ``` - -extern crate libc; - -#[cfg(unix)] use std::os::unix::prelude::*; -#[cfg(windows)] use std::os::windows::prelude::*; - -use std::fmt; -use std::fs; -use std::io; -use std::path::Path; - -/// A helper structure to represent a timestamp for a file. -/// -/// The actual value contined within is platform-specific and does not have the -/// same meaning across platforms, but comparisons and stringification can be -/// significant among the same platform. -#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Copy, Clone, Hash)] -pub struct FileTime { - seconds: u64, - nanos: u32, -} - -impl FileTime { - /// Creates a new timestamp representing a 0 time. - /// - /// Useful for creating the base of a cmp::max chain of times. - pub fn zero() -> FileTime { - FileTime { seconds: 0, nanos: 0 } - } - - /// Creates a new instance of `FileTime` with a number of seconds and - /// nanoseconds relative to January 1, 1970. - /// - /// Note that this is typically the relative point that Unix time stamps are - /// from, but on Windows the native time stamp is relative to January 1, - /// 1601 so the return value of `seconds` from the returned `FileTime` - /// instance may not be the same as that passed in. - pub fn from_seconds_since_1970(seconds: u64, nanos: u32) -> FileTime { - FileTime { - seconds: seconds + if cfg!(windows) {11644473600} else {0}, - nanos: nanos, - } - } - - /// Creates a new timestamp from the last modification time listed in the - /// specified metadata. - /// - /// The returned value corresponds to the `mtime` field of `stat` on Unix - /// platforms and the `ftLastWriteTime` field on Windows platforms. - pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime { - #[cfg(unix)] - fn imp(meta: &fs::Metadata) -> FileTime { - FileTime::from_os_repr(meta.mtime() as u64, meta.mtime_nsec() as u32) - } - #[cfg(windows)] - fn imp(meta: &fs::Metadata) -> FileTime { - FileTime::from_os_repr(meta.last_write_time()) - } - imp(meta) - } - - /// Creates a new timestamp from the last access time listed in the - /// specified metadata. - /// - /// The returned value corresponds to the `atime` field of `stat` on Unix - /// platforms and the `ftLastAccessTime` field on Windows platforms. - pub fn from_last_access_time(meta: &fs::Metadata) -> FileTime { - #[cfg(unix)] - fn imp(meta: &fs::Metadata) -> FileTime { - FileTime::from_os_repr(meta.atime() as u64, meta.atime_nsec() as u32) - } - #[cfg(windows)] - fn imp(meta: &fs::Metadata) -> FileTime { - FileTime::from_os_repr(meta.last_access_time()) - } - imp(meta) - } - - /// Creates a new timestamp from the creation time listed in the specified - /// metadata. - /// - /// The returned value corresponds to the `birthtime` field of `stat` on - /// Unix platforms and the `ftCreationTime` field on Windows platforms. Note - /// that not all Unix platforms have this field available and may return - /// `None` in some circumstances. - pub fn from_creation_time(meta: &fs::Metadata) -> Option<FileTime> { - macro_rules! birthtim { - ($(($e:expr, $i:ident)),*) => { - #[cfg(any($(target_os = $e),*))] - fn imp(meta: &fs::Metadata) -> Option<FileTime> { - $( - #[cfg(target_os = $e)] - use std::os::$i::fs::MetadataExt; - )* - let raw = meta.as_raw_stat(); - Some(FileTime::from_os_repr(raw.st_birthtime as u64, - raw.st_birthtime_nsec as u32)) - } - - #[cfg(all(not(windows), - $(not(target_os = $e)),*))] - fn imp(_meta: &fs::Metadata) -> Option<FileTime> { - None - } - } - } - - birthtim! { - ("bitrig", bitrig), - ("freebsd", freebsd), - ("ios", ios), - ("macos", macos), - ("openbsd", openbsd) - } - - #[cfg(windows)] - fn imp(meta: &fs::Metadata) -> Option<FileTime> { - Some(FileTime::from_os_repr(meta.last_access_time())) - } - imp(meta) - } - - #[cfg(windows)] - fn from_os_repr(time: u64) -> FileTime { - // Windows write times are in 100ns intervals, so do a little math to - // get it into the right representation. - FileTime { - seconds: time / (1_000_000_000 / 100), - nanos: ((time % (1_000_000_000 / 100)) * 100) as u32, - } - } - - #[cfg(unix)] - fn from_os_repr(seconds: u64, nanos: u32) -> FileTime { - FileTime { seconds: seconds, nanos: nanos } - } - - /// Returns the whole number of seconds represented by this timestamp. - /// - /// Note that this value's meaning is **platform specific**. On Unix - /// platform time stamps are typically relative to January 1, 1970, but on - /// Windows platforms time stamps are relative to January 1, 1601. - pub fn seconds(&self) -> u64 { self.seconds } - - /// Returns the whole number of seconds represented by this timestamp, - /// relative to the Unix epoch start of January 1, 1970. - /// - /// Note that this does not return the same value as `seconds` for Windows - /// platforms as seconds are relative to a different date there. - pub fn seconds_relative_to_1970(&self) -> u64 { - self.seconds - if cfg!(windows) {11644473600} else {0} - } - - /// Returns the nanosecond precision of this timestamp. - /// - /// The returned value is always less than one billion and represents a - /// portion of a second forward from the seconds returned by the `seconds` - /// method. - pub fn nanoseconds(&self) -> u32 { self.nanos } -} - -impl fmt::Display for FileTime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}.{:09}s", self.seconds, self.nanos) - } -} - -/// Set the last access and modification times for a file on the filesystem. -/// -/// This function will set the `atime` and `mtime` metadata fields for a file -/// on the local filesystem, returning any error encountered. -pub fn set_file_times<P>(p: P, atime: FileTime, mtime: FileTime) - -> io::Result<()> where P: AsRef<Path> { - set_file_times_(p.as_ref(), atime, mtime) -} - -#[cfg(unix)] -fn set_file_times_(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { - use std::ffi::CString; - use libc::{timeval, time_t, suseconds_t, utimes}; - - let times = [to_timeval(&atime), to_timeval(&mtime)]; - let p = try!(CString::new(p.as_os_str().as_bytes())); - return unsafe { - if utimes(p.as_ptr() as *const _, times.as_ptr()) == 0 { - Ok(()) - } else { - Err(io::Error::last_os_error()) - } - }; - - fn to_timeval(ft: &FileTime) -> timeval { - timeval { - tv_sec: ft.seconds() as time_t, - tv_usec: (ft.nanoseconds() / 1000) as suseconds_t, - } - } -} - -#[cfg(windows)] -#[allow(bad_style)] -fn set_file_times_(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { - use std::fs::OpenOptions; - - type BOOL = i32; - type HANDLE = *mut u8; - type DWORD = u32; - #[repr(C)] - struct FILETIME { - dwLowDateTime: u32, - dwHighDateTime: u32, - } - extern "system" { - fn SetFileTime(hFile: HANDLE, - lpCreationTime: *const FILETIME, - lpLastAccessTime: *const FILETIME, - lpLastWriteTime: *const FILETIME) -> BOOL; - } - - let f = try!(OpenOptions::new().write(true).open(p)); - let atime = to_filetime(&atime); - let mtime = to_filetime(&mtime); - return unsafe { - let ret = SetFileTime(f.as_raw_handle() as *mut _, - 0 as *const _, - &atime, &mtime); - if ret != 0 { - Ok(()) - } else { - Err(io::Error::last_os_error()) - } - }; - - fn to_filetime(ft: &FileTime) -> FILETIME { - let intervals = ft.seconds() * (1_000_000_000 / 100) + - ((ft.nanoseconds() as u64) / 100); - FILETIME { - dwLowDateTime: intervals as DWORD, - dwHighDateTime: (intervals >> 32) as DWORD, - } - } -} - -#[cfg(test)] -mod tests { - extern crate tempdir; - - use std::fs::{self, File}; - use self::tempdir::TempDir; - use super::{FileTime, set_file_times}; - - #[test] - fn set_file_times_test() { - let td = TempDir::new("filetime").unwrap(); - let path = td.path().join("foo.txt"); - File::create(&path).unwrap(); - - let metadata = fs::metadata(&path).unwrap(); - let mtime = FileTime::from_last_modification_time(&metadata); - let atime = FileTime::from_last_access_time(&metadata); - set_file_times(&path, atime, mtime).unwrap(); - - let new_mtime = FileTime::from_seconds_since_1970(10_000, 0); - set_file_times(&path, atime, new_mtime).unwrap(); - - let metadata = fs::metadata(&path).unwrap(); - let mtime = FileTime::from_last_modification_time(&metadata); - assert_eq!(mtime, new_mtime); - } -} diff --git a/src/vendor/gcc/.cargo-checksum.json b/src/vendor/gcc/.cargo-checksum.json deleted file mode 100644 index 69e2a953a17..00000000000 --- a/src/vendor/gcc/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"4cc6445feac7e9a1f8f1e1c51cc3afd0cf7bb931e3c5a6f18c41258401652702",".travis.yml":"e68f9d10a8e367890cf734239c39952ee480cf0e8da9520b377df4a2b8ccc9e8","Cargo.toml":"4c5eb683d4c57fff819ebf564a8db93b5c87284993def6bc066ba1e311d5b090","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"b1a639560fd536f2c3ab708a8e1066b675edd4d018dfa4e5e18d0d7327d81c15","appveyor.yml":"46c77d913eaa45871296942c2cd96ef092c9dcaf19201cb5c500a5107faeb06f","src/bin/gcc-shim.rs":"d6be9137cb48b86891e7b263adbf492e1193ffe682db9ba4a88eb1079b874b58","src/lib.rs":"eb4ca086dd2ffa5e30f022f556d0def6d1142160da392afb328393b3f435e8f7","src/registry.rs":"3876ef9573e3bbc050aef41a684b9a510cc1a91b15ae874fe032cf4377b4d116","src/windows_registry.rs":"36c6a7f8322407faff2dcfd4789d0876d034885944bc0340ac7c1f7cbfc307f1","tests/cc_env.rs":"d92c5e3d3d43ac244e63b2cd2c93a521fcf124bf1ccf8d4c6bfa7f8333d88976","tests/support/mod.rs":"56bcfd1e2ff5ae8e581c71229444a3d96094bf689808808dd80e315bd6632083","tests/test.rs":"b63e74d571e7d585edc53693bcf0caae88fc040613ace91e32437d4a62cddb6a"},"package":"c07c758b972368e703a562686adb39125707cc1ef3399da8c019fc6c2498a75d"} \ No newline at end of file diff --git a/src/vendor/gcc/.cargo-ok b/src/vendor/gcc/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/gcc/.cargo-ok +++ /dev/null diff --git a/src/vendor/gcc/.gitignore b/src/vendor/gcc/.gitignore deleted file mode 100644 index 3b874ca574d..00000000000 --- a/src/vendor/gcc/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -Cargo.lock -.idea -*.iml diff --git a/src/vendor/gcc/.travis.yml b/src/vendor/gcc/.travis.yml deleted file mode 100644 index 10d3d13d876..00000000000 --- a/src/vendor/gcc/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -matrix: - include: - # Minimum version supported - - rust: 1.6.0 - install: - script: cargo build - -sudo: false -install: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi - - export TARGET=$ARCH-$OS - - curl https://static.rust-lang.org/rustup.sh | - sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH -script: - - cargo build --verbose - - cargo test --verbose - - cargo test --verbose --features parallel - - cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET - - cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET --features parallel - - cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET --release - - cargo doc - - cargo clean && cargo build - - rustdoc --test README.md -L target/debug -L target/debug/deps -after_success: - - travis-cargo --only nightly doc-upload -env: - global: - secure: "CBtqrudgE0PS8x3kTr44jKbC2D4nfnmdYVecooNm0qnER4B4TSvZpZSQoCgKK6k4BYQuOSyFTOwYx6M79w39ZMOgyCP9ytB+tyMWL0/+ZuUQL04yVg4M5vd3oJMkOaXbvG56ncgPyFrseY+FPDg+mXAzvJk/nily37YXjkQj2D0=" - - matrix: - - ARCH=x86_64 - - ARCH=i686 -notifications: - email: - on_success: never -os: - - linux - - osx -addons: - apt: - packages: - - g++-multilib diff --git a/src/vendor/gcc/Cargo.toml b/src/vendor/gcc/Cargo.toml deleted file mode 100644 index 9fee7788cef..00000000000 --- a/src/vendor/gcc/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] - -name = "gcc" -version = "0.3.43" -authors = ["Alex Crichton <alex@alexcrichton.com>"] -license = "MIT/Apache-2.0" -repository = "https://github.com/alexcrichton/gcc-rs" -documentation = "https://docs.rs/gcc" -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"] - -[badges] -travis-ci = { repository = "alexcrichton/gcc-rs" } -appveyor = { repository = "alexcrichton/gcc-rs" } - -[dependencies] -rayon = { version = "0.6", optional = true } - -[features] -parallel = ["rayon"] - -[dev-dependencies] -tempdir = "0.3" diff --git a/src/vendor/gcc/LICENSE-APACHE b/src/vendor/gcc/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/gcc/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/src/vendor/gcc/LICENSE-MIT b/src/vendor/gcc/LICENSE-MIT deleted file mode 100644 index 39e0ed66021..00000000000 --- a/src/vendor/gcc/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/src/vendor/gcc/README.md b/src/vendor/gcc/README.md deleted file mode 100644 index 2d3e5ed7387..00000000000 --- a/src/vendor/gcc/README.md +++ /dev/null @@ -1,163 +0,0 @@ -# gcc-rs - -A library to compile C/C++ code into a Rust library/application. - -[](https://travis-ci.org/alexcrichton/gcc-rs) -[](https://ci.appveyor.com/project/alexcrichton/gcc-rs) - -[Documentation](https://docs.rs/gcc) - -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. Note that while this -crate is called "gcc", it actually calls out to the most relevant compile for -a platform, for example using `cl` on MSVC. That is, this crate does indeed work -on MSVC! - -## Using gcc-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 -[package] -# ... -build = "build.rs" - -[build-dependencies] -gcc = "0.3" -``` - -Next up, you'll want to write a build script like so: - -```rust,no_run -// build.rs - -extern crate gcc; - -fn main() { - gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]); -} -``` - -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 it. 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 "gcc". 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. - -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, gcc-rs uses built-in defaults - -In addition to the the above optional environment variables, `gcc-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 - -Currently gcc-rs supports parallel compilation (think `make -jN`) but this -feature is turned off by default. To enable gcc-rs to compile C/C++ in parallel, -you can change your dependency to: - -```toml -[build-dependencies] -gcc = { version = "0.3", features = ["parallel"] } -``` - -By default gcc-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 gcc/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 `gcc` 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 - -`gcc-rs` supports C++ libraries compilation by using the `cpp` method on -`Config`: - -```rust,no_run -extern crate gcc; - -fn main() { - gcc::Config::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. - -## License - -`gcc-rs` is primarily distributed under the terms of both the MIT license and -the Apache License (Version 2.0), with portions covered by various BSD-like -licenses. - -See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/src/vendor/gcc/appveyor.yml b/src/vendor/gcc/appveyor.yml deleted file mode 100644 index f6108c66514..00000000000 --- a/src/vendor/gcc/appveyor.yml +++ /dev/null @@ -1,35 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - ARCH: amd64 - VS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat - - TARGET: x86_64-pc-windows-msvc - ARCH: amd64 - VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat - - TARGET: i686-pc-windows-msvc - ARCH: x86 - VS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat - - TARGET: i686-pc-windows-msvc - ARCH: x86 - VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat - - TARGET: x86_64-pc-windows-gnu - MSYS_BITS: 64 - - TARGET: i686-pc-windows-gnu - MSYS_BITS: 32 -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" - - if defined VS call "%VS%" %ARCH% - - set PATH=%PATH%;C:\Program Files (x86)\Rust\bin - - if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin - - rustc -V - - cargo -V - -build: false - -test_script: - - cargo test --target %TARGET% - - cargo test --features parallel --target %TARGET% - - cargo test --manifest-path gcc-test/Cargo.toml --target %TARGET% - - cargo test --manifest-path gcc-test/Cargo.toml --features parallel --target %TARGET% - - cargo test --manifest-path gcc-test/Cargo.toml --release --target %TARGET% diff --git a/src/vendor/gcc/src/bin/gcc-shim.rs b/src/vendor/gcc/src/bin/gcc-shim.rs deleted file mode 100644 index 7fd0ea8fa84..00000000000 --- a/src/vendor/gcc/src/bin/gcc-shim.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![cfg_attr(test, allow(dead_code))] - -use std::env; -use std::fs::File; -use std::io::prelude::*; -use std::path::PathBuf; - -fn main() { - let out_dir = PathBuf::from(env::var_os("GCCTEST_OUT_DIR").unwrap()); - for i in 0.. { - let candidate = out_dir.join(format!("out{}", i)); - if candidate.exists() { - continue; - } - let mut f = File::create(candidate).unwrap(); - for arg in env::args().skip(1) { - writeln!(f, "{}", arg).unwrap(); - } - - File::create(out_dir.join("libfoo.a")).unwrap(); - break; - } -} diff --git a/src/vendor/gcc/src/lib.rs b/src/vendor/gcc/src/lib.rs deleted file mode 100644 index f2d9da7f694..00000000000 --- a/src/vendor/gcc/src/lib.rs +++ /dev/null @@ -1,1128 +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] -//! gcc = "0.3" -//! ``` -//! -//! 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. -//! The top-level `compile_library` function serves as a convenience and more -//! advanced configuration is available through the `Config` builder. -//! -//! This crate will automatically detect situations such as cross compilation or -//! other environment variables set by Cargo and will build code appropriately. -//! -//! # Examples -//! -//! Use the default configuration: -//! -//! ```no_run -//! extern crate gcc; -//! -//! fn main() { -//! gcc::compile_library("libfoo.a", &["src/foo.c"]); -//! } -//! ``` -//! -//! Use more advanced configuration: -//! -//! ```no_run -//! extern crate gcc; -//! -//! fn main() { -//! gcc::Config::new() -//! .file("src/foo.c") -//! .define("FOO", Some("bar")) -//! .include("src") -//! .compile("libfoo.a"); -//! } -//! ``` - -#![doc(html_root_url = "https://docs.rs/gcc/0.3")] -#![cfg_attr(test, deny(warnings))] -#![deny(missing_docs)] - -#[cfg(feature = "parallel")] -extern crate rayon; - -use std::env; -use std::ffi::{OsString, OsStr}; -use std::fs; -use std::path::{PathBuf, Path}; -use std::process::{Command, Stdio}; -use std::io::{self, BufReader, BufRead, Read, Write}; -use std::thread; - -#[cfg(windows)] -mod registry; -pub mod windows_registry; - -/// Extra configuration to pass to gcc. -pub struct Config { - include_directories: Vec<PathBuf>, - definitions: Vec<(String, Option<String>)>, - objects: Vec<PathBuf>, - flags: Vec<String>, - files: Vec<PathBuf>, - cpp: bool, - cpp_link_stdlib: Option<Option<String>>, - cpp_set_stdlib: Option<String>, - target: Option<String>, - host: Option<String>, - out_dir: Option<PathBuf>, - opt_level: Option<String>, - debug: Option<bool>, - env: Vec<(OsString, OsString)>, - compiler: Option<PathBuf>, - archiver: Option<PathBuf>, - cargo_metadata: bool, - pic: Option<bool>, -} - -/// 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. -pub struct Tool { - path: PathBuf, - args: Vec<OsString>, - env: Vec<(OsString, OsString)>, - family: ToolFamily -} - -/// 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)] -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, -} - -impl ToolFamily { - /// What the flag to request debug info for this family of tools look like - fn debug_flag(&self) -> &'static str { - match *self { - ToolFamily::Msvc => "/Z7", - ToolFamily::Gnu | - ToolFamily::Clang => "-g", - } - } - - /// What the flag to include directories into header search path looks like - fn include_flag(&self) -> &'static str { - match *self { - ToolFamily::Msvc => "/I", - ToolFamily::Gnu | - ToolFamily::Clang => "-I", - } - } - - /// What the flag to request macro-expanded source output looks like - fn expand_flag(&self) -> &'static str { - match *self { - ToolFamily::Msvc => "/E", - ToolFamily::Gnu | - ToolFamily::Clang => "-E", - } - } -} - -/// Compile a library from the given set of input C files. -/// -/// This will simply compile all files into object files and then assemble them -/// into the output. This will read the standard environment variables to detect -/// cross compilations and such. -/// -/// This function will also print all metadata on standard output for Cargo. -/// -/// # Example -/// -/// ```no_run -/// gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]); -/// ``` -pub fn compile_library(output: &str, files: &[&str]) { - let mut c = Config::new(); - for f in files.iter() { - c.file(*f); - } - c.compile(output); -} - -impl Config { - /// Construct a new instance of a blank set of configuration. - /// - /// This builder is finished with the `compile` function. - pub fn new() -> Config { - Config { - include_directories: Vec::new(), - definitions: Vec::new(), - objects: Vec::new(), - flags: Vec::new(), - files: Vec::new(), - cpp: false, - cpp_link_stdlib: None, - cpp_set_stdlib: None, - target: None, - host: None, - out_dir: None, - opt_level: None, - debug: None, - env: Vec::new(), - compiler: None, - archiver: None, - cargo_metadata: true, - pic: None, - } - } - - /// Add a directory to the `-I` or include path for headers - pub fn include<P: AsRef<Path>>(&mut self, dir: P) -> &mut Config { - self.include_directories.push(dir.as_ref().to_path_buf()); - self - } - - /// Specify a `-D` variable with an optional value. - pub fn define(&mut self, var: &str, val: Option<&str>) -> &mut Config { - self.definitions.push((var.to_string(), val.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 Config { - self.objects.push(obj.as_ref().to_path_buf()); - self - } - - /// Add an arbitrary flag to the invocation of the compiler - pub fn flag(&mut self, flag: &str) -> &mut Config { - self.flags.push(flag.to_string()); - self - } - - /// Add a file which will be compiled - pub fn file<P: AsRef<Path>>(&mut self, p: P) -> &mut Config { - self.files.push(p.as_ref().to_path_buf()); - 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 Config { - self.cpp = cpp; - 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. - /// - /// 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. - pub fn cpp_link_stdlib(&mut self, cpp_link_stdlib: Option<&str>) -> &mut Config { - self.cpp_link_stdlib = Some(cpp_link_stdlib.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. - pub fn cpp_set_stdlib(&mut self, cpp_set_stdlib: Option<&str>) -> &mut Config { - 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. - pub fn target(&mut self, target: &str) -> &mut Config { - 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. - pub fn host(&mut self, host: &str) -> &mut Config { - 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 Config { - 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 Config { - self.opt_level = Some(opt_level.to_string()); - self - } - - /// Configures whether the compiler will emit debug information when - /// generating object files. - /// - /// This option is automatically scraped from the `PROFILE` environment - /// variable by build scripts (only enabled when the profile is "debug"), so - /// it's not required to call this function. - pub fn debug(&mut self, debug: bool) -> &mut Config { - self.debug = Some(debug); - self - } - - /// Configures the output directory where all object files and static - /// libraries will be located. - /// - /// This option is automatically scraped from the `OUT_DIR` environment - /// variable by build scripts, so it's not required to call this function. - pub fn out_dir<P: AsRef<Path>>(&mut self, out_dir: P) -> &mut Config { - 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 Config { - 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 Config { - 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`. - pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Config { - self.cargo_metadata = cargo_metadata; - self - } - - /// Configures whether the compiler will emit position independent code. - /// - /// This option defaults to `false` for `i686` and `windows-gnu` targets and to `true` for all - /// other targets. - pub fn pic(&mut self, pic: bool) -> &mut Config { - self.pic = Some(pic); - self - } - - - #[doc(hidden)] - pub fn __set_env<A, B>(&mut self, a: A, b: B) -> &mut Config - 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` - /// - /// The name `output` must begin with `lib` and end with `.a` - pub fn compile(&self, output: &str) { - assert!(output.starts_with("lib")); - assert!(output.ends_with(".a")); - let lib_name = &output[3..output.len() - 2]; - let dst = self.get_out_dir(); - - let mut objects = Vec::new(); - let mut src_dst = 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().unwrap()) - } else { - obj - }; - fs::create_dir_all(&obj.parent().unwrap()).unwrap(); - src_dst.push((file.to_path_buf(), obj.clone())); - objects.push(obj); - } - self.compile_objects(&src_dst); - self.assemble(lib_name, &dst.join(output), &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={}", - &output[3..output.len() - 2])); - 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)); - } - } - } - - #[cfg(feature = "parallel")] - fn compile_objects(&self, objs: &[(PathBuf, PathBuf)]) { - use self::rayon::prelude::*; - - let mut cfg = rayon::Configuration::new(); - if let Ok(amt) = env::var("NUM_JOBS") { - if let Ok(amt) = amt.parse() { - cfg = cfg.set_num_threads(amt); - } - } - drop(rayon::initialize(cfg)); - - objs.par_iter().weight_max().for_each(|&(ref src, ref dst)| self.compile_object(src, dst)); - } - - #[cfg(not(feature = "parallel"))] - fn compile_objects(&self, objs: &[(PathBuf, PathBuf)]) { - for &(ref src, ref dst) in objs { - self.compile_object(src, dst); - } - } - - fn compile_object(&self, file: &Path, dst: &Path) { - let is_asm = file.extension().and_then(|s| s.to_str()) == Some("asm"); - let msvc = self.get_target().contains("msvc"); - let (mut cmd, name) = if msvc && is_asm { - self.msvc_macro_assembler() - } else { - let compiler = self.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() - .unwrap() - .to_string_lossy() - .into_owned()) - }; - if msvc && is_asm { - cmd.arg("/Fo").arg(dst); - } else if msvc { - let mut s = OsString::from("/Fo"); - s.push(&dst); - cmd.arg(s); - } else { - cmd.arg("-o").arg(&dst); - } - cmd.arg(if msvc { "/c" } else { "-c" }); - cmd.arg(file); - - run(&mut cmd, &name); - } - - /// Run the compiler, returning the macro-expanded version of the input files. - /// - /// This is only relevant for C and C++ files. - pub fn expand(&self) -> Vec<u8> { - let compiler = self.get_compiler(); - let mut cmd = compiler.to_command(); - for &(ref a, ref b) in self.env.iter() { - cmd.env(a, b); - } - cmd.arg(compiler.family.expand_flag()); - for file in self.files.iter() { - cmd.arg(file); - } - - let name = compiler.path - .file_name() - .unwrap() - .to_string_lossy() - .into_owned(); - - run(&mut cmd, &name) - } - - /// 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. - pub fn get_compiler(&self) -> Tool { - let opt_level = self.get_opt_level(); - let target = self.get_target(); - - let mut cmd = self.get_base_compiler(); - let nvcc = cmd.path.file_name() - .and_then(|p| p.to_str()).map(|p| p.contains("nvcc")) - .unwrap_or(false); - - // Non-target flags - // If the flag is not conditioned on target variable, it belongs here :) - match cmd.family { - ToolFamily::Msvc => { - cmd.args.push("/nologo".into()); - let features = env::var("CARGO_CFG_TARGET_FEATURE") - .unwrap_or(String::new()); - if features.contains("crt-static") { - cmd.args.push("/MT".into()); - } else { - cmd.args.push("/MD".into()); - } - match &opt_level[..] { - "z" | "s" => cmd.args.push("/Os".into()), - "1" => cmd.args.push("/O1".into()), - // -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2. - "2" | "3" => cmd.args.push("/O2".into()), - _ => {} - } - } - ToolFamily::Gnu | - ToolFamily::Clang => { - cmd.args.push(format!("-O{}", opt_level).into()); - if !nvcc { - cmd.args.push("-ffunction-sections".into()); - cmd.args.push("-fdata-sections".into()); - if self.pic.unwrap_or(!target.contains("windows-gnu")) { - cmd.args.push("-fPIC".into()); - } - } else if self.pic.unwrap_or(false) { - cmd.args.push("-Xcompiler".into()); - cmd.args.push("\'-fPIC\'".into()); - } - } - } - for arg in self.envflags(if self.cpp {"CXXFLAGS"} else {"CFLAGS"}) { - cmd.args.push(arg.into()); - } - - if self.get_debug() { - cmd.args.push(cmd.family.debug_flag().into()); - } - - // Target flags - match cmd.family { - ToolFamily::Clang => { - cmd.args.push(format!("--target={}", target).into()); - } - ToolFamily::Msvc => { - if target.contains("i586") { - cmd.args.push("/ARCH:IA32".into()); - } - } - ToolFamily::Gnu => { - if target.contains("i686") || target.contains("i586") { - cmd.args.push("-m32".into()); - } else if target.contains("x86_64") || target.contains("powerpc64") { - cmd.args.push("-m64".into()); - } - - if target.contains("musl") { - cmd.args.push("-static".into()); - } - - // armv7 targets get to use armv7 instructions - if target.starts_with("armv7-unknown-linux-") { - cmd.args.push("-march=armv7-a".into()); - } - - // On android we can guarantee some extra float instructions - // (specified in the android spec online) - if target.starts_with("armv7-linux-androideabi") { - cmd.args.push("-march=armv7-a".into()); - cmd.args.push("-mfpu=vfpv3-d16".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()); - } - - // 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" { - 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.contains("-ios") { - // FIXME: potential bug. iOS is always compiled with Clang, but Gcc compiler may be - // detected instead. - self.ios_flags(&mut cmd); - } - - if self.cpp { - match (self.cpp_set_stdlib.as_ref(), cmd.family) { - (None, _) => { } - (Some(stdlib), ToolFamily::Gnu) | - (Some(stdlib), ToolFamily::Clang) => { - cmd.args.push(format!("-stdlib=lib{}", stdlib).into()); - } - _ => { - println!("cargo:warning=cpp_set_stdlib is specified, but the {:?} compiler \ - does not support this option, ignored", cmd.family); - } - } - } - - for directory in self.include_directories.iter() { - cmd.args.push(cmd.family.include_flag().into()); - cmd.args.push(directory.into()); - } - - for flag in self.flags.iter() { - cmd.args.push(flag.into()); - } - - for &(ref key, ref value) in self.definitions.iter() { - let lead = if let ToolFamily::Msvc = cmd.family {"/"} else {"-"}; - if let &Some(ref value) = value { - cmd.args.push(format!("{}D{}={}", lead, key, value).into()); - } else { - cmd.args.push(format!("{}D{}", lead, key).into()); - } - } - cmd - } - - fn msvc_macro_assembler(&self) -> (Command, String) { - let target = self.get_target(); - let tool = if target.contains("x86_64") { - "ml64.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); - } - - (cmd, tool.to_string()) - } - - fn assemble(&self, lib_name: &str, dst: &Path, objects: &[PathBuf]) { - // 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 target = self.get_target(); - if target.contains("msvc") { - let mut cmd = match self.archiver { - Some(ref s) => self.cmd(s), - None => windows_registry::find(&target, "lib.exe").unwrap_or(self.cmd("lib.exe")), - }; - let mut out = OsString::from("/OUT:"); - out.push(dst); - run(cmd.arg(out) - .arg("/nologo") - .args(objects) - .args(&self.objects), - "lib.exe"); - - // 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); - 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() - .expect("Copying from {:?} to {:?} failed.");; - } else { - let ar = self.get_ar(); - let cmd = ar.file_name().unwrap().to_string_lossy(); - run(self.cmd(&ar) - .arg("crs") - .arg(dst) - .args(objects) - .args(&self.objects), - &cmd); - } - } - - fn ios_flags(&self, cmd: &mut Tool) { - enum ArchSpec { - Device(&'static str), - Simulator(&'static str), - } - - let target = self.get_target(); - let arch = target.split('-').nth(0).unwrap(); - 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"), - _ => fail("Unknown arch for iOS target"), - }; - - let sdk = match arch { - ArchSpec::Device(arch) => { - cmd.args.push("-arch".into()); - cmd.args.push(arch.into()); - cmd.args.push("-miphoneos-version-min=7.0".into()); - "iphoneos" - } - ArchSpec::Simulator(arch) => { - cmd.args.push(arch.into()); - cmd.args.push("-mios-simulator-version-min=7.0".into()); - "iphonesimulator" - } - }; - - self.print(&format!("Detecting iOS SDK path for {}", sdk)); - let sdk_path = self.cmd("xcrun") - .arg("--show-sdk-path") - .arg("--sdk") - .arg(sdk) - .stderr(Stdio::inherit()) - .output() - .unwrap() - .stdout; - - let sdk_path = String::from_utf8(sdk_path).unwrap(); - - cmd.args.push("-isysroot".into()); - cmd.args.push(sdk_path.trim().into()); - } - - 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); - } - return cmd; - } - - fn get_base_compiler(&self) -> Tool { - if let Some(ref c) = self.compiler { - return Tool::new(c.clone()); - } - let host = self.get_host(); - let target = self.get_target(); - let (env, msvc, gnu, default) = if self.cpp { - ("CXX", "cl.exe", "g++", "c++") - } else { - ("CC", "cl.exe", "gcc", "cc") - }; - self.env_tool(env) - .map(|(tool, args)| { - let mut t = Tool::new(PathBuf::from(tool)); - for arg in args { - t.args.push(arg.into()); - } - return t; - }) - .or_else(|| { - if target.contains("emscripten") { - if self.cpp { - Some(Tool::new(PathBuf::from("em++"))) - } else { - Some(Tool::new(PathBuf::from("emcc"))) - } - } else { - None - } - }) - .or_else(|| windows_registry::find_tool(&target, "cl.exe")) - .unwrap_or_else(|| { - 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") { - format!("{}-{}", target.replace("armv7", "arm"), gnu) - } 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"), - "arm-unknown-linux-gnueabi" => Some("arm-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-netbsdelf-eabi" => Some("arm--netbsdelf-eabi"), - "armv6-unknown-netbsdelf-eabihf" => Some("armv6--netbsdelf-eabihf"), - "armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), - "armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), - "armv7-unknown-netbsdelf-eabihf" => Some("armv7--netbsdelf-eabihf"), - "i686-pc-windows-gnu" => Some("i686-w64-mingw32"), - "i686-unknown-linux-musl" => Some("musl"), - "i686-unknown-netbsdelf" => 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"), - "powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"), - "powerpc-unknown-netbsd" => Some("powerpc--netbsd"), - "powerpc64-unknown-linux-gnu" => Some("powerpc-linux-gnu"), - "powerpc64le-unknown-linux-gnu" => Some("powerpc64le-linux-gnu"), - "s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"), - "sparc64-unknown-netbsd" => Some("sparc64--netbsd"), - "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"), - "x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"), - "x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"), - "x86_64-unknown-linux-musl" => Some("musl"), - "x86_64-unknown-netbsd" => Some("x86_64--netbsd"), - _ => None, - }); - match prefix { - Some(prefix) => format!("{}-{}", prefix, gnu), - None => default.to_string(), - } - } else { - default.to_string() - }; - Tool::new(PathBuf::from(compiler)) - }) - } - - fn get_var(&self, var_base: &str) -> Result<String, String> { - 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("could not get environment variable".to_string()), - } - } - - 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() - } - - fn env_tool(&self, name: &str) -> Option<(String, Vec<String>)> { - self.get_var(name).ok().map(|tool| { - let whitelist = ["ccache", "distcc"]; - for t in whitelist.iter() { - if tool.starts_with(t) && tool[t.len()..].starts_with(" ") { - return (t.to_string(), vec![tool[t.len()..].trim_left().to_string()]); - } - } - (tool, Vec::new()) - }) - } - - /// 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) -> Option<String> { - self.cpp_link_stdlib.clone().unwrap_or_else(|| { - let target = self.get_target(); - if target.contains("msvc") { - None - } else if target.contains("darwin") { - Some("c++".to_string()) - } else if target.contains("freebsd") { - Some("c++".to_string()) - } else { - Some("stdc++".to_string()) - } - }) - } - - fn get_ar(&self) -> PathBuf { - self.archiver - .clone() - .or_else(|| self.get_var("AR").map(PathBuf::from).ok()) - .unwrap_or_else(|| { - if self.get_target().contains("android") { - PathBuf::from(format!("{}-ar", self.get_target().replace("armv7", "arm"))) - } else if self.get_target().contains("emscripten") { - PathBuf::from("emar") - } else { - PathBuf::from("ar") - } - }) - } - - fn get_target(&self) -> String { - self.target.clone().unwrap_or_else(|| self.getenv_unwrap("TARGET")) - } - - fn get_host(&self) -> String { - self.host.clone().unwrap_or_else(|| self.getenv_unwrap("HOST")) - } - - fn get_opt_level(&self) -> String { - self.opt_level.as_ref().cloned().unwrap_or_else(|| self.getenv_unwrap("OPT_LEVEL")) - } - - fn get_debug(&self) -> bool { - self.debug.unwrap_or_else(|| self.getenv_unwrap("PROFILE") == "debug") - } - - fn get_out_dir(&self) -> PathBuf { - self.out_dir.clone().unwrap_or_else(|| env::var_os("OUT_DIR").map(PathBuf::from).unwrap()) - } - - fn getenv(&self, v: &str) -> Option<String> { - let r = env::var(v).ok(); - self.print(&format!("{} = {:?}", v, r)); - r - } - - fn getenv_unwrap(&self, v: &str) -> String { - match self.getenv(v) { - Some(s) => s, - None => fail(&format!("environment variable `{}` not defined", v)), - } - } - - fn print(&self, s: &str) { - if self.cargo_metadata { - println!("{}", s); - } - } -} - -impl Tool { - fn new(path: PathBuf) -> Tool { - // Try to detect family of the tool from its name, falling back to Gnu. - let family = if let Some(fname) = path.file_name().and_then(|p| p.to_str()) { - if fname.contains("clang") { - ToolFamily::Clang - } else if fname.contains("cl") { - ToolFamily::Msvc - } else { - ToolFamily::Gnu - } - } else { - ToolFamily::Gnu - }; - Tool { - path: path, - args: Vec::new(), - env: Vec::new(), - family: family - } - } - - /// 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 = Command::new(&self.path); - cmd.args(&self.args); - 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 - } -} - -fn run(cmd: &mut Command, program: &str) -> Vec<u8> { - 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. - let (spawn_result, stdout) = match cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() { - Ok(mut child) => { - let stderr = BufReader::new(child.stderr.take().unwrap()); - 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!(""); - } - }); - let mut stdout = vec![]; - child.stdout.take().unwrap().read_to_end(&mut stdout).unwrap(); - (child.wait(), stdout) - } - Err(e) => (Err(e), vec![]), - }; - let status = match spawn_result { - Ok(status) => status, - Err(ref e) if e.kind() == io::ErrorKind::NotFound => { - let extra = if cfg!(windows) { - " (see https://github.com/alexcrichton/gcc-rs#compile-time-requirements \ - for help)" - } else { - "" - }; - fail(&format!("failed to execute command: {}\nIs `{}` \ - not installed?{}", - e, - program, - extra)); - } - Err(e) => fail(&format!("failed to execute command: {}", e)), - }; - println!("{:?}", status); - if !status.success() { - fail(&format!("command did not execute successfully, got: {}", status)); - } - stdout -} - -fn fail(s: &str) -> ! { - println!("\n\n{}\n\n", s); - panic!() -} diff --git a/src/vendor/gcc/src/registry.rs b/src/vendor/gcc/src/registry.rs deleted file mode 100644 index a45272344db..00000000000 --- a/src/vendor/gcc/src/registry.rs +++ /dev/null @@ -1,190 +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::{OsString, OsStr}; -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/src/vendor/gcc/src/windows_registry.rs b/src/vendor/gcc/src/windows_registry.rs deleted file mode 100644 index 08b1df5f9b2..00000000000 --- a/src/vendor/gcc/src/windows_registry.rs +++ /dev/null @@ -1,424 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A helper module to probe the Windows Registry when looking for -//! windows-specific tools. - -use std::process::Command; - -use Tool; - -macro_rules! otry { - ($expr:expr) => (match $expr { - Some(val) => val, - None => return None, - }) -} - -/// Attempts to find a tool within an MSVC installation using the Windows -/// registry as a point to search from. -/// -/// The `target` argument is the target that the tool should work for (e.g. -/// compile or link for) and the `tool` argument is the tool to find (e.g. -/// `cl.exe` or `link.exe`). -/// -/// This function will return `None` if the tool could not be found, or it will -/// return `Some(cmd)` which represents a command that's ready to execute the -/// tool with the appropriate environment variables set. -/// -/// Note that this function always returns `None` for non-MSVC targets. -pub fn find(target: &str, tool: &str) -> Option<Command> { - find_tool(target, tool).map(|c| c.to_command()) -} - -/// Similar to the `find` function above, this function will attempt the same -/// operation (finding a MSVC tool in a local install) but instead returns a -/// `Tool` which may be introspected. -#[cfg(not(windows))] -pub fn find_tool(_target: &str, _tool: &str) -> Option<Tool> { - None -} - -/// Documented above. -#[cfg(windows)] -pub fn find_tool(target: &str, tool: &str) -> Option<Tool> { - use std::env; - use std::ffi::OsString; - use std::mem; - use std::path::{Path, PathBuf}; - use registry::{RegistryKey, LOCAL_MACHINE}; - - 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 - } - } - - // 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 find_msbuild(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 find_msvc_latest(tool, target, "15.0") - .or_else(|| find_msvc_latest(tool, target, "14.0")) - .or_else(|| find_msvc_12(tool, target)) - .or_else(|| find_msvc_11(tool, target)); - - // For MSVC 14 or newer we need to find the Universal CRT as well as either - // the Windows 10 SDK or Windows 8.1 SDK. - fn find_msvc_latest(tool: &str, target: &str, ver: &str) -> Option<Tool> { - let vcdir = otry!(get_vc_dir(ver)); - let mut tool = otry!(get_tool(tool, &vcdir, target)); - let sub = otry!(lib_subdir(target)); - let (ucrt, ucrt_version) = otry!(get_ucrt_dir()); - - 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("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")); - } else { - return None; - } - Some(tool.into_tool()) - } - - // For MSVC 12 we need to find the Windows 8.1 SDK. - fn find_msvc_12(tool: &str, target: &str) -> Option<Tool> { - let vcdir = otry!(get_vc_dir("12.0")); - let mut tool = otry!(get_tool(tool, &vcdir, target)); - let sub = otry!(lib_subdir(target)); - let sdk81 = otry!(get_sdk81_dir()); - tool.path.push(sdk81.join("bin").join(sub)); - let sdk_lib = sdk81.join("lib").join("winv6.3"); - tool.libs.push(sdk_lib.join("um").join(sub)); - let sdk_include = sdk81.join("include"); - tool.include.push(sdk_include.join("shared")); - tool.include.push(sdk_include.join("um")); - tool.include.push(sdk_include.join("winrt")); - Some(tool.into_tool()) - } - - // For MSVC 11 we need to find the Windows 8 SDK. - fn find_msvc_11(tool: &str, target: &str) -> Option<Tool> { - let vcdir = otry!(get_vc_dir("11.0")); - let mut tool = otry!(get_tool(tool, &vcdir, target)); - let sub = otry!(lib_subdir(target)); - let sdk8 = otry!(get_sdk8_dir()); - tool.path.push(sdk8.join("bin").join(sub)); - let sdk_lib = sdk8.join("lib").join("win8"); - tool.libs.push(sdk_lib.join("um").join(sub)); - let sdk_include = sdk8.join("include"); - tool.include.push(sdk_include.join("shared")); - tool.include.push(sdk_include.join("um")); - tool.include.push(sdk_include.join("winrt")); - Some(tool.into_tool()) - } - - fn add_env(tool: &mut Tool, env: &str, paths: Vec<PathBuf>) { - let prev = env::var_os(env).unwrap_or(OsString::new()); - let prev = env::split_paths(&prev); - let new = paths.into_iter().chain(prev); - tool.env.push((env.to_string().into(), env::join_paths(new).unwrap())); - } - - // Given a possible MSVC installation directory, we look for the linker and - // then add the MSVC library path. - fn get_tool(tool: &str, path: &Path, target: &str) -> Option<MsvcTool> { - bin_subdir(target) - .into_iter() - .map(|(sub, host)| (path.join("bin").join(sub).join(tool), path.join("bin").join(host))) - .filter(|&(ref path, _)| path.is_file()) - .map(|(path, host)| { - let mut tool = MsvcTool::new(path); - tool.path.push(host); - tool - }) - .filter_map(|mut tool| { - let sub = otry!(vc_lib_subdir(target)); - tool.libs.push(path.join("lib").join(sub)); - tool.include.push(path.join("include")); - let atlmfc_path = path.join("atlmfc"); - if atlmfc_path.exists() { - tool.libs.push(atlmfc_path.join("lib").join(sub)); - tool.include.push(atlmfc_path.join("include")); - } - Some(tool) - }) - .next() - } - - // To find MSVC we look in a specific registry key for the version we are - // trying to find. - fn get_vc_dir(ver: &str) -> Option<PathBuf> { - let key = r"SOFTWARE\Microsoft\VisualStudio\SxS\VC7"; - let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok()); - let path = otry!(key.query_str(ver).ok()); - Some(path.into()) - } - - // To find the Universal CRT we look in a specific registry key for where - // all the Universal CRTs are located and then sort them asciibetically to - // find the newest version. While this sort of sorting isn't ideal, it is - // what vcvars does so that's good enough for us. - // - // Returns a pair of (root, version) for the ucrt dir if found - fn get_ucrt_dir() -> Option<(PathBuf, String)> { - let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots"; - let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok()); - let root = otry!(key.query_str("KitsRoot10").ok()); - let readdir = otry!(Path::new(&root).join("lib").read_dir().ok()); - let max_libdir = otry!(readdir.filter_map(|dir| dir.ok()) - .map(|dir| dir.path()) - .filter(|dir| { - dir.components() - .last() - .and_then(|c| c.as_os_str().to_str()) - .map(|c| c.starts_with("10.") && dir.join("ucrt").is_dir()) - .unwrap_or(false) - }) - .max()); - let version = max_libdir.components().last().unwrap(); - let version = version.as_os_str().to_str().unwrap().to_string(); - Some((root.into(), version)) - } - - // Vcvars finds the correct version of the Windows 10 SDK by looking - // for the include `um\Windows.h` because sometimes a given version will - // only have UCRT bits without the rest of the SDK. Since we only care about - // libraries and not includes, we instead look for `um\x64\kernel32.lib`. - // Since the 32-bit and 64-bit libraries are always installed together we - // only need to bother checking x64, making this code a tiny bit simpler. - // Like we do for the Universal CRT, we sort the possibilities - // asciibetically to find the newest one as that is what vcvars does. - fn get_sdk10_dir() -> Option<(PathBuf, String)> { - let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0"; - let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok()); - let root = otry!(key.query_str("InstallationFolder").ok()); - let readdir = otry!(Path::new(&root).join("lib").read_dir().ok()); - let mut dirs = readdir.filter_map(|dir| dir.ok()) - .map(|dir| dir.path()) - .collect::<Vec<_>>(); - dirs.sort(); - let dir = otry!(dirs.into_iter() - .rev() - .filter(|dir| dir.join("um").join("x64").join("kernel32.lib").is_file()) - .next()); - let version = dir.components().last().unwrap(); - let version = version.as_os_str().to_str().unwrap().to_string(); - Some((root.into(), version)) - } - - // Interestingly there are several subdirectories, `win7` `win8` and - // `winv6.3`. Vcvars seems to only care about `winv6.3` though, so the same - // applies to us. Note that if we were targetting kernel mode drivers - // instead of user mode applications, we would care. - fn get_sdk81_dir() -> Option<PathBuf> { - let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1"; - let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok()); - let root = otry!(key.query_str("InstallationFolder").ok()); - Some(root.into()) - } - - fn get_sdk8_dir() -> Option<PathBuf> { - let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0"; - let key = otry!(LOCAL_MACHINE.open(key.as_ref()).ok()); - let root = otry!(key.query_str("InstallationFolder").ok()); - Some(root.into()) - } - - const PROCESSOR_ARCHITECTURE_INTEL: u16 = 0; - const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9; - const X86: u16 = PROCESSOR_ARCHITECTURE_INTEL; - const X86_64: u16 = PROCESSOR_ARCHITECTURE_AMD64; - - // When choosing the tool to use, we have to choose the one which matches - // the target architecture. Otherwise we end up in situations where someone - // on 32-bit Windows is trying to cross compile to 64-bit and it tries to - // invoke the native 64-bit compiler which won't work. - // - // For the return value of this function, the first member of the tuple is - // the folder of the tool we will be invoking, while the second member is - // the folder of the host toolchain for that tool which is essential when - // using a cross linker. We return a Vec since on x64 there are often two - // linkers that can target the architecture we desire. The 64-bit host - // linker is preferred, and hence first, due to 64-bit allowing it more - // address space to work with and potentially being faster. - fn bin_subdir(target: &str) -> Vec<(&'static str, &'static str)> { - let arch = target.split('-').next().unwrap(); - match (arch, host_arch()) { - ("i586", X86) | ("i686", X86) => vec![("", "")], - ("i586", X86_64) | ("i686", X86_64) => vec![("amd64_x86", "amd64"), ("", "")], - ("x86_64", X86) => vec![("x86_amd64", "")], - ("x86_64", X86_64) => vec![("amd64", "amd64"), ("x86_amd64", "")], - ("arm", X86) => vec![("x86_arm", "")], - ("arm", 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" => Some("arm"), - _ => 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" => Some("arm"), - _ => 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 - } - - // see http://stackoverflow.com/questions/328017/path-to-msbuild - fn find_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/src/vendor/gcc/tests/cc_env.rs b/src/vendor/gcc/tests/cc_env.rs deleted file mode 100644 index 559dbe8ad4e..00000000000 --- a/src/vendor/gcc/tests/cc_env.rs +++ /dev/null @@ -1,49 +0,0 @@ -extern crate tempdir; -extern crate gcc; - -use std::env; - -mod support; -use support::Test; - -#[test] -fn main() { - ccache(); - distcc(); - ccache_spaces(); -} - -fn ccache() { - let test = Test::gnu(); - test.shim("ccache"); - - env::set_var("CC", "ccache lol-this-is-not-a-compiler foo"); - test.gcc().file("foo.c").compile("libfoo.a"); - - test.cmd(0) - .must_have("lol-this-is-not-a-compiler foo") - .must_have("foo.c") - .must_not_have("ccache"); -} - -fn ccache_spaces() { - let test = Test::gnu(); - test.shim("ccache"); - - env::set_var("CC", "ccache lol-this-is-not-a-compiler foo"); - test.gcc().file("foo.c").compile("libfoo.a"); - test.cmd(0).must_have("lol-this-is-not-a-compiler foo"); -} - -fn distcc() { - let test = Test::gnu(); - test.shim("distcc"); - - env::set_var("CC", "distcc lol-this-is-not-a-compiler foo"); - test.gcc().file("foo.c").compile("libfoo.a"); - - test.cmd(0) - .must_have("lol-this-is-not-a-compiler foo") - .must_have("foo.c") - .must_not_have("distcc"); -} diff --git a/src/vendor/gcc/tests/support/mod.rs b/src/vendor/gcc/tests/support/mod.rs deleted file mode 100644 index 135a6635b59..00000000000 --- a/src/vendor/gcc/tests/support/mod.rs +++ /dev/null @@ -1,112 +0,0 @@ -#![allow(dead_code)] - -use std::env; -use std::ffi::OsStr; -use std::fs::{self, File}; -use std::io::prelude::*; -use std::path::PathBuf; - -use gcc; -use tempdir::TempDir; - -pub struct Test { - pub td: TempDir, - pub gcc: PathBuf, - pub msvc: bool, -} - -pub struct Execution { - args: Vec<String>, -} - -impl Test { - pub fn new() -> Test { - let mut gcc = PathBuf::from(env::current_exe().unwrap()); - gcc.pop(); - if gcc.ends_with("deps") { - gcc.pop(); - } - gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX)); - Test { - td: TempDir::new("gcc-test").unwrap(), - gcc: gcc, - msvc: false, - } - } - - pub fn gnu() -> Test { - let t = Test::new(); - t.shim("cc").shim("ar"); - t - } - - pub fn msvc() -> Test { - let mut t = Test::new(); - t.shim("cl").shim("lib.exe"); - t.msvc = true; - t - } - - pub fn shim(&self, name: &str) -> &Test { - let fname = format!("{}{}", name, env::consts::EXE_SUFFIX); - fs::hard_link(&self.gcc, self.td.path().join(&fname)) - .or_else(|_| fs::copy(&self.gcc, self.td.path().join(&fname)).map(|_| ())) - .unwrap(); - self - } - - pub fn gcc(&self) -> gcc::Config { - let mut cfg = gcc::Config::new(); - let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>(); - path.insert(0, self.td.path().to_owned()); - let target = if self.msvc { - "x86_64-pc-windows-msvc" - } else { - "x86_64-unknown-linux-gnu" - }; - - cfg.target(target) - .host(target) - .opt_level(2) - .debug(false) - .out_dir(self.td.path()) - .__set_env("PATH", env::join_paths(path).unwrap()) - .__set_env("GCCTEST_OUT_DIR", self.td.path()); - if self.msvc { - cfg.compiler(self.td.path().join("cl")); - cfg.archiver(self.td.path().join("lib.exe")); - } - cfg - } - - pub fn cmd(&self, i: u32) -> Execution { - let mut s = String::new(); - File::open(self.td.path().join(format!("out{}", i))) - .unwrap() - .read_to_string(&mut s) - .unwrap(); - Execution { args: s.lines().map(|s| s.to_string()).collect() } - } -} - -impl Execution { - pub fn must_have<P: AsRef<OsStr>>(&self, p: P) -> &Execution { - if !self.has(p.as_ref()) { - panic!("didn't find {:?} in {:?}", p.as_ref(), self.args); - } else { - self - } - } - - pub fn must_not_have<P: AsRef<OsStr>>(&self, p: P) -> &Execution { - if self.has(p.as_ref()) { - panic!("found {:?}", p.as_ref()); - } else { - self - } - } - - pub fn has(&self, p: &OsStr) -> bool { - self.args.iter().any(|arg| OsStr::new(arg) == p) - } -} diff --git a/src/vendor/gcc/tests/test.rs b/src/vendor/gcc/tests/test.rs deleted file mode 100644 index 5a034ff347b..00000000000 --- a/src/vendor/gcc/tests/test.rs +++ /dev/null @@ -1,230 +0,0 @@ -extern crate gcc; -extern crate tempdir; - -use support::Test; - -mod support; - -#[test] -fn gnu_smoke() { - let test = Test::gnu(); - test.gcc() - .file("foo.c") - .compile("libfoo.a"); - - 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("libfoo.a"); - - 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("libfoo.a"); - - test.cmd(0) - .must_have("-Os") - .must_not_have("-O1") - .must_not_have("-O2") - .must_not_have("-O3") - .must_not_have("-Oz"); -} - -#[test] -fn gnu_debug() { - let test = Test::gnu(); - test.gcc() - .debug(true) - .file("foo.c") - .compile("libfoo.a"); - test.cmd(0).must_have("-g"); -} - -#[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("libfoo.a"); - - 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("libfoo.a"); - - 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("libfoo.a"); - - test.cmd(0) - .must_not_have("-fPIC") - .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("libfoo.a"); - - test.cmd(0).must_have("-fPIC"); - } -} - -#[test] -fn gnu_set_stdlib() { - let test = Test::gnu(); - test.gcc() - .cpp_set_stdlib(Some("foo")) - .file("foo.c") - .compile("libfoo.a"); - - 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("libfoo.a"); - - test.cmd(0).must_have("-I").must_have("foo/bar"); -} - -#[test] -fn gnu_define() { - let test = Test::gnu(); - test.gcc() - .define("FOO", Some("bar")) - .define("BAR", None) - .file("foo.c") - .compile("libfoo.a"); - - 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("libfoo.a"); - test.cmd(0).must_have("foo.S"); -} - -#[test] -fn msvc_smoke() { - let test = Test::msvc(); - test.gcc() - .file("foo.c") - .compile("libfoo.a"); - - test.cmd(0) - .must_have("/O2") - .must_have("foo.c") - .must_not_have("/Z7") - .must_have("/c"); - 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("libfoo.a"); - - test.cmd(0).must_not_have("/O2"); -} - -#[test] -fn msvc_debug() { - let test = Test::msvc(); - test.gcc() - .debug(true) - .file("foo.c") - .compile("libfoo.a"); - test.cmd(0).must_have("/Z7"); -} - -#[test] -fn msvc_include() { - let test = Test::msvc(); - test.gcc() - .include("foo/bar") - .file("foo.c") - .compile("libfoo.a"); - - test.cmd(0).must_have("/I").must_have("foo/bar"); -} - -#[test] -fn msvc_define() { - let test = Test::msvc(); - test.gcc() - .define("FOO", Some("bar")) - .define("BAR", None) - .file("foo.c") - .compile("libfoo.a"); - - test.cmd(0).must_have("/DFOO=bar").must_have("/DBAR"); -} diff --git a/src/vendor/getopts/.cargo-checksum.json b/src/vendor/getopts/.cargo-checksum.json deleted file mode 100644 index 0c13fda1c11..00000000000 --- a/src/vendor/getopts/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"c1e953ee360e77de57f7b02f1b7880bd6a3dc22d1a69e953c2ac2c52cc52d247",".travis.yml":"f01015154ac55bebd8ff25742496135c40395959f772005bdf7c63bc9b373c12","Cargo.toml":"a027aa6d21622b42c545707ba04f78341cc28079b46da775827ab1ec37fe3ca7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"4002d78e71c4e1fb82c77590eddb999371f40dce037d895f96e6d6df42c728d3","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","src/lib.rs":"9512dd4ec1053c9fc61f630d869053ca50c55e0839e3ab7091246a8654423bf0","tests/smoke.rs":"26a95ac42e42b766ae752fe8531fb740fd147d5cdff352dec0763d175ce91806"},"package":"d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"} \ No newline at end of file diff --git a/src/vendor/getopts/.cargo-ok b/src/vendor/getopts/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/getopts/.cargo-ok +++ /dev/null diff --git a/src/vendor/getopts/.gitignore b/src/vendor/getopts/.gitignore deleted file mode 100644 index 4fffb2f89cb..00000000000 --- a/src/vendor/getopts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/src/vendor/getopts/.travis.yml b/src/vendor/getopts/.travis.yml deleted file mode 100644 index d7e3f4787ae..00000000000 --- a/src/vendor/getopts/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: rust -rust: - - 1.0.0 - - beta - - nightly -sudo: false -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH -script: - - cargo build --verbose - - cargo test --verbose - - cargo doc --no-deps -after_success: - - travis-cargo --only nightly doc-upload -env: - global: - secure: by+Jo/boBPbcF5c1N6RNCA008oJm2aRFE5T0SUc3OIfTXxY08dZc0WCBJCHrplp44VjpeKRp/89Y+k1CKncIeU8LiS6ZgsKqaQcCglE2O1KS90B6FYB7+rBqT3ib25taq1nW38clnBHYHV9nz4gOElSdKGRxCcBy+efQ5ZXr2tY= -notifications: - email: - on_success: never diff --git a/src/vendor/getopts/Cargo.toml b/src/vendor/getopts/Cargo.toml deleted file mode 100644 index f84899fe812..00000000000 --- a/src/vendor/getopts/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] - -name = "getopts" -version = "0.2.14" -authors = ["The Rust Project Developers"] -license = "MIT/Apache-2.0" -readme = "README.md" -repository = "https://github.com/rust-lang/getopts" -documentation = "http://doc.rust-lang.org/getopts" -homepage = "https://github.com/rust-lang/getopts" -description = """ -getopts-like option parsing. -""" - -[dev-dependencies] -log = "0.3" diff --git a/src/vendor/getopts/LICENSE-APACHE b/src/vendor/getopts/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/getopts/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/src/vendor/getopts/LICENSE-MIT b/src/vendor/getopts/LICENSE-MIT deleted file mode 100644 index 39d4bdb5acd..00000000000 --- a/src/vendor/getopts/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/src/vendor/getopts/README.md b/src/vendor/getopts/README.md deleted file mode 100644 index c19f48fb06b..00000000000 --- a/src/vendor/getopts/README.md +++ /dev/null @@ -1,23 +0,0 @@ -getopts -=== - -A Rust library for option parsing for CLI utilities. - -[](https://travis-ci.org/rust-lang/getopts) - -[Documentation](http://doc.rust-lang.org/getopts) - -## Usage - -Add this to your `Cargo.toml`: - -```toml -[dependencies] -getopts = "0.2.4" -``` - -and this to your crate root: - -```rust -extern crate getopts; -``` diff --git a/src/vendor/getopts/appveyor.yml b/src/vendor/getopts/appveyor.yml deleted file mode 100644 index 6a1b8dc19c0..00000000000 --- a/src/vendor/getopts/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu -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 test --verbose diff --git a/src/vendor/getopts/src/lib.rs b/src/vendor/getopts/src/lib.rs deleted file mode 100644 index 8f0c866fae9..00000000000 --- a/src/vendor/getopts/src/lib.rs +++ /dev/null @@ -1,1831 +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. -// -// ignore-lexer-test FIXME #15677 - -//! Simple getopt alternative. -//! -//! Construct a vector of options, either by using `reqopt`, `optopt`, and -//! `optflag` or by building them from components yourself, and pass them to -//! `getopts`, along with a vector of actual arguments (not including -//! `argv[0]`). You'll either get a failure code back, or a match. You'll have -//! to verify whether the amount of 'free' arguments in the match is what you -//! expect. Use `opt_*` accessors to get argument values out of the matches -//! object. -//! -//! Single-character options are expected to appear on the command line with a -//! single preceding dash; multiple-character options are expected to be -//! proceeded by two dashes. Options that expect an argument accept their -//! argument following either a space or an equals sign. Single-character -//! options don't require the space. -//! -//! # Usage -//! -//! This crate is [on crates.io](https://crates.io/crates/getopts) and can be -//! used by adding `getopts` to the dependencies in your project's `Cargo.toml`. -//! -//! ```toml -//! [dependencies] -//! getopts = "0.2" -//! ``` -//! -//! and this to your crate root: -//! -//! ```rust -//! extern crate getopts; -//! ``` -//! -//! # Example -//! -//! The following example shows simple command line parsing for an application -//! that requires an input file to be specified, accepts an optional output file -//! name following `-o`, and accepts both `-h` and `--help` as optional flags. -//! -//! ```{.rust} -//! extern crate getopts; -//! use getopts::Options; -//! use std::env; -//! -//! fn do_work(inp: &str, out: Option<String>) { -//! println!("{}", inp); -//! match out { -//! Some(x) => println!("{}", x), -//! None => println!("No Output"), -//! } -//! } -//! -//! fn print_usage(program: &str, opts: Options) { -//! let brief = format!("Usage: {} FILE [options]", program); -//! print!("{}", opts.usage(&brief)); -//! } -//! -//! fn main() { -//! let args: Vec<String> = env::args().collect(); -//! let program = args[0].clone(); -//! -//! let mut opts = Options::new(); -//! opts.optopt("o", "", "set output file name", "NAME"); -//! opts.optflag("h", "help", "print this help menu"); -//! let matches = match opts.parse(&args[1..]) { -//! Ok(m) => { m } -//! Err(f) => { panic!(f.to_string()) } -//! }; -//! if matches.opt_present("h") { -//! print_usage(&program, opts); -//! return; -//! } -//! let output = matches.opt_str("o"); -//! let input = if !matches.free.is_empty() { -//! matches.free[0].clone() -//! } else { -//! print_usage(&program, opts); -//! return; -//! }; -//! do_work(&input, output); -//! } -//! ``` - -#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/getopts/")] -#![deny(missing_docs)] -#![cfg_attr(test, deny(warnings))] -#![cfg_attr(rust_build, feature(staged_api))] -#![cfg_attr(rust_build, staged_api)] -#![cfg_attr(rust_build, - unstable(feature = "rustc_private", - reason = "use the crates.io `getopts` library instead"))] - -#[cfg(test)] #[macro_use] extern crate log; - -use self::Name::*; -use self::HasArg::*; -use self::Occur::*; -use self::Fail::*; -use self::Optval::*; -use self::SplitWithinState::*; -use self::Whitespace::*; -use self::LengthLimit::*; - -use std::error::Error; -use std::ffi::OsStr; -use std::fmt; -use std::iter::{repeat, IntoIterator}; -use std::result; - -/// A description of the options that a program can handle. -pub struct Options { - grps: Vec<OptGroup>, - parsing_style : ParsingStyle -} - -impl Options { - /// Create a blank set of options. - pub fn new() -> Options { - Options { - grps: Vec::new(), - parsing_style: ParsingStyle::FloatingFrees - } - } - - /// Set the parsing style. - pub fn parsing_style(&mut self, style: ParsingStyle) -> &mut Options { - self.parsing_style = style; - self - } - - /// Create a generic option group, stating all parameters explicitly. - pub fn opt(&mut self, short_name: &str, long_name: &str, desc: &str, - hint: &str, hasarg: HasArg, occur: Occur) -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: hint.to_string(), - desc: desc.to_string(), - hasarg: hasarg, - occur: occur - }); - self - } - - /// Create a long option that is optional and does not take an argument. - /// - /// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none - /// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none - /// * `desc` - Description for usage help - pub fn optflag(&mut self, short_name: &str, long_name: &str, desc: &str) - -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: "".to_string(), - desc: desc.to_string(), - hasarg: No, - occur: Optional - }); - self - } - - /// Create a long option that can occur more than once and does not - /// take an argument. - /// - /// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none - /// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none - /// * `desc` - Description for usage help - pub fn optflagmulti(&mut self, short_name: &str, long_name: &str, desc: &str) - -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: "".to_string(), - desc: desc.to_string(), - hasarg: No, - occur: Multi - }); - self - } - - /// Create a long option that is optional and takes an optional argument. - /// - /// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none - /// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none - /// * `desc` - Description for usage help - /// * `hint` - Hint that is used in place of the argument in the usage help, - /// e.g. `"FILE"` for a `-o FILE` option - pub fn optflagopt(&mut self, short_name: &str, long_name: &str, desc: &str, - hint: &str) -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: hint.to_string(), - desc: desc.to_string(), - hasarg: Maybe, - occur: Optional - }); - self - } - - /// Create a long option that is optional, takes an argument, and may occur - /// multiple times. - /// - /// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none - /// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none - /// * `desc` - Description for usage help - /// * `hint` - Hint that is used in place of the argument in the usage help, - /// e.g. `"FILE"` for a `-o FILE` option - pub fn optmulti(&mut self, short_name: &str, long_name: &str, desc: &str, hint: &str) - -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: hint.to_string(), - desc: desc.to_string(), - hasarg: Yes, - occur: Multi - }); - self - } - - /// Create a long option that is optional and takes an argument. - /// - /// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none - /// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none - /// * `desc` - Description for usage help - /// * `hint` - Hint that is used in place of the argument in the usage help, - /// e.g. `"FILE"` for a `-o FILE` option - pub fn optopt(&mut self, short_name: &str, long_name: &str, desc: &str, hint: &str) - -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: hint.to_string(), - desc: desc.to_string(), - hasarg: Yes, - occur: Optional - }); - self - } - - /// Create a long option that is required and takes an argument. - /// - /// * `short_name` - e.g. `"h"` for a `-h` option, or `""` for none - /// * `long_name` - e.g. `"help"` for a `--help` option, or `""` for none - /// * `desc` - Description for usage help - /// * `hint` - Hint that is used in place of the argument in the usage help, - /// e.g. `"FILE"` for a `-o FILE` option - pub fn reqopt(&mut self, short_name: &str, long_name: &str, desc: &str, hint: &str) - -> &mut Options { - let len = short_name.len(); - assert!(len == 1 || len == 0); - self.grps.push(OptGroup { - short_name: short_name.to_string(), - long_name: long_name.to_string(), - hint: hint.to_string(), - desc: desc.to_string(), - hasarg: Yes, - occur: Req - }); - self - } - - /// Parse command line arguments according to the provided options. - /// - /// On success returns `Ok(Matches)`. Use methods such as `opt_present` - /// `opt_str`, etc. to interrogate results. - /// # Panics - /// - /// Returns `Err(Fail)` on failure: use the `Debug` implementation of `Fail` - /// to display information about it. - pub fn parse<C: IntoIterator>(&self, args: C) -> Result - where C::Item: AsRef<OsStr> - { - let opts: Vec<Opt> = self.grps.iter().map(|x| x.long_to_short()).collect(); - let n_opts = opts.len(); - - fn f(_x: usize) -> Vec<Optval> { return Vec::new(); } - - let mut vals = (0 .. n_opts).map(f).collect::<Vec<_>>(); - let mut free: Vec<String> = Vec::new(); - let args = try!(args.into_iter().map(|i| { - i.as_ref().to_str().ok_or_else(|| { - Fail::UnrecognizedOption(format!("{:?}", i.as_ref())) - }).map(|s| s.to_owned()) - }).collect::<::std::result::Result<Vec<_>, _>>()); - let l = args.len(); - let mut i = 0; - while i < l { - let cur = args[i].clone(); - let curlen = cur.len(); - if !is_arg(&cur) { - match self.parsing_style { - ParsingStyle::FloatingFrees => free.push(cur), - ParsingStyle::StopAtFirstFree => { - while i < l { - free.push(args[i].clone()); - i += 1; - } - break; - } - } - } else if cur == "--" { - let mut j = i + 1; - while j < l { free.push(args[j].clone()); j += 1; } - break; - } else { - let mut names; - let mut i_arg = None; - if cur.as_bytes()[1] == b'-' { - let tail = &cur[2..curlen]; - let tail_eq: Vec<&str> = tail.splitn(2, '=').collect(); - if tail_eq.len() <= 1 { - names = vec!(Long(tail.to_string())); - } else { - names = - vec!(Long(tail_eq[0].to_string())); - i_arg = Some(tail_eq[1].to_string()); - } - } else { - names = Vec::new(); - for (j, ch) in cur.char_indices().skip(1) { - let opt = Short(ch); - - /* In a series of potential options (eg. -aheJ), if we - see one which takes an argument, we assume all - subsequent characters make up the argument. This - allows options such as -L/usr/local/lib/foo to be - interpreted correctly - */ - - let opt_id = match find_opt(&opts, opt.clone()) { - Some(id) => id, - None => return Err(UnrecognizedOption(opt.to_string())) - }; - - names.push(opt); - - let arg_follows = match opts[opt_id].hasarg { - Yes | Maybe => true, - No => false - }; - - if arg_follows { - let next = j + ch.len_utf8(); - if next < curlen { - i_arg = Some(cur[next..curlen].to_string()); - break; - } - } - } - } - let mut name_pos = 0; - for nm in names.iter() { - name_pos += 1; - let optid = match find_opt(&opts, (*nm).clone()) { - Some(id) => id, - None => return Err(UnrecognizedOption(nm.to_string())) - }; - match opts[optid].hasarg { - No => { - if name_pos == names.len() && !i_arg.is_none() { - return Err(UnexpectedArgument(nm.to_string())); - } - vals[optid].push(Given); - } - Maybe => { - if !i_arg.is_none() { - vals[optid] - .push(Val((i_arg.clone()) - .unwrap())); - } else if name_pos < names.len() || i + 1 == l || - is_arg(&args[i + 1]) { - vals[optid].push(Given); - } else { - i += 1; - vals[optid].push(Val(args[i].clone())); - } - } - Yes => { - if !i_arg.is_none() { - vals[optid].push(Val(i_arg.clone().unwrap())); - } else if i + 1 == l { - return Err(ArgumentMissing(nm.to_string())); - } else { - i += 1; - vals[optid].push(Val(args[i].clone())); - } - } - } - } - } - i += 1; - } - for i in 0 .. n_opts { - let n = vals[i].len(); - let occ = opts[i].occur; - if occ == Req && n == 0 { - return Err(OptionMissing(opts[i].name.to_string())); - } - if occ != Multi && n > 1 { - return Err(OptionDuplicated(opts[i].name.to_string())); - } - } - Ok(Matches { - opts: opts, - vals: vals, - free: free - }) - } - - /// Derive a short one-line usage summary from a set of long options. - #[allow(deprecated)] // connect => join in 1.3 - pub fn short_usage(&self, program_name: &str) -> String { - let mut line = format!("Usage: {} ", program_name); - line.push_str(&self.grps.iter() - .map(format_option) - .collect::<Vec<String>>() - .connect(" ")); - line - } - - /// Derive a usage message from a set of options. - #[allow(deprecated)] // connect => join in 1.3 - pub fn usage(&self, brief: &str) -> String { - let desc_sep = format!("\n{}", repeat(" ").take(24).collect::<String>()); - - let any_short = self.grps.iter().any(|optref| { - optref.short_name.len() > 0 - }); - - let rows = self.grps.iter().map(|optref| { - let OptGroup{short_name, - long_name, - hint, - desc, - hasarg, - ..} = (*optref).clone(); - - let mut row = " ".to_string(); - - // short option - match short_name.len() { - 0 => { - if any_short { - row.push_str(" "); - } - } - 1 => { - row.push('-'); - row.push_str(&short_name); - if long_name.len() > 0 { - row.push_str(", "); - } else { - // Only a single space here, so that any - // argument is printed in the correct spot. - row.push(' '); - } - } - _ => panic!("the short name should only be 1 ascii char long"), - } - - // long option - match long_name.len() { - 0 => {} - _ => { - row.push_str("--"); - row.push_str(&long_name); - row.push(' '); - } - } - - // arg - match hasarg { - No => {} - Yes => row.push_str(&hint), - Maybe => { - row.push('['); - row.push_str(&hint); - row.push(']'); - } - } - - // FIXME: #5516 should be graphemes not codepoints - // here we just need to indent the start of the description - let rowlen = row.chars().count(); - if rowlen < 24 { - for _ in 0 .. 24 - rowlen { - row.push(' '); - } - } else { - row.push_str(&desc_sep) - } - - // Normalize desc to contain words separated by one space character - let mut desc_normalized_whitespace = String::new(); - for word in desc.split(|c: char| c.is_whitespace()) - .filter(|s| !s.is_empty()) { - desc_normalized_whitespace.push_str(word); - desc_normalized_whitespace.push(' '); - } - - // FIXME: #5516 should be graphemes not codepoints - let mut desc_rows = Vec::new(); - each_split_within(&desc_normalized_whitespace, - 54, - |substr| { - desc_rows.push(substr.to_string()); - true - }); - - // FIXME: #5516 should be graphemes not codepoints - // wrapped description - row.push_str(&desc_rows.connect(&desc_sep)); - - row - }); - - format!("{}\n\nOptions:\n{}\n", brief, - rows.collect::<Vec<String>>().connect("\n")) - } -} - -/// What parsing style to use when parsing arguments. -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum ParsingStyle { - /// Flags and "free" arguments can be freely inter-mixed. - FloatingFrees, - /// As soon as a "free" argument (i.e. non-flag) is encountered, stop - /// considering any remaining arguments as flags. - StopAtFirstFree -} - -/// Name of an option. Either a string or a single char. -#[derive(Clone, PartialEq, Eq)] -enum Name { - /// A string representing the long name of an option. - /// For example: "help" - Long(String), - /// A char representing the short name of an option. - /// For example: 'h' - Short(char), -} - -/// Describes whether an option has an argument. -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum HasArg { - /// The option requires an argument. - Yes, - /// The option takes no argument. - No, - /// The option argument is optional. - Maybe, -} - -/// Describes how often an option may occur. -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum Occur { - /// The option occurs once. - Req, - /// The option occurs at most once. - Optional, - /// The option occurs zero or more times. - Multi, -} - -/// A description of a possible option. -#[derive(Clone, PartialEq, Eq)] -struct Opt { - /// Name of the option - name: Name, - /// Whether it has an argument - hasarg: HasArg, - /// How often it can occur - occur: Occur, - /// Which options it aliases - aliases: Vec<Opt>, -} - -/// One group of options, e.g., both `-h` and `--help`, along with -/// their shared description and properties. -#[derive(Clone, PartialEq, Eq)] -struct OptGroup { - /// Short name of the option, e.g. `h` for a `-h` option - short_name: String, - /// Long name of the option, e.g. `help` for a `--help` option - long_name: String, - /// Hint for argument, e.g. `FILE` for a `-o FILE` option - hint: String, - /// Description for usage help text - desc: String, - /// Whether option has an argument - hasarg: HasArg, - /// How often it can occur - occur: Occur -} - -/// Describes whether an option is given at all or has a value. -#[derive(Clone, PartialEq, Eq)] -enum Optval { - Val(String), - Given, -} - -/// The result of checking command line arguments. Contains a vector -/// of matches and a vector of free strings. -#[derive(Clone, PartialEq, Eq)] -pub struct Matches { - /// Options that matched - opts: Vec<Opt>, - /// Values of the Options that matched - vals: Vec<Vec<Optval>>, - /// Free string fragments - pub free: Vec<String>, -} - -/// The type returned when the command line does not conform to the -/// expected format. Use the `Debug` implementation to output detailed -/// information. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum Fail { - /// The option requires an argument but none was passed. - ArgumentMissing(String), - /// The passed option is not declared among the possible options. - UnrecognizedOption(String), - /// A required option is not present. - OptionMissing(String), - /// A single occurrence option is being used multiple times. - OptionDuplicated(String), - /// There's an argument being passed to a non-argument option. - UnexpectedArgument(String), -} - -impl Error for Fail { - fn description(&self) -> &str { - match *self { - ArgumentMissing(_) => "missing argument", - UnrecognizedOption(_) => "unrecognized option", - OptionMissing(_) => "missing option", - OptionDuplicated(_) => "duplicated option", - UnexpectedArgument(_) => "unexpected argument", - } - } -} - -/// The type of failure that occurred. -#[derive(Clone, Copy, PartialEq, Eq)] -#[allow(missing_docs)] -pub enum FailType { - ArgumentMissing_, - UnrecognizedOption_, - OptionMissing_, - OptionDuplicated_, - UnexpectedArgument_, -} - -/// The result of parsing a command line with a set of options. -pub type Result = result::Result<Matches, Fail>; - -impl Name { - fn from_str(nm: &str) -> Name { - if nm.len() == 1 { - Short(nm.as_bytes()[0] as char) - } else { - Long(nm.to_string()) - } - } - - fn to_string(&self) -> String { - match *self { - Short(ch) => ch.to_string(), - Long(ref s) => s.to_string() - } - } -} - -impl OptGroup { - /// Translate OptGroup into Opt. - /// (Both short and long names correspond to different Opts). - fn long_to_short(&self) -> Opt { - let OptGroup { - short_name, - long_name, - hasarg, - occur, - .. - } = (*self).clone(); - - match (short_name.len(), long_name.len()) { - (0,0) => panic!("this long-format option was given no name"), - (0,_) => Opt { - name: Long((long_name)), - hasarg: hasarg, - occur: occur, - aliases: Vec::new() - }, - (1,0) => Opt { - name: Short(short_name.as_bytes()[0] as char), - hasarg: hasarg, - occur: occur, - aliases: Vec::new() - }, - (1,_) => Opt { - name: Long((long_name)), - hasarg: hasarg, - occur: occur, - aliases: vec!( - Opt { - name: Short(short_name.as_bytes()[0] as char), - hasarg: hasarg, - occur: occur, - aliases: Vec::new() - } - ) - }, - (_,_) => panic!("something is wrong with the long-form opt") - } - } -} - -impl Matches { - fn opt_vals(&self, nm: &str) -> Vec<Optval> { - match find_opt(&self.opts, Name::from_str(nm)) { - Some(id) => self.vals[id].clone(), - None => panic!("No option '{}' defined", nm) - } - } - - fn opt_val(&self, nm: &str) -> Option<Optval> { - self.opt_vals(nm).into_iter().next() - } - - /// Returns true if an option was matched. - pub fn opt_present(&self, nm: &str) -> bool { - !self.opt_vals(nm).is_empty() - } - - /// Returns the number of times an option was matched. - pub fn opt_count(&self, nm: &str) -> usize { - self.opt_vals(nm).len() - } - - /// Returns true if any of several options were matched. - pub fn opts_present(&self, names: &[String]) -> bool { - names.iter().any(|nm| { - match find_opt(&self.opts, Name::from_str(&nm)) { - Some(id) if !self.vals[id].is_empty() => true, - _ => false, - } - }) - } - - /// Returns the string argument supplied to one of several matching options or `None`. - pub fn opts_str(&self, names: &[String]) -> Option<String> { - names.iter().filter_map(|nm| { - match self.opt_val(&nm) { - Some(Val(s)) => Some(s), - _ => None, - } - }).next() - } - - /// Returns a vector of the arguments provided to all matches of the given - /// option. - /// - /// Used when an option accepts multiple values. - pub fn opt_strs(&self, nm: &str) -> Vec<String> { - self.opt_vals(nm).into_iter().filter_map(|v| { - match v { - Val(s) => Some(s), - _ => None, - } - }).collect() - } - - /// Returns the string argument supplied to a matching option or `None`. - pub fn opt_str(&self, nm: &str) -> Option<String> { - match self.opt_val(nm) { - Some(Val(s)) => Some(s), - _ => None, - } - } - - - /// Returns the matching string, a default, or `None`. - /// - /// Returns `None` if the option was not present, `def` if the option was - /// present but no argument was provided, and the argument if the option was - /// present and an argument was provided. - pub fn opt_default(&self, nm: &str, def: &str) -> Option<String> { - match self.opt_val(nm) { - Some(Val(s)) => Some(s), - Some(_) => Some(def.to_string()), - None => None, - } - } - -} - -fn is_arg(arg: &str) -> bool { - arg.as_bytes().get(0) == Some(&b'-') && arg.len() > 1 -} - -fn find_opt(opts: &[Opt], nm: Name) -> Option<usize> { - // Search main options. - let pos = opts.iter().position(|opt| opt.name == nm); - if pos.is_some() { - return pos - } - - // Search in aliases. - for candidate in opts.iter() { - if candidate.aliases.iter().position(|opt| opt.name == nm).is_some() { - return opts.iter().position(|opt| opt.name == candidate.name); - } - } - - None -} - -impl fmt::Display for Fail { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - ArgumentMissing(ref nm) => { - write!(f, "Argument to option '{}' missing.", *nm) - } - UnrecognizedOption(ref nm) => { - write!(f, "Unrecognized option: '{}'.", *nm) - } - OptionMissing(ref nm) => { - write!(f, "Required option '{}' missing.", *nm) - } - OptionDuplicated(ref nm) => { - write!(f, "Option '{}' given more than once.", *nm) - } - UnexpectedArgument(ref nm) => { - write!(f, "Option '{}' does not take an argument.", *nm) - } - } - } -} - -fn format_option(opt: &OptGroup) -> String { - let mut line = String::new(); - - if opt.occur != Req { - line.push('['); - } - - // Use short_name if possible, but fall back to long_name. - if opt.short_name.len() > 0 { - line.push('-'); - line.push_str(&opt.short_name); - } else { - line.push_str("--"); - line.push_str(&opt.long_name); - } - - if opt.hasarg != No { - line.push(' '); - if opt.hasarg == Maybe { - line.push('['); - } - line.push_str(&opt.hint); - if opt.hasarg == Maybe { - line.push(']'); - } - } - - if opt.occur != Req { - line.push(']'); - } - if opt.occur == Multi { - line.push_str(".."); - } - - line -} - -#[derive(Clone, Copy)] -enum SplitWithinState { - A, // leading whitespace, initial state - B, // words - C, // internal and trailing whitespace -} - -#[derive(Clone, Copy)] -enum Whitespace { - Ws, // current char is whitespace - Cr // current char is not whitespace -} - -#[derive(Clone, Copy)] -enum LengthLimit { - UnderLim, // current char makes current substring still fit in limit - OverLim // current char makes current substring no longer fit in limit -} - - -/// Splits a string into substrings with possibly internal whitespace, -/// each of them at most `lim` bytes long. The substrings have leading and trailing -/// whitespace removed, and are only cut at whitespace boundaries. -/// -/// Note: Function was moved here from `std::str` because this module is the only place that -/// uses it, and because it was too specific for a general string function. -/// -/// # Panics -/// -/// Panics during iteration if the string contains a non-whitespace -/// sequence longer than the limit. -fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F) - -> bool where F: FnMut(&'a str) -> bool { - // Just for fun, let's write this as a state machine: - - let mut slice_start = 0; - let mut last_start = 0; - let mut last_end = 0; - let mut state = A; - let mut fake_i = ss.len(); - let mut lim = lim; - - let mut cont = true; - - // if the limit is larger than the string, lower it to save cycles - if lim >= fake_i { - lim = fake_i; - } - - let mut machine = |cont: &mut bool, (i, c): (usize, char)| { - let whitespace = if c.is_whitespace() { Ws } else { Cr }; - let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim }; - - state = match (state, whitespace, limit) { - (A, Ws, _) => { A } - (A, Cr, _) => { slice_start = i; last_start = i; B } - - (B, Cr, UnderLim) => { B } - (B, Cr, OverLim) if (i - last_start + 1) > lim - => panic!("word starting with {} longer than limit!", - &ss[last_start..i + 1]), - (B, Cr, OverLim) => { - *cont = it(&ss[slice_start..last_end]); - slice_start = last_start; - B - } - (B, Ws, UnderLim) => { - last_end = i; - C - } - (B, Ws, OverLim) => { - last_end = i; - *cont = it(&ss[slice_start..last_end]); - A - } - - (C, Cr, UnderLim) => { - last_start = i; - B - } - (C, Cr, OverLim) => { - *cont = it(&ss[slice_start..last_end]); - slice_start = i; - last_start = i; - last_end = i; - B - } - (C, Ws, OverLim) => { - *cont = it(&ss[slice_start..last_end]); - A - } - (C, Ws, UnderLim) => { - C - } - }; - - *cont - }; - - ss.char_indices().all(|x| machine(&mut cont, x)); - - // Let the automaton 'run out' by supplying trailing whitespace - while cont && match state { B | C => true, A => false } { - machine(&mut cont, (fake_i, ' ')); - fake_i += 1; - } - return cont; -} - -#[test] -fn test_split_within() { - fn t(s: &str, i: usize, u: &[String]) { - let mut v = Vec::new(); - each_split_within(s, i, |s| { v.push(s.to_string()); true }); - assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); - } - t("", 0, &[]); - t("", 15, &[]); - t("hello", 15, &["hello".to_string()]); - t("\nMary had a little lamb\nLittle lamb\n", 15, &[ - "Mary had a".to_string(), - "little lamb".to_string(), - "Little lamb".to_string() - ]); - t("\nMary had a little lamb\nLittle lamb\n", ::std::usize::MAX, - &["Mary had a little lamb\nLittle lamb".to_string()]); -} - -#[cfg(test)] -mod tests { - use super::{HasArg, Name, Occur, Opt, Options, ParsingStyle}; - use super::Fail::*; - - // Tests for reqopt - #[test] - fn test_reqopt() { - let long_args = vec!("--test=20".to_string()); - let mut opts = Options::new(); - opts.reqopt("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!(m.opt_present("t")); - assert_eq!(m.opt_str("t").unwrap(), "20"); - } - _ => { panic!("test_reqopt failed (long arg)"); } - } - let short_args = vec!("-t".to_string(), "20".to_string()); - match opts.parse(&short_args) { - Ok(ref m) => { - assert!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), "20"); - } - _ => { panic!("test_reqopt failed (short arg)"); } - } - } - - #[test] - fn test_reqopt_missing() { - let args = vec!("blah".to_string()); - match Options::new() - .reqopt("t", "test", "testing", "TEST") - .parse(&args) { - Err(OptionMissing(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_reqopt_no_arg() { - let long_args = vec!("--test".to_string()); - let mut opts = Options::new(); - opts.reqopt("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Err(ArgumentMissing(_)) => {}, - _ => panic!() - } - let short_args = vec!("-t".to_string()); - match opts.parse(&short_args) { - Err(ArgumentMissing(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_reqopt_multi() { - let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string()); - match Options::new() - .reqopt("t", "test", "testing", "TEST") - .parse(&args) { - Err(OptionDuplicated(_)) => {}, - _ => panic!() - } - } - - // Tests for optopt - #[test] - fn test_optopt() { - let long_args = vec!("--test=20".to_string()); - let mut opts = Options::new(); - opts.optopt("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), "20"); - } - _ => panic!() - } - let short_args = vec!("-t".to_string(), "20".to_string()); - match opts.parse(&short_args) { - Ok(ref m) => { - assert!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), "20"); - } - _ => panic!() - } - } - - #[test] - fn test_optopt_missing() { - let args = vec!("blah".to_string()); - match Options::new() - .optopt("t", "test", "testing", "TEST") - .parse(&args) { - Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); - } - _ => panic!() - } - } - - #[test] - fn test_optopt_no_arg() { - let long_args = vec!("--test".to_string()); - let mut opts = Options::new(); - opts.optopt("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Err(ArgumentMissing(_)) => {}, - _ => panic!() - } - let short_args = vec!("-t".to_string()); - match opts.parse(&short_args) { - Err(ArgumentMissing(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_optopt_multi() { - let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string()); - match Options::new() - .optopt("t", "test", "testing", "TEST") - .parse(&args) { - Err(OptionDuplicated(_)) => {}, - _ => panic!() - } - } - - // Tests for optflag - #[test] - fn test_optflag() { - let long_args = vec!("--test".to_string()); - let mut opts = Options::new(); - opts.optflag("t", "test", "testing"); - match opts.parse(&long_args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert!(m.opt_present("t")); - } - _ => panic!() - } - let short_args = vec!("-t".to_string()); - match opts.parse(&short_args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert!(m.opt_present("t")); - } - _ => panic!() - } - } - - #[test] - fn test_optflag_missing() { - let args = vec!("blah".to_string()); - match Options::new() - .optflag("t", "test", "testing") - .parse(&args) { - Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); - } - _ => panic!() - } - } - - #[test] - fn test_optflag_long_arg() { - let args = vec!("--test=20".to_string()); - match Options::new() - .optflag("t", "test", "testing") - .parse(&args) { - Err(UnexpectedArgument(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_optflag_multi() { - let args = vec!("--test".to_string(), "-t".to_string()); - match Options::new() - .optflag("t", "test", "testing") - .parse(&args) { - Err(OptionDuplicated(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_optflag_short_arg() { - let args = vec!("-t".to_string(), "20".to_string()); - match Options::new() - .optflag("t", "test", "testing") - .parse(&args) { - Ok(ref m) => { - // The next variable after the flag is just a free argument - - assert!(m.free[0] == "20"); - } - _ => panic!() - } - } - - // Tests for optflagmulti - #[test] - fn test_optflagmulti_short1() { - let args = vec!("-v".to_string()); - match Options::new() - .optflagmulti("v", "verbose", "verbosity") - .parse(&args) { - Ok(ref m) => { - assert_eq!(m.opt_count("v"), 1); - } - _ => panic!() - } - } - - #[test] - fn test_optflagmulti_short2a() { - let args = vec!("-v".to_string(), "-v".to_string()); - match Options::new() - .optflagmulti("v", "verbose", "verbosity") - .parse(&args) { - Ok(ref m) => { - assert_eq!(m.opt_count("v"), 2); - } - _ => panic!() - } - } - - #[test] - fn test_optflagmulti_short2b() { - let args = vec!("-vv".to_string()); - match Options::new() - .optflagmulti("v", "verbose", "verbosity") - .parse(&args) { - Ok(ref m) => { - assert_eq!(m.opt_count("v"), 2); - } - _ => panic!() - } - } - - #[test] - fn test_optflagmulti_long1() { - let args = vec!("--verbose".to_string()); - match Options::new() - .optflagmulti("v", "verbose", "verbosity") - .parse(&args) { - Ok(ref m) => { - assert_eq!(m.opt_count("verbose"), 1); - } - _ => panic!() - } - } - - #[test] - fn test_optflagmulti_long2() { - let args = vec!("--verbose".to_string(), "--verbose".to_string()); - match Options::new() - .optflagmulti("v", "verbose", "verbosity") - .parse(&args) { - Ok(ref m) => { - assert_eq!(m.opt_count("verbose"), 2); - } - _ => panic!() - } - } - - #[test] - fn test_optflagmulti_mix() { - let args = vec!("--verbose".to_string(), "-v".to_string(), - "-vv".to_string(), "verbose".to_string()); - match Options::new() - .optflagmulti("v", "verbose", "verbosity") - .parse(&args) { - Ok(ref m) => { - assert_eq!(m.opt_count("verbose"), 4); - assert_eq!(m.opt_count("v"), 4); - } - _ => panic!() - } - } - - // Tests for optflagopt - #[test] - fn test_optflagopt() { - let long_args = vec!("--test".to_string()); - let mut opts = Options::new(); - opts.optflag("t", "test", "testing"); - match opts.parse(&long_args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert!(m.opt_present("t")); - } - _ => panic!() - } - let short_args = vec!("-t".to_string()); - match opts.parse(&short_args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert!(m.opt_present("t")); - } - _ => panic!() - } - let no_args: Vec<String> = vec!(); - match opts.parse(&no_args) { - Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); - } - _ => panic!() - } - } - - // Tests for optmulti - #[test] - fn test_optmulti() { - let long_args = vec!("--test=20".to_string()); - let mut opts = Options::new(); - opts.optmulti("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Ok(ref m) => { - assert!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), "20"); - } - _ => panic!() - } - let short_args = vec!("-t".to_string(), "20".to_string()); - match opts.parse(&short_args) { - Ok(ref m) => { - assert!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), "20"); - } - _ => panic!() - } - } - - #[test] - fn test_optmulti_missing() { - let args = vec!("blah".to_string()); - match Options::new() - .optmulti("t", "test", "testing", "TEST") - .parse(&args) { - Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); - } - _ => panic!() - } - } - - #[test] - fn test_optmulti_no_arg() { - let long_args = vec!("--test".to_string()); - let mut opts = Options::new(); - opts.optmulti("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Err(ArgumentMissing(_)) => {}, - _ => panic!() - } - let short_args = vec!("-t".to_string()); - match opts.parse(&short_args) { - Err(ArgumentMissing(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_optmulti_multi() { - let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string()); - match Options::new() - .optmulti("t", "test", "testing", "TEST") - .parse(&args) { - Ok(ref m) => { - assert!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), "20"); - assert!(m.opt_present("t")); - assert_eq!(m.opt_str("t").unwrap(), "20"); - let pair = m.opt_strs("test"); - assert!(pair[0] == "20"); - assert!(pair[1] == "30"); - } - _ => panic!() - } - } - - #[test] - fn test_free_argument_is_hyphen() { - let args = vec!("-".to_string()); - match Options::new().parse(&args) { - Ok(ref m) => { - assert_eq!(m.free.len(), 1); - assert_eq!(m.free[0], "-"); - } - _ => panic!() - } - } - - #[test] - fn test_unrecognized_option() { - let long_args = vec!("--untest".to_string()); - let mut opts = Options::new(); - opts.optmulti("t", "test", "testing", "TEST"); - match opts.parse(&long_args) { - Err(UnrecognizedOption(_)) => {}, - _ => panic!() - } - let short_args = vec!("-u".to_string()); - match opts.parse(&short_args) { - Err(UnrecognizedOption(_)) => {}, - _ => panic!() - } - } - - #[test] - fn test_combined() { - let args = - vec!("prog".to_string(), - "free1".to_string(), - "-s".to_string(), - "20".to_string(), - "free2".to_string(), - "--flag".to_string(), - "--long=30".to_string(), - "-f".to_string(), - "-m".to_string(), - "40".to_string(), - "-m".to_string(), - "50".to_string(), - "-n".to_string(), - "-A B".to_string(), - "-n".to_string(), - "-60 70".to_string()); - match Options::new() - .optopt("s", "something", "something", "SOMETHING") - .optflag("", "flag", "a flag") - .reqopt("", "long", "hi", "LONG") - .optflag("f", "", "another flag") - .optmulti("m", "", "mmmmmm", "YUM") - .optmulti("n", "", "nothing", "NOTHING") - .optopt("", "notpresent", "nothing to see here", "NOPE") - .parse(&args) { - Ok(ref m) => { - assert!(m.free[0] == "prog"); - assert!(m.free[1] == "free1"); - assert_eq!(m.opt_str("s").unwrap(), "20"); - assert!(m.free[2] == "free2"); - assert!((m.opt_present("flag"))); - assert_eq!(m.opt_str("long").unwrap(), "30"); - assert!((m.opt_present("f"))); - let pair = m.opt_strs("m"); - assert!(pair[0] == "40"); - assert!(pair[1] == "50"); - let pair = m.opt_strs("n"); - assert!(pair[0] == "-A B"); - assert!(pair[1] == "-60 70"); - assert!((!m.opt_present("notpresent"))); - } - _ => panic!() - } - } - - #[test] - fn test_mixed_stop() { - let args = - vec!("-a".to_string(), - "b".to_string(), - "-c".to_string(), - "d".to_string()); - match Options::new() - .parsing_style(ParsingStyle::StopAtFirstFree) - .optflag("a", "", "") - .optopt("c", "", "", "") - .parse(&args) { - Ok(ref m) => { - println!("{}", m.opt_present("c")); - assert!(m.opt_present("a")); - assert!(!m.opt_present("c")); - assert_eq!(m.free.len(), 3); - assert_eq!(m.free[0], "b"); - assert_eq!(m.free[1], "-c"); - assert_eq!(m.free[2], "d"); - } - _ => panic!() - } - } - - #[test] - fn test_mixed_stop_hyphen() { - let args = - vec!("-a".to_string(), - "-".to_string(), - "-c".to_string(), - "d".to_string()); - match Options::new() - .parsing_style(ParsingStyle::StopAtFirstFree) - .optflag("a", "", "") - .optopt("c", "", "", "") - .parse(&args) { - Ok(ref m) => { - println!("{}", m.opt_present("c")); - assert!(m.opt_present("a")); - assert!(!m.opt_present("c")); - assert_eq!(m.free.len(), 3); - assert_eq!(m.free[0], "-"); - assert_eq!(m.free[1], "-c"); - assert_eq!(m.free[2], "d"); - } - _ => panic!() - } - } - - #[test] - fn test_multi() { - let mut opts = Options::new(); - opts.optopt("e", "", "encrypt", "ENCRYPT"); - opts.optopt("", "encrypt", "encrypt", "ENCRYPT"); - opts.optopt("f", "", "flag", "FLAG"); - - let args_single = vec!("-e".to_string(), "foo".to_string()); - let matches_single = &match opts.parse(&args_single) { - Ok(m) => m, - Err(_) => panic!() - }; - assert!(matches_single.opts_present(&["e".to_string()])); - assert!(matches_single.opts_present(&["encrypt".to_string(), "e".to_string()])); - assert!(matches_single.opts_present(&["e".to_string(), "encrypt".to_string()])); - assert!(!matches_single.opts_present(&["encrypt".to_string()])); - assert!(!matches_single.opts_present(&["thing".to_string()])); - assert!(!matches_single.opts_present(&[])); - - assert_eq!(matches_single.opts_str(&["e".to_string()]).unwrap(), "foo"); - assert_eq!(matches_single.opts_str(&["e".to_string(), "encrypt".to_string()]).unwrap(), - "foo"); - assert_eq!(matches_single.opts_str(&["encrypt".to_string(), "e".to_string()]).unwrap(), - "foo"); - - let args_both = vec!("-e".to_string(), "foo".to_string(), "--encrypt".to_string(), - "foo".to_string()); - let matches_both = &match opts.parse(&args_both) { - Ok(m) => m, - Err(_) => panic!() - }; - assert!(matches_both.opts_present(&["e".to_string()])); - assert!(matches_both.opts_present(&["encrypt".to_string()])); - assert!(matches_both.opts_present(&["encrypt".to_string(), "e".to_string()])); - assert!(matches_both.opts_present(&["e".to_string(), "encrypt".to_string()])); - assert!(!matches_both.opts_present(&["f".to_string()])); - assert!(!matches_both.opts_present(&["thing".to_string()])); - assert!(!matches_both.opts_present(&[])); - - assert_eq!(matches_both.opts_str(&["e".to_string()]).unwrap(), "foo"); - assert_eq!(matches_both.opts_str(&["encrypt".to_string()]).unwrap(), "foo"); - assert_eq!(matches_both.opts_str(&["e".to_string(), "encrypt".to_string()]).unwrap(), - "foo"); - assert_eq!(matches_both.opts_str(&["encrypt".to_string(), "e".to_string()]).unwrap(), - "foo"); - } - - #[test] - fn test_nospace() { - let args = vec!("-Lfoo".to_string(), "-M.".to_string()); - let matches = &match Options::new() - .optmulti("L", "", "library directory", "LIB") - .optmulti("M", "", "something", "MMMM") - .parse(&args) { - Ok(m) => m, - Err(_) => panic!() - }; - assert!(matches.opts_present(&["L".to_string()])); - assert_eq!(matches.opts_str(&["L".to_string()]).unwrap(), "foo"); - assert!(matches.opts_present(&["M".to_string()])); - assert_eq!(matches.opts_str(&["M".to_string()]).unwrap(), "."); - - } - - #[test] - fn test_nospace_conflict() { - let args = vec!("-vvLverbose".to_string(), "-v".to_string() ); - let matches = &match Options::new() - .optmulti("L", "", "library directory", "LIB") - .optflagmulti("v", "verbose", "Verbose") - .parse(&args) { - Ok(m) => m, - Err(e) => panic!( "{}", e ) - }; - assert!(matches.opts_present(&["L".to_string()])); - assert_eq!(matches.opts_str(&["L".to_string()]).unwrap(), "verbose"); - assert!(matches.opts_present(&["v".to_string()])); - assert_eq!(3, matches.opt_count("v")); - } - - #[test] - fn test_long_to_short() { - let mut short = Opt { - name: Name::Long("banana".to_string()), - hasarg: HasArg::Yes, - occur: Occur::Req, - aliases: Vec::new(), - }; - short.aliases = vec!(Opt { name: Name::Short('b'), - hasarg: HasArg::Yes, - occur: Occur::Req, - aliases: Vec::new() }); - let mut opts = Options::new(); - opts.reqopt("b", "banana", "some bananas", "VAL"); - let ref verbose = opts.grps[0]; - assert!(verbose.long_to_short() == short); - } - - #[test] - fn test_aliases_long_and_short() { - let args = vec!("-a".to_string(), "--apple".to_string(), "-a".to_string()); - - let matches = Options::new() - .optflagmulti("a", "apple", "Desc") - .parse(&args) - .unwrap(); - assert_eq!(3, matches.opt_count("a")); - assert_eq!(3, matches.opt_count("apple")); - } - - #[test] - fn test_usage() { - let mut opts = Options::new(); - opts.reqopt("b", "banana", "Desc", "VAL"); - opts.optopt("a", "012345678901234567890123456789", - "Desc", "VAL"); - opts.optflag("k", "kiwi", "Desc"); - opts.optflagopt("p", "", "Desc", "VAL"); - opts.optmulti("l", "", "Desc", "VAL"); - opts.optflag("", "starfruit", "Starfruit"); - - let expected = -"Usage: fruits - -Options: - -b, --banana VAL Desc - -a, --012345678901234567890123456789 VAL - Desc - -k, --kiwi Desc - -p [VAL] Desc - -l VAL Desc - --starfruit Starfruit -"; - - let generated_usage = opts.usage("Usage: fruits"); - - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", generated_usage); - assert_eq!(generated_usage, expected); - } - - #[test] - fn test_usage_description_wrapping() { - // indentation should be 24 spaces - // lines wrap after 78: or rather descriptions wrap after 54 - - let mut opts = Options::new(); - opts.optflag("k", "kiwi", - "This is a long description which won't be wrapped..+.."); // 54 - opts.optflag("a", "apple", - "This is a long description which _will_ be wrapped..+.."); - - let expected = -"Usage: fruits - -Options: - -k, --kiwi This is a long description which won't be wrapped..+.. - -a, --apple This is a long description which _will_ be - wrapped..+.. -"; - - let usage = opts.usage("Usage: fruits"); - - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", usage); - assert!(usage == expected) - } - - #[test] - fn test_usage_description_multibyte_handling() { - let mut opts = Options::new(); - opts.optflag("k", "k\u{2013}w\u{2013}", - "The word kiwi is normally spelled with two i's"); - opts.optflag("a", "apple", - "This \u{201C}description\u{201D} has some characters that could \ -confuse the line wrapping; an apple costs 0.51€ in some parts of Europe."); - - let expected = -"Usage: fruits - -Options: - -k, --k–w– The word kiwi is normally spelled with two i's - -a, --apple This “description” has some characters that could - confuse the line wrapping; an apple costs 0.51€ in - some parts of Europe. -"; - - let usage = opts.usage("Usage: fruits"); - - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", usage); - assert!(usage == expected) - } - - #[test] - fn test_usage_short_only() { - let mut opts = Options::new(); - opts.optopt("k", "", "Kiwi", "VAL"); - opts.optflag("s", "", "Starfruit"); - opts.optflagopt("a", "", "Apple", "TYPE"); - - let expected = -"Usage: fruits - -Options: - -k VAL Kiwi - -s Starfruit - -a [TYPE] Apple -"; - - let usage = opts.usage("Usage: fruits"); - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", usage); - assert!(usage == expected) - } - - #[test] - fn test_usage_long_only() { - let mut opts = Options::new(); - opts.optopt("", "kiwi", "Kiwi", "VAL"); - opts.optflag("", "starfruit", "Starfruit"); - opts.optflagopt("", "apple", "Apple", "TYPE"); - - let expected = -"Usage: fruits - -Options: - --kiwi VAL Kiwi - --starfruit Starfruit - --apple [TYPE] Apple -"; - - let usage = opts.usage("Usage: fruits"); - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", usage); - assert!(usage == expected) - } - - #[test] - fn test_short_usage() { - let mut opts = Options::new(); - opts.reqopt("b", "banana", "Desc", "VAL"); - opts.optopt("a", "012345678901234567890123456789", - "Desc", "VAL"); - opts.optflag("k", "kiwi", "Desc"); - opts.optflagopt("p", "", "Desc", "VAL"); - opts.optmulti("l", "", "Desc", "VAL"); - - let expected = "Usage: fruits -b VAL [-a VAL] [-k] [-p [VAL]] [-l VAL]..".to_string(); - let generated_usage = opts.short_usage("fruits"); - - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", generated_usage); - assert_eq!(generated_usage, expected); - } - - #[test] - fn test_args_with_equals() { - let mut opts = Options::new(); - opts.optopt("o", "one", "One", "INFO"); - opts.optopt("t", "two", "Two", "INFO"); - - let args = vec!("--one".to_string(), "A=B".to_string(), - "--two=C=D".to_string()); - let matches = &match opts.parse(&args) { - Ok(m) => m, - Err(e) => panic!("{}", e) - }; - assert_eq!(matches.opts_str(&["o".to_string()]).unwrap(), "A=B"); - assert_eq!(matches.opts_str(&["t".to_string()]).unwrap(), "C=D"); - } -} diff --git a/src/vendor/getopts/tests/smoke.rs b/src/vendor/getopts/tests/smoke.rs deleted file mode 100644 index a46f9c0167a..00000000000 --- a/src/vendor/getopts/tests/smoke.rs +++ /dev/null @@ -1,8 +0,0 @@ -extern crate getopts; - -use std::env; - -#[test] -fn main() { - getopts::Options::new().parse(env::args()).unwrap(); -} diff --git a/src/vendor/libc/.cargo-checksum.json b/src/vendor/libc/.cargo-checksum.json deleted file mode 100644 index 56c0bb8d255..00000000000 --- a/src/vendor/libc/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"7150ee9391a955b2ef7e0762fc61c0c1aab167620ca36d88d78062d93b8334ba",".travis.yml":"ca5e05b688a8c9a3215de3b38f22f4b468f73d26738a80bd939af503ddb222e1","Cargo.toml":"4b1f0d59b5fb939877a639d1d4cac5a12440c6e2d366edf2abcb45c46e3dcd3e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c1f46480074340f17f1c3ea989b28e6b632b9d324e57792293a60399b90bfda0","appveyor.yml":"c0d70c650b6231e6ff78a352224f1a522a9be69d9da4251adbaddb3f0393294d","ci/README.md":"be804f15e2128e5fd4b160cb0b13cff5f19e7d77b55ec5254aa6fd8731c84f0d","ci/docker/aarch64-unknown-linux-gnu/Dockerfile":"62ca7317439f9c303990e897450a91cd467be05eb75dfc01456d417932ac8672","ci/docker/arm-linux-androideabi/Dockerfile":"c3d60f2ba389e60e59cb6973542751c66a0e7bd484e11589c8ee7346e9ff2bab","ci/docker/arm-unknown-linux-gnueabihf/Dockerfile":"e349f7caa463adbde8d6ec4d2b9f7720ed81c77f48d75bbfb78c89751f55c2dc","ci/docker/i686-unknown-linux-gnu/Dockerfile":"07e9df6ba91025cbec7ae81ade63f8cfb8a54c5e1e5a8f8def0617e17bd59db0","ci/docker/i686-unknown-linux-musl/Dockerfile":"1a4d064adff4a8f58773305567cfe5d915bcd0762bcb0e101cf6f4ca628a96da","ci/docker/mips-unknown-linux-gnu/Dockerfile":"860299d96ee50ebdbd788e65eb6ba1f561ef66107647bddffcb2567ac350896b","ci/docker/mips-unknown-linux-musl/Dockerfile":"b5917a15c0998adb79ebfdb8aff9ab0e5c4098c4bd5ca78e90ee05859dcfbda3","ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile":"163776e0fd38f66df7415421202ac29efc7d345a628947434e573c3885594ab5","ci/docker/mipsel-unknown-linux-musl/Dockerfile":"b2dd4c26890c1070228df9694adde8fdb1fe78d7d5a71a8cb5c1b54835f93c46","ci/docker/powerpc-unknown-linux-gnu/Dockerfile":"08b846a338c2ee70100f4e80db812668dc58bfb536c44a95cd1cf004d965186b","ci/docker/powerpc64-unknown-linux-gnu/Dockerfile":"4da285ffd035d16f5da9e3701841eb86049c8cfa417fa81e53da4ef74152eac0","ci/docker/x86_64-rumprun-netbsd/Dockerfile":"44c3107fb30380785aaed6ff73fa334017a5bb4e3b5c7d4876154f09023a2b99","ci/docker/x86_64-unknown-freebsd/Dockerfile":"56fce89ceb70792be9005425f3e896361f5ba8a0553db659da87daced93f9785","ci/docker/x86_64-unknown-linux-gnu/Dockerfile":"67fabbc8c6ac02376cf9344251ad49ecdac396b71accb572fd1ae65225325bc0","ci/docker/x86_64-unknown-linux-musl/Dockerfile":"f71019fed5204b950843ef5e56144161fda7e27fad68ed0e8bc4353c388c7bcf","ci/docker/x86_64-unknown-openbsd/Dockerfile":"4a5583797a613056d87f6ae0b1d7a3d3a55552efa7c30e1e0aa67e34d69b4d9c","ci/dox.sh":"2161cb17ee0d6a2279a64149c6b7c73a5b2eab344f248ea1fa0e6c8f6335ec5f","ci/landing-page-footer.html":"b70b3112c2147f5c967e7481061ef38bc2d79a28dd55a16fb916d9c9426da2c4","ci/landing-page-head.html":"ad69663fac7924f27d0209bc519d55838e86edfc4133713a6fd08caadac1b142","ci/run-docker.sh":"325648a92ff4d74f18fdf3d190a5cd483306ed2a98479c0742ca7284acd6b948","ci/run-qemu.sh":"bb859421170871ef23a8940c5e150efec0c01b95e32d2ce2d37b79a45d9d346c","ci/run.sh":"3bb839c2d28986c6915b8f11ed820ff6c62e755fb96bd921a18899ee5f7efd32","ci/style.rs":"60564abc1d5197ed1598426dd0d6ee9939a16d2875b03373538f58843bb616c4","src/dox.rs":"eb6fbcc0b8b59430271bb71ee023961fd165337fc5fd6ca433882457a3c735bd","src/lib.rs":"4cece0e880ec8731913e5110b58d1b134148b0a43e72d6b990c1d999916fc706","src/macros.rs":"bd9802772b0e5c8b3c550d1c24307f06c0d1e4ce656b4ae1cf092142bbe5412c","src/unix/bsd/apple/b32.rs":"110ecff78da0e8d405d861447904da403d8b3f6da1f0f9dc9987633f3f04fe46","src/unix/bsd/apple/b64.rs":"e6808081c0b276cca3189628716f507c7c0d00b62417cd44addbdaefe848cec7","src/unix/bsd/apple/mod.rs":"6691f81221d455b882d68d1102de049d5b9729bb4b59050c1d62c835dcaddafb","src/unix/bsd/freebsdlike/dragonfly/mod.rs":"d87f02c64649ce63367d9f0e39de7213bd30366bbd5e497f7d88f0dc3c319294","src/unix/bsd/freebsdlike/freebsd/mod.rs":"0a675c4b7f54b410547e10e433503487eb1e738394ab81cac82112a96d275bdc","src/unix/bsd/freebsdlike/freebsd/x86.rs":"54311d3ebf2bb091ab22361e377e6ef9224aec2ecfe459fbfcedde4932db9c58","src/unix/bsd/freebsdlike/freebsd/x86_64.rs":"c7f46b9ae23fde5a9e245a28ed1380066e67f081323b4d253a18e9da3b97b860","src/unix/bsd/freebsdlike/mod.rs":"574f7a1368058fad551cdebea4f576fe672f9bbe95a85468c91f9ff5661908c3","src/unix/bsd/mod.rs":"bd422d4bca87a3e8ea4bd78b9ae019643399807d036913f42fdd7476f260297d","src/unix/bsd/netbsdlike/mod.rs":"7b62b89c6ba0d5a8e0cf0937587a81e0314f9c5dabb0c9a9164106b677cf4dd8","src/unix/bsd/netbsdlike/netbsd/mod.rs":"d62a02a78275ed705b2080cae452eb8954ef0f66ac9acb0f44c819d453904c5c","src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs":"bd251a102bed65d5cb3459275f6ec3310fe5803ff4c9651212115548f86256d0","src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs":"927eeccaf3269d299db4c2a55f8010807bf43dfa894aea6a783215f5d3560baa","src/unix/bsd/netbsdlike/netbsd/other/mod.rs":"8ce39030f3e4fb45a3d676ade97da8f6d1b3d5f6d8d141224d341c993c57e090","src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs":"f8cd05dacd3a3136c58da5a2fbe26f703767823b28e74fe8a2b57a7bd98d6d5c","src/unix/bsd/netbsdlike/openbsdlike/mod.rs":"769647209be7b8fc5b7e5c1970f16d5cf9cc3fba04bb456c9584f19a5c406e08","src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs":"b1b9cf7be9f0e4d294a57092594074ad03a65fe0eeac9d1104fa874c313e7900","src/unix/haiku/b32.rs":"bd251a102bed65d5cb3459275f6ec3310fe5803ff4c9651212115548f86256d0","src/unix/haiku/b64.rs":"b422430c550c0ba833c9206d1350861e344e3a2eb33d7d58693efb35044be1cc","src/unix/haiku/mod.rs":"d14c45d536f24cd9cd8d5170b9829026da4c782ff2d5855644cc217553e309cf","src/unix/mod.rs":"82952d405742b8b21bfbc29648115b3909d9c64422ad04fb6aca443c16ddaa99","src/unix/notbsd/android/b32.rs":"148e1b4ed8b4f700d5aa24178af925164176e1c18b54db877ced4b55ba9f03d4","src/unix/notbsd/android/b64.rs":"302caf0aa95fa022030717c58de17d85d814b04350eca081a722ec435bc4f217","src/unix/notbsd/android/mod.rs":"f7c0145110a406c5cb14243dc71b98af8971674aa7620e5f55dabfa5c8b344c8","src/unix/notbsd/linux/mips.rs":"7736e565499b04560bc7e6f8636fd39c74f4a588c671ece931d27de8ca263963","src/unix/notbsd/linux/mips64.rs":"f269d516e0f5203fbfd18ff6b22ff33f206be1584d9df03c35743f5e80127d8b","src/unix/notbsd/linux/mod.rs":"81dbebd7dd798dc57e5b5b84cec69af2b6027a415262f4ad07b8c609ad2c95ee","src/unix/notbsd/linux/musl/b32/arm.rs":"a8416bc6e36460f3c60e2f7730dad7c43466790d11214441ef227ffb05ea450f","src/unix/notbsd/linux/musl/b32/asmjs.rs":"c660c5eef21a5f7580e9258eb44881014d2aeba5928af431dfc782b6c4393f33","src/unix/notbsd/linux/musl/b32/mips.rs":"76d835acd06c7bcd07a293a6f141b715ac88b959b633df9af3610e8d6eeb1ab4","src/unix/notbsd/linux/musl/b32/mod.rs":"bd29a02c67b69791e7cabd7666503c35ed5322d244a005b9cc7fd0cb28b552a8","src/unix/notbsd/linux/musl/b32/x86.rs":"da2e557a6afa9d15649d8862a5d17032597c924cd8bb290105500905fe975133","src/unix/notbsd/linux/musl/b64/aarch64.rs":"4009c7eaf703472daef2a70bdac910d9fc395a33689ef2e8cf1c4e692445d3f0","src/unix/notbsd/linux/musl/b64/mod.rs":"20f34e48124d8ca2a08cc0d28353b310238d37a345dfa0d58993e2e930a1ae23","src/unix/notbsd/linux/musl/b64/powerpc64.rs":"dc28f5b7284235d6cf5519053cac59a1c16dc39223b71cca0871e4880755f852","src/unix/notbsd/linux/musl/b64/x86_64.rs":"43291acc0dfc92c2fec8ba6ce77ee9ca3c20bcdccec18e149f95ba911cee704b","src/unix/notbsd/linux/musl/mod.rs":"c195e04167d26f82885f9157e32a28caccfd4eabe807af683708f33e28562021","src/unix/notbsd/linux/other/b32/arm.rs":"f5cb989075fa3b5f997e7101495532c8d5c9f3577412d4c07e4c8c1a16f7b43c","src/unix/notbsd/linux/other/b32/mod.rs":"8b774feb5510b963ed031db7ab3d7e24f1ba5524a6396db0b851d237ccc16fd3","src/unix/notbsd/linux/other/b32/powerpc.rs":"3b62052bb9741afa5349098e6e9c675b60e822e41fed6b5e1b694be1872097b1","src/unix/notbsd/linux/other/b32/x86.rs":"1eda37736f5966c7968b594f74f5018f56b6b8c67bbdeb31fc3db1b6e4ac31b4","src/unix/notbsd/linux/other/b64/aarch64.rs":"a978e82d037a9c8127b2f704323864aff42ac910e721ecc69c255671ca96b950","src/unix/notbsd/linux/other/b64/mod.rs":"efb7740c2fb925ea98977a6a3ff52bc0b72205c1f88a9ba281a939b66b7f0efe","src/unix/notbsd/linux/other/b64/powerpc64.rs":"06a795bca8e91a0143ef1787b034201ed7a21d01960ce9fe869d18c274d5bdb4","src/unix/notbsd/linux/other/b64/x86_64.rs":"0ed128e93f212c0d65660bd95e29190a2dae7c9d15d6fa0d3c4c6656f89e9bdc","src/unix/notbsd/linux/other/mod.rs":"0f7b29425273101ce90a9565637e5f7f61905db2a1e8f5360b285c73b1287da1","src/unix/notbsd/linux/s390x.rs":"6eddef139e18191bc3894f759ca8bd83c59b547bc572ad8938dc61fb5a97d2e9","src/unix/notbsd/mod.rs":"6ba17e2e9a6d05d4470ba595fd38dc55f70fea874a46425a4733ae52d93ee8ff","src/unix/solaris/mod.rs":"6d1f023b637467fe26385d23b32219dbb4573ea177d159e32dad75e4a6ff95de","src/windows.rs":"08f351462388566dcdc6566fb183a467942db63a1caa1bc97f85284fb7a74063"},"package":"044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8"} \ No newline at end of file diff --git a/src/vendor/libc/.cargo-ok b/src/vendor/libc/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/libc/.cargo-ok +++ /dev/null diff --git a/src/vendor/libc/.gitignore b/src/vendor/libc/.gitignore deleted file mode 100644 index f0ff2599d09..00000000000 --- a/src/vendor/libc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -Cargo.lock -*~ diff --git a/src/vendor/libc/.travis.yml b/src/vendor/libc/.travis.yml deleted file mode 100644 index 703329b7057..00000000000 --- a/src/vendor/libc/.travis.yml +++ /dev/null @@ -1,125 +0,0 @@ -language: rust -sudo: required -dist: trusty -services: - - docker -install: - - curl https://static.rust-lang.org/rustup.sh | - sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` -script: - - cargo build - - cargo build --no-default-features - - cargo generate-lockfile --manifest-path libc-test/Cargo.toml - - if [[ $TRAVIS_OS_NAME = "linux" ]]; then - sh ci/run-docker.sh $TARGET; - else - export CARGO_TARGET_DIR=`pwd`/target; - sh ci/run.sh $TARGET; - fi - - rustc ci/style.rs && ./style src -osx_image: xcode7.3 -env: - global: - secure: eIDEoQdTyglcsTD13zSGotAX2HDhRSXIaaTnVZTThqLSrySOc3/6KY3qmOc2Msf7XaBqfFy9QA+alk7OwfePp253eiy1Kced67ffjjFOytEcRT7FlQiYpcYQD6WNHZEj62/bJBO4LTM9sGtWNCTJVEDKW0WM8mUK7qNuC+honPM= -matrix: - include: - # 1.0.0 compat - - os: linux - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.0.0 - script: cargo build - install: - - # build documentation - - os: linux - env: TARGET=x86_64-unknown-linux-gnu - rust: stable - script: sh ci/dox.sh - - # stable compat - - os: linux - env: TARGET=x86_64-unknown-linux-gnu - rust: stable - - os: linux - env: TARGET=i686-unknown-linux-gnu - rust: stable - - os: osx - env: TARGET=x86_64-apple-darwin - rust: stable - - os: osx - env: TARGET=i686-apple-darwin - rust: stable - - os: linux - env: TARGET=arm-linux-androideabi - rust: stable - - os: linux - env: TARGET=x86_64-unknown-linux-musl - rust: stable - - os: linux - env: TARGET=i686-unknown-linux-musl - rust: stable - - os: linux - env: TARGET=arm-unknown-linux-gnueabihf - rust: stable - - os: linux - env: TARGET=aarch64-unknown-linux-gnu - rust: stable - - os: osx - env: TARGET=i386-apple-ios - rust: stable - - os: osx - env: TARGET=x86_64-apple-ios - rust: stable - - os: linux - env: TARGET=x86_64-rumprun-netbsd - rust: stable - - os: linux - env: TARGET=powerpc-unknown-linux-gnu - rust: stable - - os: linux - env: TARGET=powerpc64-unknown-linux-gnu - rust: stable - - os: linux - env: TARGET=mips-unknown-linux-musl - rust: stable - - os: linux - env: TARGET=mipsel-unknown-linux-musl - rust: stable - - os: linux - env: TARGET=mips64-unknown-linux-gnuabi64 - rust: nightly - - # beta - - os: linux - env: TARGET=x86_64-unknown-linux-gnu - rust: beta - - os: osx - env: TARGET=x86_64-apple-darwin - rust: beta - - # nightly - - os: linux - env: TARGET=x86_64-unknown-linux-gnu - rust: nightly - - os: osx - env: TARGET=x86_64-apple-darwin - rust: nightly - - os: linux - env: TARGET=mips-unknown-linux-gnu - # not sure why this has to be nightly... - rust: nightly - - # QEMU based targets that compile in an emulator - - os: linux - env: TARGET=x86_64-unknown-freebsd - rust: stable - - os: linux - env: TARGET=x86_64-unknown-openbsd QEMU=openbsd.qcow2 - rust: stable - script: sh ci/run-docker.sh $TARGET - install: - -notifications: - email: - on_success: never - webhooks: https://buildbot.rust-lang.org/homu/travis diff --git a/src/vendor/libc/Cargo.toml b/src/vendor/libc/Cargo.toml deleted file mode 100644 index c08ab3aab9d..00000000000 --- a/src/vendor/libc/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] - -name = "libc" -version = "0.2.17" -authors = ["The Rust Project Developers"] -license = "MIT/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" -description = """ -A library for types and bindings to native C functions often found in libc or -other common platform libraries. -""" - -[features] -default = ["use_std"] -use_std = [] - -[workspace] -members = ["libc-test", "libc-test/generate-files"] diff --git a/src/vendor/libc/LICENSE-APACHE b/src/vendor/libc/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/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/src/vendor/libc/LICENSE-MIT b/src/vendor/libc/LICENSE-MIT deleted file mode 100644 index 39d4bdb5acd..00000000000 --- a/src/vendor/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/src/vendor/libc/README.md b/src/vendor/libc/README.md deleted file mode 100644 index 5ea812320f0..00000000000 --- a/src/vendor/libc/README.md +++ /dev/null @@ -1,137 +0,0 @@ -libc -==== - -A Rust library with native bindings to the types and functions commonly found on -various systems, including libc. - -[](https://travis-ci.org/rust-lang/libc) -[](https://ci.appveyor.com/project/alexcrichton/libc) - -[Documentation](#platforms-and-documentation) - -## Usage - -First, add the following to your `Cargo.toml`: - -```toml -[dependencies] -libc = "0.2" -``` - -Next, add this to your crate root: - -```rust -extern crate libc; -``` - -Currently libc by default links to the standard library, but if you would -instead like to use libc in a `#![no_std]` situation or crate you can request -this via: - -```toml -[dependencies] -libc = { version = "0.2", default-features = false } -``` - -## What is libc? - -The primary purpose of this crate is to provide 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 does not strive to have any form of compatibility across platforms, -but rather it is simply a straight binding to the system libraries on the -platform in question. - -## Public API - -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 - -## Adding an API - -Want to use an API which currently isn't bound in `libc`? It's quite easy to add -one! - -The internal structure of this crate is designed to minimize the number of -`#[cfg]` attributes in order to easily be able to add new items which apply -to all platforms in the future. As a result, the crate is organized -hierarchically based on platform. Each module has a number of `#[cfg]`'d -children, but only one is ever actually compiled. Each module then reexports all -the contents of its children. - -This means that for each platform that libc supports, the path from a -leaf module to the root will contain all bindings for the platform in question. -Consequently, this indicates where an API should be added! Adding an API at a -particular level in the hierarchy means that it is supported on all the child -platforms of that level. For example, when adding a Unix API it should be added -to `src/unix/mod.rs`, but when adding a Linux-only API it should be added to -`src/unix/notbsd/linux/mod.rs`. - -If you're not 100% sure at what level of the hierarchy an API should be added -at, fear not! This crate has CI support which tests any binding against all -platforms supported, so you'll see failures if an API is added at the wrong -level or has different signatures across platforms. - -With that in mind, the steps for adding a new API are: - -1. Determine where in the module hierarchy your API should be added. -2. Add the API. -3. Send a PR to this repo. -4. Wait for CI to pass, fixing errors. -5. Wait for a merge! - -### Test before you commit - -We have two automated tests running on [Travis](https://travis-ci.org/rust-lang/libc): - -1. [`libc-test`](https://github.com/alexcrichton/ctest) - - `cd libc-test && cargo run` - - Use the `skip_*()` functions in `build.rs` if you really need a workaround. -2. Style checker - - `rustc ci/style.rs && ./style src` - -## Platforms and Documentation - -The following platforms are currently tested and have documentation available: - -Tested: - * [`i686-pc-windows-msvc`](https://doc.rust-lang.org/libc/i686-pc-windows-msvc/libc/) - * [`x86_64-pc-windows-msvc`](https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc/libc/) - (Windows) - * [`i686-pc-windows-gnu`](https://doc.rust-lang.org/libc/i686-pc-windows-gnu/libc/) - * [`x86_64-pc-windows-gnu`](https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu/libc/) - * [`i686-apple-darwin`](https://doc.rust-lang.org/libc/i686-apple-darwin/libc/) - * [`x86_64-apple-darwin`](https://doc.rust-lang.org/libc/x86_64-apple-darwin/libc/) - (OSX) - * `i686-apple-ios` - * `x86_64-apple-ios` - * [`i686-unknown-linux-gnu`](https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc/) - * [`x86_64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc/) - (Linux) - * [`x86_64-unknown-linux-musl`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc/) - (Linux MUSL) - * [`aarch64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu/libc/) - * [`mips-unknown-linux-gnu`](https://doc.rust-lang.org/libc/mips-unknown-linux-gnu/libc/) - * [`arm-unknown-linux-gnueabihf`](https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf/libc/) - * [`arm-linux-androideabi`](https://doc.rust-lang.org/libc/arm-linux-androideabi/libc/) - (Android) - * [`x86_64-unknown-freebsd`](https://doc.rust-lang.org/libc/x86_64-unknown-freebsd/libc/) - * [`x86_64-unknown-openbsd`](https://doc.rust-lang.org/libc/x86_64-unknown-openbsd/libc/) - * [`x86_64-rumprun-netbsd`](https://doc.rust-lang.org/libc/x86_64-unknown-netbsd/libc/) - -The following may be supported, but are not guaranteed to always work: - - * `i686-unknown-freebsd` - * [`x86_64-unknown-bitrig`](https://doc.rust-lang.org/libc/x86_64-unknown-bitrig/libc/) - * [`x86_64-unknown-dragonfly`](https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly/libc/) - * `i686-unknown-haiku` - * `x86_64-unknown-haiku` - * [`x86_64-unknown-netbsd`](https://doc.rust-lang.org/libc/x86_64-unknown-netbsd/libc/) diff --git a/src/vendor/libc/appveyor.yml b/src/vendor/libc/appveyor.yml deleted file mode 100644 index a851bb87b6c..00000000000 --- a/src/vendor/libc/appveyor.yml +++ /dev/null @@ -1,25 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-gnu - MSYS2_BITS: 64 - - TARGET: i686-pc-windows-gnu - MSYS2_BITS: 32 - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc -install: - - 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 - - if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin - - rustc -V - - cargo -V - -build: false - -test_script: - - cargo test --target %TARGET% - - cargo run --manifest-path libc-test/Cargo.toml --target %TARGET% - -cache: - - target - - C:\Users\appveyor\.cargo\registry diff --git a/src/vendor/libc/ci/README.md b/src/vendor/libc/ci/README.md deleted file mode 100644 index 13c7c8da52f..00000000000 --- a/src/vendor/libc/ci/README.md +++ /dev/null @@ -1,203 +0,0 @@ -The goal of the libc crate is to have CI running everywhere to have the -strongest guarantees about the definitions that this library contains, and as a -result the CI is pretty complicated and also pretty large! Hopefully this can -serve as a guide through the sea of scripts in this directory and elsewhere in -this project. - -# Files - -First up, let's talk about the files in this directory: - -* `run-travis.sh` - a shell script run by all Travis builders, this is - responsible for setting up the rest of the environment such as installing new - packages, downloading Rust target libraries, etc. - -* `run.sh` - the actual script which runs tests for a particular architecture. - Called from the `run-travis.sh` script this will run all tests for the target - specified. - -* `cargo-config` - Cargo configuration of linkers to use copied into place by - the `run-travis.sh` script before builds are run. - -* `dox.sh` - script called from `run-travis.sh` on only the linux 64-bit nightly - Travis bots to build documentation for this crate. - -* `landing-page-*.html` - used by `dox.sh` to generate a landing page for all - architectures' documentation. - -* `run-qemu.sh` - see discussion about QEMU below - -* `mips`, `rumprun` - instructions to build the docker image for each respective - CI target - -# CI Systems - -Currently this repository leverages a combination of Travis CI and AppVeyor for -running tests. The triples tested are: - -* AppVeyor - * `{i686,x86_64}-pc-windows-{msvc,gnu}` -* Travis - * `{i686,x86_64,mips,aarch64}-unknown-linux-gnu` - * `x86_64-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 CD installer (most minimal is fine) -2. `qemu-img create -f qcow2 foo.qcow2 2G` -3. `qemu -cdrom foo.iso -drive if=virtio,file=foo.qcow2 -net nic,model=virtio -net user` -4. run installer -5. `echo 'console="comconsole"' >> /boot/loader.conf` -6. `echo 'autoboot_delay="0"' >> /boot/loader.conf` -7. look at /etc/ttys, see what getty argument is for ttyu0 -8. edit /etc/gettytab, look for ttyu0 argument, prepend `:al=root` to line - beneath - -(note that the current image has a `freebsd` user, but this isn't really -necessary) - -Once that's done, arrange for this script to run at login: - -``` -#!/bin/sh - -sudo kldload ext2fs -[ -e /dev/vtbd1 ] || exit 0 -sudo mount -t ext2fs /dev/vtbd1 /mnt -sh /mnt/run.sh /mnt -sudo poweroff -``` - -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/src/vendor/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/src/vendor/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile deleted file mode 100644 index 2ba69e15442..00000000000 --- a/src/vendor/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM ubuntu:16.10 -RUN apt-get update -RUN 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 \ - PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/arm-linux-androideabi/Dockerfile b/src/vendor/libc/ci/docker/arm-linux-androideabi/Dockerfile deleted file mode 100644 index 0e41ba6dbee..00000000000 --- a/src/vendor/libc/ci/docker/arm-linux-androideabi/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM alexcrichton/rust-slave-android:2015-11-22 -ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ - PATH=$PATH:/rust/bin -ENTRYPOINT ["sh"] diff --git a/src/vendor/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/src/vendor/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile deleted file mode 100644 index 3824c046640..00000000000 --- a/src/vendor/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM ubuntu:16.10 -RUN apt-get update -RUN 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 \ - PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile b/src/vendor/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile deleted file mode 100644 index c149d840729..00000000000 --- a/src/vendor/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM ubuntu:16.10 -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/src/vendor/libc/ci/docker/i686-unknown-linux-musl/Dockerfile b/src/vendor/libc/ci/docker/i686-unknown-linux-musl/Dockerfile deleted file mode 100644 index 87459a1672b..00000000000 --- a/src/vendor/libc/ci/docker/i686-unknown-linux-musl/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates -# Below we're cross-compiling musl for i686 using the system compiler on an -# x86_64 system. This is an awkward thing to be doing and so we have to jump -# through a couple hoops to get musl to be happy. In particular: -# -# * We specifically pass -m32 in CFLAGS and override CC when running ./configure, -# since otherwise the script will fail to find a compiler. -# * We manually unset CROSS_COMPILE when running make; otherwise the makefile -# will call the non-existent binary 'i686-ar'. -RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ - tar xzf - && \ - cd musl-1.1.15 && \ - CC=gcc CFLAGS=-m32 ./configure --prefix=/musl-i686 --disable-shared --target=i686 && \ - make CROSS_COMPILE= install -j4 && \ - cd .. && \ - rm -rf musl-1.1.15 -ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ - CC_i686_unknown_linux_musl=musl-gcc diff --git a/src/vendor/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile b/src/vendor/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile deleted file mode 100644 index eea1f652c3c..00000000000 --- a/src/vendor/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN 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 - -ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ - PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/mips-unknown-linux-musl/Dockerfile b/src/vendor/libc/ci/docker/mips-unknown-linux-musl/Dockerfile deleted file mode 100644 index 77c6adb435f..00000000000 --- a/src/vendor/libc/ci/docker/mips-unknown-linux-musl/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ - bzip2 - -RUN mkdir /toolchain -RUN curl -L https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ - tar xjf - -C /toolchain --strip-components=1 - -ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ - CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ - CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc diff --git a/src/vendor/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/src/vendor/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile deleted file mode 100644 index 2eb5de24538..00000000000 --- a/src/vendor/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN 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 - -ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ - CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ - PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/src/vendor/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile deleted file mode 100644 index 36c4d90ef68..00000000000 --- a/src/vendor/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ - bzip2 - -RUN mkdir /toolchain -RUN curl -L https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ - tar xjf - -C /toolchain --strip-components=2 - -ENV PATH=$PATH:/rust/bin:/toolchain/bin \ - CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ - CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc diff --git a/src/vendor/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/src/vendor/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile deleted file mode 100644 index d9d7db0f41d..00000000000 --- a/src/vendor/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN 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 \ - PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/src/vendor/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile deleted file mode 100644 index df0e6057b4f..00000000000 --- a/src/vendor/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN 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 \ - CC=powerpc64-linux-gnu-gcc \ - PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile b/src/vendor/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile deleted file mode 100644 index 129771e76b7..00000000000 --- a/src/vendor/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile +++ /dev/null @@ -1,6 +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 diff --git a/src/vendor/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile b/src/vendor/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile deleted file mode 100644 index b1273382223..00000000000 --- a/src/vendor/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM alexcrichton/rust-slave-linux-cross:2016-04-15 -USER root - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - qemu genext2fs - -ENTRYPOINT ["sh"] - -ENV PATH=$PATH:/rust/bin \ - QEMU=freebsd.qcow2.gz \ - CAN_CROSS=1 \ - CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc diff --git a/src/vendor/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/src/vendor/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile deleted file mode 100644 index 4af3f834cbe..00000000000 --- a/src/vendor/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM ubuntu:16.10 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates -ENV PATH=$PATH:/rust/bin diff --git a/src/vendor/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/src/vendor/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile deleted file mode 100644 index 9c2499948a2..00000000000 --- a/src/vendor/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates -RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ - tar xzf - && \ - cd musl-1.1.15 && \ - ./configure --prefix=/musl-x86_64 && \ - make install -j4 && \ - cd .. && \ - rm -rf musl-1.1.15 -ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin diff --git a/src/vendor/libc/ci/docker/x86_64-unknown-openbsd/Dockerfile b/src/vendor/libc/ci/docker/x86_64-unknown-openbsd/Dockerfile deleted file mode 100644 index 26340a5ed1e..00000000000 --- a/src/vendor/libc/ci/docker/x86_64-unknown-openbsd/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM ubuntu:16.10 - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu curl ca-certificates \ - genext2fs -ENV PATH=$PATH:/rust/bin \ - QEMU=2016-09-07/openbsd-6.0-without-pkgs.qcow2 diff --git a/src/vendor/libc/ci/dox.sh b/src/vendor/libc/ci/dox.sh deleted file mode 100644 index 88d882dcacd..00000000000 --- a/src/vendor/libc/ci/dox.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -# Builds documentation for all target triples that we have a registered URL for -# in liblibc. This scrapes the list of triples to document from `src/lib.rs` -# which has a bunch of `html_root_url` directives we pick up. - -set -e - -TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'` - -rm -rf target/doc -mkdir -p target/doc - -cp ci/landing-page-head.html target/doc/index.html - -for target in $TARGETS; do - echo documenting $target - - rustdoc -o target/doc/$target --target $target src/lib.rs --cfg dox \ - --crate-name libc - - echo "<li><a href="/libc/$target/libc/index.html">$target</a></li>" \ - >> target/doc/index.html -done - -cat ci/landing-page-footer.html >> target/doc/index.html - -# If we're on travis, not a PR, and on the right branch, publish! -if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then - pip install ghp-import --user $USER - $HOME/.local/bin/ghp-import -n target/doc - git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages -fi diff --git a/src/vendor/libc/ci/landing-page-footer.html b/src/vendor/libc/ci/landing-page-footer.html deleted file mode 100644 index 941cc8d2b40..00000000000 --- a/src/vendor/libc/ci/landing-page-footer.html +++ /dev/null @@ -1,3 +0,0 @@ - </ul> - </body> -</html> diff --git a/src/vendor/libc/ci/landing-page-head.html b/src/vendor/libc/ci/landing-page-head.html deleted file mode 100644 index fc69fa88eb5..00000000000 --- a/src/vendor/libc/ci/landing-page-head.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="utf-8"> - </head> - <body> - <ul> diff --git a/src/vendor/libc/ci/run-docker.sh b/src/vendor/libc/ci/run-docker.sh deleted file mode 100644 index e34e65ffcdc..00000000000 --- a/src/vendor/libc/ci/run-docker.sh +++ /dev/null @@ -1,26 +0,0 @@ -# Small script to run tests for a target (or all targets) inside all the -# respective docker images. - -set -ex - -run() { - echo $1 - docker build -t libc ci/docker/$1 - docker run \ - --rm \ - -v `rustc --print sysroot`:/rust:ro \ - -v `pwd`:/checkout:ro \ - -e CARGO_TARGET_DIR=/tmp/target \ - -w /checkout \ - --privileged \ - -it libc \ - ci/run.sh $1 -} - -if [ -z "$1" ]; then - for d in `ls ci/docker/`; do - run $d - done -else - run $1 -fi diff --git a/src/vendor/libc/ci/run-qemu.sh b/src/vendor/libc/ci/run-qemu.sh deleted file mode 100644 index b2f457df916..00000000000 --- a/src/vendor/libc/ci/run-qemu.sh +++ /dev/null @@ -1,32 +0,0 @@ -# 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/src/vendor/libc/ci/run.sh b/src/vendor/libc/ci/run.sh deleted file mode 100755 index 15721ab965d..00000000000 --- a/src/vendor/libc/ci/run.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/sh - -# Builds and runs tests for a particular target passed as an argument to this -# script. - -set -ex - -TARGET=$1 - -# If we're going to run tests inside of a qemu image, then we don't need any of -# the scripts below. Instead, download the image, prepare a filesystem which has -# the current state of this repository, and then run the image. -# -# It's assume that all images, when run with two disks, will run the `run.sh` -# script from the second which we place inside. -if [ "$QEMU" != "" ]; then - tmpdir=/tmp/qemu-img-creation - mkdir -p $tmpdir - - if [ -z "${QEMU#*.gz}" ]; then - # image is .gz : download and uncompress it - qemufile=$(echo ${QEMU%.gz} | sed 's/\//__/g') - if [ ! -f $tmpdir/$qemufile ]; then - curl https://people.mozilla.org/~acrichton/libc-test/qemu/$QEMU | \ - gunzip -d > $tmpdir/$qemufile - fi - else - # plain qcow2 image: just download it - qemufile=$(echo ${QEMU} | sed 's/\//__/g') - if [ ! -f $tmpdir/$qemufile ]; then - curl https://people.mozilla.org/~acrichton/libc-test/qemu/$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 - - # If we have a cross compiler, then we just do the standard rigamarole of - # cross-compiling an executable and then the script to run just executes the - # binary. - # - # If we don't have a cross-compiler, however, then we need to do some crazy - # acrobatics to get this to work. Generate all.{c,rs} on the host which will - # be compiled inside QEMU. Do this here because compiling syntex_syntax in - # QEMU would time out basically everywhere. - if [ "$CAN_CROSS" = "1" ]; then - cargo build --manifest-path libc-test/Cargo.toml --target $TARGET - cp $CARGO_TARGET_DIR/$TARGET/debug/libc-test $tmpdir/mount/ - echo 'exec $1/libc-test' > $tmpdir/mount/run.sh - else - rm -rf $tmpdir/generated - mkdir -p $tmpdir/generated - cargo build --manifest-path libc-test/generate-files/Cargo.toml - (cd libc-test && TARGET=$TARGET OUT_DIR=$tmpdir/generated SKIP_COMPILE=1 \ - $CARGO_TARGET_DIR/debug/generate-files) - - # Copy this folder into the mounted image, the `run.sh` entry point, and - # overwrite the standard libc-test Cargo.toml with the overlay one which will - # assume the all.{c,rs} test files have already been generated - mkdir $tmpdir/mount/libc - cp -r Cargo.* libc-test src ci $tmpdir/mount/libc/ - ln -s libc-test/target $tmpdir/mount/libc/target - cp ci/run-qemu.sh $tmpdir/mount/run.sh - echo $TARGET | tee -a $tmpdir/mount/TARGET - cp $tmpdir/generated/* $tmpdir/mount/libc/libc-test - cp libc-test/run-generated-Cargo.toml $tmpdir/mount/libc/libc-test/Cargo.toml - fi - - 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 grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log -fi - -case "$TARGET" in - *-apple-ios) - cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET -- \ - -C link-args=-mios-simulator-version-min=7.0 - ;; - - *) - cargo build --manifest-path libc-test/Cargo.toml --target $TARGET - ;; -esac - -case "$TARGET" in - arm-linux-androideabi) - emulator @arm-21 -no-window & - adb wait-for-device - adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/libc-test - adb shell /data/libc-test 2>&1 | tee /tmp/out - grep "^PASSED .* tests" /tmp/out - ;; - - arm-unknown-linux-gnueabihf) - qemu-arm -L /usr/arm-linux-gnueabihf $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - mips-unknown-linux-gnu) - qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - mips64-unknown-linux-gnuabi64) - qemu-mips64 -L /usr/mips64-linux-gnuabi64 $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - mips-unknown-linux-musl) - qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15 \ - $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - mipsel-unknown-linux-musl) - qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - powerpc-unknown-linux-gnu) - qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - powerpc64-unknown-linux-gnu) - qemu-ppc64 -L /usr/powerpc64-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - aarch64-unknown-linux-gnu) - qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; - - *-rumprun-netbsd) - rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/libc-test - qemu-system-x86_64 -nographic -vga none -m 64 \ - -kernel /tmp/libc-test.img 2>&1 | tee /tmp/out & - sleep 5 - grep "^PASSED .* tests" /tmp/out - ;; - - *) - $CARGO_TARGET_DIR/$TARGET/debug/libc-test - ;; -esac diff --git a/src/vendor/libc/ci/style.rs b/src/vendor/libc/ci/style.rs deleted file mode 100644 index 32e4ba772c5..00000000000 --- a/src/vendor/libc/ci/style.rs +++ /dev/null @@ -1,204 +0,0 @@ -//! Simple script to verify the coding style of this library -//! -//! ## How to run -//! -//! The first argument to this script is the directory to run on, so running -//! this script should be as simple as: -//! -//! ```notrust -//! rustc ci/style.rs -//! ./style src -//! ``` -//! -//! ## Guidelines -//! -//! The current style is: -//! -//! * No trailing whitespace -//! * No tabs -//! * 80-character lines -//! * `extern` instead of `extern "C"` -//! * Specific module layout: -//! 1. use directives -//! 2. typedefs -//! 3. structs -//! 4. constants -//! 5. f! { ... } functions -//! 6. extern functions -//! 7. modules + pub use -//! -//! Things not verified: -//! -//! * alignment -//! * 4-space tabs -//! * leading colons on paths - -use std::env; -use std::fs; -use std::io::prelude::*; -use std::path::Path; - -macro_rules! t { - ($e:expr) => (match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with {}", stringify!($e), e), - }) -} - -fn main() { - let arg = env::args().skip(1).next().unwrap_or(".".to_string()); - - let mut errors = Errors { errs: false }; - walk(Path::new(&arg), &mut errors); - - if errors.errs { - panic!("found some lint errors"); - } else { - println!("good style!"); - } -} - -fn walk(path: &Path, err: &mut Errors) { - for entry in t!(path.read_dir()).map(|e| t!(e)) { - let path = entry.path(); - if t!(entry.file_type()).is_dir() { - walk(&path, err); - continue - } - - let name = entry.file_name().into_string().unwrap(); - match &name[..] { - n if !n.ends_with(".rs") => continue, - - "dox.rs" | - "lib.rs" | - "macros.rs" => continue, - - _ => {} - } - - let mut contents = String::new(); - t!(t!(fs::File::open(&path)).read_to_string(&mut contents)); - - check_style(&contents, &path, err); - } -} - -struct Errors { - errs: bool, -} - -#[derive(Clone, Copy, PartialEq)] -enum State { - Start, - Imports, - Typedefs, - Structs, - Constants, - FunctionDefinitions, - Functions, - Modules, -} - -fn check_style(file: &str, path: &Path, err: &mut Errors) { - let mut state = State::Start; - let mut s_macros = 0; - let mut f_macros = 0; - let mut prev_blank = false; - - for (i, line) in file.lines().enumerate() { - if line == "" { - if prev_blank { - err.error(path, i, "double blank line"); - } - prev_blank = true; - } else { - prev_blank = false; - } - if line != line.trim_right() { - err.error(path, i, "trailing whitespace"); - } - if line.contains("\t") { - err.error(path, i, "tab character"); - } - if line.len() > 80 { - err.error(path, i, "line longer than 80 chars"); - } - if line.contains("extern \"C\"") { - err.error(path, i, "use `extern` instead of `extern \"C\""); - } - if line.contains("#[cfg(") && !line.contains(" if ") { - if state != State::Structs { - err.error(path, i, "use cfg_if! and submodules \ - instead of #[cfg]"); - } - } - - let line = line.trim_left(); - let is_pub = line.starts_with("pub "); - let line = if is_pub {&line[4..]} else {line}; - - let line_state = if line.starts_with("use ") { - if 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/src/vendor/libc/src/dox.rs b/src/vendor/libc/src/dox.rs deleted file mode 100644 index c7d3dc9c2de..00000000000 --- a/src/vendor/libc/src/dox.rs +++ /dev/null @@ -1,134 +0,0 @@ -pub use self::imp::*; - -#[cfg(not(dox))] -mod imp { - pub use core::option::Option; - pub use core::clone::Clone; - pub use core::marker::Copy; - pub use core::mem; -} - -#[cfg(dox)] -mod imp { - pub enum Option<T> { - Some(T), - None, - } - impl<T: Copy> Copy for Option<T> {} - impl<T: Clone> Clone for Option<T> { - fn clone(&self) -> Option<T> { loop {} } - } - - pub trait Clone { - fn clone(&self) -> Self; - } - - #[lang = "copy"] - pub trait Copy {} - - #[lang = "sync"] - pub trait Sync {} - impl<T> Sync for T {} - - #[lang = "sized"] - pub trait Sized {} - - macro_rules! each_int { - ($mac:ident) => ( - $mac!(u8); - $mac!(u16); - $mac!(u32); - $mac!(u64); - $mac!(usize); - $mac!(i8); - $mac!(i16); - $mac!(i32); - $mac!(i64); - $mac!(isize); - ) - } - - #[lang = "div"] - pub trait Div<RHS> { - type Output; - fn div(self, rhs: RHS) -> Self::Output; - } - - macro_rules! impl_div { - ($($i:ident)*) => ($( - impl Div<$i> for $i { - type Output = $i; - fn div(self, rhs: $i) -> $i { self / rhs } - } - )*) - } - each_int!(impl_div); - - #[lang = "shl"] - pub trait Shl<RHS> { - type Output; - fn shl(self, rhs: RHS) -> Self::Output; - } - - macro_rules! impl_shl { - ($($i:ident)*) => ($( - impl Shl<$i> for $i { - type Output = $i; - fn shl(self, rhs: $i) -> $i { self << rhs } - } - )*) - } - each_int!(impl_shl); - - #[lang = "mul"] - pub trait Mul<RHS=Self> { - type Output; - fn mul(self, rhs: RHS) -> Self::Output; - } - - macro_rules! impl_mul { - ($($i:ident)*) => ($( - impl Mul for $i { - type Output = $i; - fn mul(self, rhs: $i) -> $i { self * rhs } - } - )*) - } - each_int!(impl_mul); - - #[lang = "sub"] - pub trait Sub<RHS=Self> { - type Output; - fn sub(self, rhs: RHS) -> Self::Output; - } - - macro_rules! impl_sub { - ($($i:ident)*) => ($( - impl Sub for $i { - type Output = $i; - fn sub(self, rhs: $i) -> $i { self - rhs } - } - )*) - } - each_int!(impl_sub); - - #[lang = "bitor"] - pub trait Bitor<RHS=Self> { - type Output; - fn bitor(self, rhs: RHS) -> Self::Output; - } - - macro_rules! impl_bitor { - ($($i:ident)*) => ($( - impl Bitor for $i { - type Output = $i; - fn bitor(self, rhs: $i) -> $i { self | rhs } - } - )*) - } - each_int!(impl_bitor); - - pub mod mem { - pub fn size_of_val<T>(_: &T) -> usize { 4 } - } -} diff --git a/src/vendor/libc/src/lib.rs b/src/vendor/libc/src/lib.rs deleted file mode 100644 index dcc4791f9af..00000000000 --- a/src/vendor/libc/src/lib.rs +++ /dev/null @@ -1,274 +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. - -//! Crate docs - -#![allow(bad_style, overflowing_literals, improper_ctypes)] -#![crate_type = "rlib"] -#![crate_name = "libc"] -#![cfg_attr(dox, feature(no_core, lang_items))] -#![cfg_attr(dox, no_core)] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] - -#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc( - html_root_url = "https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( - html_root_url = "https://doc.rust-lang.org/libc/mips-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl" -))] -#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-apple-darwin" -))] -#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-apple-darwin" -))] -#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu" -))] -#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-gnu" -))] -#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc" -))] -#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-msvc" -))] -#![cfg_attr(target_os = "android", doc( - html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi" -))] -#![cfg_attr(target_os = "freebsd", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-freebsd" -))] -#![cfg_attr(target_os = "openbsd", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-openbsd" -))] -#![cfg_attr(target_os = "bitrig", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-bitrig" -))] -#![cfg_attr(target_os = "netbsd", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-netbsd" -))] -#![cfg_attr(target_os = "dragonfly", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly" -))] - -// Attributes needed when building as part of the standard library -#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute, cfg_target_vendor))] -#![cfg_attr(stdbuild, no_std)] -#![cfg_attr(stdbuild, staged_api)] -#![cfg_attr(stdbuild, allow(warnings))] -#![cfg_attr(stdbuild, unstable(feature = "libc", - reason = "use `libc` from crates.io", - issue = "27783"))] - -#![cfg_attr(not(feature = "use_std"), no_std)] - -#[cfg(all(not(stdbuild), not(dox), feature = "use_std"))] -extern crate std as core; - -#[macro_use] mod macros; -mod dox; - -// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable -// more optimization opportunities around it recognizing things like -// malloc/free. -#[repr(u8)] -pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, -} - -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - -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 enum FILE {} -pub enum fpos_t {} // TODO: fill this out with a struct - -extern { - pub fn isalnum(c: c_int) -> c_int; - pub fn isalpha(c: c_int) -> c_int; - pub fn iscntrl(c: c_int) -> c_int; - pub fn isdigit(c: c_int) -> c_int; - pub fn isgraph(c: c_int) -> c_int; - pub fn islower(c: c_int) -> c_int; - pub fn isprint(c: c_int) -> c_int; - pub fn ispunct(c: c_int) -> c_int; - pub fn isspace(c: c_int) -> c_int; - pub fn isupper(c: c_int) -> c_int; - pub fn isxdigit(c: c_int) -> c_int; - pub fn tolower(c: c_int) -> c_int; - pub fn toupper(c: c_int) -> c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fopen$UNIX2003")] - pub fn fopen(filename: *const c_char, - mode: *const c_char) -> *mut FILE; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "freopen$UNIX2003")] - pub fn freopen(filename: *const c_char, mode: *const c_char, - file: *mut FILE) -> *mut FILE; - pub fn fflush(file: *mut FILE) -> c_int; - pub fn fclose(file: *mut FILE) -> c_int; - pub fn remove(filename: *const c_char) -> c_int; - pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; - pub fn tmpfile() -> *mut FILE; - pub fn setvbuf(stream: *mut FILE, - buffer: *mut c_char, - mode: c_int, - size: size_t) -> c_int; - pub fn setbuf(stream: *mut FILE, buf: *mut c_char); - pub fn getchar() -> c_int; - pub fn putchar(c: c_int) -> c_int; - pub fn fgetc(stream: *mut FILE) -> c_int; - pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; - pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fputs$UNIX2003")] - pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; - pub fn puts(s: *const c_char) -> c_int; - pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; - pub fn fread(ptr: *mut c_void, - size: size_t, - nobj: size_t, - stream: *mut FILE) - -> size_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fwrite$UNIX2003")] - pub fn fwrite(ptr: *const c_void, - size: size_t, - nobj: size_t, - stream: *mut FILE) - -> size_t; - pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; - pub fn ftell(stream: *mut FILE) -> c_long; - pub fn rewind(stream: *mut FILE); - #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] - pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] - pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; - pub fn feof(stream: *mut FILE) -> c_int; - pub fn ferror(stream: *mut FILE) -> c_int; - pub fn perror(s: *const c_char); - pub fn atoi(s: *const c_char) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "strtod$UNIX2003")] - pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; - pub fn strtol(s: *const c_char, - endp: *mut *mut c_char, base: c_int) -> c_long; - pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, - base: c_int) -> c_ulong; - pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; - pub fn malloc(size: size_t) -> *mut c_void; - pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; - pub fn free(p: *mut c_void); - pub fn abort() -> !; - pub fn exit(status: c_int) -> !; - pub fn _exit(status: c_int) -> !; - pub fn atexit(cb: extern fn()) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "system$UNIX2003")] - pub fn system(s: *const c_char) -> c_int; - pub fn getenv(s: *const c_char) -> *mut c_char; - - pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; - pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) - -> *mut c_char; - pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; - pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; - pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; - pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; - pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; - pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; - pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; - pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; - pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; - pub fn strdup(cs: *const c_char) -> *mut c_char; - pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; - pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; - pub fn strlen(cs: *const c_char) -> size_t; - pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "strerror$UNIX2003")] - pub fn strerror(n: c_int) -> *mut c_char; - pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; - pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; - pub fn wcslen(buf: *const wchar_t) -> size_t; - - pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; - pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; - pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; -} - -// These are all inline functions on android, so they end up just being entirely -// missing on that platform. -#[cfg(not(target_os = "android"))] -extern { - pub fn abs(i: c_int) -> c_int; - pub fn atof(s: *const c_char) -> c_double; - pub fn labs(i: c_long) -> c_long; - pub fn rand() -> c_int; - pub fn srand(seed: c_uint); -} - -cfg_if! { - if #[cfg(windows)] { - mod windows; - pub use windows::*; - } else if #[cfg(unix)] { - mod unix; - pub use unix::*; - } else { - // Unknown target_family - } -} diff --git a/src/vendor/libc/src/macros.rs b/src/vendor/libc/src/macros.rs deleted file mode 100644 index 5811c84c3aa..00000000000 --- a/src/vendor/libc/src/macros.rs +++ /dev/null @@ -1,108 +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. -macro_rules! cfg_if { - ($( - if #[cfg($($meta:meta),*)] { $($it:item)* } - ) else * else { - $($it2:item)* - }) => { - __cfg_if_items! { - () ; - $( ( ($($meta),*) ($($it)*) ), )* - ( () ($($it2)*) ), - } - } -} - -macro_rules! __cfg_if_items { - (($($not:meta,)*) ; ) => {}; - (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { - __cfg_if_apply! { cfg(all(not(any($($not),*)), $($m,)*)), $($it)* } - __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* } - } -} - -macro_rules! __cfg_if_apply { - ($m:meta, $($it:item)*) => { - $(#[$m] $it)* - } -} - -macro_rules! s { - ($($(#[$attr:meta])* pub struct $i:ident { $($field:tt)* })*) => ($( - __item! { - #[repr(C)] - $(#[$attr])* - pub struct $i { $($field)* } - } - impl ::dox::Copy for $i {} - impl ::dox::Clone for $i { - fn clone(&self) -> $i { *self } - } - )*) -} - -macro_rules! f { - ($(pub fn $i:ident($($arg:ident: $argty:ty),*) -> $ret:ty { - $($body:stmt);* - })*) => ($( - #[inline] - #[cfg(not(dox))] - pub unsafe extern fn $i($($arg: $argty),*) -> $ret { - $($body);* - } - - #[cfg(dox)] - #[allow(dead_code)] - pub unsafe extern fn $i($($arg: $argty),*) -> $ret { - loop {} - } - )*) -} - -macro_rules! __item { - ($i:item) => ($i) -} - -#[cfg(test)] -mod tests { - cfg_if! { - if #[cfg(test)] { - use std::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 } - } - } - - #[test] - fn it_works() { - assert!(works1().is_some()); - assert!(works2()); - assert!(works3()); - } -} diff --git a/src/vendor/libc/src/unix/bsd/apple/b32.rs b/src/vendor/libc/src/unix/bsd/apple/b32.rs deleted file mode 100644 index 8ca02544973..00000000000 --- a/src/vendor/libc/src/unix/bsd/apple/b32.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! 32-bit specific Apple (ios/darwin) definitions - -pub type c_long = i32; -pub type c_ulong = u32; - -s! { - pub struct pthread_attr_t { - __sig: c_long, - __opaque: [::c_char; 36] - } -} - -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 TIOCTIMESTAMP: ::c_ulong = 0x40087459; -pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40087458; diff --git a/src/vendor/libc/src/unix/bsd/apple/b64.rs b/src/vendor/libc/src/unix/bsd/apple/b64.rs deleted file mode 100644 index 327a4b63116..00000000000 --- a/src/vendor/libc/src/unix/bsd/apple/b64.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! 64-bit specific Apple (ios/darwin) definitions - -pub type c_long = i64; -pub type c_ulong = u64; - -s! { - pub struct pthread_attr_t { - __sig: c_long, - __opaque: [::c_char; 56] - } -} - -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 TIOCTIMESTAMP: ::c_ulong = 0x40107459; -pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458; diff --git a/src/vendor/libc/src/unix/bsd/apple/mod.rs b/src/vendor/libc/src/unix/bsd/apple/mod.rs deleted file mode 100644 index aa4d1ac7457..00000000000 --- a/src/vendor/libc/src/unix/bsd/apple/mod.rs +++ /dev/null @@ -1,1500 +0,0 @@ -//! Apple (ios/darwin)-specific definitions -//! -//! This covers *-apple-* triples currently - -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 mach_timebase_info_data_t = mach_timebase_info; -pub type pthread_key_t = c_ulong; -pub type sigset_t = u32; -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 enum timezone {} - -s! { - 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: [::uint32_t; 16], - } - - 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 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 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 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: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_qspare: [::int64_t; 2], - } - - 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_mutex_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_MUTEX_SIZE__], - } - - pub struct pthread_mutexattr_t { - __sig: ::c_long, - __opaque: [u8; 8], - } - - pub struct pthread_cond_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_COND_SIZE__], - } - - pub struct pthread_condattr_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_CONDATTR_SIZE__], - } - - pub struct pthread_rwlock_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub si_pid: ::pid_t, - pub si_uid: ::uid_t, - pub si_status: ::c_int, - pub si_addr: *mut ::c_void, - _pad: [usize; 9], - } - - pub struct sigaction { - 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 statfs { - pub f_bsize: ::uint32_t, - pub f_iosize: ::int32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_fsid: ::fsid_t, - pub f_owner: ::uid_t, - pub f_type: ::uint32_t, - pub f_flags: ::uint32_t, - pub f_fssubtype: ::uint32_t, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 1024], - pub f_mntfromname: [::c_char; 1024], - pub f_reserved: [::uint32_t; 8], - } - - // FIXME: this should have align 4 but it's got align 8 on 64-bit - pub struct kevent { - pub ident: ::uintptr_t, - pub filter: ::int16_t, - pub flags: ::uint16_t, - pub fflags: ::uint32_t, - pub data: ::intptr_t, - pub udata: *mut ::c_void, - } - - pub struct kevent64_s { - pub ident: ::uint64_t, - pub filter: ::int16_t, - pub flags: ::uint16_t, - pub fflags: ::uint32_t, - pub data: ::int64_t, - pub udata: ::uint64_t, - pub ext: [::uint64_t; 2], - } - - pub struct dqblk { - pub dqb_bhardlimit: ::uint64_t, - pub dqb_bsoftlimit: ::uint64_t, - pub dqb_curbytes: ::uint64_t, - pub dqb_ihardlimit: ::uint32_t, - pub dqb_isoftlimit: ::uint32_t, - pub dqb_curinodes: ::uint32_t, - pub dqb_btime: ::uint32_t, - pub dqb_itime: ::uint32_t, - pub dqb_id: ::uint32_t, - pub dqb_spare: [::uint32_t; 4], - } - - 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 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 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_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_EXCL: ::c_int = 2048; -pub const O_NOCTTY: ::c_int = 131072; -pub const O_TRUNC: ::c_int = 1024; -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 MAP_FILE: ::c_int = 0x0000; -pub const MAP_SHARED: ::c_int = 0x0001; -pub const MAP_PRIVATE: ::c_int = 0x0002; -pub const MAP_FIXED: ::c_int = 0x0010; -pub const MAP_ANON: ::c_int = 0x1000; - -pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const MS_ASYNC: ::c_int = 0x0001; -pub const 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_SYSTEM: ::c_int = 11; - -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 O_ACCMODE: ::c_int = 3; - -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 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 PTHREAD_CREATE_JOINABLE: ::c_int = 1; -pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; -pub const PTHREAD_STACK_MIN: ::size_t = 8192; - -pub const RLIMIT_CPU: ::c_int = 0; -pub const RLIMIT_FSIZE: ::c_int = 1; -pub const RLIMIT_DATA: ::c_int = 2; -pub const RLIMIT_STACK: ::c_int = 3; -pub const RLIMIT_CORE: ::c_int = 4; -pub const RLIMIT_AS: ::c_int = 5; -pub const RLIMIT_RSS: ::c_int = RLIMIT_AS; -pub const RLIMIT_MEMLOCK: ::c_int = 6; -pub const RLIMIT_NPROC: ::c_int = 7; -pub const RLIMIT_NOFILE: ::c_int = 8; -pub const RLIM_NLIMITS: ::c_int = 9; -pub const _RLIMIT_POSIX_FLAG: ::c_int = 0x1000; - -pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - -pub const RUSAGE_SELF: ::c_int = 0; -pub const RUSAGE_CHILDREN: ::c_int = -1; - -pub const MADV_NORMAL: ::c_int = 0; -pub const MADV_RANDOM: ::c_int = 1; -pub const MADV_SEQUENTIAL: ::c_int = 2; -pub const MADV_WILLNEED: ::c_int = 3; -pub const MADV_DONTNEED: ::c_int = 4; -pub const MADV_FREE: ::c_int = 5; -pub const MADV_ZERO_WIRED_PAGES: ::c_int = 6; -pub const MADV_FREE_REUSABLE: ::c_int = 7; -pub const MADV_FREE_REUSE: ::c_int = 8; -pub const MADV_CAN_REUSE: ::c_int = 9; - -pub const MINCORE_INCORE: ::c_int = 0x1; -pub const MINCORE_REFERENCED: ::c_int = 0x2; -pub const MINCORE_MODIFIED: ::c_int = 0x4; -pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; -pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; - -pub const AF_UNIX: ::c_int = 1; -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 30; -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 IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -pub const IP_MULTICAST_TTL: ::c_int = 10; -pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_TTL: ::c_int = 4; -pub const IP_HDRINCL: ::c_int = 2; -pub const IP_ADD_MEMBERSHIP: ::c_int = 12; -pub const IP_DROP_MEMBERSHIP: ::c_int = 13; -pub const IPV6_JOIN_GROUP: ::c_int = 12; -pub const IPV6_LEAVE_GROUP: ::c_int = 13; - -pub const TCP_NODELAY: ::c_int = 0x01; -pub const TCP_KEEPALIVE: ::c_int = 0x10; -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_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 IFF_LOOPBACK: ::c_int = 0x8; - -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 O_DSYNC: ::c_int = 4194304; -pub const O_SYNC: ::c_int = 128; -pub const O_NONBLOCK: ::c_int = 4; - -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 IPPROTO_RAW: ::c_int = 255; - -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_DONTTRUNC: ::c_int = 0x2000; -pub const SO_WANTMORE: ::c_int = 0x4000; -pub const SO_WANTOOBFLAG: ::c_int = 0x8000; - -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: ::int16_t = -1; -pub const EVFILT_WRITE: ::int16_t = -2; -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_MACHPORT: ::int16_t = -8; -pub const EVFILT_FS: ::int16_t = -9; -pub const EVFILT_USER: ::int16_t = -10; -pub const EVFILT_VM: ::int16_t = -12; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_FLAG0: ::uint16_t = 0x1000; -pub const EV_POLL: ::uint16_t = 0x1000; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_OOBAND: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; -pub const NOTE_FFNOP: ::uint32_t = 0x00000000; -pub const NOTE_FFAND: ::uint32_t = 0x40000000; -pub const NOTE_FFOR: ::uint32_t = 0x80000000; -pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; -pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; -pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_NONE: ::uint32_t = 0x00000080; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_REAP: ::uint32_t = 0x10000000; -pub const NOTE_SIGNAL: ::uint32_t = 0x08000000; -pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000; -pub const NOTE_EXIT_DETAIL: ::uint32_t = 0x02000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000; -pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000; -pub const NOTE_EXIT_DETAIL_MASK: ::uint32_t = 0x00070000; -pub const NOTE_EXIT_DECRYPTFAIL: ::uint32_t = 0x00010000; -pub const NOTE_EXIT_MEMORY: ::uint32_t = 0x00020000; -pub const NOTE_EXIT_CSERROR: ::uint32_t = 0x00040000; -pub const NOTE_VM_PRESSURE: ::uint32_t = 0x80000000; -pub const NOTE_VM_PRESSURE_TERMINATE: ::uint32_t = 0x40000000; -pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: ::uint32_t = 0x20000000; -pub const NOTE_VM_ERROR: ::uint32_t = 0x10000000; -pub const NOTE_SECONDS: ::uint32_t = 0x00000001; -pub const NOTE_USECONDS: ::uint32_t = 0x00000002; -pub const NOTE_NSECONDS: ::uint32_t = 0x00000004; -pub const NOTE_ABSOLUTE: ::uint32_t = 0x00000008; -pub const NOTE_LEEWAY: ::uint32_t = 0x00000010; -pub const NOTE_CRITICAL: ::uint32_t = 0x00000020; -pub const NOTE_BACKGROUND: ::uint32_t = 0x00000040; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; - -pub const NL0: ::c_int = 0x00000000; -pub const NL1: ::c_int = 0x00000100; -pub const TAB0: ::c_int = 0x00000000; -pub const TAB1: ::c_int = 0x00000400; -pub const TAB2: ::c_int = 0x00000800; -pub const CR0: ::c_int = 0x00000000; -pub const CR1: ::c_int = 0x00001000; -pub const CR2: ::c_int = 0x00002000; -pub const CR3: ::c_int = 0x00003000; -pub const FF0: ::c_int = 0x00000000; -pub const FF1: ::c_int = 0x00004000; -pub const BS0: ::c_int = 0x00000000; -pub const BS1: ::c_int = 0x00008000; -pub const TAB3: ::c_int = 0x00000004; -pub const VT0: ::c_int = 0x00000000; -pub const VT1: ::c_int = 0x00010000; -pub const IUTF8: ::tcflag_t = 0x00004000; -pub const CRTSCTS: ::tcflag_t = 0x00030000; - -pub const NI_MAXHOST: ::socklen_t = 1025; - -pub const Q_GETQUOTA: ::c_int = 0x300; -pub const Q_SETQUOTA: ::c_int = 0x400; - -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; -pub const KERN_KDENABLE_BG_TRACE: ::c_int = 19; -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 POLLRDNORM: ::c_short = 0x040; -pub const POLLWRNORM: ::c_short = 0x004; -pub const POLLRDBAND: ::c_short = 0x080; -pub const POLLWRBAND: ::c_short = 0x100; - -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; - -f! { - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - status >> 8 - } - - pub fn _WSTATUS(status: ::c_int) -> ::c_int { - status & 0x7f - } - - pub fn WIFCONTINUED(status: ::c_int) -> bool { - _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13 - } - - pub fn WIFSIGNALED(status: ::c_int) -> bool { - _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0 - } - - pub fn WIFSTOPPED(status: ::c_int) -> bool { - _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 - } -} - -extern { - pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::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 shm_open(name: *const ::c_char, oflag: ::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; - pub fn mach_absolute_time() -> u64; - pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; - pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; - pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; - pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t; - pub fn __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(requeset: ::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 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 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 openat(dirfd: ::c_int, pathname: *const ::c_char, - flags: ::c_int, ...) -> ::c_int; - pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::c_int, 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 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")] - 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; -} - -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/src/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs deleted file mode 100644 index 179cd913b38..00000000000 --- a/src/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ /dev/null @@ -1,303 +0,0 @@ -pub type clock_t = u64; -pub type ino_t = u64; -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; - -s! { - 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 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 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: ::uint16_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: ::int64_t, - pub st_blksize: ::uint32_t, - pub st_flags: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_qspare1: ::int64_t, - pub st_qspare2: ::int64_t, - } -} - -pub const RAND_MAX: ::c_int = 0x7fff_ffff; -pub const PTHREAD_STACK_MIN: ::size_t = 1024; -pub const SIGSTKSZ: ::size_t = 40960; -pub const MADV_INVAL: ::c_int = 10; -pub const O_CLOEXEC: ::c_int = 0x00020000; -pub const F_GETLK: ::c_int = 7; -pub const F_SETLK: ::c_int = 8; -pub const F_SETLKW: ::c_int = 9; -pub const ELAST: ::c_int = 99; -pub const RLIMIT_POSIXLOCKS: ::c_int = 11; -pub const RLIM_NLIMITS: ::rlim_t = 12; - -pub const Q_GETQUOTA: ::c_int = 0x300; -pub const Q_SETQUOTA: ::c_int = 0x400; - -pub const CLOCK_REALTIME: clockid_t = 0; -pub const CLOCK_VIRTUAL: clockid_t = 1; -pub const CLOCK_PROF: clockid_t = 2; -pub const CLOCK_MONOTONIC: clockid_t = 4; -pub const CLOCK_UPTIME: clockid_t = 5; -pub const CLOCK_UPTIME_PRECISE: clockid_t = 7; -pub const CLOCK_UPTIME_FAST: clockid_t = 8; -pub const CLOCK_REALTIME_PRECISE: clockid_t = 9; -pub const CLOCK_REALTIME_FAST: clockid_t = 10; -pub const CLOCK_MONOTONIC_PRECISE: clockid_t = 11; -pub const CLOCK_MONOTONIC_FAST: clockid_t = 12; -pub const CLOCK_SECOND: clockid_t = 13; -pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 14; -pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 15; - -pub const CTL_UNSPEC: ::c_int = 0; -pub const CTL_KERN: ::c_int = 1; -pub const CTL_VM: ::c_int = 2; -pub const CTL_VFS: ::c_int = 3; -pub const CTL_NET: ::c_int = 4; -pub const CTL_DEBUG: ::c_int = 5; -pub const CTL_HW: ::c_int = 6; -pub const CTL_MACHDEP: ::c_int = 7; -pub const CTL_USER: ::c_int = 8; -pub const CTL_P1003_1B: ::c_int = 9; -pub const CTL_LWKT: ::c_int = 10; -pub const CTL_MAXID: ::c_int = 11; -pub const KERN_OSTYPE: ::c_int = 1; -pub const KERN_OSRELEASE: ::c_int = 2; -pub const KERN_OSREV: ::c_int = 3; -pub const KERN_VERSION: ::c_int = 4; -pub const KERN_MAXVNODES: ::c_int = 5; -pub const KERN_MAXPROC: ::c_int = 6; -pub const KERN_MAXFILES: ::c_int = 7; -pub const KERN_ARGMAX: ::c_int = 8; -pub const KERN_SECURELVL: ::c_int = 9; -pub const KERN_HOSTNAME: ::c_int = 10; -pub const KERN_HOSTID: ::c_int = 11; -pub const KERN_CLOCKRATE: ::c_int = 12; -pub const KERN_VNODE: ::c_int = 13; -pub const KERN_PROC: ::c_int = 14; -pub const KERN_FILE: ::c_int = 15; -pub const KERN_PROF: ::c_int = 16; -pub const KERN_POSIX1: ::c_int = 17; -pub const KERN_NGROUPS: ::c_int = 18; -pub const KERN_JOB_CONTROL: ::c_int = 19; -pub const KERN_SAVED_IDS: ::c_int = 20; -pub const KERN_BOOTTIME: ::c_int = 21; -pub const KERN_NISDOMAINNAME: ::c_int = 22; -pub const KERN_UPDATEINTERVAL: ::c_int = 23; -pub const KERN_OSRELDATE: ::c_int = 24; -pub const KERN_NTP_PLL: ::c_int = 25; -pub const KERN_BOOTFILE: ::c_int = 26; -pub const KERN_MAXFILESPERPROC: ::c_int = 27; -pub const KERN_MAXPROCPERUID: ::c_int = 28; -pub const KERN_DUMPDEV: ::c_int = 29; -pub const KERN_IPC: ::c_int = 30; -pub const KERN_DUMMY: ::c_int = 31; -pub const KERN_PS_STRINGS: ::c_int = 32; -pub const KERN_USRSTACK: ::c_int = 33; -pub const KERN_LOGSIGEXIT: ::c_int = 34; -pub const KERN_IOV_MAX: ::c_int = 35; -pub const KERN_MAXPOSIXLOCKSPERUID: ::c_int = 36; -pub const KERN_MAXID: ::c_int = 37; -pub const KERN_PROC_ALL: ::c_int = 0; -pub const KERN_PROC_PID: ::c_int = 1; -pub const KERN_PROC_PGRP: ::c_int = 2; -pub const KERN_PROC_SESSION: ::c_int = 3; -pub const KERN_PROC_TTY: ::c_int = 4; -pub const KERN_PROC_UID: ::c_int = 5; -pub const KERN_PROC_RUID: ::c_int = 6; -pub const KERN_PROC_ARGS: ::c_int = 7; -pub const KERN_PROC_CWD: ::c_int = 8; -pub const KERN_PROC_PATHNAME: ::c_int = 9; -pub const KERN_PROC_FLAGMASK: ::c_int = 0x10; -pub const KERN_PROC_FLAG_LWP: ::c_int = 0x10; -pub const KIPC_MAXSOCKBUF: ::c_int = 1; -pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; -pub const KIPC_SOMAXCONN: ::c_int = 3; -pub const KIPC_MAX_LINKHDR: ::c_int = 4; -pub const KIPC_MAX_PROTOHDR: ::c_int = 5; -pub const KIPC_MAX_HDR: ::c_int = 6; -pub const KIPC_MAX_DATALEN: ::c_int = 7; -pub const KIPC_MBSTAT: ::c_int = 8; -pub const KIPC_NMBCLUSTERS: ::c_int = 9; -pub const HW_MACHINE: ::c_int = 1; -pub const HW_MODEL: ::c_int = 2; -pub const HW_NCPU: ::c_int = 3; -pub const HW_BYTEORDER: ::c_int = 4; -pub const HW_PHYSMEM: ::c_int = 5; -pub const HW_USERMEM: ::c_int = 6; -pub const HW_PAGESIZE: ::c_int = 7; -pub const HW_DISKNAMES: ::c_int = 8; -pub const HW_DISKSTATS: ::c_int = 9; -pub const HW_FLOATINGPT: ::c_int = 10; -pub const HW_MACHINE_ARCH: ::c_int = 11; -pub const HW_MACHINE_PLATFORM: ::c_int = 12; -pub const HW_SENSORS: ::c_int = 13; -pub const HW_MAXID: ::c_int = 14; -pub const USER_CS_PATH: ::c_int = 1; -pub const USER_BC_BASE_MAX: ::c_int = 2; -pub const USER_BC_DIM_MAX: ::c_int = 3; -pub const USER_BC_SCALE_MAX: ::c_int = 4; -pub const USER_BC_STRING_MAX: ::c_int = 5; -pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6; -pub const USER_EXPR_NEST_MAX: ::c_int = 7; -pub const USER_LINE_MAX: ::c_int = 8; -pub const USER_RE_DUP_MAX: ::c_int = 9; -pub const USER_POSIX2_VERSION: ::c_int = 10; -pub const USER_POSIX2_C_BIND: ::c_int = 11; -pub const USER_POSIX2_C_DEV: ::c_int = 12; -pub const USER_POSIX2_CHAR_TERM: ::c_int = 13; -pub const USER_POSIX2_FORT_DEV: ::c_int = 14; -pub const USER_POSIX2_FORT_RUN: ::c_int = 15; -pub const USER_POSIX2_LOCALEDEF: ::c_int = 16; -pub const USER_POSIX2_SW_DEV: ::c_int = 17; -pub const USER_POSIX2_UPE: ::c_int = 18; -pub const USER_STREAM_MAX: ::c_int = 19; -pub const USER_TZNAME_MAX: ::c_int = 20; -pub const USER_MAXID: ::c_int = 21; -pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1; -pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2; -pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3; -pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4; -pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5; -pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6; -pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7; -pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8; -pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9; -pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10; -pub const CTL_P1003_1B_FSYNC: ::c_int = 11; -pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12; -pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13; -pub const CTL_P1003_1B_TIMERS: ::c_int = 14; -pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15; -pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16; -pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17; -pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18; -pub const CTL_P1003_1B_UNUSED1: ::c_int = 19; -pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20; -pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21; -pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22; -pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23; -pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; -pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; -pub const CTL_P1003_1B_MAXID: ::c_int = 26; - -pub const EVFILT_READ: ::int16_t = -1; -pub const EVFILT_WRITE: ::int16_t = -2; -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_PROCDESC: ::int16_t = -8; -pub const EVFILT_USER: ::int16_t = -9; -pub const EVFILT_FS: ::int16_t = -10; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_NODATA: ::uint16_t = 0x1000; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; -pub const NOTE_FFNOP: ::uint32_t = 0x00000000; -pub const NOTE_FFAND: ::uint32_t = 0x40000000; -pub const NOTE_FFOR: ::uint32_t = 0x80000000; -pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; -pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; -pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_OOB: ::uint32_t = 0x00000002; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; - -pub const MSG_NOSIGNAL: ::uint32_t = 0x400; - -extern { - 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; -} diff --git a/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs deleted file mode 100644 index a89440ebdeb..00000000000 --- a/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ /dev/null @@ -1,306 +0,0 @@ -pub type fflags_t = u32; -pub type clock_t = i32; -pub type ino_t = u32; -pub type nlink_t = u16; -pub type blksize_t = u32; -pub type clockid_t = ::c_int; - -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; - -s! { - pub struct dirent { - pub d_fileno: u32, - pub d_reclen: u16, - pub d_type: u8, - pub d_namlen: u8, - pub d_name: [::c_char; 256], - } - - 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, - } -} - -pub const RAND_MAX: ::c_int = 0x7fff_fffd; -pub const PTHREAD_STACK_MIN: ::size_t = 2048; -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 O_CLOEXEC: ::c_int = 0x00100000; -pub const F_GETLK: ::c_int = 11; -pub const F_SETLK: ::c_int = 12; -pub const F_SETLKW: ::c_int = 13; -pub const ELAST: ::c_int = 96; -pub const RLIMIT_NPTS: ::c_int = 11; -pub const RLIMIT_SWAP: ::c_int = 12; -pub const RLIM_NLIMITS: ::rlim_t = 13; - -pub const 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 EVFILT_READ: ::int16_t = -1; -pub const EVFILT_WRITE: ::int16_t = -2; -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_FS: ::int16_t = -9; -pub const EVFILT_LIO: ::int16_t = -10; -pub const EVFILT_USER: ::int16_t = -11; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_DROP: ::uint16_t = 0x1000; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; -pub const NOTE_FFNOP: ::uint32_t = 0x00000000; -pub const NOTE_FFAND: ::uint32_t = 0x40000000; -pub const NOTE_FFOR: ::uint32_t = 0x80000000; -pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; -pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; -pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; -pub const NOTE_SECONDS: ::uint32_t = 0x00000001; -pub const NOTE_MSECONDS: ::uint32_t = 0x00000002; -pub const NOTE_USECONDS: ::uint32_t = 0x00000004; -pub const NOTE_NSECONDS: ::uint32_t = 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 CTL_MAXID: ::c_int = 10; -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_MAXID: ::c_int = 38; -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 HW_MAXID: ::c_int = 13; -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_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 CTL_P1003_1B_MAXID: ::c_int = 26; - -pub const MSG_NOSIGNAL: ::c_int = 0x20000; - -extern { - pub fn __error() -> *mut ::c_int; - - pub fn mprotect(addr: *const ::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 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; -} - -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 { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs deleted file mode 100644 index 8a5e5f9fb8d..00000000000 --- a/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ /dev/null @@ -1,31 +0,0 @@ -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: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - __unused: [u8; 8], - } -} diff --git a/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs b/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs deleted file mode 100644 index a2da8452c4d..00000000000 --- a/src/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs +++ /dev/null @@ -1,30 +0,0 @@ -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: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } -} diff --git a/src/vendor/libc/src/unix/bsd/freebsdlike/mod.rs b/src/vendor/libc/src/unix/bsd/freebsdlike/mod.rs deleted file mode 100644 index 2cfb323c061..00000000000 --- a/src/vendor/libc/src/unix/bsd/freebsdlike/mod.rs +++ /dev/null @@ -1,879 +0,0 @@ -pub type dev_t = u32; -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_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 sem_t = _sem; - -pub enum timezone {} - -s! { - 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 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 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 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 addrinfo { - pub ai_flags: ::c_int, - pub ai_family: ::c_int, - pub ai_socktype: ::c_int, - pub ai_protocol: ::c_int, - pub ai_addrlen: ::socklen_t, - pub ai_canonname: *mut ::c_char, - pub ai_addr: *mut ::sockaddr, - pub ai_next: *mut addrinfo, - } - - pub struct sigset_t { - bits: [u32; 4], - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub si_pid: ::pid_t, - pub si_uid: ::uid_t, - pub si_status: ::c_int, - pub si_addr: *mut ::c_void, - _pad: [::c_int; 12], - } - - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_flags: ::c_int, - pub sa_mask: sigset_t, - } - - pub struct stack_t { - pub ss_sp: *mut ::c_char, - pub ss_size: ::size_t, - pub ss_flags: ::c_int, - } - - 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, - } - - // internal structure has changed over time - pub struct _sem { - data: [u32; 4], - } -} - -pub const EMPTY: ::c_short = 0; -pub const BOOT_TIME: ::c_short = 1; -pub const OLD_TIME: ::c_short = 2; -pub const NEW_TIME: ::c_short = 3; -pub const USER_PROCESS: ::c_short = 4; -pub const INIT_PROCESS: ::c_short = 5; -pub const LOGIN_PROCESS: ::c_short = 6; -pub const DEAD_PROCESS: ::c_short = 7; -pub const SHUTDOWN_TIME: ::c_short = 8; - -pub const LC_COLLATE_MASK: ::c_int = (1 << 0); -pub const LC_CTYPE_MASK: ::c_int = (1 << 1); -pub const LC_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 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 _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_RDONLY: ::c_int = 0; -pub const O_WRONLY: ::c_int = 1; -pub const O_RDWR: ::c_int = 2; -pub const O_ACCMODE: ::c_int = 3; -pub const O_APPEND: ::c_int = 8; -pub const O_CREAT: ::c_int = 512; -pub const O_EXCL: ::c_int = 2048; -pub const O_NOCTTY: ::c_int = 32768; -pub const O_TRUNC: ::c_int = 1024; -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_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 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 EAI_SYSTEM: ::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 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_NPROCESSORS_ONLN: ::c_int = 58; -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 = 117; - -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_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 28; -pub const AF_UNIX: ::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 IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -pub const IP_MULTICAST_TTL: ::c_int = 10; -pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_TTL: ::c_int = 4; -pub const IP_HDRINCL: ::c_int = 2; -pub const IP_ADD_MEMBERSHIP: ::c_int = 12; -pub const IP_DROP_MEMBERSHIP: ::c_int = 13; -pub const IPV6_JOIN_GROUP: ::c_int = 12; -pub const IPV6_LEAVE_GROUP: ::c_int = 13; - -pub const TCP_NODELAY: ::c_int = 1; -pub const TCP_KEEPIDLE: ::c_int = 256; -pub const SOL_SOCKET: ::c_int = 0xffff; -pub const SO_DEBUG: ::c_int = 0x01; -pub const SO_ACCEPTCONN: ::c_int = 0x0002; -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 IFF_LOOPBACK: ::c_int = 0x8; - -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 O_SYNC: ::c_int = 128; -pub const O_NONBLOCK: ::c_int = 4; - -pub const MAP_COPY: ::c_int = 0x0002; -pub const MAP_RENAME: ::c_int = 0x0020; -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 _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_HOST_NAME_MAX: ::c_int = 72; - -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_ADAPTIVE_NP: ::c_int = 4; -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 TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; - -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; - -f! { - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - status >> 8 - } - - pub fn WIFSIGNALED(status: ::c_int) -> bool { - (status & 0o177) != 0o177 && (status & 0o177) != 0 - } - - pub fn WIFSTOPPED(status: ::c_int) -> bool { - (status & 0o177) == 0o177 - } -} - -extern { - pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; - pub fn endutxent(); - pub fn getutxent() -> *mut utmpx; - pub fn getutxid(ut: *const utmpx) -> *mut utmpx; - pub fn getutxline(ut: *const utmpx) -> *mut utmpx; - pub fn pututxline(ut: *const utmpx) -> *mut utmpx; - pub fn setutxent(); - pub fn getutxuser(user: *const ::c_char) -> *mut utmpx; - pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int; -} - -#[link(name = "util")] -extern { - pub fn getnameinfo(sa: *const ::sockaddr, - salen: ::socklen_t, - host: *mut ::c_char, - hostlen: ::size_t, - serv: *mut ::c_char, - servlen: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn kevent(kq: ::c_int, - changelist: *const ::kevent, - nchanges: ::c_int, - eventlist: *mut ::kevent, - nevents: ::c_int, - timeout: *const ::timespec) -> ::c_int; - pub fn mincore(addr: *const ::c_void, len: ::size_t, - vec: *mut ::c_char) -> ::c_int; - pub fn sysctlnametomib(name: *const ::c_char, - mibp: *mut ::c_int, - sizep: *mut ::size_t) - -> ::c_int; - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) - -> ::c_int; - pub fn sysctl(name: *const ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *const ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sysctlbyname(name: *const ::c_char, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *const ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sched_setscheduler(pid: ::pid_t, - policy: ::c_int, - param: *const sched_param) -> ::c_int; - pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; - pub fn memrchr(cx: *const ::c_void, - c: ::c_int, - n: ::size_t) -> *mut ::c_void; - pub fn 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 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 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 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) -> ::c_int; - 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 pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); - pub fn pthread_attr_get_np(tid: ::pthread_t, - attr: *mut ::pthread_attr_t) -> ::c_int; - pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, - guardsize: *mut ::size_t) -> ::c_int; - pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, - stackaddr: *mut *mut ::c_void, - stacksize: *mut ::size_t) -> ::c_int; - pub fn 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 openat(dirfd: ::c_int, pathname: *const ::c_char, - flags: ::c_int, ...) -> ::c_int; - pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::c_int, 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 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 mknodat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t, dev: dev_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 mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t) -> ::c_int; - pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, - clock_id: *mut clockid_t) -> ::c_int; - pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, - clock_id: clockid_t) -> ::c_int; - pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; - pub fn sem_timedwait(sem: *mut sem_t, - abstime: *const ::timespec) -> ::c_int; - pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, - abstime: *const ::timespec) -> ::c_int; -} - -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/src/vendor/libc/src/unix/bsd/mod.rs b/src/vendor/libc/src/unix/bsd/mod.rs deleted file mode 100644 index 0616cd35184..00000000000 --- a/src/vendor/libc/src/unix/bsd/mod.rs +++ /dev/null @@ -1,368 +0,0 @@ -use dox::mem; - -pub type c_char = i8; -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 sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - - 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 - } - - 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 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], - } - - 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 fsid_t { - __fsid_val: [::int32_t; 2], - } - - pub struct if_nameindex { - pub if_index: ::c_uint, - pub if_name: *mut ::c_char, - } -} - -pub const LC_ALL: ::c_int = 0; -pub const LC_COLLATE: ::c_int = 1; -pub const LC_CTYPE: ::c_int = 2; -pub const LC_MONETARY: ::c_int = 3; -pub const LC_NUMERIC: ::c_int = 4; -pub const LC_TIME: ::c_int = 5; -pub const LC_MESSAGES: ::c_int = 6; - -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONBIO: ::c_ulong = 0x8004667e; - -pub const PATH_MAX: ::c_int = 1024; - -pub const SA_ONSTACK: ::c_int = 0x0001; -pub const SA_SIGINFO: ::c_int = 0x0040; -pub const SA_RESTART: ::c_int = 0x0002; -pub const SA_RESETHAND: ::c_int = 0x0004; -pub const SA_NOCLDSTOP: ::c_int = 0x0008; -pub const SA_NODEFER: ::c_int = 0x0010; -pub const SA_NOCLDWAIT: ::c_int = 0x0020; - -pub const SS_ONSTACK: ::c_int = 1; -pub const SS_DISABLE: ::c_int = 4; - -pub const SIGCHLD: ::c_int = 20; -pub const SIGBUS: ::c_int = 10; -pub const SIGUSR1: ::c_int = 30; -pub const SIGUSR2: ::c_int = 31; -pub const SIGCONT: ::c_int = 19; -pub const SIGSTOP: ::c_int = 17; -pub const SIGTSTP: ::c_int = 18; -pub const SIGURG: ::c_int = 16; -pub const SIGIO: ::c_int = 23; -pub const SIGSYS: ::c_int = 12; -pub const SIGTTIN: ::c_int = 21; -pub const SIGTTOU: ::c_int = 22; -pub const SIGXCPU: ::c_int = 24; -pub const SIGXFSZ: ::c_int = 25; -pub const SIGVTALRM: ::c_int = 26; -pub const SIGPROF: ::c_int = 27; -pub const SIGWINCH: ::c_int = 28; -pub const SIGINFO: ::c_int = 29; - -pub const SIG_SETMASK: ::c_int = 3; -pub const SIG_BLOCK: ::c_int = 0x1; -pub const SIG_UNBLOCK: ::c_int = 0x2; - -pub const IPV6_MULTICAST_LOOP: ::c_int = 11; -pub const IPV6_V6ONLY: ::c_int = 27; - -pub const ST_RDONLY: ::c_ulong = 1; - -pub const NCCS: usize = 20; - -pub const O_ASYNC: ::c_int = 0x40; -pub const O_FSYNC: ::c_int = 0x80; -pub const O_NDELAY: ::c_int = 0x4; -pub const O_NOFOLLOW: ::c_int = 0x100; - -pub const F_GETOWN: ::c_int = 5; -pub const F_SETOWN: ::c_int = 6; - -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 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 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 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 IEXTEN: ::tcflag_t = 0x00000400; -pub const EXTPROC: ::tcflag_t = 0x00000800; -pub const TOSTOP: ::tcflag_t = 0x00400000; -pub const FLUSHO: ::tcflag_t = 0x00800000; -pub const PENDIN: ::tcflag_t = 0x20000000; -pub const NOFLSH: ::tcflag_t = 0x80000000; - -pub const WNOHANG: ::c_int = 0x00000001; -pub const WUNTRACED: ::c_int = 0x00000002; - -pub const RTLD_NOW: ::c_int = 0x2; -pub const RTLD_DEFAULT: *mut ::c_void = -2isize 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 PIPE_BUF: usize = 512; - -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 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 - } -} - -extern { - 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 = "__getpwnam_r50")] - 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")] - 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(target_os = "netbsd", link_name = "__getpwent50")] - pub fn getpwent() -> *mut passwd; - pub fn setpwent(); - 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); -} - -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", - target_os = "bitrig"))] { - 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/src/vendor/libc/src/unix/bsd/netbsdlike/mod.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/mod.rs deleted file mode 100644 index 6604ec03b2c..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/mod.rs +++ /dev/null @@ -1,547 +0,0 @@ -pub type time_t = i64; -pub type mode_t = u32; -pub type nlink_t = ::uint32_t; -pub type ino_t = ::uint64_t; -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 = ::uint32_t; -pub type sem_t = *mut sem; - -pub enum timezone {} -pub enum sem {} - -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 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: [::int8_t; 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: ::c_int, - pub c_ospeed: ::c_int, - } - - pub struct flock { - pub l_start: ::off_t, - pub l_len: ::off_t, - pub l_pid: ::pid_t, - pub l_type: ::c_short, - pub l_whence: ::c_short, - } -} - -pub const D_T_FMT: ::nl_item = 0; -pub const D_FMT: ::nl_item = 1; -pub const T_FMT: ::nl_item = 2; -pub const T_FMT_AMPM: ::nl_item = 3; -pub const AM_STR: ::nl_item = 4; -pub const PM_STR: ::nl_item = 5; - -pub const DAY_1: ::nl_item = 6; -pub const DAY_2: ::nl_item = 7; -pub const DAY_3: ::nl_item = 8; -pub const DAY_4: ::nl_item = 9; -pub const DAY_5: ::nl_item = 10; -pub const DAY_6: ::nl_item = 11; -pub const DAY_7: ::nl_item = 12; - -pub const ABDAY_1: ::nl_item = 13; -pub const ABDAY_2: ::nl_item = 14; -pub const ABDAY_3: ::nl_item = 15; -pub const ABDAY_4: ::nl_item = 16; -pub const ABDAY_5: ::nl_item = 17; -pub const ABDAY_6: ::nl_item = 18; -pub const ABDAY_7: ::nl_item = 19; - -pub const MON_1: ::nl_item = 20; -pub const MON_2: ::nl_item = 21; -pub const MON_3: ::nl_item = 22; -pub const MON_4: ::nl_item = 23; -pub const MON_5: ::nl_item = 24; -pub const MON_6: ::nl_item = 25; -pub const MON_7: ::nl_item = 26; -pub const MON_8: ::nl_item = 27; -pub const MON_9: ::nl_item = 28; -pub const MON_10: ::nl_item = 29; -pub const MON_11: ::nl_item = 30; -pub const MON_12: ::nl_item = 31; - -pub const ABMON_1: ::nl_item = 32; -pub const ABMON_2: ::nl_item = 33; -pub const ABMON_3: ::nl_item = 34; -pub const ABMON_4: ::nl_item = 35; -pub const ABMON_5: ::nl_item = 36; -pub const ABMON_6: ::nl_item = 37; -pub const ABMON_7: ::nl_item = 38; -pub const ABMON_8: ::nl_item = 39; -pub const ABMON_9: ::nl_item = 40; -pub const ABMON_10: ::nl_item = 41; -pub const ABMON_11: ::nl_item = 42; -pub const ABMON_12: ::nl_item = 43; - -pub const RADIXCHAR: ::nl_item = 44; -pub const THOUSEP: ::nl_item = 45; -pub const YESSTR: ::nl_item = 46; -pub const YESEXPR: ::nl_item = 47; -pub const NOSTR: ::nl_item = 48; -pub const NOEXPR: ::nl_item = 49; -pub const CRNCYSTR: ::nl_item = 50; - -pub const CODESET: ::nl_item = 51; - -pub const EXIT_FAILURE : ::c_int = 1; -pub const EXIT_SUCCESS : ::c_int = 0; -pub const RAND_MAX : ::c_int = 2147483647; -pub const EOF : ::c_int = -1; -pub const SEEK_SET : ::c_int = 0; -pub const SEEK_CUR : ::c_int = 1; -pub const SEEK_END : ::c_int = 2; -pub const _IOFBF : ::c_int = 0; -pub const _IONBF : ::c_int = 2; -pub const _IOLBF : ::c_int = 1; -pub const BUFSIZ : ::c_uint = 1024; -pub const FOPEN_MAX : ::c_uint = 20; -pub const FILENAME_MAX : ::c_uint = 1024; -pub const L_tmpnam : ::c_uint = 1024; -pub const O_RDONLY : ::c_int = 0; -pub const O_WRONLY : ::c_int = 1; -pub const O_RDWR : ::c_int = 2; -pub const O_ACCMODE : ::c_int = 3; -pub const O_APPEND : ::c_int = 8; -pub const O_CREAT : ::c_int = 512; -pub const O_EXCL : ::c_int = 2048; -pub const O_NOCTTY : ::c_int = 32768; -pub const O_TRUNC : ::c_int = 1024; -pub const O_SYNC : ::c_int = 128; -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 SIGSTKSZ : ::size_t = 40960; - -pub const PROT_NONE : ::c_int = 0; -pub const PROT_READ : ::c_int = 1; -pub const PROT_WRITE : ::c_int = 2; -pub const PROT_EXEC : ::c_int = 4; - -pub const MAP_FILE : ::c_int = 0x0000; -pub const MAP_SHARED : ::c_int = 0x0001; -pub const MAP_PRIVATE : ::c_int = 0x0002; -pub const MAP_FIXED : ::c_int = 0x0010; -pub const MAP_ANON : ::c_int = 0x1000; - -pub const MAP_FAILED : *mut ::c_void = !0 as *mut ::c_void; - -pub const MCL_CURRENT : ::c_int = 0x0001; -pub const MCL_FUTURE : ::c_int = 0x0002; - -pub const MS_ASYNC : ::c_int = 0x0001; - -pub const EPERM : ::c_int = 1; -pub const ENOENT : ::c_int = 2; -pub const ESRCH : ::c_int = 3; -pub const EINTR : ::c_int = 4; -pub const EIO : ::c_int = 5; -pub const ENXIO : ::c_int = 6; -pub const E2BIG : ::c_int = 7; -pub const ENOEXEC : ::c_int = 8; -pub const EBADF : ::c_int = 9; -pub const ECHILD : ::c_int = 10; -pub const EDEADLK : ::c_int = 11; -pub const ENOMEM : ::c_int = 12; -pub const EACCES : ::c_int = 13; -pub const EFAULT : ::c_int = 14; -pub const ENOTBLK : ::c_int = 15; -pub const EBUSY : ::c_int = 16; -pub const EEXIST : ::c_int = 17; -pub const EXDEV : ::c_int = 18; -pub const ENODEV : ::c_int = 19; -pub const ENOTDIR : ::c_int = 20; -pub const EISDIR : ::c_int = 21; -pub const EINVAL : ::c_int = 22; -pub const ENFILE : ::c_int = 23; -pub const EMFILE : ::c_int = 24; -pub const ENOTTY : ::c_int = 25; -pub const ETXTBSY : ::c_int = 26; -pub const EFBIG : ::c_int = 27; -pub const ENOSPC : ::c_int = 28; -pub const ESPIPE : ::c_int = 29; -pub const EROFS : ::c_int = 30; -pub const EMLINK : ::c_int = 31; -pub const EPIPE : ::c_int = 32; -pub const EDOM : ::c_int = 33; -pub const ERANGE : ::c_int = 34; -pub const EAGAIN : ::c_int = 35; -pub const EWOULDBLOCK : ::c_int = 35; -pub const EINPROGRESS : ::c_int = 36; -pub const EALREADY : ::c_int = 37; -pub const ENOTSOCK : ::c_int = 38; -pub const EDESTADDRREQ : ::c_int = 39; -pub const EMSGSIZE : ::c_int = 40; -pub const EPROTOTYPE : ::c_int = 41; -pub const ENOPROTOOPT : ::c_int = 42; -pub const EPROTONOSUPPORT : ::c_int = 43; -pub const ESOCKTNOSUPPORT : ::c_int = 44; -pub const EOPNOTSUPP : ::c_int = 45; -pub const EPFNOSUPPORT : ::c_int = 46; -pub const EAFNOSUPPORT : ::c_int = 47; -pub const EADDRINUSE : ::c_int = 48; -pub const EADDRNOTAVAIL : ::c_int = 49; -pub const ENETDOWN : ::c_int = 50; -pub const ENETUNREACH : ::c_int = 51; -pub const ENETRESET : ::c_int = 52; -pub const ECONNABORTED : ::c_int = 53; -pub const ECONNRESET : ::c_int = 54; -pub const ENOBUFS : ::c_int = 55; -pub const EISCONN : ::c_int = 56; -pub const ENOTCONN : ::c_int = 57; -pub const ESHUTDOWN : ::c_int = 58; -pub const ETOOMANYREFS : ::c_int = 59; -pub const ETIMEDOUT : ::c_int = 60; -pub const ECONNREFUSED : ::c_int = 61; -pub const ELOOP : ::c_int = 62; -pub const ENAMETOOLONG : ::c_int = 63; -pub const EHOSTDOWN : ::c_int = 64; -pub const EHOSTUNREACH : ::c_int = 65; -pub const ENOTEMPTY : ::c_int = 66; -pub const EPROCLIM : ::c_int = 67; -pub const EUSERS : ::c_int = 68; -pub const EDQUOT : ::c_int = 69; -pub const ESTALE : ::c_int = 70; -pub const EREMOTE : ::c_int = 71; -pub const EBADRPC : ::c_int = 72; -pub const ERPCMISMATCH : ::c_int = 73; -pub const EPROGUNAVAIL : ::c_int = 74; -pub const EPROGMISMATCH : ::c_int = 75; -pub const EPROCUNAVAIL : ::c_int = 76; -pub const ENOLCK : ::c_int = 77; -pub const ENOSYS : ::c_int = 78; -pub const EFTYPE : ::c_int = 79; -pub const EAUTH : ::c_int = 80; -pub const ENEEDAUTH : ::c_int = 81; - -pub const F_DUPFD : ::c_int = 0; -pub const F_GETFD : ::c_int = 1; -pub const F_SETFD : ::c_int = 2; -pub const F_GETFL : ::c_int = 3; -pub const F_SETFL : ::c_int = 4; - -pub const SIGTRAP : ::c_int = 5; - -pub const GLOB_APPEND : ::c_int = 0x0001; -pub const GLOB_DOOFFS : ::c_int = 0x0002; -pub const GLOB_ERR : ::c_int = 0x0004; -pub const GLOB_MARK : ::c_int = 0x0008; -pub const GLOB_NOCHECK : ::c_int = 0x0010; -pub const GLOB_NOSORT : ::c_int = 0x0020; -pub const GLOB_NOESCAPE : ::c_int = 0x1000; - -pub const GLOB_NOSPACE : ::c_int = -1; -pub const GLOB_ABORTED : ::c_int = -2; -pub const GLOB_NOMATCH : ::c_int = -3; -pub const GLOB_NOSYS : ::c_int = -4; - -pub const POSIX_MADV_NORMAL : ::c_int = 0; -pub const POSIX_MADV_RANDOM : ::c_int = 1; -pub const POSIX_MADV_SEQUENTIAL : ::c_int = 2; -pub const POSIX_MADV_WILLNEED : ::c_int = 3; -pub const POSIX_MADV_DONTNEED : ::c_int = 4; - -pub const _SC_XOPEN_SHM : ::c_int = 30; - -pub const PTHREAD_CREATE_JOINABLE : ::c_int = 0; -pub const PTHREAD_CREATE_DETACHED : ::c_int = 1; - -// 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_UNIX: ::c_int = 1; -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 24; -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 IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -pub const IP_MULTICAST_TTL: ::c_int = 10; -pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_TTL: ::c_int = 4; -pub const IP_HDRINCL: ::c_int = 2; -pub const IP_ADD_MEMBERSHIP: ::c_int = 12; -pub const IP_DROP_MEMBERSHIP: ::c_int = 13; - -pub const TCP_NODELAY: ::c_int = 0x01; -pub const SOL_SOCKET: ::c_int = 0xffff; -pub const SO_DEBUG: ::c_int = 0x01; -pub const SO_ACCEPTCONN: ::c_int = 0x0002; -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 MSG_NOSIGNAL: ::c_int = 0x400; - -pub const IFF_LOOPBACK: ::c_int = 0x8; - -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 O_NONBLOCK : ::c_int = 4; - -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 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 SEM_FAILED: *mut sem_t = 0 as *mut sem_t; - -f! { - 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 - } -} - -#[link(name = "util")] -extern { - 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; - 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 futimens(fd: ::c_int, times: *const ::timespec) -> ::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 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 openat(dirfd: ::c_int, pathname: *const ::c_char, - flags: ::c_int, ...) -> ::c_int; - pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::c_int, 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 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 mknodat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t, dev: dev_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 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 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; -} - -cfg_if! { - if #[cfg(target_os = "netbsd")] { - mod netbsd; - pub use self::netbsd::*; - } else if #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] { - mod openbsdlike; - pub use self::openbsdlike::*; - } else { - // Unknown target_os - } -} diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs deleted file mode 100644 index aa46aff1910..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ /dev/null @@ -1,618 +0,0 @@ -pub type clock_t = ::c_uint; -pub type suseconds_t = ::c_int; -pub type dev_t = u64; -pub type blksize_t = ::int32_t; -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; - -s! { - 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 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 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: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_spare: [::uint32_t; 2], - } - - 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: ::uint64_t, - pub f_syncwrites: ::uint64_t, - - pub f_asyncreads: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - - pub f_fsidx: ::fsid_t, - pub f_fsid: ::c_ulong, - pub f_namemax: ::c_ulong, - pub f_owner: ::uid_t, - - pub f_spare: [::uint32_t; 4], - - pub f_fstypename: [::c_char; 32], - pub f_mntonname: [::c_char; 1024], - pub f_mntfromname: [::c_char; 1024], - } - - 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 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 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: ::c_uchar, - ptm_pad1: [u8; 3], - ptm_interlock: ::c_uchar, - 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_cond_t { - ptc_magic: ::c_uint, - ptc_lock: ::c_uchar, - 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: ::c_uchar, - 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: ::uint32_t, - pub flags: ::uint32_t, - pub fflags: ::uint32_t, - pub data: ::int64_t, - pub udata: ::intptr_t, - } - - pub struct dqblk { - pub dqb_bhardlimit: ::uint32_t, - pub dqb_bsoftlimit: ::uint32_t, - pub dqb_curblocks: ::uint32_t, - pub dqb_ihardlimit: ::uint32_t, - pub dqb_isoftlimit: ::uint32_t, - pub dqb_curinodes: ::uint32_t, - pub dqb_btime: ::int32_t, - pub dqb_itime: ::int32_t, - } - - 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 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_EXLOCK: ::c_int = 0x20; -pub const O_SHLOCK: ::c_int = 0x10; -pub const O_DIRECTORY: ::c_int = 0x200000; - -pub const MS_SYNC : ::c_int = 0x4; -pub const MS_INVALIDATE : ::c_int = 0x2; - -pub const RLIM_NLIMITS: ::c_int = 12; - -pub const ENOATTR : ::c_int = 93; -pub const EILSEQ : ::c_int = 85; -pub const EOVERFLOW : ::c_int = 84; -pub const ECANCELED : ::c_int = 87; -pub const EIDRM : ::c_int = 82; -pub const ENOMSG : ::c_int = 83; -pub const ENOTSUP : ::c_int = 86; -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 IPV6_JOIN_GROUP: ::c_int = 12; -pub const IPV6_LEAVE_GROUP: ::c_int = 13; - -pub const SO_SNDTIMEO: ::c_int = 0x100b; -pub const SO_RCVTIMEO: ::c_int = 0x100c; - -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 _SC_IOV_MAX : ::c_int = 32; -pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 47; -pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 48; -pub const _SC_LOGIN_NAME_MAX : ::c_int = 37; -pub const _SC_MQ_PRIO_MAX : ::c_int = 55; -pub const _SC_NPROCESSORS_ONLN : ::c_int = 1002; -pub const _SC_THREADS : ::c_int = 41; -pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 61; -pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 62; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 57; -pub const _SC_THREAD_KEYS_MAX : ::c_int = 58; -pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 64; -pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 65; -pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 63; -pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 66; -pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 67; -pub const _SC_THREAD_STACK_MIN : ::c_int = 59; -pub const _SC_THREAD_THREADS_MAX : ::c_int = 60; -pub const _SC_TTY_NAME_MAX : ::c_int = 68; -pub const _SC_ATEXIT_MAX : ::c_int = 40; -pub const _SC_CLK_TCK : ::c_int = 39; -pub const _SC_AIO_LISTIO_MAX : ::c_int = 51; -pub const _SC_AIO_MAX : ::c_int = 52; -pub const _SC_ASYNCHRONOUS_IO : ::c_int = 50; -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_MESSAGE_PASSING : ::c_int = 53; -pub const _SC_MQ_OPEN_MAX : ::c_int = 54; -pub const _SC_PRIORITY_SCHEDULING : ::c_int = 56; -pub const _SC_SEMAPHORES : ::c_int = 42; -pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 87; -pub const _SC_SYNCHRONIZED_IO : ::c_int = 31; -pub const _SC_TIMERS : ::c_int = 44; -pub const _SC_HOST_NAME_MAX : ::c_int = 69; - -pub const FD_SETSIZE: usize = 0x100; - -pub const ST_NOSUID: ::c_ulong = 8; - -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - ptm_magic: 0x33330003, - ptm_errorcheck: 0, - ptm_interlock: 0, - ptm_waiters: 0 as *mut _, - ptm_owner: 0, - ptm_pad1: [0; 3], - ptm_pad2: [0; 3], - 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: ::int32_t = 2; -pub const EVFILT_PROC: ::int32_t = 4; -pub const EVFILT_READ: ::int32_t = 0; -pub const EVFILT_SIGNAL: ::int32_t = 5; -pub const EVFILT_TIMER: ::int32_t = 6; -pub const EVFILT_VNODE: ::int32_t = 3; -pub const EVFILT_WRITE: ::int32_t = 1; - -pub const EV_ADD: ::uint32_t = 0x1; -pub const EV_DELETE: ::uint32_t = 0x2; -pub const EV_ENABLE: ::uint32_t = 0x4; -pub const EV_DISABLE: ::uint32_t = 0x8; -pub const EV_ONESHOT: ::uint32_t = 0x10; -pub const EV_CLEAR: ::uint32_t = 0x20; -pub const EV_RECEIPT: ::uint32_t = 0x40; -pub const EV_DISPATCH: ::uint32_t = 0x80; -pub const EV_FLAG1: ::uint32_t = 0x2000; -pub const EV_ERROR: ::uint32_t = 0x4000; -pub const EV_EOF: ::uint32_t = 0x8000; -pub const EV_SYSFLAGS: ::uint32_t = 0xf000; - -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; - -pub const CRTSCTS: ::tcflag_t = 0x00010000; - -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 EAI_SYSTEM: ::c_int = 11; - -extern { - pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::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 ptrace(requeset: ::c_int, - pid: ::pid_t, - addr: *mut ::c_void, - data: ::c_int) -> ::c_int; - pub fn pthread_setname_np(t: ::pthread_t, - name: *const ::c_char, - arg: *mut ::c_void) -> ::c_int; - pub fn pthread_getattr_np(native: ::pthread_t, - attr: *mut ::pthread_attr_t) -> ::c_int; - pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, - guardsize: *mut ::size_t) -> ::c_int; - pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, - stackaddr: *mut *mut ::c_void, - stacksize: *mut ::size_t) -> ::c_int; - #[link_name = "__sigtimedwait50"] - pub fn sigtimedwait(set: *const sigset_t, - info: *mut siginfo_t, - timeout: *const ::timespec) -> ::c_int; - pub fn sigwaitinfo(set: *const sigset_t, - info: *mut siginfo_t) -> ::c_int; - pub fn duplocale(base: ::locale_t) -> ::locale_t; - pub fn freelocale(loc: ::locale_t); - pub fn localeconv_l(loc: ::locale_t) -> *mut lconv; - pub fn newlocale(mask: ::c_int, - locale: *const ::c_char, - base: ::locale_t) -> ::locale_t; -} - -mod other; -pub use self::other::*; diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs deleted file mode 100644 index 9b0b338b91e..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs deleted file mode 100644 index b07c476aa49..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/mod.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/mod.rs deleted file mode 100644 index f4e7cc40612..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/netbsd/other/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -cfg_if! { - if #[cfg(target_arch = "x86_64")] { - mod b64; - pub use self::b64::*; - } else if #[cfg(any(target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86"))] { - mod b32; - pub use self::b32::*; - } else { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs deleted file mode 100644 index 695cf68dc5a..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs +++ /dev/null @@ -1,75 +0,0 @@ -s! { - 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 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 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 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 KERN_RND: ::c_int = 31; - -extern { - 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) -> ::c_int; - 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; -} diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs deleted file mode 100644 index d7afb11eddd..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ /dev/null @@ -1,448 +0,0 @@ -pub type c_long = i64; -pub type c_ulong = u64; -pub type clock_t = i64; -pub type suseconds_t = i64; -pub type dev_t = i32; -pub type sigset_t = ::c_uint; -pub type blksize_t = ::int32_t; -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; -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; - -s! { - 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 glob_t { - pub gl_pathc: ::c_int, - pub gl_matchc: ::c_int, - pub gl_offs: ::c_int, - 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 kevent { - pub ident: ::uintptr_t, - pub filter: ::c_short, - pub flags: ::c_ushort, - pub fflags: ::c_uint, - pub data: ::int64_t, - 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: ::uint32_t, - pub st_gen: ::uint32_t, - 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 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, - __pad: [u8; 108], - } - - 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 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 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 MS_SYNC : ::c_int = 0x0002; -pub const MS_INVALIDATE : ::c_int = 0x0004; - -pub const PTHREAD_STACK_MIN : ::size_t = 2048; - -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 ELAST : ::c_int = 91; - -pub const F_DUPFD_CLOEXEC : ::c_int = 10; - -pub const RLIM_NLIMITS: ::c_int = 9; - -pub const SO_SNDTIMEO: ::c_int = 0x1005; -pub const SO_RCVTIMEO: ::c_int = 0x1006; - -pub const IPV6_JOIN_GROUP: ::c_int = 12; -pub const IPV6_LEAVE_GROUP: ::c_int = 13; - -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_SYSTEM: ::c_int = -11; - -pub const RUSAGE_THREAD: ::c_int = 1; - -pub const MAP_COPY : ::c_int = 0x0002; -pub const MAP_NOEXTEND : ::c_int = 0x0000; - -pub const _SC_CLK_TCK : ::c_int = 3; -pub const _SC_IOV_MAX : ::c_int = 51; -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_MQ_PRIO_MAX : ::c_int = 59; -pub const _SC_NPROCESSORS_ONLN : ::c_int = 503; -pub const _SC_THREADS : ::c_int = 91; -pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78; -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_SAFE_FUNCTIONS : ::c_int = 103; -pub const _SC_THREAD_STACK_MIN : ::c_int = 89; -pub const _SC_THREAD_THREADS_MAX : ::c_int = 90; -pub const _SC_TTY_NAME_MAX : ::c_int = 107; -pub const _SC_ATEXIT_MAX : ::c_int = 46; -pub const _SC_AIO_LISTIO_MAX : ::c_int = 42; -pub const _SC_AIO_MAX : ::c_int = 43; -pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45; -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_PRIORITY_SCHEDULING : ::c_int = 61; -pub const _SC_SEMAPHORES : ::c_int = 67; -pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68; -pub const _SC_SYNCHRONIZED_IO : ::c_int = 75; -pub const _SC_TIMERS : ::c_int = 94; -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_UNIX : ::c_int = 123; -pub const _SC_XOPEN_VERSION : ::c_int = 125; -pub const _SC_SEM_NSEMS_MAX : ::c_int = 31; -pub const _SC_SEM_VALUE_MAX : ::c_int = 32; -pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44; -pub const _SC_DELAYTIMER_MAX : ::c_int = 50; -pub const _SC_PRIORITIZED_IO : ::c_int = 60; -pub const _SC_REALTIME_SIGNALS : ::c_int = 64; -pub const _SC_RTSIG_MAX : ::c_int = 66; -pub const _SC_SIGQUEUE_MAX : ::c_int = 70; -pub const _SC_TIMER_MAX : ::c_int = 93; -pub const _SC_HOST_NAME_MAX : ::c_int = 33; - -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: ::int16_t = -3; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_READ: ::int16_t = -1; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_WRITE: ::int16_t = -2; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_EOF: ::uint32_t = 0x00000002; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_TRUNCATE: ::uint32_t = 0x00000080; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 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 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_MAXID: ::c_int = 84; -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; - -extern { - pub fn getnameinfo(sa: *const ::sockaddr, - salen: ::socklen_t, - host: *mut ::c_char, - hostlen: ::size_t, - serv: *mut ::c_char, - servlen: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn kevent(kq: ::c_int, - changelist: *const ::kevent, - nchanges: ::c_int, - eventlist: *mut ::kevent, - nevents: ::c_int, - timeout: *const ::timespec) -> ::c_int; - pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; - pub fn pthread_main_np() -> ::c_int; - pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); - pub fn pthread_stackseg_np(thread: ::pthread_t, - sinfo: *mut ::stack_t) -> ::c_int; - pub fn sysctl(name: *const ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; -} - -cfg_if! { - if #[cfg(target_os = "openbsd")] { - mod openbsd; - pub use self::openbsd::*; - } else if #[cfg(target_os = "bitrig")] { - mod bitrig; - pub use self::bitrig::*; - } else { - // Unknown target_os - } -} diff --git a/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs b/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs deleted file mode 100644 index b7fed64ede5..00000000000 --- a/src/vendor/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs +++ /dev/null @@ -1,28 +0,0 @@ -s! { - 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, - } -} diff --git a/src/vendor/libc/src/unix/haiku/b32.rs b/src/vendor/libc/src/unix/haiku/b32.rs deleted file mode 100644 index 9b0b338b91e..00000000000 --- a/src/vendor/libc/src/unix/haiku/b32.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/vendor/libc/src/unix/haiku/b64.rs b/src/vendor/libc/src/unix/haiku/b64.rs deleted file mode 100644 index 5d63ce9ce43..00000000000 --- a/src/vendor/libc/src/unix/haiku/b64.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_ulong = u64; -pub type c_long = i64; diff --git a/src/vendor/libc/src/unix/haiku/mod.rs b/src/vendor/libc/src/unix/haiku/mod.rs deleted file mode 100644 index a241a020548..00000000000 --- a/src/vendor/libc/src/unix/haiku/mod.rs +++ /dev/null @@ -1,748 +0,0 @@ -use dox::mem; - -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 time_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 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 enum timezone {} - -s! { - 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 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 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 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 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 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 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, - } -} - -// 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 SIGTRAP: ::c_int = 22; - -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_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 NCCS: usize = 11; - -pub const O_RDONLY: ::c_int = 0x0000; -pub const O_WRONLY: ::c_int = 0x0001; -pub const O_RDWR: ::c_int = 0x0002; -pub const O_ACCMODE: ::c_int = 0x0003; - -pub const O_EXCL: ::c_int = 0x0100; -pub const O_CREAT: ::c_int = 0x0200; -pub const O_TRUNC: ::c_int = 0x0400; -pub const O_NOCTTY: ::c_int = 0x1000; -pub const O_NOTRAVERSE: ::c_int = 0x2000; - -pub const O_CLOEXEC: ::c_int = 0x00000040; -pub const O_NONBLOCK: ::c_int = 0x00000080; -pub const O_APPEND: ::c_int = 0x00000800; -pub const O_SYNC: ::c_int = 0x00010000; -pub const O_RSYNC: ::c_int = 0x00020000; -pub const O_DSYNC: ::c_int = 0x00040000; -pub const O_NOFOLLOW: ::c_int = 0x00080000; -pub const O_NOCACHE: ::c_int = 0x00100000; -pub const O_DIRECTORY: ::c_int = 0x00200000; - -pub const S_IFIFO: ::mode_t = 61440; -pub const S_IFCHR: ::mode_t = 49152; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IRWXU: ::mode_t = 448; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IRWXG: ::mode_t = 70; -pub const S_IXGRP: ::mode_t = 10; -pub const S_IWGRP: ::mode_t = 20; -pub const S_IRGRP: ::mode_t = 40; -pub const S_IRWXO: ::mode_t = 7; -pub const S_IXOTH: ::mode_t = 1; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IROTH: ::mode_t = 4; -pub const F_OK: ::c_int = 0; -pub const R_OK: ::c_int = 4; -pub const W_OK: ::c_int = 2; -pub const X_OK: ::c_int = 1; -pub const STDIN_FILENO: ::c_int = 0; -pub const STDOUT_FILENO: ::c_int = 1; -pub const STDERR_FILENO: ::c_int = 2; -pub const SIGHUP: ::c_int = 1; -pub const SIGINT: ::c_int = 2; -pub const SIGQUIT: ::c_int = 3; -pub const SIGILL: ::c_int = 4; -pub const 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 = 7; -pub const SIGALRM: ::c_int = 14; -pub const SIGTERM: ::c_int = 15; - -pub const EAI_SYSTEM: ::c_int = 11; - -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 = 0x004; - -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 EPERM : ::c_int = -2147483633; -pub const ENOENT : ::c_int = -2147459069; -pub const ESRCH : ::c_int = -2147454963; -pub const EINTR : ::c_int = -2147483638; -pub const EIO : ::c_int = -2147483647; -pub const ENXIO : ::c_int = -2147454965; -pub const E2BIG : ::c_int = -2147454975; -pub const ENOEXEC : ::c_int = -2147478782; -pub const EBADF : ::c_int = -2147459072; -pub const ECHILD : ::c_int = -2147454974; -pub const EDEADLK : ::c_int = -2147454973; -pub const ENOMEM : ::c_int = -2147454976; -pub const EACCES : ::c_int = -2147483646; -pub const EFAULT : ::c_int = -2147478783; -// pub const ENOTBLK : ::c_int = 15; -pub const EBUSY : ::c_int = -2147483634; -pub const EEXIST : ::c_int = -2147459070; -pub const EXDEV : ::c_int = -2147459061; -pub const ENODEV : ::c_int = -2147454969; -pub const ENOTDIR : ::c_int = -2147459067; -pub const EISDIR : ::c_int = -2147459063; -pub const EINVAL : ::c_int = -2147483643; -pub const ENFILE : ::c_int = -2147454970; -pub const EMFILE : ::c_int = -2147459062; -pub const ENOTTY : ::c_int = -2147454966; -pub const ETXTBSY : ::c_int = -2147454917; -pub const EFBIG : ::c_int = -2147454972; -pub const ENOSPC : ::c_int = -2147459065; -pub const ESPIPE : ::c_int = -2147454964; -pub const EROFS : ::c_int = -2147459064; -pub const EMLINK : ::c_int = -2147454971; -pub const EPIPE : ::c_int = -2147459059; -pub const EDOM : ::c_int = -2147454960; -pub const ERANGE : ::c_int = -2147454959; -pub const EAGAIN : ::c_int = -2147483637; -pub const EWOULDBLOCK : ::c_int = -2147483637; - -pub const EINPROGRESS : ::c_int = -2147454940; -pub const EALREADY : ::c_int = -2147454939; -pub const ENOTSOCK : ::c_int = -2147454932; -pub const EDESTADDRREQ : ::c_int = -2147454928; -pub const EMSGSIZE : ::c_int = -2147454934; -pub const EPROTOTYPE : ::c_int = -2147454958; -pub const ENOPROTOOPT : ::c_int = -2147454942; -pub const EPROTONOSUPPORT : ::c_int = -2147454957; -pub const EOPNOTSUPP : ::c_int = -2147454933; -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 = -2147454953; -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 ENOBUFS : ::c_int = -2147454941; -pub const EISCONN : ::c_int = -2147454947; -pub const ENOTCONN : ::c_int = -2147454946; -pub const ESHUTDOWN : ::c_int = -2147454945; -pub const ETIMEDOUT : ::c_int = -2147483639; -pub const ECONNREFUSED : ::c_int = -2147454944; -pub const ELOOP : ::c_int = -2147459060; -pub const ENAMETOOLONG : ::c_int = -2147459068; -pub const EHOSTDOWN : ::c_int = -2147454931; -pub const EHOSTUNREACH : ::c_int = -2147454943; -pub const ENOTEMPTY : ::c_int = -2147459066; -pub const EDQUOT : ::c_int = -2147454927; -pub const ESTALE : ::c_int = -2147454936; -pub const ENOLCK : ::c_int = -2147454968; -pub const ENOSYS : ::c_int = -2147454967; -pub const EIDRM : ::c_int = -2147454926; -pub const ENOMSG : ::c_int = -2147454937; -pub const EOVERFLOW : ::c_int = -2147454935; -pub const ECANCELED : ::c_int = -2147454929; -pub const EILSEQ : ::c_int = -2147454938; -pub const ENOATTR : ::c_int = -2147454916; -pub const EBADMSG : ::c_int = -2147454930; -pub const EMULTIHOP : ::c_int = -2147454925; -pub const ENOLINK : ::c_int = -2147454923; -pub const EPROTO : ::c_int = -2147454919; - -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; - -pub const IFF_LOOPBACK: ::c_int = 0x0008; - -pub const AF_UNIX: ::c_int = 9; -pub const AF_INET: ::c_int = 1; -pub const AF_INET6: ::c_int = 6; -pub const SOCK_RAW: ::c_int = 3; -pub const IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -pub const IP_MULTICAST_TTL: ::c_int = 10; -pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_TTL: ::c_int = 4; -pub const IP_HDRINCL: ::c_int = 2; -pub const IP_ADD_MEMBERSHIP: ::c_int = 12; -pub const IP_DROP_MEMBERSHIP: ::c_int = 13; - -pub const 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_LOOP: ::c_int = 26; -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 SO_DEBUG: ::c_int = 0x00000004; - -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 SA_NODEFER: ::c_int = 0x08; -pub const SA_RESETHAND: ::c_int = 0x04; -pub const SA_RESTART: ::c_int = 0x10; -pub const SA_NOCLDSTOP: ::c_int = 0x01; - -pub const FD_SETSIZE: usize = 1024; - -pub const RTLD_NOW: ::c_int = 0x1; -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_NAME_MAX: ::c_int = 4; - -pub const FIONBIO: ::c_int = 0xbe000000; - -pub const _SC_IOV_MAX : ::c_int = 32; -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_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_THREAD_PROCESS_SHARED : ::c_int = 46; -pub const _SC_THREAD_STACK_MIN : ::c_int = 47; -pub const _SC_THREADS : ::c_int = 31; -pub const _SC_ATEXIT_MAX : ::c_int = 37; - -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: 0, - 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 SA_ONSTACK: c_ulong = 0x20; -pub const SA_SIGINFO: c_ulong = 0x40; -pub const SA_NOCLDWAIT: c_ulong = 0x02; - -pub const SIGCHLD: ::c_int = 5; -pub const SIGBUS: ::c_int = 30; -pub const SIG_SETMASK: ::c_int = 3; - -pub const RUSAGE_CHILDREN: ::c_int = -1; - -pub const SOCK_STREAM: ::c_int = 1; -pub const SOCK_DGRAM: ::c_int = 2; - -pub const SOL_SOCKET: ::c_int = -1; -pub const SO_ACCEPTCONN: ::c_int = 0x00000001; -pub const SO_BROADCAST: ::c_int = 0x00000002; -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 NI_MAXHOST: ::size_t = 1025; - -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 >> 8) == 0 - } - - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { - (status & 0xff) - } - - pub fn WTERMSIG(status: ::c_int) -> ::c_int { - (status >> 8) & 0xff - } -} - -extern { - pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::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 getpwuid_r(uid: ::uid_t, - pwd: *mut passwd, - buffer: *mut ::c_char, - bufferSize: ::size_t, - result: *mut *mut passwd) -> ::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 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; -} - -cfg_if! { - if #[cfg(target_pointer_width = "64")] { - mod b64; - pub use self::b64::*; - } else { - mod b32; - pub use self::b32::*; - } -} diff --git a/src/vendor/libc/src/unix/mod.rs b/src/vendor/libc/src/unix/mod.rs deleted file mode 100644 index e822b063d9f..00000000000 --- a/src/vendor/libc/src/unix/mod.rs +++ /dev/null @@ -1,862 +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. - -use dox::Option; - -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 enum DIR {} -pub enum locale_t {} - -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, - } - - 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, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long, - - #[cfg(any(target_env = "musl"))] - __reserved: [c_long; 16], - } - - #[cfg_attr(target_os = "netbsd", repr(packed))] - pub struct in_addr { - pub s_addr: in_addr_t, - } - - pub struct in6_addr { - pub s6_addr: [u8; 16], - __align: [u32; 0], - } - - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - 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 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 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 IF_NAMESIZE: ::size_t = 16; - -pub const RTLD_LAZY: ::c_int = 0x1; - -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; - -cfg_if! { - if #[cfg(dox)] { - // on dox builds don't pull in anything - } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { - // cargo build, don't pull in anything extra as the libstd dep - // already pulls in all libs. - } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] { - #[link(name = "c", kind = "static")] - extern {} - } else if #[cfg(target_os = "emscripten")] { - #[link(name = "c")] - extern {} - } else if #[cfg(all(target_os = "netbsd", 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", - target_os = "bitrig"))] { - #[link(name = "c")] - #[link(name = "m")] - extern {} - } else if #[cfg(target_os = "haiku")] { - #[link(name = "root")] - #[link(name = "network")] - extern {} - } else { - #[link(name = "c")] - #[link(name = "m")] - #[link(name = "rt")] - extern {} - } -} - -extern { - pub fn getgrnam(name: *const ::c_char) -> *mut group; - pub fn getgrgid(gid: ::gid_t) -> *mut group; - - pub fn endpwent(); - #[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; - 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; - - #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] - 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")] - 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 = "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 = "listen$UNIX2003")] - 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")] - 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")] - 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")] - 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")] - pub fn stat(path: *const c_char, buf: *mut stat) -> ::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 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_r$INODE64")] - #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] - pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, - result: *mut *mut ::dirent) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "closedir$UNIX2003")] - pub fn closedir(dirp: *mut ::DIR) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "rewinddir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "rewinddir$INODE64$UNIX2003")] - pub fn rewinddir(dirp: *mut ::DIR); - - pub fn 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; - #[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$UNIX2003")] - 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 execv(prog: *const c_char, - argv: *const *const c_char) -> ::c_int; - pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) - -> ::c_int; - pub fn execvp(c: *const c_char, - argv: *const *const c_char) -> ::c_int; - pub fn fork() -> pid_t; - pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; - pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; - pub fn getegid() -> gid_t; - pub fn geteuid() -> uid_t; - pub fn getgid() -> gid_t; - pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) - -> ::c_int; - pub fn getlogin() -> *mut c_char; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "getopt$UNIX2003")] - pub fn getopt(argc: ::c_int, argv: *const *mut c_char, - optstr: *const c_char) -> ::c_int; - pub fn getpgid(pid: pid_t) -> pid_t; - pub fn getpgrp() -> pid_t; - pub fn getpid() -> pid_t; - pub fn getppid() -> pid_t; - pub fn getuid() -> uid_t; - pub fn isatty(fd: ::c_int) -> ::c_int; - pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; - pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; - pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pause$UNIX2003")] - pub fn pause() -> ::c_int; - pub fn pipe(fds: *mut ::c_int) -> ::c_int; - pub fn posix_memalign(memptr: *mut *mut ::c_void, - align: ::size_t, - size: ::size_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "read$UNIX2003")] - pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) - -> ::ssize_t; - pub fn rmdir(path: *const c_char) -> ::c_int; - pub fn 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 ttyname(fd: ::c_int) -> *mut c_char; - pub fn unlink(c: *const c_char) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "wait$UNIX2003")] - pub fn wait(status: *mut ::c_int) -> pid_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "waitpid$UNIX2003")] - pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) - -> pid_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "write$UNIX2003")] - pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) - -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pread$UNIX2003")] - pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, - offset: off_t) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pwrite$UNIX2003")] - pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, - offset: off_t) -> ::ssize_t; - pub fn umask(mask: mode_t) -> mode_t; - - #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] - pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "kill$UNIX2003")] - pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; - - 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")] - 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(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; - #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] - pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; - - pub fn getdtablesize() -> ::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 = "__gettimeofday50")] - pub fn gettimeofday(tp: *mut ::timeval, - tz: *mut ::c_void) -> ::c_int; - - pub fn pthread_self() -> ::pthread_t; - pub fn pthread_create(native: *mut ::pthread_t, - attr: *const ::pthread_attr_t, - f: extern fn(*mut ::c_void) -> *mut ::c_void, - value: *mut ::c_void) -> ::c_int; - #[cfg_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_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; - pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; - pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, - stack_size: ::size_t) -> ::c_int; - pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, - state: ::c_int) -> ::c_int; - pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] - pub fn sched_yield() -> ::c_int; - pub fn pthread_key_create(key: *mut pthread_key_t, - dtor: Option<unsafe extern fn(*mut ::c_void)>) - -> ::c_int; - pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; - pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; - pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) - -> ::c_int; - pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, - attr: *const pthread_mutexattr_t) -> ::c_int; - pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; - pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; - pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; - pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; - - pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pthread_mutexattr_destroy$UNIX2003")] - pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; - pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, - _type: ::c_int) -> ::c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pthread_cond_init$UNIX2003")] - pub fn pthread_cond_init(cond: *mut pthread_cond_t, - attr: *const pthread_condattr_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pthread_cond_wait$UNIX2003")] - pub fn pthread_cond_wait(cond: *mut pthread_cond_t, - lock: *mut pthread_mutex_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pthread_cond_timedwait$UNIX2003")] - pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, - lock: *mut pthread_mutex_t, - abstime: *const ::timespec) -> ::c_int; - pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; - pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; - pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; - pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int; - pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pthread_rwlock_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; - #[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 pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; - #[cfg_attr(all(target_os = "linux", 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 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(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; - #[cfg_attr(all(target_os = "macos", target_arch ="x86"), - link_name = "sigwait$UNIX2003")] - pub fn sigwait(set: *const sigset_t, - sig: *mut ::c_int) -> ::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(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 = "__locatime50")] - pub fn localtime(time: *const time_t) -> *mut tm; - - #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] - pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, - dev: ::dev_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; - pub fn uname(buf: *mut ::utsname) -> ::c_int; - pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; - pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; - 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 = "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; - #[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; - - pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; - pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; - pub fn sem_close(sem: *mut sem_t) -> ::c_int; - pub fn sem_unlink(name: *const ::c_char) -> ::c_int; - #[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 sem_init(sem: *mut sem_t, - pshared: ::c_int, - value: ::c_uint) - -> ::c_int; -} - -// TODO: get rid of this cfg(not(...)) -#[cfg(not(target_os = "android"))] // " if " -- appease style checker -extern { - #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] - #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] - pub fn glob(pattern: *const c_char, - flags: ::c_int, - errfunc: Option<extern fn(epath: *const c_char, - errno: ::c_int) -> ::c_int>, - pglob: *mut glob_t) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] - 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 getsid(pid: pid_t) -> pid_t; - pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - pub fn readlink(path: *const c_char, - buf: *mut c_char, - bufsz: ::size_t) - -> ::ssize_t; - - #[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; - pub fn sysconf(name: ::c_int) -> c_long; - #[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 mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; - - #[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(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(target_os = "netbsd", link_name = "__timegm50")] - pub fn timegm(tm: *mut ::tm) -> time_t; - pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; - pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; - #[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 tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; - pub fn mkstemp(template: *mut ::c_char) -> ::c_int; - pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; - pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; - pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; - pub fn nl_langinfo(item: ::nl_item) -> *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, ...); - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "nice$UNIX2003")] - pub fn nice(incr: ::c_int) -> ::c_int; -} - -cfg_if! { - if #[cfg(any(target_os = "linux", - target_os = "android", - target_os = "emscripten"))] { - mod notbsd; - pub use self::notbsd::*; - } else if #[cfg(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "openbsd", - target_os = "netbsd", - target_os = "bitrig"))] { - mod bsd; - pub use self::bsd::*; - } else if #[cfg(target_os = "solaris")] { - mod solaris; - pub use self::solaris::*; - } else if #[cfg(target_os = "haiku")] { - mod haiku; - pub use self::haiku::*; - } else { - // Unknown target_os - } -} diff --git a/src/vendor/libc/src/unix/notbsd/android/b32.rs b/src/vendor/libc/src/unix/notbsd/android/b32.rs deleted file mode 100644 index bd69ccf37d5..00000000000 --- a/src/vendor/libc/src/unix/notbsd/android/b32.rs +++ /dev/null @@ -1,151 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; -pub type mode_t = u16; -pub type off64_t = ::c_longlong; - -s! { - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_ulong, - pub sa_restorer: ::dox::Option<extern fn()>, - } - - 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_ulong, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::c_ulong, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::c_ulong, - pub st_ctime_nsec: ::c_ulong, - 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_ulong, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::c_ulong, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::c_ulong, - pub st_ctime_nsec: ::c_ulong, - pub st_ino: ::c_ulonglong, - } - - pub struct pthread_attr_t { - pub flags: ::uint32_t, - pub stack_base: *mut ::c_void, - pub stack_size: ::size_t, - pub guard_size: ::size_t, - pub sched_policy: ::int32_t, - pub sched_priority: ::int32_t, - } - - 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: ::uint32_t, - pub f_bsize: ::uint32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_fsid: ::__fsid_t, - pub f_namelen: ::uint32_t, - pub f_frsize: ::uint32_t, - pub f_flags: ::uint32_t, - pub f_spare: [::uint32_t; 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 SYS_gettid: ::c_long = 224; -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; - -extern { - pub fn timegm64(tm: *const ::tm) -> ::time64_t; -} diff --git a/src/vendor/libc/src/unix/notbsd/android/b64.rs b/src/vendor/libc/src/unix/notbsd/android/b64.rs deleted file mode 100644 index b35dde42160..00000000000 --- a/src/vendor/libc/src/unix/notbsd/android/b64.rs +++ /dev/null @@ -1,161 +0,0 @@ -// The following definitions are correct for aarch64 and may be wrong for x86_64 - -pub type c_long = i64; -pub type c_ulong = u64; -pub type mode_t = u32; -pub type off64_t = i64; - -s! { - pub struct sigaction { - pub sa_flags: ::c_uint, - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - _restorer: *mut ::c_void, - } - - 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_ulong, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_ulong, - __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_ulong, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_ulong, - __unused4: ::c_uint, - __unused5: ::c_uint, - } - - pub struct pthread_attr_t { - pub flags: ::uint32_t, - pub stack_base: *mut ::c_void, - pub stack_size: ::size_t, - pub guard_size: ::size_t, - pub sched_policy: ::int32_t, - pub sched_priority: ::int32_t, - __reserved: [::c_char; 16], - } - - 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], - } - - 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: ::uint64_t, - pub f_bsize: ::uint64_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_fsid: ::__fsid_t, - pub f_namelen: ::uint64_t, - pub f_frsize: ::uint64_t, - pub f_flags: ::uint64_t, - pub f_spare: [::uint64_t; 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 const SYS_gettid: ::c_long = 178; -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; - -extern { - pub fn timegm(tm: *const ::tm) -> ::time64_t; -} diff --git a/src/vendor/libc/src/unix/notbsd/android/mod.rs b/src/vendor/libc/src/unix/notbsd/android/mod.rs deleted file mode 100644 index efc136817db..00000000000 --- a/src/vendor/libc/src/unix/notbsd/android/mod.rs +++ /dev/null @@ -1,779 +0,0 @@ -//! Android-specific definitions for linux-like values - -use dox::mem; - -pub type c_char = u8; -pub type clock_t = ::c_long; -pub type time_t = ::c_long; -pub type suseconds_t = ::c_long; -pub type wchar_t = u32; -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 socklen_t = i32; -pub type pthread_t = ::c_long; -pub type pthread_mutexattr_t = ::c_long; -pub type pthread_condattr_t = ::c_long; -pub type sigset_t = ::c_ulong; -pub type time64_t = i64; // N/A on android -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; - -s! { - 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 rlimit64 { - pub rlim_cur: u64, - pub rlim_max: u64, - } - - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_flags: ::c_int, - pub ss_size: ::size_t - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - } - - pub struct __fsid_t { - __val: [::c_int; 2], - } - - pub struct msghdr { - pub msg_name: *mut ::c_void, - pub msg_namelen: ::c_int, - 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 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; ::NCCS], - } - - pub struct flock { - pub l_type: ::c_short, - pub l_whence: ::c_short, - pub l_start: ::off_t, - pub l_len: ::off_t, - pub l_pid: ::pid_t, - } - - pub struct 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, - } - - pub struct lastlog { - ll_time: ::time_t, - ll_line: [::c_char; UT_LINESIZE], - ll_host: [::c_char; UT_HOSTSIZE], - } - - pub struct exit_status { - pub e_termination: ::c_short, - pub e_exit: ::c_short, - } - - 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: [::int32_t; 4], - unused: [::c_char; 20], - } -} - -pub const USER_PROCESS: ::c_short = 7; - -pub const BUFSIZ: ::c_uint = 1024; -pub const FILENAME_MAX: ::c_uint = 1024; -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 = 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 = 14; -pub const _PC_NO_TRUNC: ::c_int = 15; -pub const _PC_VDISABLE: ::c_int = 16; - -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_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_MQ_PRIO_MAX: ::c_int = 51; -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_ONLN: ::c_int = 97; - -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 SA_ONSTACK: ::c_ulong = 0x08000000; -pub const SA_SIGINFO: ::c_ulong = 0x00000004; -pub const SA_NOCLDWAIT: ::c_ulong = 0x00000002; - -pub const SIGCHLD: ::c_int = 17; -pub const SIGBUS: ::c_int = 7; -pub const SIGUSR1: ::c_int = 10; -pub const SIGUSR2: ::c_int = 12; -pub const SIGCONT: ::c_int = 18; -pub const SIGSTOP: ::c_int = 19; -pub const SIGTSTP: ::c_int = 20; -pub const SIGURG: ::c_int = 23; -pub const SIGIO: ::c_int = 29; -pub const SIGSYS: ::c_int = 31; -pub const SIGSTKFLT: ::c_int = 16; -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 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 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_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 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_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_NDELAY: ::c_int = 0x800; - -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 IUTF8: ::tcflag_t = 0x00004000; -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 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 MADV_HUGEPAGE: ::c_int = 14; -pub const MADV_NOHUGEPAGE: ::c_int = 15; -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 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 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 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 RTLD_GLOBAL: ::c_int = 0x2; -pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RTLD_NOW: ::c_int = 0; -pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; - -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 SIGSTKSZ: ::size_t = 8192; -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 EAI_SYSTEM: ::c_int = 11; - -pub const NETLINK_ROUTE: ::c_int = 0; -pub const NETLINK_UNUSED: ::c_int = 1; -pub const NETLINK_USERSOCK: ::c_int = 2; -pub const NETLINK_FIREWALL: ::c_int = 3; -pub const NETLINK_SOCK_DIAG: ::c_int = 4; -pub const NETLINK_NFLOG: ::c_int = 5; -pub const NETLINK_XFRM: ::c_int = 6; -pub const NETLINK_SELINUX: ::c_int = 7; -pub const NETLINK_ISCSI: ::c_int = 8; -pub const NETLINK_AUDIT: ::c_int = 9; -pub const NETLINK_FIB_LOOKUP: ::c_int = 10; -pub const NETLINK_CONNECTOR: ::c_int = 11; -pub const NETLINK_NETFILTER: ::c_int = 12; -pub const NETLINK_IP6_FW: ::c_int = 13; -pub const NETLINK_DNRTMSG: ::c_int = 14; -pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15; -pub const NETLINK_GENERIC: ::c_int = 16; -pub const NETLINK_SCSITRANSPORT: ::c_int = 18; -pub const NETLINK_ECRYPTFS: ::c_int = 19; -pub const NETLINK_RDMA: ::c_int = 20; -pub const NETLINK_CRYPTO: ::c_int = 21; -pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG; - -pub const MAX_LINKS: ::c_int = 32; - -pub const NLM_F_REQUEST: ::c_int = 1; -pub const NLM_F_MULTI: ::c_int = 2; -pub const NLM_F_ACK: ::c_int = 4; -pub const NLM_F_ECHO: ::c_int = 8; -pub const NLM_F_DUMP_INTR: ::c_int = 16; - -pub const NLM_F_ROOT: ::c_int = 0x100; -pub const NLM_F_MATCH: ::c_int = 0x200; -pub const NLM_F_ATOMIC: ::c_int = 0x400; -pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH; - -pub const NLM_F_REPLACE: ::c_int = 0x100; -pub const NLM_F_EXCL: ::c_int = 0x200; -pub const NLM_F_CREATE: ::c_int = 0x400; -pub const NLM_F_APPEND: ::c_int = 0x800; - -pub const NLMSG_NOOP: ::c_int = 0x1; -pub const NLMSG_ERROR: ::c_int = 0x2; -pub const NLMSG_DONE: ::c_int = 0x3; -pub const NLMSG_OVERRUN: ::c_int = 0x4; -pub const NLMSG_MIN_TYPE: ::c_int = 0x10; - -pub const 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 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); - -f! { - pub fn sigemptyset(set: *mut sigset_t) -> ::c_int { - *set = 0; - return 0 - } - pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int { - *set |= signum as sigset_t; - return 0 - } - pub fn sigfillset(set: *mut sigset_t) -> ::c_int { - *set = !0; - return 0 - } - pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int { - *set &= !(signum as sigset_t); - return 0 - } - pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int { - (*set & (signum as sigset_t)) as ::c_int - } - pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t { - (*termios).c_cflag & ::CBAUD - } - pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t { - (*termios).c_cflag & ::CBAUD - } - pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int { - let cbaud = ::CBAUD; - (*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud); - return 0 - } - pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int { - let cbaud = ::CBAUD; - (*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud); - return 0 - } - pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int { - ioctl(fd, ::TCGETS, termios) - } - pub fn tcsetattr(fd: ::c_int, - optional_actions: ::c_int, - termios: *const ::termios) -> ::c_int { - ioctl(fd, optional_actions, termios) - } - pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int { - ioctl(fd, ::TCXONC, action as *mut ::c_void) - } - pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int { - ioctl(fd, ::TCFLSH, action as *mut ::c_void) - } - pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int { - ioctl(fd, TCSBRKP, duration as *mut ::c_void) - } - - 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 - } -} - -extern { - static mut __progname: *mut ::c_char; -} - -extern { - pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; - pub fn readlink(path: *const ::c_char, - buf: *mut ::c_char, - bufsz: ::size_t) - -> ::c_int; - pub fn msync(addr: *const ::c_void, len: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; - pub fn sysconf(name: ::c_int) -> ::c_long; - pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *const ::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: ::c_int) -> ::c_int; - pub fn setpriority(which: ::c_int, who: ::c_int, 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: *mut 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; -} - -cfg_if! { - if #[cfg(target_pointer_width = "32")] { - mod b32; - pub use self::b32::*; - } else if #[cfg(target_pointer_width = "64")] { - mod b64; - pub use self::b64::*; - } else { - // Unknown target_pointer_width - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/mips.rs b/src/vendor/libc/src/unix/notbsd/linux/mips.rs deleted file mode 100644 index 085f2b31ce6..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/mips.rs +++ /dev/null @@ -1,651 +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: ::c_ulong, - st_pad1: [::c_long; 3], - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::c_ulong, - pub st_pad2: [::c_long; 2], - pub st_size: ::off_t, - st_pad3: ::c_long, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, - st_pad5: [::c_long; 14], - } - - pub struct stat64 { - pub st_dev: ::c_ulong, - st_pad1: [::c_long; 3], - pub st_ino: ::ino64_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::c_ulong, - st_pad2: [::c_long; 2], - pub st_size: ::off64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - st_pad3: ::c_long, - pub st_blocks: ::blkcnt64_t, - st_pad5: [::c_long; 14], - } - - pub struct pthread_attr_t { - __size: [u32; 9] - } - - pub struct sigaction { - pub sa_flags: ::c_int, - pub sa_sigaction: ::sighandler_t, - pub sa_mask: sigset_t, - _restorer: *mut ::c_void, - _resv: [::c_int; 1], - } - - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_size: ::size_t, - pub ss_flags: ::c_int, - } - - pub struct sigset_t { - __val: [::c_ulong; 32], - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_code: ::c_int, - pub si_errno: ::c_int, - pub _pad: [::c_int; 29], - } - - pub struct 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: ::size_t, - pub msg_control: *mut ::c_void, - pub msg_controllen: ::size_t, - pub msg_flags: ::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], - } - - // 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], - } -} - -pub const BUFSIZ: ::c_uint = 8192; -pub const TMP_MAX: ::c_uint = 238328; -pub const FOPEN_MAX: ::c_uint = 16; -pub const POSIX_FADV_DONTNEED: ::c_int = 4; -pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; -pub const _SC_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 = 16; -pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; - -pub const O_APPEND: ::c_int = 8; -pub const O_CREAT: ::c_int = 256; -pub const O_EXCL: ::c_int = 1024; -pub const O_NOCTTY: ::c_int = 2048; -pub const O_NONBLOCK: ::c_int = 128; -pub const O_SYNC: ::c_int = 0x4010; -pub const O_RSYNC: ::c_int = 0x4010; -pub const O_DSYNC: ::c_int = 0x10; -pub const O_FSYNC: ::c_int = 0x4010; -pub const O_ASYNC: ::c_int = 0x1000; -pub const O_NDELAY: ::c_int = 0x80; - -pub const SOCK_NONBLOCK: ::c_int = 128; - -pub const EDEADLK: ::c_int = 45; -pub const ENAMETOOLONG: ::c_int = 78; -pub const ENOLCK: ::c_int = 46; -pub const ENOSYS: ::c_int = 89; -pub const ENOTEMPTY: ::c_int = 93; -pub const ELOOP: ::c_int = 90; -pub const ENOMSG: ::c_int = 35; -pub const EIDRM: ::c_int = 36; -pub const ECHRNG: ::c_int = 37; -pub const EL2NSYNC: ::c_int = 38; -pub const EL3HLT: ::c_int = 39; -pub const EL3RST: ::c_int = 40; -pub const ELNRNG: ::c_int = 41; -pub const EUNATCH: ::c_int = 42; -pub const ENOCSI: ::c_int = 43; -pub const EL2HLT: ::c_int = 44; -pub const EBADE: ::c_int = 50; -pub const EBADR: ::c_int = 51; -pub const EXFULL: ::c_int = 52; -pub const ENOANO: ::c_int = 53; -pub const EBADRQC: ::c_int = 54; -pub const EBADSLT: ::c_int = 55; -pub const EDEADLOCK: ::c_int = 56; -pub const EMULTIHOP: ::c_int = 74; -pub const EOVERFLOW: ::c_int = 79; -pub const ENOTUNIQ: ::c_int = 80; -pub const EBADFD: ::c_int = 81; -pub const EBADMSG: ::c_int = 77; -pub const EREMCHG: ::c_int = 82; -pub const ELIBACC: ::c_int = 83; -pub const ELIBBAD: ::c_int = 84; -pub const ELIBSCN: ::c_int = 85; -pub const ELIBMAX: ::c_int = 86; -pub const ELIBEXEC: ::c_int = 87; -pub const EILSEQ: ::c_int = 88; -pub const ERESTART: ::c_int = 91; -pub const ESTRPIPE: ::c_int = 92; -pub const EUSERS: ::c_int = 94; -pub const ENOTSOCK: ::c_int = 95; -pub const EDESTADDRREQ: ::c_int = 96; -pub const EMSGSIZE: ::c_int = 97; -pub const EPROTOTYPE: ::c_int = 98; -pub const ENOPROTOOPT: ::c_int = 99; -pub const EPROTONOSUPPORT: ::c_int = 120; -pub const ESOCKTNOSUPPORT: ::c_int = 121; -pub const EOPNOTSUPP: ::c_int = 122; -pub const EPFNOSUPPORT: ::c_int = 123; -pub const EAFNOSUPPORT: ::c_int = 124; -pub const EADDRINUSE: ::c_int = 125; -pub const EADDRNOTAVAIL: ::c_int = 126; -pub const ENETDOWN: ::c_int = 127; -pub const ENETUNREACH: ::c_int = 128; -pub const ENETRESET: ::c_int = 129; -pub const ECONNABORTED: ::c_int = 130; -pub const ECONNRESET: ::c_int = 131; -pub const ENOBUFS: ::c_int = 132; -pub const EISCONN: ::c_int = 133; -pub const ENOTCONN: ::c_int = 134; -pub const ESHUTDOWN: ::c_int = 143; -pub const ETOOMANYREFS: ::c_int = 144; -pub const ETIMEDOUT: ::c_int = 145; -pub const ECONNREFUSED: ::c_int = 146; -pub const EHOSTDOWN: ::c_int = 147; -pub const EHOSTUNREACH: ::c_int = 148; -pub const EALREADY: ::c_int = 149; -pub const EINPROGRESS: ::c_int = 150; -pub const ESTALE: ::c_int = 151; -pub const EUCLEAN: ::c_int = 135; -pub const ENOTNAM: ::c_int = 137; -pub const ENAVAIL: ::c_int = 138; -pub const EISNAM: ::c_int = 139; -pub const EREMOTEIO: ::c_int = 140; -pub const EDQUOT: ::c_int = 1133; -pub const ENOMEDIUM: ::c_int = 159; -pub const EMEDIUMTYPE: ::c_int = 160; -pub const ECANCELED: ::c_int = 158; -pub const ENOKEY: ::c_int = 161; -pub const EKEYEXPIRED: ::c_int = 162; -pub const EKEYREVOKED: ::c_int = 163; -pub const EKEYREJECTED: ::c_int = 164; -pub const EOWNERDEAD: ::c_int = 165; -pub const ENOTRECOVERABLE: ::c_int = 166; -pub const ERFKILL: ::c_int = 167; - -pub const LC_PAPER: ::c_int = 7; -pub const LC_NAME: ::c_int = 8; -pub const LC_ADDRESS: ::c_int = 9; -pub const LC_TELEPHONE: ::c_int = 10; -pub const LC_MEASUREMENT: ::c_int = 11; -pub const LC_IDENTIFICATION: ::c_int = 12; -pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); -pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); -pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); -pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); -pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); -pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); -pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK - | ::LC_NUMERIC_MASK - | ::LC_TIME_MASK - | ::LC_COLLATE_MASK - | ::LC_MONETARY_MASK - | ::LC_MESSAGES_MASK - | LC_PAPER_MASK - | LC_NAME_MASK - | LC_ADDRESS_MASK - | LC_TELEPHONE_MASK - | LC_MEASUREMENT_MASK - | LC_IDENTIFICATION_MASK; - -pub const MAP_NORESERVE: ::c_int = 0x400; -pub const MAP_ANON: ::c_int = 0x800; -pub const MAP_ANONYMOUS: ::c_int = 0x800; -pub const MAP_GROWSDOWN: ::c_int = 0x1000; -pub const MAP_DENYWRITE: ::c_int = 0x2000; -pub const MAP_EXECUTABLE: ::c_int = 0x4000; -pub const MAP_LOCKED: ::c_int = 0x8000; -pub const MAP_POPULATE: ::c_int = 0x10000; -pub const MAP_NONBLOCK: ::c_int = 0x20000; -pub const MAP_STACK: ::c_int = 0x40000; - -pub const 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 = 4; -pub const SO_REUSEPORT: ::c_int = 0x200; -pub const SO_TYPE: ::c_int = 4104; -pub const SO_ERROR: ::c_int = 4103; -pub const SO_DONTROUTE: ::c_int = 16; -pub const SO_BROADCAST: ::c_int = 32; -pub const SO_SNDBUF: ::c_int = 4097; -pub const SO_RCVBUF: ::c_int = 4098; -pub const SO_KEEPALIVE: ::c_int = 8; -pub const SO_OOBINLINE: ::c_int = 256; -pub const SO_LINGER: ::c_int = 128; -pub const SO_RCVLOWAT: ::c_int = 4100; -pub const SO_SNDLOWAT: ::c_int = 4099; -pub const SO_RCVTIMEO: ::c_int = 4102; -pub const SO_SNDTIMEO: ::c_int = 4101; -pub const SO_ACCEPTCONN: ::c_int = 4105; - -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 FIOCLEX: ::c_ulong = 0x6601; -pub const FIONBIO: ::c_ulong = 0x667e; - -pub const SA_ONSTACK: ::c_int = 0x08000000; -pub const SA_SIGINFO: ::c_int = 0x00000008; -pub const SA_NOCLDWAIT: ::c_int = 0x00010000; - -pub const SIGCHLD: ::c_int = 18; -pub const SIGBUS: ::c_int = 10; -pub const SIGTTIN: ::c_int = 26; -pub const SIGTTOU: ::c_int = 27; -pub const SIGXCPU: ::c_int = 30; -pub const SIGXFSZ: ::c_int = 31; -pub const SIGVTALRM: ::c_int = 28; -pub const SIGPROF: ::c_int = 29; -pub const SIGWINCH: ::c_int = 20; -pub const SIGUSR1: ::c_int = 16; -pub const SIGUSR2: ::c_int = 17; -pub const SIGCONT: ::c_int = 25; -pub const SIGSTOP: ::c_int = 23; -pub const SIGTSTP: ::c_int = 24; -pub const SIGURG: ::c_int = 21; -pub const SIGIO: ::c_int = 22; -pub const SIGSYS: ::c_int = 12; -pub const SIGPOLL: ::c_int = 22; -pub const SIGPWR: ::c_int = 19; -pub const SIG_SETMASK: ::c_int = 3; -pub const SIG_BLOCK: ::c_int = 0x1; -pub const SIG_UNBLOCK: ::c_int = 0x2; - -pub const 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 = 131072; - -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 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 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 SYS_gettid: ::c_long = 4222; // Valid for O32 - -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: ::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; - -#[link(name = "util")] -extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; - pub fn backtrace(buf: *mut *mut ::c_void, - sz: ::c_int) -> ::c_int; - pub fn glob64(pattern: *const ::c_char, - flags: ::c_int, - errfunc: ::dox::Option<extern fn(epath: *const ::c_char, - errno: ::c_int) - -> ::c_int>, - pglob: *mut glob64_t) -> ::c_int; - pub fn globfree64(pglob: *mut glob64_t); - pub fn ptrace(request: ::c_uint, ...) -> ::c_long; - pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t) -> ::c_int; - pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t) -> ::c_int; -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/mips64.rs b/src/vendor/libc/src/unix/notbsd/linux/mips64.rs deleted file mode 100644 index 30c336e6904..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/mips64.rs +++ /dev/null @@ -1,240 +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 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], - } - - // FIXME this is actually a union - pub struct sem_t { - __size: [::c_char; 32], - __align: [::c_long; 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 EADDRINUSE: ::c_int = 125; -pub const EADDRNOTAVAIL: ::c_int = 126; -pub const ECONNABORTED: ::c_int = 130; -pub const ECONNREFUSED: ::c_int = 146; -pub const ECONNRESET: ::c_int = 131; -pub const EDEADLK: ::c_int = 45; -pub const ENOSYS: ::c_int = 89; -pub const ENOTCONN: ::c_int = 134; -pub const ETIMEDOUT: ::c_int = 145; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONBIO: ::c_ulong = 0x667e; -pub const MAP_ANON: ::c_int = 0x800; -pub const O_ACCMODE: ::c_int = 3; -pub const O_APPEND: ::c_int = 8; -pub const O_CREAT: ::c_int = 256; -pub const O_EXCL: ::c_int = 1024; -pub const O_NONBLOCK: ::c_int = 128; -pub const POSIX_FADV_DONTNEED: ::c_int = 4; -pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const PTHREAD_STACK_MIN: ::size_t = 131072; -pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; -pub const RLIM_INFINITY: ::rlim_t = 0xffffffffffffffff; -pub const SA_ONSTACK: ::c_int = 0x08000000; -pub const SA_SIGINFO: ::c_int = 0x00000008; -pub const SIGBUS: ::c_int = 10; -pub const SIGSYS: ::c_int = 12; -pub const SIGSTKSZ: ::size_t = 0x2000; -pub const SIG_SETMASK: ::c_int = 3; -pub const SOCK_DGRAM: ::c_int = 1; -pub const SOCK_STREAM: ::c_int = 2; -pub const SOL_SOCKET: ::c_int = 0xffff; -pub const SO_BROADCAST: ::c_int = 32; -pub const SO_ERROR: ::c_int = 4103; -pub const SO_RCVTIMEO: ::c_int = 4102; -pub const SO_REUSEADDR: ::c_int = 4; -pub const SO_SNDTIMEO: ::c_int = 4101; -pub const SO_REUSEPORT: ::c_int = 0x200; -pub const SO_SNDBUF: ::c_int = 4097; -pub const SO_RCVBUF: ::c_int = 4098; -pub const SO_KEEPALIVE: ::c_int = 8; - -#[link(name = "util")] -extern { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/mod.rs deleted file mode 100644 index ea820ea5c6c..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/mod.rs +++ /dev/null @@ -1,747 +0,0 @@ -//! Linux-specific definitions for linux-like values - -use dox::mem; - -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 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 enum fpos64_t {} // TODO: fill this out with a struct - -s! { - 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 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_mutex_t { - #[cfg(any(target_arch = "mips", target_arch = "mipsel", - target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", - 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 = "mipsel", - target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", - 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"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x")))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - - pub struct pthread_cond_t { - #[cfg(any(target_env = "musl"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(target_env = "musl")))] - __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], - } - - 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: ::uint64_t, - pub dqb_bsoftlimit: ::uint64_t, - pub dqb_curspace: ::uint64_t, - pub dqb_ihardlimit: ::uint64_t, - pub dqb_isoftlimit: ::uint64_t, - pub dqb_curinodes: ::uint64_t, - pub dqb_btime: ::uint64_t, - pub dqb_itime: ::uint64_t, - pub dqb_valid: ::uint32_t, - } - - pub struct signalfd_siginfo { - pub ssi_signo: ::uint32_t, - pub ssi_errno: ::int32_t, - pub ssi_code: ::int32_t, - pub ssi_pid: ::uint32_t, - pub ssi_uid: ::uint32_t, - pub ssi_fd: ::int32_t, - pub ssi_tid: ::uint32_t, - pub ssi_band: ::uint32_t, - pub ssi_overrun: ::uint32_t, - pub ssi_trapno: ::uint32_t, - pub ssi_status: ::int32_t, - pub ssi_int: ::int32_t, - pub ssi_ptr: ::uint64_t, - pub ssi_utime: ::uint64_t, - pub ssi_stime: ::uint64_t, - pub ssi_addr: ::uint64_t, - _pad: [::uint8_t; 48], - } - - pub struct fsid_t { - __val: [::c_int; 2], - } - - 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 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 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 CLONE_NEWCGROUP: ::c_int = 0x02000000; - -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 _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; - -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_MUTEX_T], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_COND_T], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], -}; -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 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 EPOLLONESHOT: ::c_int = 0x40000000; - -pub const QFMT_VFS_OLD: ::c_int = 1; -pub const QFMT_VFS_V0: ::c_int = 2; - -pub const SFD_CLOEXEC: ::c_int = 0x080000; - -pub const EFD_SEMAPHORE: ::c_int = 0x1; - -pub const NCCS: usize = 32; - -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 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; - -f! { - 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 - } -} - -extern { - pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; - - pub fn setpwent(); - 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 fallocate(fd: ::c_int, mode: ::c_int, - offset: ::off_t, len: ::off_t) -> ::c_int; - pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, - len: ::off_t) -> ::c_int; - pub fn readahead(fd: ::c_int, offset: ::off64_t, - count: ::size_t) -> ::ssize_t; - pub fn getxattr(path: *const c_char, name: *const c_char, - value: *mut ::c_void, size: ::size_t) -> ::ssize_t; - pub fn lgetxattr(path: *const c_char, name: *const c_char, - value: *mut ::c_void, size: ::size_t) -> ::ssize_t; - pub fn fgetxattr(filedes: ::c_int, name: *const c_char, - value: *mut ::c_void, size: ::size_t) -> ::ssize_t; - pub fn setxattr(path: *const c_char, name: *const c_char, - value: *const ::c_void, size: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn lsetxattr(path: *const c_char, name: *const c_char, - value: *const ::c_void, size: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn fsetxattr(filedes: ::c_int, name: *const c_char, - value: *const ::c_void, size: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn listxattr(path: *const c_char, list: *mut c_char, - size: ::size_t) -> ::ssize_t; - pub fn llistxattr(path: *const c_char, list: *mut c_char, - size: ::size_t) -> ::ssize_t; - pub fn flistxattr(filedes: ::c_int, list: *mut c_char, - size: ::size_t) -> ::ssize_t; - pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; - pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; - pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; - pub fn signalfd(fd: ::c_int, - mask: *const ::sigset_t, - flags: ::c_int) -> ::c_int; - pub fn pwritev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int, - offset: ::off_t) -> ::ssize_t; - pub fn preadv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int, - offset: ::off_t) -> ::ssize_t; - pub fn quotactl(cmd: ::c_int, - special: *const ::c_char, - id: ::c_int, - data: *mut ::c_char) -> ::c_int; - pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; - pub fn mq_close(mqd: ::mqd_t) -> ::c_int; - pub fn mq_unlink(name: *const ::c_char) -> ::c_int; - pub fn mq_receive(mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msq_prio: *mut ::c_uint) -> ::ssize_t; - pub fn mq_send(mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msq_prio: ::c_uint) -> ::c_int; - pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; - pub fn mq_setattr(mqd: ::mqd_t, - newattr: *const ::mq_attr, - oldattr: *mut ::mq_attr) -> ::c_int; - pub fn epoll_pwait(epfd: ::c_int, - events: *mut ::epoll_event, - maxevents: ::c_int, - timeout: ::c_int, - sigmask: *const ::sigset_t) -> ::c_int; - pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; - pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::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 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 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 prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, - old_limit: *mut ::rlimit) -> ::c_int; - pub fn prlimit64(pid: ::pid_t, - resource: ::c_int, - new_limit: *const ::rlimit64, - old_limit: *mut ::rlimit64) -> ::c_int; - pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; - pub fn process_vm_readv(pid: ::pid_t, - local_iov: *const ::iovec, - liovcnt: ::c_ulong, - remote_iov: *const ::iovec, - riovcnt: ::c_ulong, - flags: ::c_ulong) -> isize; - pub fn process_vm_writev(pid: ::pid_t, - local_iov: *const ::iovec, - liovcnt: ::c_ulong, - remote_iov: *const ::iovec, - riovcnt: ::c_ulong, - flags: ::c_ulong) -> isize; - pub fn reboot(how_to: ::c_int) -> ::c_int; - - // 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); -} - -cfg_if! { - if #[cfg(any(target_env = "musl", - target_os = "emscripten"))] { - mod musl; - pub use self::musl::*; - } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { - mod mips; - pub use self::mips::*; - } else if #[cfg(any(target_arch = "s390x"))] { - mod s390x; - pub use self::s390x::*; - } else if #[cfg(any(target_arch = "mips64"))] { - mod mips64; - pub use self::mips64::*; - } else { - mod other; - pub use self::other::*; - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/arm.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b32/arm.rs deleted file mode 100644 index 998580d3e21..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/arm.rs +++ /dev/null @@ -1,336 +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 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 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 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 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; -pub const SYS_perf_event_open: ::c_long = 364; - -pub const POLLWRNORM: ::c_short = 0x100; -pub const POLLWRBAND: ::c_short = 0x200; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/asmjs.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b32/asmjs.rs deleted file mode 100644 index 91a96c185a9..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/asmjs.rs +++ /dev/null @@ -1,335 +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 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 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 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 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; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/mips.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b32/mips.rs deleted file mode 100644 index 9ebfe4a68fe..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/mips.rs +++ /dev/null @@ -1,344 +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 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 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 FIOCLEX: ::c_int = 0x6601; -pub const FIONBIO: ::c_int = 0x667E; - -pub const RLIMIT_RSS: ::c_int = 7; -pub const RLIMIT_NOFILE: ::c_int = 5; -pub const RLIMIT_AS: ::c_int = 6; -pub const RLIMIT_NPROC: ::c_int = 8; -pub const RLIMIT_MEMLOCK: ::c_int = 9; - -pub const 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 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_TYPE: ::c_int = 0x1008; -pub const SO_ERROR: ::c_int = 0x1007; -pub const SO_DONTROUTE: ::c_int = 0x0010; -pub const SO_BROADCAST: ::c_int = 0x0020; -pub const SO_SNDBUF: ::c_int = 0x1001; -pub const SO_RCVBUF: ::c_int = 0x1002; -pub const SO_KEEPALIVE: ::c_int = 0x0008; -pub const SO_OOBINLINE: ::c_int = 0x0100; -pub const SO_LINGER: ::c_int = 0x0080; -pub const SO_REUSEPORT: ::c_int = 0x200; -pub const SO_RCVLOWAT: ::c_int = 0x1004; -pub const SO_SNDLOWAT: ::c_int = 0x1003; -pub const SO_RCVTIMEO: ::c_int = 0x1006; -pub const SO_SNDTIMEO: ::c_int = 0x1005; -pub const SO_ACCEPTCONN: ::c_int = 0x1009; - -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 SYS_gettid: ::c_long = 4222; // Valid for O32 -pub const SYS_perf_event_open: ::c_long = 4333; // Valid for O32 - -pub const POLLWRNORM: ::c_short = 0x4; -pub const POLLWRBAND: ::c_short = 0x100; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b32/mod.rs deleted file mode 100644 index 899bc693109..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/mod.rs +++ /dev/null @@ -1,50 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; -pub type nlink_t = u32; - -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 sem_t { - __val: [::c_int; 4], - } -} - -pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; - -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 = "asmjs", target_arch = "wasm32"))] { - // For the time being asmjs and wasm32 are the same, and both - // backed by identical emscripten runtimes - mod asmjs; - pub use self::asmjs::*; - } else { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/x86.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b32/x86.rs deleted file mode 100644 index 194b8fd8bdc..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b32/x86.rs +++ /dev/null @@ -1,350 +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 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 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], - } - - 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 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 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 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 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 SYS_gettid: ::c_long = 224; -pub const SYS_perf_event_open: ::c_long = 336; - -pub const POLLWRNORM: ::c_short = 0x100; -pub const POLLWRBAND: ::c_short = 0x200; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs deleted file mode 100644 index 23f7dd35e5c..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub type c_char = u8; - -pub const SYS_perf_event_open: ::c_long = 241; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b64/mod.rs deleted file mode 100644 index fdaf52e166c..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/mod.rs +++ /dev/null @@ -1,370 +0,0 @@ -pub type wchar_t = i32; -pub type c_long = i64; -pub type c_ulong = u64; -pub type nlink_t = u64; - -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 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 sem_t { - __val: [::c_int; 8], - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } -} - -pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; - -pub const O_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 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 MAP_32BIT: ::c_int = 0x0040; - -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 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 = 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; - -cfg_if! { - if #[cfg(target_arch = "aarch64")] { - mod aarch64; - pub use self::aarch64::*; - } else if #[cfg(any(target_arch = "powerpc64"))] { - mod powerpc64; - pub use self::powerpc64::*; - } else if #[cfg(any(target_arch = "x86_64"))] { - mod x86_64; - pub use self::x86_64::*; - } else { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs deleted file mode 100644 index 4b8ca10aab5..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub type c_char = u8; - -pub const SYS_perf_event_open: ::c_long = 319; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs deleted file mode 100644 index 2cfd903ca84..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub type c_char = i8; - -s! { - pub struct mcontext_t { - __private: [u64; 32], - } - - 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], - } -} - -pub const SYS_gettid: ::c_long = 186; - -pub const SYS_perf_event_open: ::c_long = 298; diff --git a/src/vendor/libc/src/unix/notbsd/linux/musl/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/musl/mod.rs deleted file mode 100644 index 69a85b86eaa..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/musl/mod.rs +++ /dev/null @@ -1,245 +0,0 @@ -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 blksize_t = c_long; -pub type fsblkcnt_t = ::c_ulonglong; -pub type fsfilcnt_t = ::c_ulonglong; -pub type rlim_t = ::c_ulonglong; - -s! { - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_int, - _restorer: *mut ::c_void, - } - - 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 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 const BUFSIZ: ::c_uint = 1024; -pub const TMP_MAX: ::c_uint = 10000; -pub const FOPEN_MAX: ::c_uint = 1000; -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 RLIMIT_NLIMITS: ::c_int = 16; - -pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; - -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 FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; -pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; - -pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; - -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 PTRACE_O_EXITKILL: ::c_int = 1048576; -pub const PTRACE_O_TRACECLONE: ::c_int = 8; -pub const PTRACE_O_TRACEEXEC: ::c_int = 16; -pub const PTRACE_O_TRACEEXIT: ::c_int = 64; -pub const PTRACE_O_TRACEFORK: ::c_int = 2; -pub const PTRACE_O_TRACESYSGOOD: ::c_int = 1; -pub const PTRACE_O_TRACEVFORK: ::c_int = 4; -pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 32; -pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 2097152; - -pub const MADV_DODUMP: ::c_int = 17; -pub const MADV_DONTDUMP: ::c_int = 16; - -pub const EPOLLWAKEUP: ::c_int = 0x20000000; - -pub const POLLRDNORM: ::c_short = 0x040; -pub const POLLRDBAND: ::c_short = 0x080; - -pub const MADV_HUGEPAGE: ::c_int = 14; -pub const MADV_NOHUGEPAGE: ::c_int = 15; - -pub const PTRACE_GETFPREGS: ::c_uint = 14; -pub const PTRACE_SETFPREGS: ::c_uint = 15; -pub const PTRACE_GETFPXREGS: ::c_uint = 18; -pub const PTRACE_SETFPXREGS: ::c_uint = 19; -pub const PTRACE_GETREGS: ::c_uint = 12; -pub const PTRACE_SETREGS: ::c_uint = 13; - -pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; - -pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; - -pub const TCSANOW: ::c_int = 0; -pub const TCSADRAIN: ::c_int = 1; -pub const TCSAFLUSH: ::c_int = 2; - -pub const TIOCINQ: ::c_int = ::FIONREAD; - -pub const RTLD_GLOBAL: ::c_int = 0x100; -pub const RTLD_NOLOAD: ::c_int = 0x4; - -// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux -// kernel 3.10). See also notbsd/mod.rs -pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; -pub const CLOCK_TAI: ::clockid_t = 11; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const SIGSTKSZ: ::size_t = 8192; -pub const 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; - -extern { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; - pub fn ptrace(request: ::c_int, ...) -> ::c_long; - pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; - pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; -} - -cfg_if! { - if #[cfg(any(target_arch = "x86_64"))] { - mod b64; - pub use self::b64::*; - } else if #[cfg(any(target_arch = "x86", - target_arch = "mips", - target_arch = "arm", - target_arch = "asmjs", - target_arch = "wasm32"))] { - mod b32; - pub use self::b32::*; - } else { } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b32/arm.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b32/arm.rs deleted file mode 100644 index 2c6fbcd6e3f..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b32/arm.rs +++ /dev/null @@ -1,168 +0,0 @@ -pub type c_char = u8; -pub type wchar_t = u32; - -s! { - pub struct ipc_perm { - pub __key: ::key_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - pub cuid: ::uid_t, - pub cgid: ::gid_t, - pub mode: ::c_ushort, - __pad1: ::c_ushort, - pub __seq: ::c_ushort, - __pad2: ::c_ushort, - __unused1: ::c_ulong, - __unused2: ::c_ulong - } - - pub struct stat64 { - pub st_dev: ::dev_t, - __pad1: ::c_uint, - __st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __pad2: ::c_uint, - pub st_size: ::off64_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_ino: ::ino64_t, - } - - pub struct 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 const O_DIRECT: ::c_int = 0x10000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; - -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; - -pub const EDEADLOCK: ::c_int = 35; - -pub const SO_PEERCRED: ::c_int = 17; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; - -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONBIO: ::c_ulong = 0x5421; - -pub const SYS_gettid: ::c_long = 224; -pub const SYS_perf_event_open: ::c_long = 364; - -pub const PTRACE_GETFPXREGS: ::c_uint = 18; -pub const PTRACE_SETFPXREGS: ::c_uint = 19; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const SIGSTKSZ: ::size_t = 8192; -pub const 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 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; diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b32/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b32/mod.rs deleted file mode 100644 index 48c3502ada1..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b32/mod.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! 32-bit specific definitions for linux-like values - -pub type c_long = i32; -pub type c_ulong = u32; -pub type clock_t = i32; -pub type time_t = i32; -pub type suseconds_t = i32; -pub type ino_t = u32; -pub type off_t = i32; -pub type blkcnt_t = i32; -pub type __fsword_t = i32; - -pub type blksize_t = i32; -pub type nlink_t = u32; - -s! { - pub struct stat { - pub st_dev: ::dev_t, - __pad1: ::c_short, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __pad2: ::c_short, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused4: ::c_long, - __unused5: ::c_long, - } - - pub struct pthread_attr_t { - __size: [u32; 9] - } - - pub struct sigset_t { - __val: [::c_ulong; 32], - } - - pub struct sysinfo { - pub uptime: ::c_long, - pub loads: [::c_ulong; 3], - pub totalram: ::c_ulong, - pub freeram: ::c_ulong, - pub sharedram: ::c_ulong, - pub bufferram: ::c_ulong, - pub totalswap: ::c_ulong, - pub freeswap: ::c_ulong, - pub procs: ::c_ushort, - pub pad: ::c_ushort, - pub totalhigh: ::c_ulong, - pub freehigh: ::c_ulong, - pub mem_unit: ::c_uint, - pub _f: [::c_char; 8], - } -} - -pub const __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 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; - -cfg_if! { - if #[cfg(target_arch = "x86")] { - mod x86; - pub use self::x86::*; - } else if #[cfg(target_arch = "arm")] { - mod arm; - pub use self::arm::*; - } else if #[cfg(target_arch = "powerpc")] { - mod powerpc; - pub use self::powerpc::*; - } else { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b32/powerpc.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b32/powerpc.rs deleted file mode 100644 index 3125e9f337d..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b32/powerpc.rs +++ /dev/null @@ -1,165 +0,0 @@ -pub type c_char = u8; -pub type wchar_t = i32; - -s! { - pub struct ipc_perm { - __key: ::key_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - pub cuid: ::uid_t, - pub cgid: ::gid_t, - pub mode: ::mode_t, - __seq: ::uint32_t, - __pad1: ::uint32_t, - __glibc_reserved1: ::uint64_t, - __glibc_reserved2: ::uint64_t, - } - - 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 shmid_ds { - pub shm_perm: ::ipc_perm, - __glibc_reserved1: ::c_uint, - pub shm_atime: ::time_t, - __glibc_reserved2: ::c_uint, - pub shm_dtime: ::time_t, - __glibc_reserved3: ::c_uint, - pub shm_ctime: ::time_t, - __glibc_reserved4: ::c_uint, - pub shm_segsz: ::size_t, - pub shm_cpid: ::pid_t, - pub shm_lpid: ::pid_t, - pub shm_nattch: ::shmatt_t, - __glibc_reserved5: ::c_ulong, - __glibc_reserved6: ::c_ulong, - } - - pub struct msqid_ds { - pub msg_perm: ::ipc_perm, - __glibc_reserved1: ::c_uint, - pub msg_stime: ::time_t, - __glibc_reserved2: ::c_uint, - pub msg_rtime: ::time_t, - __glibc_reserved3: ::c_uint, - pub msg_ctime: ::time_t, - __msg_cbytes: ::c_ulong, - pub msg_qnum: ::msgqnum_t, - pub msg_qbytes: ::msglen_t, - pub msg_lspid: ::pid_t, - pub msg_lrpid: ::pid_t, - __glibc_reserved4: ::c_ulong, - __glibc_reserved5: ::c_ulong, - } -} - -pub const O_DIRECT: ::c_int = 0x20000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; - -pub const MAP_LOCKED: ::c_int = 0x00080; -pub const MAP_NORESERVE: ::c_int = 0x00040; - -pub const EDEADLOCK: ::c_int = 58; - -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 FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONBIO: ::c_ulong = 0x8004667e; - -pub const SYS_gettid: ::c_long = 207; -pub const SYS_perf_event_open: ::c_long = 319; - -pub const MCL_CURRENT: ::c_int = 0x2000; -pub const MCL_FUTURE: ::c_int = 0x4000; - -pub const SIGSTKSZ: ::size_t = 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 = 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 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; diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b32/x86.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b32/x86.rs deleted file mode 100644 index 86abd1eb103..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b32/x86.rs +++ /dev/null @@ -1,213 +0,0 @@ -pub type c_char = i8; -pub type wchar_t = i32; -pub type greg_t = i32; - -s! { - pub struct _libc_fpreg { - pub significand: [u16; 4], - pub exponent: u16, - } - - pub struct _libc_fpstate { - pub cw: ::c_ulong, - pub sw: ::c_ulong, - pub tag: ::c_ulong, - pub ipoff: ::c_ulong, - pub cssel: ::c_ulong, - pub dataoff: ::c_ulong, - pub datasel: ::c_ulong, - pub _st: [_libc_fpreg; 8], - pub status: ::c_ulong, - } - - pub struct mcontext_t { - pub gregs: [greg_t; 19], - pub fpregs: *mut _libc_fpstate, - pub oldmask: ::c_ulong, - pub cr2: ::c_ulong, - } - - 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], - } - - 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 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 const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; - -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; -pub const MAP_32BIT: ::c_int = 0x0040; - -pub const EDEADLOCK: ::c_int = 35; - -pub const SO_PEERCRED: ::c_int = 17; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; - -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONBIO: ::c_ulong = 0x5421; - -pub const SYS_gettid: ::c_long = 224; -pub const SYS_perf_event_open: ::c_long = 336; - -pub const PTRACE_GETFPXREGS: ::c_uint = 18; -pub const PTRACE_SETFPXREGS: ::c_uint = 19; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const SIGSTKSZ: ::size_t = 8192; -pub const 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 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; - -extern { - pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; - pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; - pub fn makecontext(ucp: *mut ucontext_t, - func: extern fn (), - argc: ::c_int, ...); - pub fn swapcontext(uocp: *mut ucontext_t, - ucp: *const ucontext_t) -> ::c_int; -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b64/aarch64.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b64/aarch64.rs deleted file mode 100644 index 1da95b10203..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b64/aarch64.rs +++ /dev/null @@ -1,178 +0,0 @@ -//! AArch64-specific definitions for 64-bit linux-like values - -pub type c_char = u8; -pub type wchar_t = u32; -pub type nlink_t = u32; -pub type blksize_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, - __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 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 const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; - -pub const O_DIRECT: ::c_int = 0x10000; -pub const O_DIRECTORY: ::c_int = 0x4000; -pub const O_NOFOLLOW: ::c_int = 0x8000; - -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; - -pub const EDEADLOCK: ::c_int = 35; - -pub const SO_PEERCRED: ::c_int = 17; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; - -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONBIO: ::c_ulong = 0x5421; - -pub const SYS_gettid: ::c_long = 178; -pub const SYS_perf_event_open: ::c_long = 241; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const SIGSTKSZ: ::size_t = 16384; -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 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; diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b64/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b64/mod.rs deleted file mode 100644 index 352dba843d2..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b64/mod.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! 64-bit specific definitions for linux-like values - -pub type c_long = i64; -pub type c_ulong = u64; -pub type clock_t = i64; -pub type time_t = i64; -pub type suseconds_t = i64; -pub type ino_t = u64; -pub type off_t = i64; -pub type blkcnt_t = i64; -pub type __fsword_t = ::c_long; - -s! { - pub struct sigset_t { - __val: [::c_ulong; 16], - } - - 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 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 const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; - -cfg_if! { - if #[cfg(target_arch = "aarch64")] { - mod aarch64; - pub use self::aarch64::*; - } else if #[cfg(any(target_arch = "powerpc64"))] { - mod powerpc64; - pub use self::powerpc64::*; - } else if #[cfg(any(target_arch = "x86_64"))] { - mod x86_64; - pub use self::x86_64::*; - } else { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs deleted file mode 100644 index c5ce962e39a..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs +++ /dev/null @@ -1,176 +0,0 @@ -//! PowerPC64-specific definitions for 64-bit linux-like values - -pub type c_char = u8; -pub type wchar_t = i32; -pub type nlink_t = u64; -pub type blksize_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: ::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 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: ::uint32_t, - __pad1: ::uint32_t, - __unused1: ::uint64_t, - __unused2: ::c_ulong, - } - - pub struct shmid_ds { - pub shm_perm: ::ipc_perm, - pub shm_atime: ::time_t, - pub shm_dtime: ::time_t, - pub shm_ctime: ::time_t, - pub shm_segsz: ::size_t, - pub shm_cpid: ::pid_t, - pub shm_lpid: ::pid_t, - pub shm_nattch: ::shmatt_t, - __unused4: ::c_ulong, - __unused5: ::c_ulong - } -} - -pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; - -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 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 FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONBIO: ::c_ulong = 0x8004667e; - -pub const SYS_gettid: ::c_long = 207; -pub const SYS_perf_event_open: ::c_long = 319; - -pub const MCL_CURRENT: ::c_int = 0x2000; -pub const MCL_FUTURE: ::c_int = 0x4000; - -pub const SIGSTKSZ: ::size_t = 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 = 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 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; diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/vendor/libc/src/unix/notbsd/linux/other/b64/x86_64.rs deleted file mode 100644 index 69295e6d5de..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/b64/x86_64.rs +++ /dev/null @@ -1,246 +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; - -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 pthread_attr_t { - __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 mcontext_t { - pub gregs: [greg_t; 23], - pub fpregs: *mut _libc_fpstate, - __private: [u64; 8], - } - - 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], - } - - 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 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 const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; - -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; - -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; -pub const MAP_32BIT: ::c_int = 0x0040; - -pub const EDEADLOCK: ::c_int = 35; - -pub const SO_PEERCRED: ::c_int = 17; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; - -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONBIO: ::c_ulong = 0x5421; - -pub const PTRACE_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_O_EXITKILL: ::c_uint = 1048576; -pub const PTRACE_O_TRACECLONE: ::c_uint = 8; -pub const PTRACE_O_TRACEEXEC: ::c_uint = 16; -pub const PTRACE_O_TRACEEXIT: ::c_uint = 64; -pub const PTRACE_O_TRACEFORK: ::c_uint = 2; -pub const PTRACE_O_TRACESYSGOOD: ::c_uint = 1; -pub const PTRACE_O_TRACEVFORK: ::c_uint = 4; -pub const PTRACE_O_TRACEVFORKDONE: ::c_uint = 32; -pub const PTRACE_O_TRACESECCOMP: ::c_uint = 128; -pub const PTRACE_O_SUSPEND_SECCOMP: ::c_uint = 2097152; -pub const PTRACE_PEEKSIGINFO_SHARED: ::c_uint = 1; - -pub const SYS_gettid: ::c_long = 186; -pub const SYS_perf_event_open: ::c_long = 298; - -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: ::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 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; - -extern { - pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; - pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; - pub fn makecontext(ucp: *mut ucontext_t, - func: extern fn (), - argc: ::c_int, ...); - pub fn swapcontext(uocp: *mut ucontext_t, - ucp: *const ucontext_t) -> ::c_int; -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/other/mod.rs b/src/vendor/libc/src/unix/notbsd/linux/other/mod.rs deleted file mode 100644 index b100cec54ba..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/other/mod.rs +++ /dev/null @@ -1,620 +0,0 @@ -pub type fsblkcnt_t = ::c_ulong; -pub type fsfilcnt_t = ::c_ulong; -pub type rlim_t = c_ulong; -pub type __priority_which_t = ::c_uint; - -s! { - pub struct __exit_status { - pub e_termination: ::c_short, - pub e_exit: ::c_short, - } - - pub struct __timeval { - pub tv_sec: ::int32_t, - pub tv_usec: ::int32_t, - } - - 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_pointer_width = "32"))] - pub ut_session: ::c_long, - #[cfg(any(target_arch = "aarch64", target_pointer_width = "32"))] - pub ut_tv: ::timeval, - - #[cfg(not(any(target_arch = "aarch64", target_pointer_width = "32")))] - pub ut_session: ::int32_t, - #[cfg(not(any(target_arch = "aarch64", target_pointer_width = "32")))] - pub ut_tv: __timeval, - - pub ut_addr_v6: [::int32_t; 4], - __glibc_reserved: [::c_char; 20], - } - - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_int, - _restorer: *mut ::c_void, - } - - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_flags: ::c_int, - pub ss_size: ::size_t - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - - pub struct glob64_t { - pub gl_pathc: ::size_t, - pub gl_pathv: *mut *mut ::c_char, - pub gl_offs: ::size_t, - pub gl_flags: ::c_int, - - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - } - - pub struct ucred { - pub pid: ::pid_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - } - - pub struct statfs { - pub f_type: __fsword_t, - pub f_bsize: __fsword_t, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - - pub f_namelen: __fsword_t, - pub f_frsize: __fsword_t, - f_spare: [__fsword_t; 5], - } - - pub struct msghdr { - pub msg_name: *mut ::c_void, - pub msg_namelen: ::socklen_t, - pub msg_iov: *mut ::iovec, - pub msg_iovlen: ::size_t, - pub msg_control: *mut ::c_void, - pub msg_controllen: ::size_t, - pub msg_flags: ::c_int, - } - - pub struct 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, - } - - // 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], - } -} - -pub const __UT_LINESIZE: usize = 32; -pub const __UT_NAMESIZE: usize = 32; -pub const __UT_HOSTSIZE: usize = 256; -pub const EMPTY: ::c_short = 0; -pub const RUN_LVL: ::c_short = 1; -pub const BOOT_TIME: ::c_short = 2; -pub const NEW_TIME: ::c_short = 3; -pub const OLD_TIME: ::c_short = 4; -pub const INIT_PROCESS: ::c_short = 5; -pub const LOGIN_PROCESS: ::c_short = 6; -pub const USER_PROCESS: ::c_short = 7; -pub const DEAD_PROCESS: ::c_short = 8; -pub const ACCOUNTING: ::c_short = 9; - -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_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 RLIM_INFINITY: ::rlim_t = !0; -pub const RLIMIT_RTTIME: ::c_int = 15; -pub const RLIMIT_NLIMITS: ::c_int = 16; - -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 SOCK_NONBLOCK: ::c_int = O_NONBLOCK; - -pub const LC_PAPER: ::c_int = 7; -pub const LC_NAME: ::c_int = 8; -pub const LC_ADDRESS: ::c_int = 9; -pub const LC_TELEPHONE: ::c_int = 10; -pub const LC_MEASUREMENT: ::c_int = 11; -pub const LC_IDENTIFICATION: ::c_int = 12; -pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); -pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); -pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); -pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); -pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); -pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); -pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK - | ::LC_NUMERIC_MASK - | ::LC_TIME_MASK - | ::LC_COLLATE_MASK - | ::LC_MONETARY_MASK - | ::LC_MESSAGES_MASK - | LC_PAPER_MASK - | LC_NAME_MASK - | LC_ADDRESS_MASK - | LC_TELEPHONE_MASK - | LC_MEASUREMENT_MASK - | LC_IDENTIFICATION_MASK; - -pub const MAP_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_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 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 EUCLEAN: ::c_int = 117; -pub const ENOTNAM: ::c_int = 118; -pub const ENAVAIL: ::c_int = 119; -pub const EISNAM: ::c_int = 120; -pub const EREMOTEIO: ::c_int = 121; -pub const EDQUOT: ::c_int = 122; -pub const ENOMEDIUM: ::c_int = 123; -pub const EMEDIUMTYPE: ::c_int = 124; -pub const ECANCELED: ::c_int = 125; -pub const ENOKEY: ::c_int = 126; -pub const EKEYEXPIRED: ::c_int = 127; -pub const EKEYREVOKED: ::c_int = 128; -pub const EKEYREJECTED: ::c_int = 129; -pub const EOWNERDEAD: ::c_int = 130; -pub const ENOTRECOVERABLE: ::c_int = 131; -pub const EHWPOISON: ::c_int = 133; -pub const ERFKILL: ::c_int = 132; - -pub const SOCK_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 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 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 SA_ONSTACK: ::c_int = 0x08000000; -pub const SA_SIGINFO: ::c_int = 0x00000004; -pub const SA_NOCLDWAIT: ::c_int = 0x00000002; - -pub const SIGCHLD: ::c_int = 17; -pub const SIGBUS: ::c_int = 7; -pub const SIGUSR1: ::c_int = 10; -pub const SIGUSR2: ::c_int = 12; -pub const SIGCONT: ::c_int = 18; -pub const SIGSTOP: ::c_int = 19; -pub const SIGTSTP: ::c_int = 20; -pub const SIGURG: ::c_int = 23; -pub const SIGIO: ::c_int = 29; -pub const SIGSYS: ::c_int = 31; -pub const SIGSTKFLT: ::c_int = 16; -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 POLLRDNORM: ::c_short = 0x040; -pub const POLLWRNORM: ::c_short = 0x100; -pub const POLLRDBAND: ::c_short = 0x080; -pub const POLLWRBAND: ::c_short = 0x200; - -pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; -pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; - -pub const BUFSIZ: ::c_uint = 8192; -pub const TMP_MAX: ::c_uint = 238328; -pub const FOPEN_MAX: ::c_uint = 16; -pub const POSIX_FADV_DONTNEED: ::c_int = 4; -pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; -pub const _SC_2_C_VERSION: ::c_int = 96; -pub const O_ACCMODE: ::c_int = 3; -pub const O_ASYNC: ::c_int = 0x2000; -pub const O_NDELAY: ::c_int = 0x800; -pub const ST_RELATIME: ::c_ulong = 4096; -pub const NI_MAXHOST: ::socklen_t = 1025; - -pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; -pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; -pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; -pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; -pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; -pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; -pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; -pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; -pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; -pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; -pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; -pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; -pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; -pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; -pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; -pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; -pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; -pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; -pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; -pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; -pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; -pub const TMPFS_MAGIC: ::c_long = 0x01021994; -pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; - -pub const VEOF: usize = 4; -pub const IUTF8: ::tcflag_t = 0x00004000; - -pub const CPU_SETSIZE: ::c_int = 0x400; - -pub const QFMT_VFS_V1: ::c_int = 4; - -pub const PTRACE_TRACEME: ::c_uint = 0; -pub const PTRACE_PEEKTEXT: ::c_uint = 1; -pub const PTRACE_PEEKDATA: ::c_uint = 2; -pub const PTRACE_PEEKUSER: ::c_uint = 3; -pub const PTRACE_POKETEXT: ::c_uint = 4; -pub const PTRACE_POKEDATA: ::c_uint = 5; -pub const PTRACE_POKEUSER: ::c_uint = 6; -pub const PTRACE_CONT: ::c_uint = 7; -pub const PTRACE_KILL: ::c_uint = 8; -pub const PTRACE_SINGLESTEP: ::c_uint = 9; -pub const PTRACE_ATTACH: ::c_uint = 16; -pub const PTRACE_DETACH: ::c_uint = 17; -pub const PTRACE_SYSCALL: ::c_uint = 24; -pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; -pub const PTRACE_GETREGSET: ::c_uint = 0x4204; -pub const PTRACE_SETREGSET: ::c_uint = 0x4205; -pub const PTRACE_SEIZE: ::c_uint = 0x4206; -pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; -pub const PTRACE_LISTEN: ::c_uint = 0x4208; -pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; - -pub const MADV_DODUMP: ::c_int = 17; -pub const MADV_DONTDUMP: ::c_int = 16; - -pub const EPOLLWAKEUP: ::c_int = 0x20000000; - -pub const MADV_HUGEPAGE: ::c_int = 14; -pub const MADV_NOHUGEPAGE: ::c_int = 15; -pub const MAP_HUGETLB: ::c_int = 0x040000; - -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 SEEK_DATA: ::c_int = 3; -pub const SEEK_HOLE: ::c_int = 4; - -pub const SFD_NONBLOCK: ::c_int = 0x0800; - -pub const TCSANOW: ::c_int = 0; -pub const TCSADRAIN: ::c_int = 1; -pub const TCSAFLUSH: ::c_int = 2; - -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -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 RTLD_DEEPBIND: ::c_int = 0x8; -pub const RTLD_GLOBAL: ::c_int = 0x100; -pub const RTLD_NOLOAD: ::c_int = 0x4; - -pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; -pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; -pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; -pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; -pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; - -pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; -pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; -pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; -pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; -pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; -pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; -pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; -pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; - -pub const NETLINK_ROUTE: ::c_int = 0; -pub const NETLINK_UNUSED: ::c_int = 1; -pub const NETLINK_USERSOCK: ::c_int = 2; -pub const NETLINK_FIREWALL: ::c_int = 3; -pub const NETLINK_SOCK_DIAG: ::c_int = 4; -pub const NETLINK_NFLOG: ::c_int = 5; -pub const NETLINK_XFRM: ::c_int = 6; -pub const NETLINK_SELINUX: ::c_int = 7; -pub const NETLINK_ISCSI: ::c_int = 8; -pub const NETLINK_AUDIT: ::c_int = 9; -pub const NETLINK_FIB_LOOKUP: ::c_int = 10; -pub const NETLINK_CONNECTOR: ::c_int = 11; -pub const NETLINK_NETFILTER: ::c_int = 12; -pub const NETLINK_IP6_FW: ::c_int = 13; -pub const NETLINK_DNRTMSG: ::c_int = 14; -pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15; -pub const NETLINK_GENERIC: ::c_int = 16; -pub const NETLINK_SCSITRANSPORT: ::c_int = 18; -pub const NETLINK_ECRYPTFS: ::c_int = 19; -pub const NETLINK_RDMA: ::c_int = 20; -pub const NETLINK_CRYPTO: ::c_int = 21; -pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG; - -pub const MAX_LINKS: ::c_int = 32; - -pub const NLM_F_REQUEST: ::c_int = 1; -pub const NLM_F_MULTI: ::c_int = 2; -pub const NLM_F_ACK: ::c_int = 4; -pub const NLM_F_ECHO: ::c_int = 8; -pub const NLM_F_DUMP_INTR: ::c_int = 16; -pub const NLM_F_DUMP_FILTERED: ::c_int = 32; - -pub const NLM_F_ROOT: ::c_int = 0x100; -pub const NLM_F_MATCH: ::c_int = 0x200; -pub const NLM_F_ATOMIC: ::c_int = 0x400; -pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH; - -pub const NLM_F_REPLACE: ::c_int = 0x100; -pub const NLM_F_EXCL: ::c_int = 0x200; -pub const NLM_F_CREATE: ::c_int = 0x400; -pub const NLM_F_APPEND: ::c_int = 0x800; - -pub const NLMSG_NOOP: ::c_int = 0x1; -pub const NLMSG_ERROR: ::c_int = 0x2; -pub const NLMSG_DONE: ::c_int = 0x3; -pub const NLMSG_OVERRUN: ::c_int = 0x4; -pub const NLMSG_MIN_TYPE: ::c_int = 0x10; - -pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1; -pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2; -pub const NETLINK_PKTINFO: ::c_int = 3; -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); - -cfg_if! { - if #[cfg(any(target_arch = "arm", target_arch = "x86", - target_arch = "x86_64"))] { - pub const PTHREAD_STACK_MIN: ::size_t = 16384; - } else { - pub const PTHREAD_STACK_MIN: ::size_t = 131072; - } -} - -extern { - 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(); -} - -#[link(name = "util")] -extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; - pub fn backtrace(buf: *mut *mut ::c_void, - sz: ::c_int) -> ::c_int; - pub fn glob64(pattern: *const ::c_char, - flags: ::c_int, - errfunc: ::dox::Option<extern fn(epath: *const ::c_char, - errno: ::c_int) - -> ::c_int>, - pglob: *mut glob64_t) -> ::c_int; - pub fn globfree64(pglob: *mut glob64_t); - pub fn ptrace(request: ::c_uint, ...) -> ::c_long; - pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t) -> ::c_int; - pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t) -> ::c_int; - pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; - pub fn setpriority(which: ::__priority_which_t, who: ::id_t, - prio: ::c_int) -> ::c_int; - pub fn pthread_getaffinity_np(thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t) -> ::c_int; - pub fn pthread_setaffinity_np(thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t) -> ::c_int; - pub fn sched_getcpu() -> ::c_int; -} - -cfg_if! { - if #[cfg(any(target_arch = "x86", - target_arch = "arm", - target_arch = "powerpc"))] { - mod b32; - pub use self::b32::*; - } else if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "powerpc64"))] { - mod b64; - pub use self::b64::*; - } else { - // Unknown target_arch - } -} diff --git a/src/vendor/libc/src/unix/notbsd/linux/s390x.rs b/src/vendor/libc/src/unix/notbsd/linux/s390x.rs deleted file mode 100644 index be12d72fc51..00000000000 --- a/src/vendor/libc/src/unix/notbsd/linux/s390x.rs +++ /dev/null @@ -1,679 +0,0 @@ -pub type blkcnt_t = i64; -pub type blksize_t = i64; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; -pub type fsblkcnt_t = u64; -pub type fsfilcnt_t = u64; -pub type ino_t = u64; -pub type nlink_t = u64; -pub type off_t = i64; -pub type rlim_t = u64; -pub type suseconds_t = i64; -pub type time_t = i64; -pub type wchar_t = i32; -pub type greg_t = u64; -pub type clock_t = i64; -pub type __fsword_t = ::c_long; -pub type __priority_which_t = ::c_uint; - -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, - st_pad0: ::c_int, - pub st_rdev: ::dev_t, - pub st_size: ::off_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, - __glibc_reserved: [::c_long; 3], - } - - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - st_pad0: ::c_int, - pub st_rdev: ::dev_t, - pub st_size: ::off_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - __glibc_reserved: [::c_long; 3], - } - - pub struct pthread_attr_t { - __size: [::c_ulong; 7] - } - - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - __glibc_reserved0: ::c_int, - pub sa_flags: ::c_int, - _restorer: *mut ::c_void, - pub sa_mask: sigset_t, - } - - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_flags: ::c_int, - pub ss_size: ::size_t, - } - - pub struct sigset_t { - __size: [::c_ulong; 16], - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - _pad: ::c_int, - _pad2: [::c_long; 14], - } - - pub struct ipc_perm { - pub __key: ::key_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - pub cuid: ::uid_t, - pub cgid: ::gid_t, - pub mode: ::mode_t, - pub __seq: ::c_ushort, - __pad1: ::c_ushort, - __unused1: ::c_ulong, - __unused2: ::c_ulong - } - - pub struct shmid_ds { - pub shm_perm: ::ipc_perm, - pub shm_segsz: ::size_t, - pub shm_atime: ::time_t, - pub shm_dtime: ::time_t, - pub shm_ctime: ::time_t, - pub shm_cpid: ::pid_t, - pub shm_lpid: ::pid_t, - pub shm_nattch: ::shmatt_t, - __unused4: ::c_ulong, - __unused5: ::c_ulong - } - - pub struct statfs { - pub f_type: ::c_uint, - pub f_bsize: ::c_uint, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_uint, - pub f_frsize: ::c_uint, - pub f_flags: ::c_uint, - f_spare: [::c_uint; 4], - } - - pub struct 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 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 sysinfo { - pub uptime: ::c_long, - pub loads: [::c_ulong; 3], - pub totalram: ::c_ulong, - pub freeram: ::c_ulong, - pub sharedram: ::c_ulong, - pub bufferram: ::c_ulong, - pub totalswap: ::c_ulong, - pub freeswap: ::c_ulong, - pub procs: ::c_ushort, - pub pad: ::c_ushort, - pub totalhigh: ::c_ulong, - pub freehigh: ::c_ulong, - pub mem_unit: ::c_uint, - pub _f: [::c_char; 0], - } - - pub struct glob64_t { - pub gl_pathc: ::size_t, - pub gl_pathv: *mut *mut ::c_char, - pub gl_offs: ::size_t, - pub gl_flags: ::c_int, - - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - } - - pub struct ucred { - pub pid: ::pid_t, - pub uid: ::uid_t, - pub gid: ::gid_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, - } - - // FIXME this is actually a union - pub struct sem_t { - __size: [::c_char; 32], - __align: [::c_long; 0], - } - - pub struct __psw_t { - pub mask: u64, - pub addr: u64, - } - - // FIXME: This is actually a union. - pub struct fpreg_t { - pub d: ::c_double, - // f: ::c_float, - } - - pub struct fpregset_t { - pub fpc: u32, - __pad: u32, - pub fprs: [fpreg_t; 16], - } - - pub struct mcontext_t { - pub psw: __psw_t, - pub gregs: [u64; 16], - pub aregs: [u32; 16], - pub fpregs: fpregset_t, - } - - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: ::sigset_t, - } - - pub struct msqid_ds { - pub msg_perm: ::ipc_perm, - pub msg_stime: ::time_t, - pub msg_rtime: ::time_t, - pub msg_ctime: ::time_t, - __msg_cbytes: ::c_ulong, - pub msg_qnum: ::msgqnum_t, - pub msg_qbytes: ::msglen_t, - pub msg_lspid: ::pid_t, - pub msg_lrpid: ::pid_t, - __glibc_reserved4: ::c_ulong, - __glibc_reserved5: ::c_ulong, - } -} - -pub const POSIX_FADV_DONTNEED: ::c_int = 6; -pub const POSIX_FADV_NOREUSE: ::c_int = 7; - -pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; - -pub const EADDRINUSE: ::c_int = 98; -pub const EADDRNOTAVAIL: ::c_int = 99; -pub const ECONNABORTED: ::c_int = 103; -pub const ECONNREFUSED: ::c_int = 111; -pub const ECONNRESET: ::c_int = 104; -pub const EDEADLK: ::c_int = 35; -pub const ENOSYS: ::c_int = 38; -pub const ENOTCONN: ::c_int = 107; -pub const ETIMEDOUT: ::c_int = 110; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONBIO: ::c_ulong = 0x5421; -pub const MAP_ANON: ::c_int = 0x20; -pub const O_ACCMODE: ::c_int = 3; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NONBLOCK: ::c_int = 2048; -pub const PTHREAD_STACK_MIN: ::size_t = 16384; -pub const RLIM_INFINITY: ::rlim_t = 0xffffffffffffffff; -pub const SA_NOCLDWAIT: ::c_int = 2; -pub const SA_ONSTACK: ::c_int = 0x08000000; -pub const SA_SIGINFO: ::c_int = 4; -pub const SIGBUS: ::c_int = 7; -pub const SIGSTKSZ: ::size_t = 0x2000; -pub const SIG_SETMASK: ::c_int = 2; -pub const SOCK_DGRAM: ::c_int = 2; -pub const SOCK_STREAM: ::c_int = 1; -pub const SOL_SOCKET: ::c_int = 1; -pub const SO_BROADCAST: ::c_int = 6; -pub const SO_ERROR: ::c_int = 4; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_REUSEADDR: ::c_int = 2; -pub const SO_SNDTIMEO: ::c_int = 21; - -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_RTTIME: ::c_int = 15; -pub const RLIMIT_NLIMITS: ::c_int = 16; - -pub const O_NOCTTY: ::c_int = 256; -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; -pub const O_FSYNC: ::c_int = 0x101000; -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_NOFOLLOW: ::c_int = 0x20000; - -pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; - -pub const LC_PAPER: ::c_int = 7; -pub const LC_NAME: ::c_int = 8; -pub const LC_ADDRESS: ::c_int = 9; -pub const LC_TELEPHONE: ::c_int = 10; -pub const LC_MEASUREMENT: ::c_int = 11; -pub const LC_IDENTIFICATION: ::c_int = 12; -pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); -pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); -pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); -pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); -pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); -pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); -pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK - | ::LC_NUMERIC_MASK - | ::LC_TIME_MASK - | ::LC_COLLATE_MASK - | ::LC_MONETARY_MASK - | ::LC_MESSAGES_MASK - | LC_PAPER_MASK - | LC_NAME_MASK - | LC_ADDRESS_MASK - | LC_TELEPHONE_MASK - | LC_MEASUREMENT_MASK - | LC_IDENTIFICATION_MASK; - -pub const MAP_ANONYMOUS: ::c_int = 0x0020; -pub const MAP_GROWSDOWN: ::c_int = 0x0100; -pub const MAP_DENYWRITE: ::c_int = 0x0800; -pub const MAP_EXECUTABLE: ::c_int = 0x01000; -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; -pub const MAP_POPULATE: ::c_int = 0x08000; -pub const MAP_NONBLOCK: ::c_int = 0x010000; -pub const MAP_STACK: ::c_int = 0x020000; - -pub const 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 EUCLEAN: ::c_int = 117; -pub const ENOTNAM: ::c_int = 118; -pub const ENAVAIL: ::c_int = 119; -pub const EISNAM: ::c_int = 120; -pub const EREMOTEIO: ::c_int = 121; -pub const EDQUOT: ::c_int = 122; -pub const ENOMEDIUM: ::c_int = 123; -pub const EMEDIUMTYPE: ::c_int = 124; -pub const ECANCELED: ::c_int = 125; -pub const ENOKEY: ::c_int = 126; -pub const EKEYEXPIRED: ::c_int = 127; -pub const EKEYREVOKED: ::c_int = 128; -pub const EKEYREJECTED: ::c_int = 129; -pub const EOWNERDEAD: ::c_int = 130; -pub const ENOTRECOVERABLE: ::c_int = 131; -pub const EHWPOISON: ::c_int = 133; -pub const ERFKILL: ::c_int = 132; - -pub const SOCK_SEQPACKET: ::c_int = 5; - -pub const SO_TYPE: ::c_int = 3; -pub const SO_DONTROUTE: ::c_int = 5; -pub const SO_SNDBUF: ::c_int = 7; -pub const SO_RCVBUF: ::c_int = 8; -pub const SO_KEEPALIVE: ::c_int = 9; -pub const SO_OOBINLINE: ::c_int = 10; -pub const SO_LINGER: ::c_int = 13; -pub const SO_REUSEPORT: ::c_int = 15; -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 TCP_COOKIE_TRANSACTIONS: ::c_int = 15; -pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; -pub const TCP_THIN_DUPACK: ::c_int = 17; -pub const TCP_USER_TIMEOUT: ::c_int = 18; -pub const TCP_REPAIR: ::c_int = 19; -pub const TCP_REPAIR_QUEUE: ::c_int = 20; -pub const TCP_QUEUE_SEQ: ::c_int = 21; -pub const TCP_REPAIR_OPTIONS: ::c_int = 22; -pub const TCP_FASTOPEN: ::c_int = 23; -pub const TCP_TIMESTAMP: ::c_int = 24; - -pub const SIGCHLD: ::c_int = 17; -pub const SIGUSR1: ::c_int = 10; -pub const SIGUSR2: ::c_int = 12; -pub const SIGCONT: ::c_int = 18; -pub const SIGSTOP: ::c_int = 19; -pub const SIGTSTP: ::c_int = 20; -pub const SIGURG: ::c_int = 23; -pub const SIGIO: ::c_int = 29; -pub const SIGSYS: ::c_int = 31; -pub const SIGSTKFLT: ::c_int = 16; -pub const SIGUNUSED: ::c_int = 31; -pub const SIGTTIN: ::c_int = 21; -pub const SIGTTOU: ::c_int = 22; -pub const SIGXCPU: ::c_int = 24; -pub const SIGXFSZ: ::c_int = 25; -pub const SIGVTALRM: ::c_int = 26; -pub const SIGPROF: ::c_int = 27; -pub const SIGWINCH: ::c_int = 28; -pub const SIGPOLL: ::c_int = 29; -pub const SIGPWR: ::c_int = 30; -pub const SIG_BLOCK: ::c_int = 0x000000; -pub const SIG_UNBLOCK: ::c_int = 0x01; - -pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; -pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; - -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_2_C_VERSION: ::c_int = 96; -pub const O_ASYNC: ::c_int = 0x2000; -pub const O_NDELAY: ::c_int = 0x800; -pub const ST_RELATIME: ::c_ulong = 4096; -pub const NI_MAXHOST: ::socklen_t = 1025; - -pub const ADFS_SUPER_MAGIC: ::c_int = 0x0000adf5; -pub const AFFS_SUPER_MAGIC: ::c_int = 0x0000adff; -pub const CODA_SUPER_MAGIC: ::c_int = 0x73757245; -pub const CRAMFS_MAGIC: ::c_int = 0x28cd3d45; -pub const EFS_SUPER_MAGIC: ::c_int = 0x00414a53; -pub const EXT2_SUPER_MAGIC: ::c_int = 0x0000ef53; -pub const EXT3_SUPER_MAGIC: ::c_int = 0x0000ef53; -pub const EXT4_SUPER_MAGIC: ::c_int = 0x0000ef53; -pub const HPFS_SUPER_MAGIC: ::c_int = 0xf995e849; -pub const HUGETLBFS_MAGIC: ::c_int = 0x958458f6; -pub const ISOFS_SUPER_MAGIC: ::c_int = 0x00009660; -pub const JFFS2_SUPER_MAGIC: ::c_int = 0x000072b6; -pub const MINIX_SUPER_MAGIC: ::c_int = 0x0000137f; -pub const MINIX_SUPER_MAGIC2: ::c_int = 0x0000138f; -pub const MINIX2_SUPER_MAGIC: ::c_int = 0x00002468; -pub const MINIX2_SUPER_MAGIC2: ::c_int = 0x00002478; -pub const MSDOS_SUPER_MAGIC: ::c_int = 0x00004d44; -pub const NCP_SUPER_MAGIC: ::c_int = 0x0000564c; -pub const NFS_SUPER_MAGIC: ::c_int = 0x00006969; -pub const OPENPROM_SUPER_MAGIC: ::c_int = 0x00009fa1; -pub const PROC_SUPER_MAGIC: ::c_int = 0x00009fa0; -pub const QNX4_SUPER_MAGIC: ::c_int = 0x0000002f; -pub const REISERFS_SUPER_MAGIC: ::c_int = 0x52654973; -pub const SMB_SUPER_MAGIC: ::c_int = 0x0000517b; -pub const TMPFS_MAGIC: ::c_int = 0x01021994; -pub const USBDEVICE_SUPER_MAGIC: ::c_int = 0x00009fa2; - -pub const VEOF: usize = 4; -pub const VEOL: usize = 11; -pub const VEOL2: usize = 16; -pub const VMIN: usize = 6; -pub const IEXTEN: ::tcflag_t = 0x00008000; -pub const TOSTOP: ::tcflag_t = 0x00000100; -pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const IUTF8: ::tcflag_t = 0x00004000; - -pub const CPU_SETSIZE: ::c_int = 0x400; - -pub const EXTPROC: ::tcflag_t = 0x00010000; - -pub const QFMT_VFS_V1: ::c_int = 4; - -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_GETREGS: ::c_uint = 12; -pub const PTRACE_SETREGS: ::c_uint = 13; -pub const PTRACE_GETFPREGS: ::c_uint = 14; -pub const PTRACE_SETFPREGS: ::c_uint = 15; -pub const PTRACE_ATTACH: ::c_uint = 16; -pub const PTRACE_DETACH: ::c_uint = 17; -pub const PTRACE_SYSCALL: ::c_uint = 24; -pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; -pub const PTRACE_GETREGSET: ::c_uint = 0x4204; -pub const PTRACE_SETREGSET: ::c_uint = 0x4205; -pub const PTRACE_SEIZE: ::c_uint = 0x4206; -pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; -pub const PTRACE_LISTEN: ::c_uint = 0x4208; -pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; - -pub const MADV_DODUMP: ::c_int = 17; -pub const MADV_DONTDUMP: ::c_int = 16; - -pub const EPOLLWAKEUP: ::c_int = 0x20000000; - -pub const MADV_HUGEPAGE: ::c_int = 14; -pub const MADV_NOHUGEPAGE: ::c_int = 15; -pub const MAP_HUGETLB: ::c_int = 0x040000; - -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 SEEK_DATA: ::c_int = 3; -pub const SEEK_HOLE: ::c_int = 4; - -pub const SFD_NONBLOCK: ::c_int = 0x0800; - -pub const TCSANOW: ::c_int = 0; -pub const TCSADRAIN: ::c_int = 1; -pub const TCSAFLUSH: ::c_int = 2; - -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const FIONREAD: ::c_ulong = 0x541B; -pub const TIOCCONS: ::c_ulong = 0x541D; - -pub const RTLD_DEEPBIND: ::c_int = 0x8; -pub const RTLD_GLOBAL: ::c_int = 0x100; -pub const RTLD_NOLOAD: ::c_int = 0x4; - -pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; -pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; -pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; -pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; -pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; - -pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; -pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; -pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; -pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; -pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; -pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; -pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; -pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; - -pub const SYS_gettid: ::c_long = 236; -pub const SYS_perf_event_open: ::c_long = 331; - -#[link(name = "util")] -extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; - pub fn backtrace(buf: *mut *mut ::c_void, - sz: ::c_int) -> ::c_int; - pub fn glob64(pattern: *const ::c_char, - flags: ::c_int, - errfunc: ::dox::Option<extern fn(epath: *const ::c_char, - errno: ::c_int) - -> ::c_int>, - pglob: *mut glob64_t) -> ::c_int; - pub fn globfree64(pglob: *mut glob64_t); - pub fn ptrace(request: ::c_uint, ...) -> ::c_long; - pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t) -> ::c_int; - pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t) -> ::c_int; - pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; - pub fn setpriority(which: ::__priority_which_t, who: ::id_t, - prio: ::c_int) -> ::c_int; - pub fn pthread_getaffinity_np(thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t) -> ::c_int; - pub fn pthread_setaffinity_np(thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t) -> ::c_int; - pub fn sched_getcpu() -> ::c_int; - pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; - pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; - pub fn makecontext(ucp: *mut ucontext_t, - func: extern fn (), - argc: ::c_int, ...); - pub fn swapcontext(uocp: *mut ucontext_t, - ucp: *const ucontext_t) -> ::c_int; -} diff --git a/src/vendor/libc/src/unix/notbsd/mod.rs b/src/vendor/libc/src/unix/notbsd/mod.rs deleted file mode 100644 index a53211a2b80..00000000000 --- a/src/vendor/libc/src/unix/notbsd/mod.rs +++ /dev/null @@ -1,867 +0,0 @@ -use dox::mem; - -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 enum timezone {} - -s! { - pub struct sockaddr { - pub sa_family: sa_family_t, - pub sa_data: [::c_char; 14], - } - - pub struct sockaddr_in { - pub sin_family: sa_family_t, - pub sin_port: ::in_port_t, - pub sin_addr: ::in_addr, - pub sin_zero: [u8; 8], - } - - pub struct sockaddr_in6 { - 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_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 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_nl { - pub nl_family: ::sa_family_t, - nl_pad: ::c_ushort, - pub nl_pid: u32, - pub nl_groups: u32 - } - - 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"))] - pub sched_ss_low_priority: ::c_int, - #[cfg(any(target_env = "musl"))] - pub sched_ss_repl_period: ::timespec, - #[cfg(any(target_env = "musl"))] - pub sched_ss_init_budget: ::timespec, - #[cfg(any(target_env = "musl"))] - 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, - } - - #[cfg_attr(any(all(target_arch = "x86", not(target_env = "musl")), - target_arch = "x86_64"), - repr(packed))] - pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, - } - - 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 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, - } -} - -// 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; -pub const F_SETPIPE_SZ: ::c_int = 1031; -pub const F_GETPIPE_SZ: ::c_int = 1032; - -// 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 O_TRUNC: ::c_int = 512; -pub const O_CLOEXEC: ::c_int = 0x80000; - -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 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 AF_PACKET: ::c_int = 17; -pub const IPPROTO_RAW: ::c_int = 255; - -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; - -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 AF_UNIX: ::c_int = 1; -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 10; -pub const AF_NETLINK: ::c_int = 16; -pub const SOCK_RAW: ::c_int = 3; -pub const IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -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_ADD_MEMBERSHIP: ::c_int = 20; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; - -pub const TCP_NODELAY: ::c_int = 1; -pub const TCP_MAXSEG: ::c_int = 2; -pub const TCP_CORK: ::c_int = 3; -pub const TCP_KEEPIDLE: ::c_int = 4; -pub const TCP_KEEPINTVL: ::c_int = 5; -pub const TCP_KEEPCNT: ::c_int = 6; -pub const TCP_SYNCNT: ::c_int = 7; -pub const TCP_LINGER2: ::c_int = 8; -pub const TCP_DEFER_ACCEPT: ::c_int = 9; -pub const TCP_WINDOW_CLAMP: ::c_int = 10; -pub const TCP_INFO: ::c_int = 11; -pub const TCP_QUICKACK: ::c_int = 12; -pub const TCP_CONGESTION: ::c_int = 13; - -pub const IPV6_MULTICAST_LOOP: ::c_int = 19; -pub const IPV6_V6ONLY: ::c_int = 26; - -pub const SO_DEBUG: ::c_int = 1; - -pub const MSG_NOSIGNAL: ::c_int = 0x4000; - -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 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 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 EPOLL_CLOEXEC: ::c_int = 0x80000; - -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: ::uint32_t = 1; -pub const QIF_SPACE: ::uint32_t = 2; -pub const QIF_ILIMITS: ::uint32_t = 4; -pub const QIF_INODES: ::uint32_t = 8; -pub const QIF_BTIME: ::uint32_t = 16; -pub const QIF_ITIME: ::uint32_t = 32; -pub const QIF_LIMITS: ::uint32_t = 5; -pub const QIF_USAGE: ::uint32_t = 10; -pub const QIF_TIMES: ::uint32_t = 48; -pub const QIF_ALL: ::uint32_t = 63; - -pub const EFD_CLOEXEC: ::c_int = 0x80000; - -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 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 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 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; - -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 WIFSIGNALED(status: ::c_int) -> bool { - (status & 0x7f) + 1 >= 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 { - 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 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_nanosleep(clk_id: clockid_t, - flags: ::c_int, - rqtp: *const ::timespec, - rmtp: *mut ::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 sched_setscheduler(pid: ::pid_t, - policy: ::c_int, - param: *const sched_param) -> ::c_int; - pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; - pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; - pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; - pub fn epoll_create(size: ::c_int) -> ::c_int; - pub fn epoll_create1(flags: ::c_int) -> ::c_int; - pub fn epoll_ctl(epfd: ::c_int, - op: ::c_int, - fd: ::c_int, - event: *mut epoll_event) -> ::c_int; - pub fn epoll_wait(epfd: ::c_int, - events: *mut epoll_event, - maxevents: ::c_int, - timeout: ::c_int) -> ::c_int; - pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; - pub fn mount(src: *const ::c_char, - target: *const ::c_char, - fstype: *const ::c_char, - flags: ::c_ulong, - data: *const ::c_void) -> ::c_int; - pub fn umount(target: *const ::c_char) -> ::c_int; - pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; - pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, - child_stack: *mut ::c_void, - flags: ::c_int, - arg: *mut ::c_void, ...) -> ::c_int; - pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; - pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; - pub fn memrchr(cx: *const ::c_void, - c: ::c_int, - n: ::size_t) -> *mut ::c_void; - pub fn syscall(num: ::c_long, ...) -> ::c_long; - pub fn sendfile(out_fd: ::c_int, - in_fd: ::c_int, - offset: *mut off_t, - count: ::size_t) -> ::ssize_t; - pub fn splice(fd_in: ::c_int, - off_in: *mut ::loff_t, - fd_out: ::c_int, - off_out: *mut ::loff_t, - len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn tee(fd_in: ::c_int, - fd_out: ::c_int, - len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn vmsplice(fd: ::c_int, - iov: *const ::iovec, - nr_segs: ::size_t, - flags: ::c_uint) -> ::ssize_t; - - pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, - advise: ::c_int) -> ::c_int; - pub fn 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 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 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_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 eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; - pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int; - - pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, - flags: ::c_int, ...) -> ::c_int; - pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::c_int, 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 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 mknodat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t, dev: dev_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 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 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 setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; - pub fn sem_timedwait(sem: *mut sem_t, - abstime: *const ::timespec) -> ::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; -} - -cfg_if! { - if #[cfg(any(target_os = "linux", - target_os = "emscripten"))] { - 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/src/vendor/libc/src/unix/solaris/mod.rs b/src/vendor/libc/src/unix/solaris/mod.rs deleted file mode 100644 index 63cd1249a48..00000000000 --- a/src/vendor/libc/src/unix/solaris/mod.rs +++ /dev/null @@ -1,1047 +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 = i64; -pub type clock_t = i64; -pub type daddr_t = i64; -pub type dev_t = u64; -pub type fsblkcnt_t = u64; -pub type fsfilcnt_t = u64; -pub type ino_t = i64; -pub type key_t = i32; -pub type major_t = u32; -pub type minor_t = u32; -pub type mode_t = u32; -pub type nlink_t = u32; -pub type rlim_t = u64; -pub type speed_t = u32; -pub type tcflag_t = u32; -pub type time_t = i64; -pub type wchar_t = i32; -pub type nfds_t = ::c_ulong; - -pub type suseconds_t = ::c_long; -pub type off_t = i64; -pub type useconds_t = ::c_uint; -pub type socklen_t = u32; -pub type sa_family_t = u8; -pub type pthread_t = ::uintptr_t; -pub type pthread_key_t = ::c_uint; -pub type blksize_t = u32; -pub type fflags_t = u32; -pub type nl_item = ::c_int; - -pub enum timezone {} - -s! { - pub struct sockaddr { - pub sa_family: sa_family_t, - pub sa_data: [::c_char; 14], - } - - pub struct sockaddr_in { - pub sin_family: sa_family_t, - pub sin_port: ::in_port_t, - pub sin_addr: ::in_addr, - pub sin_zero: [::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 sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108] - } - - 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 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 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 fd_set { - fds_bits: [i32; FD_SETSIZE / 32], - } - - 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 dirent { - pub d_ino: ::ino_t, - pub d_off: ::off_t, - pub d_reclen: u16, - pub d_name: [::c_char; 1] - } - - 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 sockaddr_storage { - pub ss_family: ::sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 240], - } - - 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_code: ::c_int, - pub si_errno: ::c_int, - pub si_pad: ::c_int, - pub si_addr: *mut ::c_void, - __pad: [u8; 232], - } - - 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 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 FIONBIO: ::c_int = 0x8004667e; - -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 IPV6_MULTICAST_LOOP: ::c_int = 0x8; -pub const IPV6_V6ONLY: ::c_int = 0x27; - -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_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_TRUNC: ::c_int = 512; -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 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_SHARED: ::c_int = 0x0001; -pub const MAP_PRIVATE: ::c_int = 0x0002; -pub const MAP_FIXED: ::c_int = 0x0010; -pub const MAP_NORESERVE: ::c_int = 0x40; -pub const MAP_ANON: ::c_int = 0x0100; -pub const MAP_RENAME: ::c_int = 0x20; -pub const MAP_ALIGN: ::c_int = 0x200; -pub const MAP_TEXT: ::c_int = 0x400; -pub const MAP_INITDATA: ::c_int = 0x800; -pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const MS_SYNC: ::c_int = 0x0004; -pub const MS_ASYNC: ::c_int = 0x0001; -pub const MS_INVALIDATE: ::c_int = 0x0002; -pub const MS_INVALCURPROC: ::c_int = 0x0008; - -pub const EPERM: ::c_int = 1; -pub const ENOENT: ::c_int = 2; -pub const ESRCH: ::c_int = 3; -pub const EINTR: ::c_int = 4; -pub const EIO: ::c_int = 5; -pub const ENXIO: ::c_int = 6; -pub const E2BIG: ::c_int = 7; -pub const ENOEXEC: ::c_int = 8; -pub const EBADF: ::c_int = 9; -pub const ECHILD: ::c_int = 10; -pub const EDEADLK: ::c_int = 45; -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 = 11; -pub const EWOULDBLOCK: ::c_int = 11; -pub const EINPROGRESS: ::c_int = 150; -pub const EALREADY: ::c_int = 149; -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 ELOOP: ::c_int = 90; -pub const ENAMETOOLONG: ::c_int = 78; -pub const EHOSTDOWN: ::c_int = 147; -pub const EHOSTUNREACH: ::c_int = 148; -pub const ENOTEMPTY: ::c_int = 93; -pub const EUSERS: ::c_int = 94; -pub const EDQUOT: ::c_int = 49; -pub const ESTALE: ::c_int = 151; -pub const EREMOTE: ::c_int = 66; -pub const ENOLCK: ::c_int = 46; -pub const ENOSYS: ::c_int = 89; -pub const EIDRM: ::c_int = 36; -pub const ENOMSG: ::c_int = 35; -pub const EOVERFLOW: ::c_int = 79; -pub const ECANCELED: ::c_int = 47; -pub const EILSEQ: ::c_int = 88; -pub const EBADMSG: ::c_int = 77; -pub const EMULTIHOP: ::c_int = 74; -pub const ENOLINK: ::c_int = 67; -pub const EPROTO: ::c_int = 71; - -pub const EAI_SYSTEM: ::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 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 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 = 77; -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_MQ_PRIO_MAX: ::c_int = 30; -pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 577; -pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 578; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 568; -pub const _SC_THREAD_KEYS_MAX: ::c_int = 572; -pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 580; -pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 581; -pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 579; -pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 582; -pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 583; -pub const _SC_THREAD_STACK_MIN: ::c_int = 573; -pub const _SC_THREAD_THREADS_MAX: ::c_int = 574; -pub const _SC_THREADS: ::c_int = 576; -pub const _SC_TTY_NAME_MAX: ::c_int = 575; -pub const _SC_ATEXIT_MAX: ::c_int = 76; -pub const _SC_XOPEN_CRYPT: ::c_int = 62; -pub const _SC_XOPEN_ENH_I18N: ::c_int = 63; -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_XOPEN_SHM: ::c_int = 64; -pub const _SC_XOPEN_UNIX: ::c_int = 78; -pub const _SC_XOPEN_VERSION: ::c_int = 12; -pub const _SC_XOPEN_XCU_VERSION: ::c_int = 67; - -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: u16 = 0; -pub const PTHREAD_STACK_MIN: ::size_t = 4096; - -pub const SIGSTKSZ: ::size_t = 8192; - -// https://illumos.org/man/3c/clock_gettime -// https://github.com/illumos/illumos-gate/ -// blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s -// clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME -// or __CLOCK_REALTIME0 -// -// https://github.com/illumos/illumos-gate/ -// blob/HEAD/usr/src/uts/common/sys/time_impl.h -// Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4 -// __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3 -pub const CLOCK_REALTIME: clockid_t = 3; -pub const CLOCK_MONOTONIC: clockid_t = 4; -pub const TIMER_RELTIME: ::c_int = 0; -pub const TIMER_ABSTIME: ::c_int = 1; - -pub const RLIMIT_CPU: ::c_int = 0; -pub const RLIMIT_FSIZE: ::c_int = 1; -pub const RLIMIT_DATA: ::c_int = 2; -pub const RLIMIT_STACK: ::c_int = 3; -pub const RLIMIT_CORE: ::c_int = 4; -pub const RLIMIT_NOFILE: ::c_int = 5; -pub const RLIMIT_VMEM: ::c_int = 6; -pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; - -pub const RLIM_NLIMITS: rlim_t = 7; -pub const RLIM_INFINITY: rlim_t = 0x7fffffff; - -pub const RUSAGE_SELF: ::c_int = 0; -pub const RUSAGE_CHILDREN: ::c_int = -1; - -pub const MADV_NORMAL: ::c_int = 0; -pub const MADV_RANDOM: ::c_int = 1; -pub const MADV_SEQUENTIAL: ::c_int = 2; -pub const MADV_WILLNEED: ::c_int = 3; -pub const MADV_DONTNEED: ::c_int = 4; -pub const MADV_FREE: ::c_int = 5; - -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 26; -pub const AF_UNIX: ::c_int = 1; -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 IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -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 IFF_LOOPBACK: ::c_int = 0x8; - -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 O_SYNC: ::c_int = 16; -pub const O_NONBLOCK: ::c_int = 128; - -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_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_PAGESIZE: ::c_int = 11; -pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; -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_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_2_VERSION: ::c_int = 53; -pub const _SC_2_C_BIND: ::c_int = 45; -pub const _SC_2_C_DEV: ::c_int = 46; -pub const _SC_2_CHAR_TERM: ::c_int = 66; -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_ASYNCHRONOUS_IO: ::c_int = 21; -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_PRIORITIZED_IO: ::c_int = 31; -pub const _SC_PRIORITY_SCHEDULING: ::c_int = 32; -pub const _SC_REALTIME_SIGNALS: ::c_int = 33; -pub const _SC_SEMAPHORES: ::c_int = 35; -pub const _SC_FSYNC: ::c_int = 23; -pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 38; -pub const _SC_SYNCHRONIZED_IO: ::c_int = 42; -pub const _SC_TIMERS: ::c_int = 43; -pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 20; -pub const _SC_DELAYTIMER_MAX: ::c_int = 22; -pub const _SC_MQ_OPEN_MAX: ::c_int = 29; -pub const _SC_RTSIG_MAX: ::c_int = 34; -pub const _SC_SEM_NSEMS_MAX: ::c_int = 36; -pub const _SC_SEM_VALUE_MAX: ::c_int = 37; -pub const _SC_SIGQUEUE_MAX: ::c_int = 39; -pub const _SC_TIMER_MAX: ::c_int = 44; - -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_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; - -f! { - pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { - let fd = fd as usize; - (*set).fds_bits[fd / 32] &= !(1 << (fd % 32)); - return - } - - pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { - let fd = fd as usize; - return ((*set).fds_bits[fd / 32] & (1 << (fd % 32))) != 0 - } - - pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { - let fd = fd as usize; - (*set).fds_bits[fd / 32] |= 1 << (fd % 32); - 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 - } -} - -extern { - 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 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 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 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 getpwnam_r(name: *const ::c_char, - pwd: *mut passwd, - buf: *mut ::c_char, - buflen: ::c_int) -> *const passwd; - pub fn getpwuid_r(uid: ::uid_t, - pwd: *mut passwd, - buf: *mut ::c_char, - buflen: ::c_int) -> *const passwd; - pub fn setpwent(); - pub fn getpwent() -> *mut passwd; - pub fn readdir(dirp: *mut ::DIR) -> *const ::dirent; - 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 openat(dirfd: ::c_int, pathname: *const ::c_char, - flags: ::c_int, ...) -> ::c_int; - pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::c_int, 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 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 mknodat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t, dev: dev_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 mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t) -> ::c_int; - pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; - pub fn if_nameindex() -> *mut if_nameindex; - pub fn if_freenameindex(ptr: *mut if_nameindex); - 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 pthread_mutex_timedlock(lock: *mut pthread_mutex_t, - abstime: *const ::timespec) -> ::c_int; -} diff --git a/src/vendor/libc/src/windows.rs b/src/vendor/libc/src/windows.rs deleted file mode 100644 index b916fd4bd6b..00000000000 --- a/src/vendor/libc/src/windows.rs +++ /dev/null @@ -1,234 +0,0 @@ -//! Windows CRT definitions - -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; -pub enum timezone {} -pub type time64_t = i64; - -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 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 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; - -cfg_if! { - if #[cfg(all(target_env = "gnu"))] { - pub const L_tmpnam: ::c_uint = 14; - pub const TMP_MAX: ::c_uint = 0x7fff; - } else if #[cfg(all(target_env = "msvc"))] { - pub const L_tmpnam: ::c_uint = 260; - pub const TMP_MAX: ::c_uint = 0x7fff_ffff; - } else { - // Unknown target_env - } -} - -pub const O_RDONLY: ::c_int = 0; -pub const O_WRONLY: ::c_int = 1; -pub const O_RDWR: ::c_int = 2; -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; - -#[cfg(target_env = "msvc")] // " if " -- appease style checker -#[link(name = "msvcrt")] -extern {} - -extern { - #[link_name = "_chmod"] - pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; - #[link_name = "_wchmod"] - pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int; - #[link_name = "_mkdir"] - pub fn mkdir(path: *const c_char) -> ::c_int; - #[link_name = "_wrmdir"] - pub fn wrmdir(path: *const wchar_t) -> ::c_int; - #[link_name = "_fstat64"] - pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; - #[link_name = "_stat64"] - pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; - #[link_name = "_wstat64"] - pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int; - #[link_name = "_wutime64"] - pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int; - #[link_name = "_popen"] - pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; - #[link_name = "_pclose"] - pub fn pclose(stream: *mut ::FILE) -> ::c_int; - #[link_name = "_fdopen"] - pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; - #[link_name = "_fileno"] - pub fn fileno(stream: *mut ::FILE) -> ::c_int; - #[link_name = "_open"] - pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; - #[link_name = "_wopen"] - pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int; - #[link_name = "_creat"] - pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int; - #[link_name = "_access"] - pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; - #[link_name = "_chdir"] - pub fn chdir(dir: *const c_char) -> ::c_int; - #[link_name = "_close"] - pub fn close(fd: ::c_int) -> ::c_int; - #[link_name = "_dup"] - pub fn dup(fd: ::c_int) -> ::c_int; - #[link_name = "_dup2"] - pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; - #[link_name = "_execv"] - pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t; - #[link_name = "_execve"] - pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) -> ::c_int; - #[link_name = "_execvp"] - pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; - #[link_name = "_execvpe"] - pub fn execvpe(c: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) -> ::c_int; - #[link_name = "_getcwd"] - pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char; - #[link_name = "_getpid"] - pub fn getpid() -> ::c_int; - #[link_name = "_isatty"] - pub fn isatty(fd: ::c_int) -> ::c_int; - #[link_name = "_lseek"] - pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; - #[link_name = "_pipe"] - pub fn pipe(fds: *mut ::c_int, - psize: ::c_uint, - textmode: ::c_int) -> ::c_int; - #[link_name = "_read"] - pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int; - #[link_name = "_rmdir"] - pub fn rmdir(path: *const c_char) -> ::c_int; - #[link_name = "_unlink"] - pub fn unlink(c: *const c_char) -> ::c_int; - #[link_name = "_write"] - pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int; - #[link_name = "_commit"] - pub fn commit(fd: ::c_int) -> ::c_int; - #[link_name = "_get_osfhandle"] - pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t; - #[link_name = "_open_osfhandle"] - pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int; - pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char; - #[link_name = "_wsetlocale"] - pub fn wsetlocale(category: ::c_int, - locale: *const wchar_t) -> *mut wchar_t; -} diff --git a/src/vendor/log/.cargo-checksum.json b/src/vendor/log/.cargo-checksum.json deleted file mode 100644 index 2255dcb7c7b..00000000000 --- a/src/vendor/log/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"12cc0f91b51fedf41ae1670d1624ee1d78a284bdb101645b60a06a12de16c069",".travis.yml":"7e59fac4ef16079658aa829fc2f0bce2de96225ba72f1ef8fea6d55d5be37fe2","Cargo.toml":"021b91ff433a559e29fabddbe01c1e4cdba33317c0b8f399c61b4335771cbca4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"7c831cff45cfd33333cc246815dccb25bfa0b981053656e707828fe3f25151da","appveyor.yml":"c61473b8c780ad2626282ce2b2ba0ef278082b6afe151a62ff419f33eaf90221","src/lib.rs":"0c05947b6f133fa9818f3a71f8f98549cf4c8f8840559fce6d0e33998af449d4","src/macros.rs":"9068d69d32e989ac273ce73659125d31cf4a166076eefdad74dfbdf9506cf9c4","tests/filters.rs":"cc61ed41a6cd77e5aef91cc8c76216b492d8de34f00635254f3835a3d964ce22"},"package":"ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054"} \ No newline at end of file diff --git a/src/vendor/log/.cargo-ok b/src/vendor/log/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/log/.cargo-ok +++ /dev/null diff --git a/src/vendor/log/.gitignore b/src/vendor/log/.gitignore deleted file mode 100644 index 2c96eb1b651..00000000000 --- a/src/vendor/log/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target/ -Cargo.lock diff --git a/src/vendor/log/.travis.yml b/src/vendor/log/.travis.yml deleted file mode 100644 index 89e7ae02ab5..00000000000 --- a/src/vendor/log/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: rust -sudo: false -rust: - - stable - - beta - - nightly -script: - - cargo build --verbose - - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --no-default-features) - - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --features nightly) - - cargo test --verbose - - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features) - - cargo test --verbose --manifest-path env/Cargo.toml - - cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml - - cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml --release - - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo doc --no-deps --features nightly) - - CARGO_TARGET_DIR=target cargo doc --no-deps --manifest-path env/Cargo.toml -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - [ $TRAVIS_RUST_VERSION = nightly ] && - echo '<meta http-equiv=refresh content=0;url=log/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: bNUxFmA5uEdKKdVDtgb+5WQuMRDZ6QxK5152sIZWSimxyr/x5erNZ1uacPh02Ng92dbUQ66wz90WPmqTwoL0EeJ/FmZDd29hRHXe82MNpz47QX3cGMgFNldQ2GmJmCHBXKu373B80o/ZB+BTVcYcl1ksTXuIhQg2wZtXh8bZ9F4= -notifications: - email: - on_success: never diff --git a/src/vendor/log/Cargo.toml b/src/vendor/log/Cargo.toml deleted file mode 100644 index f2081ecffcc..00000000000 --- a/src/vendor/log/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] - -name = "log" -version = "0.3.6" -authors = ["The Rust Project Developers"] -license = "MIT/Apache-2.0" -readme = "README.md" -repository = "https://github.com/rust-lang/log" -documentation = "https://doc.rust-lang.org/log" -homepage = "https://github.com/rust-lang/log" -description = """ -A lightweight logging facade for Rust -""" - -[[test]] -name = "filters" -harness = false - -[features] -max_level_off = [] -max_level_error = [] -max_level_warn = [] -max_level_info = [] -max_level_debug = [] -max_level_trace = [] - -release_max_level_off = [] -release_max_level_error = [] -release_max_level_warn = [] -release_max_level_info = [] -release_max_level_debug = [] -release_max_level_trace = [] - -nightly = [] -use_std = [] -default = ["use_std"] diff --git a/src/vendor/log/LICENSE-APACHE b/src/vendor/log/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/log/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/src/vendor/log/LICENSE-MIT b/src/vendor/log/LICENSE-MIT deleted file mode 100644 index 39d4bdb5acd..00000000000 --- a/src/vendor/log/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/src/vendor/log/README.md b/src/vendor/log/README.md deleted file mode 100644 index 0e9dc58ae7b..00000000000 --- a/src/vendor/log/README.md +++ /dev/null @@ -1,160 +0,0 @@ -log -=== - -A Rust library providing a lightweight logging *facade*. - -[](https://travis-ci.org/rust-lang-nursery/log) -[](https://ci.appveyor.com/project/alexcrichton/log) - -* [`log` documentation](https://doc.rust-lang.org/log) -* [`env_logger` documentation](https://doc.rust-lang.org/log/env_logger) - -A logging facade provides a single logging API that abstracts over the actual -logging implementation. Libraries can use the logging API provided by this -crate, and the consumer of those libraries can choose the logging -implementation that is most suitable for its use case. - -## Usage - -## In libraries - -Libraries should link only to the `log` crate, and use the provided macros to -log whatever information will be useful to downstream consumers: - -```toml -[dependencies] -log = "0.3" -``` - -```rust -#[macro_use] -extern crate log; - -pub fn shave_the_yak(yak: &Yak) { - trace!("Commencing yak shaving"); - - loop { - match find_a_razor() { - Ok(razor) => { - info!("Razor located: {}", razor); - yak.shave(razor); - break; - } - Err(err) => { - warn!("Unable to locate a razor: {}, retrying", err); - } - } - } -} -``` - -## In executables - -Executables should choose a logger implementation and initialize it early in the -runtime of the program. Logger implementations will typically include a -function to do this. Any log messages generated before the logger is -initialized will be ignored. - -The executable itself may use the `log` crate to log as well. - -The `env_logger` crate provides a logger implementation that mirrors the -functionality of the old revision of the `log` crate. - -```toml -[dependencies] -log = "0.3" -env_logger = "0.3" -``` - -```rust -#[macro_use] -extern crate log; -extern crate env_logger; - -fn main() { - env_logger::init().unwrap(); - - info!("starting up"); - - // ... -} -``` - -## In tests - -Tests can use the `env_logger` crate to see log messages generated during that test: - -```toml -[dependencies] -log = "0.3" - -[dev-dependencies] -env_logger = "0.3" -``` - -```rust -#[macro_use] -extern crate log; - -fn add_one(num: i32) -> i32 { - info!("add_one called with {}", num); - num + 1 -} - -#[cfg(test)] -mod tests { - use super::*; - extern crate env_logger; - - #[test] - fn it_adds_one() { - let _ = env_logger::init(); - info!("can log from the test too"); - assert_eq!(3, add_one(2)); - } - - #[test] - fn it_handles_negative_numbers() { - let _ = env_logger::init(); - info!("logging from another test"); - assert_eq!(-7, add_one(-8)); - } -} -``` - -Assuming the module under test is called `my_lib`, running the tests with the -`RUST_LOG` filtering to info messages from this module looks like: - -```bash -$ RUST_LOG=my_lib=info cargo test - Running target/debug/my_lib-... - -running 2 tests -INFO:my_lib::tests: logging from another test -INFO:my_lib: add_one called with -8 -test tests::it_handles_negative_numbers ... ok -INFO:my_lib::tests: can log from the test too -INFO:my_lib: add_one called with 2 -test tests::it_adds_one ... ok - -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured -``` - -Note that `env_logger::init()` needs to be called in each test in which you -want to enable logging. Additionally, the default behavior of tests to -run in parallel means that logging output may be interleaved with test output. -Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by -running one test by specifying its name as an argument to the test binaries as -directed by the `cargo test` help docs: - -```bash -$ RUST_LOG=my_lib=info cargo test it_adds_one - Running target/debug/my_lib-... - -running 1 test -INFO:my_lib::tests: can log from the test too -INFO:my_lib: add_one called with 2 -test tests::it_adds_one ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured -``` diff --git a/src/vendor/log/appveyor.yml b/src/vendor/log/appveyor.yml deleted file mode 100644 index 841011deb23..00000000000 --- a/src/vendor/log/appveyor.yml +++ /dev/null @@ -1,18 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu -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 test --verbose - - cargo test --manifest-path env/Cargo.toml diff --git a/src/vendor/log/src/lib.rs b/src/vendor/log/src/lib.rs deleted file mode 100644 index da2fc159633..00000000000 --- a/src/vendor/log/src/lib.rs +++ /dev/null @@ -1,1013 +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 lightweight logging facade. -//! -//! A logging facade provides a single logging API that abstracts over the -//! actual logging implementation. Libraries can use the logging API provided -//! by this crate, and the consumer of those libraries can choose the logging -//! framework that is most suitable for its use case. -//! -//! If no logging implementation is selected, the facade falls back to a "noop" -//! implementation that ignores all log messages. The overhead in this case -//! is very small - just an integer load, comparison and jump. -//! -//! A log request consists of a target, a level, and a body. A target is a -//! string which defaults to the module path of the location of the log -//! request, though that default may be overridden. Logger implementations -//! typically use the target to filter requests based on some user -//! configuration. -//! -//! # Use -//! -//! ## In libraries -//! -//! Libraries should link only to the `log` crate, and use the provided -//! macros to log whatever information will be useful to downstream consumers. -//! -//! ### Examples -//! -//! ```rust -//! # #![allow(unstable)] -//! #[macro_use] -//! extern crate log; -//! -//! # #[derive(Debug)] pub struct Yak(String); -//! # impl Yak { fn shave(&self, _: u32) {} } -//! # fn find_a_razor() -> Result<u32, u32> { Ok(1) } -//! pub fn shave_the_yak(yak: &Yak) { -//! info!(target: "yak_events", "Commencing yak shaving for {:?}", yak); -//! -//! loop { -//! match find_a_razor() { -//! Ok(razor) => { -//! info!("Razor located: {}", razor); -//! yak.shave(razor); -//! break; -//! } -//! Err(err) => { -//! warn!("Unable to locate a razor: {}, retrying", err); -//! } -//! } -//! } -//! } -//! # fn main() {} -//! ``` -//! -//! ## In executables -//! -//! Executables should choose a logging framework and initialize it early in the -//! runtime of the program. Logging frameworks will typically include a -//! function to do this. Any log messages generated before the framework is -//! initialized will be ignored. -//! -//! The executable itself may use the `log` crate to log as well. -//! -//! ### Warning -//! -//! The logging system may only be initialized once. -//! -//! ### Examples -//! -//! ```rust,ignore -//! #[macro_use] -//! extern crate log; -//! extern crate my_logger; -//! -//! fn main() { -//! my_logger::init(); -//! -//! info!("starting up"); -//! -//! // ... -//! } -//! ``` -//! -//! # Logger implementations -//! -//! Loggers implement the `Log` trait. Here's a very basic example that simply -//! logs all messages at the `Error`, `Warn` or `Info` levels to stdout: -//! -//! ```rust -//! extern crate log; -//! -//! use log::{LogRecord, LogLevel, LogMetadata}; -//! -//! struct SimpleLogger; -//! -//! impl log::Log for SimpleLogger { -//! fn enabled(&self, metadata: &LogMetadata) -> bool { -//! metadata.level() <= LogLevel::Info -//! } -//! -//! fn log(&self, record: &LogRecord) { -//! if self.enabled(record.metadata()) { -//! println!("{} - {}", record.level(), record.args()); -//! } -//! } -//! } -//! -//! # fn main() {} -//! ``` -//! -//! Loggers are installed by calling the `set_logger` function. It takes a -//! closure which is provided a `MaxLogLevel` token and returns a `Log` trait -//! object. The `MaxLogLevel` token controls the global maximum log level. The -//! logging facade uses this as an optimization to improve performance of log -//! messages at levels that are disabled. In the case of our example logger, -//! we'll want to set the maximum log level to `Info`, since we ignore any -//! `Debug` or `Trace` level log messages. A logging framework should provide a -//! function that wraps a call to `set_logger`, handling initialization of the -//! logger: -//! -//! ```rust -//! # extern crate log; -//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, LogMetadata}; -//! # struct SimpleLogger; -//! # impl log::Log for SimpleLogger { -//! # fn enabled(&self, _: &LogMetadata) -> bool { false } -//! # fn log(&self, _: &log::LogRecord) {} -//! # } -//! # fn main() {} -//! # #[cfg(feature = "use_std")] -//! pub fn init() -> Result<(), SetLoggerError> { -//! log::set_logger(|max_log_level| { -//! max_log_level.set(LogLevelFilter::Info); -//! Box::new(SimpleLogger) -//! }) -//! } -//! ``` -//! -//! # Use with `no_std` -//! -//! To use the `log` crate without depending on `libstd`, you need to specify -//! `default-features = false` when specifying the dependency in `Cargo.toml`. -//! This makes no difference to libraries using `log` since the logging API -//! remains the same. However executables will need to use the `set_logger_raw` -//! function to initialize a logger and the `shutdown_logger_raw` function to -//! shut down the global logger before exiting: -//! -//! ```rust -//! # extern crate log; -//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, ShutdownLoggerError, -//! # LogMetadata}; -//! # struct SimpleLogger; -//! # impl log::Log for SimpleLogger { -//! # fn enabled(&self, _: &LogMetadata) -> bool { false } -//! # fn log(&self, _: &log::LogRecord) {} -//! # } -//! # impl SimpleLogger { -//! # fn flush(&self) {} -//! # } -//! # fn main() {} -//! pub fn init() -> Result<(), SetLoggerError> { -//! unsafe { -//! log::set_logger_raw(|max_log_level| { -//! static LOGGER: SimpleLogger = SimpleLogger; -//! max_log_level.set(LogLevelFilter::Info); -//! &SimpleLogger -//! }) -//! } -//! } -//! pub fn shutdown() -> Result<(), ShutdownLoggerError> { -//! log::shutdown_logger_raw().map(|logger| { -//! let logger = unsafe { &*(logger as *const SimpleLogger) }; -//! logger.flush(); -//! }) -//! } -//! ``` - -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/log/")] -#![warn(missing_docs)] -#![cfg_attr(feature = "nightly", feature(panic_handler))] - -#![cfg_attr(not(feature = "use_std"), no_std)] - -#[cfg(not(feature = "use_std"))] -extern crate core as std; - -use std::cmp; -#[cfg(feature = "use_std")] -use std::error; -use std::fmt; -use std::mem; -use std::ops::Deref; -use std::str::FromStr; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; -#[macro_use] -mod macros; - -// The setup here is a bit weird to make shutdown_logger_raw work. -// -// There are four different states that we care about: the logger's -// uninitialized, the logger's initializing (set_logger's been called but -// LOGGER hasn't actually been set yet), the logger's active, or the logger is -// shut down after calling shutdown_logger_raw. -// -// The LOGGER static holds a pointer to the global logger. It is protected by -// the STATE static which determines whether LOGGER has been initialized yet. -// -// The shutdown_logger_raw routine needs to make sure that no threads are -// actively logging before it returns. The number of actively logging threads is -// tracked in the REFCOUNT static. The routine first sets STATE back to -// INITIALIZING. All logging calls past that point will immediately return -// without accessing the logger. At that point, the at_exit routine just waits -// for the refcount to reach 0 before deallocating the logger. Note that the -// refcount does not necessarily monotonically decrease at this point, as new -// log calls still increment and decrement it, but the interval in between is -// small enough that the wait is really just for the active log calls to finish. - -static mut LOGGER: *const Log = &NopLogger; -static STATE: AtomicUsize = ATOMIC_USIZE_INIT; -static REFCOUNT: AtomicUsize = ATOMIC_USIZE_INIT; - -const UNINITIALIZED: usize = 0; -const INITIALIZING: usize = 1; -const INITIALIZED: usize = 2; - -static MAX_LOG_LEVEL_FILTER: AtomicUsize = ATOMIC_USIZE_INIT; - -static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO", - "DEBUG", "TRACE"]; - -/// An enum representing the available verbosity levels of the logging framework -/// -/// A `LogLevel` may be compared directly to a `LogLevelFilter`. -#[repr(usize)] -#[derive(Copy, Eq, Debug)] -pub enum LogLevel { - /// The "error" level. - /// - /// Designates very serious errors. - Error = 1, // This way these line up with the discriminants for LogLevelFilter below - /// The "warn" level. - /// - /// Designates hazardous situations. - Warn, - /// The "info" level. - /// - /// Designates useful information. - Info, - /// The "debug" level. - /// - /// Designates lower priority information. - Debug, - /// The "trace" level. - /// - /// Designates very low priority, often extremely verbose, information. - Trace, -} - -impl Clone for LogLevel { - #[inline] - fn clone(&self) -> LogLevel { - *self - } -} - -impl PartialEq for LogLevel { - #[inline] - fn eq(&self, other: &LogLevel) -> bool { - *self as usize == *other as usize - } -} - -impl PartialEq<LogLevelFilter> for LogLevel { - #[inline] - fn eq(&self, other: &LogLevelFilter) -> bool { - *self as usize == *other as usize - } -} - -impl PartialOrd for LogLevel { - #[inline] - fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> { - Some(self.cmp(other)) - } -} - -impl PartialOrd<LogLevelFilter> for LogLevel { - #[inline] - fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> { - Some((*self as usize).cmp(&(*other as usize))) - } -} - -impl Ord for LogLevel { - #[inline] - fn cmp(&self, other: &LogLevel) -> cmp::Ordering { - (*self as usize).cmp(&(*other as usize)) - } -} - -fn ok_or<T, E>(t: Option<T>, e: E) -> Result<T, E> { - match t { - Some(t) => Ok(t), - None => Err(e), - } -} - -// Reimplemented here because std::ascii is not available in libcore -fn eq_ignore_ascii_case(a: &str, b: &str) -> bool { - fn to_ascii_uppercase(c: u8) -> u8 { - if c >= b'a' && c <= b'z' { - c - b'a' + b'A' - } else { - c - } - } - - if a.len() == b.len() { - a.bytes() - .zip(b.bytes()) - .all(|(a, b)| to_ascii_uppercase(a) == to_ascii_uppercase(b)) - } else { - false - } -} - -impl FromStr for LogLevel { - type Err = (); - fn from_str(level: &str) -> Result<LogLevel, ()> { - ok_or(LOG_LEVEL_NAMES.iter() - .position(|&name| eq_ignore_ascii_case(name, level)) - .into_iter() - .filter(|&idx| idx != 0) - .map(|idx| LogLevel::from_usize(idx).unwrap()) - .next(), ()) - } -} - -impl fmt::Display for LogLevel { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.pad(LOG_LEVEL_NAMES[*self as usize]) - } -} - -impl LogLevel { - fn from_usize(u: usize) -> Option<LogLevel> { - match u { - 1 => Some(LogLevel::Error), - 2 => Some(LogLevel::Warn), - 3 => Some(LogLevel::Info), - 4 => Some(LogLevel::Debug), - 5 => Some(LogLevel::Trace), - _ => None - } - } - - /// Returns the most verbose logging level. - #[inline] - pub fn max() -> LogLevel { - LogLevel::Trace - } - - /// Converts the `LogLevel` to the equivalent `LogLevelFilter`. - #[inline] - pub fn to_log_level_filter(&self) -> LogLevelFilter { - LogLevelFilter::from_usize(*self as usize).unwrap() - } -} - -/// An enum representing the available verbosity level filters of the logging -/// framework. -/// -/// A `LogLevelFilter` may be compared directly to a `LogLevel`. -#[repr(usize)] -#[derive(Copy, Eq, Debug)] -pub enum LogLevelFilter { - /// A level lower than all log levels. - Off, - /// Corresponds to the `Error` log level. - Error, - /// Corresponds to the `Warn` log level. - Warn, - /// Corresponds to the `Info` log level. - Info, - /// Corresponds to the `Debug` log level. - Debug, - /// Corresponds to the `Trace` log level. - Trace, -} - -// Deriving generates terrible impls of these traits - -impl Clone for LogLevelFilter { - #[inline] - fn clone(&self) -> LogLevelFilter { - *self - } -} - -impl PartialEq for LogLevelFilter { - #[inline] - fn eq(&self, other: &LogLevelFilter) -> bool { - *self as usize == *other as usize - } -} - -impl PartialEq<LogLevel> for LogLevelFilter { - #[inline] - fn eq(&self, other: &LogLevel) -> bool { - other.eq(self) - } -} - -impl PartialOrd for LogLevelFilter { - #[inline] - fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> { - Some(self.cmp(other)) - } -} - -impl PartialOrd<LogLevel> for LogLevelFilter { - #[inline] - fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> { - other.partial_cmp(self).map(|x| x.reverse()) - } -} - -impl Ord for LogLevelFilter { - #[inline] - fn cmp(&self, other: &LogLevelFilter) -> cmp::Ordering { - (*self as usize).cmp(&(*other as usize)) - } -} - -impl FromStr for LogLevelFilter { - type Err = (); - fn from_str(level: &str) -> Result<LogLevelFilter, ()> { - ok_or(LOG_LEVEL_NAMES.iter() - .position(|&name| eq_ignore_ascii_case(name, level)) - .map(|p| LogLevelFilter::from_usize(p).unwrap()), ()) - } -} - -impl fmt::Display for LogLevelFilter { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{}", LOG_LEVEL_NAMES[*self as usize]) - } -} - -impl LogLevelFilter { - fn from_usize(u: usize) -> Option<LogLevelFilter> { - match u { - 0 => Some(LogLevelFilter::Off), - 1 => Some(LogLevelFilter::Error), - 2 => Some(LogLevelFilter::Warn), - 3 => Some(LogLevelFilter::Info), - 4 => Some(LogLevelFilter::Debug), - 5 => Some(LogLevelFilter::Trace), - _ => None - } - } - /// Returns the most verbose logging level filter. - #[inline] - pub fn max() -> LogLevelFilter { - LogLevelFilter::Trace - } - - /// Converts `self` to the equivalent `LogLevel`. - /// - /// Returns `None` if `self` is `LogLevelFilter::Off`. - #[inline] - pub fn to_log_level(&self) -> Option<LogLevel> { - LogLevel::from_usize(*self as usize) - } -} - -/// The "payload" of a log message. -pub struct LogRecord<'a> { - metadata: LogMetadata<'a>, - location: &'a LogLocation, - args: fmt::Arguments<'a>, -} - -impl<'a> LogRecord<'a> { - /// The message body. - pub fn args(&self) -> &fmt::Arguments<'a> { - &self.args - } - - /// Metadata about the log directive. - pub fn metadata(&self) -> &LogMetadata { - &self.metadata - } - - /// The location of the log directive. - pub fn location(&self) -> &LogLocation { - self.location - } - - /// The verbosity level of the message. - pub fn level(&self) -> LogLevel { - self.metadata.level() - } - - /// The name of the target of the directive. - pub fn target(&self) -> &str { - self.metadata.target() - } -} - -/// Metadata about a log message. -pub struct LogMetadata<'a> { - level: LogLevel, - target: &'a str, -} - -impl<'a> LogMetadata<'a> { - /// The verbosity level of the message. - pub fn level(&self) -> LogLevel { - self.level - } - - /// The name of the target of the directive. - pub fn target(&self) -> &str { - self.target - } -} - -/// A trait encapsulating the operations required of a logger -pub trait Log: Sync+Send { - /// Determines if a log message with the specified metadata would be - /// logged. - /// - /// This is used by the `log_enabled!` macro to allow callers to avoid - /// expensive computation of log message arguments if the message would be - /// discarded anyway. - fn enabled(&self, metadata: &LogMetadata) -> bool; - - /// Logs the `LogRecord`. - /// - /// Note that `enabled` is *not* necessarily called before this method. - /// Implementations of `log` should perform all necessary filtering - /// internally. - fn log(&self, record: &LogRecord); -} - -// Just used as a dummy initial value for LOGGER -struct NopLogger; - -impl Log for NopLogger { - fn enabled(&self, _: &LogMetadata) -> bool { false } - - fn log(&self, _: &LogRecord) {} -} - -/// The location of a log message. -/// -/// # Warning -/// -/// The fields of this struct are public so that they may be initialized by the -/// `log!` macro. They are subject to change at any time and should never be -/// accessed directly. -#[derive(Copy, Clone, Debug)] -pub struct LogLocation { - #[doc(hidden)] - pub __module_path: &'static str, - #[doc(hidden)] - pub __file: &'static str, - #[doc(hidden)] - pub __line: u32, -} - -impl LogLocation { - /// The module path of the message. - pub fn module_path(&self) -> &str { - self.__module_path - } - - /// The source file containing the message. - pub fn file(&self) -> &str { - self.__file - } - - /// The line containing the message. - pub fn line(&self) -> u32 { - self.__line - } -} - -/// A token providing read and write access to the global maximum log level -/// filter. -/// -/// The maximum log level is used as an optimization to avoid evaluating log -/// messages that will be ignored by the logger. Any message with a level -/// higher than the maximum log level filter will be ignored. A logger should -/// make sure to keep the maximum log level filter in sync with its current -/// configuration. -#[allow(missing_copy_implementations)] -pub struct MaxLogLevelFilter(()); - -impl fmt::Debug for MaxLogLevelFilter { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "MaxLogLevelFilter") - } -} - -impl MaxLogLevelFilter { - /// Gets the current maximum log level filter. - pub fn get(&self) -> LogLevelFilter { - max_log_level() - } - - /// Sets the maximum log level. - pub fn set(&self, level: LogLevelFilter) { - MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst) - } -} - -/// Returns the current maximum log level. -/// -/// The `log!`, `error!`, `warn!`, `info!`, `debug!`, and `trace!` macros check -/// this value and discard any message logged at a higher level. The maximum -/// log level is set by the `MaxLogLevel` token passed to loggers. -#[inline(always)] -pub fn max_log_level() -> LogLevelFilter { - unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) } -} - -/// Sets the global logger. -/// -/// The `make_logger` closure is passed a `MaxLogLevel` object, which the -/// logger should use to keep the global maximum log level in sync with the -/// highest log level that the logger will not ignore. -/// -/// This function may only be called once in the lifetime of a program. Any log -/// events that occur before the call to `set_logger` completes will be -/// ignored. -/// -/// This function does not typically need to be called manually. Logger -/// implementations should provide an initialization method that calls -/// `set_logger` internally. -/// -/// Requires the `use_std` feature (enabled by default). -#[cfg(feature = "use_std")] -pub fn set_logger<M>(make_logger: M) -> Result<(), SetLoggerError> - where M: FnOnce(MaxLogLevelFilter) -> Box<Log> { - unsafe { set_logger_raw(|max_level| mem::transmute(make_logger(max_level))) } -} - -/// Sets the global logger from a raw pointer. -/// -/// This function is similar to `set_logger` except that it is usable in -/// `no_std` code. -/// -/// The `make_logger` closure is passed a `MaxLogLevel` object, which the -/// logger should use to keep the global maximum log level in sync with the -/// highest log level that the logger will not ignore. -/// -/// This function may only be called once in the lifetime of a program. Any log -/// events that occur before the call to `set_logger_raw` completes will be -/// ignored. -/// -/// This function does not typically need to be called manually. Logger -/// implementations should provide an initialization method that calls -/// `set_logger_raw` internally. -/// -/// # Safety -/// -/// The pointer returned by `make_logger` must remain valid for the entire -/// duration of the program or until `shutdown_logger_raw` is called. In -/// addition, `shutdown_logger` *must not* be called after this function. -pub unsafe fn set_logger_raw<M>(make_logger: M) -> Result<(), SetLoggerError> - where M: FnOnce(MaxLogLevelFilter) -> *const Log { - if STATE.compare_and_swap(UNINITIALIZED, INITIALIZING, - Ordering::SeqCst) != UNINITIALIZED { - return Err(SetLoggerError(())); - } - - LOGGER = make_logger(MaxLogLevelFilter(())); - STATE.store(INITIALIZED, Ordering::SeqCst); - Ok(()) -} - -/// Shuts down the global logger. -/// -/// This function may only be called once in the lifetime of a program, and may -/// not be called before `set_logger`. Once the global logger has been shut -/// down, it can no longer be re-initialized by `set_logger`. Any log events -/// that occur after the call to `shutdown_logger` completes will be ignored. -/// -/// The logger that was originally created by the call to to `set_logger` is -/// returned on success. At that point it is guaranteed that no other threads -/// are concurrently accessing the logger object. -#[cfg(feature = "use_std")] -pub fn shutdown_logger() -> Result<Box<Log>, ShutdownLoggerError> { - shutdown_logger_raw().map(|l| unsafe { mem::transmute(l) }) -} - -/// Shuts down the global logger. -/// -/// This function is similar to `shutdown_logger` except that it is usable in -/// `no_std` code. -/// -/// This function may only be called once in the lifetime of a program, and may -/// not be called before `set_logger_raw`. Once the global logger has been shut -/// down, it can no longer be re-initialized by `set_logger_raw`. Any log -/// events that occur after the call to `shutdown_logger_raw` completes will be -/// ignored. -/// -/// The pointer that was originally passed to `set_logger_raw` is returned on -/// success. At that point it is guaranteed that no other threads are -/// concurrently accessing the logger object. -pub fn shutdown_logger_raw() -> Result<*const Log, ShutdownLoggerError> { - // Set the global log level to stop other thread from logging - MAX_LOG_LEVEL_FILTER.store(0, Ordering::SeqCst); - - // Set to INITIALIZING to prevent re-initialization after - if STATE.compare_and_swap(INITIALIZED, INITIALIZING, - Ordering::SeqCst) != INITIALIZED { - return Err(ShutdownLoggerError(())); - } - - while REFCOUNT.load(Ordering::SeqCst) != 0 { - // FIXME add a sleep here when it doesn't involve timers - } - - unsafe { - let logger = LOGGER; - LOGGER = &NopLogger; - Ok(logger) - } -} - -/// The type returned by `set_logger` if `set_logger` has already been called. -#[allow(missing_copy_implementations)] -#[derive(Debug)] -pub struct SetLoggerError(()); - -impl fmt::Display for SetLoggerError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "attempted to set a logger after the logging system \ - was already initialized") - } -} - -// The Error trait is not available in libcore -#[cfg(feature = "use_std")] -impl error::Error for SetLoggerError { - fn description(&self) -> &str { "set_logger() called multiple times" } -} - -/// The type returned by `shutdown_logger_raw` if `shutdown_logger_raw` has -/// already been called or if `set_logger_raw` has not been called yet. -#[allow(missing_copy_implementations)] -#[derive(Debug)] -pub struct ShutdownLoggerError(()); - -impl fmt::Display for ShutdownLoggerError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "attempted to shut down the logger without an active logger") - } -} - -// The Error trait is not available in libcore -#[cfg(feature = "use_std")] -impl error::Error for ShutdownLoggerError { - fn description(&self) -> &str { "shutdown_logger() called without an active logger" } -} - -/// Registers a panic hook which logs at the error level. -/// -/// The format is the same as the default panic hook . The reporting module is -/// `log::panic`. -/// -/// Requires the `use_std` (enabled by default) and `nightly` features. -#[cfg(all(feature = "nightly", feature = "use_std"))] -pub fn log_panics() { - std::panic::set_hook(Box::new(panic::log)); -} - -// inner module so that the reporting module is log::panic instead of log -#[cfg(all(feature = "nightly", feature = "use_std"))] -mod panic { - use std::panic::PanicInfo; - use std::thread; - - pub fn log(info: &PanicInfo) { - let thread = thread::current(); - let thread = thread.name().unwrap_or("<unnamed>"); - - let msg = match info.payload().downcast_ref::<&'static str>() { - Some(s) => *s, - None => match info.payload().downcast_ref::<String>() { - Some(s) => &s[..], - None => "Box<Any>", - } - }; - - match info.location() { - Some(location) => { - error!("thread '{}' panicked at '{}': {}:{}", - thread, - msg, - location.file(), - location.line()) - } - None => error!("thread '{}' panicked at '{}'", thread, msg), - } - } -} - -struct LoggerGuard(&'static Log); - -impl Drop for LoggerGuard { - fn drop(&mut self) { - REFCOUNT.fetch_sub(1, Ordering::SeqCst); - } -} - -impl Deref for LoggerGuard { - type Target = Log; - - fn deref(&self) -> &(Log + 'static) { - self.0 - } -} - -fn logger() -> Option<LoggerGuard> { - REFCOUNT.fetch_add(1, Ordering::SeqCst); - if STATE.load(Ordering::SeqCst) != INITIALIZED { - REFCOUNT.fetch_sub(1, Ordering::SeqCst); - None - } else { - Some(LoggerGuard(unsafe { &*LOGGER })) - } -} - -// WARNING -// This is not considered part of the crate's public API. It is subject to -// change at any time. -#[doc(hidden)] -pub fn __enabled(level: LogLevel, target: &str) -> bool { - if let Some(logger) = logger() { - logger.enabled(&LogMetadata { level: level, target: target }) - } else { - false - } -} - -// WARNING -// This is not considered part of the crate's public API. It is subject to -// change at any time. -#[doc(hidden)] -pub fn __log(level: LogLevel, target: &str, loc: &LogLocation, - args: fmt::Arguments) { - if let Some(logger) = logger() { - let record = LogRecord { - metadata: LogMetadata { - level: level, - target: target, - }, - location: loc, - args: args - }; - logger.log(&record) - } -} - -// WARNING -// This is not considered part of the crate's public API. It is subject to -// change at any time. -#[inline(always)] -#[doc(hidden)] -pub fn __static_max_level() -> LogLevelFilter { - if !cfg!(debug_assertions) { - // This is a release build. Check `release_max_level_*` first. - if cfg!(feature = "release_max_level_off") { - return LogLevelFilter::Off - } else if cfg!(feature = "release_max_level_error") { - return LogLevelFilter::Error - } else if cfg!(feature = "release_max_level_warn") { - return LogLevelFilter::Warn - } else if cfg!(feature = "release_max_level_info") { - return LogLevelFilter::Info - } else if cfg!(feature = "release_max_level_debug") { - return LogLevelFilter::Debug - } else if cfg!(feature = "release_max_level_trace") { - return LogLevelFilter::Trace - } - } - if cfg!(feature = "max_level_off") { - LogLevelFilter::Off - } else if cfg!(feature = "max_level_error") { - LogLevelFilter::Error - } else if cfg!(feature = "max_level_warn") { - LogLevelFilter::Warn - } else if cfg!(feature = "max_level_info") { - LogLevelFilter::Info - } else if cfg!(feature = "max_level_debug") { - LogLevelFilter::Debug - } else { - LogLevelFilter::Trace - } -} - -#[cfg(test)] -mod tests { - extern crate std; - use tests::std::string::ToString; - use super::{LogLevel, LogLevelFilter}; - - #[test] - fn test_loglevelfilter_from_str() { - let tests = [ - ("off", Ok(LogLevelFilter::Off)), - ("error", Ok(LogLevelFilter::Error)), - ("warn", Ok(LogLevelFilter::Warn)), - ("info", Ok(LogLevelFilter::Info)), - ("debug", Ok(LogLevelFilter::Debug)), - ("trace", Ok(LogLevelFilter::Trace)), - ("OFF", Ok(LogLevelFilter::Off)), - ("ERROR", Ok(LogLevelFilter::Error)), - ("WARN", Ok(LogLevelFilter::Warn)), - ("INFO", Ok(LogLevelFilter::Info)), - ("DEBUG", Ok(LogLevelFilter::Debug)), - ("TRACE", Ok(LogLevelFilter::Trace)), - ("asdf", Err(())), - ]; - for &(s, ref expected) in &tests { - assert_eq!(expected, &s.parse()); - } - } - - #[test] - fn test_loglevel_from_str() { - let tests = [ - ("OFF", Err(())), - ("error", Ok(LogLevel::Error)), - ("warn", Ok(LogLevel::Warn)), - ("info", Ok(LogLevel::Info)), - ("debug", Ok(LogLevel::Debug)), - ("trace", Ok(LogLevel::Trace)), - ("ERROR", Ok(LogLevel::Error)), - ("WARN", Ok(LogLevel::Warn)), - ("INFO", Ok(LogLevel::Info)), - ("DEBUG", Ok(LogLevel::Debug)), - ("TRACE", Ok(LogLevel::Trace)), - ("asdf", Err(())), - ]; - for &(s, ref expected) in &tests { - assert_eq!(expected, &s.parse()); - } - } - - #[test] - fn test_loglevel_show() { - assert_eq!("INFO", LogLevel::Info.to_string()); - assert_eq!("ERROR", LogLevel::Error.to_string()); - } - - #[test] - fn test_loglevelfilter_show() { - assert_eq!("OFF", LogLevelFilter::Off.to_string()); - assert_eq!("ERROR", LogLevelFilter::Error.to_string()); - } - - #[test] - fn test_cross_cmp() { - assert!(LogLevel::Debug > LogLevelFilter::Error); - assert!(LogLevelFilter::Warn < LogLevel::Trace); - assert!(LogLevelFilter::Off < LogLevel::Error); - } - - #[test] - fn test_cross_eq() { - assert!(LogLevel::Error == LogLevelFilter::Error); - assert!(LogLevelFilter::Off != LogLevel::Error); - assert!(LogLevel::Trace == LogLevelFilter::Trace); - } - - #[test] - fn test_to_log_level() { - assert_eq!(Some(LogLevel::Error), LogLevelFilter::Error.to_log_level()); - assert_eq!(None, LogLevelFilter::Off.to_log_level()); - assert_eq!(Some(LogLevel::Debug), LogLevelFilter::Debug.to_log_level()); - } - - #[test] - fn test_to_log_level_filter() { - assert_eq!(LogLevelFilter::Error, LogLevel::Error.to_log_level_filter()); - assert_eq!(LogLevelFilter::Trace, LogLevel::Trace.to_log_level_filter()); - } - - #[test] - #[cfg(feature = "use_std")] - fn test_error_trait() { - use std::error::Error; - use super::SetLoggerError; - let e = SetLoggerError(()); - assert_eq!(e.description(), "set_logger() called multiple times"); - } -} diff --git a/src/vendor/log/src/macros.rs b/src/vendor/log/src/macros.rs deleted file mode 100644 index 7037f9ac0de..00000000000 --- a/src/vendor/log/src/macros.rs +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2014-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. -/// The standard logging macro. -/// -/// This macro will generically log with the specified `LogLevel` and `format!` -/// based argument list. -/// -/// The `max_level_*` features can be used to statically disable logging at -/// various levels. -#[macro_export] -macro_rules! log { - (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({ - static _LOC: $crate::LogLocation = $crate::LogLocation { - __line: line!(), - __file: file!(), - __module_path: module_path!(), - }; - let lvl = $lvl; - if lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() { - $crate::__log(lvl, $target, &_LOC, format_args!($($arg)+)) - } - }); - ($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+)) -} - -/// Logs a message at the error level. -/// -/// Logging at this level is disabled if the `max_level_off` feature is present. -#[macro_export] -macro_rules! error { - (target: $target:expr, $($arg:tt)*) => ( - log!(target: $target, $crate::LogLevel::Error, $($arg)*); - ); - ($($arg:tt)*) => ( - log!($crate::LogLevel::Error, $($arg)*); - ) -} - -/// Logs a message at the warn level. -/// -/// Logging at this level is disabled if any of the following features are -/// present: `max_level_off` or `max_level_error`. -/// -/// When building in release mode (i.e., without the `debug_assertions` option), -/// logging at this level is also disabled if any of the following features are -/// present: `release_max_level_off` or `max_level_error`. -#[macro_export] -macro_rules! warn { - (target: $target:expr, $($arg:tt)*) => ( - log!(target: $target, $crate::LogLevel::Warn, $($arg)*); - ); - ($($arg:tt)*) => ( - log!($crate::LogLevel::Warn, $($arg)*); - ) -} - -/// Logs a message at the info level. -/// -/// Logging at this level is disabled if any of the following features are -/// present: `max_level_off`, `max_level_error`, or `max_level_warn`. -/// -/// When building in release mode (i.e., without the `debug_assertions` option), -/// logging at this level is also disabled if any of the following features are -/// present: `release_max_level_off`, `release_max_level_error`, or -/// `release_max_level_warn`. -#[macro_export] -macro_rules! info { - (target: $target:expr, $($arg:tt)*) => ( - log!(target: $target, $crate::LogLevel::Info, $($arg)*); - ); - ($($arg:tt)*) => ( - log!($crate::LogLevel::Info, $($arg)*); - ) -} - -/// Logs a message at the debug level. -/// -/// Logging at this level is disabled if any of the following features are -/// present: `max_level_off`, `max_level_error`, `max_level_warn`, or -/// `max_level_info`. -/// -/// When building in release mode (i.e., without the `debug_assertions` option), -/// logging at this level is also disabled if any of the following features are -/// present: `release_max_level_off`, `release_max_level_error`, -/// `release_max_level_warn`, or `release_max_level_info`. -#[macro_export] -macro_rules! debug { - (target: $target:expr, $($arg:tt)*) => ( - log!(target: $target, $crate::LogLevel::Debug, $($arg)*); - ); - ($($arg:tt)*) => ( - log!($crate::LogLevel::Debug, $($arg)*); - ) -} - -/// Logs a message at the trace level. -/// -/// Logging at this level is disabled if any of the following features are -/// present: `max_level_off`, `max_level_error`, `max_level_warn`, -/// `max_level_info`, or `max_level_debug`. -/// -/// When building in release mode (i.e., without the `debug_assertions` option), -/// logging at this level is also disabled if any of the following features are -/// present: `release_max_level_off`, `release_max_level_error`, -/// `release_max_level_warn`, `release_max_level_info`, or -/// `release_max_level_debug`. -#[macro_export] -macro_rules! trace { - (target: $target:expr, $($arg:tt)*) => ( - log!(target: $target, $crate::LogLevel::Trace, $($arg)*); - ); - ($($arg:tt)*) => ( - log!($crate::LogLevel::Trace, $($arg)*); - ) -} - -/// Determines if a message logged at the specified level in that module will -/// be logged. -/// -/// This can be used to avoid expensive computation of log message arguments if -/// the message would be ignored anyway. -/// -/// # Examples -/// -/// ```rust -/// # #[macro_use] -/// # extern crate log; -/// use log::LogLevel::Debug; -/// -/// # fn foo() { -/// if log_enabled!(Debug) { -/// let data = expensive_call(); -/// debug!("expensive debug data: {} {}", data.x, data.y); -/// } -/// # } -/// # struct Data { x: u32, y: u32 } -/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } } -/// # fn main() {} -/// ``` -#[macro_export] -macro_rules! log_enabled { - (target: $target:expr, $lvl:expr) => ({ - let lvl = $lvl; - lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() && - $crate::__enabled(lvl, $target) - }); - ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl)) -} diff --git a/src/vendor/log/tests/filters.rs b/src/vendor/log/tests/filters.rs deleted file mode 100644 index e08d46db195..00000000000 --- a/src/vendor/log/tests/filters.rs +++ /dev/null @@ -1,76 +0,0 @@ -#[macro_use] extern crate log; - -use std::sync::{Arc, Mutex}; -use log::{LogLevel, LogLevelFilter, Log, LogRecord, LogMetadata}; -use log::MaxLogLevelFilter; - -#[cfg(feature = "use_std")] -use log::set_logger; -#[cfg(not(feature = "use_std"))] -fn set_logger<M>(make_logger: M) -> Result<(), log::SetLoggerError> - where M: FnOnce(MaxLogLevelFilter) -> Box<Log> { - unsafe { - log::set_logger_raw(|x| std::mem::transmute(make_logger(x))) - } -} - -struct State { - last_log: Mutex<Option<LogLevel>>, - filter: MaxLogLevelFilter, -} - -struct Logger(Arc<State>); - -impl Log for Logger { - fn enabled(&self, _: &LogMetadata) -> bool { - true - } - - fn log(&self, record: &LogRecord) { - *self.0.last_log.lock().unwrap() = Some(record.level()); - } -} - -fn main() { - let mut a = None; - set_logger(|max| { - let me = Arc::new(State { - last_log: Mutex::new(None), - filter: max, - }); - a = Some(me.clone()); - Box::new(Logger(me)) - }).unwrap(); - let a = a.unwrap(); - - test(&a, LogLevelFilter::Off); - test(&a, LogLevelFilter::Error); - test(&a, LogLevelFilter::Warn); - test(&a, LogLevelFilter::Info); - test(&a, LogLevelFilter::Debug); - test(&a, LogLevelFilter::Trace); -} - -fn test(a: &State, filter: LogLevelFilter) { - a.filter.set(filter); - error!(""); - last(&a, t(LogLevel::Error, filter)); - warn!(""); - last(&a, t(LogLevel::Warn, filter)); - info!(""); - last(&a, t(LogLevel::Info, filter)); - debug!(""); - last(&a, t(LogLevel::Debug, filter)); - trace!(""); - last(&a, t(LogLevel::Trace, filter)); - - fn t(lvl: LogLevel, filter: LogLevelFilter) -> Option<LogLevel> { - if lvl <= filter {Some(lvl)} else {None} - } -} - -fn last(state: &State, expected: Option<LogLevel>) { - let mut lvl = state.last_log.lock().unwrap(); - assert_eq!(*lvl, expected); - *lvl = None; -} diff --git a/src/vendor/num_cpus/.cargo-checksum.json b/src/vendor/num_cpus/.cargo-checksum.json deleted file mode 100644 index 18d604e29e1..00000000000 --- a/src/vendor/num_cpus/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805","Cargo.toml":"934724b164e0fcfd6ba88e6eafc0425a786e544b64dddeba2078b15d35d7da9b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0593d22d122d4bfec6407115e3907546312976f75473417aaa4c57ecd2095ae6","README.md":"0a93f73d6f78677be73b67788ea7be1f358b776df26ebc09ee3326615601f33e","src/lib.rs":"f894837b10b1a0181dd6aa297e0e1d4c903c4e0ceccdb531ca0aa0cc3806616c"},"package":"cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3"} \ No newline at end of file diff --git a/src/vendor/num_cpus/.cargo-ok b/src/vendor/num_cpus/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/num_cpus/.cargo-ok +++ /dev/null diff --git a/src/vendor/num_cpus/.gitignore b/src/vendor/num_cpus/.gitignore deleted file mode 100644 index a9d37c560c6..00000000000 --- a/src/vendor/num_cpus/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -Cargo.lock diff --git a/src/vendor/num_cpus/Cargo.toml b/src/vendor/num_cpus/Cargo.toml deleted file mode 100644 index 4a6418b232c..00000000000 --- a/src/vendor/num_cpus/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] - -name = "num_cpus" -version = "0.2.13" -description = "Get the number of CPUs on a machine." -authors = ["Sean McArthur <sean.monstar@gmail.com>"] -license = "MIT/Apache-2.0" -repository = "https://github.com/seanmonstar/num_cpus" - - -[dependencies] -libc = "0.2" diff --git a/src/vendor/num_cpus/LICENSE-APACHE b/src/vendor/num_cpus/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/num_cpus/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/src/vendor/num_cpus/LICENSE-MIT b/src/vendor/num_cpus/LICENSE-MIT deleted file mode 100644 index 8e91dc998a9..00000000000 --- a/src/vendor/num_cpus/LICENSE-MIT +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2015 - -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/src/vendor/num_cpus/README.md b/src/vendor/num_cpus/README.md deleted file mode 100644 index 3628e858e92..00000000000 --- a/src/vendor/num_cpus/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# num_cpus - -A replacement for the deprecated `std::os::num_cpus`. - -## Usage - -Add to Cargo.toml: - -``` -[dependencies] -num_cpus = "0.2" -``` - -In your `main.rs` or `lib.rs`: - -```rust -extern crate num_cpus; - -// elsewhere -let num = num_cpus::get(); -``` - -## 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/src/vendor/num_cpus/src/lib.rs b/src/vendor/num_cpus/src/lib.rs deleted file mode 100644 index 809b8d8ad1d..00000000000 --- a/src/vendor/num_cpus/src/lib.rs +++ /dev/null @@ -1,116 +0,0 @@ -//! Replaces the deprecated functionality of std::os::num_cpus. -#![cfg_attr(test, deny(warnings))] -#![deny(missing_docs)] -#![allow(non_snake_case)] - -#[cfg(not(windows))] -extern crate libc; - -/// Returns the number of CPUs of the current machine. -#[inline] -pub fn get() -> usize { - get_num_cpus() -} - -#[cfg(windows)] -fn get_num_cpus() -> usize { - #[repr(C)] - struct SYSTEM_INFO { - wProcessorArchitecture: u16, - wReserved: u16, - dwPageSize: u32, - lpMinimumApplicationAddress: *mut u8, - lpMaximumApplicationAddress: *mut u8, - dwActiveProcessorMask: *mut u8, - dwNumberOfProcessors: u32, - dwProcessorType: u32, - dwAllocationGranularity: u32, - wProcessorLevel: u16, - wProcessorRevision: u16, - } - - extern "system" { - fn GetSystemInfo(lpSystemInfo: *mut SYSTEM_INFO); - } - - unsafe { - let mut sysinfo: SYSTEM_INFO = std::mem::uninitialized(); - GetSystemInfo(&mut sysinfo); - sysinfo.dwNumberOfProcessors as usize - } -} - -#[cfg(any(target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd"))] -fn get_num_cpus() -> usize { - let mut cpus: libc::c_uint = 0; - let mut cpus_size = std::mem::size_of_val(&cpus); - - unsafe { - cpus = libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as libc::c_uint; - } - if cpus < 1 { - let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0]; - unsafe { - libc::sysctl(mib.as_mut_ptr(), - 2, - &mut cpus as *mut _ as *mut _, - &mut cpus_size as *mut _ as *mut _, - 0 as *mut _, - 0); - } - if cpus < 1 { - cpus = 1; - } - } - cpus as usize -} - -#[cfg(target_os = "openbsd")] -fn get_num_cpus() -> usize { - let mut cpus: libc::c_uint = 0; - let mut cpus_size = std::mem::size_of_val(&cpus); - let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0]; - - unsafe { - libc::sysctl(mib.as_mut_ptr(), - 2, - &mut cpus as *mut _ as *mut _, - &mut cpus_size as *mut _ as *mut _, - 0 as *mut _, - 0); - } - if cpus < 1 { - cpus = 1; - } - cpus as usize -} - -#[cfg( - any( - target_os = "linux", - target_os = "nacl", - target_os = "macos", - target_os = "ios", - target_os = "android", - target_os = "solaris", - ) -)] -fn get_num_cpus() -> usize { - unsafe { - libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize - } -} - -#[test] -fn lower_bound() { - assert!(get() > 0); -} - - -#[test] -fn upper_bound() { - assert!(get() < 236_451); -} diff --git a/src/vendor/rustc-serialize/.cargo-checksum.json b/src/vendor/rustc-serialize/.cargo-checksum.json deleted file mode 100644 index f4784c97912..00000000000 --- a/src/vendor/rustc-serialize/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"c1e953ee360e77de57f7b02f1b7880bd6a3dc22d1a69e953c2ac2c52cc52d247",".travis.yml":"b5b4e6935204150e66dd35eea5e2aae48f87987a2f8f9f4683e934216d07bc85","Cargo.toml":"f1c2eb2fa47a89f3572f7c25d616395c4140be85078f3649d30d217a961ac01e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"11c5bfb489de42f984b1380f8100edb794fb88f750c03e9c62aff0f53860e4d5","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","benches/base64.rs":"96f7d0c7d260362e41b8cefb4839f1e1b3c18c2f10344f6ccafac7c434f99ca9","benches/hex.rs":"057821307b4b7de02f2c267f9248457386035382916c5afe4b72d6f2e905062c","benches/json.rs":"659f2ae2e1ad5ed022fafce6418d17dfe09c3dcb3f054857dce0effc907da850","src/base64.rs":"21186423be90189baca9d902d7a2d4abb24845d52427ede22036e05218125c88","src/collection_impls.rs":"8ae6bc0d61a4777d834c2b24fa987550cb13c570e1564f87ee32eceff3cb2d5b","src/hex.rs":"e2d95034da31627bb7536c9e38388d8c6787e9976d89cf38cf2c8558bf3249b7","src/json.rs":"4754f85b9fa23600927e6b8a45a960d69cd9f701f5118817ed62bae3de2ec876","src/lib.rs":"6e7beb6b5c4ebcaadedb8a82e1cc17249f9a8da2a59d19e1af9dd9a75e8ddf6b","src/serialize.rs":"49c477148a8c823d0caba5bc37444282894d0a9919a0bf40d8b30ee293bd62f8"},"package":"6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b"} \ No newline at end of file diff --git a/src/vendor/rustc-serialize/.cargo-ok b/src/vendor/rustc-serialize/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/rustc-serialize/.cargo-ok +++ /dev/null diff --git a/src/vendor/rustc-serialize/.gitignore b/src/vendor/rustc-serialize/.gitignore deleted file mode 100644 index 4fffb2f89cb..00000000000 --- a/src/vendor/rustc-serialize/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/src/vendor/rustc-serialize/.travis.yml b/src/vendor/rustc-serialize/.travis.yml deleted file mode 100644 index eb446b23fe6..00000000000 --- a/src/vendor/rustc-serialize/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: rust -rust: - - 1.0.0 - - beta - - nightly -sudo: false -script: - - cargo build --verbose - - cargo test --verbose - - | - [ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose - - cargo doc -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - [ $TRAVIS_RUST_VERSION = nightly ] && - echo '<meta http-equiv=refresh content=0;url=/rustc-serialize/rustc_serialize/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: f0CwX+CnvRbEqK3H6zhBQe4u0t14OQvyd6nUhq/oXkJ6LdtrSx+qQtLSmAU7L8p1IXyP8csxv37bTdEB7/U1c6bJcN2OXHrw9nD0NDvZEs1zSZvFQBm+YBwV7EaposPHCeqee3X9b00g7+bObywMYtEkk7yD2NiOY9SjMRcjTLQ= -notifications: - email: - on_success: never diff --git a/src/vendor/rustc-serialize/Cargo.toml b/src/vendor/rustc-serialize/Cargo.toml deleted file mode 100644 index f0cb1a4845c..00000000000 --- a/src/vendor/rustc-serialize/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] - -name = "rustc-serialize" -version = "0.3.19" -authors = ["The Rust Project Developers"] -license = "MIT/Apache-2.0" -readme = "README.md" -repository = "https://github.com/rust-lang/rustc-serialize" -homepage = "https://github.com/rust-lang/rustc-serialize" -documentation = "https://doc.rust-lang.org/rustc-serialize" -description = """ -Generic serialization/deserialization support corresponding to the -`derive(RustcEncodable, RustcDecodable)` mode in the compiler. Also includes -support for hex, base64, and json encoding and decoding. -""" - -[dev-dependencies] -rand = "0.3" diff --git a/src/vendor/rustc-serialize/LICENSE-APACHE b/src/vendor/rustc-serialize/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/rustc-serialize/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/src/vendor/rustc-serialize/LICENSE-MIT b/src/vendor/rustc-serialize/LICENSE-MIT deleted file mode 100644 index 39d4bdb5acd..00000000000 --- a/src/vendor/rustc-serialize/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/src/vendor/rustc-serialize/README.md b/src/vendor/rustc-serialize/README.md deleted file mode 100644 index db2f5693aeb..00000000000 --- a/src/vendor/rustc-serialize/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# rustc-serialize - -Serialization and deserialization support provided by the compiler in the form -of `derive(RustcEncodable, RustcDecodable)`. - -[](https://travis-ci.org/rust-lang-nursery/rustc-serialize) -[](https://ci.appveyor.com/project/alexcrichton/rustc-serialize) - -[Documentation](https://doc.rust-lang.org/rustc-serialize) - -## Usage - -Add this to your `Cargo.toml`: - -```toml -[dependencies] -rustc-serialize = "0.3" -``` - -and this to your crate root: - -```rust -extern crate rustc_serialize; -``` diff --git a/src/vendor/rustc-serialize/appveyor.yml b/src/vendor/rustc-serialize/appveyor.yml deleted file mode 100644 index 6a1b8dc19c0..00000000000 --- a/src/vendor/rustc-serialize/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu -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 test --verbose diff --git a/src/vendor/rustc-serialize/benches/base64.rs b/src/vendor/rustc-serialize/benches/base64.rs deleted file mode 100644 index 6a6565bc148..00000000000 --- a/src/vendor/rustc-serialize/benches/base64.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![feature(test)] - -extern crate test; -extern crate rustc_serialize; - -use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD}; -use test::Bencher; - -#[bench] -fn bench_to_base64(b: &mut Bencher) { - let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ - ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; - b.iter(|| { - s.as_bytes().to_base64(STANDARD); - }); - b.bytes = s.len() as u64; -} - -#[bench] -fn bench_from_base64(b: &mut Bencher) { - let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ - ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; - let sb = s.as_bytes().to_base64(STANDARD); - b.iter(|| { - sb.from_base64().unwrap(); - }); - b.bytes = sb.len() as u64; -} - - -#[bench] -fn bench_to_base64_large(b: &mut Bencher) { - let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect(); - b.iter(|| { - s.to_base64(STANDARD); - }); - b.bytes = s.len() as u64; -} - -#[bench] -fn bench_from_base64_large(b: &mut Bencher) { - let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect(); - let sb = s.to_base64(STANDARD); - b.iter(|| { - sb.from_base64().unwrap(); - }); - b.bytes = sb.len() as u64; -} diff --git a/src/vendor/rustc-serialize/benches/hex.rs b/src/vendor/rustc-serialize/benches/hex.rs deleted file mode 100644 index 97a7735e817..00000000000 --- a/src/vendor/rustc-serialize/benches/hex.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![feature(test)] - -extern crate test; -extern crate rustc_serialize; - -use test::Bencher; -use rustc_serialize::hex::{FromHex, ToHex}; - -#[bench] -fn bench_to_hex(b: &mut Bencher) { - let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ - ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; - b.iter(|| { - s.as_bytes().to_hex(); - }); - b.bytes = s.len() as u64; -} - -#[bench] -fn bench_from_hex(b: &mut Bencher) { - let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ - ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; - let sb = s.as_bytes().to_hex(); - b.iter(|| { - sb.from_hex().unwrap(); - }); - b.bytes = sb.len() as u64; -} diff --git a/src/vendor/rustc-serialize/benches/json.rs b/src/vendor/rustc-serialize/benches/json.rs deleted file mode 100644 index 20768e116a7..00000000000 --- a/src/vendor/rustc-serialize/benches/json.rs +++ /dev/null @@ -1,84 +0,0 @@ -#![feature(test)] - -extern crate test; -extern crate rustc_serialize; - -use std::string; -use rustc_serialize::json::{Json, Parser}; -use test::Bencher; - -#[bench] -fn bench_streaming_small(b: &mut Bencher) { - b.iter( || { - let mut parser = Parser::new( - r#"{ - "a": 1.0, - "b": [ - true, - "foo\nbar", - { "c": {"d": null} } - ] - }"#.chars() - ); - loop { - match parser.next() { - None => return, - _ => {} - } - } - }); -} -#[bench] -fn bench_small(b: &mut Bencher) { - b.iter( || { - let _ = Json::from_str(r#"{ - "a": 1.0, - "b": [ - true, - "foo\nbar", - { "c": {"d": null} } - ] - }"#); - }); -} - -#[bench] -fn bench_decode_hex_escape(b: &mut Bencher) { - let mut src = "\"".to_string(); - for _ in 0..10 { - src.push_str("\\uF975\\uf9bc\\uF9A0\\uF9C4\\uF975\\uf9bc\\uF9A0\\uF9C4"); - } - src.push_str("\""); - b.iter( || { - let _ = Json::from_str(&src); - }); -} - -fn big_json() -> string::String { - let mut src = "[\n".to_string(); - for _ in 0..500 { - src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \ - [1,2,3]},"#); - } - src.push_str("{}]"); - return src; -} - -#[bench] -fn bench_streaming_large(b: &mut Bencher) { - let src = big_json(); - b.iter( || { - let mut parser = Parser::new(src.chars()); - loop { - match parser.next() { - None => return, - _ => {} - } - } - }); -} -#[bench] -fn bench_large(b: &mut Bencher) { - let src = big_json(); - b.iter( || { let _ = Json::from_str(&src); }); -} diff --git a/src/vendor/rustc-serialize/src/base64.rs b/src/vendor/rustc-serialize/src/base64.rs deleted file mode 100644 index dc2ba8a4f97..00000000000 --- a/src/vendor/rustc-serialize/src/base64.rs +++ /dev/null @@ -1,476 +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. -// -// ignore-lexer-test FIXME #15679 - -//! Base64 binary-to-text encoding - -pub use self::FromBase64Error::*; -pub use self::CharacterSet::*; - -use std::fmt; -use std::error; - -/// Available encoding character sets -#[derive(Clone, Copy, Debug)] -pub enum CharacterSet { - /// The standard character set (uses `+` and `/`) - Standard, - /// The URL safe character set (uses `-` and `_`) - UrlSafe -} - -/// Available newline types -#[derive(Clone, Copy, Debug)] -pub enum Newline { - /// A linefeed (i.e. Unix-style newline) - LF, - /// A carriage return and a linefeed (i.e. Windows-style newline) - CRLF -} - -/// Contains configuration parameters for `to_base64`. -#[derive(Clone, Copy, Debug)] -pub struct Config { - /// Character set to use - pub char_set: CharacterSet, - /// Newline to use - pub newline: Newline, - /// True to pad output with `=` characters - pub pad: bool, - /// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping - pub line_length: Option<usize> -} - -/// Configuration for RFC 4648 standard base64 encoding -pub static STANDARD: Config = - Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: None}; - -/// Configuration for RFC 4648 base64url encoding -pub static URL_SAFE: Config = - Config {char_set: UrlSafe, newline: Newline::CRLF, pad: false, line_length: None}; - -/// Configuration for RFC 2045 MIME base64 encoding -pub static MIME: Config = - Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: Some(76)}; - -static STANDARD_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ - abcdefghijklmnopqrstuvwxyz\ - 0123456789+/"; - -static URLSAFE_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ - abcdefghijklmnopqrstuvwxyz\ - 0123456789-_"; - -/// A trait for converting a value to base64 encoding. -pub trait ToBase64 { - /// Converts the value of `self` to a base64 value following the specified - /// format configuration, returning the owned string. - fn to_base64(&self, config: Config) -> String; -} - -impl ToBase64 for [u8] { - /// Turn a vector of `u8` bytes into a base64 string. - /// - /// # Example - /// - /// ```rust - /// extern crate rustc_serialize; - /// use rustc_serialize::base64::{ToBase64, STANDARD}; - /// - /// fn main () { - /// let str = [52,32].to_base64(STANDARD); - /// println!("base 64 output: {:?}", str); - /// } - /// ``` - fn to_base64(&self, config: Config) -> String { - let bytes = match config.char_set { - Standard => STANDARD_CHARS, - UrlSafe => URLSAFE_CHARS - }; - - let len = self.len(); - let newline = match config.newline { - Newline::LF => "\n", - Newline::CRLF => "\r\n", - }; - - // Preallocate memory. - let mut prealloc_len = (len + 2) / 3 * 4; - if let Some(line_length) = config.line_length { - let num_lines = match prealloc_len { - 0 => 0, - n => (n - 1) / line_length - }; - prealloc_len += num_lines * newline.bytes().count(); - } - - let mut out_bytes = vec![b'='; prealloc_len]; - - // Deal with padding bytes - let mod_len = len % 3; - - // Use iterators to reduce branching - { - let mut cur_length = 0; - - let mut s_in = self[..len - mod_len].iter().map(|&x| x as u32); - let mut s_out = out_bytes.iter_mut(); - - // Convenient shorthand - let enc = |val| bytes[val as usize]; - let mut write = |val| *s_out.next().unwrap() = val; - - // Iterate though blocks of 4 - while let (Some(first), Some(second), Some(third)) = - (s_in.next(), s_in.next(), s_in.next()) { - - // Line break if needed - if let Some(line_length) = config.line_length { - if cur_length >= line_length { - for b in newline.bytes() { write(b) }; - cur_length = 0; - } - } - - let n = first << 16 | second << 8 | third; - - // This 24-bit number gets separated into four 6-bit numbers. - write(enc((n >> 18) & 63)); - write(enc((n >> 12) & 63)); - write(enc((n >> 6 ) & 63)); - write(enc((n >> 0 ) & 63)); - - cur_length += 4; - } - - // Line break only needed if padding is required - if mod_len != 0 { - if let Some(line_length) = config.line_length { - if cur_length >= line_length { - for b in newline.bytes() { write(b) }; - } - } - } - - // Heh, would be cool if we knew this was exhaustive - // (the dream of bounded integer types) - match mod_len { - 0 => (), - 1 => { - let n = (self[len-1] as u32) << 16; - write(enc((n >> 18) & 63)); - write(enc((n >> 12) & 63)); - } - 2 => { - let n = (self[len-2] as u32) << 16 | - (self[len-1] as u32) << 8; - write(enc((n >> 18) & 63)); - write(enc((n >> 12) & 63)); - write(enc((n >> 6 ) & 63)); - } - _ => panic!("Algebra is broken, please alert the math police") - } - } - - // We get padding for "free", so only have to drop it if unwanted. - if !config.pad { - while let Some(&b'=') = out_bytes.last() { - out_bytes.pop(); - } - } - - unsafe { String::from_utf8_unchecked(out_bytes) } - } -} - -/// A trait for converting from base64 encoded values. -pub trait FromBase64 { - /// Converts the value of `self`, interpreted as base64 encoded data, into - /// an owned vector of bytes, returning the vector. - fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>; -} - -/// Errors that can occur when decoding a base64 encoded string -#[derive(Clone, Copy)] -pub enum FromBase64Error { - /// The input contained a character not part of the base64 format - InvalidBase64Byte(u8, usize), - /// The input had an invalid length - InvalidBase64Length, -} - -impl fmt::Debug for FromBase64Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - InvalidBase64Byte(ch, idx) => - write!(f, "Invalid character '{}' at position {}", ch, idx), - InvalidBase64Length => write!(f, "Invalid length"), - } - } -} - -impl error::Error for FromBase64Error { - fn description(&self) -> &str { - match *self { - InvalidBase64Byte(_, _) => "invalid character", - InvalidBase64Length => "invalid length", - } - } -} - -impl fmt::Display for FromBase64Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self, f) - } -} - -impl FromBase64 for str { - /// Convert any base64 encoded string (literal, `@`, `&`, or `~`) - /// to the byte values it encodes. - /// - /// You can use the `String::from_utf8` function to turn a `Vec<u8>` into a - /// string with characters corresponding to those values. - /// - /// # Example - /// - /// This converts a string literal to base64 and back. - /// - /// ```rust - /// extern crate rustc_serialize; - /// use rustc_serialize::base64::{ToBase64, FromBase64, STANDARD}; - /// - /// fn main () { - /// let hello_str = b"Hello, World".to_base64(STANDARD); - /// println!("base64 output: {}", hello_str); - /// let res = hello_str.from_base64(); - /// if res.is_ok() { - /// let opt_bytes = String::from_utf8(res.unwrap()); - /// if opt_bytes.is_ok() { - /// println!("decoded from base64: {:?}", opt_bytes.unwrap()); - /// } - /// } - /// } - /// ``` - #[inline] - fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> { - self.as_bytes().from_base64() - } -} - -impl FromBase64 for [u8] { - fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> { - let mut r = Vec::with_capacity(self.len()); - let mut buf: u32 = 0; - let mut modulus = 0; - - let mut it = self.iter(); - for byte in it.by_ref() { - let code = DECODE_TABLE[*byte as usize]; - if code >= SPECIAL_CODES_START { - match code { - NEWLINE_CODE => continue, - EQUALS_CODE => break, - INVALID_CODE => return Err(InvalidBase64Byte( - *byte, (byte as *const _ as usize) - self.as_ptr() as usize)), - _ => unreachable!(), - } - } - buf = (buf | code as u32) << 6; - modulus += 1; - if modulus == 4 { - modulus = 0; - r.push((buf >> 22) as u8); - r.push((buf >> 14) as u8); - r.push((buf >> 6 ) as u8); - } - } - - for byte in it { - match *byte { - b'=' | b'\r' | b'\n' => continue, - _ => return Err(InvalidBase64Byte( - *byte, (byte as *const _ as usize) - self.as_ptr() as usize)), - } - } - - match modulus { - 2 => { - r.push((buf >> 10) as u8); - } - 3 => { - r.push((buf >> 16) as u8); - r.push((buf >> 8 ) as u8); - } - 0 => (), - _ => return Err(InvalidBase64Length), - } - - Ok(r) - } -} - -/// Base64 decoding lookup table, generated using: -/// ```rust -/// let mut ch = 0u8; -/// loop { -/// let code = match ch { -/// b'A'...b'Z' => ch - 0x41, -/// b'a'...b'z' => ch - 0x47, -/// b'0'...b'9' => ch + 0x04, -/// b'+' | b'-' => 0x3E, -/// b'/' | b'_' => 0x3F, -/// b'=' => 0xFE, -/// b'\r' | b'\n' => 0xFD, -/// _ => 0xFF, -/// }; -/// print!("0x{:02X}, ", code); -/// if ch % 16 == 15 { println!(""); } -/// else if ch == 0xFF { break; } -/// ch += 1; -/// } -/// println!(""); -/// } -/// ``` -const DECODE_TABLE: [u8; 256] = [ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0x3E, 0xFF, 0x3F, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, - 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, - 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -]; -const INVALID_CODE: u8 = 0xFF; -const EQUALS_CODE: u8 = 0xFE; -const NEWLINE_CODE: u8 = 0xFD; -const SPECIAL_CODES_START: u8 = NEWLINE_CODE; - -#[cfg(test)] -mod tests { - use base64::{Config, Newline, FromBase64, ToBase64, STANDARD, URL_SAFE}; - - #[test] - fn test_to_base64_basic() { - assert_eq!("".as_bytes().to_base64(STANDARD), ""); - assert_eq!("f".as_bytes().to_base64(STANDARD), "Zg=="); - assert_eq!("fo".as_bytes().to_base64(STANDARD), "Zm8="); - assert_eq!("foo".as_bytes().to_base64(STANDARD), "Zm9v"); - assert_eq!("foob".as_bytes().to_base64(STANDARD), "Zm9vYg=="); - assert_eq!("fooba".as_bytes().to_base64(STANDARD), "Zm9vYmE="); - assert_eq!("foobar".as_bytes().to_base64(STANDARD), "Zm9vYmFy"); - } - - #[test] - fn test_to_base64_crlf_line_break() { - assert!(![08; 1000].to_base64(Config {line_length: None, ..STANDARD}) - .contains("\r\n")); - assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), - ..STANDARD}), - "Zm9v\r\nYmFy"); - } - - #[test] - fn test_to_base64_lf_line_break() { - assert!(![08; 1000].to_base64(Config {line_length: None, - newline: Newline::LF, - ..STANDARD}) - .contains("\n")); - assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), - newline: Newline::LF, - ..STANDARD}), - "Zm9v\nYmFy"); - } - - #[test] - fn test_to_base64_padding() { - assert_eq!("f".as_bytes().to_base64(Config {pad: false, ..STANDARD}), "Zg"); - assert_eq!("fo".as_bytes().to_base64(Config {pad: false, ..STANDARD}), "Zm8"); - } - - #[test] - fn test_to_base64_url_safe() { - assert_eq!([251, 255].to_base64(URL_SAFE), "-_8"); - assert_eq!([251, 255].to_base64(STANDARD), "+/8="); - } - - #[test] - fn test_to_base64_empty_line_length() { - [].to_base64(Config {line_length: Some(72), ..STANDARD}); - } - - #[test] - fn test_from_base64_basic() { - assert_eq!("".from_base64().unwrap(), b""); - assert_eq!("Zg==".from_base64().unwrap(), b"f"); - assert_eq!("Zm8=".from_base64().unwrap(), b"fo"); - assert_eq!("Zm9v".from_base64().unwrap(), b"foo"); - assert_eq!("Zm9vYg==".from_base64().unwrap(), b"foob"); - assert_eq!("Zm9vYmE=".from_base64().unwrap(), b"fooba"); - assert_eq!("Zm9vYmFy".from_base64().unwrap(), b"foobar"); - } - - #[test] - fn test_from_base64_bytes() { - assert_eq!(b"Zm9vYmFy".from_base64().unwrap(), b"foobar"); - } - - #[test] - fn test_from_base64_newlines() { - assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(), - b"foobar"); - assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(), - b"foob"); - assert_eq!("Zm9v\nYmFy".from_base64().unwrap(), - b"foobar"); - assert_eq!("Zm9vYg==\n".from_base64().unwrap(), - b"foob"); - } - - #[test] - fn test_from_base64_urlsafe() { - assert_eq!("-_8".from_base64().unwrap(), "+/8=".from_base64().unwrap()); - } - - #[test] - fn test_from_base64_invalid_char() { - assert!("Zm$=".from_base64().is_err()); - assert!("Zg==$".from_base64().is_err()); - } - - #[test] - fn test_from_base64_invalid_padding() { - assert!("Z===".from_base64().is_err()); - } - - #[test] - fn test_base64_random() { - use rand::{thread_rng, Rng}; - - for _ in 0..1000 { - let times = thread_rng().gen_range(1, 100); - let v = thread_rng().gen_iter::<u8>().take(times) - .collect::<Vec<_>>(); - assert_eq!(v.to_base64(STANDARD) - .from_base64() - .unwrap(), - v); - } - } -} diff --git a/src/vendor/rustc-serialize/src/collection_impls.rs b/src/vendor/rustc-serialize/src/collection_impls.rs deleted file mode 100644 index f8074c911be..00000000000 --- a/src/vendor/rustc-serialize/src/collection_impls.rs +++ /dev/null @@ -1,186 +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. - -//! Implementations of serialization for structures found in libcollections - -use std::hash::Hash; - -use {Decodable, Encodable, Decoder, Encoder, cap_capacity}; -use std::collections::{LinkedList, VecDeque, BTreeMap, BTreeSet, HashMap, HashSet}; - -impl< - T: Encodable -> Encodable for LinkedList<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for (i, e) in self.iter().enumerate() { - try!(s.emit_seq_elt(i, |s| e.encode(s))); - } - Ok(()) - }) - } -} - -impl<T:Decodable> Decodable for LinkedList<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<LinkedList<T>, D::Error> { - d.read_seq(|d, len| { - let mut list = LinkedList::new(); - for i in 0..len { - list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); - } - Ok(list) - }) - } -} - -impl<T: Encodable> Encodable for VecDeque<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for (i, e) in self.iter().enumerate() { - try!(s.emit_seq_elt(i, |s| e.encode(s))); - } - Ok(()) - }) - } -} - -impl<T:Decodable> Decodable for VecDeque<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<VecDeque<T>, D::Error> { - d.read_seq(|d, len| { - let mut deque: VecDeque<T> = VecDeque::new(); - for i in 0..len { - deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); - } - Ok(deque) - }) - } -} - -impl< - K: Encodable + Ord, - V: Encodable -> Encodable for BTreeMap<K, V> { - fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { - e.emit_map(self.len(), |e| { - let mut i = 0; - for (key, val) in self.iter() { - try!(e.emit_map_elt_key(i, |e| key.encode(e))); - try!(e.emit_map_elt_val(i, |e| val.encode(e))); - i += 1; - } - Ok(()) - }) - } -} - -impl< - K: Decodable + Ord, - V: Decodable -> Decodable for BTreeMap<K, V> { - fn decode<D: Decoder>(d: &mut D) -> Result<BTreeMap<K, V>, D::Error> { - d.read_map(|d, len| { - let mut map = BTreeMap::new(); - for i in 0..len { - let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d))); - let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d))); - map.insert(key, val); - } - Ok(map) - }) - } -} - -impl< - T: Encodable + Ord -> Encodable for BTreeSet<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - let mut i = 0; - for e in self.iter() { - try!(s.emit_seq_elt(i, |s| e.encode(s))); - i += 1; - } - Ok(()) - }) - } -} - -impl< - T: Decodable + Ord -> Decodable for BTreeSet<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<BTreeSet<T>, D::Error> { - d.read_seq(|d, len| { - let mut set = BTreeSet::new(); - for i in 0..len { - set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); - } - Ok(set) - }) - } -} - -impl<K, V> Encodable for HashMap<K, V> - where K: Encodable + Hash + Eq, - V: Encodable, -{ - fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> { - e.emit_map(self.len(), |e| { - let mut i = 0; - for (key, val) in self.iter() { - try!(e.emit_map_elt_key(i, |e| key.encode(e))); - try!(e.emit_map_elt_val(i, |e| val.encode(e))); - i += 1; - } - Ok(()) - }) - } -} - -impl<K, V> Decodable for HashMap<K, V> - where K: Decodable + Hash + Eq, - V: Decodable, -{ - fn decode<D: Decoder>(d: &mut D) -> Result<HashMap<K, V>, D::Error> { - d.read_map(|d, len| { - let mut map = HashMap::with_capacity(cap_capacity::<(K, V)>(len)); - for i in 0..len { - let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d))); - let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d))); - map.insert(key, val); - } - Ok(map) - }) - } -} - -impl<T> Encodable for HashSet<T> where T: Encodable + Hash + Eq { - fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_seq(self.len(), |s| { - let mut i = 0; - for e in self.iter() { - try!(s.emit_seq_elt(i, |s| e.encode(s))); - i += 1; - } - Ok(()) - }) - } -} - -impl<T> Decodable for HashSet<T> where T: Decodable + Hash + Eq, { - fn decode<D: Decoder>(d: &mut D) -> Result<HashSet<T>, D::Error> { - d.read_seq(|d, len| { - let mut set = HashSet::with_capacity(cap_capacity::<T>(len)); - for i in 0..len { - set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); - } - Ok(set) - }) - } -} diff --git a/src/vendor/rustc-serialize/src/hex.rs b/src/vendor/rustc-serialize/src/hex.rs deleted file mode 100644 index 08d25fdf2e3..00000000000 --- a/src/vendor/rustc-serialize/src/hex.rs +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2013-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. -// -// ignore-lexer-test FIXME #15679 - -//! Hex binary-to-text encoding - -pub use self::FromHexError::*; - -use std::fmt; -use std::error; - -/// A trait for converting a value to hexadecimal encoding -pub trait ToHex { - /// Converts the value of `self` to a hex value, returning the owned - /// string. - fn to_hex(&self) -> String; -} - -static CHARS: &'static[u8] = b"0123456789abcdef"; - -impl ToHex for [u8] { - /// Turn a vector of `u8` bytes into a hexadecimal string. - /// - /// # Example - /// - /// ```rust - /// extern crate rustc_serialize; - /// use rustc_serialize::hex::ToHex; - /// - /// fn main () { - /// let str = [52,32].to_hex(); - /// println!("{}", str); - /// } - /// ``` - fn to_hex(&self) -> String { - let mut v = Vec::with_capacity(self.len() * 2); - for &byte in self.iter() { - v.push(CHARS[(byte >> 4) as usize]); - v.push(CHARS[(byte & 0xf) as usize]); - } - - unsafe { - String::from_utf8_unchecked(v) - } - } -} - -/// A trait for converting hexadecimal encoded values -pub trait FromHex { - /// Converts the value of `self`, interpreted as hexadecimal encoded data, - /// into an owned vector of bytes, returning the vector. - fn from_hex(&self) -> Result<Vec<u8>, FromHexError>; -} - -/// Errors that can occur when decoding a hex encoded string -#[derive(Clone, Copy)] -pub enum FromHexError { - /// The input contained a character not part of the hex format - InvalidHexCharacter(char, usize), - /// The input had an invalid length - InvalidHexLength, -} - -impl fmt::Debug for FromHexError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - InvalidHexCharacter(ch, idx) => - write!(f, "Invalid character '{}' at position {}", ch, idx), - InvalidHexLength => write!(f, "Invalid input length"), - } - } -} - -impl error::Error for FromHexError { - fn description(&self) -> &str { - match *self { - InvalidHexCharacter(_, _) => "invalid character", - InvalidHexLength => "invalid length", - } - } -} - -impl fmt::Display for FromHexError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self, f) - } -} - -impl FromHex for str { - /// Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) - /// to the byte values it encodes. - /// - /// You can use the `String::from_utf8` function to turn a - /// `Vec<u8>` into a string with characters corresponding to those values. - /// - /// # Example - /// - /// This converts a string literal to hexadecimal and back. - /// - /// ```rust - /// extern crate rustc_serialize; - /// use rustc_serialize::hex::{FromHex, ToHex}; - /// - /// fn main () { - /// let hello_str = "Hello, World".as_bytes().to_hex(); - /// println!("{}", hello_str); - /// let bytes = hello_str.from_hex().unwrap(); - /// println!("{:?}", bytes); - /// let result_str = String::from_utf8(bytes).unwrap(); - /// println!("{}", result_str); - /// } - /// ``` - fn from_hex(&self) -> Result<Vec<u8>, FromHexError> { - // This may be an overestimate if there is any whitespace - let mut b = Vec::with_capacity(self.len() / 2); - let mut modulus = 0; - let mut buf = 08; - - for (idx, byte) in self.bytes().enumerate() { - buf <<= 4; - - match byte { - b'A'...b'F' => buf |= byte - b'A' + 10, - b'a'...b'f' => buf |= byte - b'a' + 10, - b'0'...b'9' => buf |= byte - b'0', - b' '|b'\r'|b'\n'|b'\t' => { - buf >>= 4; - continue - } - _ => { - let ch = self[idx..].chars().next().unwrap(); - return Err(InvalidHexCharacter(ch, idx)) - } - } - - modulus += 1; - if modulus == 2 { - modulus = 0; - b.push(buf); - } - } - - match modulus { - 0 => Ok(b.into_iter().collect()), - _ => Err(InvalidHexLength), - } - } -} - -#[cfg(test)] -mod tests { - use hex::{FromHex, ToHex}; - - #[test] - pub fn test_to_hex() { - assert_eq!("foobar".as_bytes().to_hex(), "666f6f626172"); - } - - #[test] - pub fn test_from_hex_okay() { - assert_eq!("666f6f626172".from_hex().unwrap(), - b"foobar"); - assert_eq!("666F6F626172".from_hex().unwrap(), - b"foobar"); - } - - #[test] - pub fn test_from_hex_odd_len() { - assert!("666".from_hex().is_err()); - assert!("66 6".from_hex().is_err()); - } - - #[test] - pub fn test_from_hex_invalid_char() { - assert!("66y6".from_hex().is_err()); - } - - #[test] - pub fn test_from_hex_ignores_whitespace() { - assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(), - b"foobar"); - } - - #[test] - pub fn test_to_hex_all_bytes() { - for i in 0..256 { - assert_eq!([i as u8].to_hex(), format!("{:02x}", i)); - } - } - - #[test] - pub fn test_from_hex_all_bytes() { - for i in 0..256 { - let ii: &[u8] = &[i as u8]; - assert_eq!(format!("{:02x}", i).from_hex().unwrap(), - ii); - assert_eq!(format!("{:02X}", i).from_hex().unwrap(), - ii); - } - } -} diff --git a/src/vendor/rustc-serialize/src/json.rs b/src/vendor/rustc-serialize/src/json.rs deleted file mode 100644 index 44bf6a2fff2..00000000000 --- a/src/vendor/rustc-serialize/src/json.rs +++ /dev/null @@ -1,3955 +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. - -// Rust JSON serialization library -// Copyright (c) 2011 Google Inc. - -//! JSON parsing and serialization -//! -//! # What is JSON? -//! -//! JSON (JavaScript Object Notation) is a way to write data in Javascript. -//! Like XML, it allows encoding structured data in a text format that can be -//! easily read by humans. Its simple syntax and native compatibility with -//! JavaScript have made it a widely used format. -//! -//! Data types that can be encoded are JavaScript types (see the `Json` enum -//! for more details): -//! -//! * `I64`: equivalent to rust's `i64` -//! * `U64`: equivalent to rust's `u64` -//! * `F64`: equivalent to rust's `f64` -//! * `Boolean`: equivalent to rust's `bool` -//! * `String`: equivalent to rust's `String` -//! * `Array`: equivalent to rust's `Vec<T>`, but also allowing objects of -//! different types in the -//! same array -//! * `Object`: equivalent to rust's `BTreeMap<String, json::Json>` -//! * `Null` -//! -//! An object is a series of string keys mapping to values, in `"key": value` -//! format. Arrays are enclosed in square brackets ([ ... ]) and objects in -//! curly brackets ({ ... }). A simple JSON document encoding a person, -//! their age, address and phone numbers could look like -//! -//! ```ignore -//! { -//! "FirstName": "John", -//! "LastName": "Doe", -//! "Age": 43, -//! "Address": { -//! "Street": "Downing Street 10", -//! "City": "London", -//! "Country": "Great Britain" -//! }, -//! "PhoneNumbers": [ -//! "+44 1234567", -//! "+44 2345678" -//! ] -//! } -//! ``` -//! -//! # Rust Type-based Encoding and Decoding -//! -//! Rust provides a mechanism for low boilerplate encoding & decoding of values -//! to and from JSON via the serialization API. To be able to encode a piece -//! of data, it must implement the `rustc_serialize::Encodable` trait. To be -//! able to decode a piece of data, it must implement the -//! `rustc_serialize::Decodable` trait. The Rust compiler provides an -//! annotation to automatically generate the code for these traits: -//! `#[derive(RustcDecodable, RustcEncodable)]` -//! -//! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode -//! objects. The `ToJson` trait provides a `to_json` method to convert an -//! object into a `json::Json` value. A `json::Json` value can be encoded as a -//! string or buffer using the functions described above. You can also use the -//! `json::Encoder` object, which implements the `Encoder` trait. -//! -//! When using `ToJson`, the `Encodable` trait implementation is not -//! mandatory. -//! -//! # Examples of use -//! -//! ## Using Autoserialization -//! -//! Create a struct called `TestStruct` and serialize and deserialize it to and -//! from JSON using the serialization API, using the derived serialization code. -//! -//! ```rust -//! extern crate rustc_serialize; -//! use rustc_serialize::json; -//! -//! // Automatically generate `RustcDecodable` and `RustcEncodable` trait -//! // implementations -//! #[derive(RustcDecodable, RustcEncodable)] -//! pub struct TestStruct { -//! data_int: u8, -//! data_str: String, -//! data_vector: Vec<u8>, -//! } -//! -//! fn main() { -//! let object = TestStruct { -//! data_int: 1, -//! data_str: "homura".to_string(), -//! data_vector: vec![2,3,4,5], -//! }; -//! -//! // Serialize using `json::encode` -//! let encoded = json::encode(&object).unwrap(); -//! -//! // Deserialize using `json::decode` -//! let decoded: TestStruct = json::decode(&encoded).unwrap(); -//! } -//! ``` -//! -//! ## Using the `ToJson` trait -//! -//! The examples below use the `ToJson` trait to generate the JSON string, -//! which is required for custom mappings. -//! -//! ### Simple example of `ToJson` usage -//! -//! ```rust -//! extern crate rustc_serialize; -//! use rustc_serialize::json::{self, ToJson, Json}; -//! -//! // A custom data structure -//! struct ComplexNum { -//! a: f64, -//! b: f64, -//! } -//! -//! // JSON value representation -//! impl ToJson for ComplexNum { -//! fn to_json(&self) -> Json { -//! Json::String(format!("{}+{}i", self.a, self.b)) -//! } -//! } -//! -//! // Only generate `RustcEncodable` trait implementation -//! #[derive(RustcEncodable)] -//! pub struct ComplexNumRecord { -//! uid: u8, -//! dsc: String, -//! val: Json, -//! } -//! -//! fn main() { -//! let num = ComplexNum { a: 0.0001, b: 12.539 }; -//! let data: String = json::encode(&ComplexNumRecord{ -//! uid: 1, -//! dsc: "test".to_string(), -//! val: num.to_json(), -//! }).unwrap(); -//! println!("data: {}", data); -//! // data: {"uid":1,"dsc":"test","val":"0.0001+12.539i"}; -//! } -//! ``` -//! -//! ### Verbose example of `ToJson` usage -//! -//! ```rust -//! extern crate rustc_serialize; -//! use std::collections::BTreeMap; -//! use rustc_serialize::json::{self, Json, ToJson}; -//! -//! // Only generate `Decodable` trait implementation -//! #[derive(RustcDecodable)] -//! pub struct TestStruct { -//! data_int: u8, -//! data_str: String, -//! data_vector: Vec<u8>, -//! } -//! -//! // Specify encoding method manually -//! impl ToJson for TestStruct { -//! fn to_json(&self) -> Json { -//! let mut d = BTreeMap::new(); -//! // All standard types implement `to_json()`, so use it -//! d.insert("data_int".to_string(), self.data_int.to_json()); -//! d.insert("data_str".to_string(), self.data_str.to_json()); -//! d.insert("data_vector".to_string(), self.data_vector.to_json()); -//! Json::Object(d) -//! } -//! } -//! -//! fn main() { -//! // Serialize using `ToJson` -//! let input_data = TestStruct { -//! data_int: 1, -//! data_str: "madoka".to_string(), -//! data_vector: vec![2,3,4,5], -//! }; -//! let json_obj: Json = input_data.to_json(); -//! let json_str: String = json_obj.to_string(); -//! -//! // Deserialize like before -//! let decoded: TestStruct = json::decode(&json_str).unwrap(); -//! } -//! ``` -//! -//! ## Parsing a `str` to `Json` and reading the result -//! -//! ```rust -//! extern crate rustc_serialize; -//! use rustc_serialize::json::Json; -//! -//! fn main() { -//! let data = Json::from_str("{\"foo\": 13, \"bar\": \"baz\"}").unwrap(); -//! println!("data: {}", data); -//! // data: {"bar":"baz","foo":13} -//! println!("object? {}", data.is_object()); -//! // object? true -//! -//! let obj = data.as_object().unwrap(); -//! let foo = obj.get("foo").unwrap(); -//! -//! println!("array? {:?}", foo.as_array()); -//! // array? None -//! println!("u64? {:?}", foo.as_u64()); -//! // u64? Some(13u64) -//! -//! for (key, value) in obj.iter() { -//! println!("{}: {}", key, match *value { -//! Json::U64(v) => format!("{} (u64)", v), -//! Json::String(ref v) => format!("{} (string)", v), -//! _ => format!("other") -//! }); -//! } -//! // bar: baz (string) -//! // foo: 13 (u64) -//! } -//! ``` -//! -//! # The status of this library -//! -//! While this library is the standard way of working with JSON in Rust, -//! there is a next-generation library called Serde that's in the works (it's -//! faster, overcomes some design limitations of rustc-serialize and has more -//! features). You might consider using it when starting a new project or -//! evaluating Rust JSON performance. - -use self::JsonEvent::*; -use self::ErrorCode::*; -use self::ParserError::*; -use self::DecoderError::*; -use self::ParserState::*; -use self::InternalStackElement::*; - -use std::collections::{HashMap, BTreeMap}; -use std::error::Error as StdError; -use std::i64; -use std::io::prelude::*; -use std::mem::swap; -use std::ops::Index; -use std::str::FromStr; -use std::string; -use std::{char, f64, fmt, io, str}; - -use Encodable; - -/// Represents a json value -#[derive(Clone, PartialEq, PartialOrd, Debug)] -pub enum Json { - I64(i64), - U64(u64), - F64(f64), - String(string::String), - Boolean(bool), - Array(self::Array), - Object(self::Object), - Null, -} - -pub type Array = Vec<Json>; -pub type Object = BTreeMap<string::String, Json>; - -pub struct PrettyJson<'a> { inner: &'a Json } - -pub struct AsJson<'a, T: 'a> { inner: &'a T } -pub struct AsPrettyJson<'a, T: 'a> { inner: &'a T, indent: Option<u32> } - -/// The errors that can arise while parsing a JSON stream. -#[derive(Clone, Copy, PartialEq)] -pub enum ErrorCode { - InvalidSyntax, - InvalidNumber, - EOFWhileParsingObject, - EOFWhileParsingArray, - EOFWhileParsingValue, - EOFWhileParsingString, - KeyMustBeAString, - ExpectedColon, - TrailingCharacters, - TrailingComma, - InvalidEscape, - InvalidUnicodeCodePoint, - LoneLeadingSurrogateInHexEscape, - UnexpectedEndOfHexEscape, - UnrecognizedHex, - NotFourDigit, - ControlCharacterInString, - NotUtf8, -} - -#[derive(Debug)] -pub enum ParserError { - /// msg, line, col - SyntaxError(ErrorCode, usize, usize), - IoError(io::Error), -} - -impl PartialEq for ParserError { - fn eq(&self, other: &ParserError) -> bool { - match (self, other) { - (&SyntaxError(msg0, line0, col0), &SyntaxError(msg1, line1, col1)) => - msg0 == msg1 && line0 == line1 && col0 == col1, - (&IoError(_), _) => false, - (_, &IoError(_)) => false, - } - } -} - -// Builder and Parser have the same errors. -pub type BuilderError = ParserError; - -#[derive(PartialEq, Debug)] -pub enum DecoderError { - ParseError(ParserError), - ExpectedError(string::String, string::String), - MissingFieldError(string::String), - UnknownVariantError(string::String), - ApplicationError(string::String), - EOF, -} - -#[derive(Copy, Debug)] -pub enum EncoderError { - FmtError(fmt::Error), - BadHashmapKey, -} - -impl Clone for EncoderError { - fn clone(&self) -> Self { *self } -} - -/// Returns a readable error string for a given error code. -pub fn error_str(error: ErrorCode) -> &'static str { - match error { - InvalidSyntax => "invalid syntax", - InvalidNumber => "invalid number", - EOFWhileParsingObject => "EOF While parsing object", - EOFWhileParsingArray => "EOF While parsing array", - EOFWhileParsingValue => "EOF While parsing value", - EOFWhileParsingString => "EOF While parsing string", - KeyMustBeAString => "key must be a string", - ExpectedColon => "expected `:`", - TrailingCharacters => "trailing characters", - TrailingComma => "trailing comma", - InvalidEscape => "invalid escape", - UnrecognizedHex => "invalid \\u{ esc}ape (unrecognized hex)", - NotFourDigit => "invalid \\u{ esc}ape (not four digits)", - ControlCharacterInString => "unescaped control character in string", - NotUtf8 => "contents not utf-8", - InvalidUnicodeCodePoint => "invalid Unicode code point", - LoneLeadingSurrogateInHexEscape => "lone leading surrogate in hex escape", - UnexpectedEndOfHexEscape => "unexpected end of hex escape", - } -} - -/// Shortcut function to decode a JSON `&str` into an object -pub fn decode<T: ::Decodable>(s: &str) -> DecodeResult<T> { - let json = match Json::from_str(s) { - Ok(x) => x, - Err(e) => return Err(ParseError(e)) - }; - - let mut decoder = Decoder::new(json); - ::Decodable::decode(&mut decoder) -} - -/// Shortcut function to encode a `T` into a JSON `String` -pub fn encode<T: ::Encodable>(object: &T) -> EncodeResult<string::String> { - let mut s = String::new(); - { - let mut encoder = Encoder::new(&mut s); - try!(object.encode(&mut encoder)); - } - Ok(s) -} - -impl fmt::Debug for ErrorCode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - error_str(*self).fmt(f) - } -} - -impl StdError for DecoderError { - fn description(&self) -> &str { "decoder error" } - fn cause(&self) -> Option<&StdError> { - match *self { - DecoderError::ParseError(ref e) => Some(e), - _ => None, - } - } -} - -impl fmt::Display for DecoderError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self, f) - } -} - -impl From<ParserError> for DecoderError { - fn from(err: ParserError) -> DecoderError { - ParseError(From::from(err)) - } -} - -impl StdError for ParserError { - fn description(&self) -> &str { "failed to parse json" } -} - -impl fmt::Display for ParserError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self, f) - } -} - -impl From<io::Error> for ParserError { - fn from(err: io::Error) -> ParserError { - IoError(err) - } -} - -impl StdError for EncoderError { - fn description(&self) -> &str { "encoder error" } -} - -impl fmt::Display for EncoderError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self, f) - } -} - -impl From<fmt::Error> for EncoderError { - fn from(err: fmt::Error) -> EncoderError { EncoderError::FmtError(err) } -} - -pub type EncodeResult<T> = Result<T, EncoderError>; -pub type DecodeResult<T> = Result<T, DecoderError>; - -fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult<()> { - try!(wr.write_str("\"")); - - let mut start = 0; - - for (i, byte) in v.bytes().enumerate() { - let escaped = match byte { - b'"' => "\\\"", - b'\\' => "\\\\", - b'\x00' => "\\u0000", - b'\x01' => "\\u0001", - b'\x02' => "\\u0002", - b'\x03' => "\\u0003", - b'\x04' => "\\u0004", - b'\x05' => "\\u0005", - b'\x06' => "\\u0006", - b'\x07' => "\\u0007", - b'\x08' => "\\b", - b'\t' => "\\t", - b'\n' => "\\n", - b'\x0b' => "\\u000b", - b'\x0c' => "\\f", - b'\r' => "\\r", - b'\x0e' => "\\u000e", - b'\x0f' => "\\u000f", - b'\x10' => "\\u0010", - b'\x11' => "\\u0011", - b'\x12' => "\\u0012", - b'\x13' => "\\u0013", - b'\x14' => "\\u0014", - b'\x15' => "\\u0015", - b'\x16' => "\\u0016", - b'\x17' => "\\u0017", - b'\x18' => "\\u0018", - b'\x19' => "\\u0019", - b'\x1a' => "\\u001a", - b'\x1b' => "\\u001b", - b'\x1c' => "\\u001c", - b'\x1d' => "\\u001d", - b'\x1e' => "\\u001e", - b'\x1f' => "\\u001f", - b'\x7f' => "\\u007f", - _ => { continue; } - }; - - if start < i { - try!(wr.write_str(&v[start..i])); - } - - try!(wr.write_str(escaped)); - - start = i + 1; - } - - if start != v.len() { - try!(wr.write_str(&v[start..])); - } - - try!(wr.write_str("\"")); - Ok(()) -} - -fn escape_char(writer: &mut fmt::Write, v: char) -> EncodeResult<()> { - let mut buf = [0; 4]; - let _ = write!(&mut &mut buf[..], "{}", v); - let buf = unsafe { str::from_utf8_unchecked(&buf[..v.len_utf8()]) }; - escape_str(writer, buf) -} - -fn spaces(wr: &mut fmt::Write, n: u32) -> EncodeResult<()> { - let mut n = n as usize; - const BUF: &'static str = " "; - - while n >= BUF.len() { - try!(wr.write_str(BUF)); - n -= BUF.len(); - } - - if n > 0 { - try!(wr.write_str(&BUF[..n])); - } - Ok(()) -} - -fn fmt_number_or_null(v: f64) -> string::String { - use std::num::FpCategory::{Nan, Infinite}; - - match v.classify() { - Nan | Infinite => "null".to_string(), - _ => { - let s = v.to_string(); - if s.contains(".") {s} else {s + ".0"} - } - } -} - -macro_rules! emit_enquoted_if_mapkey { - ($enc:ident,$e:expr) => { - if $enc.is_emitting_map_key { - try!(write!($enc.writer, "\"{}\"", $e)); - Ok(()) - } else { - try!(write!($enc.writer, "{}", $e)); - Ok(()) - } - } -} - -enum EncodingFormat { - Compact, - Pretty { - curr_indent: u32, - indent: u32 - } -} - -/// A structure for implementing serialization to JSON. -pub struct Encoder<'a> { - writer: &'a mut (fmt::Write+'a), - format : EncodingFormat, - is_emitting_map_key: bool, -} - -impl<'a> Encoder<'a> { - /// Creates a new encoder whose output will be written in human-readable - /// JSON to the specified writer - pub fn new_pretty(writer: &'a mut fmt::Write) -> Encoder<'a> { - Encoder { - writer: writer, - format: EncodingFormat::Pretty { - curr_indent: 0, - indent: 2, - }, - is_emitting_map_key: false, - } - } - - /// Creates a new encoder whose output will be written in compact - /// JSON to the specified writer - pub fn new(writer: &'a mut fmt::Write) -> Encoder<'a> { - Encoder { - writer: writer, - format: EncodingFormat::Compact, - is_emitting_map_key: false, - } - } - - /// Set the number of spaces to indent for each level. - /// This is safe to set during encoding. - pub fn set_indent(&mut self, new_indent: u32) -> Result<(), ()> { - if let EncodingFormat::Pretty{ref mut curr_indent, ref mut indent} = self.format { - // self.indent very well could be 0 so we need to use checked division. - let level = curr_indent.checked_div(*indent).unwrap_or(0); - *indent = new_indent; - *curr_indent = level * *indent; - Ok(()) - } else { - Err(()) - } - } -} - -impl<'a> ::Encoder for Encoder<'a> { - type Error = EncoderError; - - fn emit_nil(&mut self) -> EncodeResult<()> { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - try!(write!(self.writer, "null")); - Ok(()) - } - - fn emit_usize(&mut self, v: usize) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_u64(&mut self, v: u64) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_u32(&mut self, v: u32) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_u16(&mut self, v: u16) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_u8(&mut self, v: u8) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - - fn emit_isize(&mut self, v: isize) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_i64(&mut self, v: i64) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_i32(&mut self, v: i32) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_i16(&mut self, v: i16) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - fn emit_i8(&mut self, v: i8) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) } - - fn emit_bool(&mut self, v: bool) -> EncodeResult<()> { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if v { - try!(write!(self.writer, "true")); - } else { - try!(write!(self.writer, "false")); - } - Ok(()) - } - - fn emit_f64(&mut self, v: f64) -> EncodeResult<()> { - emit_enquoted_if_mapkey!(self, fmt_number_or_null(v)) - } - fn emit_f32(&mut self, v: f32) -> EncodeResult<()> { - self.emit_f64(v as f64) - } - - fn emit_char(&mut self, v: char) -> EncodeResult<()> { - escape_char(self.writer, v) - } - fn emit_str(&mut self, v: &str) -> EncodeResult<()> { - escape_str(self.writer, v) - } - - fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - f(self) - } - - fn emit_enum_variant<F>(&mut self, - name: &str, - _id: usize, - cnt: usize, - f: F) - -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - // enums are encoded as strings or objects - // Bunny => "Bunny" - // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]} - if cnt == 0 { - escape_str(self.writer, name) - } else { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - try!(write!(self.writer, "{{\n")); - *curr_indent += indent; - try!(spaces(self.writer, *curr_indent)); - try!(write!(self.writer, "\"variant\": ")); - try!(escape_str(self.writer, name)); - try!(write!(self.writer, ",\n")); - try!(spaces(self.writer, *curr_indent)); - try!(write!(self.writer, "\"fields\": [\n")); - *curr_indent += indent; - } else { - try!(write!(self.writer, "{{\"variant\":")); - try!(escape_str(self.writer, name)); - try!(write!(self.writer, ",\"fields\":[")); - } - try!(f(self)); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent -= indent; - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, *curr_indent)); - *curr_indent -= indent; - try!(write!(self.writer, "]\n")); - try!(spaces(self.writer, *curr_indent)); - try!(write!(self.writer, "}}")); - } else { - try!(write!(self.writer, "]}}")); - } - Ok(()) - } - } - - fn emit_enum_variant_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { - try!(write!(self.writer, ",")); - if let EncodingFormat::Pretty{..} = self.format { - try!(write!(self.writer, "\n")); - } - } - if let EncodingFormat::Pretty{curr_indent, ..} = self.format { - try!(spaces(self.writer, curr_indent)); - } - f(self) - } - - fn emit_enum_struct_variant<F>(&mut self, - name: &str, - id: usize, - cnt: usize, - f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_enum_variant(name, id, cnt, f) - } - - fn emit_enum_struct_variant_field<F>(&mut self, - _: &str, - idx: usize, - f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_enum_variant_arg(idx, f) - } - - - fn emit_struct<F>(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if len == 0 { - try!(write!(self.writer, "{{}}")); - } else { - try!(write!(self.writer, "{{")); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent += indent; - } - try!(f(self)); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent -= indent; - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, *curr_indent)); - } - try!(write!(self.writer, "}}")); - } - Ok(()) - } - - fn emit_struct_field<F>(&mut self, name: &str, idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { - try!(write!(self.writer, ",")); - } - if let EncodingFormat::Pretty{curr_indent, ..} = self.format { - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, curr_indent)); - } - try!(escape_str(self.writer, name)); - if let EncodingFormat::Pretty{..} = self.format { - try!(write!(self.writer, ": ")); - } else { - try!(write!(self.writer, ":")); - } - f(self) - } - - fn emit_tuple<F>(&mut self, len: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_seq(len, f) - } - fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_seq_elt(idx, f) - } - - fn emit_tuple_struct<F>(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_seq(len, f) - } - fn emit_tuple_struct_arg<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_seq_elt(idx, f) - } - - fn emit_option<F>(&mut self, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - f(self) - } - fn emit_option_none(&mut self) -> EncodeResult<()> { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_nil() - } - fn emit_option_some<F>(&mut self, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - f(self) - } - - fn emit_seq<F>(&mut self, len: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if len == 0 { - try!(write!(self.writer, "[]")); - } else { - try!(write!(self.writer, "[")); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent += indent; - } - try!(f(self)); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent -= indent; - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, *curr_indent)); - } - try!(write!(self.writer, "]")); - } - Ok(()) - } - - fn emit_seq_elt<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { - try!(write!(self.writer, ",")); - } - if let EncodingFormat::Pretty{ref mut curr_indent, ..} = self.format { - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, *curr_indent)); - } - f(self) - } - - fn emit_map<F>(&mut self, len: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if len == 0 { - try!(write!(self.writer, "{{}}")); - } else { - try!(write!(self.writer, "{{")); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent += indent; - } - try!(f(self)); - if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format { - *curr_indent -= indent; - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, *curr_indent)); - } - try!(write!(self.writer, "}}")); - } - Ok(()) - } - - fn emit_map_elt_key<F>(&mut self, idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { - try!(write!(self.writer, ",")); - } - if let EncodingFormat::Pretty{curr_indent, ..} = self.format { - try!(write!(self.writer, "\n")); - try!(spaces(self.writer, curr_indent)); - } - self.is_emitting_map_key = true; - try!(f(self)); - self.is_emitting_map_key = false; - Ok(()) - } - - fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> EncodeResult<()> where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>, - { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if let EncodingFormat::Pretty{..} = self.format { - try!(write!(self.writer, ": ")); - } else { - try!(write!(self.writer, ":")); - } - f(self) - } -} - -impl Encodable for Json { - fn encode<S: ::Encoder>(&self, e: &mut S) -> Result<(), S::Error> { - match *self { - Json::I64(v) => v.encode(e), - Json::U64(v) => v.encode(e), - Json::F64(v) => v.encode(e), - Json::String(ref v) => v.encode(e), - Json::Boolean(v) => v.encode(e), - Json::Array(ref v) => v.encode(e), - Json::Object(ref v) => v.encode(e), - Json::Null => e.emit_nil(), - } - } -} - -/// Create an `AsJson` wrapper which can be used to print a value as JSON -/// on-the-fly via `write!` -pub fn as_json<T: Encodable>(t: &T) -> AsJson<T> { - AsJson { inner: t } -} - -/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON -/// on-the-fly via `write!` -pub fn as_pretty_json<T: Encodable>(t: &T) -> AsPrettyJson<T> { - AsPrettyJson { inner: t, indent: None } -} - -impl Json { - /// Decodes a json value from an `&mut io::Read` - pub fn from_reader(rdr: &mut io::Read) -> Result<Self, BuilderError> { - let contents = { - let mut c = Vec::new(); - try!(rdr.read_to_end(&mut c)); - c - }; - let s = match str::from_utf8(&contents).ok() { - Some(s) => s, - _ => return Err(SyntaxError(NotUtf8, 0, 0)) - }; - let mut builder = Builder::new(s.chars()); - builder.build() - } - - /// Decodes a json value from a string - pub fn from_str(s: &str) -> Result<Self, BuilderError> { - let mut builder = Builder::new(s.chars()); - builder.build() - } - - /// Borrow this json object as a pretty object to generate a pretty - /// representation for it via `Display`. - pub fn pretty(&self) -> PrettyJson { - PrettyJson { inner: self } - } - - /// If the Json value is an Object, returns the value associated with the provided key. - /// Otherwise, returns None. - pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{ - match self { - &Json::Object(ref map) => map.get(key), - _ => None - } - } - - /// Attempts to get a nested Json Object for each key in `keys`. - /// If any key is found not to exist, find_path will return None. - /// Otherwise, it will return the Json value associated with the final key. - pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{ - let mut target = self; - for key in keys.iter() { - match target.find(*key) { - Some(t) => { target = t; }, - None => return None - } - } - Some(target) - } - - /// If the Json value is an Object, performs a depth-first search until - /// a value associated with the provided key is found. If no value is found - /// or the Json value is not an Object, returns None. - pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> { - match self { - &Json::Object(ref map) => { - match map.get(key) { - Some(json_value) => Some(json_value), - None => { - for (_, v) in map.iter() { - match v.search(key) { - x if x.is_some() => return x, - _ => () - } - } - None - } - } - }, - _ => None - } - } - - /// Returns true if the Json value is an Object. Returns false otherwise. - pub fn is_object<'a>(&'a self) -> bool { - self.as_object().is_some() - } - - /// If the Json value is an Object, returns the associated BTreeMap. - /// Returns None otherwise. - pub fn as_object<'a>(&'a self) -> Option<&'a Object> { - match self { - &Json::Object(ref map) => Some(map), - _ => None - } - } - - /// If the Json value is an Object, returns the associated mutable BTreeMap. - /// Returns None otherwise. - pub fn as_object_mut<'a>(&'a mut self) -> Option<&'a mut Object> { - match self { - &mut Json::Object(ref mut map) => Some(map), - _ => None - } - } - - /// Returns true if the Json value is an Array. Returns false otherwise. - pub fn is_array<'a>(&'a self) -> bool { - self.as_array().is_some() - } - - /// If the Json value is an Array, returns the associated vector. - /// Returns None otherwise. - pub fn as_array<'a>(&'a self) -> Option<&'a Array> { - match self { - &Json::Array(ref array) => Some(&*array), - _ => None - } - } - - /// If the Json value is an Array, returns the associated mutable vector. - /// Returns None otherwise. - pub fn as_array_mut<'a>(&'a mut self) -> Option<&'a mut Array> { - match self { - &mut Json::Array(ref mut list) => Some(list), - _ => None - } - } - - /// Returns true if the Json value is a String. Returns false otherwise. - pub fn is_string<'a>(&'a self) -> bool { - self.as_string().is_some() - } - - /// If the Json value is a String, returns the associated str. - /// Returns None otherwise. - pub fn as_string<'a>(&'a self) -> Option<&'a str> { - match *self { - Json::String(ref s) => Some(&s), - _ => None - } - } - - /// Returns true if the Json value is a Number. Returns false otherwise. - pub fn is_number(&self) -> bool { - match *self { - Json::I64(_) | Json::U64(_) | Json::F64(_) => true, - _ => false, - } - } - - /// Returns true if the Json value is a i64. Returns false otherwise. - pub fn is_i64(&self) -> bool { - match *self { - Json::I64(_) => true, - _ => false, - } - } - - /// Returns true if the Json value is a u64. Returns false otherwise. - pub fn is_u64(&self) -> bool { - match *self { - Json::U64(_) => true, - _ => false, - } - } - - /// Returns true if the Json value is a f64. Returns false otherwise. - pub fn is_f64(&self) -> bool { - match *self { - Json::F64(_) => true, - _ => false, - } - } - - /// If the Json value is a number, return or cast it to a i64. - /// Returns None otherwise. - pub fn as_i64(&self) -> Option<i64> { - match *self { - Json::I64(n) => Some(n), - Json::U64(n) if n >= i64::MAX as u64 => None, - Json::U64(n) => Some(n as i64), - _ => None - } - } - - /// If the Json value is a number, return or cast it to a u64. - /// Returns None otherwise. - pub fn as_u64(&self) -> Option<u64> { - match *self { - Json::I64(n) if n >= 0 => Some(n as u64), - Json::U64(n) => Some(n), - _ => None - } - } - - /// If the Json value is a number, return or cast it to a f64. - /// Returns None otherwise. - pub fn as_f64(&self) -> Option<f64> { - match *self { - Json::I64(n) => Some(n as f64), - Json::U64(n) => Some(n as f64), - Json::F64(n) => Some(n), - _ => None - } - } - - /// Returns true if the Json value is a Boolean. Returns false otherwise. - pub fn is_boolean(&self) -> bool { - self.as_boolean().is_some() - } - - /// If the Json value is a Boolean, returns the associated bool. - /// Returns None otherwise. - pub fn as_boolean(&self) -> Option<bool> { - match self { - &Json::Boolean(b) => Some(b), - _ => None - } - } - - /// Returns true if the Json value is a Null. Returns false otherwise. - pub fn is_null(&self) -> bool { - self.as_null().is_some() - } - - /// If the Json value is a Null, returns (). - /// Returns None otherwise. - pub fn as_null(&self) -> Option<()> { - match self { - &Json::Null => Some(()), - _ => None - } - } -} - -impl<'a> Index<&'a str> for Json { - type Output = Json; - - fn index(&self, idx: &str) -> &Json { - self.find(idx).unwrap() - } -} - -impl Index<usize> for Json { - type Output = Json; - - fn index<'a>(&'a self, idx: usize) -> &'a Json { - match self { - &Json::Array(ref v) => &v[idx], - _ => panic!("can only index Json with usize if it is an array") - } - } -} - -/// The output of the streaming parser. -#[derive(PartialEq, Debug)] -pub enum JsonEvent { - ObjectStart, - ObjectEnd, - ArrayStart, - ArrayEnd, - BooleanValue(bool), - I64Value(i64), - U64Value(u64), - F64Value(f64), - StringValue(string::String), - NullValue, - Error(ParserError), -} - -#[derive(PartialEq, Debug)] -enum ParserState { - // Parse a value in an array, true means first element. - ParseArray(bool), - // Parse ',' or ']' after an element in an array. - ParseArrayComma, - // Parse a key:value in an object, true means first element. - ParseObject(bool), - // Parse ',' or ']' after an element in an object. - ParseObjectComma, - // Initial state. - ParseStart, - // Expecting the stream to end. - ParseBeforeFinish, - // Parsing can't continue. - ParseFinished, -} - -/// A Stack represents the current position of the parser in the logical -/// structure of the JSON stream. -/// For example foo.bar[3].x -pub struct Stack { - stack: Vec<InternalStackElement>, - str_buffer: Vec<u8>, -} - -/// StackElements compose a Stack. -/// For example, Key("foo"), Key("bar"), Index(3) and Key("x") are the -/// StackElements compositing the stack that represents foo.bar[3].x -#[derive(PartialEq, Clone, Debug)] -pub enum StackElement<'l> { - Index(u32), - Key(&'l str), -} - -// Internally, Key elements are stored as indices in a buffer to avoid -// allocating a string for every member of an object. -#[derive(PartialEq, Clone, Debug)] -enum InternalStackElement { - InternalIndex(u32), - InternalKey(u16, u16), // start, size -} - -impl Stack { - pub fn new() -> Stack { - Stack { stack: Vec::new(), str_buffer: Vec::new() } - } - - /// Returns The number of elements in the Stack. - pub fn len(&self) -> usize { self.stack.len() } - - /// Returns true if the stack is empty. - pub fn is_empty(&self) -> bool { self.stack.is_empty() } - - /// Provides access to the StackElement at a given index. - /// lower indices are at the bottom of the stack while higher indices are - /// at the top. - pub fn get<'l>(&'l self, idx: usize) -> StackElement<'l> { - match self.stack[idx] { - InternalIndex(i) => StackElement::Index(i), - InternalKey(start, size) => { - StackElement::Key(str::from_utf8( - &self.str_buffer[start as usize .. start as usize + size as usize]).unwrap()) - } - } - } - - /// Compares this stack with an array of StackElements. - pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool { - if self.stack.len() != rhs.len() { return false; } - for i in 0..rhs.len() { - if self.get(i) != rhs[i] { return false; } - } - return true; - } - - /// Returns true if the bottom-most elements of this stack are the same as - /// the ones passed as parameter. - pub fn starts_with(&self, rhs: &[StackElement]) -> bool { - if self.stack.len() < rhs.len() { return false; } - for i in 0..rhs.len() { - if self.get(i) != rhs[i] { return false; } - } - return true; - } - - /// Returns true if the top-most elements of this stack are the same as - /// the ones passed as parameter. - pub fn ends_with(&self, rhs: &[StackElement]) -> bool { - if self.stack.len() < rhs.len() { return false; } - let offset = self.stack.len() - rhs.len(); - for i in 0..rhs.len() { - if self.get(i + offset) != rhs[i] { return false; } - } - return true; - } - - /// Returns the top-most element (if any). - pub fn top<'l>(&'l self) -> Option<StackElement<'l>> { - return match self.stack.last() { - None => None, - Some(&InternalIndex(i)) => Some(StackElement::Index(i)), - Some(&InternalKey(start, size)) => { - Some(StackElement::Key(str::from_utf8( - &self.str_buffer[start as usize .. (start+size) as usize] - ).unwrap())) - } - } - } - - // Used by Parser to insert Key elements at the top of the stack. - fn push_key(&mut self, key: string::String) { - self.stack.push(InternalKey(self.str_buffer.len() as u16, key.len() as u16)); - for c in key.as_bytes().iter() { - self.str_buffer.push(*c); - } - } - - // Used by Parser to insert Index elements at the top of the stack. - fn push_index(&mut self, index: u32) { - self.stack.push(InternalIndex(index)); - } - - // Used by Parser to remove the top-most element of the stack. - fn pop(&mut self) { - assert!(!self.is_empty()); - match *self.stack.last().unwrap() { - InternalKey(_, sz) => { - let new_size = self.str_buffer.len() - sz as usize; - self.str_buffer.truncate(new_size); - } - InternalIndex(_) => {} - } - self.stack.pop(); - } - - // Used by Parser to test whether the top-most element is an index. - fn last_is_index(&self) -> bool { - if self.is_empty() { return false; } - return match *self.stack.last().unwrap() { - InternalIndex(_) => true, - _ => false, - } - } - - // Used by Parser to increment the index of the top-most element. - fn bump_index(&mut self) { - let len = self.stack.len(); - let idx = match *self.stack.last().unwrap() { - InternalIndex(i) => { i + 1 } - _ => { panic!(); } - }; - self.stack[len - 1] = InternalIndex(idx); - } -} - -/// A streaming JSON parser implemented as an iterator of JsonEvent, consuming -/// an iterator of char. -pub struct Parser<T> { - rdr: T, - ch: Option<char>, - line: usize, - col: usize, - // We maintain a stack representing where we are in the logical structure - // of the JSON stream. - stack: Stack, - // A state machine is kept to make it possible to interrupt and resume parsing. - state: ParserState, -} - -impl<T: Iterator<Item = char>> Iterator for Parser<T> { - type Item = JsonEvent; - - fn next(&mut self) -> Option<JsonEvent> { - if self.state == ParseFinished { - return None; - } - - if self.state == ParseBeforeFinish { - self.parse_whitespace(); - // Make sure there is no trailing characters. - if self.eof() { - self.state = ParseFinished; - return None; - } else { - return Some(self.error_event(TrailingCharacters)); - } - } - - return Some(self.parse()); - } -} - -impl<T: Iterator<Item = char>> Parser<T> { - /// Creates the JSON parser. - pub fn new(rdr: T) -> Parser<T> { - let mut p = Parser { - rdr: rdr, - ch: Some('\x00'), - line: 1, - col: 0, - stack: Stack::new(), - state: ParseStart, - }; - p.bump(); - return p; - } - - /// Provides access to the current position in the logical structure of the - /// JSON stream. - pub fn stack<'l>(&'l self) -> &'l Stack { - return &self.stack; - } - - fn eof(&self) -> bool { self.ch.is_none() } - fn ch_or_null(&self) -> char { self.ch.unwrap_or('\x00') } - fn bump(&mut self) { - self.ch = self.rdr.next(); - - if self.ch_is('\n') { - self.line += 1; - self.col = 1; - } else { - self.col += 1; - } - } - - fn next_char(&mut self) -> Option<char> { - self.bump(); - self.ch - } - fn ch_is(&self, c: char) -> bool { - self.ch == Some(c) - } - - fn error<E>(&self, reason: ErrorCode) -> Result<E, ParserError> { - Err(SyntaxError(reason, self.line, self.col)) - } - - fn parse_whitespace(&mut self) { - while self.ch_is(' ') || - self.ch_is('\n') || - self.ch_is('\t') || - self.ch_is('\r') { self.bump(); } - } - - fn parse_number(&mut self) -> JsonEvent { - let mut neg = false; - - if self.ch_is('-') { - self.bump(); - neg = true; - } - - let res = match self.parse_u64() { - Ok(res) => res, - Err(e) => { return Error(e); } - }; - - if self.ch_is('.') || self.ch_is('e') || self.ch_is('E') { - let mut res = res as f64; - - if self.ch_is('.') { - res = match self.parse_decimal(res) { - Ok(res) => res, - Err(e) => { return Error(e); } - }; - } - - if self.ch_is('e') || self.ch_is('E') { - res = match self.parse_exponent(res) { - Ok(res) => res, - Err(e) => { return Error(e); } - }; - } - - if neg { - res *= -1.0; - } - - F64Value(res) - } else { - if neg { - // Make sure we don't underflow. - if res > (i64::MAX as u64) + 1 { - Error(SyntaxError(InvalidNumber, self.line, self.col)) - } else if res == 0 { - I64Value(res as i64) - } else { - I64Value((!res + 1) as i64) - } - } else { - U64Value(res) - } - } - } - - fn parse_u64(&mut self) -> Result<u64, ParserError> { - let mut accum: u64 = 0; - - match self.ch_or_null() { - '0' => { - self.bump(); - - // A leading '0' must be the only digit before the decimal point. - match self.ch_or_null() { - '0' ... '9' => return self.error(InvalidNumber), - _ => () - } - }, - '1' ... '9' => { - while !self.eof() { - match self.ch_or_null() { - c @ '0' ... '9' => { - macro_rules! try_or_invalid { - ($e: expr) => { - match $e { - Some(v) => v, - None => return self.error(InvalidNumber) - } - } - } - accum = try_or_invalid!(accum.checked_mul(10)); - accum = try_or_invalid!(accum.checked_add((c as u64) - ('0' as u64))); - - self.bump(); - } - _ => break, - } - } - } - _ => return self.error(InvalidNumber), - } - - Ok(accum) - } - - fn parse_decimal(&mut self, mut res: f64) -> Result<f64, ParserError> { - self.bump(); - - // Make sure a digit follows the decimal place. - match self.ch_or_null() { - '0' ... '9' => (), - _ => return self.error(InvalidNumber) - } - - let mut dec = 1.0; - while !self.eof() { - match self.ch_or_null() { - c @ '0' ... '9' => { - dec /= 10.0; - res += (((c as isize) - ('0' as isize)) as f64) * dec; - self.bump(); - } - _ => break, - } - } - - Ok(res) - } - - fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> { - self.bump(); - - let mut exp = 0; - let mut neg_exp = false; - - if self.ch_is('+') { - self.bump(); - } else if self.ch_is('-') { - self.bump(); - neg_exp = true; - } - - // Make sure a digit follows the exponent place. - match self.ch_or_null() { - '0' ... '9' => (), - _ => return self.error(InvalidNumber) - } - while !self.eof() { - match self.ch_or_null() { - c @ '0' ... '9' => { - exp *= 10; - exp += (c as usize) - ('0' as usize); - - self.bump(); - } - _ => break - } - } - - let exp = 10_f64.powi(exp as i32); - if neg_exp { - res /= exp; - } else { - res *= exp; - } - - Ok(res) - } - - fn decode_hex_escape(&mut self) -> Result<u16, ParserError> { - let mut i = 0; - let mut n = 0; - while i < 4 { - self.bump(); - n = match self.ch_or_null() { - c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)), - c @ 'a' ... 'f' => n * 16 + (10 + (c as u16) - ('a' as u16)), - c @ 'A' ... 'F' => n * 16 + (10 + (c as u16) - ('A' as u16)), - _ => return self.error(InvalidEscape) - }; - - i += 1; - } - - Ok(n) - } - - fn parse_str(&mut self) -> Result<string::String, ParserError> { - let mut escape = false; - let mut res = string::String::new(); - - loop { - self.bump(); - if self.eof() { - return self.error(EOFWhileParsingString); - } - - if escape { - match self.ch_or_null() { - '"' => res.push('"'), - '\\' => res.push('\\'), - '/' => res.push('/'), - 'b' => res.push('\x08'), - 'f' => res.push('\x0c'), - 'n' => res.push('\n'), - 'r' => res.push('\r'), - 't' => res.push('\t'), - 'u' => match try!(self.decode_hex_escape()) { - 0xDC00 ... 0xDFFF => { - return self.error(LoneLeadingSurrogateInHexEscape) - } - - // Non-BMP characters are encoded as a sequence of - // two hex escapes, representing UTF-16 surrogates. - n1 @ 0xD800 ... 0xDBFF => { - match (self.next_char(), self.next_char()) { - (Some('\\'), Some('u')) => (), - _ => return self.error(UnexpectedEndOfHexEscape), - } - - let n2 = try!(self.decode_hex_escape()); - if n2 < 0xDC00 || n2 > 0xDFFF { - return self.error(LoneLeadingSurrogateInHexEscape) - } - let c = (((n1 - 0xD800) as u32) << 10 | - (n2 - 0xDC00) as u32) + 0x1_0000; - res.push(char::from_u32(c).unwrap()); - } - - n => match char::from_u32(n as u32) { - Some(c) => res.push(c), - None => return self.error(InvalidUnicodeCodePoint), - }, - }, - _ => return self.error(InvalidEscape), - } - escape = false; - } else if self.ch_is('\\') { - escape = true; - } else { - match self.ch { - Some('"') => { - self.bump(); - return Ok(res); - }, - Some(c) if c <= '\u{1F}' => - return self.error(ControlCharacterInString), - Some(c) => res.push(c), - None => unreachable!() - } - } - } - } - - // Invoked at each iteration, consumes the stream until it has enough - // information to return a JsonEvent. - // Manages an internal state so that parsing can be interrupted and resumed. - // Also keeps track of the position in the logical structure of the json - // stream int the form of a stack that can be queried by the user using the - // stack() method. - fn parse(&mut self) -> JsonEvent { - loop { - // The only paths where the loop can spin a new iteration - // are in the cases ParseArrayComma and ParseObjectComma if ',' - // is parsed. In these cases the state is set to (respectively) - // ParseArray(false) and ParseObject(false), which always return, - // so there is no risk of getting stuck in an infinite loop. - // All other paths return before the end of the loop's iteration. - self.parse_whitespace(); - - match self.state { - ParseStart => { - return self.parse_start(); - } - ParseArray(first) => { - return self.parse_array(first); - } - ParseArrayComma => { - match self.parse_array_comma_or_end() { - Some(evt) => { return evt; } - None => {} - } - } - ParseObject(first) => { - return self.parse_object(first); - } - ParseObjectComma => { - self.stack.pop(); - if self.ch_is(',') { - self.state = ParseObject(false); - self.bump(); - } else { - return self.parse_object_end(); - } - } - _ => { - return self.error_event(InvalidSyntax); - } - } - } - } - - fn parse_start(&mut self) -> JsonEvent { - let val = self.parse_value(); - self.state = match val { - Error(_) => ParseFinished, - ArrayStart => ParseArray(true), - ObjectStart => ParseObject(true), - _ => ParseBeforeFinish, - }; - return val; - } - - fn parse_array(&mut self, first: bool) -> JsonEvent { - if self.ch_is(']') { - if !first { - self.error_event(InvalidSyntax) - } else { - self.state = if self.stack.is_empty() { - ParseBeforeFinish - } else if self.stack.last_is_index() { - ParseArrayComma - } else { - ParseObjectComma - }; - self.bump(); - ArrayEnd - } - } else { - if first { - self.stack.push_index(0); - } - let val = self.parse_value(); - self.state = match val { - Error(_) => ParseFinished, - ArrayStart => ParseArray(true), - ObjectStart => ParseObject(true), - _ => ParseArrayComma, - }; - val - } - } - - fn parse_array_comma_or_end(&mut self) -> Option<JsonEvent> { - if self.ch_is(',') { - self.stack.bump_index(); - self.state = ParseArray(false); - self.bump(); - None - } else if self.ch_is(']') { - self.stack.pop(); - self.state = if self.stack.is_empty() { - ParseBeforeFinish - } else if self.stack.last_is_index() { - ParseArrayComma - } else { - ParseObjectComma - }; - self.bump(); - Some(ArrayEnd) - } else if self.eof() { - Some(self.error_event(EOFWhileParsingArray)) - } else { - Some(self.error_event(InvalidSyntax)) - } - } - - fn parse_object(&mut self, first: bool) -> JsonEvent { - if self.ch_is('}') { - if !first { - if self.stack.is_empty() { - return self.error_event(TrailingComma); - } else { - self.stack.pop(); - } - } - self.state = if self.stack.is_empty() { - ParseBeforeFinish - } else if self.stack.last_is_index() { - ParseArrayComma - } else { - ParseObjectComma - }; - self.bump(); - return ObjectEnd; - } - if self.eof() { - return self.error_event(EOFWhileParsingObject); - } - if !self.ch_is('"') { - return self.error_event(KeyMustBeAString); - } - let s = match self.parse_str() { - Ok(s) => s, - Err(e) => { - self.state = ParseFinished; - return Error(e); - } - }; - self.parse_whitespace(); - if self.eof() { - return self.error_event(EOFWhileParsingObject); - } else if self.ch_or_null() != ':' { - return self.error_event(ExpectedColon); - } - self.stack.push_key(s); - self.bump(); - self.parse_whitespace(); - - let val = self.parse_value(); - - self.state = match val { - Error(_) => ParseFinished, - ArrayStart => ParseArray(true), - ObjectStart => ParseObject(true), - _ => ParseObjectComma, - }; - return val; - } - - fn parse_object_end(&mut self) -> JsonEvent { - if self.ch_is('}') { - self.state = if self.stack.is_empty() { - ParseBeforeFinish - } else if self.stack.last_is_index() { - ParseArrayComma - } else { - ParseObjectComma - }; - self.bump(); - ObjectEnd - } else if self.eof() { - self.error_event(EOFWhileParsingObject) - } else { - self.error_event(InvalidSyntax) - } - } - - fn parse_value(&mut self) -> JsonEvent { - if self.eof() { return self.error_event(EOFWhileParsingValue); } - match self.ch_or_null() { - 'n' => { self.parse_ident("ull", NullValue) } - 't' => { self.parse_ident("rue", BooleanValue(true)) } - 'f' => { self.parse_ident("alse", BooleanValue(false)) } - '0' ... '9' | '-' => self.parse_number(), - '"' => match self.parse_str() { - Ok(s) => StringValue(s), - Err(e) => Error(e), - }, - '[' => { - self.bump(); - ArrayStart - } - '{' => { - self.bump(); - ObjectStart - } - _ => { self.error_event(InvalidSyntax) } - } - } - - fn parse_ident(&mut self, ident: &str, value: JsonEvent) -> JsonEvent { - if ident.chars().all(|c| Some(c) == self.next_char()) { - self.bump(); - value - } else { - Error(SyntaxError(InvalidSyntax, self.line, self.col)) - } - } - - fn error_event(&mut self, reason: ErrorCode) -> JsonEvent { - self.state = ParseFinished; - Error(SyntaxError(reason, self.line, self.col)) - } -} - -/// A Builder consumes a json::Parser to create a generic Json structure. -pub struct Builder<T> { - parser: Parser<T>, - token: Option<JsonEvent>, -} - -impl<T: Iterator<Item = char>> Builder<T> { - /// Create a JSON Builder. - pub fn new(src: T) -> Builder<T> { - Builder { parser: Parser::new(src), token: None, } - } - - // Decode a Json value from a Parser. - pub fn build(&mut self) -> Result<Json, BuilderError> { - self.bump(); - let result = self.build_value(); - self.bump(); - match self.token.take() { - None => {} - Some(Error(e)) => { return Err(e); } - _ => { return Err(SyntaxError(InvalidSyntax, self.parser.line, self.parser.col)); } - } - result - } - - fn bump(&mut self) { - self.token = self.parser.next(); - } - - fn build_value(&mut self) -> Result<Json, BuilderError> { - return match self.token.take() { - Some(NullValue) => Ok(Json::Null), - Some(I64Value(n)) => Ok(Json::I64(n)), - Some(U64Value(n)) => Ok(Json::U64(n)), - Some(F64Value(n)) => Ok(Json::F64(n)), - Some(BooleanValue(b)) => Ok(Json::Boolean(b)), - Some(StringValue(ref mut s)) => { - let mut temp = string::String::new(); - swap(s, &mut temp); - Ok(Json::String(temp)) - } - Some(Error(e)) => Err(e), - Some(ArrayStart) => self.build_array(), - Some(ObjectStart) => self.build_object(), - Some(ObjectEnd) => self.parser.error(InvalidSyntax), - Some(ArrayEnd) => self.parser.error(InvalidSyntax), - None => self.parser.error(EOFWhileParsingValue), - } - } - - fn build_array(&mut self) -> Result<Json, BuilderError> { - self.bump(); - let mut values = Vec::new(); - - loop { - if let Some(ArrayEnd) = self.token { - return Ok(Json::Array(values.into_iter().collect())); - } - match self.build_value() { - Ok(v) => values.push(v), - Err(e) => { return Err(e) } - } - self.bump(); - } - } - - fn build_object(&mut self) -> Result<Json, BuilderError> { - self.bump(); - - let mut values = BTreeMap::new(); - - loop { - match self.token.take() { - Some(ObjectEnd) => { return Ok(Json::Object(values)); } - Some(Error(e)) => { return Err(e); } - None => { break; } - token => { self.token = token; } - } - let key = match self.parser.stack().top() { - Some(StackElement::Key(k)) => { k.to_string() } - _ => { panic!("invalid state"); } - }; - match self.build_value() { - Ok(value) => { values.insert(key, value); } - Err(e) => { return Err(e); } - } - self.bump(); - } - return self.parser.error(EOFWhileParsingObject); - } -} - -/// A structure to decode JSON to values in rust. -pub struct Decoder { - stack: Vec<Json>, -} - -impl Decoder { - /// Creates a new decoder instance for decoding the specified JSON value. - pub fn new(json: Json) -> Decoder { - Decoder { stack: vec![json] } - } -} - -impl Decoder { - fn pop(&mut self) -> DecodeResult<Json> { - match self.stack.pop() { - Some(s) => Ok(s), - None => Err(EOF), - } - } -} - -macro_rules! expect { - ($e:expr, Null) => ({ - match try!($e) { - Json::Null => Ok(()), - other => Err(ExpectedError("Null".to_string(), - format!("{}", other))) - } - }); - ($e:expr, $t:ident) => ({ - match try!($e) { - Json::$t(v) => Ok(v), - other => { - Err(ExpectedError(stringify!($t).to_string(), - format!("{}", other))) - } - } - }) -} - -macro_rules! read_primitive { - ($name:ident, $ty:ident) => { - #[allow(unused_comparisons)] - fn $name(&mut self) -> DecodeResult<$ty> { - match try!(self.pop()) { - Json::I64(i) => { - let other = i as $ty; - if i == other as i64 && (other > 0) == (i > 0) { - Ok(other) - } else { - Err(ExpectedError("Number".to_string(), i.to_string())) - } - } - Json::U64(u) => { - let other = u as $ty; - if u == other as u64 && other >= 0 { - Ok(other) - } else { - Err(ExpectedError("Number".to_string(), u.to_string())) - } - } - Json::F64(f) => { - Err(ExpectedError("Integer".to_string(), f.to_string())) - } - // re: #12967.. a type w/ numeric keys (ie HashMap<usize, V> etc) - // is going to have a string here, as per JSON spec. - Json::String(s) => match s.parse() { - Ok(f) => Ok(f), - Err(_) => Err(ExpectedError("Number".to_string(), s)), - }, - value => { - Err(ExpectedError("Number".to_string(), value.to_string())) - } - } - } - } -} - -impl ::Decoder for Decoder { - type Error = DecoderError; - - fn read_nil(&mut self) -> DecodeResult<()> { - expect!(self.pop(), Null) - } - - read_primitive! { read_usize, usize } - read_primitive! { read_u8, u8 } - read_primitive! { read_u16, u16 } - read_primitive! { read_u32, u32 } - read_primitive! { read_u64, u64 } - read_primitive! { read_isize, isize } - read_primitive! { read_i8, i8 } - read_primitive! { read_i16, i16 } - read_primitive! { read_i32, i32 } - read_primitive! { read_i64, i64 } - - fn read_f32(&mut self) -> DecodeResult<f32> { - self.read_f64().map(|x| x as f32) - } - - fn read_f64(&mut self) -> DecodeResult<f64> { - match try!(self.pop()) { - Json::I64(f) => Ok(f as f64), - Json::U64(f) => Ok(f as f64), - Json::F64(f) => Ok(f), - Json::String(s) => { - // re: #12967.. a type w/ numeric keys (ie HashMap<usize, V> etc) - // is going to have a string here, as per JSON spec. - match s.parse() { - Ok(f) => Ok(f), - Err(_) => Err(ExpectedError("Number".to_string(), s)), - } - }, - Json::Null => Ok(f64::NAN), - value => Err(ExpectedError("Number".to_string(), format!("{}", value))) - } - } - - fn read_bool(&mut self) -> DecodeResult<bool> { - expect!(self.pop(), Boolean) - } - - fn read_char(&mut self) -> DecodeResult<char> { - let s = try!(self.read_str()); - { - let mut it = s.chars(); - match (it.next(), it.next()) { - // exactly one character - (Some(c), None) => return Ok(c), - _ => () - } - } - Err(ExpectedError("single character string".to_string(), format!("{}", s))) - } - - fn read_str(&mut self) -> DecodeResult<string::String> { - expect!(self.pop(), String) - } - - fn read_enum<T, F>(&mut self, _name: &str, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - f(self) - } - - fn read_enum_variant<T, F>(&mut self, names: &[&str], - mut f: F) -> DecodeResult<T> - where F: FnMut(&mut Decoder, usize) -> DecodeResult<T>, - { - let name = match try!(self.pop()) { - Json::String(s) => s, - Json::Object(mut o) => { - let n = match o.remove(&"variant".to_string()) { - Some(Json::String(s)) => s, - Some(val) => { - return Err(ExpectedError("String".to_string(), format!("{}", val))) - } - None => { - return Err(MissingFieldError("variant".to_string())) - } - }; - match o.remove(&"fields".to_string()) { - Some(Json::Array(l)) => { - for field in l.into_iter().rev() { - self.stack.push(field); - } - }, - Some(val) => { - return Err(ExpectedError("Array".to_string(), format!("{}", val))) - } - None => { - return Err(MissingFieldError("fields".to_string())) - } - } - n - } - json => { - return Err(ExpectedError("String or Object".to_string(), format!("{}", json))) - } - }; - let idx = match names.iter().position(|n| *n == name) { - Some(idx) => idx, - None => return Err(UnknownVariantError(name)) - }; - f(self, idx) - } - - fn read_enum_variant_arg<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - f(self) - } - - fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> DecodeResult<T> where - F: FnMut(&mut Decoder, usize) -> DecodeResult<T>, - { - self.read_enum_variant(names, f) - } - - - fn read_enum_struct_variant_field<T, F>(&mut self, - _name: &str, - idx: usize, - f: F) - -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - self.read_enum_variant_arg(idx, f) - } - - fn read_struct<T, F>(&mut self, _name: &str, _len: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - let value = try!(f(self)); - try!(self.pop()); - Ok(value) - } - - fn read_struct_field<T, F>(&mut self, - name: &str, - _idx: usize, - f: F) - -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - let mut obj = try!(expect!(self.pop(), Object)); - - let value = match obj.remove(&name.to_string()) { - None => { - // Add a Null and try to parse it as an Option<_> - // to get None as a default value. - self.stack.push(Json::Null); - match f(self) { - Ok(x) => x, - Err(_) => return Err(MissingFieldError(name.to_string())), - } - }, - Some(json) => { - self.stack.push(json); - try!(f(self)) - } - }; - self.stack.push(Json::Object(obj)); - Ok(value) - } - - fn read_tuple<T, F>(&mut self, tuple_len: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - self.read_seq(move |d, len| { - if len == tuple_len { - f(d) - } else { - Err(ExpectedError(format!("Tuple{}", tuple_len), format!("Tuple{}", len))) - } - }) - } - - fn read_tuple_arg<T, F>(&mut self, idx: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - self.read_seq_elt(idx, f) - } - - fn read_tuple_struct<T, F>(&mut self, - _name: &str, - len: usize, - f: F) - -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - self.read_tuple(len, f) - } - - fn read_tuple_struct_arg<T, F>(&mut self, - idx: usize, - f: F) - -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - self.read_tuple_arg(idx, f) - } - - fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where - F: FnMut(&mut Decoder, bool) -> DecodeResult<T>, - { - match try!(self.pop()) { - Json::Null => f(self, false), - value => { self.stack.push(value); f(self, true) } - } - } - - fn read_seq<T, F>(&mut self, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder, usize) -> DecodeResult<T>, - { - let array = try!(expect!(self.pop(), Array)); - let len = array.len(); - for v in array.into_iter().rev() { - self.stack.push(v); - } - f(self, len) - } - - fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - f(self) - } - - fn read_map<T, F>(&mut self, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder, usize) -> DecodeResult<T>, - { - let obj = try!(expect!(self.pop(), Object)); - let len = obj.len(); - for (key, value) in obj.into_iter() { - self.stack.push(value); - self.stack.push(Json::String(key)); - } - f(self, len) - } - - fn read_map_elt_key<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - f(self) - } - - fn read_map_elt_val<T, F>(&mut self, _idx: usize, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder) -> DecodeResult<T>, - { - f(self) - } - - fn error(&mut self, err: &str) -> DecoderError { - ApplicationError(err.to_string()) - } -} - -/// A trait for converting values to JSON -pub trait ToJson { - /// Converts the value of `self` to an instance of JSON - fn to_json(&self) -> Json; -} - -macro_rules! to_json_impl_i64 { - ($($t:ty), +) => ( - $(impl ToJson for $t { - fn to_json(&self) -> Json { Json::I64(*self as i64) } - })+ - ) -} - -to_json_impl_i64! { isize, i8, i16, i32, i64 } - -macro_rules! to_json_impl_u64 { - ($($t:ty), +) => ( - $(impl ToJson for $t { - fn to_json(&self) -> Json { Json::U64(*self as u64) } - })+ - ) -} - -to_json_impl_u64! { usize, u8, u16, u32, u64 } - -impl ToJson for Json { - fn to_json(&self) -> Json { self.clone() } -} - -impl ToJson for f32 { - fn to_json(&self) -> Json { (*self as f64).to_json() } -} - -impl ToJson for f64 { - fn to_json(&self) -> Json { - use std::num::FpCategory::{Nan, Infinite}; - - match self.classify() { - Nan | Infinite => Json::Null, - _ => Json::F64(*self) - } - } -} - -impl ToJson for () { - fn to_json(&self) -> Json { Json::Null } -} - -impl ToJson for bool { - fn to_json(&self) -> Json { Json::Boolean(*self) } -} - -impl ToJson for str { - fn to_json(&self) -> Json { Json::String(self.to_string()) } -} - -impl ToJson for string::String { - fn to_json(&self) -> Json { Json::String((*self).clone()) } -} - -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 : ToJson ),* - > ToJson for ( $( $tyvar ),* , ) { - - #[inline] - #[allow(non_snake_case)] - fn to_json(&self) -> Json { - match *self { - ($(ref $tyvar),*,) => Json::Array(vec![$($tyvar.to_json()),*]) - } - } - } - } -} - -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} - -impl<A: ToJson> ToJson for [A] { - fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) } -} - -impl<A: ToJson> ToJson for Vec<A> { - fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) } -} - -impl<A: ToJson> ToJson for BTreeMap<string::String, A> { - fn to_json(&self) -> Json { - let mut d = BTreeMap::new(); - for (key, value) in self.iter() { - d.insert((*key).clone(), value.to_json()); - } - Json::Object(d) - } -} - -impl<A: ToJson> ToJson for HashMap<string::String, A> { - fn to_json(&self) -> Json { - let mut d = BTreeMap::new(); - for (key, value) in self.iter() { - d.insert((*key).clone(), value.to_json()); - } - Json::Object(d) - } -} - -impl<A:ToJson> ToJson for Option<A> { - fn to_json(&self) -> Json { - match *self { - None => Json::Null, - Some(ref value) => value.to_json() - } - } -} - -struct FormatShim<'a, 'b: 'a> { - inner: &'a mut fmt::Formatter<'b>, -} - -impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> { - fn write_str(&mut self, s: &str) -> fmt::Result { - match self.inner.write_str(s) { - Ok(_) => Ok(()), - Err(_) => Err(fmt::Error) - } - } -} - -impl fmt::Display for Json { - /// Encodes a json value into a string - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut shim = FormatShim { inner: f }; - let mut encoder = Encoder::new(&mut shim); - match self.encode(&mut encoder) { - Ok(_) => Ok(()), - Err(_) => Err(fmt::Error) - } - } -} - -impl<'a> fmt::Display for PrettyJson<'a> { - /// Encodes a json value into a string - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut shim = FormatShim { inner: f }; - let mut encoder = Encoder::new_pretty(&mut shim); - match self.inner.encode(&mut encoder) { - Ok(_) => Ok(()), - Err(_) => Err(fmt::Error) - } - } -} - -impl<'a, T: Encodable> fmt::Display for AsJson<'a, T> { - /// Encodes a json value into a string - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut shim = FormatShim { inner: f }; - let mut encoder = Encoder::new(&mut shim); - match self.inner.encode(&mut encoder) { - Ok(_) => Ok(()), - Err(_) => Err(fmt::Error) - } - } -} - -impl<'a, T> AsPrettyJson<'a, T> { - /// Set the indentation level for the emitted JSON - pub fn indent(mut self, indent: u32) -> AsPrettyJson<'a, T> { - self.indent = Some(indent); - self - } -} - -impl<'a, T: Encodable> fmt::Display for AsPrettyJson<'a, T> { - /// Encodes a json value into a string - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut shim = FormatShim { inner: f }; - let mut encoder = Encoder::new_pretty(&mut shim); - if let Some(n) = self.indent { - // unwrap cannot panic for pretty encoders - let _ = encoder.set_indent(n); - } - match self.inner.encode(&mut encoder) { - Ok(_) => Ok(()), - Err(_) => Err(fmt::Error) - } - } -} - -impl FromStr for Json { - type Err = ParserError; - fn from_str(s: &str) -> Result<Json, ParserError> { - Json::from_str(s) - } -} - -#[cfg(test)] -mod tests { - use self::Animal::*; - use {Encodable, Decodable}; - use super::Json::*; - use super::ErrorCode::*; - use super::ParserError::*; - use super::DecoderError::*; - use super::JsonEvent::*; - use super::StackElement::*; - use super::{Json, DecodeResult, DecoderError, JsonEvent, Parser, - StackElement, Stack, Decoder, Encoder, EncoderError}; - use std::{i64, u64, f32, f64}; - use std::collections::BTreeMap; - use std::string; - - #[derive(RustcDecodable, Eq, PartialEq, Debug)] - struct OptionData { - opt: Option<usize>, - } - - #[test] - fn test_decode_option_none() { - let s ="{}"; - let obj: OptionData = super::decode(s).unwrap(); - assert_eq!(obj, OptionData { opt: None }); - } - - #[test] - fn test_decode_option_some() { - let s = "{ \"opt\": 10 }"; - let obj: OptionData = super::decode(s).unwrap(); - assert_eq!(obj, OptionData { opt: Some(10) }); - } - - #[test] - fn test_decode_option_malformed() { - check_err::<OptionData>("{ \"opt\": [] }", - ExpectedError("Number".to_string(), "[]".to_string())); - check_err::<OptionData>("{ \"opt\": false }", - ExpectedError("Number".to_string(), "false".to_string())); - } - - #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)] - enum Animal { - Dog, - Frog(string::String, isize) - } - - #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)] - struct Inner { - a: (), - b: usize, - c: Vec<string::String>, - } - - #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)] - struct Outer { - inner: Vec<Inner>, - } - - fn mk_object(items: &[(string::String, Json)]) -> Json { - let mut d = BTreeMap::new(); - - for item in items.iter() { - match *item { - (ref key, ref value) => { d.insert((*key).clone(), (*value).clone()); }, - } - }; - - Object(d) - } - - #[test] - fn test_from_str_trait() { - let s = "null"; - assert!(s.parse::<Json>().unwrap() == s.parse().unwrap()); - } - - #[test] - fn test_write_null() { - assert_eq!(Null.to_string(), "null"); - assert_eq!(Null.pretty().to_string(), "null"); - } - - #[test] - fn test_write_i64() { - assert_eq!(U64(0).to_string(), "0"); - assert_eq!(U64(0).pretty().to_string(), "0"); - - assert_eq!(U64(1234).to_string(), "1234"); - assert_eq!(U64(1234).pretty().to_string(), "1234"); - - assert_eq!(I64(-5678).to_string(), "-5678"); - assert_eq!(I64(-5678).pretty().to_string(), "-5678"); - - assert_eq!(U64(7650007200025252000).to_string(), "7650007200025252000"); - assert_eq!(U64(7650007200025252000).pretty().to_string(), "7650007200025252000"); - } - - #[test] - fn test_write_f64() { - assert_eq!(F64(3.0).to_string(), "3.0"); - assert_eq!(F64(3.0).pretty().to_string(), "3.0"); - - assert_eq!(F64(3.1).to_string(), "3.1"); - assert_eq!(F64(3.1).pretty().to_string(), "3.1"); - - assert_eq!(F64(-1.5).to_string(), "-1.5"); - assert_eq!(F64(-1.5).pretty().to_string(), "-1.5"); - - assert_eq!(F64(0.5).to_string(), "0.5"); - assert_eq!(F64(0.5).pretty().to_string(), "0.5"); - - assert_eq!(F64(f64::NAN).to_string(), "null"); - assert_eq!(F64(f64::NAN).pretty().to_string(), "null"); - - assert_eq!(F64(f64::INFINITY).to_string(), "null"); - assert_eq!(F64(f64::INFINITY).pretty().to_string(), "null"); - - assert_eq!(F64(f64::NEG_INFINITY).to_string(), "null"); - assert_eq!(F64(f64::NEG_INFINITY).pretty().to_string(), "null"); - } - - #[test] - fn test_write_str() { - assert_eq!(String("".to_string()).to_string(), "\"\""); - assert_eq!(String("".to_string()).pretty().to_string(), "\"\""); - - assert_eq!(String("homura".to_string()).to_string(), "\"homura\""); - assert_eq!(String("madoka".to_string()).pretty().to_string(), "\"madoka\""); - } - - #[test] - fn test_write_bool() { - assert_eq!(Boolean(true).to_string(), "true"); - assert_eq!(Boolean(true).pretty().to_string(), "true"); - - assert_eq!(Boolean(false).to_string(), "false"); - assert_eq!(Boolean(false).pretty().to_string(), "false"); - } - - #[test] - fn test_write_array() { - assert_eq!(Array(vec![]).to_string(), "[]"); - assert_eq!(Array(vec![]).pretty().to_string(), "[]"); - - assert_eq!(Array(vec![Boolean(true)]).to_string(), "[true]"); - assert_eq!( - Array(vec![Boolean(true)]).pretty().to_string(), - "\ - [\n \ - true\n\ - ]" - ); - - let long_test_array = Array(vec![ - Boolean(false), - Null, - Array(vec![String("foo\nbar".to_string()), F64(3.5)])]); - - assert_eq!(long_test_array.to_string(), - "[false,null,[\"foo\\nbar\",3.5]]"); - assert_eq!( - long_test_array.pretty().to_string(), - "\ - [\n \ - false,\n \ - null,\n \ - [\n \ - \"foo\\nbar\",\n \ - 3.5\n \ - ]\n\ - ]" - ); - } - - #[test] - fn test_write_object() { - assert_eq!(mk_object(&[]).to_string(), "{}"); - assert_eq!(mk_object(&[]).pretty().to_string(), "{}"); - - assert_eq!( - mk_object(&[ - ("a".to_string(), Boolean(true)) - ]).to_string(), - "{\"a\":true}" - ); - assert_eq!( - mk_object(&[("a".to_string(), Boolean(true))]).pretty().to_string(), - "\ - {\n \ - \"a\": true\n\ - }" - ); - - let complex_obj = mk_object(&[ - ("b".to_string(), Array(vec![ - mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]), - mk_object(&[("d".to_string(), String("".to_string()))]) - ])) - ]); - - assert_eq!( - complex_obj.to_string(), - "{\ - \"b\":[\ - {\"c\":\"\\f\\r\"},\ - {\"d\":\"\"}\ - ]\ - }" - ); - assert_eq!( - complex_obj.pretty().to_string(), - "\ - {\n \ - \"b\": [\n \ - {\n \ - \"c\": \"\\f\\r\"\n \ - },\n \ - {\n \ - \"d\": \"\"\n \ - }\n \ - ]\n\ - }" - ); - - let a = mk_object(&[ - ("a".to_string(), Boolean(true)), - ("b".to_string(), Array(vec![ - mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]), - mk_object(&[("d".to_string(), String("".to_string()))]) - ])) - ]); - - // We can't compare the strings directly because the object fields be - // printed in a different order. - assert_eq!(a.clone(), a.to_string().parse().unwrap()); - assert_eq!(a.clone(), a.pretty().to_string().parse().unwrap()); - } - - #[test] - fn test_write_enum() { - let animal = Dog; - assert_eq!( - format!("{}", super::as_json(&animal)), - "\"Dog\"" - ); - assert_eq!( - format!("{}", super::as_pretty_json(&animal)), - "\"Dog\"" - ); - - let animal = Frog("Henry".to_string(), 349); - assert_eq!( - format!("{}", super::as_json(&animal)), - "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}" - ); - assert_eq!( - format!("{}", super::as_pretty_json(&animal)), - "{\n \ - \"variant\": \"Frog\",\n \ - \"fields\": [\n \ - \"Henry\",\n \ - 349\n \ - ]\n\ - }" - ); - } - - macro_rules! check_encoder_for_simple { - ($value:expr, $expected:expr) => ({ - let s = format!("{}", super::as_json(&$value)); - assert_eq!(s, $expected); - - let s = format!("{}", super::as_pretty_json(&$value)); - assert_eq!(s, $expected); - }) - } - - #[test] - fn test_write_some() { - check_encoder_for_simple!(Some("jodhpurs".to_string()), "\"jodhpurs\""); - } - - #[test] - fn test_write_none() { - check_encoder_for_simple!(None::<string::String>, "null"); - } - - #[test] - fn test_write_char() { - check_encoder_for_simple!('a', "\"a\""); - check_encoder_for_simple!('\t', "\"\\t\""); - check_encoder_for_simple!('\u{0000}', "\"\\u0000\""); - check_encoder_for_simple!('\u{001b}', "\"\\u001b\""); - check_encoder_for_simple!('\u{007f}', "\"\\u007f\""); - check_encoder_for_simple!('\u{00a0}', "\"\u{00a0}\""); - check_encoder_for_simple!('\u{abcd}', "\"\u{abcd}\""); - check_encoder_for_simple!('\u{10ffff}', "\"\u{10ffff}\""); - } - - #[test] - fn test_trailing_characters() { - assert_eq!(Json::from_str("nulla"), Err(SyntaxError(TrailingCharacters, 1, 5))); - assert_eq!(Json::from_str("truea"), Err(SyntaxError(TrailingCharacters, 1, 5))); - assert_eq!(Json::from_str("falsea"), Err(SyntaxError(TrailingCharacters, 1, 6))); - assert_eq!(Json::from_str("1a"), Err(SyntaxError(TrailingCharacters, 1, 2))); - assert_eq!(Json::from_str("[]a"), Err(SyntaxError(TrailingCharacters, 1, 3))); - assert_eq!(Json::from_str("{}a"), Err(SyntaxError(TrailingCharacters, 1, 3))); - } - - #[test] - fn test_read_identifiers() { - assert_eq!(Json::from_str("n"), Err(SyntaxError(InvalidSyntax, 1, 2))); - assert_eq!(Json::from_str("nul"), Err(SyntaxError(InvalidSyntax, 1, 4))); - assert_eq!(Json::from_str("t"), Err(SyntaxError(InvalidSyntax, 1, 2))); - assert_eq!(Json::from_str("truz"), Err(SyntaxError(InvalidSyntax, 1, 4))); - assert_eq!(Json::from_str("f"), Err(SyntaxError(InvalidSyntax, 1, 2))); - assert_eq!(Json::from_str("faz"), Err(SyntaxError(InvalidSyntax, 1, 3))); - - assert_eq!(Json::from_str("null"), Ok(Null)); - assert_eq!(Json::from_str("true"), Ok(Boolean(true))); - assert_eq!(Json::from_str("false"), Ok(Boolean(false))); - assert_eq!(Json::from_str(" null "), Ok(Null)); - assert_eq!(Json::from_str(" true "), Ok(Boolean(true))); - assert_eq!(Json::from_str(" false "), Ok(Boolean(false))); - } - - #[test] - fn test_decode_identifiers() { - let v: () = super::decode("null").unwrap(); - assert_eq!(v, ()); - - let v: bool = super::decode("true").unwrap(); - assert_eq!(v, true); - - let v: bool = super::decode("false").unwrap(); - assert_eq!(v, false); - } - - #[test] - fn test_read_number() { - assert_eq!(Json::from_str("+"), Err(SyntaxError(InvalidSyntax, 1, 1))); - assert_eq!(Json::from_str("."), Err(SyntaxError(InvalidSyntax, 1, 1))); - assert_eq!(Json::from_str("NaN"), Err(SyntaxError(InvalidSyntax, 1, 1))); - assert_eq!(Json::from_str("-"), Err(SyntaxError(InvalidNumber, 1, 2))); - assert_eq!(Json::from_str("00"), Err(SyntaxError(InvalidNumber, 1, 2))); - assert_eq!(Json::from_str("1."), Err(SyntaxError(InvalidNumber, 1, 3))); - assert_eq!(Json::from_str("1e"), Err(SyntaxError(InvalidNumber, 1, 3))); - assert_eq!(Json::from_str("1e+"), Err(SyntaxError(InvalidNumber, 1, 4))); - - assert_eq!(Json::from_str("18446744073709551616"), Err(SyntaxError(InvalidNumber, 1, 20))); - assert_eq!(Json::from_str("18446744073709551617"), Err(SyntaxError(InvalidNumber, 1, 20))); - assert_eq!(Json::from_str("-9223372036854775809"), Err(SyntaxError(InvalidNumber, 1, 21))); - - assert_eq!(Json::from_str("3"), Ok(U64(3))); - assert_eq!(Json::from_str("3.1"), Ok(F64(3.1))); - assert_eq!(Json::from_str("-1.2"), Ok(F64(-1.2))); - assert_eq!(Json::from_str("0.4"), Ok(F64(0.4))); - assert_eq!(Json::from_str("0.4e5"), Ok(F64(0.4e5))); - assert_eq!(Json::from_str("0.4e+15"), Ok(F64(0.4e15))); - assert_eq!(Json::from_str("0.4e-01"), Ok(F64(0.4e-01))); - assert_eq!(Json::from_str(" 3 "), Ok(U64(3))); - - assert_eq!(Json::from_str("-9223372036854775808"), Ok(I64(i64::MIN))); - assert_eq!(Json::from_str("9223372036854775807"), Ok(U64(i64::MAX as u64))); - assert_eq!(Json::from_str("18446744073709551615"), Ok(U64(u64::MAX))); - } - - #[test] - fn test_decode_numbers() { - let v: f64 = super::decode("3").unwrap(); - assert_eq!(v, 3.0); - - let v: f64 = super::decode("3.1").unwrap(); - assert_eq!(v, 3.1); - - let v: f64 = super::decode("-1.2").unwrap(); - assert_eq!(v, -1.2); - - let v: f64 = super::decode("0.4").unwrap(); - assert_eq!(v, 0.4); - - let v: f64 = super::decode("0.4e5").unwrap(); - assert_eq!(v, 0.4e5); - - let v: f64 = super::decode("0.4e15").unwrap(); - assert_eq!(v, 0.4e15); - - let v: f64 = super::decode("0.4e-01").unwrap(); - assert_eq!(v, 0.4e-01); - - let v: u64 = super::decode("0").unwrap(); - assert_eq!(v, 0); - - let v: u64 = super::decode("18446744073709551615").unwrap(); - assert_eq!(v, u64::MAX); - - let v: i64 = super::decode("-9223372036854775808").unwrap(); - assert_eq!(v, i64::MIN); - - let v: i64 = super::decode("9223372036854775807").unwrap(); - assert_eq!(v, i64::MAX); - - let res: DecodeResult<i64> = super::decode("765.25252"); - match res { - Ok(..) => panic!("expected an error"), - Err(ExpectedError(ref s, _)) => assert_eq!(s, "Integer"), - Err(..) => panic!("expected an 'expected integer' error"), - } - } - - #[test] - fn test_read_str() { - assert_eq!(Json::from_str("\""), Err(SyntaxError(EOFWhileParsingString, 1, 2))); - assert_eq!(Json::from_str("\"lol"), Err(SyntaxError(EOFWhileParsingString, 1, 5))); - assert_eq!(Json::from_str("\"\n\""), Err(SyntaxError(ControlCharacterInString, 2, 1))); - assert_eq!(Json::from_str("\"\0\""), Err(SyntaxError(ControlCharacterInString, 1, 2))); - assert_eq!(Json::from_str("\"\u{1}\""), Err(SyntaxError(ControlCharacterInString, 1, 2))); - assert_eq!(Json::from_str("\"\u{1F}\""), Err(SyntaxError(ControlCharacterInString, 1, 2))); - - // Only C0 control characters are excluded. - assert!('\u{7F}'.is_control()); - assert!('\u{80}'.is_control()); - assert!('\u{9F}'.is_control()); - let c1_controls = "\u{7F}\u{80}\u{9F}".to_string(); - assert_eq!(Json::from_str(&format!("\"{}\"", c1_controls)), Ok(String(c1_controls))); - - assert_eq!(Json::from_str("\"\""), Ok(String("".to_string()))); - assert_eq!(Json::from_str("\"foo\""), Ok(String("foo".to_string()))); - assert_eq!(Json::from_str("\"\\\"\""), Ok(String("\"".to_string()))); - assert_eq!(Json::from_str("\"\\b\""), Ok(String("\x08".to_string()))); - assert_eq!(Json::from_str("\"\\n\""), Ok(String("\n".to_string()))); - assert_eq!(Json::from_str("\"\\r\""), Ok(String("\r".to_string()))); - assert_eq!(Json::from_str("\"\\t\""), Ok(String("\t".to_string()))); - assert_eq!(Json::from_str(" \"foo\" "), Ok(String("foo".to_string()))); - assert_eq!(Json::from_str("\"\\u12ab\""), Ok(String("\u{12ab}".to_string()))); - assert_eq!(Json::from_str("\"\\uAB12\""), Ok(String("\u{AB12}".to_string()))); - } - - #[test] - fn test_decode_str() { - let s = [("\"\"", ""), - ("\"foo\"", "foo"), - ("\"\\\"\"", "\""), - ("\"\\b\"", "\x08"), - ("\"\\n\"", "\n"), - ("\"\\r\"", "\r"), - ("\"\\t\"", "\t"), - ("\"\\u12ab\"", "\u{12ab}"), - ("\"\\uAB12\"", "\u{AB12}")]; - - for &(i, o) in s.iter() { - let v: string::String = super::decode(i).unwrap(); - assert_eq!(v, o); - } - } - - #[test] - fn test_read_array() { - assert_eq!(Json::from_str("["), Err(SyntaxError(EOFWhileParsingValue, 1, 2))); - assert_eq!(Json::from_str("[1"), Err(SyntaxError(EOFWhileParsingArray, 1, 3))); - assert_eq!(Json::from_str("[1,"), Err(SyntaxError(EOFWhileParsingValue, 1, 4))); - assert_eq!(Json::from_str("[1,]"), Err(SyntaxError(InvalidSyntax, 1, 4))); - assert_eq!(Json::from_str("[6 7]"), Err(SyntaxError(InvalidSyntax, 1, 4))); - - assert_eq!(Json::from_str("[]"), Ok(Array(vec![]))); - assert_eq!(Json::from_str("[ ]"), Ok(Array(vec![]))); - assert_eq!(Json::from_str("[true]"), Ok(Array(vec![Boolean(true)]))); - assert_eq!(Json::from_str("[ false ]"), Ok(Array(vec![Boolean(false)]))); - assert_eq!(Json::from_str("[null]"), Ok(Array(vec![Null]))); - assert_eq!(Json::from_str("[3, 1]"), - Ok(Array(vec![U64(3), U64(1)]))); - assert_eq!(Json::from_str("\n[3, 2]\n"), - Ok(Array(vec![U64(3), U64(2)]))); - assert_eq!(Json::from_str("[2, [4, 1]]"), - Ok(Array(vec![U64(2), Array(vec![U64(4), U64(1)])]))); - } - - #[test] - fn test_decode_array() { - let v: Vec<()> = super::decode("[]").unwrap(); - assert_eq!(v, vec![]); - - let v: Vec<()> = super::decode("[null]").unwrap(); - assert_eq!(v, vec![()]); - - let v: Vec<bool> = super::decode("[true]").unwrap(); - assert_eq!(v, vec![true]); - - let v: Vec<isize> = super::decode("[3, 1]").unwrap(); - assert_eq!(v, vec![3, 1]); - - let v: Vec<Vec<usize>> = super::decode("[[3], [1, 2]]").unwrap(); - assert_eq!(v, vec![vec![3], vec![1, 2]]); - } - - #[test] - fn test_decode_tuple() { - let t: (usize, usize, usize) = super::decode("[1, 2, 3]").unwrap(); - assert_eq!(t, (1, 2, 3)); - - let t: (usize, string::String) = super::decode("[1, \"two\"]").unwrap(); - assert_eq!(t, (1, "two".to_string())); - } - - #[test] - fn test_decode_tuple_malformed_types() { - assert!(super::decode::<(usize, string::String)>("[1, 2]").is_err()); - } - - #[test] - fn test_decode_tuple_malformed_length() { - assert!(super::decode::<(usize, usize)>("[1, 2, 3]").is_err()); - } - - #[test] - fn test_read_object() { - assert_eq!(Json::from_str("{"), Err(SyntaxError(EOFWhileParsingObject, 1, 2))); - assert_eq!(Json::from_str("{ "), Err(SyntaxError(EOFWhileParsingObject, 1, 3))); - assert_eq!(Json::from_str("{1"), Err(SyntaxError(KeyMustBeAString, 1, 2))); - assert_eq!(Json::from_str("{ \"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 6))); - assert_eq!(Json::from_str("{\"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 5))); - assert_eq!(Json::from_str("{\"a\" "), Err(SyntaxError(EOFWhileParsingObject, 1, 6))); - - assert_eq!(Json::from_str("{\"a\" 1"), Err(SyntaxError(ExpectedColon, 1, 6))); - assert_eq!(Json::from_str("{\"a\":"), Err(SyntaxError(EOFWhileParsingValue, 1, 6))); - assert_eq!(Json::from_str("{\"a\":1"), Err(SyntaxError(EOFWhileParsingObject, 1, 7))); - assert_eq!(Json::from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax, 1, 8))); - assert_eq!(Json::from_str("{\"a\":1,"), Err(SyntaxError(EOFWhileParsingObject, 1, 8))); - - assert_eq!(Json::from_str("{}").unwrap(), mk_object(&[])); - assert_eq!(Json::from_str("{\"a\": 3}").unwrap(), - mk_object(&[("a".to_string(), U64(3))])); - - assert_eq!(Json::from_str( - "{ \"a\": null, \"b\" : true }").unwrap(), - mk_object(&[ - ("a".to_string(), Null), - ("b".to_string(), Boolean(true))])); - assert_eq!(Json::from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(), - mk_object(&[ - ("a".to_string(), Null), - ("b".to_string(), Boolean(true))])); - assert_eq!(Json::from_str( - "{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(), - mk_object(&[ - ("a".to_string(), F64(1.0)), - ("b".to_string(), Array(vec![Boolean(true)])) - ])); - assert_eq!(Json::from_str( - "{\ - \"a\": 1.0, \ - \"b\": [\ - true,\ - \"foo\\nbar\", \ - { \"c\": {\"d\": null} } \ - ]\ - }").unwrap(), - mk_object(&[ - ("a".to_string(), F64(1.0)), - ("b".to_string(), Array(vec![ - Boolean(true), - String("foo\nbar".to_string()), - mk_object(&[ - ("c".to_string(), mk_object(&[("d".to_string(), Null)])) - ]) - ])) - ])); - } - - #[test] - fn test_decode_struct() { - let s = "{ - \"inner\": [ - { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] } - ] - }"; - - let v: Outer = super::decode(s).unwrap(); - assert_eq!( - v, - Outer { - inner: vec![ - Inner { a: (), b: 2, c: vec!["abc".to_string(), "xyz".to_string()] } - ] - } - ); - } - - #[derive(RustcDecodable)] - struct FloatStruct { - f: f64, - a: Vec<f64> - } - #[test] - fn test_decode_struct_with_nan() { - let s = "{\"f\":null,\"a\":[null,123]}"; - let obj: FloatStruct = super::decode(s).unwrap(); - assert!(obj.f.is_nan()); - assert!(obj.a[0].is_nan()); - assert_eq!(obj.a[1], 123f64); - } - - #[test] - fn test_decode_option() { - let value: Option<string::String> = super::decode("null").unwrap(); - assert_eq!(value, None); - - let value: Option<string::String> = super::decode("\"jodhpurs\"").unwrap(); - assert_eq!(value, Some("jodhpurs".to_string())); - } - - #[test] - fn test_decode_enum() { - let value: Animal = super::decode("\"Dog\"").unwrap(); - assert_eq!(value, Dog); - - let s = "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}"; - let value: Animal = super::decode(s).unwrap(); - assert_eq!(value, Frog("Henry".to_string(), 349)); - } - - #[test] - fn test_decode_map() { - let s = "{\"a\": \"Dog\", \"b\": {\"variant\":\"Frog\",\ - \"fields\":[\"Henry\", 349]}}"; - let mut map: BTreeMap<string::String, Animal> = super::decode(s).unwrap(); - - assert_eq!(map.remove(&"a".to_string()), Some(Dog)); - assert_eq!(map.remove(&"b".to_string()), Some(Frog("Henry".to_string(), 349))); - } - - #[test] - fn test_multiline_errors() { - assert_eq!(Json::from_str("{\n \"foo\":\n \"bar\""), - Err(SyntaxError(EOFWhileParsingObject, 3, 8))); - } - - #[derive(RustcDecodable)] - #[allow(dead_code)] - struct DecodeStruct { - x: f64, - y: bool, - z: string::String, - w: Vec<DecodeStruct> - } - #[derive(RustcDecodable)] - enum DecodeEnum { - A(f64), - B(string::String) - } - fn check_err<T: Decodable>(to_parse: &'static str, expected: DecoderError) { - let res: DecodeResult<T> = match Json::from_str(to_parse) { - Err(e) => Err(ParseError(e)), - Ok(json) => Decodable::decode(&mut Decoder::new(json)) - }; - match res { - Ok(_) => panic!("`{:?}` parsed & decoded ok, expecting error `{:?}`", - to_parse, expected), - Err(ParseError(e)) => panic!("`{}` is not valid json: {:?}", - to_parse, e), - Err(e) => { - assert_eq!(e, expected); - } - } - } - #[test] - fn test_decode_errors_struct() { - check_err::<DecodeStruct>("[]", ExpectedError("Object".to_string(), "[]".to_string())); - check_err::<DecodeStruct>("{\"x\": true, \"y\": true, \"z\": \"\", \"w\": []}", - ExpectedError("Number".to_string(), "true".to_string())); - check_err::<DecodeStruct>("{\"x\": 1, \"y\": [], \"z\": \"\", \"w\": []}", - ExpectedError("Boolean".to_string(), "[]".to_string())); - check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": {}, \"w\": []}", - ExpectedError("String".to_string(), "{}".to_string())); - check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": \"\", \"w\": null}", - ExpectedError("Array".to_string(), "null".to_string())); - check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": \"\"}", - MissingFieldError("w".to_string())); - } - #[test] - fn test_decode_errors_enum() { - check_err::<DecodeEnum>("{}", - MissingFieldError("variant".to_string())); - check_err::<DecodeEnum>("{\"variant\": 1}", - ExpectedError("String".to_string(), "1".to_string())); - check_err::<DecodeEnum>("{\"variant\": \"A\"}", - MissingFieldError("fields".to_string())); - check_err::<DecodeEnum>("{\"variant\": \"A\", \"fields\": null}", - ExpectedError("Array".to_string(), "null".to_string())); - check_err::<DecodeEnum>("{\"variant\": \"C\", \"fields\": []}", - UnknownVariantError("C".to_string())); - } - - #[test] - fn test_find(){ - let json_value = Json::from_str("{\"dog\" : \"cat\"}").unwrap(); - let found_str = json_value.find("dog"); - assert!(found_str.unwrap().as_string().unwrap() == "cat"); - } - - #[test] - fn test_find_path(){ - let json_value = Json::from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap(); - let found_str = json_value.find_path(&["dog", "cat", "mouse"]); - assert!(found_str.unwrap().as_string().unwrap() == "cheese"); - } - - #[test] - fn test_search(){ - let json_value = Json::from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap(); - let found_str = json_value.search("mouse").and_then(|j| j.as_string()); - assert!(found_str.unwrap() == "cheese"); - } - - #[test] - fn test_index(){ - let json_value = Json::from_str("{\"animals\":[\"dog\",\"cat\",\"mouse\"]}").unwrap(); - let ref array = json_value["animals"]; - assert_eq!(array[0].as_string().unwrap(), "dog"); - assert_eq!(array[1].as_string().unwrap(), "cat"); - assert_eq!(array[2].as_string().unwrap(), "mouse"); - } - - #[test] - fn test_is_object(){ - let json_value = Json::from_str("{}").unwrap(); - assert!(json_value.is_object()); - } - - #[test] - fn test_as_object(){ - let json_value = Json::from_str("{}").unwrap(); - let json_object = json_value.as_object(); - assert!(json_object.is_some()); - } - - #[test] - fn test_is_array(){ - let json_value = Json::from_str("[1, 2, 3]").unwrap(); - assert!(json_value.is_array()); - } - - #[test] - fn test_as_array(){ - let json_value = Json::from_str("[1, 2, 3]").unwrap(); - let json_array = json_value.as_array(); - let expected_length = 3; - assert!(json_array.is_some() && json_array.unwrap().len() == expected_length); - } - - #[test] - fn test_is_string(){ - let json_value = Json::from_str("\"dog\"").unwrap(); - assert!(json_value.is_string()); - } - - #[test] - fn test_as_string(){ - let json_value = Json::from_str("\"dog\"").unwrap(); - let json_str = json_value.as_string(); - let expected_str = "dog"; - assert_eq!(json_str, Some(expected_str)); - } - - #[test] - fn test_is_number(){ - let json_value = Json::from_str("12").unwrap(); - assert!(json_value.is_number()); - } - - #[test] - fn test_is_i64(){ - let json_value = Json::from_str("-12").unwrap(); - assert!(json_value.is_i64()); - - let json_value = Json::from_str("12").unwrap(); - assert!(!json_value.is_i64()); - - let json_value = Json::from_str("12.0").unwrap(); - assert!(!json_value.is_i64()); - } - - #[test] - fn test_is_u64(){ - let json_value = Json::from_str("12").unwrap(); - assert!(json_value.is_u64()); - - let json_value = Json::from_str("-12").unwrap(); - assert!(!json_value.is_u64()); - - let json_value = Json::from_str("12.0").unwrap(); - assert!(!json_value.is_u64()); - } - - #[test] - fn test_is_f64(){ - let json_value = Json::from_str("12").unwrap(); - assert!(!json_value.is_f64()); - - let json_value = Json::from_str("-12").unwrap(); - assert!(!json_value.is_f64()); - - let json_value = Json::from_str("12.0").unwrap(); - assert!(json_value.is_f64()); - - let json_value = Json::from_str("-12.0").unwrap(); - assert!(json_value.is_f64()); - } - - #[test] - fn test_as_i64(){ - let json_value = Json::from_str("-12").unwrap(); - let json_num = json_value.as_i64(); - assert_eq!(json_num, Some(-12)); - } - - #[test] - fn test_as_u64(){ - let json_value = Json::from_str("12").unwrap(); - let json_num = json_value.as_u64(); - assert_eq!(json_num, Some(12)); - } - - #[test] - fn test_as_f64(){ - let json_value = Json::from_str("12.0").unwrap(); - let json_num = json_value.as_f64(); - assert_eq!(json_num, Some(12f64)); - } - - #[test] - fn test_is_boolean(){ - let json_value = Json::from_str("false").unwrap(); - assert!(json_value.is_boolean()); - } - - #[test] - fn test_as_boolean(){ - let json_value = Json::from_str("false").unwrap(); - let json_bool = json_value.as_boolean(); - let expected_bool = false; - assert!(json_bool.is_some() && json_bool.unwrap() == expected_bool); - } - - #[test] - fn test_is_null(){ - let json_value = Json::from_str("null").unwrap(); - assert!(json_value.is_null()); - } - - #[test] - fn test_as_null(){ - let json_value = Json::from_str("null").unwrap(); - let json_null = json_value.as_null(); - let expected_null = (); - assert!(json_null.is_some() && json_null.unwrap() == expected_null); - } - - #[test] - fn test_encode_hashmap_with_numeric_key() { - use std::collections::HashMap; - let mut hm: HashMap<usize, bool> = HashMap::new(); - hm.insert(1, true); - let json_str = super::as_pretty_json(&hm).to_string(); - match Json::from_str(&json_str) { - Err(_) => panic!("Unable to parse json_str: {}", json_str), - _ => {} // it parsed and we are good to go - } - } - - #[test] - fn test_negative_zero() { - Json::from_str("{\"test\":-0}").unwrap(); - } - - #[test] - fn test_prettyencode_hashmap_with_numeric_key() { - use std::collections::HashMap; - let mut hm: HashMap<usize, bool> = HashMap::new(); - hm.insert(1, true); - let json_str = super::as_pretty_json(&hm).to_string(); - match Json::from_str(&json_str) { - Err(_) => panic!("Unable to parse json_str: {}", json_str), - _ => {} // it parsed and we are good to go - } - } - - #[test] - fn test_prettyencoder_indent_level_param() { - use std::collections::BTreeMap; - - let mut tree = BTreeMap::new(); - - tree.insert("hello".to_string(), String("guten tag".to_string())); - tree.insert("goodbye".to_string(), String("sayonara".to_string())); - - let json = Array( - // The following layout below should look a lot like - // the pretty-printed JSON (indent * x) - vec! - ( // 0x - String("greetings".to_string()), // 1x - Object(tree), // 1x + 2x + 2x + 1x - ) // 0x - // End JSON array (7 lines) - ); - - // Helper function for counting indents - fn indents(source: &str) -> usize { - let trimmed = source.trim_left_matches(' '); - source.len() - trimmed.len() - } - - // Test up to 4 spaces of indents (more?) - for i in 0..4 { - let printed = super::as_pretty_json(&json).indent(i as u32) - .to_string(); - - // Check for indents at each line - let lines: Vec<&str> = printed.lines().collect(); - assert_eq!(lines.len(), 7); // JSON should be 7 lines - - assert_eq!(indents(lines[0]), 0 * i); // [ - assert_eq!(indents(lines[1]), 1 * i); // "greetings", - assert_eq!(indents(lines[2]), 1 * i); // { - assert_eq!(indents(lines[3]), 2 * i); // "hello": "guten tag", - assert_eq!(indents(lines[4]), 2 * i); // "goodbye": "sayonara" - assert_eq!(indents(lines[5]), 1 * i); // }, - assert_eq!(indents(lines[6]), 0 * i); // ] - - // Finally, test that the pretty-printed JSON is valid - Json::from_str(&printed).ok() - .expect("Pretty-printed JSON is invalid!"); - } - } - - #[test] - fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() { - use std::collections::HashMap; - use Decodable; - let json_str = "{\"1\":true}"; - let json_obj = match Json::from_str(json_str) { - Err(_) => panic!("Unable to parse json_str: {}", json_str), - Ok(o) => o - }; - let mut decoder = Decoder::new(json_obj); - let _hm: HashMap<usize, bool> = Decodable::decode(&mut decoder).unwrap(); - } - - #[test] - fn test_hashmap_with_enum_key() { - use std::collections::HashMap; - use json; - #[derive(RustcEncodable, Eq, Hash, PartialEq, RustcDecodable, Debug)] - enum Enum { - Foo, - #[allow(dead_code)] - Bar, - } - let mut map = HashMap::new(); - map.insert(Enum::Foo, 0); - let result = json::encode(&map).unwrap(); - assert_eq!(result, r#"{"Foo":0}"#); - let decoded: HashMap<Enum, _> = json::decode(&result).unwrap(); - assert_eq!(map, decoded); - } - - #[test] - fn test_hashmap_with_numeric_key_will_error_with_string_keys() { - use std::collections::HashMap; - use Decodable; - let json_str = "{\"a\":true}"; - let json_obj = match Json::from_str(json_str) { - Err(_) => panic!("Unable to parse json_str: {}", json_str), - Ok(o) => o - }; - let mut decoder = Decoder::new(json_obj); - let result: Result<HashMap<usize, bool>, DecoderError> = Decodable::decode(&mut decoder); - assert_eq!(result, Err(ExpectedError("Number".to_string(), "a".to_string()))); - } - - fn assert_stream_equal(src: &str, - expected: Vec<(JsonEvent, Vec<StackElement>)>) { - let mut parser = Parser::new(src.chars()); - let mut i = 0; - loop { - let evt = match parser.next() { - Some(e) => e, - None => { break; } - }; - let (ref expected_evt, ref expected_stack) = expected[i]; - if !parser.stack().is_equal_to(&expected_stack) { - panic!("Parser stack is not equal to {:?}", expected_stack); - } - assert_eq!(&evt, expected_evt); - i+=1; - } - } - #[test] - #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064) - fn test_streaming_parser() { - assert_stream_equal( - r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#, - vec![ - (ObjectStart, vec![]), - (StringValue("bar".to_string()), vec![Key("foo")]), - (ArrayStart, vec![Key("array")]), - (U64Value(0), vec![Key("array"), Index(0)]), - (U64Value(1), vec![Key("array"), Index(1)]), - (U64Value(2), vec![Key("array"), Index(2)]), - (U64Value(3), vec![Key("array"), Index(3)]), - (U64Value(4), vec![Key("array"), Index(4)]), - (U64Value(5), vec![Key("array"), Index(5)]), - (ArrayEnd, vec![Key("array")]), - (ArrayStart, vec![Key("idents")]), - (NullValue, vec![Key("idents"), Index(0)]), - (BooleanValue(true), vec![Key("idents"), Index(1)]), - (BooleanValue(false), vec![Key("idents"), Index(2)]), - (ArrayEnd, vec![Key("idents")]), - (ObjectEnd, vec![]), - ] - ); - } - fn last_event(src: &str) -> JsonEvent { - let mut parser = Parser::new(src.chars()); - let mut evt = NullValue; - loop { - evt = match parser.next() { - Some(e) => e, - None => return evt, - } - } - } - - #[test] - #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064) - fn test_read_object_streaming() { - assert_eq!(last_event("{ "), Error(SyntaxError(EOFWhileParsingObject, 1, 3))); - assert_eq!(last_event("{1"), Error(SyntaxError(KeyMustBeAString, 1, 2))); - assert_eq!(last_event("{ \"a\""), Error(SyntaxError(EOFWhileParsingObject, 1, 6))); - assert_eq!(last_event("{\"a\""), Error(SyntaxError(EOFWhileParsingObject, 1, 5))); - assert_eq!(last_event("{\"a\" "), Error(SyntaxError(EOFWhileParsingObject, 1, 6))); - - assert_eq!(last_event("{\"a\" 1"), Error(SyntaxError(ExpectedColon, 1, 6))); - assert_eq!(last_event("{\"a\":"), Error(SyntaxError(EOFWhileParsingValue, 1, 6))); - assert_eq!(last_event("{\"a\":1"), Error(SyntaxError(EOFWhileParsingObject, 1, 7))); - assert_eq!(last_event("{\"a\":1 1"), Error(SyntaxError(InvalidSyntax, 1, 8))); - assert_eq!(last_event("{\"a\":1,"), Error(SyntaxError(EOFWhileParsingObject, 1, 8))); - assert_eq!(last_event("{\"a\":1,}"), Error(SyntaxError(TrailingComma, 1, 8))); - - assert_stream_equal( - "{}", - vec![(ObjectStart, vec![]), (ObjectEnd, vec![])] - ); - assert_stream_equal( - "{\"a\": 3}", - vec![ - (ObjectStart, vec![]), - (U64Value(3), vec![Key("a")]), - (ObjectEnd, vec![]), - ] - ); - assert_stream_equal( - "{ \"a\": null, \"b\" : true }", - vec![ - (ObjectStart, vec![]), - (NullValue, vec![Key("a")]), - (BooleanValue(true), vec![Key("b")]), - (ObjectEnd, vec![]), - ] - ); - assert_stream_equal( - "{\"a\" : 1.0 ,\"b\": [ true ]}", - vec![ - (ObjectStart, vec![]), - (F64Value(1.0), vec![Key("a")]), - (ArrayStart, vec![Key("b")]), - (BooleanValue(true),vec![Key("b"), Index(0)]), - (ArrayEnd, vec![Key("b")]), - (ObjectEnd, vec![]), - ] - ); - assert_stream_equal( - r#"{ - "a": 1.0, - "b": [ - true, - "foo\nbar", - { "c": {"d": null} }, - "\uD834\uDF06" - ] - }"#, - vec![ - (ObjectStart, vec![]), - (F64Value(1.0), vec![Key("a")]), - (ArrayStart, vec![Key("b")]), - (BooleanValue(true), vec![Key("b"), Index(0)]), - (StringValue("foo\nbar".to_string()), vec![Key("b"), Index(1)]), - (ObjectStart, vec![Key("b"), Index(2)]), - (ObjectStart, vec![Key("b"), Index(2), Key("c")]), - (NullValue, vec![Key("b"), Index(2), Key("c"), Key("d")]), - (ObjectEnd, vec![Key("b"), Index(2), Key("c")]), - (ObjectEnd, vec![Key("b"), Index(2)]), - (StringValue("\u{1D306}".to_string()), vec![Key("b"), Index(3)]), - (ArrayEnd, vec![Key("b")]), - (ObjectEnd, vec![]), - ] - ); - } - #[test] - #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064) - fn test_read_array_streaming() { - assert_stream_equal( - "[]", - vec![ - (ArrayStart, vec![]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "[ ]", - vec![ - (ArrayStart, vec![]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "[true]", - vec![ - (ArrayStart, vec![]), - (BooleanValue(true), vec![Index(0)]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "[ false ]", - vec![ - (ArrayStart, vec![]), - (BooleanValue(false), vec![Index(0)]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "[null]", - vec![ - (ArrayStart, vec![]), - (NullValue, vec![Index(0)]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "[3, 1]", - vec![ - (ArrayStart, vec![]), - (U64Value(3), vec![Index(0)]), - (U64Value(1), vec![Index(1)]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "\n[3, 2]\n", - vec![ - (ArrayStart, vec![]), - (U64Value(3), vec![Index(0)]), - (U64Value(2), vec![Index(1)]), - (ArrayEnd, vec![]), - ] - ); - assert_stream_equal( - "[2, [4, 1]]", - vec![ - (ArrayStart, vec![]), - (U64Value(2), vec![Index(0)]), - (ArrayStart, vec![Index(1)]), - (U64Value(4), vec![Index(1), Index(0)]), - (U64Value(1), vec![Index(1), Index(1)]), - (ArrayEnd, vec![Index(1)]), - (ArrayEnd, vec![]), - ] - ); - - assert_eq!(last_event("["), Error(SyntaxError(EOFWhileParsingValue, 1, 2))); - - assert_eq!(Json::from_str("["), Err(SyntaxError(EOFWhileParsingValue, 1, 2))); - assert_eq!(Json::from_str("[1"), Err(SyntaxError(EOFWhileParsingArray, 1, 3))); - assert_eq!(Json::from_str("[1,"), Err(SyntaxError(EOFWhileParsingValue, 1, 4))); - assert_eq!(Json::from_str("[1,]"), Err(SyntaxError(InvalidSyntax, 1, 4))); - assert_eq!(Json::from_str("[6 7]"), Err(SyntaxError(InvalidSyntax, 1, 4))); - - } - #[test] - fn test_trailing_characters_streaming() { - assert_eq!(last_event("nulla"), Error(SyntaxError(TrailingCharacters, 1, 5))); - assert_eq!(last_event("truea"), Error(SyntaxError(TrailingCharacters, 1, 5))); - assert_eq!(last_event("falsea"), Error(SyntaxError(TrailingCharacters, 1, 6))); - assert_eq!(last_event("1a"), Error(SyntaxError(TrailingCharacters, 1, 2))); - assert_eq!(last_event("[]a"), Error(SyntaxError(TrailingCharacters, 1, 3))); - assert_eq!(last_event("{}a"), Error(SyntaxError(TrailingCharacters, 1, 3))); - } - #[test] - fn test_read_identifiers_streaming() { - assert_eq!(Parser::new("null".chars()).next(), Some(NullValue)); - assert_eq!(Parser::new("true".chars()).next(), Some(BooleanValue(true))); - assert_eq!(Parser::new("false".chars()).next(), Some(BooleanValue(false))); - - assert_eq!(last_event("n"), Error(SyntaxError(InvalidSyntax, 1, 2))); - assert_eq!(last_event("nul"), Error(SyntaxError(InvalidSyntax, 1, 4))); - assert_eq!(last_event("t"), Error(SyntaxError(InvalidSyntax, 1, 2))); - assert_eq!(last_event("truz"), Error(SyntaxError(InvalidSyntax, 1, 4))); - assert_eq!(last_event("f"), Error(SyntaxError(InvalidSyntax, 1, 2))); - assert_eq!(last_event("faz"), Error(SyntaxError(InvalidSyntax, 1, 3))); - } - - #[test] - fn test_stack() { - let mut stack = Stack::new(); - - assert!(stack.is_empty()); - assert!(stack.len() == 0); - assert!(!stack.last_is_index()); - - stack.push_index(0); - stack.bump_index(); - - assert!(stack.len() == 1); - assert!(stack.is_equal_to(&[Index(1)])); - assert!(stack.starts_with(&[Index(1)])); - assert!(stack.ends_with(&[Index(1)])); - assert!(stack.last_is_index()); - assert!(stack.get(0) == Index(1)); - - stack.push_key("foo".to_string()); - - assert!(stack.len() == 2); - assert!(stack.is_equal_to(&[Index(1), Key("foo")])); - assert!(stack.starts_with(&[Index(1), Key("foo")])); - assert!(stack.starts_with(&[Index(1)])); - assert!(stack.ends_with(&[Index(1), Key("foo")])); - assert!(stack.ends_with(&[Key("foo")])); - assert!(!stack.last_is_index()); - assert!(stack.get(0) == Index(1)); - assert!(stack.get(1) == Key("foo")); - - stack.push_key("bar".to_string()); - - assert!(stack.len() == 3); - assert!(stack.is_equal_to(&[Index(1), Key("foo"), Key("bar")])); - assert!(stack.starts_with(&[Index(1)])); - assert!(stack.starts_with(&[Index(1), Key("foo")])); - assert!(stack.starts_with(&[Index(1), Key("foo"), Key("bar")])); - assert!(stack.ends_with(&[Key("bar")])); - assert!(stack.ends_with(&[Key("foo"), Key("bar")])); - assert!(stack.ends_with(&[Index(1), Key("foo"), Key("bar")])); - assert!(!stack.last_is_index()); - assert!(stack.get(0) == Index(1)); - assert!(stack.get(1) == Key("foo")); - assert!(stack.get(2) == Key("bar")); - - stack.pop(); - - assert!(stack.len() == 2); - assert!(stack.is_equal_to(&[Index(1), Key("foo")])); - assert!(stack.starts_with(&[Index(1), Key("foo")])); - assert!(stack.starts_with(&[Index(1)])); - assert!(stack.ends_with(&[Index(1), Key("foo")])); - assert!(stack.ends_with(&[Key("foo")])); - assert!(!stack.last_is_index()); - assert!(stack.get(0) == Index(1)); - assert!(stack.get(1) == Key("foo")); - } - - #[test] - fn test_to_json() { - use std::collections::{HashMap,BTreeMap}; - use super::ToJson; - - let array2 = Array(vec!(I64(1), I64(2))); - let array3 = Array(vec!(I64(1), I64(2), I64(3))); - let object = { - let mut tree_map = BTreeMap::new(); - tree_map.insert("a".to_string(), U64(1)); - tree_map.insert("b".to_string(), U64(2)); - Object(tree_map) - }; - - assert_eq!(array2.to_json(), array2); - assert_eq!(object.to_json(), object); - assert_eq!(3_isize.to_json(), I64(3)); - assert_eq!(4_i8.to_json(), I64(4)); - assert_eq!(5_i16.to_json(), I64(5)); - assert_eq!(6_i32.to_json(), I64(6)); - assert_eq!(7_i64.to_json(), I64(7)); - assert_eq!(8_usize.to_json(), U64(8)); - assert_eq!(9_u8.to_json(), U64(9)); - assert_eq!(10_u16.to_json(), U64(10)); - assert_eq!(11_u32.to_json(), U64(11)); - assert_eq!(12_u64.to_json(), U64(12)); - assert_eq!(13.0_f32.to_json(), F64(13.0_f64)); - assert_eq!(14.0_f64.to_json(), F64(14.0_f64)); - assert_eq!(().to_json(), Null); - assert_eq!(f32::INFINITY.to_json(), Null); - assert_eq!(f64::NAN.to_json(), Null); - assert_eq!(true.to_json(), Boolean(true)); - assert_eq!(false.to_json(), Boolean(false)); - assert_eq!("abc".to_json(), String("abc".to_string())); - assert_eq!("abc".to_string().to_json(), String("abc".to_string())); - assert_eq!((1, 2).to_json(), array2); - assert_eq!((1, 2, 3).to_json(), array3); - assert_eq!([1, 2].to_json(), array2); - assert_eq!((&[1, 2, 3]).to_json(), array3); - assert_eq!((vec![1, 2]).to_json(), array2); - assert_eq!(vec!(1, 2, 3).to_json(), array3); - let mut tree_map = BTreeMap::new(); - tree_map.insert("a".to_string(), 1 as u32); - tree_map.insert("b".to_string(), 2); - assert_eq!(tree_map.to_json(), object); - let mut hash_map = HashMap::new(); - hash_map.insert("a".to_string(), 1 as u32); - hash_map.insert("b".to_string(), 2); - assert_eq!(hash_map.to_json(), object); - assert_eq!(Some(15).to_json(), I64(15)); - assert_eq!(Some(15 as u32).to_json(), U64(15)); - assert_eq!(None::<isize>.to_json(), Null); - } - - #[test] - fn test_encode_hashmap_with_arbitrary_key() { - use std::collections::HashMap; - #[derive(PartialEq, Eq, Hash, RustcEncodable)] - struct ArbitraryType(u32); - let mut hm: HashMap<ArbitraryType, bool> = HashMap::new(); - hm.insert(ArbitraryType(1), true); - let mut mem_buf = string::String::new(); - let mut encoder = Encoder::new(&mut mem_buf); - let result = hm.encode(&mut encoder); - match result.err().unwrap() { - EncoderError::BadHashmapKey => (), - _ => panic!("expected bad hash map key") - } - } - - #[test] - fn test_encode_decode_phantom_data() { - use std::marker::PhantomData; - - #[derive(Debug, RustcDecodable, RustcEncodable, Eq, PartialEq)] - struct Foo<P> { - phantom_data: PhantomData<P> - } - - let f: Foo<u8> = Foo { - phantom_data: PhantomData - }; - let s = super::encode(&f).unwrap(); - let d: Foo<u8> = super::decode(&s).unwrap(); - assert_eq!(f, d); - } - - #[test] - fn test_bad_json_stack_depleted() { - use json; - #[derive(Debug, RustcDecodable)] - enum ChatEvent { - Variant(i32) - } - let serialized = "{\"variant\": \"Variant\", \"fields\": []}"; - let r: Result<ChatEvent, _> = json::decode(serialized); - assert!(r.unwrap_err() == EOF); - } - - #[test] - fn fixed_length_array() { - #[derive(Debug, RustcDecodable, RustcEncodable, Eq, PartialEq)] - struct Foo { - a: [u8; 1], - b: [i32; 2], - c: [u64; 3], - } - let f = Foo { - a: [0], - b: [1, 2], - c: [3, 4, 5], - }; - let s = super::encode(&f).unwrap(); - let d = super::decode(&s).unwrap(); - assert_eq!(f, d); - } - - #[test] - fn test_unexpected_token() { - match Json::from_str("{\"\":\"\",\"\":{\"\":\"\",\"\":[{\"\":\"\",}}}") { - Err(e) => assert_eq!(e, SyntaxError(InvalidSyntax, 1, 32)), - _ => () - }; - } -} diff --git a/src/vendor/rustc-serialize/src/lib.rs b/src/vendor/rustc-serialize/src/lib.rs deleted file mode 100644 index 8a4acf2d502..00000000000 --- a/src/vendor/rustc-serialize/src/lib.rs +++ /dev/null @@ -1,69 +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. - -//! Support code for encoding and decoding types. -//! -//! # Usage -//! -//! This crate is [on crates.io](https://crates.io/crates/rustc-serialize) and -//! can be used by adding `rustc-serialize` to the dependencies in your -//! project's `Cargo.toml`. -//! -//! ```toml -//! [dependencies] -//! rustc-serialize = "0.3" -//! ``` -//! -//! and this to your crate root: -//! -//! ```rust -//! extern crate rustc_serialize; -//! ``` - -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/rustc-serialize/")] -#![cfg_attr(test, deny(warnings))] -#![allow(trivial_numeric_casts)] -#![cfg_attr(rust_build, feature(staged_api))] -#![cfg_attr(rust_build, staged_api)] -#![cfg_attr(rust_build, - unstable(feature = "rustc_private", - reason = "use the crates.io `rustc-serialize` library instead"))] - -#[cfg(test)] extern crate rand; - -pub use self::serialize::{Decoder, Encoder, Decodable, Encodable, - DecoderHelpers, EncoderHelpers}; - - -// Limit collections from allocating more than -// 1 MB for calls to `with_capacity`. -fn cap_capacity<T>(given_len: usize) -> usize { - use std::cmp::min; - use std::mem::size_of; - const PRE_ALLOCATE_CAP: usize = 0x100000; - - match size_of::<T>() { - 0 => min(given_len, PRE_ALLOCATE_CAP), - n => min(given_len, PRE_ALLOCATE_CAP / n) - } -} - -mod serialize; -mod collection_impls; - -pub mod base64; -pub mod hex; -pub mod json; - -mod rustc_serialize { - pub use serialize::*; -} diff --git a/src/vendor/rustc-serialize/src/serialize.rs b/src/vendor/rustc-serialize/src/serialize.rs deleted file mode 100644 index 02052f6d670..00000000000 --- a/src/vendor/rustc-serialize/src/serialize.rs +++ /dev/null @@ -1,843 +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. - -//! Support code for encoding and decoding types. - -/* -Core encoding and decoding interfaces. -*/ - -use std::cell::{Cell, RefCell}; -use std::ffi::OsString; -use std::path; -use std::rc::Rc; -use std::sync::Arc; -use std::marker::PhantomData; -use std::borrow::Cow; - -use cap_capacity; - -pub trait Encoder { - type Error; - - // Primitive types: - fn emit_nil(&mut self) -> Result<(), Self::Error>; - fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>; - fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>; - fn emit_u32(&mut self, v: u32) -> Result<(), Self::Error>; - fn emit_u16(&mut self, v: u16) -> Result<(), Self::Error>; - fn emit_u8(&mut self, v: u8) -> Result<(), Self::Error>; - fn emit_isize(&mut self, v: isize) -> Result<(), Self::Error>; - fn emit_i64(&mut self, v: i64) -> Result<(), Self::Error>; - fn emit_i32(&mut self, v: i32) -> Result<(), Self::Error>; - fn emit_i16(&mut self, v: i16) -> Result<(), Self::Error>; - fn emit_i8(&mut self, v: i8) -> Result<(), Self::Error>; - fn emit_bool(&mut self, v: bool) -> Result<(), Self::Error>; - fn emit_f64(&mut self, v: f64) -> Result<(), Self::Error>; - fn emit_f32(&mut self, v: f32) -> Result<(), Self::Error>; - fn emit_char(&mut self, v: char) -> Result<(), Self::Error>; - fn emit_str(&mut self, v: &str) -> Result<(), Self::Error>; - - // Compound types: - fn emit_enum<F>(&mut self, name: &str, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_enum_variant<F>(&mut self, v_name: &str, - v_id: usize, - len: usize, - f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_enum_variant_arg<F>(&mut self, a_idx: usize, f: F) - -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_enum_struct_variant<F>(&mut self, v_name: &str, - v_id: usize, - len: usize, - f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_enum_struct_variant_field<F>(&mut self, - f_name: &str, - f_idx: usize, - f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_struct<F>(&mut self, name: &str, len: usize, f: F) - -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_struct_field<F>(&mut self, f_name: &str, f_idx: usize, f: F) - -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_tuple<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_tuple_struct<F>(&mut self, name: &str, len: usize, f: F) - -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_tuple_struct_arg<F>(&mut self, f_idx: usize, f: F) - -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - // Specialized types: - fn emit_option<F>(&mut self, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_option_none(&mut self) -> Result<(), Self::Error>; - fn emit_option_some<F>(&mut self, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_seq_elt<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - - fn emit_map<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_map_elt_key<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; - fn emit_map_elt_val<F>(&mut self, idx: usize, f: F) -> Result<(), Self::Error> - where F: FnOnce(&mut Self) -> Result<(), Self::Error>; -} - -pub trait Decoder { - type Error; - - // Primitive types: - fn read_nil(&mut self) -> Result<(), Self::Error>; - fn read_usize(&mut self) -> Result<usize, Self::Error>; - fn read_u64(&mut self) -> Result<u64, Self::Error>; - fn read_u32(&mut self) -> Result<u32, Self::Error>; - fn read_u16(&mut self) -> Result<u16, Self::Error>; - fn read_u8(&mut self) -> Result<u8, Self::Error>; - fn read_isize(&mut self) -> Result<isize, Self::Error>; - fn read_i64(&mut self) -> Result<i64, Self::Error>; - fn read_i32(&mut self) -> Result<i32, Self::Error>; - fn read_i16(&mut self) -> Result<i16, Self::Error>; - fn read_i8(&mut self) -> Result<i8, Self::Error>; - fn read_bool(&mut self) -> Result<bool, Self::Error>; - fn read_f64(&mut self) -> Result<f64, Self::Error>; - fn read_f32(&mut self) -> Result<f32, Self::Error>; - fn read_char(&mut self) -> Result<char, Self::Error>; - fn read_str(&mut self) -> Result<String, Self::Error>; - - // Compound types: - fn read_enum<T, F>(&mut self, name: &str, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) - -> Result<T, Self::Error> - where F: FnMut(&mut Self, usize) -> Result<T, Self::Error>; - fn read_enum_variant_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) - -> Result<T, Self::Error> - where F: FnMut(&mut Self, usize) -> Result<T, Self::Error>; - fn read_enum_struct_variant_field<T, F>(&mut self, - &f_name: &str, - f_idx: usize, - f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - fn read_struct_field<T, F>(&mut self, - f_name: &str, - f_idx: usize, - f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - fn read_tuple<T, F>(&mut self, len: usize, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - fn read_tuple_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - fn read_tuple_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - fn read_tuple_struct_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - // Specialized types: - fn read_option<T, F>(&mut self, f: F) -> Result<T, Self::Error> - where F: FnMut(&mut Self, bool) -> Result<T, Self::Error>; - - fn read_seq<T, F>(&mut self, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self, usize) -> Result<T, Self::Error>; - fn read_seq_elt<T, F>(&mut self, idx: usize, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - fn read_map<T, F>(&mut self, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self, usize) -> Result<T, Self::Error>; - fn read_map_elt_key<T, F>(&mut self, idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - fn read_map_elt_val<T, F>(&mut self, idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error>; - - // Failure - fn error(&mut self, err: &str) -> Self::Error; -} - -pub trait Encodable { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>; -} - -pub trait Decodable: Sized { - fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>; -} - -impl Encodable for usize { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_usize(*self) - } -} - -impl Decodable for usize { - fn decode<D: Decoder>(d: &mut D) -> Result<usize, D::Error> { - d.read_usize() - } -} - -impl Encodable for u8 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_u8(*self) - } -} - -impl Decodable for u8 { - fn decode<D: Decoder>(d: &mut D) -> Result<u8, D::Error> { - d.read_u8() - } -} - -impl Encodable for u16 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_u16(*self) - } -} - -impl Decodable for u16 { - fn decode<D: Decoder>(d: &mut D) -> Result<u16, D::Error> { - d.read_u16() - } -} - -impl Encodable for u32 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_u32(*self) - } -} - -impl Decodable for u32 { - fn decode<D: Decoder>(d: &mut D) -> Result<u32, D::Error> { - d.read_u32() - } -} - -impl Encodable for u64 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_u64(*self) - } -} - -impl Decodable for u64 { - fn decode<D: Decoder>(d: &mut D) -> Result<u64, D::Error> { - d.read_u64() - } -} - -impl Encodable for isize { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_isize(*self) - } -} - -impl Decodable for isize { - fn decode<D: Decoder>(d: &mut D) -> Result<isize, D::Error> { - d.read_isize() - } -} - -impl Encodable for i8 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_i8(*self) - } -} - -impl Decodable for i8 { - fn decode<D: Decoder>(d: &mut D) -> Result<i8, D::Error> { - d.read_i8() - } -} - -impl Encodable for i16 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_i16(*self) - } -} - -impl Decodable for i16 { - fn decode<D: Decoder>(d: &mut D) -> Result<i16, D::Error> { - d.read_i16() - } -} - -impl Encodable for i32 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_i32(*self) - } -} - -impl Decodable for i32 { - fn decode<D: Decoder>(d: &mut D) -> Result<i32, D::Error> { - d.read_i32() - } -} - -impl Encodable for i64 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_i64(*self) - } -} - -impl Decodable for i64 { - fn decode<D: Decoder>(d: &mut D) -> Result<i64, D::Error> { - d.read_i64() - } -} - -impl Encodable for str { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_str(self) - } -} - -impl Encodable for String { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_str(self) - } -} - -impl Decodable for String { - fn decode<D: Decoder>(d: &mut D) -> Result<String, D::Error> { - d.read_str() - } -} - -impl Encodable for f32 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_f32(*self) - } -} - -impl Decodable for f32 { - fn decode<D: Decoder>(d: &mut D) -> Result<f32, D::Error> { - d.read_f32() - } -} - -impl Encodable for f64 { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_f64(*self) - } -} - -impl Decodable for f64 { - fn decode<D: Decoder>(d: &mut D) -> Result<f64, D::Error> { - d.read_f64() - } -} - -impl Encodable for bool { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_bool(*self) - } -} - -impl Decodable for bool { - fn decode<D: Decoder>(d: &mut D) -> Result<bool, D::Error> { - d.read_bool() - } -} - -impl Encodable for char { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_char(*self) - } -} - -impl Decodable for char { - fn decode<D: Decoder>(d: &mut D) -> Result<char, D::Error> { - d.read_char() - } -} - -impl Encodable for () { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_nil() - } -} - -impl Decodable for () { - fn decode<D: Decoder>(d: &mut D) -> Result<(), D::Error> { - d.read_nil() - } -} - -impl<'a, T: ?Sized + Encodable> Encodable for &'a T { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - (**self).encode(s) - } -} - -impl<T: ?Sized + Encodable> Encodable for Box<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - (**self).encode(s) - } -} - -impl< T: Decodable> Decodable for Box<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<Box<T>, D::Error> { - Ok(Box::new(try!(Decodable::decode(d)))) - } -} - -impl< T: Decodable> Decodable for Box<[T]> { - fn decode<D: Decoder>(d: &mut D) -> Result<Box<[T]>, D::Error> { - let v: Vec<T> = try!(Decodable::decode(d)); - Ok(v.into_boxed_slice()) - } -} - -impl<T:Encodable> Encodable for Rc<T> { - #[inline] - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - (**self).encode(s) - } -} - -impl<T:Decodable> Decodable for Rc<T> { - #[inline] - fn decode<D: Decoder>(d: &mut D) -> Result<Rc<T>, D::Error> { - Ok(Rc::new(try!(Decodable::decode(d)))) - } -} - -impl<'a, T:Encodable + ToOwned + ?Sized> Encodable for Cow<'a, T> { - #[inline] - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - (**self).encode(s) - } -} - -impl<'a, T: ?Sized> Decodable for Cow<'a, T> - where T: ToOwned, T::Owned: Decodable -{ - #[inline] - fn decode<D: Decoder>(d: &mut D) -> Result<Cow<'static, T>, D::Error> { - Ok(Cow::Owned(try!(Decodable::decode(d)))) - } -} - -impl<T:Encodable> Encodable for [T] { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for (i, e) in self.iter().enumerate() { - try!(s.emit_seq_elt(i, |s| e.encode(s))) - } - Ok(()) - }) - } -} - -impl<T:Encodable> Encodable for Vec<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for (i, e) in self.iter().enumerate() { - try!(s.emit_seq_elt(i, |s| e.encode(s))) - } - Ok(()) - }) - } -} - -impl<T:Decodable> Decodable for Vec<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<Vec<T>, D::Error> { - d.read_seq(|d, len| { - let mut v = Vec::with_capacity(cap_capacity::<T>(len)); - for i in 0..len { - v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); - } - Ok(v) - }) - } -} - -impl<T:Encodable> Encodable for Option<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_option(|s| { - match *self { - None => s.emit_option_none(), - Some(ref v) => s.emit_option_some(|s| v.encode(s)), - } - }) - } -} - -impl<T:Decodable> Decodable for Option<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<Option<T>, D::Error> { - d.read_option(|d, b| { - if b { - Ok(Some(try!(Decodable::decode(d)))) - } else { - Ok(None) - } - }) - } -} - -impl<T> Encodable for PhantomData<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_nil() - } -} - -impl<T> Decodable for PhantomData<T> { - fn decode<D: Decoder>(_d: &mut D) -> Result<PhantomData<T>, D::Error> { - Ok(PhantomData) - } -} - -macro_rules! peel { - ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* }) -} - -/// Evaluates to the number of identifiers passed to it, for example: -/// `count_idents!(a, b, c) == 3 -macro_rules! count_idents { - () => { 0 }; - ($_i:ident, $($rest:ident,)*) => { 1 + count_idents!($($rest,)*) } -} - -macro_rules! tuple { - () => (); - ( $($name:ident,)+ ) => ( - impl<$($name:Decodable),*> Decodable for ($($name,)*) { - fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)*), D::Error> { - let len: usize = count_idents!($($name,)*); - d.read_tuple(len, |d| { - let mut i = 0; - let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 }, - |d| -> Result<$name,D::Error> { - Decodable::decode(d) - })),)*); - return Ok(ret); - }) - } - } - impl<$($name:Encodable),*> Encodable for ($($name,)*) { - #[allow(non_snake_case)] - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - let ($(ref $name,)*) = *self; - let mut n = 0; - $(let $name = $name; n += 1;)* - s.emit_tuple(n, |s| { - let mut i = 0; - $(try!(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s)));)* - Ok(()) - }) - } - } - peel! { $($name,)* } - ) -} - -tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } - -macro_rules! array { - ($zero:expr) => (); - ($len:expr, $($idx:expr),*) => { - impl<T:Decodable> Decodable for [T; $len] { - fn decode<D: Decoder>(d: &mut D) -> Result<[T; $len], D::Error> { - d.read_seq(|d, len| { - if len != $len { - return Err(d.error("wrong array length")); - } - Ok([$( - try!(d.read_seq_elt($len - $idx - 1, - |d| Decodable::decode(d))) - ),+]) - }) - } - } - - impl<T:Encodable> Encodable for [T; $len] { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq($len, |s| { - for i in 0..$len { - try!(s.emit_seq_elt(i, |s| self[i].encode(s))); - } - Ok(()) - }) - } - } - array! { $($idx),* } - } -} - -array! { - 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 -} - -impl Encodable for path::Path { - #[cfg(unix)] - fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { - use std::os::unix::prelude::*; - self.as_os_str().as_bytes().encode(e) - } - #[cfg(windows)] - fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { - use std::os::windows::prelude::*; - let v = self.as_os_str().encode_wide().collect::<Vec<_>>(); - v.encode(e) - } -} - -impl Encodable for path::PathBuf { - fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { - (**self).encode(e) - } -} - -impl Decodable for path::PathBuf { - #[cfg(unix)] - fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> { - use std::os::unix::prelude::*; - let bytes: Vec<u8> = try!(Decodable::decode(d)); - let s: OsString = OsStringExt::from_vec(bytes); - let mut p = path::PathBuf::new(); - p.push(s); - Ok(p) - } - #[cfg(windows)] - fn decode<D: Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> { - use std::os::windows::prelude::*; - let bytes: Vec<u16> = try!(Decodable::decode(d)); - let s: OsString = OsStringExt::from_wide(&bytes); - let mut p = path::PathBuf::new(); - p.push(s); - Ok(p) - } -} - -impl<T: Encodable + Copy> Encodable for Cell<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - self.get().encode(s) - } -} - -impl<T: Decodable + Copy> Decodable for Cell<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<Cell<T>, D::Error> { - Ok(Cell::new(try!(Decodable::decode(d)))) - } -} - -// FIXME: #15036 -// Should use `try_borrow`, returning a -// `encoder.error("attempting to Encode borrowed RefCell")` -// from `encode` when `try_borrow` returns `None`. - -impl<T: Encodable> Encodable for RefCell<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - self.borrow().encode(s) - } -} - -impl<T: Decodable> Decodable for RefCell<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<RefCell<T>, D::Error> { - Ok(RefCell::new(try!(Decodable::decode(d)))) - } -} - -impl<T:Encodable> Encodable for Arc<T> { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - (**self).encode(s) - } -} - -impl<T:Decodable+Send+Sync> Decodable for Arc<T> { - fn decode<D: Decoder>(d: &mut D) -> Result<Arc<T>, D::Error> { - Ok(Arc::new(try!(Decodable::decode(d)))) - } -} - -// ___________________________________________________________________________ -// Helper routines - -pub trait EncoderHelpers: Encoder { - fn emit_from_vec<T, F>(&mut self, v: &[T], f: F) - -> Result<(), <Self as Encoder>::Error> - where F: FnMut(&mut Self, &T) -> Result<(), <Self as Encoder>::Error>; -} - -impl<S:Encoder> EncoderHelpers for S { - fn emit_from_vec<T, F>(&mut self, v: &[T], mut f: F) -> Result<(), S::Error> where - F: FnMut(&mut S, &T) -> Result<(), S::Error>, - { - self.emit_seq(v.len(), |this| { - for (i, e) in v.iter().enumerate() { - try!(this.emit_seq_elt(i, |this| { - f(this, e) - })); - } - Ok(()) - }) - } -} - -pub trait DecoderHelpers: Decoder { - fn read_to_vec<T, F>(&mut self, f: F) - -> Result<Vec<T>, <Self as Decoder>::Error> where - F: FnMut(&mut Self) -> Result<T, <Self as Decoder>::Error>; -} - -impl<D: Decoder> DecoderHelpers for D { - fn read_to_vec<T, F>(&mut self, mut f: F) -> Result<Vec<T>, D::Error> where F: - FnMut(&mut D) -> Result<T, D::Error>, - { - self.read_seq(|this, len| { - let mut v = Vec::with_capacity(cap_capacity::<T>(len)); - for i in 0..len { - v.push(try!(this.read_seq_elt(i, |this| f(this)))); - } - Ok(v) - }) - } -} - -#[test] -#[allow(unused_variables)] -fn capacity_rules() { - use std::usize::MAX; - use std::collections::{HashMap, HashSet}; - - struct MyDecoder; - impl Decoder for MyDecoder { - type Error = (); - - // Primitive types: - fn read_nil(&mut self) -> Result<(), Self::Error> { Err(()) } - fn read_usize(&mut self) -> Result<usize, Self::Error> { Err(()) } - fn read_u64(&mut self) -> Result<u64, Self::Error> { Err(()) } - fn read_u32(&mut self) -> Result<u32, Self::Error> { Err(()) } - fn read_u16(&mut self) -> Result<u16, Self::Error> { Err(()) } - fn read_u8(&mut self) -> Result<u8, Self::Error> { Err(()) } - fn read_isize(&mut self) -> Result<isize, Self::Error> { Err(()) } - fn read_i64(&mut self) -> Result<i64, Self::Error> { Err(()) } - fn read_i32(&mut self) -> Result<i32, Self::Error> { Err(()) } - fn read_i16(&mut self) -> Result<i16, Self::Error> { Err(()) } - fn read_i8(&mut self) -> Result<i8, Self::Error> { Err(()) } - fn read_bool(&mut self) -> Result<bool, Self::Error> { Err(()) } - fn read_f64(&mut self) -> Result<f64, Self::Error> { Err(()) } - fn read_f32(&mut self) -> Result<f32, Self::Error> { Err(()) } - fn read_char(&mut self) -> Result<char, Self::Error> { Err(()) } - fn read_str(&mut self) -> Result<String, Self::Error> { Err(()) } - - // Compound types: - fn read_enum<T, F>(&mut self, name: &str, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) - -> Result<T, Self::Error> - where F: FnMut(&mut Self, usize) -> Result<T, Self::Error> { Err(()) } - fn read_enum_variant_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) - -> Result<T, Self::Error> - where F: FnMut(&mut Self, usize) -> Result<T, Self::Error> { Err(()) } - fn read_enum_struct_variant_field<T, F>(&mut self, - f_name: &str, - f_idx: usize, - f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - fn read_struct_field<T, F>(&mut self, - f_name: &str, - f_idx: usize, - f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - fn read_tuple<T, F>(&mut self, len: usize, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - fn read_tuple_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - fn read_tuple_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - fn read_tuple_struct_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - // Specialized types: - fn read_option<T, F>(&mut self, f: F) -> Result<T, Self::Error> - where F: FnMut(&mut Self, bool) -> Result<T, Self::Error> { Err(()) } - - fn read_seq<T, F>(&mut self, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self, usize) -> Result<T, Self::Error> { - f(self, MAX) - } - fn read_seq_elt<T, F>(&mut self, idx: usize, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - fn read_map<T, F>(&mut self, f: F) -> Result<T, Self::Error> - where F: FnOnce(&mut Self, usize) -> Result<T, Self::Error> { - f(self, MAX) - } - fn read_map_elt_key<T, F>(&mut self, idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - fn read_map_elt_val<T, F>(&mut self, idx: usize, f: F) - -> Result<T, Self::Error> - where F: FnOnce(&mut Self) -> Result<T, Self::Error> { Err(()) } - - // Failure - fn error(&mut self, err: &str) -> Self::Error { () } - } - - let mut dummy = MyDecoder; - let vec_result: Result<Vec<u8>, ()> = Decodable::decode(&mut dummy); - assert!(vec_result.is_err()); - - let map_result: Result<HashMap<u8, u8>, ()> = Decodable::decode(&mut dummy); - assert!(map_result.is_err()); - - let set_result: Result<HashSet<u8>, ()> = Decodable::decode(&mut dummy); - assert!(set_result.is_err()); -} diff --git a/src/vendor/toml/.cargo-checksum.json b/src/vendor/toml/.cargo-checksum.json deleted file mode 100644 index 582aacf1cb9..00000000000 --- a/src/vendor/toml/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805",".travis.yml":"7d917e42244b1d0d0304a11e8ef45bbc34e2a859bf35a752ed6069920a7cc8c5","Cargo.toml":"e423de5a2491283f1f5481a47f16b8b94b442586a0174ab9bc6828d9eade00ef","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"7102611d4c8d3e6f7701b3d4d7658db99b63e46187499bdb559ca6c985bd8bc2","examples/toml2json.rs":"d1980e1d53e712ea6f9d6b3a36ce156b075bf8c1dd7660c2947e7b81106ea41c","src/decoder/mod.rs":"b0267de2b40597eb60e6fb2cd0686bc7f8acf99892274a580eb4c71c2578661b","src/decoder/rustc_serialize.rs":"285bce51f45385c3580c5f3b43a7853275164d95cadfd7c9e806e5b3a57f9f9b","src/decoder/serde.rs":"706bde155d007e43f0728d20da568e78cec8ce44788d47d0a9fd34c27bbcbdcd","src/display.rs":"f4bcfc92aee2d10ae9c9e84e2692aa117d73dc7cbc18606169ba65f148855ab7","src/encoder/mod.rs":"9b3973b567dd29e1fc675140fa6585fb23e6561226ea84a308762086a94316f4","src/encoder/rustc_serialize.rs":"b814e47d4afefbd1a920a35427ab64139dd9b4e02f526f51fc411669554c455f","src/encoder/serde.rs":"7ea349f7e01158e42e555f709baa8e558338a79b11f631b1d39572058244a20f","src/lib.rs":"2509358430471408321f2469d6ca7517f9a2b34b43392a4958fbed0105cf8cac","src/parser.rs":"4d4bdac86b865c46029f40d03b7373c957d1073abc2c0010a1d34667d123bbe2","tests/README.md":"3e7d07d64c34e117c3d862ee12e4947af8c133fb0b53f6f0de43cc3bfa5057b8","tests/invalid-encoder/array-mixed-types-ints-and-floats.json":"206d2a353153efbcee74e7ee7b0f852e7a948cfb88417f74607b3ad6f020e373","tests/invalid.rs":"ef9b613246634673e43f95b8688f275d22726f41fb9ecb824504217e6f5d5c58","tests/invalid/array-mixed-types-arrays-and-ints.toml":"c1547b686357c7a865e333a7ce7eed1e30743ebc4daac8ea6148bdd84b7e4dc7","tests/invalid/array-mixed-types-ints-and-floats.toml":"baa235fc168869716680955fd5bdafab30b6fa9b3d09185086261a56ef12960e","tests/invalid/array-mixed-types-strings-and-ints.toml":"4440057ed90d4461db0be55cfd71299cad96b601d5faec2140666242f6fde147","tests/invalid/datetime-malformed-no-leads.toml":"1fa6bf72ea0b96be835ac031408f7acfd0b8d18d5f54b4c0fce8136aad27d22e","tests/invalid/datetime-malformed-no-secs.toml":"b9c30b7fa1847c80e381d68cc79834eefbb8813cd0eff465fb7cbe0733df429b","tests/invalid/datetime-malformed-no-t.toml":"490a46d2e707ef4f87987ec12a22afa5a71c97c5eaa0f4201a174c47846c6a4a","tests/invalid/datetime-malformed-no-z.toml":"6ca48b84c444b3ca51a480aa9688dd1044861010aff674a67e5cec34fd2eb489","tests/invalid/datetime-malformed-with-milli.toml":"62bfd0a6645bcb3f78211523e5673a3d1fa726d9e942c1643df243d6fba474c8","tests/invalid/duplicate-key-table.toml":"a896ea2180d16fcdd4f6c30aa27529b5b29e7e195a4e7a9944343028783602e9","tests/invalid/duplicate-keys.toml":"4bb0a65c22e7704893a2a51334eb2518af702850ef59aeecd5226e7b26bc07ec","tests/invalid/duplicate-tables.toml":"23b16ce26e1155ee6bf1fff559701dce86475c6a2878536b61f6b7e68be340de","tests/invalid/empty-implicit-table.toml":"d6026110dc0dee7babd69592218819328caa425f48cc879e895b29e48550c06c","tests/invalid/empty-table.toml":"37517e5f3dc66819f61f5a7bb8ace1921282415f10551d2defa5c3eb0985b570","tests/invalid/float-no-leading-zero.toml":"159654461094c938574ba2d2d09baa3d3c387dd6ed024fd411530c0573a1ec42","tests/invalid/float-no-trailing-digits.toml":"64e4f336186cd096be2804532dbd694dd50ea551d292a9cdbf0bef2abf227101","tests/invalid/key-after-array.toml":"314af33770170b53bf2ec3be43ea1609d981c81d62c968052499b85ed54ccce8","tests/invalid/key-after-table.toml":"ed0dcf38f003d184dd18d1518702da0115cbfb05a5a28cbcf42de2f9bdee05fa","tests/invalid/key-empty.toml":"4303477abf4c0b920b42e96edd61caecf9c1f2d5d97f56af876854cd725aff3c","tests/invalid/key-hash.toml":"cd2a2eba6032d32c829633d3cd2778aeba81f5ff554e69f62af6557d1dc712f6","tests/invalid/key-newline.toml":"06a313a6bd70c2db6a1f5bda479d854d8f87e037e3cabf18fb5db822466ffcac","tests/invalid/key-open-bracket.toml":"52dea939022949290e3a19f1291d15605429344dce3cd1aa1f1568ecad8ca365","tests/invalid/key-single-open-bracket.toml":"245843abef9e72e7efac30138a994bf6301e7e1d7d7042a33d42e863d2638811","tests/invalid/key-space.toml":"b4e336d07c27fb3d0f0a6e50b733e1546202dfd58aaf2f7956f56fd6f075b0a1","tests/invalid/key-start-bracket.toml":"3bd3748a9df1d25ab2661330a3da187bd4da3958292bbf0e8b59d7963634dd87","tests/invalid/key-two-equals.toml":"3ac0c4e339d47c86e57564e43147b772ae83933b78083dc78d0ef77e231df3f1","tests/invalid/string-bad-byte-escape.toml":"c665dcec7c02f442c4fdc80423698eed2376ce65779cf855371772293bec2927","tests/invalid/string-bad-escape.toml":"eeca691fbba3d270f58ae2953d2d1369a773e619e39d8c11f38d6bf6f8472e82","tests/invalid/string-byte-escapes.toml":"4a4604b32971de3a252cd01d2997b450972c3ec9030cf22a070d49c57f050da4","tests/invalid/string-no-close.toml":"bb2eaf96eb9f83a52bd0772abb313060a06b94f650efeb45edce774622686882","tests/invalid/table-array-implicit.toml":"9b841ea64d68be4deb54f67fc807b05fd235452ee563ffa7de69dbca64b2f7dd","tests/invalid/table-array-malformed-bracket.toml":"164f641b2628bf04f8202d9746a360a4a243faca1408dc2ecd0c0fdd2d1c2c27","tests/invalid/table-array-malformed-empty.toml":"56ca2a15019cf5c3555041a191f983dc72b1678f0de0afd1a7b8f46ed7970420","tests/invalid/table-empty.toml":"37517e5f3dc66819f61f5a7bb8ace1921282415f10551d2defa5c3eb0985b570","tests/invalid/table-nested-brackets-close.toml":"991e1210f81e24abcd735988f0d960d4ee94d2ec3b133c6fea6e24932d91c507","tests/invalid/table-nested-brackets-open.toml":"8fb569fc90fa606ae94708ee2bf205bff8db8a023624b3e52ef6b2c1a98ba1c6","tests/invalid/table-whitespace.toml":"2c2db1259adc641df0459e896d349d3db60965d5368d5c8ed50aedd3bc88f040","tests/invalid/table-with-pound.toml":"d8070437f07bd115ac8006c61e286401bd3be88728a62264796e757121750ecd","tests/invalid/text-after-array-entries.toml":"2530cace13292313983b90b01d63e4b8ac484809e7ef0ac79904923573eda7ec","tests/invalid/text-after-integer.toml":"6168ed823a135b8914956b04307aeec2347b10eb1aa79008406d7b547cbde682","tests/invalid/text-after-string.toml":"1771987dd679e1cc181cf53406ba313fdc3413a081d17a93da6041bf6ccccf5e","tests/invalid/text-after-table.toml":"f27ae56bb0b42d3af4c813392857afdfeb4bf8ab77ff896cd93ba32cf1a21b26","tests/invalid/text-before-array-separator.toml":"192d28699573abbdc521797576d4885adf756336c3e76971f10270603c957464","tests/invalid/text-in-array.toml":"50d7b16d7a03d470f1a907eebfeb156d0c696e6f9a8c734a5e4caa2365f54654","tests/valid.rs":"d2199e449a1f6b5aab1914f7b739ae0f496657ca249aa3b9bcdd85b89075e4e4","tests/valid/array-empty.json":"4ed46e8aa3586a7ddd9097cda38919699860052f188880de18e12d4acbee5307","tests/valid/array-empty.toml":"769faa42a690b02ad1b573277f0d793a4a38a7ecf30b9db67bf9836fe2b7778c","tests/valid/array-nospaces.json":"7c82b474797871488c2b522e9b852772a78c681a86900f780f7a0be4f901e1ec","tests/valid/array-nospaces.toml":"01fba63551b1051f7e117c9551c488b293bd3cd4745cbeec6b3709c32f2a3a64","tests/valid/arrays-hetergeneous.json":"dac4702412c90d5ddd6b898c3657c71d782d0aca46e5b9ca19cc694d3e226c0f","tests/valid/arrays-hetergeneous.toml":"361ae2e8470b47b12b336eb61eedd09abb20e216fbeb582b46d16a2831adda4d","tests/valid/arrays-nested.json":"34d6f8fd770f0728f38dbf0d686bed2c218bc16da978290c0208d3bf3704bdec","tests/valid/arrays-nested.toml":"a5941a01a2ba2fa179a3885039a5f81ca6c9876b2e8bea7b880563238be9f004","tests/valid/arrays.json":"315fff195a7d4c80e867e1f14c12a23e36dcc666e8de36138249b15e99bdd4dd","tests/valid/arrays.toml":"2d3c91b77d4f6a65a6a5a2c5ad521dbe86cc2f0ff389dfe58e8c34275cdc35c7","tests/valid/bool.json":"bb608b912fe4d89cb2186da957c10951780575bb34b2f43305335c745eff049c","tests/valid/bool.toml":"3c06ad4dce7430326f5f867105b2e9382def90cccb3ecb69f657c0b88974ab04","tests/valid/comments-everywhere.json":"800f8efd86d1bab4f91f0e367da52a2465e1480387df892561ed8948fd1a38c3","tests/valid/comments-everywhere.toml":"8636108c34f50d45244b142d342234b7535e01fba2db2d2ffed3430223009cea","tests/valid/datetime.json":"94f130c3b2a5f30c625a3a3168b9dfe52aa109b470c4e077f352b3dd79382a69","tests/valid/datetime.toml":"4e1b71ba31a1feef80a1e436225aa9c5d291bf780f558e7cfa76998fe2a29e08","tests/valid/empty.json":"ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356","tests/valid/empty.toml":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tests/valid/example-bom.toml":"50f3607be97de2f894ccd41a29d3a8a1b1f430982e5ab5bf43047874837f6a42","tests/valid/example-v0.3.0.json":"ec02332eb59dab93a50560771e4b01b972a29d93b6dca8954728c0631e1799a0","tests/valid/example-v0.3.0.toml":"aba9349588c1ba6af2a3ad0c1db2c3d311dca66b64f654480340a0823dfd4546","tests/valid/example-v0.4.0.json":"8b967b246ca2383172eaaecf790b2115a18020f63c70d0848d1dc25fc1fed5a9","tests/valid/example-v0.4.0.toml":"47ee4c4cd83637cd09aca6518f88c8ed56acc2b3022e5ea53d9121e5d35335ed","tests/valid/example.json":"c57fabb1be0ae7ed140fe7ae5082051571c85180204b8ae8d8da1e86133278c9","tests/valid/example.toml":"6f02b2a52ea63c70b629e41e06a8eb1eb4aab359ab966a7a397b248e13849c9c","tests/valid/example2.json":"de89432e78f0a074aae54650fedf151ceca3b0ccb148b8a66e18e2ed68024ba2","tests/valid/example2.toml":"c389eeb485fb7cb9445d617a9a0f8ba70049f08d66cf6b6f2a9a986574295de1","tests/valid/float.json":"9676c13fef00a01bc729456bfe27f1b24a1bd059c9a5913bb0b0401e976a0aab","tests/valid/float.toml":"b6784f554aa38bb210f0905c3bafdfae6db723a4f53288fb07febc66451bbc2d","tests/valid/hard_example.json":"8d170e73e156b8b6be559246880e9cb6a79b36f63d14bc97e3bdf2f2091e7a17","tests/valid/hard_example.toml":"cd3b89f8917a44f944b12fe47f69f86bb39f17db85d1a081bf0c134831eb90f9","tests/valid/implicit-and-explicit-after.json":"6dcaeaf8ee3479bf2cd5c14eb58970757175aaefab014bce9acb0b85e7bf9dd0","tests/valid/implicit-and-explicit-after.toml":"0599b16822764cdb1c3d3cf53f71186b97afc9f60f8d58358a4a89fe4d9477c3","tests/valid/implicit-and-explicit-before.json":"6dcaeaf8ee3479bf2cd5c14eb58970757175aaefab014bce9acb0b85e7bf9dd0","tests/valid/implicit-and-explicit-before.toml":"33435dddb68144b652ca5f5e0c4c53e4f7b3ca0166f9b944eda55f8d76ed2871","tests/valid/implicit-groups.json":"fc2bb43ec20c8c9148c8a70490b3a054506932c41687222ea11faae47eafb723","tests/valid/implicit-groups.toml":"248b3e8272ec43ce4af872981acde10628eeae73537ed6763a1f4245f5a9610c","tests/valid/integer.json":"0fc2d0cb1fb46d7805c1007b1fa4c46a65b273e56ae9d751df686e81d3a3354f","tests/valid/integer.toml":"74b964eb9561be6aa7266f6034cee1cd0657bdab8043a5ec9da33d9b184345da","tests/valid/key-equals-nospace.json":"b9878ee3585d1b48710a4bc09f2163b910ea71a2bfdaa8f1da68e599e8b30f47","tests/valid/key-equals-nospace.toml":"24cab0d01b67b184d0a737de3a5b5d47b8b69b36203273296d5ef763f7fdcf68","tests/valid/key-space.json":"30be539b01420be5cedc9078b88c3279bbef7c0bdde36ba8249ed8906112d5c7","tests/valid/key-space.toml":"9e9459b8cfebc404cf93d77c2d4082cadcd57165a2f9ce9cb35d1d12dc94a8c0","tests/valid/key-special-chars.json":"8bbebb20660d93efa73707bdb09e87a43c2b31c18f13df6388c701a1bc7cab8c","tests/valid/key-special-chars.toml":"c6cb0ba12d32f03cda4206097a1edb27cd154215d72e1c5791cc4f8dff2270b3","tests/valid/key-with-pound.json":"ea4dd79d0ad2a824bcce5c4c194d7fae82a7584a2ab7c0d83d6ddaae6130973e","tests/valid/key-with-pound.toml":"c334f676e19c01b96111277248654358cc8222fd0639aecaf429407e63b6a2dc","tests/valid/long-float.json":"7e103f56e490aa1b1fe5a762000ceb1f8c599f7d81aa215c90f5da41ab4ba6db","tests/valid/long-float.toml":"4d23f706f2a0d241840f6ea78657820c9c7b904c0c3c16828f8cc2574d7c8761","tests/valid/long-integer.json":"9ed7976639f0c2cd7f112584e2f5d272e92569be7135ea5bb9ba597abaff0767","tests/valid/long-integer.toml":"309f94be7ff5fd6f6dedbd257a1e6c171cb71aa74409ff3f8babda951f89d687","tests/valid/multiline-string.json":"3d67a8b992b85e9a2e58b77a1b76dc29745a9c2b4a362ad517786fed541948d7","tests/valid/multiline-string.toml":"7d6650009eb31a03d5b40b20712ef0157e9b787d9c966e66c38873a34e3b861c","tests/valid/raw-multiline-string.json":"4c95e34497433168cac25eb4132485c3bd13c35cad9d13d7becf7f90469dacca","tests/valid/raw-multiline-string.toml":"c724151024ccde432e0ec0d4ba60a5320d77841008116324c39516b8cbb94f4d","tests/valid/raw-string.json":"19268797aff8dfa28437d6ed8f9d813035f6eee50aade5fc774ba12b3290216b","tests/valid/raw-string.toml":"16510e05d477a0856ebaf38cacd0e9e18f02ab63ac7bd1a2eabbaa47a54d0e49","tests/valid/string-empty.json":"ece7d01326742a46e37d6404175118c0a91a2494f7ba2290bbc1d6f990ddb65b","tests/valid/string-empty.toml":"251e9e4052ede79f6b2462e71f73e0b7c9f5927484f6f77f0cd8b3c839b0c13b","tests/valid/string-escapes.json":"3d516f03cf94d5b5ee6b0887b8d37fdf21152752f049f5922a24adaacb5b8c35","tests/valid/string-escapes.toml":"86b1569e10fec91301709ad747012f0f42395050a2343b42aca450e001120f7a","tests/valid/string-simple.json":"622676e347676cce9f9733210acbd8056ce77a0588772ffd6efb05bb4e81b571","tests/valid/string-simple.toml":"ae74db09acea3be2ccae7f854f7b6f7c874ace9d4d87bf2f437b059a7d38a464","tests/valid/string-with-pound.json":"458a0add71536c1df5e1ed3ee5483c6eb48578abce0b0ebcdf75ea20d41ed6f4","tests/valid/string-with-pound.toml":"1aee397830d9ad2a93d41ee9c435acdbfef3758d1bb7c48bca7424fbbec89466","tests/valid/table-array-implicit.json":"3f7d3cdb468de67bc183162805d9c753ef5772f6f363ac2a26598387a5d991ea","tests/valid/table-array-implicit.toml":"66bcb030899a95e9a25ec44b7c9291b02f80ecbc324061cf1cd93223a2919f21","tests/valid/table-array-many.json":"3f21243eeb71ca3e5657a43559c806e12e3833e9f74c43c0c12aad9b0c853e4c","tests/valid/table-array-many.toml":"8d8ea546f954a81ca149a02147ae5f4bf075151cfcd530e62dcf05a04d843ffb","tests/valid/table-array-nest.json":"0a987d2bf1d5bc85f5c9433f23d389063600682a68538b6e57938a3c572959e4","tests/valid/table-array-nest.toml":"71b9c753bf773f232ac71cb2469a54ee0110ff137829045421edd7c5a64d6b6a","tests/valid/table-array-one.json":"7dc0ea3f7f843f7dc7443e68af43a1e5130a5fbae8a27fb02d8d92fa2487888e","tests/valid/table-array-one.toml":"4c478aea2dd7dfcfda682503b49e610f0fa4ce85a3b3cd0bc9041d4959e3626a","tests/valid/table-empty.json":"11e43e212d87b3b2547a5f2541f4091a3d2f6ba00b2a2004b07e02734e927ea7","tests/valid/table-empty.toml":"24d4941e67d5965d270eaebdb9816b994311e0f2f0e79ef6bb626f362c52842e","tests/valid/table-sub-empty.json":"85cca6d48a5993c4f207c21ed96652af4f50b6936b0807659c75317c1763b6db","tests/valid/table-sub-empty.toml":"ae92e90a806ffefcbf8cda83cb82acf7448f75efa50dcfb5e2384632d36471b3","tests/valid/table-whitespace.json":"ad84ac49a6d13f7c4a8af0e1e71fd7ff2a446aa16a34c21a809a0850dfa76e73","tests/valid/table-whitespace.toml":"2f15dafb263d2771671db299f6202b4b78d293aec1ded7641ec7eb1cb024b52c","tests/valid/table-with-pound.json":"151e76606efe77500cbb0aa8fcf8ccfadb124d533bb79a9caa62e937b826e676","tests/valid/table-with-pound.toml":"a1f86c2e3789cc89500ec1d5eac2ec0bdb94bf445fddc3cab558b5228f3aba56","tests/valid/unicode-escape.json":"ebbf81930fa92ea5822bb1ed808b798731abe5c97e64f6471e1e86878d79037c","tests/valid/unicode-escape.toml":"aa26e55e5526a0d00ad68eca774d5c43cbcdf24ae753e0219bf3ab31b9e628b8","tests/valid/unicode-literal.json":"1dd42756384b954955815dc3e906db64b4cd2c0c094f9b3c86633d1652d6d79d","tests/valid/unicode-literal.toml":"bffc6c3d4757de31d0cbfd7b8dc591edd2910fe8a4e1c46bbee422dddc841003"},"package":"0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796"} \ No newline at end of file diff --git a/src/vendor/toml/.cargo-ok b/src/vendor/toml/.cargo-ok deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/toml/.cargo-ok +++ /dev/null diff --git a/src/vendor/toml/.gitignore b/src/vendor/toml/.gitignore deleted file mode 100644 index a9d37c560c6..00000000000 --- a/src/vendor/toml/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -Cargo.lock diff --git a/src/vendor/toml/.travis.yml b/src/vendor/toml/.travis.yml deleted file mode 100644 index cf28e867d3e..00000000000 --- a/src/vendor/toml/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -sudo: false -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH -script: - - cargo build --verbose - - cargo build --verbose --no-default-features - - cargo build --verbose --features serde --no-default-features - - cargo test --verbose --features serde - - cargo test --verbose --manifest-path serde-tests/Cargo.toml - - rustdoc --test README.md -L target - - cargo doc --no-deps -after_success: - - travis-cargo --only nightly doc-upload - - travis-cargo coveralls --no-sudo -env: - global: - secure: LZMkQQJT5LqLQQ8JyakjvHNqqMPy8lm/SyC+H5cKUVI/xk7xRuti4eKY937N8uSmbff2m9ZYlG6cNwIOfk/nWn8YsqxA8Wg/xugubWzqGuqu+NQ4IZVa7INT2Fiqyk5SPCh8B5fo2x7OBJ24SCkWb2p8bEWAuW8XdZZOdmi3H2I= -notifications: - email: - on_success: never -addons: - apt: - packages: - - libcurl4-openssl-dev - - libelf-dev - - libdw-dev diff --git a/src/vendor/toml/Cargo.toml b/src/vendor/toml/Cargo.toml deleted file mode 100644 index f1807317310..00000000000 --- a/src/vendor/toml/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] - -name = "toml" -version = "0.1.30" -authors = ["Alex Crichton <alex@alexcrichton.com>"] -license = "MIT/Apache-2.0" -readme = "README.md" -keywords = ["encoding"] -repository = "https://github.com/alexcrichton/toml-rs" -homepage = "https://github.com/alexcrichton/toml-rs" -documentation = "http://alexcrichton.com/toml-rs" -description = """ -A native Rust encoder and decoder of TOML-formatted files and streams. Provides -implementations of the standard Encodable/Decodable traits for TOML data to -facilitate deserializing and serializing Rust structures. -""" - -[dependencies] -rustc-serialize = { optional = true, version = "0.3.0" } -serde = { optional = true, version = "0.7" } - -[features] -default = ["rustc-serialize"] - -[dev-dependencies] -rustc-serialize = "0.3" diff --git a/src/vendor/toml/LICENSE-APACHE b/src/vendor/toml/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/src/vendor/toml/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/src/vendor/toml/LICENSE-MIT b/src/vendor/toml/LICENSE-MIT deleted file mode 100644 index 39e0ed66021..00000000000 --- a/src/vendor/toml/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/src/vendor/toml/README.md b/src/vendor/toml/README.md deleted file mode 100644 index 69334981f03..00000000000 --- a/src/vendor/toml/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# toml-rs - -[](https://travis-ci.org/alexcrichton/toml-rs) -[](https://coveralls.io/github/alexcrichton/toml-rs?branch=master) - -[Documentation](http://alexcrichton.com/toml-rs) - -A [TOML][toml] decoder and encoder for Rust. This library is currently compliant with -the v0.4.0 version of TOML. This library will also likely continue to stay up to -date with the TOML specification as changes happen. - -[toml]: https://github.com/toml-lang/toml - -```toml -# Cargo.toml -[dependencies] -toml = "0.1" -``` - -# License - -`toml-rs` is primarily distributed under the terms of both the MIT license and -the Apache License (Version 2.0), with portions covered by various BSD-like -licenses. - -See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/src/vendor/toml/examples/toml2json.rs b/src/vendor/toml/examples/toml2json.rs deleted file mode 100644 index 0d406804a38..00000000000 --- a/src/vendor/toml/examples/toml2json.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![deny(warnings)] - -extern crate toml; -extern crate rustc_serialize; - -use std::fs::File; -use std::env; -use std::io; -use std::io::prelude::*; - -use toml::Value; -use rustc_serialize::json::Json; - -fn main() { - let mut args = env::args(); - let mut input = String::new(); - let filename = if args.len() > 1 { - let name = args.nth(1).unwrap(); - File::open(&name).and_then(|mut f| { - f.read_to_string(&mut input) - }).unwrap(); - name - } else { - io::stdin().read_to_string(&mut input).unwrap(); - "<stdin>".to_string() - }; - - let mut parser = toml::Parser::new(&input); - let toml = match parser.parse() { - Some(toml) => toml, - None => { - for err in &parser.errors { - let (loline, locol) = parser.to_linecol(err.lo); - let (hiline, hicol) = parser.to_linecol(err.hi); - println!("{}:{}:{}-{}:{} error: {}", - filename, loline, locol, hiline, hicol, err.desc); - } - return - } - }; - let json = convert(Value::Table(toml)); - println!("{}", json.pretty()); -} - -fn convert(toml: Value) -> Json { - match toml { - Value::String(s) => Json::String(s), - Value::Integer(i) => Json::I64(i), - Value::Float(f) => Json::F64(f), - Value::Boolean(b) => Json::Boolean(b), - Value::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()), - Value::Table(table) => Json::Object(table.into_iter().map(|(k, v)| { - (k, convert(v)) - }).collect()), - Value::Datetime(dt) => Json::String(dt), - } -} diff --git a/src/vendor/toml/src/decoder/mod.rs b/src/vendor/toml/src/decoder/mod.rs deleted file mode 100644 index a59628038ab..00000000000 --- a/src/vendor/toml/src/decoder/mod.rs +++ /dev/null @@ -1,235 +0,0 @@ -use std::error; -use std::fmt; -use std::collections::{btree_map, BTreeMap}; -use std::iter::Peekable; - -use Value; -use self::DecodeErrorKind::*; - -#[cfg(feature = "rustc-serialize")] mod rustc_serialize; -#[cfg(feature = "serde")] mod serde; - -/// A structure to transform TOML values into Rust values. -/// -/// This decoder implements the serialization `Decoder` interface, allowing -/// `Decodable` types to be generated by this decoder. The input is any -/// arbitrary TOML value. -pub struct Decoder { - /// The TOML value left over after decoding. This can be used to inspect - /// whether fields were decoded or not. - pub toml: Option<Value>, - cur_field: Option<String>, - cur_map: Peekable<btree_map::IntoIter<String, Value>>, - leftover_map: ::Table, -} - -/// Description for errors which can occur while decoding a type. -#[derive(PartialEq, Debug)] -pub struct DecodeError { - /// Field that this error applies to. - pub field: Option<String>, - /// The type of error which occurred while decoding, - pub kind: DecodeErrorKind, -} - -/// Enumeration of possible errors which can occur while decoding a structure. -#[derive(PartialEq, Debug)] -pub enum DecodeErrorKind { - /// An error flagged by the application, e.g. value out of range - ApplicationError(String), - /// A field was expected, but none was found. - ExpectedField(/* type */ Option<&'static str>), - /// A field was found, but it was not an expected one. - UnknownField, - /// A field was found, but it had the wrong type. - ExpectedType(/* expected */ &'static str, /* found */ &'static str), - /// The nth map key was expected, but none was found. - ExpectedMapKey(usize), - /// The nth map element was expected, but none was found. - ExpectedMapElement(usize), - /// An enum decoding was requested, but no variants were supplied - NoEnumVariants, - /// The unit type was being decoded, but a non-zero length string was found - NilTooLong, - /// There was an error with the syntactical structure of the TOML. - SyntaxError, - /// A custom error was generated when decoding. - CustomError(String), - /// The end of the TOML input was reached too soon - EndOfStream, - /// Produced by serde ... - InvalidType(&'static str), -} - -/// Decodes a TOML value into a decodable type. -/// -/// This function will consume the given TOML value and attempt to decode it -/// into the type specified. If decoding fails, `None` will be returned. If a -/// finer-grained error is desired, then it is recommended to use `Decodable` -/// directly. -#[cfg(feature = "rustc-serialize")] -pub fn decode<T: ::rustc_serialize::Decodable>(toml: Value) -> Option<T> { - ::rustc_serialize::Decodable::decode(&mut Decoder::new(toml)).ok() -} - -/// Decodes a TOML value into a decodable type. -/// -/// This function will consume the given TOML value and attempt to decode it -/// into the type specified. If decoding fails, `None` will be returned. If a -/// finer-grained error is desired, then it is recommended to use `Decodable` -/// directly. -#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] -pub fn decode<T: ::serde::Deserialize>(toml: Value) -> Option<T> { - ::serde::Deserialize::deserialize(&mut Decoder::new(toml)).ok() -} - -/// Decodes a string into a toml-encoded value. -/// -/// This function will parse the given string into a TOML value, and then parse -/// the TOML value into the desired type. If any error occurs, `None` is -/// returned. -/// -/// If more fine-grained errors are desired, these steps should be driven -/// manually. -#[cfg(feature = "rustc-serialize")] -pub fn decode_str<T: ::rustc_serialize::Decodable>(s: &str) -> Option<T> { - ::Parser::new(s).parse().and_then(|t| decode(Value::Table(t))) -} - -/// Decodes a string into a toml-encoded value. -/// -/// This function will parse the given string into a TOML value, and then parse -/// the TOML value into the desired type. If any error occurs, `None` is -/// returned. -/// -/// If more fine-grained errors are desired, these steps should be driven -/// manually. -#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] -pub fn decode_str<T: ::serde::Deserialize>(s: &str) -> Option<T> { - ::Parser::new(s).parse().and_then(|t| decode(Value::Table(t))) -} - -impl Decoder { - /// Creates a new decoder, consuming the TOML value to decode. - /// - /// This decoder can be passed to the `Decodable` methods or driven - /// manually. - pub fn new(toml: Value) -> Decoder { - Decoder { - toml: Some(toml), - cur_field: None, - leftover_map: BTreeMap::new(), - cur_map: BTreeMap::new().into_iter().peekable(), - } - } - - fn sub_decoder(&self, toml: Option<Value>, field: &str) -> Decoder { - Decoder { - toml: toml, - cur_field: if field.len() == 0 { - self.cur_field.clone() - } else { - match self.cur_field { - None => Some(format!("{}", field)), - Some(ref s) => Some(format!("{}.{}", s, field)) - } - }, - leftover_map: BTreeMap::new(), - cur_map: BTreeMap::new().into_iter().peekable(), - } - } - - fn err(&self, kind: DecodeErrorKind) -> DecodeError { - DecodeError { - field: self.cur_field.clone(), - kind: kind, - } - } - - fn mismatch(&self, expected: &'static str, - found: &Option<Value>) -> DecodeError{ - match *found { - Some(ref val) => self.err(ExpectedType(expected, val.type_str())), - None => self.err(ExpectedField(Some(expected))), - } - } -} - -impl fmt::Display for DecodeError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(match self.kind { - ApplicationError(ref err) => { - write!(f, "{}", err) - } - ExpectedField(expected_type) => { - match expected_type { - Some("table") => write!(f, "expected a section"), - Some(e) => write!(f, "expected a value of type `{}`", e), - None => write!(f, "expected a value"), - } - } - UnknownField => write!(f, "unknown field"), - ExpectedType(expected, found) => { - fn humanize(s: &str) -> String { - if s == "section" { - format!("a section") - } else { - format!("a value of type `{}`", s) - } - } - write!(f, "expected {}, but found {}", - humanize(expected), - humanize(found)) - } - ExpectedMapKey(idx) => { - write!(f, "expected at least {} keys", idx + 1) - } - ExpectedMapElement(idx) => { - write!(f, "expected at least {} elements", idx + 1) - } - NoEnumVariants => { - write!(f, "expected an enum variant to decode to") - } - NilTooLong => { - write!(f, "expected 0-length string") - } - SyntaxError => { - write!(f, "syntax error") - } - EndOfStream => { - write!(f, "end of stream") - } - InvalidType(s) => { - write!(f, "invalid type: {}", s) - } - CustomError(ref s) => { - write!(f, "custom error: {}", s) - } - }); - match self.field { - Some(ref s) => { - write!(f, " for the key `{}`", s) - } - None => Ok(()) - } - } -} - -impl error::Error for DecodeError { - fn description(&self) -> &str { - match self.kind { - ApplicationError(ref s) => &**s, - ExpectedField(..) => "expected a field", - UnknownField => "found an unknown field", - ExpectedType(..) => "expected a type", - ExpectedMapKey(..) => "expected a map key", - ExpectedMapElement(..) => "expected a map element", - NoEnumVariants => "no enum variants to decode to", - NilTooLong => "nonzero length string representing nil", - SyntaxError => "syntax error", - EndOfStream => "end of stream", - InvalidType(..) => "invalid type", - CustomError(..) => "custom error", - } - } -} diff --git a/src/vendor/toml/src/decoder/rustc_serialize.rs b/src/vendor/toml/src/decoder/rustc_serialize.rs deleted file mode 100644 index 2f4fb0937a8..00000000000 --- a/src/vendor/toml/src/decoder/rustc_serialize.rs +++ /dev/null @@ -1,371 +0,0 @@ -use rustc_serialize; -use std::mem; -use std::collections::BTreeMap; - -use super::{Decoder, DecodeError}; -use super::DecodeErrorKind::*; -use Value; - -impl rustc_serialize::Decoder for Decoder { - type Error = DecodeError; - fn read_nil(&mut self) -> Result<(), DecodeError> { - match self.toml { - Some(Value::String(ref s)) if s.is_empty() => {} - Some(Value::String(..)) => return Err(self.err(NilTooLong)), - ref found => return Err(self.mismatch("string", found)), - } - self.toml.take(); - Ok(()) - } - fn read_usize(&mut self) -> Result<usize, DecodeError> { - self.read_i64().map(|i| i as usize) - } - fn read_u64(&mut self) -> Result<u64, DecodeError> { - self.read_i64().map(|i| i as u64) - } - fn read_u32(&mut self) -> Result<u32, DecodeError> { - self.read_i64().map(|i| i as u32) - } - fn read_u16(&mut self) -> Result<u16, DecodeError> { - self.read_i64().map(|i| i as u16) - } - fn read_u8(&mut self) -> Result<u8, DecodeError> { - self.read_i64().map(|i| i as u8) - } - fn read_isize(&mut self) -> Result<isize, DecodeError> { - self.read_i64().map(|i| i as isize) - } - fn read_i64(&mut self) -> Result<i64, DecodeError> { - match self.toml { - Some(Value::Integer(i)) => { self.toml.take(); Ok(i) } - ref found => Err(self.mismatch("integer", found)), - } - } - fn read_i32(&mut self) -> Result<i32, DecodeError> { - self.read_i64().map(|i| i as i32) - } - fn read_i16(&mut self) -> Result<i16, DecodeError> { - self.read_i64().map(|i| i as i16) - } - fn read_i8(&mut self) -> Result<i8, DecodeError> { - self.read_i64().map(|i| i as i8) - } - fn read_bool(&mut self) -> Result<bool, DecodeError> { - match self.toml { - Some(Value::Boolean(b)) => { self.toml.take(); Ok(b) } - ref found => Err(self.mismatch("bool", found)), - } - } - fn read_f64(&mut self) -> Result<f64, DecodeError> { - match self.toml { - Some(Value::Float(f)) => { self.toml.take(); Ok(f) }, - ref found => Err(self.mismatch("float", found)), - } - } - fn read_f32(&mut self) -> Result<f32, DecodeError> { - self.read_f64().map(|f| f as f32) - } - fn read_char(&mut self) -> Result<char, DecodeError> { - let ch = match self.toml { - Some(Value::String(ref s)) if s.chars().count() == 1 => - s.chars().next().unwrap(), - ref found => return Err(self.mismatch("string", found)), - }; - self.toml.take(); - Ok(ch) - } - fn read_str(&mut self) -> Result<String, DecodeError> { - match self.toml.take() { - Some(Value::String(s)) => Ok(s), - found => { - let err = Err(self.mismatch("string", &found)); - self.toml = found; - err - } - } - } - - // Compound types: - fn read_enum<T, F>(&mut self, _name: &str, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - f(self) - } - - fn read_enum_variant<T, F>(&mut self, names: &[&str], mut f: F) - -> Result<T, DecodeError> - where F: FnMut(&mut Decoder, usize) -> Result<T, DecodeError> - { - // When decoding enums, this crate takes the strategy of trying to - // decode the current TOML as all of the possible variants, returning - // success on the first one that succeeds. - // - // Note that fidelity of the errors returned here is a little nebulous, - // but we try to return the error that had the relevant field as the - // longest field. This way we hopefully match an error against what was - // most likely being written down without losing too much info. - let mut first_error = None::<DecodeError>; - for i in 0..names.len() { - let mut d = self.sub_decoder(self.toml.clone(), ""); - match f(&mut d, i) { - Ok(t) => { - self.toml = d.toml; - return Ok(t) - } - Err(e) => { - if let Some(ref first) = first_error { - let my_len = e.field.as_ref().map(|s| s.len()); - let first_len = first.field.as_ref().map(|s| s.len()); - if my_len <= first_len { - continue - } - } - first_error = Some(e); - } - } - } - Err(first_error.unwrap_or_else(|| self.err(NoEnumVariants))) - } - fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - f(self) - } - - fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) - -> Result<T, DecodeError> - where F: FnMut(&mut Decoder, usize) -> Result<T, DecodeError> - { - panic!() - } - fn read_enum_struct_variant_field<T, F>(&mut self, - _f_name: &str, - _f_idx: usize, - _f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - panic!() - } - - fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - match self.toml { - Some(Value::Table(..)) => { - let ret = try!(f(self)); - match self.toml { - Some(Value::Table(ref t)) if t.is_empty() => {} - _ => return Ok(ret) - } - self.toml.take(); - Ok(ret) - } - ref found => Err(self.mismatch("table", found)), - } - } - fn read_struct_field<T, F>(&mut self, f_name: &str, _f_idx: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - let field = format!("{}", f_name); - let toml = match self.toml { - Some(Value::Table(ref mut table)) => { - table.remove(&field) - .or_else(|| table.remove(&f_name.replace("_", "-"))) - }, - ref found => return Err(self.mismatch("table", found)), - }; - let mut d = self.sub_decoder(toml, f_name); - let ret = try!(f(&mut d)); - if let Some(value) = d.toml { - if let Some(Value::Table(ref mut table)) = self.toml { - table.insert(field, value); - } - } - Ok(ret) - } - - fn read_tuple<T, F>(&mut self, tuple_len: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - self.read_seq(move |d, len| { - assert!(len == tuple_len, - "expected tuple of length `{}`, found tuple \ - of length `{}`", tuple_len, len); - f(d) - }) - } - fn read_tuple_arg<T, F>(&mut self, a_idx: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - self.read_seq_elt(a_idx, f) - } - - fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - panic!() - } - fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - panic!() - } - - // Specialized types: - fn read_option<T, F>(&mut self, mut f: F) - -> Result<T, DecodeError> - where F: FnMut(&mut Decoder, bool) -> Result<T, DecodeError> - { - match self.toml { - Some(..) => f(self, true), - None => f(self, false), - } - } - - fn read_seq<T, F>(&mut self, f: F) -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder, usize) -> Result<T, DecodeError> - { - let len = match self.toml { - Some(Value::Array(ref arr)) => arr.len(), - None => 0, - ref found => return Err(self.mismatch("array", found)), - }; - let ret = try!(f(self, len)); - match self.toml { - Some(Value::Array(ref mut arr)) => { - arr.retain(|slot| slot.as_integer() != Some(0)); - if !arr.is_empty() { return Ok(ret) } - } - _ => return Ok(ret) - } - self.toml.take(); - Ok(ret) - } - fn read_seq_elt<T, F>(&mut self, idx: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - let toml = match self.toml { - Some(Value::Array(ref mut arr)) => { - mem::replace(&mut arr[idx], Value::Integer(0)) - } - ref found => return Err(self.mismatch("array", found)), - }; - let mut d = self.sub_decoder(Some(toml), ""); - let ret = try!(f(&mut d)); - if let Some(toml) = d.toml { - if let Some(Value::Array(ref mut arr)) = self.toml { - arr[idx] = toml; - } - } - Ok(ret) - } - - fn read_map<T, F>(&mut self, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder, usize) -> Result<T, DecodeError> - { - let map = match self.toml.take() { - Some(Value::Table(table)) => table, - found => { - self.toml = found; - return Err(self.mismatch("table", &self.toml)) - } - }; - let amt = map.len(); - let prev_iter = mem::replace(&mut self.cur_map, - map.into_iter().peekable()); - let prev_map = mem::replace(&mut self.leftover_map, BTreeMap::new()); - let ret = try!(f(self, amt)); - let leftover = mem::replace(&mut self.leftover_map, prev_map); - self.cur_map = prev_iter; - if !leftover.is_empty() { - self.toml = Some(Value::Table(leftover)); - } - Ok(ret) - } - fn read_map_elt_key<T, F>(&mut self, idx: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - let key = match self.cur_map.peek().map(|p| p.0.clone()) { - Some(k) => k, - None => return Err(self.err(ExpectedMapKey(idx))), - }; - let val = Value::String(key.clone()); - f(&mut self.sub_decoder(Some(val), &key)) - } - fn read_map_elt_val<T, F>(&mut self, idx: usize, f: F) - -> Result<T, DecodeError> - where F: FnOnce(&mut Decoder) -> Result<T, DecodeError> - { - match self.cur_map.next() { - Some((key, value)) => { - let mut d = self.sub_decoder(Some(value), &key); - let ret = f(&mut d); - if let Some(toml) = d.toml.take() { - self.leftover_map.insert(key, toml); - } - ret - } - None => Err(self.err(ExpectedMapElement(idx))), - } - } - - fn error(&mut self, err: &str) -> DecodeError { - DecodeError { - field: self.cur_field.clone(), - kind: ApplicationError(format!("{}", err)) - } - } -} - -#[cfg(test)] -mod tests { - use rustc_serialize::Decodable; - use std::collections::HashMap; - - use {Parser, Decoder, Value}; - - #[test] - fn bad_enum_chooses_longest_error() { - #[derive(RustcDecodable)] - #[allow(dead_code)] - struct Foo { - wut: HashMap<String, Bar>, - } - - #[derive(RustcDecodable)] - enum Bar { - Simple(String), - Detailed(Baz), - } - - #[derive(RustcDecodable, Debug)] - struct Baz { - features: Vec<String>, - } - - let s = r#" - [wut] - a = { features = "" } - "#; - let v = Parser::new(s).parse().unwrap(); - let mut d = Decoder::new(Value::Table(v)); - let err = match Foo::decode(&mut d) { - Ok(_) => panic!("expected error"), - Err(e) => e, - }; - assert_eq!(err.field.as_ref().unwrap(), "wut.a.features"); - - } -} diff --git a/src/vendor/toml/src/decoder/serde.rs b/src/vendor/toml/src/decoder/serde.rs deleted file mode 100644 index 91bc8acf5ea..00000000000 --- a/src/vendor/toml/src/decoder/serde.rs +++ /dev/null @@ -1,544 +0,0 @@ -use serde::de; -use Value; -use super::{Decoder, DecodeError, DecodeErrorKind}; -use std::collections::BTreeMap; - -impl de::Deserializer for Decoder { - type Error = DecodeError; - - fn deserialize<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor - { - match self.toml.take() { - Some(Value::String(s)) => visitor.visit_string(s), - Some(Value::Integer(i)) => visitor.visit_i64(i), - Some(Value::Float(f)) => visitor.visit_f64(f), - Some(Value::Boolean(b)) => visitor.visit_bool(b), - Some(Value::Datetime(s)) => visitor.visit_string(s), - Some(Value::Array(a)) => { - let len = a.len(); - let iter = a.into_iter(); - visitor.visit_seq(SeqDeserializer::new(iter, len, &mut self.toml)) - } - Some(Value::Table(t)) => { - visitor.visit_map(MapVisitor { - iter: t.into_iter(), - de: self, - key: None, - value: None, - }) - } - None => Err(self.err(DecodeErrorKind::EndOfStream)), - } - } - - fn deserialize_bool<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor - { - match self.toml.take() { - Some(Value::Boolean(b)) => visitor.visit_bool(b), - ref found => Err(self.mismatch("bool", found)), - } - } - - fn deserialize_i64<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor - { - match self.toml.take() { - Some(Value::Integer(f)) => visitor.visit_i64(f), - ref found => Err(self.mismatch("integer", found)), - } - } - - fn deserialize_u64<V>(&mut self, v: V) -> Result<V::Value, DecodeError> - where V: de::Visitor - { - self.deserialize_i64(v) - } - - fn deserialize_f64<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor - { - match self.toml.take() { - Some(Value::Float(f)) => visitor.visit_f64(f), - ref found => Err(self.mismatch("float", found)), - } - } - - fn deserialize_str<V>(&mut self, mut visitor: V) - -> Result<V::Value, Self::Error> - where V: de::Visitor, - { - match self.toml.take() { - Some(Value::String(s)) => visitor.visit_string(s), - ref found => Err(self.mismatch("string", found)), - } - } - - fn deserialize_char<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor - { - match self.toml.take() { - Some(Value::String(ref s)) if s.chars().count() == 1 => { - visitor.visit_char(s.chars().next().unwrap()) - } - ref found => return Err(self.mismatch("string", found)), - } - } - - fn deserialize_option<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor - { - if self.toml.is_none() { - visitor.visit_none() - } else { - visitor.visit_some(self) - } - } - - fn deserialize_seq<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - if self.toml.is_none() { - let iter = None::<i32>.into_iter(); - visitor.visit_seq(de::value::SeqDeserializer::new(iter, 0)) - } else { - self.deserialize(visitor) - } - } - - fn deserialize_map<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - match self.toml.take() { - Some(Value::Table(t)) => { - visitor.visit_map(MapVisitor { - iter: t.into_iter(), - de: self, - key: None, - value: None, - }) - } - ref found => Err(self.mismatch("table", found)), - } - } - - fn deserialize_enum<V>(&mut self, - _enum: &str, - variants: &[&str], - mut visitor: V) -> Result<V::Value, DecodeError> - where V: de::EnumVisitor, - { - // When decoding enums, this crate takes the strategy of trying to - // decode the current TOML as all of the possible variants, returning - // success on the first one that succeeds. - // - // Note that fidelity of the errors returned here is a little nebulous, - // but we try to return the error that had the relevant field as the - // longest field. This way we hopefully match an error against what was - // most likely being written down without losing too much info. - let mut first_error = None::<DecodeError>; - - for variant in 0..variants.len() { - let mut de = VariantVisitor { - de: self.sub_decoder(self.toml.clone(), ""), - variant: variant, - }; - - match visitor.visit(&mut de) { - Ok(value) => { - self.toml = de.de.toml; - return Ok(value); - } - Err(e) => { - if let Some(ref first) = first_error { - let my_len = e.field.as_ref().map(|s| s.len()); - let first_len = first.field.as_ref().map(|s| s.len()); - if my_len <= first_len { - continue - } - } - first_error = Some(e); - } - } - } - - Err(first_error.unwrap_or_else(|| self.err(DecodeErrorKind::NoEnumVariants))) - } - - // When #[derive(Deserialize)] encounters an unknown struct field it will - // call this method (somehow), and we want to preserve all unknown struct - // fields to return them upwards (to warn about unused keys), so we override - // that here to not tamper with our own internal state. - fn deserialize_ignored_any<V>(&mut self, visitor: V) - -> Result<V::Value, Self::Error> - where V: de::Visitor - { - use serde::de::value::ValueDeserializer; - let mut d = <() as ValueDeserializer<Self::Error>>::into_deserializer(()); - d.deserialize(visitor) - } -} - -struct VariantVisitor { - de: Decoder, - variant: usize, -} - -impl de::VariantVisitor for VariantVisitor { - type Error = DecodeError; - - fn visit_variant<V>(&mut self) -> Result<V, DecodeError> - where V: de::Deserialize - { - use serde::de::value::ValueDeserializer; - - let mut de = self.variant.into_deserializer(); - - de::Deserialize::deserialize(&mut de) - } - - fn visit_unit(&mut self) -> Result<(), DecodeError> { - de::Deserialize::deserialize(&mut self.de) - } - - fn visit_newtype<T>(&mut self) -> Result<T, DecodeError> - where T: de::Deserialize, - { - de::Deserialize::deserialize(&mut self.de) - } - - fn visit_tuple<V>(&mut self, - _len: usize, - visitor: V) -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - de::Deserializer::deserialize(&mut self.de, visitor) - } - - fn visit_struct<V>(&mut self, - _fields: &'static [&'static str], - visitor: V) -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - de::Deserializer::deserialize(&mut self.de, visitor) - } -} - -struct SeqDeserializer<'a, I> { - iter: I, - len: usize, - toml: &'a mut Option<Value>, -} - -impl<'a, I> SeqDeserializer<'a, I> where I: Iterator<Item=Value> { - fn new(iter: I, len: usize, toml: &'a mut Option<Value>) -> Self { - SeqDeserializer { - iter: iter, - len: len, - toml: toml, - } - } - - fn put_value_back(&mut self, v: Value) { - *self.toml = self.toml.take().or(Some(Value::Array(Vec::new()))); - match self.toml.as_mut().unwrap() { - &mut Value::Array(ref mut a) => { - a.push(v); - }, - _ => unreachable!(), - } - } -} - -impl<'a, I> de::Deserializer for SeqDeserializer<'a, I> - where I: Iterator<Item=Value>, -{ - type Error = DecodeError; - - fn deserialize<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - visitor.visit_seq(self) - } -} - -impl<'a, I> de::SeqVisitor for SeqDeserializer<'a, I> - where I: Iterator<Item=Value> -{ - type Error = DecodeError; - - fn visit<V>(&mut self) -> Result<Option<V>, DecodeError> - where V: de::Deserialize - { - match self.iter.next() { - Some(value) => { - self.len -= 1; - let mut de = Decoder::new(value); - let v = try!(de::Deserialize::deserialize(&mut de)); - if let Some(t) = de.toml { - self.put_value_back(t); - } - Ok(Some(v)) - } - None => Ok(None), - } - } - - fn end(&mut self) -> Result<(), DecodeError> { - if self.len == 0 { - Ok(()) - } else { - Err(de::Error::end_of_stream()) - } - } - - fn size_hint(&self) -> (usize, Option<usize>) { - (self.len, Some(self.len)) - } -} - -impl de::Error for DecodeError { - fn custom<T: Into<String>>(msg: T) -> DecodeError { - DecodeError { - field: None, - kind: DecodeErrorKind::CustomError(msg.into()), - } - } - fn end_of_stream() -> DecodeError { - DecodeError { field: None, kind: DecodeErrorKind::EndOfStream } - } - fn missing_field(name: &'static str) -> DecodeError { - DecodeError { - field: Some(name.to_string()), - kind: DecodeErrorKind::ExpectedField(None), - } - } - fn unknown_field(name: &str) -> DecodeError { - DecodeError { - field: Some(name.to_string()), - kind: DecodeErrorKind::UnknownField, - } - } - fn invalid_type(ty: de::Type) -> Self { - DecodeError { - field: None, - kind: DecodeErrorKind::InvalidType(match ty { - de::Type::Bool => "bool", - de::Type::Usize | - de::Type::U8 | - de::Type::U16 | - de::Type::U32 | - de::Type::U64 | - de::Type::Isize | - de::Type::I8 | - de::Type::I16 | - de::Type::I32 | - de::Type::I64 => "integer", - de::Type::F32 | - de::Type::F64 => "float", - de::Type::Char | - de::Type::Str | - de::Type::String => "string", - de::Type::Seq => "array", - de::Type::Struct | - de::Type::Map => "table", - de::Type::Unit => "Unit", - de::Type::Option => "Option", - de::Type::UnitStruct => "UnitStruct", - de::Type::NewtypeStruct => "NewtypeStruct", - de::Type::TupleStruct => "TupleStruct", - de::Type::FieldName => "FieldName", - de::Type::Tuple => "Tuple", - de::Type::Enum => "Enum", - de::Type::VariantName => "VariantName", - de::Type::StructVariant => "StructVariant", - de::Type::TupleVariant => "TupleVariant", - de::Type::UnitVariant => "UnitVariant", - de::Type::Bytes => "Bytes", - }) - } - } -} - -struct MapVisitor<'a, I> { - iter: I, - de: &'a mut Decoder, - key: Option<String>, - value: Option<Value>, -} - -impl<'a, I> MapVisitor<'a, I> { - fn put_value_back(&mut self, v: Value) { - self.de.toml = self.de.toml.take().or_else(|| { - Some(Value::Table(BTreeMap::new())) - }); - - match self.de.toml.as_mut().unwrap() { - &mut Value::Table(ref mut t) => { - t.insert(self.key.take().unwrap(), v); - }, - _ => unreachable!(), - } - } -} - -impl<'a, I> de::MapVisitor for MapVisitor<'a, I> - where I: Iterator<Item=(String, Value)> -{ - type Error = DecodeError; - - fn visit_key<K>(&mut self) -> Result<Option<K>, DecodeError> - where K: de::Deserialize - { - while let Some((k, v)) = self.iter.next() { - let mut dec = self.de.sub_decoder(Some(Value::String(k.clone())), &k); - self.key = Some(k); - - match de::Deserialize::deserialize(&mut dec) { - Ok(val) => { - self.value = Some(v); - return Ok(Some(val)) - } - - // If this was an unknown field, then we put the toml value - // back into the map and keep going. - Err(DecodeError {kind: DecodeErrorKind::UnknownField, ..}) => { - self.put_value_back(v); - } - - Err(e) => return Err(e), - } - } - Ok(None) - } - - fn visit_value<V>(&mut self) -> Result<V, DecodeError> - where V: de::Deserialize - { - match self.value.take() { - Some(t) => { - let mut dec = { - // Borrowing the key here because Rust doesn't have - // non-lexical borrows yet. - let key = match self.key { - Some(ref key) => &**key, - None => "" - }; - - self.de.sub_decoder(Some(t), key) - }; - let v = try!(de::Deserialize::deserialize(&mut dec)); - if let Some(t) = dec.toml { - self.put_value_back(t); - } - Ok(v) - }, - None => Err(de::Error::end_of_stream()) - } - } - - fn end(&mut self) -> Result<(), DecodeError> { - if let Some(v) = self.value.take() { - self.put_value_back(v); - } - while let Some((k, v)) = self.iter.next() { - self.key = Some(k); - self.put_value_back(v); - } - Ok(()) - } - - fn missing_field<V>(&mut self, field_name: &'static str) - -> Result<V, DecodeError> where V: de::Deserialize { - // See if the type can deserialize from a unit. - match de::Deserialize::deserialize(&mut UnitDeserializer) { - Err(DecodeError { - kind: DecodeErrorKind::InvalidType(..), - field, - }) => Err(DecodeError { - field: field.or(Some(field_name.to_string())), - kind: DecodeErrorKind::ExpectedField(None), - }), - v => v, - } - } -} - -struct UnitDeserializer; - -impl de::Deserializer for UnitDeserializer { - type Error = DecodeError; - - fn deserialize<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - visitor.visit_unit() - } - - fn deserialize_option<V>(&mut self, mut visitor: V) - -> Result<V::Value, DecodeError> - where V: de::Visitor, - { - visitor.visit_none() - } -} - -impl de::Deserialize for Value { - fn deserialize<D>(deserializer: &mut D) -> Result<Value, D::Error> - where D: de::Deserializer - { - struct ValueVisitor; - - impl de::Visitor for ValueVisitor { - type Value = Value; - - fn visit_bool<E>(&mut self, value: bool) -> Result<Value, E> { - Ok(Value::Boolean(value)) - } - - fn visit_i64<E>(&mut self, value: i64) -> Result<Value, E> { - Ok(Value::Integer(value)) - } - - fn visit_f64<E>(&mut self, value: f64) -> Result<Value, E> { - Ok(Value::Float(value)) - } - - fn visit_str<E>(&mut self, value: &str) -> Result<Value, E> { - Ok(Value::String(value.into())) - } - - fn visit_string<E>(&mut self, value: String) -> Result<Value, E> { - Ok(Value::String(value)) - } - - fn visit_seq<V>(&mut self, visitor: V) -> Result<Value, V::Error> - where V: de::SeqVisitor - { - let values = try!(de::impls::VecVisitor::new().visit_seq(visitor)); - Ok(Value::Array(values)) - } - - fn visit_map<V>(&mut self, visitor: V) -> Result<Value, V::Error> - where V: de::MapVisitor - { - let mut v = de::impls::BTreeMapVisitor::new(); - let values = try!(v.visit_map(visitor)); - Ok(Value::Table(values)) - } - } - - deserializer.deserialize(ValueVisitor) - } -} diff --git a/src/vendor/toml/src/display.rs b/src/vendor/toml/src/display.rs deleted file mode 100644 index 6891530beeb..00000000000 --- a/src/vendor/toml/src/display.rs +++ /dev/null @@ -1,201 +0,0 @@ -use std::fmt; - -use Table as TomlTable; -use Value::{self, String, Integer, Float, Boolean, Datetime, Array, Table}; - -struct Printer<'a, 'b:'a> { - output: &'a mut fmt::Formatter<'b>, - stack: Vec<&'a str>, -} - -struct Key<'a>(&'a [&'a str]); - -impl fmt::Display for Value { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - String(ref s) => write_str(f, s), - Integer(i) => write!(f, "{}", i), - Float(fp) => { - try!(write!(f, "{}", fp)); - if fp % 1.0 == 0.0 { try!(write!(f, ".0")) } - Ok(()) - } - Boolean(b) => write!(f, "{}", b), - Datetime(ref s) => write!(f, "{}", s), - Table(ref t) => { - let mut p = Printer { output: f, stack: Vec::new() }; - p.print(t) - } - Array(ref a) => { - try!(write!(f, "[")); - for (i, v) in a.iter().enumerate() { - if i != 0 { try!(write!(f, ", ")); } - try!(write!(f, "{}", v)); - } - write!(f, "]") - } - } - } -} - -fn write_str(f: &mut fmt::Formatter, s: &str) -> fmt::Result { - try!(write!(f, "\"")); - for ch in s.chars() { - match ch { - '\u{8}' => try!(write!(f, "\\b")), - '\u{9}' => try!(write!(f, "\\t")), - '\u{a}' => try!(write!(f, "\\n")), - '\u{c}' => try!(write!(f, "\\f")), - '\u{d}' => try!(write!(f, "\\r")), - '\u{22}' => try!(write!(f, "\\\"")), - '\u{5c}' => try!(write!(f, "\\\\")), - ch => try!(write!(f, "{}", ch)), - } - } - write!(f, "\"") -} - -impl<'a, 'b> Printer<'a, 'b> { - fn print(&mut self, table: &'a TomlTable) -> fmt::Result { - for (k, v) in table.iter() { - match *v { - Table(..) => continue, - Array(ref a) => { - if let Some(&Table(..)) = a.first() { - continue; - } - } - _ => {} - } - try!(writeln!(self.output, "{} = {}", Key(&[k]), v)); - } - for (k, v) in table.iter() { - match *v { - Table(ref inner) => { - self.stack.push(k); - try!(writeln!(self.output, "\n[{}]", Key(&self.stack))); - try!(self.print(inner)); - self.stack.pop(); - } - Array(ref inner) => { - match inner.first() { - Some(&Table(..)) => {} - _ => continue - } - self.stack.push(k); - for inner in inner.iter() { - try!(writeln!(self.output, "\n[[{}]]", Key(&self.stack))); - match *inner { - Table(ref inner) => try!(self.print(inner)), - _ => panic!("non-heterogeneous toml array"), - } - } - self.stack.pop(); - } - _ => {}, - } - } - Ok(()) - } -} - -impl<'a> fmt::Display for Key<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - for (i, part) in self.0.iter().enumerate() { - if i != 0 { try!(write!(f, ".")); } - let ok = part.chars().all(|c| { - match c { - 'a' ... 'z' | - 'A' ... 'Z' | - '0' ... '9' | - '-' | '_' => true, - _ => false, - } - }); - if ok { - try!(write!(f, "{}", part)); - } else { - try!(write_str(f, part)); - } - } - Ok(()) - } -} - -#[cfg(test)] -#[allow(warnings)] -mod tests { - use Value; - use Value::{String, Integer, Float, Boolean, Datetime, Array, Table}; - use std::collections::BTreeMap; - - macro_rules! map( ($($k:expr => $v:expr),*) => ({ - let mut _m = BTreeMap::new(); - $(_m.insert($k.to_string(), $v);)* - _m - }) ); - - #[test] - fn simple_show() { - assert_eq!(String("foo".to_string()).to_string(), - "\"foo\""); - assert_eq!(Integer(10).to_string(), - "10"); - assert_eq!(Float(10.0).to_string(), - "10.0"); - assert_eq!(Float(2.4).to_string(), - "2.4"); - assert_eq!(Boolean(true).to_string(), - "true"); - assert_eq!(Datetime("test".to_string()).to_string(), - "test"); - assert_eq!(Array(vec![]).to_string(), - "[]"); - assert_eq!(Array(vec![Integer(1), Integer(2)]).to_string(), - "[1, 2]"); - } - - #[test] - fn table() { - assert_eq!(Table(map! { }).to_string(), - ""); - assert_eq!(Table(map! { "test" => Integer(2) }).to_string(), - "test = 2\n"); - assert_eq!(Table(map! { - "test" => Integer(2), - "test2" => Table(map! { - "test" => String("wut".to_string()) - }) - }).to_string(), - "test = 2\n\ - \n\ - [test2]\n\ - test = \"wut\"\n"); - assert_eq!(Table(map! { - "test" => Integer(2), - "test2" => Table(map! { - "test" => String("wut".to_string()) - }) - }).to_string(), - "test = 2\n\ - \n\ - [test2]\n\ - test = \"wut\"\n"); - assert_eq!(Table(map! { - "test" => Integer(2), - "test2" => Array(vec![Table(map! { - "test" => String("wut".to_string()) - })]) - }).to_string(), - "test = 2\n\ - \n\ - [[test2]]\n\ - test = \"wut\"\n"); - assert_eq!(Table(map! { - "foo.bar" => Integer(2), - "foo\"bar" => Integer(2) - }).to_string(), - "\"foo\\\"bar\" = 2\n\ - \"foo.bar\" = 2\n"); - } -} diff --git a/src/vendor/toml/src/encoder/mod.rs b/src/vendor/toml/src/encoder/mod.rs deleted file mode 100644 index fb628fa3d23..00000000000 --- a/src/vendor/toml/src/encoder/mod.rs +++ /dev/null @@ -1,214 +0,0 @@ -use std::collections::BTreeMap; -use std::error; -use std::fmt; -use std::mem; - -use {Value, Table}; - -#[cfg(feature = "rustc-serialize")] mod rustc_serialize; -#[cfg(feature = "serde")] mod serde; - -/// A structure to transform Rust values into TOML values. -/// -/// This encoder implements the serialization `Encoder` interface, allowing -/// `Encodable` rust types to be fed into the encoder. The output of this -/// encoder is a TOML `Table` structure. The resulting TOML can be stringified -/// if necessary. -/// -/// # Example -/// -/// ``` -/// extern crate rustc_serialize; -/// extern crate toml; -/// -/// # fn main() { -/// use toml::{Encoder, Value}; -/// use rustc_serialize::Encodable; -/// -/// #[derive(RustcEncodable)] -/// struct MyStruct { foo: isize, bar: String } -/// let my_struct = MyStruct { foo: 4, bar: "hello!".to_string() }; -/// -/// let mut e = Encoder::new(); -/// my_struct.encode(&mut e).unwrap(); -/// -/// assert_eq!(e.toml.get(&"foo".to_string()), Some(&Value::Integer(4))) -/// # } -/// ``` -pub struct Encoder { - /// Output TOML that is emitted. The current version of this encoder forces - /// the top-level representation of a structure to be a table. - /// - /// This field can be used to extract the return value after feeding a value - /// into this `Encoder`. - pub toml: Table, - state: State, -} - -/// Enumeration of errors which can occur while encoding a rust value into a -/// TOML value. -#[allow(missing_copy_implementations)] -#[derive(Debug)] -pub enum Error { - /// Indication that a key was needed when a value was emitted, but no key - /// was previously emitted. - NeedsKey, - /// Indication that a key was emitted, but not value was emitted. - NoValue, - /// Indicates that a map key was attempted to be emitted at an invalid - /// location. - InvalidMapKeyLocation, - /// Indicates that a type other than a string was attempted to be used as a - /// map key type. - InvalidMapKeyType, - /// A custom error type was generated - Custom(String), -} - -#[derive(PartialEq)] -enum State { - Start, - NextKey(String), - NextArray(Vec<Value>), - NextMapKey, -} - -impl Encoder { - /// Constructs a new encoder which will emit to the given output stream. - pub fn new() -> Encoder { - Encoder { state: State::Start, toml: BTreeMap::new() } - } - - fn emit_value(&mut self, v: Value) -> Result<(), Error> { - match mem::replace(&mut self.state, State::Start) { - State::NextKey(key) => { self.toml.insert(key, v); Ok(()) } - State::NextArray(mut vec) => { - // TODO: validate types - vec.push(v); - self.state = State::NextArray(vec); - Ok(()) - } - State::NextMapKey => { - match v { - Value::String(s) => { self.state = State::NextKey(s); Ok(()) } - _ => Err(Error::InvalidMapKeyType) - } - } - _ => Err(Error::NeedsKey) - } - } - - fn emit_none(&mut self) -> Result<(), Error> { - match mem::replace(&mut self.state, State::Start) { - State::Start => unreachable!(), - State::NextKey(_) => Ok(()), - State::NextArray(..) => panic!("how to encode None in an array?"), - State::NextMapKey => Err(Error::InvalidMapKeyLocation), - } - } - - fn seq<F>(&mut self, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - let old = mem::replace(&mut self.state, State::NextArray(Vec::new())); - try!(f(self)); - match mem::replace(&mut self.state, old) { - State::NextArray(v) => self.emit_value(Value::Array(v)), - _ => unreachable!(), - } - } - - fn table<F>(&mut self, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - match mem::replace(&mut self.state, State::Start) { - State::NextKey(key) => { - let mut nested = Encoder::new(); - try!(f(&mut nested)); - self.toml.insert(key, Value::Table(nested.toml)); - Ok(()) - } - State::NextArray(mut arr) => { - let mut nested = Encoder::new(); - try!(f(&mut nested)); - arr.push(Value::Table(nested.toml)); - self.state = State::NextArray(arr); - Ok(()) - } - State::Start => f(self), - State::NextMapKey => Err(Error::InvalidMapKeyLocation), - } - } - - fn table_key<F>(&mut self, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - match mem::replace(&mut self.state, State::NextMapKey) { - State::Start => {} - _ => return Err(Error::InvalidMapKeyLocation), - } - try!(f(self)); - match self.state { - State::NextKey(_) => Ok(()), - _ => Err(Error::InvalidMapKeyLocation), - } - } -} - -/// Encodes an encodable value into a TOML value. -/// -/// This function expects the type given to represent a TOML table in some form. -/// If encoding encounters an error, then this function will fail the task. -#[cfg(feature = "rustc-serialize")] -pub fn encode<T: ::rustc_serialize::Encodable>(t: &T) -> Value { - let mut e = Encoder::new(); - t.encode(&mut e).unwrap(); - Value::Table(e.toml) -} - -/// Encodes an encodable value into a TOML value. -/// -/// This function expects the type given to represent a TOML table in some form. -/// If encoding encounters an error, then this function will fail the task. -#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] -pub fn encode<T: ::serde::Serialize>(t: &T) -> Value { - let mut e = Encoder::new(); - t.serialize(&mut e).unwrap(); - Value::Table(e.toml) -} - -/// Encodes an encodable value into a TOML string. -/// -/// This function expects the type given to represent a TOML table in some form. -/// If encoding encounters an error, then this function will fail the task. -#[cfg(feature = "rustc-serialize")] -pub fn encode_str<T: ::rustc_serialize::Encodable>(t: &T) -> String { - encode(t).to_string() -} - -/// Encodes an encodable value into a TOML string. -/// -/// This function expects the type given to represent a TOML table in some form. -/// If encoding encounters an error, then this function will fail the task. -#[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] -pub fn encode_str<T: ::serde::Serialize>(t: &T) -> String { - encode(t).to_string() -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - Error::NeedsKey => write!(f, "need a key to encode"), - Error::NoValue => write!(f, "no value to emit for a previous key"), - Error::InvalidMapKeyLocation => write!(f, "a map cannot be emitted \ - at this location"), - Error::InvalidMapKeyType => write!(f, "only strings can be used as \ - key types"), - Error::Custom(ref s) => write!(f, "custom error: {}", s), - } - } -} - -impl error::Error for Error { - fn description(&self) -> &str { "TOML encoding error" } -} diff --git a/src/vendor/toml/src/encoder/rustc_serialize.rs b/src/vendor/toml/src/encoder/rustc_serialize.rs deleted file mode 100644 index 7f1db876c58..00000000000 --- a/src/vendor/toml/src/encoder/rustc_serialize.rs +++ /dev/null @@ -1,716 +0,0 @@ -use std::mem; - -use rustc_serialize; -use Value; -use super::{Encoder, Error, State}; -use super::Error::*; - -impl rustc_serialize::Encoder for Encoder { - type Error = Error; - - fn emit_nil(&mut self) -> Result<(), Error> { Ok(()) } - fn emit_usize(&mut self, v: usize) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_u8(&mut self, v: u8) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_u16(&mut self, v: u16) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_u32(&mut self, v: u32) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_u64(&mut self, v: u64) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_isize(&mut self, v: isize) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_i8(&mut self, v: i8) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_i16(&mut self, v: i16) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_i32(&mut self, v: i32) -> Result<(), Error> { - self.emit_i64(v as i64) - } - fn emit_i64(&mut self, v: i64) -> Result<(), Error> { - self.emit_value(Value::Integer(v)) - } - fn emit_bool(&mut self, v: bool) -> Result<(), Error> { - self.emit_value(Value::Boolean(v)) - } - fn emit_f32(&mut self, v: f32) -> Result<(), Error> { self.emit_f64(v as f64) } - fn emit_f64(&mut self, v: f64) -> Result<(), Error> { - self.emit_value(Value::Float(v)) - } - fn emit_char(&mut self, v: char) -> Result<(), Error> { - self.emit_str(&*format!("{}", v)) - } - fn emit_str(&mut self, v: &str) -> Result<(), Error> { - self.emit_value(Value::String(format!("{}", v))) - } - fn emit_enum<F>(&mut self, _name: &str, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } - fn emit_enum_variant<F>(&mut self, _v_name: &str, _v_id: usize, - _len: usize, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } - fn emit_enum_variant_arg<F>(&mut self, _a_idx: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } - fn emit_enum_struct_variant<F>(&mut self, _v_name: &str, _v_id: usize, - _len: usize, - _f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - panic!() - } - fn emit_enum_struct_variant_field<F>(&mut self, - _f_name: &str, - _f_idx: usize, - _f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - panic!() - } - fn emit_struct<F>(&mut self, _name: &str, _len: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - self.table(f) - } - fn emit_struct_field<F>(&mut self, f_name: &str, _f_idx: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - let old = mem::replace(&mut self.state, - State::NextKey(format!("{}", f_name))); - try!(f(self)); - if self.state != State::Start { - return Err(NoValue) - } - self.state = old; - Ok(()) - } - fn emit_tuple<F>(&mut self, len: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - self.emit_seq(len, f) - } - fn emit_tuple_arg<F>(&mut self, idx: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - self.emit_seq_elt(idx, f) - } - fn emit_tuple_struct<F>(&mut self, _name: &str, _len: usize, _f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - unimplemented!() - } - fn emit_tuple_struct_arg<F>(&mut self, _f_idx: usize, _f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - unimplemented!() - } - fn emit_option<F>(&mut self, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } - fn emit_option_none(&mut self) -> Result<(), Error> { - self.emit_none() - } - fn emit_option_some<F>(&mut self, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } - fn emit_seq<F>(&mut self, _len: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - self.seq(f) - } - fn emit_seq_elt<F>(&mut self, _idx: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } - fn emit_map<F>(&mut self, len: usize, f: F) - -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - self.emit_struct("foo", len, f) - } - fn emit_map_elt_key<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - self.table_key(f) - } - fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> - where F: FnOnce(&mut Encoder) -> Result<(), Error> - { - f(self) - } -} - -impl rustc_serialize::Encodable for Value { - fn encode<E>(&self, e: &mut E) -> Result<(), E::Error> - where E: rustc_serialize::Encoder - { - match *self { - Value::String(ref s) => e.emit_str(s), - Value::Integer(i) => e.emit_i64(i), - Value::Float(f) => e.emit_f64(f), - Value::Boolean(b) => e.emit_bool(b), - Value::Datetime(ref s) => e.emit_str(s), - Value::Array(ref a) => { - e.emit_seq(a.len(), |e| { - for item in a { - try!(item.encode(e)); - } - Ok(()) - }) - } - Value::Table(ref t) => { - e.emit_map(t.len(), |e| { - for (i, (key, value)) in t.iter().enumerate() { - try!(e.emit_map_elt_key(i, |e| e.emit_str(key))); - try!(e.emit_map_elt_val(i, |e| value.encode(e))); - } - Ok(()) - }) - } - } - } -} - -#[cfg(test)] -mod tests { - use std::collections::{BTreeMap, HashSet}; - use rustc_serialize::{self, Encodable, Decodable}; - - use {Encoder, Decoder, DecodeError}; - use Value; - use Value::{Table, Integer, Array, Float}; - - macro_rules! encode( ($t:expr) => ({ - let mut e = Encoder::new(); - $t.encode(&mut e).unwrap(); - e.toml - }) ); - - macro_rules! decode( ($t:expr) => ({ - let mut d = Decoder::new($t); - Decodable::decode(&mut d).unwrap() - }) ); - - macro_rules! map( ($($k:ident, $v:expr),*) => ({ - let mut _m = BTreeMap::new(); - $(_m.insert(stringify!($k).to_string(), $v);)* - _m - }) ); - - #[test] - fn smoke() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: isize } - - let v = Foo { a: 2 }; - assert_eq!(encode!(v), map! { a, Integer(2) }); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn smoke_hyphen() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a_b: isize } - - let v = Foo { a_b: 2 }; - assert_eq!(encode!(v), map! { a_b, Integer(2) }); - assert_eq!(v, decode!(Table(encode!(v)))); - - let mut m = BTreeMap::new(); - m.insert("a-b".to_string(), Integer(2)); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn nested() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: isize, b: Bar } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { a: String } - - let v = Foo { a: 2, b: Bar { a: "test".to_string() } }; - assert_eq!(encode!(v), - map! { - a, Integer(2), - b, Table(map! { - a, Value::String("test".to_string()) - }) - }); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn application_decode_error() { - #[derive(PartialEq, Debug)] - struct Range10(usize); - impl Decodable for Range10 { - fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<Range10, D::Error> { - let x: usize = try!(Decodable::decode(d)); - if x > 10 { - Err(d.error("Value out of range!")) - } else { - Ok(Range10(x)) - } - } - } - let mut d_good = Decoder::new(Integer(5)); - let mut d_bad1 = Decoder::new(Value::String("not an isize".to_string())); - let mut d_bad2 = Decoder::new(Integer(11)); - - assert_eq!(Ok(Range10(5)), Decodable::decode(&mut d_good)); - - let err1: Result<Range10, _> = Decodable::decode(&mut d_bad1); - assert!(err1.is_err()); - let err2: Result<Range10, _> = Decodable::decode(&mut d_bad2); - assert!(err2.is_err()); - } - - #[test] - fn array() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Vec<isize> } - - let v = Foo { a: vec![1, 2, 3, 4] }; - assert_eq!(encode!(v), - map! { - a, Array(vec![ - Integer(1), - Integer(2), - Integer(3), - Integer(4) - ]) - }); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn tuple() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: (isize, isize, isize, isize) } - - let v = Foo { a: (1, 2, 3, 4) }; - assert_eq!(encode!(v), - map! { - a, Array(vec![ - Integer(1), - Integer(2), - Integer(3), - Integer(4) - ]) - }); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn inner_structs_with_options() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { - a: Option<Box<Foo>>, - b: Bar, - } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { - a: String, - b: f64, - } - - let v = Foo { - a: Some(Box::new(Foo { - a: None, - b: Bar { a: "foo".to_string(), b: 4.5 }, - })), - b: Bar { a: "bar".to_string(), b: 1.0 }, - }; - assert_eq!(encode!(v), - map! { - a, Table(map! { - b, Table(map! { - a, Value::String("foo".to_string()), - b, Float(4.5) - }) - }), - b, Table(map! { - a, Value::String("bar".to_string()), - b, Float(1.0) - }) - }); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn hashmap() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { - map: BTreeMap<String, isize>, - set: HashSet<char>, - } - - let v = Foo { - map: { - let mut m = BTreeMap::new(); - m.insert("foo".to_string(), 10); - m.insert("bar".to_string(), 4); - m - }, - set: { - let mut s = HashSet::new(); - s.insert('a'); - s - }, - }; - assert_eq!(encode!(v), - map! { - map, Table(map! { - foo, Integer(10), - bar, Integer(4) - }), - set, Array(vec![Value::String("a".to_string())]) - } - ); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn tuple_struct() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo(isize, String, f64); - - let v = Foo(1, "foo".to_string(), 4.5); - assert_eq!( - encode!(v), - map! { - _field0, Integer(1), - _field1, Value::String("foo".to_string()), - _field2, Float(4.5) - } - ); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn table_array() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Vec<Bar>, } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { a: isize } - - let v = Foo { a: vec![Bar { a: 1 }, Bar { a: 2 }] }; - assert_eq!( - encode!(v), - map! { - a, Array(vec![ - Table(map!{ a, Integer(1) }), - Table(map!{ a, Integer(2) }), - ]) - } - ); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn type_errors() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { bar: isize } - - let mut d = Decoder::new(Table(map! { - bar, Float(1.0) - })); - let a: Result<Foo, DecodeError> = Decodable::decode(&mut d); - match a { - Ok(..) => panic!("should not have decoded"), - Err(e) => { - assert_eq!(format!("{}", e), - "expected a value of type `integer`, but \ - found a value of type `float` for the key `bar`"); - } - } - } - - #[test] - fn missing_errors() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { bar: isize } - - let mut d = Decoder::new(Table(map! { - })); - let a: Result<Foo, DecodeError> = Decodable::decode(&mut d); - match a { - Ok(..) => panic!("should not have decoded"), - Err(e) => { - assert_eq!(format!("{}", e), - "expected a value of type `integer` for the key `bar`"); - } - } - } - - #[test] - fn parse_enum() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: E } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - enum E { - Bar(isize), - Baz(f64), - Last(Foo2), - } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo2 { - test: String, - } - - let v = Foo { a: E::Bar(10) }; - assert_eq!( - encode!(v), - map! { a, Integer(10) } - ); - assert_eq!(v, decode!(Table(encode!(v)))); - - let v = Foo { a: E::Baz(10.2) }; - assert_eq!( - encode!(v), - map! { a, Float(10.2) } - ); - assert_eq!(v, decode!(Table(encode!(v)))); - - let v = Foo { a: E::Last(Foo2 { test: "test".to_string() }) }; - assert_eq!( - encode!(v), - map! { a, Table(map! { test, Value::String("test".to_string()) }) } - ); - assert_eq!(v, decode!(Table(encode!(v)))); - } - - #[test] - fn unused_fields() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: isize } - - let v = Foo { a: 2 }; - let mut d = Decoder::new(Table(map! { - a, Integer(2), - b, Integer(5) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, Some(Table(map! { - b, Integer(5) - }))); - } - - #[test] - fn unused_fields2() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Bar } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { a: isize } - - let v = Foo { a: Bar { a: 2 } }; - let mut d = Decoder::new(Table(map! { - a, Table(map! { - a, Integer(2), - b, Integer(5) - }) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, Some(Table(map! { - a, Table(map! { - b, Integer(5) - }) - }))); - } - - #[test] - fn unused_fields3() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Bar } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { a: isize } - - let v = Foo { a: Bar { a: 2 } }; - let mut d = Decoder::new(Table(map! { - a, Table(map! { - a, Integer(2) - }) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, None); - } - - #[test] - fn unused_fields4() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: BTreeMap<String, String> } - - let v = Foo { a: map! { a, "foo".to_string() } }; - let mut d = Decoder::new(Table(map! { - a, Table(map! { - a, Value::String("foo".to_string()) - }) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, None); - } - - #[test] - fn unused_fields5() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Vec<String> } - - let v = Foo { a: vec!["a".to_string()] }; - let mut d = Decoder::new(Table(map! { - a, Array(vec![Value::String("a".to_string())]) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, None); - } - - #[test] - fn unused_fields6() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Option<Vec<String>> } - - let v = Foo { a: Some(vec![]) }; - let mut d = Decoder::new(Table(map! { - a, Array(vec![]) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, None); - } - - #[test] - fn unused_fields7() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Vec<Bar> } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { a: isize } - - let v = Foo { a: vec![Bar { a: 1 }] }; - let mut d = Decoder::new(Table(map! { - a, Array(vec![Table(map! { - a, Integer(1), - b, Integer(2) - })]) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, Some(Table(map! { - a, Array(vec![Table(map! { - b, Integer(2) - })]) - }))); - } - - #[test] - fn unused_fields8() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: BTreeMap<String, Bar> } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar { a: isize } - - let v = Foo { a: map! { a, Bar { a: 2 } } }; - let mut d = Decoder::new(Table(map! { - a, Table(map! { - a, Table(map! { - a, Integer(2), - b, Integer(2) - }) - }) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - assert_eq!(d.toml, Some(Table(map! { - a, Table(map! { - a, Table(map! { - b, Integer(2) - }) - }) - }))); - } - - #[test] - fn empty_arrays() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Vec<Bar> } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar; - - let v = Foo { a: vec![] }; - let mut d = Decoder::new(Table(map! {})); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - } - - #[test] - fn empty_arrays2() { - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Foo { a: Option<Vec<Bar>> } - #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] - struct Bar; - - let v = Foo { a: None }; - let mut d = Decoder::new(Table(map! {})); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - - let v = Foo { a: Some(vec![]) }; - let mut d = Decoder::new(Table(map! { - a, Array(vec![]) - })); - assert_eq!(v, Decodable::decode(&mut d).unwrap()); - } - - #[test] - fn round_trip() { - let toml = r#" - [test] - foo = "bar" - - [[values]] - foo = "baz" - - [[values]] - foo = "qux" - "#; - - let value: Value = toml.parse().unwrap(); - let val2 = ::encode_str(&value).parse().unwrap(); - assert_eq!(value, val2); - } -} diff --git a/src/vendor/toml/src/encoder/serde.rs b/src/vendor/toml/src/encoder/serde.rs deleted file mode 100644 index d5bbb77a848..00000000000 --- a/src/vendor/toml/src/encoder/serde.rs +++ /dev/null @@ -1,108 +0,0 @@ -use serde::ser; -use Value; -use super::{Encoder, Error}; - -impl ser::Serializer for Encoder { - type Error = Error; - - fn serialize_bool(&mut self, v: bool) -> Result<(), Error> { - self.emit_value(Value::Boolean(v)) - } - fn serialize_i64(&mut self, v: i64) -> Result<(), Error> { - self.emit_value(Value::Integer(v)) - } - fn serialize_u64(&mut self, v: u64) -> Result<(), Error> { - self.serialize_i64(v as i64) - } - fn serialize_f64(&mut self, v: f64) -> Result<(), Error> { - self.emit_value(Value::Float(v)) - } - fn serialize_str(&mut self, value: &str) -> Result<(), Error> { - self.emit_value(Value::String(value.to_string())) - } - fn serialize_unit(&mut self) -> Result<(), Error> { - Ok(()) - } - fn serialize_none(&mut self) -> Result<(), Error> { - self.emit_none() - } - fn serialize_some<V>(&mut self, value: V) -> Result<(), Error> - where V: ser::Serialize - { - value.serialize(self) - } - fn serialize_seq<V>(&mut self, mut visitor: V) -> Result<(), Error> - where V: ser::SeqVisitor - { - self.seq(|me| { - while try!(visitor.visit(me)).is_some() {} - Ok(()) - }) - } - fn serialize_seq_elt<T>(&mut self, value: T) -> Result<(), Error> - where T: ser::Serialize - { - value.serialize(self) - } - fn serialize_map<V>(&mut self, mut visitor: V) -> Result<(), Error> - where V: ser::MapVisitor - { - self.table(|me| { - while try!(visitor.visit(me)).is_some() {} - Ok(()) - }) - } - fn serialize_map_elt<K, V>(&mut self, key: K, value: V) -> Result<(), Error> - where K: ser::Serialize, V: ser::Serialize - { - try!(self.table_key(|me| key.serialize(me))); - try!(value.serialize(self)); - Ok(()) - } - fn serialize_newtype_struct<T>(&mut self, - _name: &'static str, - value: T) -> Result<(), Self::Error> - where T: ser::Serialize, - { - // Don't serialize the newtype struct in a tuple. - value.serialize(self) - } - fn serialize_newtype_variant<T>(&mut self, - _name: &'static str, - _variant_index: usize, - _variant: &'static str, - value: T) -> Result<(), Self::Error> - where T: ser::Serialize, - { - // Don't serialize the newtype struct variant in a tuple. - value.serialize(self) - } -} - -impl ser::Serialize for Value { - fn serialize<E>(&self, e: &mut E) -> Result<(), E::Error> - where E: ser::Serializer - { - match *self { - Value::String(ref s) => e.serialize_str(s), - Value::Integer(i) => e.serialize_i64(i), - Value::Float(f) => e.serialize_f64(f), - Value::Boolean(b) => e.serialize_bool(b), - Value::Datetime(ref s) => e.serialize_str(s), - Value::Array(ref a) => { - e.serialize_seq(ser::impls::SeqIteratorVisitor::new(a.iter(), - Some(a.len()))) - } - Value::Table(ref t) => { - e.serialize_map(ser::impls::MapIteratorVisitor::new(t.iter(), - Some(t.len()))) - } - } - } -} - -impl ser::Error for Error { - fn custom<T: Into<String>>(msg: T) -> Error { - Error::Custom(msg.into()) - } -} diff --git a/src/vendor/toml/src/lib.rs b/src/vendor/toml/src/lib.rs deleted file mode 100644 index 21b3e21ac05..00000000000 --- a/src/vendor/toml/src/lib.rs +++ /dev/null @@ -1,492 +0,0 @@ -//! A TOML-parsing library -//! -//! This library is an implementation in Rust of a parser for TOML configuration -//! files [1]. It is focused around high quality errors including specific spans -//! and detailed error messages when things go wrong. -//! -//! This implementation currently passes the language agnostic [test suite][2]. -//! -//! # Example -//! -//! ``` -//! let toml = r#" -//! [test] -//! foo = "bar" -//! "#; -//! -//! let value = toml::Parser::new(toml).parse().unwrap(); -//! println!("{:?}", value); -//! ``` -//! -//! # Conversions -//! -//! This library also supports using the standard `Encodable` and `Decodable` -//! traits with TOML values. This library provides the following conversion -//! capabilities: -//! -//! * `String` => `toml::Value` - via `Parser` -//! * `toml::Value` => `String` - via `Display` -//! * `toml::Value` => rust object - via `Decoder` -//! * rust object => `toml::Value` - via `Encoder` -//! -//! Convenience functions for performing multiple conversions at a time are also -//! provided. -//! -//! [1]: https://github.com/mojombo/toml -//! [2]: https://github.com/BurntSushi/toml-test - -#![doc(html_root_url = "http://alexcrichton.com/toml-rs")] -#![deny(missing_docs)] -#![cfg_attr(test, deny(warnings))] - -#[cfg(feature = "rustc-serialize")] extern crate rustc_serialize; -#[cfg(feature = "serde")] extern crate serde; - -use std::collections::BTreeMap; -use std::str::FromStr; - -pub use parser::{Parser, ParserError}; - -#[cfg(any(feature = "rustc-serialize", feature = "serde"))] -pub use self::encoder::{Encoder, Error, encode, encode_str}; -#[cfg(any(feature = "rustc-serialize", feature = "serde"))] -pub use self::decoder::{Decoder, DecodeError, DecodeErrorKind, decode, decode_str}; - -mod parser; -mod display; -#[cfg(any(feature = "rustc-serialize", feature = "serde"))] -mod encoder; -#[cfg(any(feature = "rustc-serialize", feature = "serde"))] -mod decoder; - -/// Representation of a TOML value. -#[derive(PartialEq, Clone, Debug)] -#[allow(missing_docs)] -pub enum Value { - String(String), - Integer(i64), - Float(f64), - Boolean(bool), - Datetime(String), - Array(Array), - Table(Table), -} - -/// Type representing a TOML array, payload of the Value::Array variant -pub type Array = Vec<Value>; - -/// Type representing a TOML table, payload of the Value::Table variant -pub type Table = BTreeMap<String, Value>; - -impl Value { - /// Tests whether this and another value have the same type. - pub fn same_type(&self, other: &Value) -> bool { - match (self, other) { - (&Value::String(..), &Value::String(..)) | - (&Value::Integer(..), &Value::Integer(..)) | - (&Value::Float(..), &Value::Float(..)) | - (&Value::Boolean(..), &Value::Boolean(..)) | - (&Value::Datetime(..), &Value::Datetime(..)) | - (&Value::Array(..), &Value::Array(..)) | - (&Value::Table(..), &Value::Table(..)) => true, - - _ => false, - } - } - - /// Returns a human-readable representation of the type of this value. - pub fn type_str(&self) -> &'static str { - match *self { - Value::String(..) => "string", - Value::Integer(..) => "integer", - Value::Float(..) => "float", - Value::Boolean(..) => "boolean", - Value::Datetime(..) => "datetime", - Value::Array(..) => "array", - Value::Table(..) => "table", - } - } - - /// Extracts the string of this value if it is a string. - pub fn as_str(&self) -> Option<&str> { - match *self { Value::String(ref s) => Some(&**s), _ => None } - } - - /// Extracts the integer value if it is an integer. - pub fn as_integer(&self) -> Option<i64> { - match *self { Value::Integer(i) => Some(i), _ => None } - } - - /// Extracts the float value if it is a float. - pub fn as_float(&self) -> Option<f64> { - match *self { Value::Float(f) => Some(f), _ => None } - } - - /// Extracts the boolean value if it is a boolean. - pub fn as_bool(&self) -> Option<bool> { - match *self { Value::Boolean(b) => Some(b), _ => None } - } - - /// Extracts the datetime value if it is a datetime. - /// - /// Note that a parsed TOML value will only contain ISO 8601 dates. An - /// example date is: - /// - /// ```notrust - /// 1979-05-27T07:32:00Z - /// ``` - pub fn as_datetime(&self) -> Option<&str> { - match *self { Value::Datetime(ref s) => Some(&**s), _ => None } - } - - /// Extracts the array value if it is an array. - pub fn as_slice(&self) -> Option<&[Value]> { - match *self { Value::Array(ref s) => Some(&**s), _ => None } - } - - /// Extracts the table value if it is a table. - pub fn as_table(&self) -> Option<&Table> { - match *self { Value::Table(ref s) => Some(s), _ => None } - } - - /// Lookups for value at specified path. - /// - /// Uses '.' as a path separator. - /// - /// Note: arrays have zero-based indexes. - /// - /// Note: empty path returns self. - /// - /// ``` - /// # #![allow(unstable)] - /// let toml = r#" - /// [test] - /// foo = "bar" - /// - /// [[values]] - /// foo = "baz" - /// - /// [[values]] - /// foo = "qux" - /// "#; - /// let value: toml::Value = toml.parse().unwrap(); - /// - /// let foo = value.lookup("test.foo").unwrap(); - /// assert_eq!(foo.as_str().unwrap(), "bar"); - /// - /// let foo = value.lookup("values.1.foo").unwrap(); - /// assert_eq!(foo.as_str().unwrap(), "qux"); - /// - /// let no_bar = value.lookup("test.bar"); - /// assert_eq!(no_bar.is_none(), true); - /// ``` - pub fn lookup<'a>(&'a self, path: &'a str) -> Option<&'a Value> { - let ref path = match Parser::new(path).lookup() { - Some(path) => path, - None => return None, - }; - let mut cur_value = self; - if path.len() == 0 { - return Some(cur_value) - } - - for key in path { - match *cur_value { - Value::Table(ref hm) => { - match hm.get(key) { - Some(v) => cur_value = v, - None => return None - } - }, - Value::Array(ref v) => { - match key.parse::<usize>().ok() { - Some(idx) if idx < v.len() => cur_value = &v[idx], - _ => return None - } - }, - _ => return None - } - }; - - Some(cur_value) - - } - /// Lookups for mutable value at specified path. - /// - /// Uses '.' as a path separator. - /// - /// Note: arrays have zero-based indexes. - /// - /// Note: empty path returns self. - /// - /// ``` - /// # #![allow(unstable)] - /// let toml = r#" - /// [test] - /// foo = "bar" - /// - /// [[values]] - /// foo = "baz" - /// - /// [[values]] - /// foo = "qux" - /// "#; - /// let mut value: toml::Value = toml.parse().unwrap(); - /// { - /// let string = value.lookup_mut("test.foo").unwrap(); - /// assert_eq!(string, &mut toml::Value::String(String::from("bar"))); - /// *string = toml::Value::String(String::from("foo")); - /// } - /// let result = value.lookup_mut("test.foo").unwrap(); - /// assert_eq!(result.as_str().unwrap(), "foo"); - /// ``` - pub fn lookup_mut(&mut self, path: &str) -> Option<&mut Value> { - let ref path = match Parser::new(path).lookup() { - Some(path) => path, - None => return None, - }; - - let mut cur = self; - if path.len() == 0 { - return Some(cur) - } - - for key in path { - let tmp = cur; - match *tmp { - Value::Table(ref mut hm) => { - match hm.get_mut(key) { - Some(v) => cur = v, - None => return None - } - } - Value::Array(ref mut v) => { - match key.parse::<usize>().ok() { - Some(idx) if idx < v.len() => cur = &mut v[idx], - _ => return None - } - } - _ => return None - } - } - Some(cur) - } -} - -impl FromStr for Value { - type Err = Vec<ParserError>; - fn from_str(s: &str) -> Result<Value, Vec<ParserError>> { - let mut p = Parser::new(s); - match p.parse().map(Value::Table) { - Some(n) => Ok(n), - None => Err(p.errors), - } - } -} - -#[cfg(test)] -mod tests { - use super::Value; - - #[test] - fn lookup_mut_change() { - let toml = r#" - [test] - foo = "bar" - - [[values]] - foo = "baz" - - [[values]] - foo = "qux" - "#; - - let mut value: Value = toml.parse().unwrap(); - { - let foo = value.lookup_mut("values.0.foo").unwrap(); - *foo = Value::String(String::from("bar")); - } - let foo = value.lookup("values.0.foo").unwrap(); - assert_eq!(foo.as_str().unwrap(), "bar"); - } - - #[test] - fn lookup_mut_valid() { - let toml = r#" - [test] - foo = "bar" - - [[values]] - foo = "baz" - - [[values]] - foo = "qux" - "#; - - let mut value: Value = toml.parse().unwrap(); - - { - let test_foo = value.lookup_mut("test.foo").unwrap(); - assert_eq!(test_foo.as_str().unwrap(), "bar"); - } - - { - let foo1 = value.lookup_mut("values.1.foo").unwrap(); - assert_eq!(foo1.as_str().unwrap(), "qux"); - } - - assert!(value.lookup_mut("test.bar").is_none()); - assert!(value.lookup_mut("test.foo.bar").is_none()); - } - - #[test] - fn lookup_mut_invalid_index() { - let toml = r#" - [[values]] - foo = "baz" - "#; - - let mut value: Value = toml.parse().unwrap(); - - { - let foo = value.lookup_mut("test.foo"); - assert!(foo.is_none()); - } - - { - let foo = value.lookup_mut("values.100.foo"); - assert!(foo.is_none()); - } - - { - let foo = value.lookup_mut("values.str.foo"); - assert!(foo.is_none()); - } - } - - #[test] - fn lookup_mut_self() { - let mut value: Value = r#"foo = "bar""#.parse().unwrap(); - - { - let foo = value.lookup_mut("foo").unwrap(); - assert_eq!(foo.as_str().unwrap(), "bar"); - } - - let foo = value.lookup_mut("").unwrap(); - assert!(foo.as_table().is_some()); - - let baz = foo.lookup_mut("foo").unwrap(); - assert_eq!(baz.as_str().unwrap(), "bar"); - } - - #[test] - fn lookup_valid() { - let toml = r#" - [test] - foo = "bar" - - [[values]] - foo = "baz" - - [[values]] - foo = "qux" - "#; - - let value: Value = toml.parse().unwrap(); - - let test_foo = value.lookup("test.foo").unwrap(); - assert_eq!(test_foo.as_str().unwrap(), "bar"); - - let foo1 = value.lookup("values.1.foo").unwrap(); - assert_eq!(foo1.as_str().unwrap(), "qux"); - - assert!(value.lookup("test.bar").is_none()); - assert!(value.lookup("test.foo.bar").is_none()); - } - - #[test] - fn lookup_invalid_index() { - let toml = r#" - [[values]] - foo = "baz" - "#; - - let value: Value = toml.parse().unwrap(); - - let foo = value.lookup("test.foo"); - assert!(foo.is_none()); - - let foo = value.lookup("values.100.foo"); - assert!(foo.is_none()); - - let foo = value.lookup("values.str.foo"); - assert!(foo.is_none()); - } - - #[test] - fn lookup_self() { - let value: Value = r#"foo = "bar""#.parse().unwrap(); - - let foo = value.lookup("foo").unwrap(); - assert_eq!(foo.as_str().unwrap(), "bar"); - - let foo = value.lookup("").unwrap(); - assert!(foo.as_table().is_some()); - - let baz = foo.lookup("foo").unwrap(); - assert_eq!(baz.as_str().unwrap(), "bar"); - } - - #[test] - fn lookup_advanced() { - let value: Value = "[table]\n\"value\" = 0".parse().unwrap(); - let looked = value.lookup("table.\"value\"").unwrap(); - assert_eq!(*looked, Value::Integer(0)); - } - - #[test] - fn lookup_advanced_table() { - let value: Value = "[table.\"name.other\"]\nvalue = \"my value\"".parse().unwrap(); - let looked = value.lookup(r#"table."name.other".value"#).unwrap(); - assert_eq!(*looked, Value::String(String::from("my value"))); - } - - #[test] - fn lookup_mut_advanced() { - let mut value: Value = "[table]\n\"value\" = [0, 1, 2]".parse().unwrap(); - let looked = value.lookup_mut("table.\"value\".1").unwrap(); - assert_eq!(*looked, Value::Integer(1)); - } - - #[test] - fn single_dot() { - let value: Value = "[table]\n\"value\" = [0, 1, 2]".parse().unwrap(); - assert_eq!(None, value.lookup(".")); - } - - #[test] - fn array_dot() { - let value: Value = "[table]\n\"value\" = [0, 1, 2]".parse().unwrap(); - assert_eq!(None, value.lookup("0.")); - } - - #[test] - fn dot_inside() { - let value: Value = "[table]\n\"value\" = [0, 1, 2]".parse().unwrap(); - assert_eq!(None, value.lookup("table.\"value.0\"")); - } - - #[test] - fn table_with_quotes() { - let value: Value = "[table.\"element\"]\n\"value\" = [0, 1, 2]".parse().unwrap(); - assert_eq!(None, value.lookup("\"table.element\".\"value\".0")); - } - - #[test] - fn table_with_quotes_2() { - let value: Value = "[table.\"element\"]\n\"value\" = [0, 1, 2]".parse().unwrap(); - assert_eq!(Value::Integer(0), *value.lookup("table.\"element\".\"value\".0").unwrap()); - } - -} diff --git a/src/vendor/toml/src/parser.rs b/src/vendor/toml/src/parser.rs deleted file mode 100644 index 8fa2d77acc4..00000000000 --- a/src/vendor/toml/src/parser.rs +++ /dev/null @@ -1,1581 +0,0 @@ -use std::char; -use std::collections::BTreeMap; -use std::error::Error; -use std::fmt; -use std::str; - -macro_rules! try { - ($e:expr) => (match $e { Some(s) => s, None => return None }) -} - -// We redefine Value because we need to keep track of encountered table -// definitions, eg when parsing: -// -// [a] -// [a.b] -// [a] -// -// we have to error out on redefinition of [a]. This bit of data is difficult to -// track in a side table so we just have a "stripped down" AST to work with -// which has the relevant metadata fields in it. -struct TomlTable { - values: BTreeMap<String, Value>, - defined: bool, -} - -impl TomlTable { - fn convert(self) -> super::Table { - self.values.into_iter().map(|(k,v)| (k, v.convert())).collect() - } -} - -enum Value { - String(String), - Integer(i64), - Float(f64), - Boolean(bool), - Datetime(String), - Array(Vec<Value>), - Table(TomlTable), -} - -impl Value { - fn type_str(&self) -> &'static str { - match *self { - Value::String(..) => "string", - Value::Integer(..) => "integer", - Value::Float(..) => "float", - Value::Boolean(..) => "boolean", - Value::Datetime(..) => "datetime", - Value::Array(..) => "array", - Value::Table(..) => "table", - } - } - - fn same_type(&self, other: &Value) -> bool { - match (self, other) { - (&Value::String(..), &Value::String(..)) | - (&Value::Integer(..), &Value::Integer(..)) | - (&Value::Float(..), &Value::Float(..)) | - (&Value::Boolean(..), &Value::Boolean(..)) | - (&Value::Datetime(..), &Value::Datetime(..)) | - (&Value::Array(..), &Value::Array(..)) | - (&Value::Table(..), &Value::Table(..)) => true, - - _ => false, - } - } - - fn convert(self) -> super::Value { - match self { - Value::String(x) => super::Value::String(x), - Value::Integer(x) => super::Value::Integer(x), - Value::Float(x) => super::Value::Float(x), - Value::Boolean(x) => super::Value::Boolean(x), - Value::Datetime(x) => super::Value::Datetime(x), - Value::Array(v) => - super::Value::Array( - v.into_iter().map(|x| x.convert()).collect() - ), - Value::Table(t) => super::Value::Table(t.convert()) - } - } -} - -/// Parser for converting a string to a TOML `Value` instance. -/// -/// This parser contains the string slice that is being parsed, and exports the -/// list of errors which have occurred during parsing. -pub struct Parser<'a> { - input: &'a str, - cur: str::CharIndices<'a>, - require_newline_after_table: bool, - - /// A list of all errors which have occurred during parsing. - /// - /// Not all parse errors are fatal, so this list is added to as much as - /// possible without aborting parsing. If `None` is returned by `parse`, it - /// is guaranteed that this list is not empty. - pub errors: Vec<ParserError>, -} - -/// A structure representing a parse error. -/// -/// The data in this structure can be used to trace back to the original cause -/// of the error in order to provide diagnostics about parse errors. -#[derive(Debug, Clone)] -pub struct ParserError { - /// The low byte at which this error is pointing at. - pub lo: usize, - /// One byte beyond the last character at which this error is pointing at. - pub hi: usize, - /// A human-readable description explaining what the error is. - pub desc: String, -} - -impl<'a> Parser<'a> { - /// Creates a new parser for a string. - /// - /// The parser can be executed by invoking the `parse` method. - /// - /// # Example - /// - /// ``` - /// let toml = r#" - /// [test] - /// foo = "bar" - /// "#; - /// - /// let mut parser = toml::Parser::new(toml); - /// match parser.parse() { - /// Some(value) => println!("found toml: {:?}", value), - /// None => { - /// println!("parse errors: {:?}", parser.errors); - /// } - /// } - /// ``` - pub fn new(s: &'a str) -> Parser<'a> { - Parser { - input: s, - cur: s.char_indices(), - errors: Vec::new(), - require_newline_after_table: true, - } - } - - /// Converts a byte offset from an error message to a (line, column) pair - /// - /// All indexes are 0-based. - pub fn to_linecol(&self, offset: usize) -> (usize, usize) { - let mut cur = 0; - for (i, line) in self.input.lines().enumerate() { - if cur + line.len() + 1 > offset { - return (i, offset - cur) - } - cur += line.len() + 1; - } - (self.input.lines().count(), 0) - } - - /// Historical versions of toml-rs accidentally allowed a newline after a - /// table definition, but the TOML spec requires a newline after a table - /// definition header. - /// - /// This option can be set to `false` (the default is `true`) to emulate - /// this behavior for backwards compatibility with older toml-rs versions. - pub fn set_require_newline_after_table(&mut self, require: bool) { - self.require_newline_after_table = require; - } - - fn next_pos(&self) -> usize { - self.cur.clone().next().map(|p| p.0).unwrap_or(self.input.len()) - } - - // Returns true and consumes the next character if it matches `ch`, - // otherwise do nothing and return false - fn eat(&mut self, ch: char) -> bool { - match self.peek(0) { - Some((_, c)) if c == ch => { self.cur.next(); true } - Some(_) | None => false, - } - } - - // Peeks ahead `n` characters - fn peek(&self, n: usize) -> Option<(usize, char)> { - self.cur.clone().skip(n).next() - } - - fn expect(&mut self, ch: char) -> bool { - if self.eat(ch) { return true } - let mut it = self.cur.clone(); - let lo = it.next().map(|p| p.0).unwrap_or(self.input.len()); - let hi = it.next().map(|p| p.0).unwrap_or(self.input.len()); - self.errors.push(ParserError { - lo: lo, - hi: hi, - desc: match self.cur.clone().next() { - Some((_, c)) => format!("expected `{}`, but found `{}`", ch, c), - None => format!("expected `{}`, but found eof", ch) - } - }); - false - } - - // Consumes a BOM (Byte Order Mark) if one is next - fn bom(&mut self) -> bool { - match self.peek(0) { - Some((_, '\u{feff}')) => { self.cur.next(); true } - _ => false - } - } - - // Consumes whitespace ('\t' and ' ') until another character (or EOF) is - // reached. Returns if any whitespace was consumed - fn ws(&mut self) -> bool { - let mut ret = false; - loop { - match self.peek(0) { - Some((_, '\t')) | - Some((_, ' ')) => { self.cur.next(); ret = true; } - _ => break, - } - } - ret - } - - // Consumes the rest of the line after a comment character - fn comment(&mut self) -> bool { - if !self.eat('#') { return false } - for (_, ch) in self.cur.by_ref() { - if ch == '\n' { break } - } - true - } - - // Consumes a newline if one is next - fn newline(&mut self) -> bool { - match self.peek(0) { - Some((_, '\n')) => { self.cur.next(); true } - Some((_, '\r')) if self.peek(1).map(|c| c.1) == Some('\n') => { - self.cur.next(); self.cur.next(); true - } - _ => false - } - } - - /// Executes the parser, parsing the string contained within. - /// - /// This function will return the `TomlTable` instance if parsing is - /// successful, or it will return `None` if any parse error or invalid TOML - /// error occurs. - /// - /// If an error occurs, the `errors` field of this parser can be consulted - /// to determine the cause of the parse failure. - pub fn parse(&mut self) -> Option<super::Table> { - let mut ret = TomlTable { values: BTreeMap::new(), defined: false }; - self.bom(); - while self.peek(0).is_some() { - self.ws(); - if self.newline() { continue } - if self.comment() { continue } - if self.eat('[') { - let array = self.eat('['); - let start = self.next_pos(); - - // Parse the name of the section - let mut keys = Vec::new(); - loop { - self.ws(); - if let Some(s) = self.key_name() { - keys.push(s); - } - self.ws(); - if self.eat(']') { - if array && !self.expect(']') { return None } - break - } - if !self.expect('.') { return None } - } - if keys.is_empty() { return None } - - // Build the section table - let mut table = TomlTable { - values: BTreeMap::new(), - defined: true, - }; - if self.require_newline_after_table { - self.ws(); - if !self.comment() && !self.newline() { - self.errors.push(ParserError { - lo: start, - hi: start, - desc: format!("expected a newline after table definition"), - }); - return None - } - } - if !self.values(&mut table) { return None } - if array { - self.insert_array(&mut ret, &keys, Value::Table(table), - start) - } else { - self.insert_table(&mut ret, &keys, table, start) - } - } else { - if !self.values(&mut ret) { return None } - } - } - if !self.errors.is_empty() { - None - } else { - Some(ret.convert()) - } - } - - // Parse an array index as a natural number - fn array_index(&mut self) -> Option<String> { - self.integer(0, false, false) - } - - /// Parse a path into a vector of paths - pub fn lookup(&mut self) -> Option<Vec<String>> { - if self.input.len() == 0 { - return Some(vec![]); - } - let mut keys = Vec::new(); - loop { - self.ws(); - if let Some(s) = self.key_name() { - keys.push(s); - } else if let Some(s) = self.array_index() { - keys.push(s); - } else { - return None - } - self.ws(); - if !self.expect('.') { return Some(keys) } - } - } - - // Parse a single key name starting at `start` - fn key_name(&mut self) -> Option<String> { - let start = self.next_pos(); - let key = if self.eat('"') { - self.finish_basic_string(start, false) - } else if self.eat('\'') { - self.finish_literal_string(start, false) - } else { - let mut ret = String::new(); - while let Some((_, ch)) = self.cur.clone().next() { - match ch { - 'a' ... 'z' | - 'A' ... 'Z' | - '0' ... '9' | - '_' | '-' => { self.cur.next(); ret.push(ch) } - _ => break, - } - } - Some(ret) - }; - match key { - Some(ref name) if name.is_empty() => { - self.errors.push(ParserError { - lo: start, - hi: start, - desc: format!("expected a key but found an empty string"), - }); - None - } - Some(name) => Some(name), - None => None, - } - } - - // Parses the values into the given TomlTable. Returns true in case of success - // and false in case of error. - fn values(&mut self, into: &mut TomlTable) -> bool { - loop { - self.ws(); - if self.newline() { continue } - if self.comment() { continue } - match self.peek(0) { - Some((_, '[')) => break, - Some(..) => {} - None => break, - } - let key_lo = self.next_pos(); - let key = match self.key_name() { - Some(s) => s, - None => return false - }; - if !self.keyval_sep() { return false } - let value = match self.value() { - Some(value) => value, - None => return false, - }; - self.insert(into, key, value, key_lo); - self.ws(); - self.comment(); - self.newline(); - } - true - } - - fn keyval_sep(&mut self) -> bool { - self.ws(); - if !self.expect('=') { return false } - self.ws(); - true - } - - // Parses a value - fn value(&mut self) -> Option<Value> { - self.ws(); - match self.cur.clone().next() { - Some((pos, '"')) => self.basic_string(pos), - Some((pos, '\'')) => self.literal_string(pos), - Some((pos, 't')) | - Some((pos, 'f')) => self.boolean(pos), - Some((pos, '[')) => self.array(pos), - Some((pos, '{')) => self.inline_table(pos), - Some((pos, '-')) | - Some((pos, '+')) => self.number_or_datetime(pos), - Some((pos, ch)) if is_digit(ch) => self.number_or_datetime(pos), - _ => { - let mut it = self.cur.clone(); - let lo = it.next().map(|p| p.0).unwrap_or(self.input.len()); - let hi = it.next().map(|p| p.0).unwrap_or(self.input.len()); - self.errors.push(ParserError { - lo: lo, - hi: hi, - desc: format!("expected a value"), - }); - None - } - } - } - - // Parses a single or multi-line string - fn basic_string(&mut self, start: usize) -> Option<Value> { - if !self.expect('"') { return None } - let mut multiline = false; - - // detect multiline literals, but be careful about empty "" - // strings - if self.eat('"') { - if self.eat('"') { - multiline = true; - self.newline(); - } else { - // empty - return Some(Value::String(String::new())) - } - } - - self.finish_basic_string(start, multiline).map(Value::String) - } - - // Finish parsing a basic string after the opening quote has been seen - fn finish_basic_string(&mut self, - start: usize, - multiline: bool) -> Option<String> { - let mut ret = String::new(); - loop { - while multiline && self.newline() { ret.push('\n') } - match self.cur.next() { - Some((_, '"')) => { - if multiline { - if !self.eat('"') { ret.push_str("\""); continue } - if !self.eat('"') { ret.push_str("\"\""); continue } - } - return Some(ret) - } - Some((pos, '\\')) => { - if let Some(c) = escape(self, pos, multiline) { - ret.push(c); - } - } - Some((pos, ch)) if ch < '\u{1f}' => { - self.errors.push(ParserError { - lo: pos, - hi: pos + 1, - desc: format!("control character `{}` must be escaped", - ch.escape_default().collect::<String>()) - }); - } - Some((_, ch)) => ret.push(ch), - None => { - self.errors.push(ParserError { - lo: start, - hi: self.input.len(), - desc: format!("unterminated string literal"), - }); - return None - } - } - } - - fn escape(me: &mut Parser, pos: usize, multiline: bool) -> Option<char> { - if multiline && me.newline() { - while me.ws() || me.newline() { /* ... */ } - return None - } - match me.cur.next() { - Some((_, 'b')) => Some('\u{8}'), - Some((_, 't')) => Some('\u{9}'), - Some((_, 'n')) => Some('\u{a}'), - Some((_, 'f')) => Some('\u{c}'), - Some((_, 'r')) => Some('\u{d}'), - Some((_, '"')) => Some('\u{22}'), - Some((_, '\\')) => Some('\u{5c}'), - Some((pos, c @ 'u')) | - Some((pos, c @ 'U')) => { - let len = if c == 'u' {4} else {8}; - let num = &me.input[pos+1..]; - let num = if num.char_indices().nth(len).map(|(i, _)| i).unwrap_or(0) == len { - &num[..len] - } else { - "invalid" - }; - if let Some(n) = u32::from_str_radix(num, 16).ok() { - if let Some(c) = char::from_u32(n) { - me.cur.by_ref().skip(len - 1).next(); - return Some(c) - } else { - me.errors.push(ParserError { - lo: pos + 1, - hi: pos + 5, - desc: format!("codepoint `{:x}` is \ - not a valid unicode \ - codepoint", n), - }) - } - } else { - me.errors.push(ParserError { - lo: pos, - hi: pos + 1, - desc: format!("expected {} hex digits \ - after a `{}` escape", len, c), - }) - } - None - } - Some((pos, ch)) => { - let next_pos = me.next_pos(); - me.errors.push(ParserError { - lo: pos, - hi: next_pos, - desc: format!("unknown string escape: `{}`", - ch.escape_default().collect::<String>()), - }); - None - } - None => { - me.errors.push(ParserError { - lo: pos, - hi: pos + 1, - desc: format!("unterminated escape sequence"), - }); - None - } - } - } - } - - fn literal_string(&mut self, start: usize) -> Option<Value> { - if !self.expect('\'') { return None } - let mut multiline = false; - - // detect multiline literals - if self.eat('\'') { - if self.eat('\'') { - multiline = true; - self.newline(); - } else { - return Some(Value::String(String::new())) // empty - } - } - - self.finish_literal_string(start, multiline).map(Value::String) - } - - fn finish_literal_string(&mut self, start: usize, multiline: bool) - -> Option<String> { - let mut ret = String::new(); - loop { - if !multiline && self.newline() { - let next = self.next_pos(); - self.errors.push(ParserError { - lo: start, - hi: next, - desc: format!("literal strings cannot contain newlines"), - }); - return None - } - match self.cur.next() { - Some((_, '\'')) => { - if multiline { - if !self.eat('\'') { ret.push_str("'"); continue } - if !self.eat('\'') { ret.push_str("''"); continue } - } - return Some(ret) - } - Some((_, ch)) => ret.push(ch), - None => { - self.errors.push(ParserError { - lo: start, - hi: self.input.len(), - desc: format!("unterminated string literal"), - }); - return None - } - } - } - } - - fn number_or_datetime(&mut self, start: usize) -> Option<Value> { - let mut is_float = false; - let prefix = try!(self.integer(start, false, true)); - let decimal = if self.eat('.') { - is_float = true; - Some(try!(self.integer(start, true, false))) - } else { - None - }; - let exponent = if self.eat('e') || self.eat('E') { - is_float = true; - Some(try!(self.integer(start, false, true))) - } else { - None - }; - let end = self.next_pos(); - let input = &self.input[start..end]; - let ret = if decimal.is_none() && - exponent.is_none() && - !input.starts_with("+") && - !input.starts_with("-") && - start + 4 == end && - self.eat('-') { - self.datetime(start) - } else { - let input = match (decimal, exponent) { - (None, None) => prefix, - (Some(ref d), None) => prefix + "." + d, - (None, Some(ref e)) => prefix + "E" + e, - (Some(ref d), Some(ref e)) => prefix + "." + d + "E" + e, - }; - let input = input.trim_left_matches('+'); - if is_float { - input.parse().ok().map(Value::Float) - } else { - input.parse().ok().map(Value::Integer) - } - }; - if ret.is_none() { - self.errors.push(ParserError { - lo: start, - hi: end, - desc: format!("invalid numeric literal"), - }); - } - ret - } - - fn integer(&mut self, - start: usize, - allow_leading_zeros: bool, - allow_sign: bool) -> Option<String> { - let mut s = String::new(); - if allow_sign { - if self.eat('-') { s.push('-'); } - else if self.eat('+') { s.push('+'); } - } - match self.cur.next() { - Some((_, '0')) if !allow_leading_zeros => { - s.push('0'); - match self.peek(0) { - Some((pos, c)) if '0' <= c && c <= '9' => { - self.errors.push(ParserError { - lo: start, - hi: pos, - desc: format!("leading zeroes are not allowed"), - }); - return None - } - _ => {} - } - } - Some((_, ch)) if '0' <= ch && ch <= '9' => { - s.push(ch); - } - _ => { - let pos = self.next_pos(); - self.errors.push(ParserError { - lo: pos, - hi: pos, - desc: format!("expected start of a numeric literal"), - }); - return None; - } - } - let mut underscore = false; - loop { - match self.cur.clone().next() { - Some((_, ch)) if '0' <= ch && ch <= '9' => { - s.push(ch); - self.cur.next(); - underscore = false; - } - Some((_, '_')) if !underscore => { - self.cur.next(); - underscore = true; - } - Some(_) | None => break, - } - } - if underscore { - let pos = self.next_pos(); - self.errors.push(ParserError { - lo: pos, - hi: pos, - desc: format!("numeral cannot end with an underscore"), - }); - None - } else { - Some(s) - } - } - - fn boolean(&mut self, start: usize) -> Option<Value> { - let rest = &self.input[start..]; - if rest.starts_with("true") { - for _ in 0..4 { - self.cur.next(); - } - Some(Value::Boolean(true)) - } else if rest.starts_with("false") { - for _ in 0..5 { - self.cur.next(); - } - Some(Value::Boolean(false)) - } else { - let next = self.next_pos(); - self.errors.push(ParserError { - lo: start, - hi: next, - desc: format!("unexpected character: `{}`", - rest.chars().next().unwrap()), - }); - None - } - } - - fn datetime(&mut self, start: usize) -> Option<Value> { - // Up to `start` already contains the year, and we've eaten the next - // `-`, so we just resume parsing from there. - - let mut valid = true; - - // month - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - - // day - valid = valid && self.cur.next().map(|c| c.1) == Some('-'); - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - - valid = valid && self.cur.next().map(|c| c.1) == Some('T'); - - // hour - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - - // minute - valid = valid && self.cur.next().map(|c| c.1) == Some(':'); - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - - // second - valid = valid && self.cur.next().map(|c| c.1) == Some(':'); - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - - // fractional seconds - if self.eat('.') { - valid = valid && digit(self.cur.next()); - loop { - match self.cur.clone().next() { - Some((_, c)) if is_digit(c) => { - self.cur.next(); - } - _ => break, - } - } - } - - // time zone - if !self.eat('Z') { - valid = valid && (self.eat('+') || self.eat('-')); - - // hour - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - - // minute - valid = valid && self.cur.next().map(|c| c.1) == Some(':'); - valid = valid && digit(self.cur.next()); - valid = valid && digit(self.cur.next()); - } - - return if valid { - Some(Value::Datetime(self.input[start..self.next_pos()].to_string())) - } else { - let next = self.next_pos(); - self.errors.push(ParserError { - lo: start, - hi: start + next, - desc: format!("malformed date literal"), - }); - None - }; - - fn digit(val: Option<(usize, char)>) -> bool { - match val { - Some((_, c)) => is_digit(c), - None => false, - } - } - } - - fn array(&mut self, _start: usize) -> Option<Value> { - if !self.expect('[') { return None } - let mut ret = Vec::new(); - fn consume(me: &mut Parser) { - loop { - me.ws(); - if !me.newline() && !me.comment() { break } - } - } - let mut type_str = None; - loop { - // Break out early if we see the closing bracket - consume(self); - if self.eat(']') { return Some(Value::Array(ret)) } - - // Attempt to parse a value, triggering an error if it's the wrong - // type. - let start = self.next_pos(); - let value = try!(self.value()); - let end = self.next_pos(); - let expected = type_str.unwrap_or(value.type_str()); - if value.type_str() != expected { - self.errors.push(ParserError { - lo: start, - hi: end, - desc: format!("expected type `{}`, found type `{}`", - expected, value.type_str()), - }); - } else { - type_str = Some(expected); - ret.push(value); - } - - // Look for a comma. If we don't find one we're done - consume(self); - if !self.eat(',') { break } - } - consume(self); - if !self.expect(']') { return None } - Some(Value::Array(ret)) - } - - fn inline_table(&mut self, _start: usize) -> Option<Value> { - if !self.expect('{') { return None } - self.ws(); - let mut ret = TomlTable { values: BTreeMap::new(), defined: true }; - if self.eat('}') { return Some(Value::Table(ret)) } - loop { - let lo = self.next_pos(); - let key = try!(self.key_name()); - if !self.keyval_sep() { return None } - let value = try!(self.value()); - self.insert(&mut ret, key, value, lo); - - self.ws(); - if self.eat('}') { break } - if !self.expect(',') { return None } - self.ws(); - } - Some(Value::Table(ret)) - } - - fn insert(&mut self, into: &mut TomlTable, key: String, value: Value, - key_lo: usize) { - if into.values.contains_key(&key) { - self.errors.push(ParserError { - lo: key_lo, - hi: key_lo + key.len(), - desc: format!("duplicate key: `{}`", key), - }) - } else { - into.values.insert(key, value); - } - } - - fn recurse<'b>(&mut self, mut cur: &'b mut TomlTable, keys: &'b [String], - key_lo: usize) -> Option<(&'b mut TomlTable, &'b str)> { - let key_hi = keys.iter().fold(0, |a, b| a + b.len()); - for part in keys[..keys.len() - 1].iter() { - let tmp = cur; - - if tmp.values.contains_key(part) { - match *tmp.values.get_mut(part).unwrap() { - Value::Table(ref mut table) => cur = table, - Value::Array(ref mut array) => { - match array.last_mut() { - Some(&mut Value::Table(ref mut table)) => cur = table, - _ => { - self.errors.push(ParserError { - lo: key_lo, - hi: key_hi, - desc: format!("array `{}` does not contain \ - tables", part) - }); - return None - } - } - } - _ => { - self.errors.push(ParserError { - lo: key_lo, - hi: key_hi, - desc: format!("key `{}` was not previously a table", - part) - }); - return None - } - } - continue - } - - // Initialize an empty table as part of this sub-key - tmp.values.insert(part.clone(), Value::Table(TomlTable { - values: BTreeMap::new(), - defined: false, - })); - match *tmp.values.get_mut(part).unwrap() { - Value::Table(ref mut inner) => cur = inner, - _ => unreachable!(), - } - } - Some((cur, &**keys.last().unwrap())) - } - - fn insert_table(&mut self, into: &mut TomlTable, keys: &[String], - table: TomlTable, key_lo: usize) { - let (into, key) = match self.recurse(into, keys, key_lo) { - Some(pair) => pair, - None => return, - }; - if !into.values.contains_key(key) { - into.values.insert(key.to_owned(), Value::Table(table)); - return - } - if let Value::Table(ref mut into) = *into.values.get_mut(key).unwrap() { - if into.defined { - self.errors.push(ParserError { - lo: key_lo, - hi: key_lo + key.len(), - desc: format!("redefinition of table `{}`", key), - }); - } - for (k, v) in table.values { - if into.values.insert(k.clone(), v).is_some() { - self.errors.push(ParserError { - lo: key_lo, - hi: key_lo + key.len(), - desc: format!("duplicate key `{}` in table", k), - }); - } - } - } else { - self.errors.push(ParserError { - lo: key_lo, - hi: key_lo + key.len(), - desc: format!("duplicate key `{}` in table", key), - }); - } - } - - fn insert_array(&mut self, into: &mut TomlTable, - keys: &[String], value: Value, key_lo: usize) { - let (into, key) = match self.recurse(into, keys, key_lo) { - Some(pair) => pair, - None => return, - }; - if !into.values.contains_key(key) { - into.values.insert(key.to_owned(), Value::Array(Vec::new())); - } - match *into.values.get_mut(key).unwrap() { - Value::Array(ref mut vec) => { - match vec.first() { - Some(ref v) if !v.same_type(&value) => { - self.errors.push(ParserError { - lo: key_lo, - hi: key_lo + key.len(), - desc: format!("expected type `{}`, found type `{}`", - v.type_str(), value.type_str()), - }) - } - Some(..) | None => {} - } - vec.push(value); - } - _ => { - self.errors.push(ParserError { - lo: key_lo, - hi: key_lo + key.len(), - desc: format!("key `{}` was previously not an array", key), - }); - } - } - } -} - -impl Error for ParserError { - fn description(&self) -> &str { "TOML parse error" } -} - -impl fmt::Display for ParserError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.desc.fmt(f) - } -} - -fn is_digit(c: char) -> bool { - match c { '0' ... '9' => true, _ => false } -} - -#[cfg(test)] -mod tests { - use Value::Table; - use Parser; - - macro_rules! bad { - ($s:expr, $msg:expr) => ({ - let mut p = Parser::new($s); - assert!(p.parse().is_none()); - assert!(p.errors.iter().any(|e| e.desc.contains($msg)), - "errors: {:?}", p.errors); - }) - } - - #[test] - fn lookup_internal() { - let mut parser = Parser::new(r#"hello."world\t".a.0.'escaped'.value"#); - let result = vec![ - String::from("hello"), - String::from("world\t"), - String::from("a"), - String::from("0"), - String::from("escaped"), - String::from("value") - ]; - - assert_eq!(parser.lookup().unwrap(), result); - } - - #[test] - fn lookup_internal_void() { - let mut parser = Parser::new(""); - assert_eq!(parser.lookup().unwrap(), Vec::<String>::new()); - } - - #[test] - fn lookup_internal_simple() { - let mut parser = Parser::new("value"); - assert_eq!(parser.lookup().unwrap(), vec![String::from("value")]); - } - - // This is due to key_name not parsing an empty "" correctly. Disabled for now. - #[test] - #[ignore] - fn lookup_internal_quoted_void() { - let mut parser = Parser::new("\"\""); - assert_eq!(parser.lookup().unwrap(), vec![String::from("")]); - } - - - #[test] - fn crlf() { - let mut p = Parser::new("\ -[project]\r\n\ -\r\n\ -name = \"splay\"\r\n\ -version = \"0.1.0\"\r\n\ -authors = [\"alex@crichton.co\"]\r\n\ -\r\n\ -[[lib]]\r\n\ -\r\n\ -path = \"lib.rs\"\r\n\ -name = \"splay\"\r\n\ -description = \"\"\"\ -A Rust implementation of a TAR file reader and writer. This library does not\r\n\ -currently handle compression, but it is abstract over all I/O readers and\r\n\ -writers. Additionally, great lengths are taken to ensure that the entire\r\n\ -contents are never required to be entirely resident in memory all at once.\r\n\ -\"\"\"\ -"); - assert!(p.parse().is_some()); - } - - #[test] - fn linecol() { - let p = Parser::new("ab\ncde\nf"); - assert_eq!(p.to_linecol(0), (0, 0)); - assert_eq!(p.to_linecol(1), (0, 1)); - assert_eq!(p.to_linecol(3), (1, 0)); - assert_eq!(p.to_linecol(4), (1, 1)); - assert_eq!(p.to_linecol(7), (2, 0)); - } - - #[test] - fn fun_with_strings() { - let mut p = Parser::new(r#" -bar = "\U00000000" -key1 = "One\nTwo" -key2 = """One\nTwo""" -key3 = """ -One -Two""" - -key4 = "The quick brown fox jumps over the lazy dog." -key5 = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" -key6 = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """ -# What you see is what you get. -winpath = 'C:\Users\nodejs\templates' -winpath2 = '\\ServerX\admin$\system32\' -quoted = 'Tom "Dubs" Preston-Werner' -regex = '<\i\c*\s*>' - -regex2 = '''I [dw]on't need \d{2} apples''' -lines = ''' -The first newline is -trimmed in raw strings. - All other whitespace - is preserved. -''' -"#); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("bar").and_then(|k| k.as_str()), Some("\0")); - assert_eq!(table.lookup("key1").and_then(|k| k.as_str()), - Some("One\nTwo")); - assert_eq!(table.lookup("key2").and_then(|k| k.as_str()), - Some("One\nTwo")); - assert_eq!(table.lookup("key3").and_then(|k| k.as_str()), - Some("One\nTwo")); - - let msg = "The quick brown fox jumps over the lazy dog."; - assert_eq!(table.lookup("key4").and_then(|k| k.as_str()), Some(msg)); - assert_eq!(table.lookup("key5").and_then(|k| k.as_str()), Some(msg)); - assert_eq!(table.lookup("key6").and_then(|k| k.as_str()), Some(msg)); - - assert_eq!(table.lookup("winpath").and_then(|k| k.as_str()), - Some(r"C:\Users\nodejs\templates")); - assert_eq!(table.lookup("winpath2").and_then(|k| k.as_str()), - Some(r"\\ServerX\admin$\system32\")); - assert_eq!(table.lookup("quoted").and_then(|k| k.as_str()), - Some(r#"Tom "Dubs" Preston-Werner"#)); - assert_eq!(table.lookup("regex").and_then(|k| k.as_str()), - Some(r"<\i\c*\s*>")); - assert_eq!(table.lookup("regex2").and_then(|k| k.as_str()), - Some(r"I [dw]on't need \d{2} apples")); - assert_eq!(table.lookup("lines").and_then(|k| k.as_str()), - Some("The first newline is\n\ - trimmed in raw strings.\n \ - All other whitespace\n \ - is preserved.\n")); - } - - #[test] - fn tables_in_arrays() { - let mut p = Parser::new(r#" -[[foo]] - #… - [foo.bar] - #… - -[[foo]] # ... - #… - [foo.bar] - #... -"#); - let table = Table(p.parse().unwrap()); - table.lookup("foo.0.bar").unwrap().as_table().unwrap(); - table.lookup("foo.1.bar").unwrap().as_table().unwrap(); - } - - #[test] - fn fruit() { - let mut p = Parser::new(r#" -[[fruit]] - name = "apple" - - [fruit.physical] - color = "red" - shape = "round" - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - -[[fruit]] - name = "banana" - - [[fruit.variety]] - name = "plantain" -"#); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("fruit.0.name").and_then(|k| k.as_str()), - Some("apple")); - assert_eq!(table.lookup("fruit.0.physical.color").and_then(|k| k.as_str()), - Some("red")); - assert_eq!(table.lookup("fruit.0.physical.shape").and_then(|k| k.as_str()), - Some("round")); - assert_eq!(table.lookup("fruit.0.variety.0.name").and_then(|k| k.as_str()), - Some("red delicious")); - assert_eq!(table.lookup("fruit.0.variety.1.name").and_then(|k| k.as_str()), - Some("granny smith")); - assert_eq!(table.lookup("fruit.1.name").and_then(|k| k.as_str()), - Some("banana")); - assert_eq!(table.lookup("fruit.1.variety.0.name").and_then(|k| k.as_str()), - Some("plantain")); - } - - #[test] - fn stray_cr() { - assert!(Parser::new("\r").parse().is_none()); - assert!(Parser::new("a = [ \r ]").parse().is_none()); - assert!(Parser::new("a = \"\"\"\r\"\"\"").parse().is_none()); - assert!(Parser::new("a = \"\"\"\\ \r \"\"\"").parse().is_none()); - - let mut p = Parser::new("foo = '''\r'''"); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\r")); - - let mut p = Parser::new("foo = '\r'"); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\r")); - } - - #[test] - fn blank_literal_string() { - let mut p = Parser::new("foo = ''"); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("")); - } - - #[test] - fn many_blank() { - let mut p = Parser::new("foo = \"\"\"\n\n\n\"\"\""); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\n\n")); - } - - #[test] - fn literal_eats_crlf() { - let mut p = Parser::new(" - foo = \"\"\"\\\r\n\"\"\" - bar = \"\"\"\\\r\n \r\n \r\n a\"\"\" - "); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("")); - assert_eq!(table.lookup("bar").and_then(|k| k.as_str()), Some("a")); - } - - #[test] - fn string_no_newline() { - assert!(Parser::new("a = \"\n\"").parse().is_none()); - assert!(Parser::new("a = '\n'").parse().is_none()); - } - - #[test] - fn bad_leading_zeros() { - assert!(Parser::new("a = 00").parse().is_none()); - assert!(Parser::new("a = -00").parse().is_none()); - assert!(Parser::new("a = +00").parse().is_none()); - assert!(Parser::new("a = 00.0").parse().is_none()); - assert!(Parser::new("a = -00.0").parse().is_none()); - assert!(Parser::new("a = +00.0").parse().is_none()); - assert!(Parser::new("a = 9223372036854775808").parse().is_none()); - assert!(Parser::new("a = -9223372036854775809").parse().is_none()); - } - - #[test] - fn bad_floats() { - assert!(Parser::new("a = 0.").parse().is_none()); - assert!(Parser::new("a = 0.e").parse().is_none()); - assert!(Parser::new("a = 0.E").parse().is_none()); - assert!(Parser::new("a = 0.0E").parse().is_none()); - assert!(Parser::new("a = 0.0e").parse().is_none()); - assert!(Parser::new("a = 0.0e-").parse().is_none()); - assert!(Parser::new("a = 0.0e+").parse().is_none()); - assert!(Parser::new("a = 0.0e+00").parse().is_none()); - } - - #[test] - fn floats() { - macro_rules! t { - ($actual:expr, $expected:expr) => ({ - let f = format!("foo = {}", $actual); - let mut p = Parser::new(&f); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_float()), - Some($expected)); - }) - } - - t!("1.0", 1.0); - t!("1.0e0", 1.0); - t!("1.0e+0", 1.0); - t!("1.0e-0", 1.0); - t!("1.001e-0", 1.001); - t!("2e10", 2e10); - t!("2e+10", 2e10); - t!("2e-10", 2e-10); - t!("2_0.0", 20.0); - t!("2_0.0_0e0_0", 20.0); - t!("2_0.1_0e1_0", 20.1e10); - } - - #[test] - fn bare_key_names() { - let mut p = Parser::new(" - foo = 3 - foo_3 = 3 - foo_-2--3--r23f--4-f2-4 = 3 - _ = 3 - - = 3 - 8 = 8 - \"a\" = 3 - \"!\" = 3 - \"a^b\" = 3 - \"\\\"\" = 3 - \"character encoding\" = \"value\" - 'ʎǝʞ' = \"value\" - "); - let table = Table(p.parse().unwrap()); - assert!(table.lookup("foo").is_some()); - assert!(table.lookup("-").is_some()); - assert!(table.lookup("_").is_some()); - assert!(table.lookup("8").is_some()); - assert!(table.lookup("foo_3").is_some()); - assert!(table.lookup("foo_-2--3--r23f--4-f2-4").is_some()); - assert!(table.lookup("a").is_some()); - assert!(table.lookup("\"!\"").is_some()); - assert!(table.lookup("\"\\\"\"").is_some()); - assert!(table.lookup("\"character encoding\"").is_some()); - assert!(table.lookup("'ʎǝʞ'").is_some()); - } - - #[test] - fn bad_keys() { - assert!(Parser::new("key\n=3").parse().is_none()); - assert!(Parser::new("key=\n3").parse().is_none()); - assert!(Parser::new("key|=3").parse().is_none()); - assert!(Parser::new("\"\"=3").parse().is_none()); - assert!(Parser::new("=3").parse().is_none()); - assert!(Parser::new("\"\"|=3").parse().is_none()); - assert!(Parser::new("\"\n\"|=3").parse().is_none()); - assert!(Parser::new("\"\r\"|=3").parse().is_none()); - } - - #[test] - fn bad_table_names() { - assert!(Parser::new("[]").parse().is_none()); - assert!(Parser::new("[.]").parse().is_none()); - assert!(Parser::new("[\"\".\"\"]").parse().is_none()); - assert!(Parser::new("[a.]").parse().is_none()); - assert!(Parser::new("[\"\"]").parse().is_none()); - assert!(Parser::new("[!]").parse().is_none()); - assert!(Parser::new("[\"\n\"]").parse().is_none()); - assert!(Parser::new("[a.b]\n[a.\"b\"]").parse().is_none()); - assert!(Parser::new("[']").parse().is_none()); - assert!(Parser::new("[''']").parse().is_none()); - assert!(Parser::new("['''''']").parse().is_none()); - assert!(Parser::new("['\n']").parse().is_none()); - assert!(Parser::new("['\r\n']").parse().is_none()); - } - - #[test] - fn table_names() { - let mut p = Parser::new(" - [a.\"b\"] - [\"f f\"] - [\"f.f\"] - [\"\\\"\"] - ['a.a'] - ['\"\"'] - "); - let table = Table(p.parse().unwrap()); - assert!(table.lookup("a.b").is_some()); - assert!(table.lookup("\"f f\"").is_some()); - assert!(table.lookup("\"\\\"\"").is_some()); - assert!(table.lookup("'\"\"'").is_some()); - } - - #[test] - fn invalid_bare_numeral() { - assert!(Parser::new("4").parse().is_none()); - } - - #[test] - fn inline_tables() { - assert!(Parser::new("a = {}").parse().is_some()); - assert!(Parser::new("a = {b=1}").parse().is_some()); - assert!(Parser::new("a = { b = 1 }").parse().is_some()); - assert!(Parser::new("a = {a=1,b=2}").parse().is_some()); - assert!(Parser::new("a = {a=1,b=2,c={}}").parse().is_some()); - assert!(Parser::new("a = {a=1,}").parse().is_none()); - assert!(Parser::new("a = {,}").parse().is_none()); - assert!(Parser::new("a = {a=1,a=1}").parse().is_none()); - assert!(Parser::new("a = {\n}").parse().is_none()); - assert!(Parser::new("a = {").parse().is_none()); - assert!(Parser::new("a = {a=[\n]}").parse().is_some()); - assert!(Parser::new("a = {\"a\"=[\n]}").parse().is_some()); - assert!(Parser::new("a = [\n{},\n{},\n]").parse().is_some()); - } - - #[test] - fn number_underscores() { - macro_rules! t { - ($actual:expr, $expected:expr) => ({ - let f = format!("foo = {}", $actual); - let mut p = Parser::new(&f); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_integer()), - Some($expected)); - }) - } - - t!("1_0", 10); - t!("1_0_0", 100); - t!("1_000", 1000); - t!("+1_000", 1000); - t!("-1_000", -1000); - } - - #[test] - fn bad_underscores() { - assert!(Parser::new("foo = 0_").parse().is_none()); - assert!(Parser::new("foo = 0__0").parse().is_none()); - assert!(Parser::new("foo = __0").parse().is_none()); - assert!(Parser::new("foo = 1_0_").parse().is_none()); - } - - #[test] - fn bad_unicode_codepoint() { - bad!("foo = \"\\uD800\"", "not a valid unicode codepoint"); - } - - #[test] - fn bad_strings() { - bad!("foo = \"\\uxx\"", "expected 4 hex digits"); - bad!("foo = \"\\u\"", "expected 4 hex digits"); - bad!("foo = \"\\", "unterminated"); - bad!("foo = '", "unterminated"); - } - - #[test] - fn empty_string() { - let mut p = Parser::new("foo = \"\""); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").unwrap().as_str(), Some("")); - } - - #[test] - fn booleans() { - let mut p = Parser::new("foo = true"); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").unwrap().as_bool(), Some(true)); - - let mut p = Parser::new("foo = false"); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").unwrap().as_bool(), Some(false)); - - assert!(Parser::new("foo = true2").parse().is_none()); - assert!(Parser::new("foo = false2").parse().is_none()); - assert!(Parser::new("foo = t1").parse().is_none()); - assert!(Parser::new("foo = f2").parse().is_none()); - } - - #[test] - fn bad_nesting() { - bad!(" - a = [2] - [[a]] - b = 5 - ", "expected type `integer`, found type `table`"); - bad!(" - a = 1 - [a.b] - ", "key `a` was not previously a table"); - bad!(" - a = [] - [a.b] - ", "array `a` does not contain tables"); - bad!(" - a = [] - [[a.b]] - ", "array `a` does not contain tables"); - bad!(" - [a] - b = { c = 2, d = {} } - [a.b] - c = 2 - ", "duplicate key `c` in table"); - } - - #[test] - fn bad_table_redefine() { - bad!(" - [a] - foo=\"bar\" - [a.b] - foo=\"bar\" - [a] - ", "redefinition of table `a`"); - bad!(" - [a] - foo=\"bar\" - b = { foo = \"bar\" } - [a] - ", "redefinition of table `a`"); - bad!(" - [a] - b = {} - [a.b] - ", "redefinition of table `b`"); - - bad!(" - [a] - b = {} - [a] - ", "redefinition of table `a`"); - } - - #[test] - fn datetimes() { - macro_rules! t { - ($actual:expr) => ({ - let f = format!("foo = {}", $actual); - let mut p = Parser::new(&f); - let table = Table(p.parse().unwrap()); - assert_eq!(table.lookup("foo").and_then(|k| k.as_datetime()), - Some($actual)); - }) - } - - t!("2016-09-09T09:09:09Z"); - t!("2016-09-09T09:09:09.0Z"); - t!("2016-09-09T09:09:09.0+10:00"); - t!("2016-09-09T09:09:09.01234567890-02:00"); - bad!("foo = 2016-09-09T09:09:09.Z", "malformed date literal"); - bad!("foo = 2016-9-09T09:09:09Z", "malformed date literal"); - bad!("foo = 2016-09-09T09:09:09+2:00", "malformed date literal"); - bad!("foo = 2016-09-09T09:09:09-2:00", "malformed date literal"); - bad!("foo = 2016-09-09T09:09:09Z-2:00", "expected"); - } -} diff --git a/src/vendor/toml/tests/README.md b/src/vendor/toml/tests/README.md deleted file mode 100644 index ebbc01ccf34..00000000000 --- a/src/vendor/toml/tests/README.md +++ /dev/null @@ -1 +0,0 @@ -Tests are from https://github.com/BurntSushi/toml-test diff --git a/src/vendor/toml/tests/invalid-encoder/array-mixed-types-ints-and-floats.json b/src/vendor/toml/tests/invalid-encoder/array-mixed-types-ints-and-floats.json deleted file mode 100644 index 2d42ead67e6..00000000000 --- a/src/vendor/toml/tests/invalid-encoder/array-mixed-types-ints-and-floats.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ints-and-floats": { - "type": "array", - "value": [ - { - "type": "integer", - "value": "1" - }, - { - "type": "float", - "value": "1.1" - } - ] - } -} diff --git a/src/vendor/toml/tests/invalid.rs b/src/vendor/toml/tests/invalid.rs deleted file mode 100644 index 63e4de8e713..00000000000 --- a/src/vendor/toml/tests/invalid.rs +++ /dev/null @@ -1,108 +0,0 @@ -extern crate toml; - -use toml::{Parser}; - -fn run(toml: &str) { - let mut p = Parser::new(toml); - let table = p.parse(); - assert!(table.is_none()); - assert!(p.errors.len() > 0); - - // test Parser::to_linecol with the generated error offsets - for error in &p.errors { - p.to_linecol(error.lo); - p.to_linecol(error.hi); - } -} - -macro_rules! test( ($name:ident, $toml:expr) => ( - #[test] - fn $name() { run($toml); } -) ); - -test!(array_mixed_types_arrays_and_ints, - include_str!("invalid/array-mixed-types-arrays-and-ints.toml")); -test!(array_mixed_types_ints_and_floats, - include_str!("invalid/array-mixed-types-ints-and-floats.toml")); -test!(array_mixed_types_strings_and_ints, - include_str!("invalid/array-mixed-types-strings-and-ints.toml")); -test!(datetime_malformed_no_leads, - include_str!("invalid/datetime-malformed-no-leads.toml")); -test!(datetime_malformed_no_secs, - include_str!("invalid/datetime-malformed-no-secs.toml")); -test!(datetime_malformed_no_t, - include_str!("invalid/datetime-malformed-no-t.toml")); -test!(datetime_malformed_no_z, - include_str!("invalid/datetime-malformed-no-z.toml")); -test!(datetime_malformed_with_milli, - include_str!("invalid/datetime-malformed-with-milli.toml")); -test!(duplicate_keys, - include_str!("invalid/duplicate-keys.toml")); -test!(duplicate_key_table, - include_str!("invalid/duplicate-key-table.toml")); -test!(duplicate_tables, - include_str!("invalid/duplicate-tables.toml")); -test!(empty_implicit_table, - include_str!("invalid/empty-implicit-table.toml")); -test!(empty_table, - include_str!("invalid/empty-table.toml")); -test!(float_no_leading_zero, - include_str!("invalid/float-no-leading-zero.toml")); -test!(float_no_trailing_digits, - include_str!("invalid/float-no-trailing-digits.toml")); -test!(key_after_array, - include_str!("invalid/key-after-array.toml")); -test!(key_after_table, - include_str!("invalid/key-after-table.toml")); -test!(key_empty, - include_str!("invalid/key-empty.toml")); -test!(key_hash, - include_str!("invalid/key-hash.toml")); -test!(key_newline, - include_str!("invalid/key-newline.toml")); -test!(key_open_bracket, - include_str!("invalid/key-open-bracket.toml")); -test!(key_single_open_bracket, - include_str!("invalid/key-single-open-bracket.toml")); -test!(key_space, - include_str!("invalid/key-space.toml")); -test!(key_start_bracket, - include_str!("invalid/key-start-bracket.toml")); -test!(key_two_equals, - include_str!("invalid/key-two-equals.toml")); -test!(string_bad_byte_escape, - include_str!("invalid/string-bad-byte-escape.toml")); -test!(string_bad_escape, - include_str!("invalid/string-bad-escape.toml")); -test!(string_byte_escapes, - include_str!("invalid/string-byte-escapes.toml")); -test!(string_no_close, - include_str!("invalid/string-no-close.toml")); -test!(table_array_implicit, - include_str!("invalid/table-array-implicit.toml")); -test!(table_array_malformed_bracket, - include_str!("invalid/table-array-malformed-bracket.toml")); -test!(table_array_malformed_empty, - include_str!("invalid/table-array-malformed-empty.toml")); -test!(table_empty, - include_str!("invalid/table-empty.toml")); -test!(table_nested_brackets_close, - include_str!("invalid/table-nested-brackets-close.toml")); -test!(table_nested_brackets_open, - include_str!("invalid/table-nested-brackets-open.toml")); -test!(table_whitespace, - include_str!("invalid/table-whitespace.toml")); -test!(table_with_pound, - include_str!("invalid/table-with-pound.toml")); -test!(text_after_array_entries, - include_str!("invalid/text-after-array-entries.toml")); -test!(text_after_integer, - include_str!("invalid/text-after-integer.toml")); -test!(text_after_string, - include_str!("invalid/text-after-string.toml")); -test!(text_after_table, - include_str!("invalid/text-after-table.toml")); -test!(text_before_array_separator, - include_str!("invalid/text-before-array-separator.toml")); -test!(text_in_array, - include_str!("invalid/text-in-array.toml")); diff --git a/src/vendor/toml/tests/invalid/array-mixed-types-arrays-and-ints.toml b/src/vendor/toml/tests/invalid/array-mixed-types-arrays-and-ints.toml deleted file mode 100644 index 051ec73136b..00000000000 --- a/src/vendor/toml/tests/invalid/array-mixed-types-arrays-and-ints.toml +++ /dev/null @@ -1 +0,0 @@ -arrays-and-ints = [1, ["Arrays are not integers."]] diff --git a/src/vendor/toml/tests/invalid/array-mixed-types-ints-and-floats.toml b/src/vendor/toml/tests/invalid/array-mixed-types-ints-and-floats.toml deleted file mode 100644 index a5aa9b7a033..00000000000 --- a/src/vendor/toml/tests/invalid/array-mixed-types-ints-and-floats.toml +++ /dev/null @@ -1 +0,0 @@ -ints-and-floats = [1, 1.1] diff --git a/src/vendor/toml/tests/invalid/array-mixed-types-strings-and-ints.toml b/src/vendor/toml/tests/invalid/array-mixed-types-strings-and-ints.toml deleted file mode 100644 index f3483080532..00000000000 --- a/src/vendor/toml/tests/invalid/array-mixed-types-strings-and-ints.toml +++ /dev/null @@ -1 +0,0 @@ -strings-and-ints = ["hi", 42] diff --git a/src/vendor/toml/tests/invalid/datetime-malformed-no-leads.toml b/src/vendor/toml/tests/invalid/datetime-malformed-no-leads.toml deleted file mode 100644 index 123f173beb3..00000000000 --- a/src/vendor/toml/tests/invalid/datetime-malformed-no-leads.toml +++ /dev/null @@ -1 +0,0 @@ -no-leads = 1987-7-05T17:45:00Z diff --git a/src/vendor/toml/tests/invalid/datetime-malformed-no-secs.toml b/src/vendor/toml/tests/invalid/datetime-malformed-no-secs.toml deleted file mode 100644 index ba939007627..00000000000 --- a/src/vendor/toml/tests/invalid/datetime-malformed-no-secs.toml +++ /dev/null @@ -1 +0,0 @@ -no-secs = 1987-07-05T17:45Z diff --git a/src/vendor/toml/tests/invalid/datetime-malformed-no-t.toml b/src/vendor/toml/tests/invalid/datetime-malformed-no-t.toml deleted file mode 100644 index 617e3c56d40..00000000000 --- a/src/vendor/toml/tests/invalid/datetime-malformed-no-t.toml +++ /dev/null @@ -1 +0,0 @@ -no-t = 1987-07-0517:45:00Z diff --git a/src/vendor/toml/tests/invalid/datetime-malformed-no-z.toml b/src/vendor/toml/tests/invalid/datetime-malformed-no-z.toml deleted file mode 100644 index cf66b1ea6b3..00000000000 --- a/src/vendor/toml/tests/invalid/datetime-malformed-no-z.toml +++ /dev/null @@ -1 +0,0 @@ -no-z = 1987-07-05T17:45:00 diff --git a/src/vendor/toml/tests/invalid/datetime-malformed-with-milli.toml b/src/vendor/toml/tests/invalid/datetime-malformed-with-milli.toml deleted file mode 100644 index eef792f34d6..00000000000 --- a/src/vendor/toml/tests/invalid/datetime-malformed-with-milli.toml +++ /dev/null @@ -1 +0,0 @@ -with-milli = 1987-07-5T17:45:00.12Z diff --git a/src/vendor/toml/tests/invalid/duplicate-key-table.toml b/src/vendor/toml/tests/invalid/duplicate-key-table.toml deleted file mode 100644 index cedf05fc53b..00000000000 --- a/src/vendor/toml/tests/invalid/duplicate-key-table.toml +++ /dev/null @@ -1,5 +0,0 @@ -[fruit] -type = "apple" - -[fruit.type] -apple = "yes" diff --git a/src/vendor/toml/tests/invalid/duplicate-keys.toml b/src/vendor/toml/tests/invalid/duplicate-keys.toml deleted file mode 100644 index 9b5aee0e59b..00000000000 --- a/src/vendor/toml/tests/invalid/duplicate-keys.toml +++ /dev/null @@ -1,2 +0,0 @@ -dupe = false -dupe = true diff --git a/src/vendor/toml/tests/invalid/duplicate-tables.toml b/src/vendor/toml/tests/invalid/duplicate-tables.toml deleted file mode 100644 index 8ddf49b4e89..00000000000 --- a/src/vendor/toml/tests/invalid/duplicate-tables.toml +++ /dev/null @@ -1,2 +0,0 @@ -[a] -[a] diff --git a/src/vendor/toml/tests/invalid/empty-implicit-table.toml b/src/vendor/toml/tests/invalid/empty-implicit-table.toml deleted file mode 100644 index 0cc36d0d281..00000000000 --- a/src/vendor/toml/tests/invalid/empty-implicit-table.toml +++ /dev/null @@ -1 +0,0 @@ -[naughty..naughty] diff --git a/src/vendor/toml/tests/invalid/empty-table.toml b/src/vendor/toml/tests/invalid/empty-table.toml deleted file mode 100644 index fe51488c706..00000000000 --- a/src/vendor/toml/tests/invalid/empty-table.toml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/vendor/toml/tests/invalid/float-no-leading-zero.toml b/src/vendor/toml/tests/invalid/float-no-leading-zero.toml deleted file mode 100644 index cab76bfd158..00000000000 --- a/src/vendor/toml/tests/invalid/float-no-leading-zero.toml +++ /dev/null @@ -1,2 +0,0 @@ -answer = .12345 -neganswer = -.12345 diff --git a/src/vendor/toml/tests/invalid/float-no-trailing-digits.toml b/src/vendor/toml/tests/invalid/float-no-trailing-digits.toml deleted file mode 100644 index cbff2d06f05..00000000000 --- a/src/vendor/toml/tests/invalid/float-no-trailing-digits.toml +++ /dev/null @@ -1,2 +0,0 @@ -answer = 1. -neganswer = -1. diff --git a/src/vendor/toml/tests/invalid/key-after-array.toml b/src/vendor/toml/tests/invalid/key-after-array.toml deleted file mode 100644 index 5c1a1b0a9bc..00000000000 --- a/src/vendor/toml/tests/invalid/key-after-array.toml +++ /dev/null @@ -1 +0,0 @@ -[[agencies]] owner = "S Cjelli" diff --git a/src/vendor/toml/tests/invalid/key-after-table.toml b/src/vendor/toml/tests/invalid/key-after-table.toml deleted file mode 100644 index 4bc82136ce9..00000000000 --- a/src/vendor/toml/tests/invalid/key-after-table.toml +++ /dev/null @@ -1 +0,0 @@ -[history] guard = "sleeping" diff --git a/src/vendor/toml/tests/invalid/key-empty.toml b/src/vendor/toml/tests/invalid/key-empty.toml deleted file mode 100644 index 09f998f4163..00000000000 --- a/src/vendor/toml/tests/invalid/key-empty.toml +++ /dev/null @@ -1 +0,0 @@ - = 1 diff --git a/src/vendor/toml/tests/invalid/key-hash.toml b/src/vendor/toml/tests/invalid/key-hash.toml deleted file mode 100644 index e321b1fbd0c..00000000000 --- a/src/vendor/toml/tests/invalid/key-hash.toml +++ /dev/null @@ -1 +0,0 @@ -a# = 1 diff --git a/src/vendor/toml/tests/invalid/key-newline.toml b/src/vendor/toml/tests/invalid/key-newline.toml deleted file mode 100644 index 707aad54ec3..00000000000 --- a/src/vendor/toml/tests/invalid/key-newline.toml +++ /dev/null @@ -1,2 +0,0 @@ -a -= 1 diff --git a/src/vendor/toml/tests/invalid/key-open-bracket.toml b/src/vendor/toml/tests/invalid/key-open-bracket.toml deleted file mode 100644 index f0aeb16e500..00000000000 --- a/src/vendor/toml/tests/invalid/key-open-bracket.toml +++ /dev/null @@ -1 +0,0 @@ -[abc = 1 diff --git a/src/vendor/toml/tests/invalid/key-single-open-bracket.toml b/src/vendor/toml/tests/invalid/key-single-open-bracket.toml deleted file mode 100644 index 8e2f0bef135..00000000000 --- a/src/vendor/toml/tests/invalid/key-single-open-bracket.toml +++ /dev/null @@ -1 +0,0 @@ -[ \ No newline at end of file diff --git a/src/vendor/toml/tests/invalid/key-space.toml b/src/vendor/toml/tests/invalid/key-space.toml deleted file mode 100644 index 201806d2801..00000000000 --- a/src/vendor/toml/tests/invalid/key-space.toml +++ /dev/null @@ -1 +0,0 @@ -a b = 1 \ No newline at end of file diff --git a/src/vendor/toml/tests/invalid/key-start-bracket.toml b/src/vendor/toml/tests/invalid/key-start-bracket.toml deleted file mode 100644 index e0597ae1c6f..00000000000 --- a/src/vendor/toml/tests/invalid/key-start-bracket.toml +++ /dev/null @@ -1,3 +0,0 @@ -[a] -[xyz = 5 -[b] diff --git a/src/vendor/toml/tests/invalid/key-two-equals.toml b/src/vendor/toml/tests/invalid/key-two-equals.toml deleted file mode 100644 index 25a037894eb..00000000000 --- a/src/vendor/toml/tests/invalid/key-two-equals.toml +++ /dev/null @@ -1 +0,0 @@ -key= = 1 diff --git a/src/vendor/toml/tests/invalid/string-bad-byte-escape.toml b/src/vendor/toml/tests/invalid/string-bad-byte-escape.toml deleted file mode 100644 index 4c7be59f4b1..00000000000 --- a/src/vendor/toml/tests/invalid/string-bad-byte-escape.toml +++ /dev/null @@ -1 +0,0 @@ -naughty = "\xAg" diff --git a/src/vendor/toml/tests/invalid/string-bad-escape.toml b/src/vendor/toml/tests/invalid/string-bad-escape.toml deleted file mode 100644 index 60acb0ccc50..00000000000 --- a/src/vendor/toml/tests/invalid/string-bad-escape.toml +++ /dev/null @@ -1 +0,0 @@ -invalid-escape = "This string has a bad \a escape character." diff --git a/src/vendor/toml/tests/invalid/string-byte-escapes.toml b/src/vendor/toml/tests/invalid/string-byte-escapes.toml deleted file mode 100644 index e94452a8dfc..00000000000 --- a/src/vendor/toml/tests/invalid/string-byte-escapes.toml +++ /dev/null @@ -1 +0,0 @@ -answer = "\x33" diff --git a/src/vendor/toml/tests/invalid/string-no-close.toml b/src/vendor/toml/tests/invalid/string-no-close.toml deleted file mode 100644 index 0c292fcab73..00000000000 --- a/src/vendor/toml/tests/invalid/string-no-close.toml +++ /dev/null @@ -1 +0,0 @@ -no-ending-quote = "One time, at band camp diff --git a/src/vendor/toml/tests/invalid/table-array-implicit.toml b/src/vendor/toml/tests/invalid/table-array-implicit.toml deleted file mode 100644 index 05f2507ecb6..00000000000 --- a/src/vendor/toml/tests/invalid/table-array-implicit.toml +++ /dev/null @@ -1,14 +0,0 @@ -# This test is a bit tricky. It should fail because the first use of -# `[[albums.songs]]` without first declaring `albums` implies that `albums` -# must be a table. The alternative would be quite weird. Namely, it wouldn't -# comply with the TOML spec: "Each double-bracketed sub-table will belong to -# the most *recently* defined table element *above* it." -# -# This is in contrast to the *valid* test, table-array-implicit where -# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared -# later. (Although, `[albums]` could be.) -[[albums.songs]] -name = "Glory Days" - -[[albums]] -name = "Born in the USA" diff --git a/src/vendor/toml/tests/invalid/table-array-malformed-bracket.toml b/src/vendor/toml/tests/invalid/table-array-malformed-bracket.toml deleted file mode 100644 index 39c73b05c44..00000000000 --- a/src/vendor/toml/tests/invalid/table-array-malformed-bracket.toml +++ /dev/null @@ -1,2 +0,0 @@ -[[albums] -name = "Born to Run" diff --git a/src/vendor/toml/tests/invalid/table-array-malformed-empty.toml b/src/vendor/toml/tests/invalid/table-array-malformed-empty.toml deleted file mode 100644 index a470ca332f3..00000000000 --- a/src/vendor/toml/tests/invalid/table-array-malformed-empty.toml +++ /dev/null @@ -1,2 +0,0 @@ -[[]] -name = "Born to Run" diff --git a/src/vendor/toml/tests/invalid/table-empty.toml b/src/vendor/toml/tests/invalid/table-empty.toml deleted file mode 100644 index fe51488c706..00000000000 --- a/src/vendor/toml/tests/invalid/table-empty.toml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/vendor/toml/tests/invalid/table-nested-brackets-close.toml b/src/vendor/toml/tests/invalid/table-nested-brackets-close.toml deleted file mode 100644 index c8b5a678580..00000000000 --- a/src/vendor/toml/tests/invalid/table-nested-brackets-close.toml +++ /dev/null @@ -1,2 +0,0 @@ -[a]b] -zyx = 42 diff --git a/src/vendor/toml/tests/invalid/table-nested-brackets-open.toml b/src/vendor/toml/tests/invalid/table-nested-brackets-open.toml deleted file mode 100644 index 246d7e91fe4..00000000000 --- a/src/vendor/toml/tests/invalid/table-nested-brackets-open.toml +++ /dev/null @@ -1,2 +0,0 @@ -[a[b] -zyx = 42 diff --git a/src/vendor/toml/tests/invalid/table-whitespace.toml b/src/vendor/toml/tests/invalid/table-whitespace.toml deleted file mode 100644 index 79bbcb1e298..00000000000 --- a/src/vendor/toml/tests/invalid/table-whitespace.toml +++ /dev/null @@ -1 +0,0 @@ -[invalid key] \ No newline at end of file diff --git a/src/vendor/toml/tests/invalid/table-with-pound.toml b/src/vendor/toml/tests/invalid/table-with-pound.toml deleted file mode 100644 index 0d8edb524fe..00000000000 --- a/src/vendor/toml/tests/invalid/table-with-pound.toml +++ /dev/null @@ -1,2 +0,0 @@ -[key#group] -answer = 42 \ No newline at end of file diff --git a/src/vendor/toml/tests/invalid/text-after-array-entries.toml b/src/vendor/toml/tests/invalid/text-after-array-entries.toml deleted file mode 100644 index 1a7289074ed..00000000000 --- a/src/vendor/toml/tests/invalid/text-after-array-entries.toml +++ /dev/null @@ -1,4 +0,0 @@ -array = [ - "Is there life after an array separator?", No - "Entry" -] diff --git a/src/vendor/toml/tests/invalid/text-after-integer.toml b/src/vendor/toml/tests/invalid/text-after-integer.toml deleted file mode 100644 index 42de7aff4d8..00000000000 --- a/src/vendor/toml/tests/invalid/text-after-integer.toml +++ /dev/null @@ -1 +0,0 @@ -answer = 42 the ultimate answer? diff --git a/src/vendor/toml/tests/invalid/text-after-string.toml b/src/vendor/toml/tests/invalid/text-after-string.toml deleted file mode 100644 index c92a6f11d85..00000000000 --- a/src/vendor/toml/tests/invalid/text-after-string.toml +++ /dev/null @@ -1 +0,0 @@ -string = "Is there life after strings?" No. diff --git a/src/vendor/toml/tests/invalid/text-after-table.toml b/src/vendor/toml/tests/invalid/text-after-table.toml deleted file mode 100644 index 87da9db26df..00000000000 --- a/src/vendor/toml/tests/invalid/text-after-table.toml +++ /dev/null @@ -1 +0,0 @@ -[error] this shouldn't be here diff --git a/src/vendor/toml/tests/invalid/text-before-array-separator.toml b/src/vendor/toml/tests/invalid/text-before-array-separator.toml deleted file mode 100644 index 9b06a392410..00000000000 --- a/src/vendor/toml/tests/invalid/text-before-array-separator.toml +++ /dev/null @@ -1,4 +0,0 @@ -array = [ - "Is there life before an array separator?" No, - "Entry" -] diff --git a/src/vendor/toml/tests/invalid/text-in-array.toml b/src/vendor/toml/tests/invalid/text-in-array.toml deleted file mode 100644 index a6a6c42075e..00000000000 --- a/src/vendor/toml/tests/invalid/text-in-array.toml +++ /dev/null @@ -1,5 +0,0 @@ -array = [ - "Entry 1", - I don't belong, - "Entry 2", -] diff --git a/src/vendor/toml/tests/valid.rs b/src/vendor/toml/tests/valid.rs deleted file mode 100644 index 09589c9e7a9..00000000000 --- a/src/vendor/toml/tests/valid.rs +++ /dev/null @@ -1,195 +0,0 @@ -extern crate rustc_serialize; -extern crate toml; - -use std::collections::BTreeMap; -use rustc_serialize::json::Json; - -use toml::{Parser, Value}; -use toml::Value::{Table, Integer, Float, Boolean, Datetime, Array}; - -fn to_json(toml: Value) -> Json { - fn doit(s: &str, json: Json) -> Json { - let mut map = BTreeMap::new(); - map.insert(format!("{}", "type"), Json::String(format!("{}", s))); - map.insert(format!("{}", "value"), json); - Json::Object(map) - } - match toml { - Value::String(s) => doit("string", Json::String(s)), - Integer(i) => doit("integer", Json::String(format!("{}", i))), - Float(f) => doit("float", Json::String({ - let s = format!("{:.15}", f); - let s = format!("{}", s.trim_right_matches('0')); - if s.ends_with(".") {format!("{}0", s)} else {s} - })), - Boolean(b) => doit("bool", Json::String(format!("{}", b))), - Datetime(s) => doit("datetime", Json::String(s)), - Array(arr) => { - let is_table = match arr.first() { - Some(&Table(..)) => true, - _ => false, - }; - let json = Json::Array(arr.into_iter().map(to_json).collect()); - if is_table {json} else {doit("array", json)} - } - Table(table) => Json::Object(table.into_iter().map(|(k, v)| { - (k, to_json(v)) - }).collect()), - } -} - -fn run(toml: &str, json: &str) { - let mut p = Parser::new(toml); - let table = p.parse(); - assert!(p.errors.len() == 0, "had_errors: {:?}", - p.errors.iter().map(|e| { - (e.desc.clone(), &toml[e.lo - 5..e.hi + 5]) - }).collect::<Vec<(String, &str)>>()); - assert!(table.is_some()); - let toml = Table(table.unwrap()); - let toml_string = format!("{}", toml); - - let json = Json::from_str(json).unwrap(); - let toml_json = to_json(toml.clone()); - assert!(json == toml_json, - "expected\n{}\ngot\n{}\n", - json.pretty(), - toml_json.pretty()); - - let table2 = Parser::new(&toml_string).parse().unwrap(); - // floats are a little lossy - if table2.values().any(|v| v.as_float().is_some()) { return } - assert_eq!(toml, Table(table2)); -} - -macro_rules! test( ($name:ident, $toml:expr, $json:expr) => ( - #[test] - fn $name() { run($toml, $json); } -) ); - -test!(array_empty, - include_str!("valid/array-empty.toml"), - include_str!("valid/array-empty.json")); -test!(array_nospaces, - include_str!("valid/array-nospaces.toml"), - include_str!("valid/array-nospaces.json")); -test!(arrays_hetergeneous, - include_str!("valid/arrays-hetergeneous.toml"), - include_str!("valid/arrays-hetergeneous.json")); -test!(arrays, - include_str!("valid/arrays.toml"), - include_str!("valid/arrays.json")); -test!(arrays_nested, - include_str!("valid/arrays-nested.toml"), - include_str!("valid/arrays-nested.json")); -test!(empty, - include_str!("valid/empty.toml"), - include_str!("valid/empty.json")); -test!(bool, - include_str!("valid/bool.toml"), - include_str!("valid/bool.json")); -test!(datetime, - include_str!("valid/datetime.toml"), - include_str!("valid/datetime.json")); -test!(example, - include_str!("valid/example.toml"), - include_str!("valid/example.json")); -test!(float, - include_str!("valid/float.toml"), - include_str!("valid/float.json")); -test!(implicit_and_explicit_after, - include_str!("valid/implicit-and-explicit-after.toml"), - include_str!("valid/implicit-and-explicit-after.json")); -test!(implicit_and_explicit_before, - include_str!("valid/implicit-and-explicit-before.toml"), - include_str!("valid/implicit-and-explicit-before.json")); -test!(implicit_groups, - include_str!("valid/implicit-groups.toml"), - include_str!("valid/implicit-groups.json")); -test!(integer, - include_str!("valid/integer.toml"), - include_str!("valid/integer.json")); -test!(key_equals_nospace, - include_str!("valid/key-equals-nospace.toml"), - include_str!("valid/key-equals-nospace.json")); -test!(key_space, - include_str!("valid/key-space.toml"), - include_str!("valid/key-space.json")); -test!(key_special_chars, - include_str!("valid/key-special-chars.toml"), - include_str!("valid/key-special-chars.json")); -test!(key_with_pound, - include_str!("valid/key-with-pound.toml"), - include_str!("valid/key-with-pound.json")); -test!(long_float, - include_str!("valid/long-float.toml"), - include_str!("valid/long-float.json")); -test!(long_integer, - include_str!("valid/long-integer.toml"), - include_str!("valid/long-integer.json")); -test!(multiline_string, - include_str!("valid/multiline-string.toml"), - include_str!("valid/multiline-string.json")); -test!(raw_multiline_string, - include_str!("valid/raw-multiline-string.toml"), - include_str!("valid/raw-multiline-string.json")); -test!(raw_string, - include_str!("valid/raw-string.toml"), - include_str!("valid/raw-string.json")); -test!(string_empty, - include_str!("valid/string-empty.toml"), - include_str!("valid/string-empty.json")); -test!(string_escapes, - include_str!("valid/string-escapes.toml"), - include_str!("valid/string-escapes.json")); -test!(string_simple, - include_str!("valid/string-simple.toml"), - include_str!("valid/string-simple.json")); -test!(string_with_pound, - include_str!("valid/string-with-pound.toml"), - include_str!("valid/string-with-pound.json")); -test!(table_array_implicit, - include_str!("valid/table-array-implicit.toml"), - include_str!("valid/table-array-implicit.json")); -test!(table_array_many, - include_str!("valid/table-array-many.toml"), - include_str!("valid/table-array-many.json")); -test!(table_array_nest, - include_str!("valid/table-array-nest.toml"), - include_str!("valid/table-array-nest.json")); -test!(table_array_one, - include_str!("valid/table-array-one.toml"), - include_str!("valid/table-array-one.json")); -test!(table_empty, - include_str!("valid/table-empty.toml"), - include_str!("valid/table-empty.json")); -test!(table_sub_empty, - include_str!("valid/table-sub-empty.toml"), - include_str!("valid/table-sub-empty.json")); -test!(table_whitespace, - include_str!("valid/table-whitespace.toml"), - include_str!("valid/table-whitespace.json")); -test!(table_with_pound, - include_str!("valid/table-with-pound.toml"), - include_str!("valid/table-with-pound.json")); -test!(unicode_escape, - include_str!("valid/unicode-escape.toml"), - include_str!("valid/unicode-escape.json")); -test!(unicode_literal, - include_str!("valid/unicode-literal.toml"), - include_str!("valid/unicode-literal.json")); -test!(hard_example, - include_str!("valid/hard_example.toml"), - include_str!("valid/hard_example.json")); -test!(example2, - include_str!("valid/example2.toml"), - include_str!("valid/example2.json")); -test!(example3, - include_str!("valid/example-v0.3.0.toml"), - include_str!("valid/example-v0.3.0.json")); -test!(example4, - include_str!("valid/example-v0.4.0.toml"), - include_str!("valid/example-v0.4.0.json")); -test!(example_bom, - include_str!("valid/example-bom.toml"), - include_str!("valid/example.json")); diff --git a/src/vendor/toml/tests/valid/array-empty.json b/src/vendor/toml/tests/valid/array-empty.json deleted file mode 100644 index 2fbf2567f87..00000000000 --- a/src/vendor/toml/tests/valid/array-empty.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "thevoid": { "type": "array", "value": [ - {"type": "array", "value": [ - {"type": "array", "value": [ - {"type": "array", "value": [ - {"type": "array", "value": []} - ]} - ]} - ]} - ]} -} diff --git a/src/vendor/toml/tests/valid/array-empty.toml b/src/vendor/toml/tests/valid/array-empty.toml deleted file mode 100644 index fa58dc63d48..00000000000 --- a/src/vendor/toml/tests/valid/array-empty.toml +++ /dev/null @@ -1 +0,0 @@ -thevoid = [[[[[]]]]] diff --git a/src/vendor/toml/tests/valid/array-nospaces.json b/src/vendor/toml/tests/valid/array-nospaces.json deleted file mode 100644 index 1833d61c559..00000000000 --- a/src/vendor/toml/tests/valid/array-nospaces.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ints": { - "type": "array", - "value": [ - {"type": "integer", "value": "1"}, - {"type": "integer", "value": "2"}, - {"type": "integer", "value": "3"} - ] - } -} diff --git a/src/vendor/toml/tests/valid/array-nospaces.toml b/src/vendor/toml/tests/valid/array-nospaces.toml deleted file mode 100644 index 66189367fe9..00000000000 --- a/src/vendor/toml/tests/valid/array-nospaces.toml +++ /dev/null @@ -1 +0,0 @@ -ints = [1,2,3] diff --git a/src/vendor/toml/tests/valid/arrays-hetergeneous.json b/src/vendor/toml/tests/valid/arrays-hetergeneous.json deleted file mode 100644 index 478fa5c706b..00000000000 --- a/src/vendor/toml/tests/valid/arrays-hetergeneous.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "mixed": { - "type": "array", - "value": [ - {"type": "array", "value": [ - {"type": "integer", "value": "1"}, - {"type": "integer", "value": "2"} - ]}, - {"type": "array", "value": [ - {"type": "string", "value": "a"}, - {"type": "string", "value": "b"} - ]}, - {"type": "array", "value": [ - {"type": "float", "value": "1.1"}, - {"type": "float", "value": "2.1"} - ]} - ] - } -} diff --git a/src/vendor/toml/tests/valid/arrays-hetergeneous.toml b/src/vendor/toml/tests/valid/arrays-hetergeneous.toml deleted file mode 100644 index a246fcf1deb..00000000000 --- a/src/vendor/toml/tests/valid/arrays-hetergeneous.toml +++ /dev/null @@ -1 +0,0 @@ -mixed = [[1, 2], ["a", "b"], [1.1, 2.1]] diff --git a/src/vendor/toml/tests/valid/arrays-nested.json b/src/vendor/toml/tests/valid/arrays-nested.json deleted file mode 100644 index d21920cc3eb..00000000000 --- a/src/vendor/toml/tests/valid/arrays-nested.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "nest": { - "type": "array", - "value": [ - {"type": "array", "value": [ - {"type": "string", "value": "a"} - ]}, - {"type": "array", "value": [ - {"type": "string", "value": "b"} - ]} - ] - } -} diff --git a/src/vendor/toml/tests/valid/arrays-nested.toml b/src/vendor/toml/tests/valid/arrays-nested.toml deleted file mode 100644 index ce3302249b7..00000000000 --- a/src/vendor/toml/tests/valid/arrays-nested.toml +++ /dev/null @@ -1 +0,0 @@ -nest = [["a"], ["b"]] diff --git a/src/vendor/toml/tests/valid/arrays.json b/src/vendor/toml/tests/valid/arrays.json deleted file mode 100644 index 58aedbccbef..00000000000 --- a/src/vendor/toml/tests/valid/arrays.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "ints": { - "type": "array", - "value": [ - {"type": "integer", "value": "1"}, - {"type": "integer", "value": "2"}, - {"type": "integer", "value": "3"} - ] - }, - "floats": { - "type": "array", - "value": [ - {"type": "float", "value": "1.1"}, - {"type": "float", "value": "2.1"}, - {"type": "float", "value": "3.1"} - ] - }, - "strings": { - "type": "array", - "value": [ - {"type": "string", "value": "a"}, - {"type": "string", "value": "b"}, - {"type": "string", "value": "c"} - ] - }, - "dates": { - "type": "array", - "value": [ - {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, - {"type": "datetime", "value": "1979-05-27T07:32:00Z"}, - {"type": "datetime", "value": "2006-06-01T11:00:00Z"} - ] - } -} diff --git a/src/vendor/toml/tests/valid/arrays.toml b/src/vendor/toml/tests/valid/arrays.toml deleted file mode 100644 index c435f57b62c..00000000000 --- a/src/vendor/toml/tests/valid/arrays.toml +++ /dev/null @@ -1,8 +0,0 @@ -ints = [1, 2, 3] -floats = [1.1, 2.1, 3.1] -strings = ["a", "b", "c"] -dates = [ - 1987-07-05T17:45:00Z, - 1979-05-27T07:32:00Z, - 2006-06-01T11:00:00Z, -] diff --git a/src/vendor/toml/tests/valid/bool.json b/src/vendor/toml/tests/valid/bool.json deleted file mode 100644 index ae368e9492e..00000000000 --- a/src/vendor/toml/tests/valid/bool.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "f": {"type": "bool", "value": "false"}, - "t": {"type": "bool", "value": "true"} -} diff --git a/src/vendor/toml/tests/valid/bool.toml b/src/vendor/toml/tests/valid/bool.toml deleted file mode 100644 index a8a829b34de..00000000000 --- a/src/vendor/toml/tests/valid/bool.toml +++ /dev/null @@ -1,2 +0,0 @@ -t = true -f = false diff --git a/src/vendor/toml/tests/valid/comments-everywhere.json b/src/vendor/toml/tests/valid/comments-everywhere.json deleted file mode 100644 index e69a2e95823..00000000000 --- a/src/vendor/toml/tests/valid/comments-everywhere.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "group": { - "answer": {"type": "integer", "value": "42"}, - "more": { - "type": "array", - "value": [ - {"type": "integer", "value": "42"}, - {"type": "integer", "value": "42"} - ] - } - } -} diff --git a/src/vendor/toml/tests/valid/comments-everywhere.toml b/src/vendor/toml/tests/valid/comments-everywhere.toml deleted file mode 100644 index 3dca74cade5..00000000000 --- a/src/vendor/toml/tests/valid/comments-everywhere.toml +++ /dev/null @@ -1,24 +0,0 @@ -# Top comment. - # Top comment. -# Top comment. - -# [no-extraneous-groups-please] - -[group] # Comment -answer = 42 # Comment -# no-extraneous-keys-please = 999 -# Inbetween comment. -more = [ # Comment - # What about multiple # comments? - # Can you handle it? - # - # Evil. -# Evil. - 42, 42, # Comments within arrays are fun. - # What about multiple # comments? - # Can you handle it? - # - # Evil. -# Evil. -# ] Did I fool you? -] # Hopefully not. diff --git a/src/vendor/toml/tests/valid/datetime.json b/src/vendor/toml/tests/valid/datetime.json deleted file mode 100644 index 2ca93ce966f..00000000000 --- a/src/vendor/toml/tests/valid/datetime.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "bestdayever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"} -} diff --git a/src/vendor/toml/tests/valid/datetime.toml b/src/vendor/toml/tests/valid/datetime.toml deleted file mode 100644 index 2e993407d71..00000000000 --- a/src/vendor/toml/tests/valid/datetime.toml +++ /dev/null @@ -1 +0,0 @@ -bestdayever = 1987-07-05T17:45:00Z diff --git a/src/vendor/toml/tests/valid/empty.json b/src/vendor/toml/tests/valid/empty.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/src/vendor/toml/tests/valid/empty.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/vendor/toml/tests/valid/empty.toml b/src/vendor/toml/tests/valid/empty.toml deleted file mode 100644 index e69de29bb2d..00000000000 --- a/src/vendor/toml/tests/valid/empty.toml +++ /dev/null diff --git a/src/vendor/toml/tests/valid/example-bom.toml b/src/vendor/toml/tests/valid/example-bom.toml deleted file mode 100644 index fb5ac815c9b..00000000000 --- a/src/vendor/toml/tests/valid/example-bom.toml +++ /dev/null @@ -1,5 +0,0 @@ -best-day-ever = 1987-07-05T17:45:00Z - -[numtheory] -boring = false -perfection = [6, 28, 496] diff --git a/src/vendor/toml/tests/valid/example-v0.3.0.json b/src/vendor/toml/tests/valid/example-v0.3.0.json deleted file mode 100644 index 1d9dcb581c2..00000000000 --- a/src/vendor/toml/tests/valid/example-v0.3.0.json +++ /dev/null @@ -1 +0,0 @@ -{"Array":{"key1":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key2":{"type":"array","value":[{"type":"string","value":"red"},{"type":"string","value":"yellow"},{"type":"string","value":"green"}]},"key3":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"integer","value":"3"},{"type":"integer","value":"4"},{"type":"integer","value":"5"}]}]},"key4":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"string","value":"a"},{"type":"string","value":"b"},{"type":"string","value":"c"}]}]},"key5":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key6":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}},"Booleans":{"False":{"type":"bool","value":"false"},"True":{"type":"bool","value":"true"}},"Datetime":{"key1":{"type":"datetime","value":"1979-05-27T07:32:00Z"}},"Float":{"both":{},"exponent":{},"fractional":{"key1":{"type":"float","value":"1.0"},"key2":{"type":"float","value":"3.1415"},"key3":{"type":"float","value":"-0.01"}}},"Integer":{"key1":{"type":"integer","value":"99"},"key2":{"type":"integer","value":"42"},"key3":{"type":"integer","value":"0"},"key4":{"type":"integer","value":"-17"}},"String":{"Literal":{"Multiline":{"lines":{"type":"string","value":"The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"},"regex2":{"type":"string","value":"I [dw]on't need \\d{2} apples"}},"quoted":{"type":"string","value":"Tom \"Dubs\" Preston-Werner"},"regex":{"type":"string","value":"\u003c\\i\\c*\\s*\u003e"},"winpath":{"type":"string","value":"C:\\Users\\nodejs\\templates"},"winpath2":{"type":"string","value":"\\\\ServerX\\admin$\\system32\\"}},"Multiline":{"key1":{"type":"string","value":"One\nTwo"},"key2":{"type":"string","value":"One\nTwo"},"key3":{"type":"string","value":"One\nTwo"}},"Multilined":{"Singleline":{"key1":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key2":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key3":{"type":"string","value":"The quick brown fox jumps over the lazy dog."}}},"basic":{"type":"string","value":"I'm a string. \"You can quote me\". Name\u0009José\nLocation\u0009SF."}},"Table":{"key":{"type":"string","value":"value"}},"dog":{"tater":{"type":{"type":"string","value":"pug"}}},"fruit":[{"name":{"type":"string","value":"apple"},"physical":{"color":{"type":"string","value":"red"},"shape":{"type":"string","value":"round"}},"variety":[{"name":{"type":"string","value":"red delicious"}},{"name":{"type":"string","value":"granny smith"}}]},{"name":{"type":"string","value":"banana"},"variety":[{"name":{"type":"string","value":"plantain"}}]}],"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"x":{"y":{"z":{"w":{}}}}} diff --git a/src/vendor/toml/tests/valid/example-v0.3.0.toml b/src/vendor/toml/tests/valid/example-v0.3.0.toml deleted file mode 100644 index 76aacc31aac..00000000000 --- a/src/vendor/toml/tests/valid/example-v0.3.0.toml +++ /dev/null @@ -1,182 +0,0 @@ -# Comment -# I am a comment. Hear me roar. Roar. - -# Table -# Tables (also known as hash tables or dictionaries) are collections of key/value pairs. -# They appear in square brackets on a line by themselves. - -[Table] - -key = "value" # Yeah, you can do this. - -# Nested tables are denoted by table names with dots in them. Name your tables whatever crap you please, just don't use #, ., [ or ]. - -[dog.tater] -type = "pug" - -# You don't need to specify all the super-tables if you don't want to. TOML knows how to do it for you. - -# [x] you -# [x.y] don't -# [x.y.z] need these -[x.y.z.w] # for this to work - -# String -# There are four ways to express strings: basic, multi-line basic, literal, and multi-line literal. -# All strings must contain only valid UTF-8 characters. - -[String] -basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." - -[String.Multiline] - -# The following strings are byte-for-byte equivalent: -key1 = "One\nTwo" -key2 = """One\nTwo""" -key3 = """ -One -Two""" - -[String.Multilined.Singleline] - -# The following strings are byte-for-byte equivalent: -key1 = "The quick brown fox jumps over the lazy dog." - -key2 = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" - -key3 = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """ - -[String.Literal] - -# What you see is what you get. -winpath = 'C:\Users\nodejs\templates' -winpath2 = '\\ServerX\admin$\system32\' -quoted = 'Tom "Dubs" Preston-Werner' -regex = '<\i\c*\s*>' - - -[String.Literal.Multiline] - -regex2 = '''I [dw]on't need \d{2} apples''' -lines = ''' -The first newline is -trimmed in raw strings. - All other whitespace - is preserved. -''' - -# Integer -# Integers are whole numbers. Positive numbers may be prefixed with a plus sign. -# Negative numbers are prefixed with a minus sign. - -[Integer] -key1 = +99 -key2 = 42 -key3 = 0 -key4 = -17 - -# Float -# A float consists of an integer part (which may be prefixed with a plus or minus sign) -# followed by a fractional part and/or an exponent part. - -[Float.fractional] - -# fractional -key1 = +1.0 -key2 = 3.1415 -key3 = -0.01 - -[Float.exponent] - -# exponent -#key1 = 5e+22 -#key2 = 1e6 -#key3 = -2E-2 - -[Float.both] - -# both -#key = 6.626e-34 - -# Boolean -# Booleans are just the tokens you're used to. Always lowercase. - -[Booleans] -True = true -False = false - -# Datetime -# Datetimes are RFC 3339 dates. - -[Datetime] -key1 = 1979-05-27T07:32:00Z -#key2 = 1979-05-27T00:32:00-07:00 -#key3 = 1979-05-27T00:32:00.999999-07:00 - -# Array -# Arrays are square brackets with other primitives inside. Whitespace is ignored. Elements are separated by commas. Data types may not be mixed. - -[Array] -key1 = [ 1, 2, 3 ] -key2 = [ "red", "yellow", "green" ] -key3 = [ [ 1, 2 ], [3, 4, 5] ] -key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok - -#Arrays can also be multiline. So in addition to ignoring whitespace, arrays also ignore newlines between the brackets. -# Terminating commas are ok before the closing bracket. - -key5 = [ - 1, 2, 3 -] -key6 = [ - 1, - 2, # this is ok -] - -# Array of Tables -# These can be expressed by using a table name in double brackets. -# Each table with the same double bracketed name will be an element in the array. -# The tables are inserted in the order encountered. - -[[products]] -name = "Hammer" -sku = 738594937 - -[[products]] - -[[products]] -name = "Nail" -sku = 284758393 -color = "gray" - - -# You can create nested arrays of tables as well. - -[[fruit]] - name = "apple" - - [fruit.physical] - color = "red" - shape = "round" - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - -[[fruit]] - name = "banana" - - [[fruit.variety]] - name = "plantain" - diff --git a/src/vendor/toml/tests/valid/example-v0.4.0.json b/src/vendor/toml/tests/valid/example-v0.4.0.json deleted file mode 100644 index d5cac343a81..00000000000 --- a/src/vendor/toml/tests/valid/example-v0.4.0.json +++ /dev/null @@ -1 +0,0 @@ -{"array":{"key1":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key2":{"type":"array","value":[{"type":"string","value":"red"},{"type":"string","value":"yellow"},{"type":"string","value":"green"}]},"key3":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"integer","value":"3"},{"type":"integer","value":"4"},{"type":"integer","value":"5"}]}]},"key4":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"string","value":"a"},{"type":"string","value":"b"},{"type":"string","value":"c"}]}]},"key5":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key6":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}},"boolean":{"False":{"type":"bool","value":"false"},"True":{"type":"bool","value":"true"}},"datetime":{},"float":{"both":{},"exponent":{},"fractional":{"key1":{"type":"float","value":"1.0"},"key2":{"type":"float","value":"3.1415"},"key3":{"type":"float","value":"-0.01"}},"underscores":{}},"fruit":[{"name":{"type":"string","value":"apple"},"physical":{"color":{"type":"string","value":"red"},"shape":{"type":"string","value":"round"}},"variety":[{"name":{"type":"string","value":"red delicious"}},{"name":{"type":"string","value":"granny smith"}}]},{"name":{"type":"string","value":"banana"},"variety":[{"name":{"type":"string","value":"plantain"}}]}],"integer":{"key1":{"type":"integer","value":"99"},"key2":{"type":"integer","value":"42"},"key3":{"type":"integer","value":"0"},"key4":{"type":"integer","value":"-17"},"underscores":{"key1":{"type":"integer","value":"1000"},"key2":{"type":"integer","value":"5349221"},"key3":{"type":"integer","value":"12345"}}},"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"string":{"basic":{"basic":{"type":"string","value":"I'm a string. \"You can quote me\". Name\u0009José\nLocation\u0009SF."}},"literal":{"multiline":{"lines":{"type":"string","value":"The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"},"regex2":{"type":"string","value":"I [dw]on't need \\d{2} apples"}},"quoted":{"type":"string","value":"Tom \"Dubs\" Preston-Werner"},"regex":{"type":"string","value":"\u003c\\i\\c*\\s*\u003e"},"winpath":{"type":"string","value":"C:\\Users\\nodejs\\templates"},"winpath2":{"type":"string","value":"\\\\ServerX\\admin$\\system32\\"}},"multiline":{"continued":{"key1":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key2":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key3":{"type":"string","value":"The quick brown fox jumps over the lazy dog."}},"key1":{"type":"string","value":"One\nTwo"},"key2":{"type":"string","value":"One\nTwo"},"key3":{"type":"string","value":"One\nTwo"}}},"table":{"inline":{"name":{"first":{"type":"string","value":"Tom"},"last":{"type":"string","value":"Preston-Werner"}},"point":{"x":{"type":"integer","value":"1"},"y":{"type":"integer","value":"2"}}},"key":{"type":"string","value":"value"},"subtable":{"key":{"type":"string","value":"another value"}}},"x":{"y":{"z":{"w":{}}}}} diff --git a/src/vendor/toml/tests/valid/example-v0.4.0.toml b/src/vendor/toml/tests/valid/example-v0.4.0.toml deleted file mode 100644 index ffbcce0d9df..00000000000 --- a/src/vendor/toml/tests/valid/example-v0.4.0.toml +++ /dev/null @@ -1,235 +0,0 @@ -################################################################################ -## Comment - -# Speak your mind with the hash symbol. They go from the symbol to the end of -# the line. - - -################################################################################ -## Table - -# Tables (also known as hash tables or dictionaries) are collections of -# key/value pairs. They appear in square brackets on a line by themselves. - -[table] - -key = "value" # Yeah, you can do this. - -# Nested tables are denoted by table names with dots in them. Name your tables -# whatever crap you please, just don't use #, ., [ or ]. - -[table.subtable] - -key = "another value" - -# You don't need to specify all the super-tables if you don't want to. TOML -# knows how to do it for you. - -# [x] you -# [x.y] don't -# [x.y.z] need these -[x.y.z.w] # for this to work - - -################################################################################ -## Inline Table - -# Inline tables provide a more compact syntax for expressing tables. They are -# especially useful for grouped data that can otherwise quickly become verbose. -# Inline tables are enclosed in curly braces `{` and `}`. No newlines are -# allowed between the curly braces unless they are valid within a value. - -[table.inline] - -name = { first = "Tom", last = "Preston-Werner" } -point = { x = 1, y = 2 } - - -################################################################################ -## String - -# There are four ways to express strings: basic, multi-line basic, literal, and -# multi-line literal. All strings must contain only valid UTF-8 characters. - -[string.basic] - -basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." - -[string.multiline] - -# The following strings are byte-for-byte equivalent: -key1 = "One\nTwo" -key2 = """One\nTwo""" -key3 = """ -One -Two""" - -[string.multiline.continued] - -# The following strings are byte-for-byte equivalent: -key1 = "The quick brown fox jumps over the lazy dog." - -key2 = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" - -key3 = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """ - -[string.literal] - -# What you see is what you get. -winpath = 'C:\Users\nodejs\templates' -winpath2 = '\\ServerX\admin$\system32\' -quoted = 'Tom "Dubs" Preston-Werner' -regex = '<\i\c*\s*>' - - -[string.literal.multiline] - -regex2 = '''I [dw]on't need \d{2} apples''' -lines = ''' -The first newline is -trimmed in raw strings. - All other whitespace - is preserved. -''' - - -################################################################################ -## Integer - -# Integers are whole numbers. Positive numbers may be prefixed with a plus sign. -# Negative numbers are prefixed with a minus sign. - -[integer] - -key1 = +99 -key2 = 42 -key3 = 0 -key4 = -17 - -[integer.underscores] - -# For large numbers, you may use underscores to enhance readability. Each -# underscore must be surrounded by at least one digit. -key1 = 1_000 -key2 = 5_349_221 -key3 = 1_2_3_4_5 # valid but inadvisable - - -################################################################################ -## Float - -# A float consists of an integer part (which may be prefixed with a plus or -# minus sign) followed by a fractional part and/or an exponent part. - -[float.fractional] - -key1 = +1.0 -key2 = 3.1415 -key3 = -0.01 - -[float.exponent] - -[float.both] - -[float.underscores] - - -################################################################################ -## Boolean - -# Booleans are just the tokens you're used to. Always lowercase. - -[boolean] - -True = true -False = false - - -################################################################################ -## Datetime - -# Datetimes are RFC 3339 dates. - -[datetime] - -#key1 = 1979-05-27T07:32:00Z -#key2 = 1979-05-27T00:32:00-07:00 -#key3 = 1979-05-27T00:32:00.999999-07:00 - - -################################################################################ -## Array - -# Arrays are square brackets with other primitives inside. Whitespace is -# ignored. Elements are separated by commas. Data types may not be mixed. - -[array] - -key1 = [ 1, 2, 3 ] -key2 = [ "red", "yellow", "green" ] -key3 = [ [ 1, 2 ], [3, 4, 5] ] -key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok - -# Arrays can also be multiline. So in addition to ignoring whitespace, arrays -# also ignore newlines between the brackets. Terminating commas are ok before -# the closing bracket. - -key5 = [ - 1, 2, 3 -] -key6 = [ - 1, - 2, # this is ok -] - - -################################################################################ -## Array of Tables - -# These can be expressed by using a table name in double brackets. Each table -# with the same double bracketed name will be an element in the array. The -# tables are inserted in the order encountered. - -[[products]] - -name = "Hammer" -sku = 738594937 - -[[products]] - -[[products]] - -name = "Nail" -sku = 284758393 -color = "gray" - - -# You can create nested arrays of tables as well. - -[[fruit]] - name = "apple" - - [fruit.physical] - color = "red" - shape = "round" - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - -[[fruit]] - name = "banana" - - [[fruit.variety]] - name = "plantain" diff --git a/src/vendor/toml/tests/valid/example.json b/src/vendor/toml/tests/valid/example.json deleted file mode 100644 index 48aa90784a4..00000000000 --- a/src/vendor/toml/tests/valid/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "best-day-ever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, - "numtheory": { - "boring": {"type": "bool", "value": "false"}, - "perfection": { - "type": "array", - "value": [ - {"type": "integer", "value": "6"}, - {"type": "integer", "value": "28"}, - {"type": "integer", "value": "496"} - ] - } - } -} diff --git a/src/vendor/toml/tests/valid/example.toml b/src/vendor/toml/tests/valid/example.toml deleted file mode 100644 index 8cb02e01b03..00000000000 --- a/src/vendor/toml/tests/valid/example.toml +++ /dev/null @@ -1,5 +0,0 @@ -best-day-ever = 1987-07-05T17:45:00Z - -[numtheory] -boring = false -perfection = [6, 28, 496] diff --git a/src/vendor/toml/tests/valid/example2.json b/src/vendor/toml/tests/valid/example2.json deleted file mode 100644 index 3249a974fba..00000000000 --- a/src/vendor/toml/tests/valid/example2.json +++ /dev/null @@ -1 +0,0 @@ -{"clients":{"data":{"type":"array","value":[{"type":"array","value":[{"type":"string","value":"gamma"},{"type":"string","value":"delta"}]},{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}]},"hosts":{"type":"array","value":[{"type":"string","value":"alpha"},{"type":"string","value":"omega"}]}},"database":{"connection_max":{"type":"integer","value":"5000"},"enabled":{"type":"bool","value":"true"},"ports":{"type":"array","value":[{"type":"integer","value":"8001"},{"type":"integer","value":"8001"},{"type":"integer","value":"8002"}]},"server":{"type":"string","value":"192.168.1.1"}},"owner":{"bio":{"type":"string","value":"GitHub Cofounder \u0026 CEO\nLikes tater tots and beer."},"dob":{"type":"datetime","value":"1979-05-27T07:32:00Z"},"name":{"type":"string","value":"Tom Preston-Werner"},"organization":{"type":"string","value":"GitHub"}},"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"servers":{"alpha":{"dc":{"type":"string","value":"eqdc10"},"ip":{"type":"string","value":"10.0.0.1"}},"beta":{"country":{"type":"string","value":"中国"},"dc":{"type":"string","value":"eqdc10"},"ip":{"type":"string","value":"10.0.0.2"}}},"title":{"type":"string","value":"TOML Example"}} diff --git a/src/vendor/toml/tests/valid/example2.toml b/src/vendor/toml/tests/valid/example2.toml deleted file mode 100644 index bc12c990160..00000000000 --- a/src/vendor/toml/tests/valid/example2.toml +++ /dev/null @@ -1,47 +0,0 @@ -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - country = "中国" # This should be parsed as UTF-8 - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] - -# Products - - [[products]] - name = "Hammer" - sku = 738594937 - - [[products]] - name = "Nail" - sku = 284758393 - color = "gray" diff --git a/src/vendor/toml/tests/valid/float.json b/src/vendor/toml/tests/valid/float.json deleted file mode 100644 index b8a2e97581f..00000000000 --- a/src/vendor/toml/tests/valid/float.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "pi": {"type": "float", "value": "3.14"}, - "negpi": {"type": "float", "value": "-3.14"} -} diff --git a/src/vendor/toml/tests/valid/float.toml b/src/vendor/toml/tests/valid/float.toml deleted file mode 100644 index 7c528d200c3..00000000000 --- a/src/vendor/toml/tests/valid/float.toml +++ /dev/null @@ -1,2 +0,0 @@ -pi = 3.14 -negpi = -3.14 diff --git a/src/vendor/toml/tests/valid/hard_example.json b/src/vendor/toml/tests/valid/hard_example.json deleted file mode 100644 index 9762e58ef35..00000000000 --- a/src/vendor/toml/tests/valid/hard_example.json +++ /dev/null @@ -1 +0,0 @@ -{"the":{"hard":{"another_test_string":{"type":"string","value":" Same thing, but with a string #"},"bit#":{"multi_line_array":{"type":"array","value":[{"type":"string","value":"]"}]},"what?":{"type":"string","value":"You don't think some user won't do that?"}},"harder_test_string":{"type":"string","value":" And when \"'s are in the string, along with # \""},"test_array":{"type":"array","value":[{"type":"string","value":"] "},{"type":"string","value":" # "}]},"test_array2":{"type":"array","value":[{"type":"string","value":"Test #11 ]proved that"},{"type":"string","value":"Experiment #9 was a success"}]}},"test_string":{"type":"string","value":"You'll hate me after this - #"}}} diff --git a/src/vendor/toml/tests/valid/hard_example.toml b/src/vendor/toml/tests/valid/hard_example.toml deleted file mode 100644 index 38856c8737a..00000000000 --- a/src/vendor/toml/tests/valid/hard_example.toml +++ /dev/null @@ -1,33 +0,0 @@ -# Test file for TOML -# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate -# This part you'll really hate - -[the] -test_string = "You'll hate me after this - #" # " Annoying, isn't it? - - [the.hard] - test_array = [ "] ", " # "] # ] There you go, parse this! - test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] - # You didn't think it'd as easy as chucking out the last #, did you? - another_test_string = " Same thing, but with a string #" - harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" - # Things will get harder - - [the.hard."bit#"] - "what?" = "You don't think some user won't do that?" - multi_line_array = [ - "]", - # ] Oh yes I did - ] - -# Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test - -#[error] if you didn't catch this, your parser is broken -#string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this -#array = [ -# "This might most likely happen in multiline arrays", -# Like here, -# "or here, -# and here" -# ] End of array comment, forgot the # -#number = 3.14 pi <--again forgot the # diff --git a/src/vendor/toml/tests/valid/implicit-and-explicit-after.json b/src/vendor/toml/tests/valid/implicit-and-explicit-after.json deleted file mode 100644 index 374bd09343e..00000000000 --- a/src/vendor/toml/tests/valid/implicit-and-explicit-after.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "a": { - "better": {"type": "integer", "value": "43"}, - "b": { - "c": { - "answer": {"type": "integer", "value": "42"} - } - } - } -} diff --git a/src/vendor/toml/tests/valid/implicit-and-explicit-after.toml b/src/vendor/toml/tests/valid/implicit-and-explicit-after.toml deleted file mode 100644 index c0e8865b392..00000000000 --- a/src/vendor/toml/tests/valid/implicit-and-explicit-after.toml +++ /dev/null @@ -1,5 +0,0 @@ -[a.b.c] -answer = 42 - -[a] -better = 43 diff --git a/src/vendor/toml/tests/valid/implicit-and-explicit-before.json b/src/vendor/toml/tests/valid/implicit-and-explicit-before.json deleted file mode 100644 index 374bd09343e..00000000000 --- a/src/vendor/toml/tests/valid/implicit-and-explicit-before.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "a": { - "better": {"type": "integer", "value": "43"}, - "b": { - "c": { - "answer": {"type": "integer", "value": "42"} - } - } - } -} diff --git a/src/vendor/toml/tests/valid/implicit-and-explicit-before.toml b/src/vendor/toml/tests/valid/implicit-and-explicit-before.toml deleted file mode 100644 index eee68ff5143..00000000000 --- a/src/vendor/toml/tests/valid/implicit-and-explicit-before.toml +++ /dev/null @@ -1,5 +0,0 @@ -[a] -better = 43 - -[a.b.c] -answer = 42 diff --git a/src/vendor/toml/tests/valid/implicit-groups.json b/src/vendor/toml/tests/valid/implicit-groups.json deleted file mode 100644 index fbae7fc71be..00000000000 --- a/src/vendor/toml/tests/valid/implicit-groups.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "a": { - "b": { - "c": { - "answer": {"type": "integer", "value": "42"} - } - } - } -} diff --git a/src/vendor/toml/tests/valid/implicit-groups.toml b/src/vendor/toml/tests/valid/implicit-groups.toml deleted file mode 100644 index b6333e49d57..00000000000 --- a/src/vendor/toml/tests/valid/implicit-groups.toml +++ /dev/null @@ -1,2 +0,0 @@ -[a.b.c] -answer = 42 diff --git a/src/vendor/toml/tests/valid/integer.json b/src/vendor/toml/tests/valid/integer.json deleted file mode 100644 index 61985a1e97c..00000000000 --- a/src/vendor/toml/tests/valid/integer.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "answer": {"type": "integer", "value": "42"}, - "neganswer": {"type": "integer", "value": "-42"} -} diff --git a/src/vendor/toml/tests/valid/integer.toml b/src/vendor/toml/tests/valid/integer.toml deleted file mode 100644 index c4f62972cb2..00000000000 --- a/src/vendor/toml/tests/valid/integer.toml +++ /dev/null @@ -1,2 +0,0 @@ -answer = 42 -neganswer = -42 diff --git a/src/vendor/toml/tests/valid/key-equals-nospace.json b/src/vendor/toml/tests/valid/key-equals-nospace.json deleted file mode 100644 index 1f8709ab9f4..00000000000 --- a/src/vendor/toml/tests/valid/key-equals-nospace.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "answer": {"type": "integer", "value": "42"} -} diff --git a/src/vendor/toml/tests/valid/key-equals-nospace.toml b/src/vendor/toml/tests/valid/key-equals-nospace.toml deleted file mode 100644 index 560901c5a43..00000000000 --- a/src/vendor/toml/tests/valid/key-equals-nospace.toml +++ /dev/null @@ -1 +0,0 @@ -answer=42 diff --git a/src/vendor/toml/tests/valid/key-space.json b/src/vendor/toml/tests/valid/key-space.json deleted file mode 100644 index 9d1f76911d5..00000000000 --- a/src/vendor/toml/tests/valid/key-space.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a b": {"type": "integer", "value": "1"} -} diff --git a/src/vendor/toml/tests/valid/key-space.toml b/src/vendor/toml/tests/valid/key-space.toml deleted file mode 100644 index f4f36c4f6df..00000000000 --- a/src/vendor/toml/tests/valid/key-space.toml +++ /dev/null @@ -1 +0,0 @@ -"a b" = 1 diff --git a/src/vendor/toml/tests/valid/key-special-chars.json b/src/vendor/toml/tests/valid/key-special-chars.json deleted file mode 100644 index 6550ebda232..00000000000 --- a/src/vendor/toml/tests/valid/key-special-chars.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "~!@#$^&*()_+-`1234567890[]\\|/?><.,;:'": { - "type": "integer", "value": "1" - } -} diff --git a/src/vendor/toml/tests/valid/key-special-chars.toml b/src/vendor/toml/tests/valid/key-special-chars.toml deleted file mode 100644 index dc43625d232..00000000000 --- a/src/vendor/toml/tests/valid/key-special-chars.toml +++ /dev/null @@ -1 +0,0 @@ -"~!@#$^&*()_+-`1234567890[]\\|/?><.,;:'" = 1 diff --git a/src/vendor/toml/tests/valid/key-with-pound.json b/src/vendor/toml/tests/valid/key-with-pound.json deleted file mode 100644 index ee39e1de4cb..00000000000 --- a/src/vendor/toml/tests/valid/key-with-pound.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "key#name": {"type": "integer", "value": "5"} -} diff --git a/src/vendor/toml/tests/valid/key-with-pound.toml b/src/vendor/toml/tests/valid/key-with-pound.toml deleted file mode 100644 index 65b766fd157..00000000000 --- a/src/vendor/toml/tests/valid/key-with-pound.toml +++ /dev/null @@ -1 +0,0 @@ -"key#name" = 5 diff --git a/src/vendor/toml/tests/valid/long-float.json b/src/vendor/toml/tests/valid/long-float.json deleted file mode 100644 index 8ceed47971e..00000000000 --- a/src/vendor/toml/tests/valid/long-float.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "longpi": {"type": "float", "value": "3.141592653589793"}, - "neglongpi": {"type": "float", "value": "-3.141592653589793"} -} diff --git a/src/vendor/toml/tests/valid/long-float.toml b/src/vendor/toml/tests/valid/long-float.toml deleted file mode 100644 index 9558ae47c02..00000000000 --- a/src/vendor/toml/tests/valid/long-float.toml +++ /dev/null @@ -1,2 +0,0 @@ -longpi = 3.141592653589793 -neglongpi = -3.141592653589793 diff --git a/src/vendor/toml/tests/valid/long-integer.json b/src/vendor/toml/tests/valid/long-integer.json deleted file mode 100644 index 16c331ed398..00000000000 --- a/src/vendor/toml/tests/valid/long-integer.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "answer": {"type": "integer", "value": "9223372036854775807"}, - "neganswer": {"type": "integer", "value": "-9223372036854775808"} -} diff --git a/src/vendor/toml/tests/valid/long-integer.toml b/src/vendor/toml/tests/valid/long-integer.toml deleted file mode 100644 index 424a13ac2af..00000000000 --- a/src/vendor/toml/tests/valid/long-integer.toml +++ /dev/null @@ -1,2 +0,0 @@ -answer = 9223372036854775807 -neganswer = -9223372036854775808 diff --git a/src/vendor/toml/tests/valid/multiline-string.json b/src/vendor/toml/tests/valid/multiline-string.json deleted file mode 100644 index 075bf505464..00000000000 --- a/src/vendor/toml/tests/valid/multiline-string.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "multiline_empty_one": { - "type": "string", - "value": "" - }, - "multiline_empty_two": { - "type": "string", - "value": "" - }, - "multiline_empty_three": { - "type": "string", - "value": "" - }, - "multiline_empty_four": { - "type": "string", - "value": "" - }, - "equivalent_one": { - "type": "string", - "value": "The quick brown fox jumps over the lazy dog." - }, - "equivalent_two": { - "type": "string", - "value": "The quick brown fox jumps over the lazy dog." - }, - "equivalent_three": { - "type": "string", - "value": "The quick brown fox jumps over the lazy dog." - } -} diff --git a/src/vendor/toml/tests/valid/multiline-string.toml b/src/vendor/toml/tests/valid/multiline-string.toml deleted file mode 100644 index 15b11434ff0..00000000000 --- a/src/vendor/toml/tests/valid/multiline-string.toml +++ /dev/null @@ -1,23 +0,0 @@ -multiline_empty_one = """""" -multiline_empty_two = """ -""" -multiline_empty_three = """\ - """ -multiline_empty_four = """\ - \ - \ - """ - -equivalent_one = "The quick brown fox jumps over the lazy dog." -equivalent_two = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" - -equivalent_three = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """ diff --git a/src/vendor/toml/tests/valid/raw-multiline-string.json b/src/vendor/toml/tests/valid/raw-multiline-string.json deleted file mode 100644 index b43cce5a2d1..00000000000 --- a/src/vendor/toml/tests/valid/raw-multiline-string.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "oneline": { - "type": "string", - "value": "This string has a ' quote character." - }, - "firstnl": { - "type": "string", - "value": "This string has a ' quote character." - }, - "multiline": { - "type": "string", - "value": "This string\nhas ' a quote character\nand more than\none newline\nin it." - } -} diff --git a/src/vendor/toml/tests/valid/raw-multiline-string.toml b/src/vendor/toml/tests/valid/raw-multiline-string.toml deleted file mode 100644 index 8094c03e31a..00000000000 --- a/src/vendor/toml/tests/valid/raw-multiline-string.toml +++ /dev/null @@ -1,9 +0,0 @@ -oneline = '''This string has a ' quote character.''' -firstnl = ''' -This string has a ' quote character.''' -multiline = ''' -This string -has ' a quote character -and more than -one newline -in it.''' diff --git a/src/vendor/toml/tests/valid/raw-string.json b/src/vendor/toml/tests/valid/raw-string.json deleted file mode 100644 index 693ab9b54a4..00000000000 --- a/src/vendor/toml/tests/valid/raw-string.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "backspace": { - "type": "string", - "value": "This string has a \\b backspace character." - }, - "tab": { - "type": "string", - "value": "This string has a \\t tab character." - }, - "newline": { - "type": "string", - "value": "This string has a \\n new line character." - }, - "formfeed": { - "type": "string", - "value": "This string has a \\f form feed character." - }, - "carriage": { - "type": "string", - "value": "This string has a \\r carriage return character." - }, - "slash": { - "type": "string", - "value": "This string has a \\/ slash character." - }, - "backslash": { - "type": "string", - "value": "This string has a \\\\ backslash character." - } -} diff --git a/src/vendor/toml/tests/valid/raw-string.toml b/src/vendor/toml/tests/valid/raw-string.toml deleted file mode 100644 index 92acd2557c4..00000000000 --- a/src/vendor/toml/tests/valid/raw-string.toml +++ /dev/null @@ -1,7 +0,0 @@ -backspace = 'This string has a \b backspace character.' -tab = 'This string has a \t tab character.' -newline = 'This string has a \n new line character.' -formfeed = 'This string has a \f form feed character.' -carriage = 'This string has a \r carriage return character.' -slash = 'This string has a \/ slash character.' -backslash = 'This string has a \\ backslash character.' diff --git a/src/vendor/toml/tests/valid/string-empty.json b/src/vendor/toml/tests/valid/string-empty.json deleted file mode 100644 index 6c26d695b29..00000000000 --- a/src/vendor/toml/tests/valid/string-empty.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "answer": { - "type": "string", - "value": "" - } -} diff --git a/src/vendor/toml/tests/valid/string-empty.toml b/src/vendor/toml/tests/valid/string-empty.toml deleted file mode 100644 index e37e6815bc7..00000000000 --- a/src/vendor/toml/tests/valid/string-empty.toml +++ /dev/null @@ -1 +0,0 @@ -answer = "" diff --git a/src/vendor/toml/tests/valid/string-escapes.json b/src/vendor/toml/tests/valid/string-escapes.json deleted file mode 100644 index 62dac5178fb..00000000000 --- a/src/vendor/toml/tests/valid/string-escapes.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "backspace": { - "type": "string", - "value": "This string has a \u0008 backspace character." - }, - "tab": { - "type": "string", - "value": "This string has a \u0009 tab character." - }, - "newline": { - "type": "string", - "value": "This string has a \u000A new line character." - }, - "formfeed": { - "type": "string", - "value": "This string has a \u000C form feed character." - }, - "carriage": { - "type": "string", - "value": "This string has a \u000D carriage return character." - }, - "quote": { - "type": "string", - "value": "This string has a \u0022 quote character." - }, - "slash": { - "type": "string", - "value": "This string has a \u002F slash character." - }, - "backslash": { - "type": "string", - "value": "This string has a \u005C backslash character." - }, - "notunicode1": { - "type": "string", - "value": "This string does not have a unicode \\u escape." - }, - "notunicode2": { - "type": "string", - "value": "This string does not have a unicode \u005Cu escape." - }, - "notunicode3": { - "type": "string", - "value": "This string does not have a unicode \\u0075 escape." - }, - "notunicode4": { - "type": "string", - "value": "This string does not have a unicode \\\u0075 escape." - } -} diff --git a/src/vendor/toml/tests/valid/string-escapes.toml b/src/vendor/toml/tests/valid/string-escapes.toml deleted file mode 100644 index c5d495428a1..00000000000 --- a/src/vendor/toml/tests/valid/string-escapes.toml +++ /dev/null @@ -1,12 +0,0 @@ -backspace = "This string has a \b backspace character." -tab = "This string has a \t tab character." -newline = "This string has a \n new line character." -formfeed = "This string has a \f form feed character." -carriage = "This string has a \r carriage return character." -quote = "This string has a \" quote character." -slash = "This string has a / slash character." -backslash = "This string has a \\ backslash character." -notunicode1 = "This string does not have a unicode \\u escape." -notunicode2 = "This string does not have a unicode \u005Cu escape." -notunicode3 = "This string does not have a unicode \\u0075 escape." -notunicode4 = "This string does not have a unicode \\\u0075 escape." diff --git a/src/vendor/toml/tests/valid/string-simple.json b/src/vendor/toml/tests/valid/string-simple.json deleted file mode 100644 index 2e05f99b4d1..00000000000 --- a/src/vendor/toml/tests/valid/string-simple.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "answer": { - "type": "string", - "value": "You are not drinking enough whisky." - } -} diff --git a/src/vendor/toml/tests/valid/string-simple.toml b/src/vendor/toml/tests/valid/string-simple.toml deleted file mode 100644 index e17ade6237b..00000000000 --- a/src/vendor/toml/tests/valid/string-simple.toml +++ /dev/null @@ -1 +0,0 @@ -answer = "You are not drinking enough whisky." diff --git a/src/vendor/toml/tests/valid/string-with-pound.json b/src/vendor/toml/tests/valid/string-with-pound.json deleted file mode 100644 index 33cdc9c4b58..00000000000 --- a/src/vendor/toml/tests/valid/string-with-pound.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pound": {"type": "string", "value": "We see no # comments here."}, - "poundcomment": { - "type": "string", - "value": "But there are # some comments here." - } -} diff --git a/src/vendor/toml/tests/valid/string-with-pound.toml b/src/vendor/toml/tests/valid/string-with-pound.toml deleted file mode 100644 index 5fd87466dff..00000000000 --- a/src/vendor/toml/tests/valid/string-with-pound.toml +++ /dev/null @@ -1,2 +0,0 @@ -pound = "We see no # comments here." -poundcomment = "But there are # some comments here." # Did I # mess you up? diff --git a/src/vendor/toml/tests/valid/table-array-implicit.json b/src/vendor/toml/tests/valid/table-array-implicit.json deleted file mode 100644 index 32e464012d6..00000000000 --- a/src/vendor/toml/tests/valid/table-array-implicit.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "albums": { - "songs": [ - {"name": {"type": "string", "value": "Glory Days"}} - ] - } -} diff --git a/src/vendor/toml/tests/valid/table-array-implicit.toml b/src/vendor/toml/tests/valid/table-array-implicit.toml deleted file mode 100644 index 3157ac981d3..00000000000 --- a/src/vendor/toml/tests/valid/table-array-implicit.toml +++ /dev/null @@ -1,2 +0,0 @@ -[[albums.songs]] -name = "Glory Days" diff --git a/src/vendor/toml/tests/valid/table-array-many.json b/src/vendor/toml/tests/valid/table-array-many.json deleted file mode 100644 index 84df2dabb0d..00000000000 --- a/src/vendor/toml/tests/valid/table-array-many.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "people": [ - { - "first_name": {"type": "string", "value": "Bruce"}, - "last_name": {"type": "string", "value": "Springsteen"} - }, - { - "first_name": {"type": "string", "value": "Eric"}, - "last_name": {"type": "string", "value": "Clapton"} - }, - { - "first_name": {"type": "string", "value": "Bob"}, - "last_name": {"type": "string", "value": "Seger"} - } - ] -} diff --git a/src/vendor/toml/tests/valid/table-array-many.toml b/src/vendor/toml/tests/valid/table-array-many.toml deleted file mode 100644 index 46062beb8e7..00000000000 --- a/src/vendor/toml/tests/valid/table-array-many.toml +++ /dev/null @@ -1,11 +0,0 @@ -[[people]] -first_name = "Bruce" -last_name = "Springsteen" - -[[people]] -first_name = "Eric" -last_name = "Clapton" - -[[people]] -first_name = "Bob" -last_name = "Seger" diff --git a/src/vendor/toml/tests/valid/table-array-nest.json b/src/vendor/toml/tests/valid/table-array-nest.json deleted file mode 100644 index c117afa40d4..00000000000 --- a/src/vendor/toml/tests/valid/table-array-nest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "albums": [ - { - "name": {"type": "string", "value": "Born to Run"}, - "songs": [ - {"name": {"type": "string", "value": "Jungleland"}}, - {"name": {"type": "string", "value": "Meeting Across the River"}} - ] - }, - { - "name": {"type": "string", "value": "Born in the USA"}, - "songs": [ - {"name": {"type": "string", "value": "Glory Days"}}, - {"name": {"type": "string", "value": "Dancing in the Dark"}} - ] - } - ] -} diff --git a/src/vendor/toml/tests/valid/table-array-nest.toml b/src/vendor/toml/tests/valid/table-array-nest.toml deleted file mode 100644 index d659a3d9470..00000000000 --- a/src/vendor/toml/tests/valid/table-array-nest.toml +++ /dev/null @@ -1,17 +0,0 @@ -[[albums]] -name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] -name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" diff --git a/src/vendor/toml/tests/valid/table-array-one.json b/src/vendor/toml/tests/valid/table-array-one.json deleted file mode 100644 index d75faaeb239..00000000000 --- a/src/vendor/toml/tests/valid/table-array-one.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "people": [ - { - "first_name": {"type": "string", "value": "Bruce"}, - "last_name": {"type": "string", "value": "Springsteen"} - } - ] -} diff --git a/src/vendor/toml/tests/valid/table-array-one.toml b/src/vendor/toml/tests/valid/table-array-one.toml deleted file mode 100644 index cd7e1b69071..00000000000 --- a/src/vendor/toml/tests/valid/table-array-one.toml +++ /dev/null @@ -1,3 +0,0 @@ -[[people]] -first_name = "Bruce" -last_name = "Springsteen" diff --git a/src/vendor/toml/tests/valid/table-empty.json b/src/vendor/toml/tests/valid/table-empty.json deleted file mode 100644 index 6f3873af6b2..00000000000 --- a/src/vendor/toml/tests/valid/table-empty.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a": {} -} diff --git a/src/vendor/toml/tests/valid/table-empty.toml b/src/vendor/toml/tests/valid/table-empty.toml deleted file mode 100644 index 8bb6a0aa07e..00000000000 --- a/src/vendor/toml/tests/valid/table-empty.toml +++ /dev/null @@ -1 +0,0 @@ -[a] diff --git a/src/vendor/toml/tests/valid/table-sub-empty.json b/src/vendor/toml/tests/valid/table-sub-empty.json deleted file mode 100644 index 97877708e6d..00000000000 --- a/src/vendor/toml/tests/valid/table-sub-empty.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a": { "b": {} } -} diff --git a/src/vendor/toml/tests/valid/table-sub-empty.toml b/src/vendor/toml/tests/valid/table-sub-empty.toml deleted file mode 100644 index 70b7fe11c3d..00000000000 --- a/src/vendor/toml/tests/valid/table-sub-empty.toml +++ /dev/null @@ -1,2 +0,0 @@ -[a] -[a.b] diff --git a/src/vendor/toml/tests/valid/table-whitespace.json b/src/vendor/toml/tests/valid/table-whitespace.json deleted file mode 100644 index 3a73ec86453..00000000000 --- a/src/vendor/toml/tests/valid/table-whitespace.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "valid key": {} -} diff --git a/src/vendor/toml/tests/valid/table-whitespace.toml b/src/vendor/toml/tests/valid/table-whitespace.toml deleted file mode 100644 index daf881d13a5..00000000000 --- a/src/vendor/toml/tests/valid/table-whitespace.toml +++ /dev/null @@ -1 +0,0 @@ -["valid key"] diff --git a/src/vendor/toml/tests/valid/table-with-pound.json b/src/vendor/toml/tests/valid/table-with-pound.json deleted file mode 100644 index 5e594e41919..00000000000 --- a/src/vendor/toml/tests/valid/table-with-pound.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "key#group": { - "answer": {"type": "integer", "value": "42"} - } -} diff --git a/src/vendor/toml/tests/valid/table-with-pound.toml b/src/vendor/toml/tests/valid/table-with-pound.toml deleted file mode 100644 index 33f2c4fd6cf..00000000000 --- a/src/vendor/toml/tests/valid/table-with-pound.toml +++ /dev/null @@ -1,2 +0,0 @@ -["key#group"] -answer = 42 diff --git a/src/vendor/toml/tests/valid/unicode-escape.json b/src/vendor/toml/tests/valid/unicode-escape.json deleted file mode 100644 index 8c09dc0aa93..00000000000 --- a/src/vendor/toml/tests/valid/unicode-escape.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "answer4": {"type": "string", "value": "\u03B4α"}, - "answer8": {"type": "string", "value": "\u03B4β"} -} diff --git a/src/vendor/toml/tests/valid/unicode-escape.toml b/src/vendor/toml/tests/valid/unicode-escape.toml deleted file mode 100644 index 20198f4a986..00000000000 --- a/src/vendor/toml/tests/valid/unicode-escape.toml +++ /dev/null @@ -1,2 +0,0 @@ -answer4 = "\u03B4α" -answer8 = "\U000003B4β" diff --git a/src/vendor/toml/tests/valid/unicode-literal.json b/src/vendor/toml/tests/valid/unicode-literal.json deleted file mode 100644 index 00aa2f8325e..00000000000 --- a/src/vendor/toml/tests/valid/unicode-literal.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "answer": {"type": "string", "value": "δ"} -} diff --git a/src/vendor/toml/tests/valid/unicode-literal.toml b/src/vendor/toml/tests/valid/unicode-literal.toml deleted file mode 100644 index c65723ca1d2..00000000000 --- a/src/vendor/toml/tests/valid/unicode-literal.toml +++ /dev/null @@ -1 +0,0 @@ -answer = "δ" |
